kernel: add linux 5.10 support
[openwrt/openwrt.git] / target / linux / generic / pending-5.10 / 640-10-net-dsa-resolve-forwarding-path-for-dsa-slave-ports.patch
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
4
5 Add .ndo_fill_forward_path for dsa slave port devices
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
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,
14 DEV_PATH_VLAN,
15 DEV_PATH_BRIDGE,
16 + DEV_PATH_DSA,
17 };
18
19 struct net_device_path {
20 @@ -856,6 +857,10 @@ struct net_device_path {
21 u16 vlan_id;
22 __be16 vlan_proto;
23 } bridge;
24 + struct {
25 + int port;
26 + u16 proto;
27 + } dsa;
28 };
29 };
30
31 --- a/net/dsa/slave.c
32 +++ b/net/dsa/slave.c
33 @@ -1582,6 +1582,21 @@ static struct devlink_port *dsa_slave_ge
34 return dp->ds->devlink ? &dp->devlink_port : NULL;
35 }
36
37 +static int dsa_slave_fill_forward_path(struct net_device_path_ctx *ctx,
38 + struct net_device_path *path)
39 +{
40 + struct dsa_port *dp = dsa_slave_to_port(ctx->dev);
41 + struct dsa_port *cpu_dp = dp->cpu_dp;
42 +
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;
48 +
49 + return 0;
50 +}
51 +
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,
60 };
61
62 static struct device_type dsa_type = {