[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210524213313.1437891-4-andrew@lunn.ch>
Date: Mon, 24 May 2021 23:33:13 +0200
From: Andrew Lunn <andrew@...n.ch>
To: David Miller <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: netdev <netdev@...r.kernel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <vladimir.oltean@....com>, cao88yu@...il.com,
Andrew Lunn <andrew@...n.ch>
Subject: [PATCH net 3/3] net: dsa: Include tagger overhead when setting MTU for DSA and CPU ports
Same members of the Marvell Ethernet switches impose MTU restrictions
on ports used for connecting to the CPU or DSA. If the MTU is set too
low, tagged frames will be discarded. Ensure the tagger overhead is
included in setting the MTU for DSA and CPU ports.
Fixes: 1baf0fac10fb ("net: dsa: mv88e6xxx: Use chip-wide max frame size for MTU")
Reported by: 曹煜 <cao88yu@...il.com>
Signed-off-by: Andrew Lunn <andrew@...n.ch>
---
net/dsa/switch.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 9bf8e20ecdf3..48c737b0b802 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -67,14 +67,26 @@ static bool dsa_switch_mtu_match(struct dsa_switch *ds, int port,
static int dsa_switch_mtu(struct dsa_switch *ds,
struct dsa_notifier_mtu_info *info)
{
- int port, ret;
+ struct dsa_port *cpu_dp;
+ int port, ret, overhead;
if (!ds->ops->port_change_mtu)
return -EOPNOTSUPP;
for (port = 0; port < ds->num_ports; port++) {
if (dsa_switch_mtu_match(ds, port, info)) {
- ret = ds->ops->port_change_mtu(ds, port, info->mtu);
+ overhead = 0;
+ if (dsa_is_cpu_port(ds, port)) {
+ cpu_dp = dsa_to_port(ds, port);
+ overhead = cpu_dp->tag_ops->overhead;
+ }
+ if (dsa_is_dsa_port(ds, port)) {
+ cpu_dp = dsa_to_port(ds, port)->cpu_dp;
+ overhead = cpu_dp->tag_ops->overhead;
+ }
+
+ ret = ds->ops->port_change_mtu(ds, port,
+ info->mtu + overhead);
if (ret)
return ret;
}
--
2.31.1
Powered by blists - more mailing lists