1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 24 Mar 2021 02:30:37 +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>
8 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 --- a/include/linux/netdevice.h
12 +++ b/include/linux/netdevice.h
13 @@ -846,6 +846,7 @@ enum net_device_path_type {
20 struct net_device_path {
21 @@ -866,6 +867,10 @@ struct net_device_path {
34 @@ -1619,6 +1619,21 @@ static struct devlink_port *dsa_slave_ge
35 return dp->ds->devlink ? &dp->devlink_port : NULL;
38 +static int dsa_slave_fill_forward_path(struct net_device_path_ctx *ctx,
39 + struct net_device_path *path)
41 + struct dsa_port *dp = dsa_slave_to_port(ctx->dev);
42 + struct dsa_port *cpu_dp = dp->cpu_dp;
44 + path->dev = ctx->dev;
45 + path->type = DEV_PATH_DSA;
46 + path->dsa.proto = cpu_dp->tag_ops->proto;
47 + path->dsa.port = dp->index;
48 + ctx->dev = cpu_dp->master;
53 static const struct net_device_ops dsa_slave_netdev_ops = {
54 .ndo_open = dsa_slave_open,
55 .ndo_stop = dsa_slave_close,
56 @@ -1644,6 +1659,7 @@ static const struct net_device_ops dsa_s
57 .ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
58 .ndo_get_devlink_port = dsa_slave_get_devlink_port,
59 .ndo_change_mtu = dsa_slave_change_mtu,
60 + .ndo_fill_forward_path = dsa_slave_fill_forward_path,
63 static struct device_type dsa_type = {