d1126de5dd077086c7a84f9aa2e869994e5e3be7
[openwrt/staging/ansuel.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 --- a/net/dsa/master.c
39 +++ b/net/dsa/master.c
40 @@ -330,28 +330,13 @@ static const struct attribute_group dsa_
41 .attrs = dsa_slave_attrs,
42 };
43
44 -static void dsa_master_reset_mtu(struct net_device *dev)
45 -{
46 - int err;
47 -
48 - rtnl_lock();
49 - err = dev_set_mtu(dev, ETH_DATA_LEN);
50 - if (err)
51 - netdev_dbg(dev,
52 - "Unable to reset MTU to exclude DSA overheads\n");
53 - rtnl_unlock();
54 -}
55 -
56 static struct lock_class_key dsa_master_addr_list_lock_key;
57
58 int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
59 {
60 - const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;
61 struct dsa_switch *ds = cpu_dp->ds;
62 struct device_link *consumer_link;
63 - int mtu, ret;
64 -
65 - mtu = ETH_DATA_LEN + dsa_tag_protocol_overhead(tag_ops);
66 + int ret;
67
68 /* The DSA master must use SET_NETDEV_DEV for this to work. */
69 consumer_link = device_link_add(ds->dev, dev->dev.parent,
70 @@ -361,13 +346,6 @@ int dsa_master_setup(struct net_device *
71 "Failed to create a device link to DSA switch %s\n",
72 dev_name(ds->dev));
73
74 - rtnl_lock();
75 - ret = dev_set_mtu(dev, mtu);
76 - rtnl_unlock();
77 - if (ret)
78 - netdev_warn(dev, "error %d setting MTU to %d to include DSA overhead\n",
79 - ret, mtu);
80 -
81 /* If we use a tagging format that doesn't have an ethertype
82 * field, make sure that all packets from this point on get
83 * sent to the tag format's receive function.
84 @@ -405,7 +383,6 @@ void dsa_master_teardown(struct net_devi
85 sysfs_remove_group(&dev->dev.kobj, &dsa_group);
86 dsa_netdev_ops_set(dev, NULL);
87 dsa_master_ethtool_teardown(dev);
88 - dsa_master_reset_mtu(dev);
89 dsa_master_set_promiscuity(dev, -1);
90
91 dev->dsa_ptr = NULL;