From: Jakub Kicinski <kuba@kernel.org>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Jonathan McDowell <noodles@earth.li>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change
Date: Mon, 20 Jun 2022 21:56:19 -0700 [thread overview]
Message-ID: <20220620215619.2209533a@kernel.org> (raw)
In-Reply-To: <20220618072650.3502-3-ansuelsmth@gmail.com>
On Sat, 18 Jun 2022 09:26:50 +0200 Christian Marangi wrote:
> It was discovered that the Documentation lacks of a fundamental detail
> on how to correctly change the MAX_FRAME_SIZE of the switch.
>
> In fact if the MAX_FRAME_SIZE is changed while the cpu port is on, the
> switch panics and cease to send any packet. This cause the mgmt ethernet
> system to not receive any packet (the slow fallback still works) and
> makes the device not reachable. To recover from this a switch reset is
> required.
>
> To correctly handle this, turn off the cpu ports before changing the
> MAX_FRAME_SIZE and turn on again after the value is applied.
>
> Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
It reads like this patch should be backported to 5.10 and 5.15 stable
branches. While patches 1 and 2 are cleanups. In which case you should
reports just patch 3 against net/master first, we'll send it to Linus at
the end of the week and then you can send the cleanups on top for -next.
One extra question below.
> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index eaaf80f96fa9..0b92b9d5954a 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -2334,6 +2334,7 @@ static int
> qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> {
> struct qca8k_priv *priv = ds->priv;
> + int ret;
>
> /* We have only have a general MTU setting.
> * DSA always set the CPU port's MTU to the largest MTU of the slave
> @@ -2344,10 +2345,29 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> if (!dsa_is_cpu_port(ds, port))
> return 0;
>
> + /* To change the MAX_FRAME_SIZE the cpu ports must be off or
> + * the switch panics.
> + * Turn off both cpu ports before applying the new value to prevent
> + * this.
> + */
> + if (priv->port_enabled_map & BIT(0))
> + qca8k_port_set_status(priv, 0, 0);
> +
> + if (priv->port_enabled_map & BIT(6))
> + qca8k_port_set_status(priv, 6, 0);
> +
> /* Include L2 header / FCS length */
> - return regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
> - QCA8K_MAX_FRAME_SIZE_MASK,
> - new_mtu + ETH_HLEN + ETH_FCS_LEN);
> + ret = regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
Why care about the return code of this regmap access but not the ones
inside the *port_set_status() calls?
> + QCA8K_MAX_FRAME_SIZE_MASK,
> + new_mtu + ETH_HLEN + ETH_FCS_LEN);
> +
> + if (priv->port_enabled_map & BIT(0))
> + qca8k_port_set_status(priv, 0, 1);
> +
> + if (priv->port_enabled_map & BIT(6))
> + qca8k_port_set_status(priv, 6, 1);
> +
> + return ret;
> }
>
> static int
next prev parent reply other threads:[~2022-06-21 4:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-18 7:26 [RESEND net-next PATCH 1/3] net: dsa: qca8k: reduce mgmt ethernet timeout Christian Marangi
2022-06-18 7:26 ` [RESEND net-next PATCH 2/3] net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg Christian Marangi
2022-06-18 7:26 ` [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change Christian Marangi
2022-06-21 4:56 ` Jakub Kicinski [this message]
2022-06-21 14:51 ` Christian Marangi
2022-06-21 15:04 ` Christian Marangi
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=20220620215619.2209533a@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noodles@earth.li \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--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).