All of lore.kernel.org
 help / color / mirror / Atom feed
* [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
  0 siblings, 1 reply; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2026-12-05 17:36 UTC | newest]

Thread overview: 3+ 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.