Skip to content

Commit 65d63e8

Browse files
committed
Merge branch 'net-dsa-marvell-mtu-reporting'
Vladimir Oltean says: ==================== Fix MTU reporting for Marvell DSA switches where we can't change it As explained in patch 2, the driver doesn't know how to change the MTU on MV88E6165, MV88E6191, MV88E6220, MV88E6250 and MV88E6290, and there is a regression where it actually reports an MTU value below the Ethernet standard (1500). Fixing that shows another issue where DSA is unprepared to be told that a switch supports an MTU of only 1500, and still errors out. That is addressed by patch 1. Testing was not done on "real" hardware, but on a different Marvell DSA switch, with code modified such that the driver doesn't know how to change the MTU on that, either. A key assumption is that these switches don't need any MTU configuration to pass full MTU-sized, DSA-tagged packets, which seems like a reasonable assumption to make. My 6390 and 6190 switches, with .port_set_jumbo_size commented out, certainly don't seem to have any problem passing MTU-sized traffic, as can be seen in this iperf3 session captured with tcpdump on the DSA master: $MAC > $MAC, Marvell DSA mode Forward, dev 2, port 8, untagged, VID 1000, FPri 0, ethertype IPv4 (0x0800), length 1518: 10.0.0.69.49590 > 10.0.0.1.5201: Flags [.], seq 81088:82536, ack 1, win 502, options [nop,nop,TS val 2221498829 ecr 3012859850], length 1448 I don't want to go all the way and say that the adjustment made by commit b9c587f ("dsa: mv88e6xxx: Include tagger overhead when setting MTU for DSA and CPU ports") is completely unnecessary, just that there's an equally good chance that the switches with unknown MTU configuration procedure "just work". ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b830c96 + 7e95173 commit 65d63e8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,14 +3549,25 @@ static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
35493549
return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
35503550
else if (chip->info->ops->set_max_frame_size)
35513551
return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
3552-
return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
3552+
return ETH_DATA_LEN;
35533553
}
35543554

35553555
static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
35563556
{
35573557
struct mv88e6xxx_chip *chip = ds->priv;
35583558
int ret = 0;
35593559

3560+
/* For families where we don't know how to alter the MTU,
3561+
* just accept any value up to ETH_DATA_LEN
3562+
*/
3563+
if (!chip->info->ops->port_set_jumbo_size &&
3564+
!chip->info->ops->set_max_frame_size) {
3565+
if (new_mtu > ETH_DATA_LEN)
3566+
return -EINVAL;
3567+
3568+
return 0;
3569+
}
3570+
35603571
if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
35613572
new_mtu += EDSA_HLEN;
35623573

@@ -3565,9 +3576,6 @@ static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
35653576
ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
35663577
else if (chip->info->ops->set_max_frame_size)
35673578
ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
3568-
else
3569-
if (new_mtu > 1522)
3570-
ret = -EINVAL;
35713579
mv88e6xxx_reg_unlock(chip);
35723580

35733581
return ret;

net/dsa/slave.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
19331933
int new_master_mtu;
19341934
int old_master_mtu;
19351935
int mtu_limit;
1936+
int overhead;
19361937
int cpu_mtu;
19371938
int err;
19381939

@@ -1961,9 +1962,10 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
19611962
largest_mtu = slave_mtu;
19621963
}
19631964

1964-
mtu_limit = min_t(int, master->max_mtu, dev->max_mtu);
1965+
overhead = dsa_tag_protocol_overhead(cpu_dp->tag_ops);
1966+
mtu_limit = min_t(int, master->max_mtu, dev->max_mtu + overhead);
19651967
old_master_mtu = master->mtu;
1966-
new_master_mtu = largest_mtu + dsa_tag_protocol_overhead(cpu_dp->tag_ops);
1968+
new_master_mtu = largest_mtu + overhead;
19671969
if (new_master_mtu > mtu_limit)
19681970
return -ERANGE;
19691971

@@ -1998,8 +2000,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
19982000

19992001
out_port_failed:
20002002
if (new_master_mtu != old_master_mtu)
2001-
dsa_port_mtu_change(cpu_dp, old_master_mtu -
2002-
dsa_tag_protocol_overhead(cpu_dp->tag_ops));
2003+
dsa_port_mtu_change(cpu_dp, old_master_mtu - overhead);
20032004
out_cpu_failed:
20042005
if (new_master_mtu != old_master_mtu)
20052006
dev_set_mtu(master, old_master_mtu);

0 commit comments

Comments
 (0)