Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH net] net: enetc: do not transmit redirected XDP frames when the link is down
@ 2025-12-05 10:53 Wei Fang
  2025-12-09  8:35 ` Vladimir Oltean
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Fang @ 2025-12-05 10:53 UTC (permalink / raw)
  To: claudiu.manoil, vladimir.oltean, xiaoning.wang, andrew+netdev,
	davem, edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend,
	sdf
  Cc: imx, netdev, linux-kernel, bpf

In the current implementation, the enetc_xdp_xmit() always transmits
redirected XDP frames even if the link is down, but the frames cannot
be transmitted from TX BD rings when the link is down, so the frames
are still kept in the TX BD rings. If the XDP program is uninstalled,
users will see the following warning logs.

fsl_enetc 0000:00:00.0 eno0: timeout for tx ring #6 clear

More worse, the TX BD ring cannot work properly anymore, because the
HW PIR and CIR are not the same after the re-initialization of the TX
BD ring. And I see no reasons to transmit the redirected XDP frames
when the link is down, so add a link status check to quickly fix this
issue. However, this solution does not completely solve the problem,
for example, if the link is broken during transmission and the TX BD
ring still has unsent frames. I think this requires another patch to
address this situation, but it will not conflict with the current
solution and can coexist.

Fixes: 9d2b68cc108d ("net: enetc: add support for XDP_REDIRECT")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/enetc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 0535e92404e3..f410c245ea91 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -1778,7 +1778,8 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames,
 	int xdp_tx_bd_cnt, i, k;
 	int xdp_tx_frm_cnt = 0;
 
-	if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags)))
+	if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags) ||
+		     !netif_carrier_ok(ndev)))
 		return -ENETDOWN;
 
 	enetc_lock_mdio();
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-12-09 10:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 10:53 [PATCH net] net: enetc: do not transmit redirected XDP frames when the link is down Wei Fang
2025-12-09  8:35 ` Vladimir Oltean
2025-12-09  9:08   ` Wei Fang
2025-12-09  9:41     ` Vladimir Oltean
2025-12-09  9:59       ` Wei Fang
2025-12-09 10:15       ` Wei Fang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox