* [PATCH net] net: stmmac: do not toggle RX VLAN offload while running
@ 2026-12-05 17:26 Lorenzo Bianconi
2026-12-05 17:32 ` netdev-bot+sinfo
2026-12-06 5:56 ` Maxime Chevallier
0 siblings, 2 replies; 5+ messages in thread
From: Lorenzo Bianconi @ 2026-12-05 17:26 UTC (permalink / raw)
To: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Lai Peter Jun Ann
Cc: netdev, linux-arm-kernel, Lorenzo Bianconi
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>
---
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,
--
Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: stmmac: do not toggle RX VLAN offload while running
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
1 sibling, 1 reply; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-12-05 17:32 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Lai Peter Jun Ann, netdev, linux-arm-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: stmmac: do not toggle RX VLAN offload while running
2026-12-05 17:32 ` netdev-bot+sinfo
@ 2026-12-05 17:36 ` Lorenzo Bianconi
0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Bianconi @ 2026-12-05 17:36 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Lai Peter Jun Ann, netdev, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 1343 bytes --]
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
The issue has been reported by sashiko
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
This is a real issue reported by sashiko
>
> - What hardware the change was tested on. For driver fixes please
> mention the device (and if relevant firmware version) used for
> testing, or say that the change was not tested on real hardware.
I tested the fix on a Qualcomm rb3-gen2 board
Regards,
Lorenzo
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: stmmac: do not toggle RX VLAN offload while running
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-06 5:56 ` Maxime Chevallier
2026-12-06 12:35 ` Lorenzo Bianconi
1 sibling, 1 reply; 5+ messages in thread
From: Maxime Chevallier @ 2026-12-06 5:56 UTC (permalink / raw)
To: Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Lai Peter Jun Ann
Cc: netdev, linux-arm-kernel
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,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: stmmac: do not toggle RX VLAN offload while running
2026-12-06 5:56 ` Maxime Chevallier
@ 2026-12-06 12:35 ` Lorenzo Bianconi
0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Bianconi @ 2026-12-06 12:35 UTC (permalink / raw)
To: Maxime Chevallier
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Lai Peter Jun Ann,
netdev, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 4635 bytes --]
On Dec 06, Maxime Chevallier wrote:
> 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...
Hi Maxime,
If it is ok to receive corrupted frames during offload reconfiguration, I am fine
to drop this patch, I was just fixing a comment from sashiko that seemed reasonable
to me :)
Regards,
Lorenzo
>
> 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,
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-06 12:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-12-06 12:35 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox