1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 4 Mar 2021 23:19:06 +0100
3 Subject: [PATCH] net: dsa: resolve forwarding path for dsa slave ports
5 Add .ndo_fill_forward_path for dsa slave port devices
8 --- a/include/linux/netdevice.h
9 +++ b/include/linux/netdevice.h
10 @@ -832,6 +832,7 @@ enum net_device_path_type {
17 struct net_device_path {
18 @@ -851,6 +852,10 @@ struct net_device_path {
31 @@ -1582,6 +1582,21 @@ static struct devlink_port *dsa_slave_ge
32 return dp->ds->devlink ? &dp->devlink_port : NULL;
35 +static int dsa_slave_fill_forward_path(struct net_device_path_ctx *ctx,
36 + struct net_device_path *path)
38 + struct dsa_port *dp = dsa_slave_to_port(ctx->dev);
39 + struct dsa_port *cpu_dp = dp->cpu_dp;
41 + path->dev = ctx->dev;
42 + path->type = DEV_PATH_DSA;
43 + path->dsa.proto = cpu_dp->tag_ops->proto;
44 + path->dsa.port = dp->index;
45 + ctx->dev = cpu_dp->master;
50 static const struct net_device_ops dsa_slave_netdev_ops = {
51 .ndo_open = dsa_slave_open,
52 .ndo_stop = dsa_slave_close,
53 @@ -1607,6 +1622,7 @@ static const struct net_device_ops dsa_s
54 .ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
55 .ndo_get_devlink_port = dsa_slave_get_devlink_port,
56 .ndo_change_mtu = dsa_slave_change_mtu,
57 + .ndo_fill_forward_path = dsa_slave_fill_forward_path,
60 static struct device_type dsa_type = {