Skip to content

Commit

Permalink
dsa: mv88e6xxx: Include tagger overhead when setting MTU for DSA and …
Browse files Browse the repository at this point in the history
…CPU ports

[ Upstream commit b9c587f ]

Same members of the Marvell Ethernet switches impose MTU restrictions
on ports used for connecting to the CPU or another switch for DSA. If
the MTU is set too low, tagged frames will be discarded. Ensure the
worst case tagger overhead is included in setting the MTU for DSA and
CPU ports.

Fixes: 1baf0fa ("net: dsa: mv88e6xxx: Use chip-wide max frame size for MTU")
Reported by: 曹煜 <cao88yu@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
lunn authored and gregkh committed Oct 6, 2021
1 parent 7b771b1 commit c20a0ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/dsa/mv88e6xxx/chip.c
Expand Up @@ -2718,17 +2718,20 @@ static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
struct mv88e6xxx_chip *chip = ds->priv;

if (chip->info->ops->port_set_jumbo_size)
return 10240 - VLAN_ETH_HLEN - ETH_FCS_LEN;
return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
else if (chip->info->ops->set_max_frame_size)
return 1632 - VLAN_ETH_HLEN - ETH_FCS_LEN;
return 1522 - VLAN_ETH_HLEN - ETH_FCS_LEN;
return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
}

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

if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
new_mtu += EDSA_HLEN;

mv88e6xxx_reg_lock(chip);
if (chip->info->ops->port_set_jumbo_size)
ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/dsa/mv88e6xxx/chip.h
Expand Up @@ -18,6 +18,7 @@
#include <linux/timecounter.h>
#include <net/dsa.h>

#define EDSA_HLEN 8
#define MV88E6XXX_N_FID 4096

/* PVT limits for 4-bit port and 5-bit switch */
Expand Down

0 comments on commit c20a0ad

Please sign in to comment.