c8f0a32dd962960ea727f716607ffed4059a6c56
[openwrt/staging/noltari.git] / target / linux / generic / pending-5.10 / 640-12-net-dsa-resolve-forwarding-path-for-dsa-slave-ports.patch
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
4
5 Add .ndo_fill_forward_path for dsa slave port devices
6 ---
7
8 --- a/include/linux/netdevice.h
9 +++ b/include/linux/netdevice.h
10 @@ -832,6 +832,7 @@ enum net_device_path_type {
11 DEV_PATH_VLAN,
12 DEV_PATH_BRIDGE,
13 DEV_PATH_PPPOE,
14 + DEV_PATH_DSA,
15 };
16
17 struct net_device_path {
18 @@ -851,6 +852,10 @@ struct net_device_path {
19 u16 vlan_id;
20 __be16 vlan_proto;
21 } bridge;
22 + struct {
23 + int port;
24 + u16 proto;
25 + } dsa;
26 };
27 };
28
29 --- a/net/dsa/slave.c
30 +++ b/net/dsa/slave.c
31 @@ -1582,6 +1582,21 @@ static struct devlink_port *dsa_slave_ge
32 return dp->ds->devlink ? &dp->devlink_port : NULL;
33 }
34
35 +static int dsa_slave_fill_forward_path(struct net_device_path_ctx *ctx,
36 + struct net_device_path *path)
37 +{
38 + struct dsa_port *dp = dsa_slave_to_port(ctx->dev);
39 + struct dsa_port *cpu_dp = dp->cpu_dp;
40 +
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;
46 +
47 + return 0;
48 +}
49 +
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,
58 };
59
60 static struct device_type dsa_type = {