kernel: add linux 5.10 support
[openwrt/openwrt.git] / target / linux / generic / pending-5.10 / 640-13-dsa-slave-add-support-for-TC_SETUP_FT.patch
1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Mon, 18 Jan 2021 22:39:17 +0100
3 Subject: [PATCH] dsa: slave: add support for TC_SETUP_FT
4
5 The dsa infrastructure provides a well-defined hierarchy of devices,
6 pass up the call to set up the flow block to the master device. From the
7 software dataplane, the netfilter infrastructure uses the dsa slave
8 devices to refer to the input and output device for the given skbuff.
9 Similarly, the flowtable definition in the ruleset refers to the dsa
10 slave port devices.
11
12 This patch adds the glue code to call ndo_setup_tc with TC_SETUP_FT
13 with the master device via the dsa slave devices.
14
15 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
16 ---
17
18 --- a/net/dsa/slave.c
19 +++ b/net/dsa/slave.c
20 @@ -1202,14 +1202,32 @@ static int dsa_slave_setup_tc_block(stru
21 }
22 }
23
24 +static int dsa_slave_setup_ft_block(struct dsa_switch *ds, int port,
25 + void *type_data)
26 +{
27 + struct dsa_port *cpu_dp = dsa_to_port(ds, port)->cpu_dp;
28 + struct net_device *master = cpu_dp->master;
29 +
30 + if (!master->netdev_ops->ndo_setup_tc)
31 + return -EOPNOTSUPP;
32 +
33 + return master->netdev_ops->ndo_setup_tc(master, TC_SETUP_FT, type_data);
34 +}
35 +
36 static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
37 void *type_data)
38 {
39 struct dsa_port *dp = dsa_slave_to_port(dev);
40 struct dsa_switch *ds = dp->ds;
41
42 - if (type == TC_SETUP_BLOCK)
43 + switch (type) {
44 + case TC_SETUP_BLOCK:
45 return dsa_slave_setup_tc_block(dev, type_data);
46 + case TC_SETUP_FT:
47 + return dsa_slave_setup_ft_block(ds, dp->index, type_data);
48 + default:
49 + break;
50 + }
51
52 if (!ds->ops->port_setup_tc)
53 return -EOPNOTSUPP;