1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 7 Dec 2020 20:31:48 +0100
3 Subject: [PATCH] net: dsa: resolve forwarding path for dsa slave ports
5 Add .ndo_fill_forward_path for dsa slave port devices
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 --- a/include/linux/netdevice.h
11 +++ b/include/linux/netdevice.h
12 @@ -837,6 +837,7 @@ enum net_device_path_type {
13 DEV_PATH_ETHERNET = 0,
19 struct net_device_path {
20 @@ -856,6 +857,10 @@ struct net_device_path {
33 @@ -1582,6 +1582,21 @@ static struct devlink_port *dsa_slave_ge
34 return dp->ds->devlink ? &dp->devlink_port : NULL;
37 +static int dsa_slave_fill_forward_path(struct net_device_path_ctx *ctx,
38 + struct net_device_path *path)
40 + struct dsa_port *dp = dsa_slave_to_port(ctx->dev);
41 + struct dsa_port *cpu_dp = dp->cpu_dp;
43 + path->dev = ctx->dev;
44 + path->type = DEV_PATH_DSA;
45 + path->dsa.proto = cpu_dp->tag_ops->proto;
46 + path->dsa.port = dp->index;
47 + ctx->dev = cpu_dp->master;
52 static const struct net_device_ops dsa_slave_netdev_ops = {
53 .ndo_open = dsa_slave_open,
54 .ndo_stop = dsa_slave_close,
55 @@ -1607,6 +1622,7 @@ static const struct net_device_ops dsa_s
56 .ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
57 .ndo_get_devlink_port = dsa_slave_get_devlink_port,
58 .ndo_change_mtu = dsa_slave_change_mtu,
59 + .ndo_fill_forward_path = dsa_slave_fill_forward_path,
62 static struct device_type dsa_type = {