提交 066dfc42 编写于 作者: V Vladimir Oltean 提交者: David S. Miller

Revert "net: dsa: stop updating master MTU from master.c"

This reverts commit a1ff94c2.

Switch drivers that don't implement ->port_change_mtu() will cause the
DSA master to remain with an MTU of 1500, since we've deleted the other
code path. In turn, this causes a regression for those systems, where
MTU-sized traffic can no longer be terminated.

Revert the change taking into account the fact that rtnl_lock() is now
taken top-level from the callers of dsa_master_setup() and
dsa_master_teardown(). Also add a comment in order for it to be
absolutely clear why it is still needed.

Fixes: a1ff94c2 ("net: dsa: stop updating master MTU from master.c")
Reported-by: NLuiz Angelo Daros de Luca <luizluca@gmail.com>
Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: NLuiz Angelo Daros de Luca <luizluca@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 1effe8ca
...@@ -335,11 +335,24 @@ static const struct attribute_group dsa_group = { ...@@ -335,11 +335,24 @@ static const struct attribute_group dsa_group = {
.attrs = dsa_slave_attrs, .attrs = dsa_slave_attrs,
}; };
static void dsa_master_reset_mtu(struct net_device *dev)
{
int err;
err = dev_set_mtu(dev, ETH_DATA_LEN);
if (err)
netdev_dbg(dev,
"Unable to reset MTU to exclude DSA overheads\n");
}
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
{ {
const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;
struct dsa_switch *ds = cpu_dp->ds; struct dsa_switch *ds = cpu_dp->ds;
struct device_link *consumer_link; struct device_link *consumer_link;
int ret; int mtu, ret;
mtu = ETH_DATA_LEN + dsa_tag_protocol_overhead(tag_ops);
/* The DSA master must use SET_NETDEV_DEV for this to work. */ /* The DSA master must use SET_NETDEV_DEV for this to work. */
consumer_link = device_link_add(ds->dev, dev->dev.parent, consumer_link = device_link_add(ds->dev, dev->dev.parent,
...@@ -349,6 +362,15 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) ...@@ -349,6 +362,15 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
"Failed to create a device link to DSA switch %s\n", "Failed to create a device link to DSA switch %s\n",
dev_name(ds->dev)); dev_name(ds->dev));
/* The switch driver may not implement ->port_change_mtu(), case in
* which dsa_slave_change_mtu() will not update the master MTU either,
* so we need to do that here.
*/
ret = dev_set_mtu(dev, mtu);
if (ret)
netdev_warn(dev, "error %d setting MTU to %d to include DSA overhead\n",
ret, mtu);
/* If we use a tagging format that doesn't have an ethertype /* If we use a tagging format that doesn't have an ethertype
* field, make sure that all packets from this point on get * field, make sure that all packets from this point on get
* sent to the tag format's receive function. * sent to the tag format's receive function.
...@@ -384,6 +406,7 @@ void dsa_master_teardown(struct net_device *dev) ...@@ -384,6 +406,7 @@ void dsa_master_teardown(struct net_device *dev)
sysfs_remove_group(&dev->dev.kobj, &dsa_group); sysfs_remove_group(&dev->dev.kobj, &dsa_group);
dsa_netdev_ops_set(dev, NULL); dsa_netdev_ops_set(dev, NULL);
dsa_master_ethtool_teardown(dev); dsa_master_ethtool_teardown(dev);
dsa_master_reset_mtu(dev);
dsa_master_set_promiscuity(dev, -1); dsa_master_set_promiscuity(dev, -1);
dev->dsa_ptr = NULL; dev->dsa_ptr = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册