bnxt_en: Fix XDP_TX path
Michael Chan
maintainerPATCH 1/1 bnxt_en: Fix XDP_TX path
For XDP_TX action in bnxt_rx_xdp(), clearing of the event flags is not correct. __bnxt_poll_work() -> bnxt_rx_pkt() -> bnxt_rx_xdp() may be looping within NAPI and some event flags may be set in earlier iterations. In particular, if BNXT_TX_EVENT is set earlier indicating some XDP_TX packets are ready and pending, it will be cleared if it is XDP_TX action again. Normally, we will set BNXT_TX_EVENT again when we successfully call __bnxt_xmit_xdp(). But if the TX ring has no more room, the flag will not be set. This will cause the TX producer to be ahead but the driver will not hit the TX doorbell.
For multi-buf XDP_TX, there is no need to clear the event flags and set BNXT_AGG_EVENT. The BNXT_AGG_EVENT flag should have been set earlier in bnxt_rx_pkt().
The visible symptom of this is that the RX ring associated with the TX XDP ring will eventually become empty and all packets will be dropped. Because this condition will cause the driver to not refill the RX ring seeing that the TX ring has forever pending XDP_TX packets.
The fix is to only clear BNXT_RX_EVENT when we have successfully called __bnxt_xmit_xdp().
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +1 -2
@@ -268,13 +268,11 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,case XDP_TX : rx_buf = &rxr->rx_buf_ring[cons]; mapping = rx_buf->mapping - bp->rx_dma_offset; - *event &=BNXT_TX_CMP_EVENT ;if (unlikely (xdp_buff_has_frags (xdp))) {struct skb_shared_info *sinfo =xdp_get_shared_info_from_buff (xdp); tx_needed += sinfo->nr_frags; - *event =BNXT_AGG_EVENT ; }if (tx_avail < tx_needed) {
@@ -287,6 +285,7 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,dma_sync_single_for_device (&pdev->dev, mapping + offset, *len, bp->rx_dir); + *event &= ~BNXT_RX_EVENT ; *event |=BNXT_TX_EVENT ;__bnxt_xmit_xdp (bp, txr, mapping + offset, *len,NEXT_RX (rxr->rx_prod), xdp);
Signature · 1 line
2.51.0
Quoted 22 lines · Michael Chan
For
XDP_TXaction inbnxt_rx_xdp(), clearing of the event flags is not correct.__bnxt_poll_work()->bnxt_rx_pkt()->bnxt_rx_xdp()may be looping within NAPI and some event flags may be set in earlier iterations. In particular, ifBNXT_TX_EVENTis set earlier indicating someXDP_TXpackets are ready and pending, it will be cleared if it isXDP_TXaction again. Normally, we will setBNXT_TX_EVENTagain when we successfully call__bnxt_xmit_xdp(). But if the TX ring has no more room, the flag will not be set. This will cause the TX producer to be ahead but the driver will not hit the TX doorbell.For multi-buf
XDP_TX, there is no need to clear the event flags and setBNXT_AGG_EVENT. TheBNXT_AGG_EVENTflag should have been set earlier inbnxt_rx_pkt().The visible symptom of this is that the RX ring associated with the TX XDP ring will eventually become empty and all packets will be dropped. Because this condition will cause the driver to not refill the RX ring seeing that the TX ring has forever pending
XDP_TXpackets.The fix is to only clear
BNXT_RX_EVENTwhen we have successfully called__bnxt_xmit_xdp().
Quoted 7 lines
Fixes 7f0a168b0441 ("bnxt_en: Add completion ring pointer in TX and RX ring structures")Reported-by Pavel Dubovitsky <[email protected]>Reviewed-by Andy Gospodarek <[email protected]>Reviewed-by Pavan Chebbi <[email protected]>Reviewed-by Kalesh AP <[email protected]>Signed-off-by Michael Chan <[email protected]>---
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 2 Dec 2025 16:30:24 -0800 you wrote:
For
XDP_TXaction inbnxt_rx_xdp(), clearing of the event flags is not correct.__bnxt_poll_work()->bnxt_rx_pkt()->bnxt_rx_xdp()may be looping within NAPI and some event flags may be set in earlier iterations. In particular, ifBNXT_TX_EVENTis set earlier indicating someXDP_TXpackets are ready and pending, it will be cleared if it isXDP_TXaction again. Normally, we will setBNXT_TX_EVENTagain when we successfully call__bnxt_xmit_xdp(). But if the TX ring has no more room, the flag will not be set. This will cause the TX producer to be ahead but the driver will not hit the TX doorbell.[...]
Here is the summary with links:
- [net] bnxt_en: Fix XDP_TX path
https://git.kernel.org/netdev/net/c/0373d5c387f2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html