From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Lai Peter Jun Ann <jun.ann.lai@intel.com>
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net] net: stmmac: do not toggle RX VLAN offload while running
Date: Sun, 6 Dec 2026 06:56:41 +0100 [thread overview]
Message-ID: <5d6b1d95-d942-4cb8-b452-29f980223c27@bootlin.com> (raw)
In-Reply-To: <20261205-stmmac-do-not-flip-vlan-offload-v1-1-5b3fa52c306b@oss.qualcomm.com>
Hi Lorenzo,
On 12/5/26 18:26, Lorenzo Bianconi wrote:
> The RX VLAN offload mode is consumed by the receive path: stmmac_rx()
> and stmmac_dispatch_skb_zc() use hw_vlan_en to decide whether to take
> the VLAN tag from the RX descriptor, and the software stripping path
> uses the advertised RX VLAN feature bits.
>
> stmmac_set_features() changes that state at runtime, while RX NAPI can
> run concurrently. A frame received with one setting can therefore be
> processed after the setting has changed, which may lose a tag that was
> stripped or duplicate a tag that is still in the frame. The MAC register
> update also cannot be made atomic with respect to frames already in
> flight without stopping RX DMA and flushing the descriptor rings.
>
> Since this is an RX offload mode change and there is no cheap way to
> synchronize it with the receive path, only allow it while the interface
> is down. Mask the RX VLAN feature bits back to their currently advertised
> state in stmmac_fix_features() when the device is running, so
> ndo_set_features() never changes the mode under a live RX path. A request
> made while the interface is running is ignored and is not deferred to the
> next open; userspace must bring the interface down to change the RX VLAN
> offload.
>
> Fixes: 750011e239a5 ("net: stmmac: Add support for HW-accelerated VLAN stripping")
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
This triggered some new failures on the Netdev CI for 6 stmmac runners:
- https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-rk3568/test-outputs/24-vlan-py/
- https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-imx8mp/test-outputs/24-vlan-py/
- https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-jh7110/test-outputs/24-vlan-py/
- https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-socfpga-agilex5/test-outputs/24-vlan-py/
- https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-stm32mp1/test-outputs/24-vlan-py/
- https://netdevci.bootlin.com/stmmac/outputs/941929-bootlin-stmmac-stm32mp2/test-outputs/24-vlan-py/
The test fails precisely because we can't switch offload mode while interface is on.
Besides the selftest, is it worth fixing ? We may have an error on one frame
while it's being actively reconfigured, I guess a lot of other drivers are
subject to the same class of problem... Is it a bit too defensive ?
I may be wrong here, I don't know exactly what's the netdev policy regarding
wether it's OK to have potentially one frame corrupt while the user is
reconfiguring offloads...
Maxime
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index d32d3e7b1b8c..b978e64399d4 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -6371,6 +6371,8 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
> netdev_features_t features)
> {
> struct stmmac_priv *priv = netdev_priv(dev);
> + netdev_features_t vlan_rx = NETIF_F_HW_VLAN_CTAG_RX |
> + NETIF_F_HW_VLAN_STAG_RX;
>
> if (priv->plat->rx_coe == STMMAC_RX_COE_NONE)
> features &= ~NETIF_F_RXCSUM;
> @@ -6393,6 +6395,15 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
> features &= ~NETIF_F_HW_VLAN_STAG_RX;
> }
>
> + /* The RX VLAN mode cannot be changed while RX is running: frames
> + * received under the old mode might otherwise be processed with the
> + * new one. Keep the current mode and defer the change until the
> + * interface is down.
> + */
> + if (netif_running(dev) &&
> + (features & vlan_rx) != (dev->features & vlan_rx))
> + features = (features & ~vlan_rx) | (dev->features & vlan_rx);
> +
> return features;
> }
>
>
> ---
> base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a
> change-id: 20261205-stmmac-do-not-flip-vlan-offload-613a9cad635b
>
> Best regards,
next prev parent reply other threads:[~2026-12-06 5:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 17:26 [PATCH net] net: stmmac: do not toggle RX VLAN offload while running Lorenzo Bianconi
2026-12-05 17:32 ` netdev-bot+sinfo
2026-12-05 17:36 ` Lorenzo Bianconi
2026-12-06 5:56 ` Maxime Chevallier [this message]
2026-12-06 12:35 ` Lorenzo Bianconi
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=5d6b1d95-d942-4cb8-b452-29f980223c27@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jun.ann.lai@intel.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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