765-v5.17-03-net-next-net-dsa-stop-updating-master-MTU-from-master.c.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From a1ff94c2973c43bc1e2677ac63ebb15b1d1ff846 Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  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. At present there are two paths for changing the MTU of the DSA master.
  6. The first is:
  7. dsa_tree_setup
  8. -> dsa_tree_setup_ports
  9. -> dsa_port_setup
  10. -> dsa_slave_create
  11. -> dsa_slave_change_mtu
  12. -> dev_set_mtu(master)
  13. The second is:
  14. dsa_tree_setup
  15. -> dsa_tree_setup_master
  16. -> dsa_master_setup
  17. -> dev_set_mtu(dev)
  18. So the dev_set_mtu() call from dsa_master_setup() has been effectively
  19. superseded by the dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN) that is
  20. done from dsa_slave_create() for each user port. The later function also
  21. updates the master MTU according to the largest user port MTU from the
  22. tree. Therefore, updating the master MTU through a separate code path
  23. isn't needed.
  24. Signed-off-by: Vladimir Oltean <[email protected]>
  25. Reviewed-by: Florian Fainelli <[email protected]>
  26. Signed-off-by: David S. Miller <[email protected]>
  27. ---
  28. net/dsa/master.c | 25 +------------------------
  29. 1 file changed, 1 insertion(+), 24 deletions(-)
  30. --- a/net/dsa/master.c
  31. +++ b/net/dsa/master.c
  32. @@ -329,28 +329,13 @@ static const struct attribute_group dsa_
  33. .attrs = dsa_slave_attrs,
  34. };
  35. -static void dsa_master_reset_mtu(struct net_device *dev)
  36. -{
  37. - int err;
  38. -
  39. - rtnl_lock();
  40. - err = dev_set_mtu(dev, ETH_DATA_LEN);
  41. - if (err)
  42. - netdev_dbg(dev,
  43. - "Unable to reset MTU to exclude DSA overheads\n");
  44. - rtnl_unlock();
  45. -}
  46. -
  47. static struct lock_class_key dsa_master_addr_list_lock_key;
  48. int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
  49. {
  50. - const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;
  51. struct dsa_switch *ds = cpu_dp->ds;
  52. struct device_link *consumer_link;
  53. - int mtu, ret;
  54. -
  55. - mtu = ETH_DATA_LEN + dsa_tag_protocol_overhead(tag_ops);
  56. + int ret;
  57. /* The DSA master must use SET_NETDEV_DEV for this to work. */
  58. consumer_link = device_link_add(ds->dev, dev->dev.parent,
  59. @@ -360,13 +345,6 @@ int dsa_master_setup(struct net_device *
  60. "Failed to create a device link to DSA switch %s\n",
  61. dev_name(ds->dev));
  62. - rtnl_lock();
  63. - ret = dev_set_mtu(dev, mtu);
  64. - rtnl_unlock();
  65. - if (ret)
  66. - netdev_warn(dev, "error %d setting MTU to %d to include DSA overhead\n",
  67. - ret, mtu);
  68. -
  69. /* If we use a tagging format that doesn't have an ethertype
  70. * field, make sure that all packets from this point on get
  71. * sent to the tag format's receive function.
  72. @@ -404,7 +382,6 @@ void dsa_master_teardown(struct net_devi
  73. sysfs_remove_group(&dev->dev.kobj, &dsa_group);
  74. dsa_netdev_ops_set(dev, NULL);
  75. dsa_master_ethtool_teardown(dev);
  76. - dsa_master_reset_mtu(dev);
  77. dsa_master_set_promiscuity(dev, -1);
  78. dev->dsa_ptr = NULL;