Skip to content

Commit 066dfc4

Browse files
vladimirolteandavem330
authored andcommitted
Revert "net: dsa: stop updating master MTU from master.c"
This reverts commit a1ff94c. 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: a1ff94c ("net: dsa: stop updating master MTU from master.c") Reported-by: Luiz Angelo Daros de Luca <luizluca@gmail.com> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Tested-by: Luiz Angelo Daros de Luca <luizluca@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1effe8c commit 066dfc4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

net/dsa/master.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,24 @@ static const struct attribute_group dsa_group = {
335335
.attrs = dsa_slave_attrs,
336336
};
337337

338+
static void dsa_master_reset_mtu(struct net_device *dev)
339+
{
340+
int err;
341+
342+
err = dev_set_mtu(dev, ETH_DATA_LEN);
343+
if (err)
344+
netdev_dbg(dev,
345+
"Unable to reset MTU to exclude DSA overheads\n");
346+
}
347+
338348
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
339349
{
350+
const struct dsa_device_ops *tag_ops = cpu_dp->tag_ops;
340351
struct dsa_switch *ds = cpu_dp->ds;
341352
struct device_link *consumer_link;
342-
int ret;
353+
int mtu, ret;
354+
355+
mtu = ETH_DATA_LEN + dsa_tag_protocol_overhead(tag_ops);
343356

344357
/* The DSA master must use SET_NETDEV_DEV for this to work. */
345358
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)
349362
"Failed to create a device link to DSA switch %s\n",
350363
dev_name(ds->dev));
351364

365+
/* The switch driver may not implement ->port_change_mtu(), case in
366+
* which dsa_slave_change_mtu() will not update the master MTU either,
367+
* so we need to do that here.
368+
*/
369+
ret = dev_set_mtu(dev, mtu);
370+
if (ret)
371+
netdev_warn(dev, "error %d setting MTU to %d to include DSA overhead\n",
372+
ret, mtu);
373+
352374
/* If we use a tagging format that doesn't have an ethertype
353375
* field, make sure that all packets from this point on get
354376
* sent to the tag format's receive function.
@@ -384,6 +406,7 @@ void dsa_master_teardown(struct net_device *dev)
384406
sysfs_remove_group(&dev->dev.kobj, &dsa_group);
385407
dsa_netdev_ops_set(dev, NULL);
386408
dsa_master_ethtool_teardown(dev);
409+
dsa_master_reset_mtu(dev);
387410
dsa_master_set_promiscuity(dev, -1);
388411

389412
dev->dsa_ptr = NULL;

0 commit comments

Comments
 (0)