From: Vladimir Oltean <olteanv@gmail.com>
To: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com,
davem@davemloft.net, o.rempel@pengutronix.de
Cc: netdev@vger.kernel.org
Subject: [PATCH net 1/2] net: dsa: be compatible with DSA masters with max_mtu of 1500 or less
Date: Tue, 21 Apr 2020 15:31:09 +0300 [thread overview]
Message-ID: <20200421123110.13733-2-olteanv@gmail.com> (raw)
In-Reply-To: <20200421123110.13733-1-olteanv@gmail.com>
From: Vladimir Oltean <vladimir.oltean@nxp.com>
It would be ideal if the DSA switch ports would support an MTU of 1500
bytes by default, same as any other net device. But there are 2 cases of
issues with trying to do that:
- Drivers that are legitimately MTU-challenged and don't support
anything larger than ETH_DATA_LEN. A very quick search shows that
sungem.c is one such example - there may be many others.
- Drivers that simply don't populate netdev->max_mtu. In that case, it
seems that the ether_setup function sets dev->max_mtu to a default
value of ETH_DATA_LEN. And due to the above cases which really are
MTU-challenged, we can't really make any guesses.
So for these cases, if the max_mtu of the master net_device is lower
than 1500, use that (minus the tagger overhead) as the max MTU of the
switch ports.
Fixes: bfcb813203e6 ("net: dsa: configure the MTU for switch ports")
Reported-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
net/dsa/slave.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index e94eb1aac602..3776a6f6d312 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1723,6 +1723,7 @@ int dsa_slave_create(struct dsa_port *port)
const char *name = port->name;
struct net_device *slave_dev;
struct dsa_slave_priv *p;
+ int mtu;
int ret;
if (!ds->num_tx_queues)
@@ -1767,8 +1768,10 @@ int dsa_slave_create(struct dsa_port *port)
p->xmit = cpu_dp->tag_ops->xmit;
port->slave = slave_dev;
+ mtu = min_t(int, master->max_mtu - cpu_dp->tag_ops->overhead,
+ ETH_DATA_LEN);
rtnl_lock();
- ret = dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN);
+ ret = dsa_slave_change_mtu(slave_dev, mtu);
rtnl_unlock();
if (ret && ret != -EOPNOTSUPP) {
dev_err(ds->dev, "error %d setting MTU on port %d\n",
--
2.17.1
next prev parent reply other threads:[~2020-04-21 12:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-21 12:31 [PATCH net 0/2] MTU fixes for DSA Vladimir Oltean
2020-04-21 12:31 ` Vladimir Oltean [this message]
2020-04-21 13:33 ` [PATCH net 1/2] net: dsa: be compatible with DSA masters with max_mtu of 1500 or less Andrew Lunn
2020-04-21 13:42 ` Vladimir Oltean
2020-04-21 14:06 ` Andrew Lunn
2020-04-21 14:24 ` Vladimir Oltean
2020-04-21 14:50 ` Andrew Lunn
2020-04-21 12:31 ` [PATCH net 2/2] net: dsa: don't fail to probe if we couldn't set the MTU 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=20200421123110.13733-2-olteanv@gmail.com \
--to=olteanv@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=vivien.didelot@gmail.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).