c81bedaaf88d80e749d06a00e3e12ce6e5b67225
[openwrt/staging/xback.git] /
1 From a1ff94c2973c43bc1e2677ac63ebb15b1d1ff846 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Thu, 6 Jan 2022 01:11:14 +0200
4 Subject: [PATCH 3/6] net: dsa: stop updating master MTU from master.c
5
6 At present there are two paths for changing the MTU of the DSA master.
7
8 The first is:
9
10 dsa_tree_setup
11 -> dsa_tree_setup_ports
12 -> dsa_port_setup
13 -> dsa_slave_create
14 -> dsa_slave_change_mtu
15 -> dev_set_mtu(master)
16
17 The second is:
18
19 dsa_tree_setup
20 -> dsa_tree_setup_master
21 -> dsa_master_setup
22 -> dev_set_mtu(dev)
23
24 So the dev_set_mtu() call from dsa_master_setup() has been effectively
25 superseded by the dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN) that is
26 done from dsa_slave_create() for each user port. The later function also
27 updates the master MTU according to the largest user port MTU from the
28 tree. Therefore, updating the master MTU through a separate code path
29 isn't needed.
30
31 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
32 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
33 Signed-off-by: David S. Miller <davem@davemloft.net>
34 ---
35 net/dsa/master.c | 25 +------------------------
36 1 file changed, 1 insertion(+), 24 deletions(-)
37
38 diff --git a/net/dsa/master.c b/net/dsa/master.c
39 index e8e19857621b..f4efb244f91d 100644
40 --- a/net/dsa/master.c
41 +++ b/net/dsa/master.c
42 @@ -330,28 +330,13 @@ static const struct attribute_group dsa_group = {
43 .attrs = dsa_slave_attrs,
44 };
45
46 -static void dsa_master_reset_mtu(struct net_device *dev)
47 -{
48 - int err;
49 -
50 - rtnl_lock();
51 - err = dev_set_mtu(dev, ETH_DATA_LEN);
52 - if (err)
53 - netdev_dbg(dev,
54 - "Unable to reset MTU to exclude DSA overheads\n");
55 - rtnl_unlock();
56 -}
57 -
58 static struct lock_class_key dsa_master_addr_list_lock_key;
59
60 int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
61 {
62 - const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;
63 struct dsa_switch *ds = cpu_dp->ds;
64 struct device_link *consumer_link;
65 - int mtu, ret;
66 -
67 - mtu = ETH_DATA_LEN + dsa_tag_protocol_overhead(tag_ops);
68 + int ret;
69
70 /* The DSA master must use SET_NETDEV_DEV for this to work. */
71 consumer_link = device_link_add(ds->dev, dev->dev.parent,
72 @@ -361,13 +346,6 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
73 "Failed to create a device link to DSA switch %s\n",
74 dev_name(ds->dev));
75
76 - rtnl_lock();
77 - ret = dev_set_mtu(dev, mtu);
78 - rtnl_unlock();
79 - if (ret)
80 - netdev_warn(dev, "error %d setting MTU to %d to include DSA overhead\n",
81 - ret, mtu);
82 -
83 /* If we use a tagging format that doesn't have an ethertype
84 * field, make sure that all packets from this point on get
85 * sent to the tag format's receive function.
86 @@ -405,7 +383,6 @@ void dsa_master_teardown(struct net_device *dev)
87 sysfs_remove_group(&dev->dev.kobj, &dsa_group);
88 dsa_netdev_ops_set(dev, NULL);
89 dsa_master_ethtool_teardown(dev);
90 - dsa_master_reset_mtu(dev);
91 dsa_master_set_promiscuity(dev, -1);
92
93 dev->dsa_ptr = NULL;
94 --
95 2.34.1
96