netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>
Cc: netdev <netdev@vger.kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	cao88yu@gmail.com, Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH net 3/3] net: dsa: Include tagger overhead when setting MTU for DSA and CPU ports
Date: Mon, 24 May 2021 23:33:13 +0200	[thread overview]
Message-ID: <20210524213313.1437891-4-andrew@lunn.ch> (raw)
In-Reply-To: <20210524213313.1437891-1-andrew@lunn.ch>

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@gmail.com>
Signed-off-by: Andrew Lunn <andrew@lunn.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


  parent reply	other threads:[~2021-05-24 21:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 21:33 [PATCH net 0/3] MTU fixes for mv88e6xxx Andrew Lunn
2021-05-24 21:33 ` [PATCH net 1/3] dsa: mv88e6xxx: 6161: Use chip wide MAX MTU Andrew Lunn
2021-05-24 21:33 ` [PATCH net 2/3] dsa: mv88e6xxx: Fix MTU definition Andrew Lunn
2021-05-24 21:54   ` Vladimir Oltean
2021-05-24 21:33 ` Andrew Lunn [this message]
2021-05-24 22:04   ` [PATCH net 3/3] net: dsa: Include tagger overhead when setting MTU for DSA and CPU ports Vladimir Oltean
2021-05-25  2:53     ` Andrew Lunn
2021-05-25  9:10       ` Vladimir Oltean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210524213313.1437891-4-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=cao88yu@gmail.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).