Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iwl-net v2] ice: account for XDP_TX buffers when cleaning a Tx ring
@ 2026-11-24 13:29 Magnus Karlsson
  2026-11-24 14:19 ` Loktionov, Aleksandr
  0 siblings, 1 reply; 3+ messages in thread
From: Magnus Karlsson @ 2026-11-24 13:29 UTC (permalink / raw)
  To: magnus.karlsson, magnus.karlsson, intel-wired-lan,
	anthony.l.nguyen, maciej.fijalkowski, przemyslaw.kitszel

xdp_tx_active counts the XDP_TX buffers on an XDP ring, so that
ice_clean_xdp_irq_zc() can complete AF_XDP zero-copy frames in bulk when
there are none. ice_clean_tx_ring() frees the buffers that are still on
the ring, both through ice_xsk_clean_xdp_ring() and through
ice_unmap_and_free_tx_buf(), but leaves the counter as it was.

After a ring is cleaned with XDP_TX frames in flight, for example when
an AF_XDP socket is bound or unbound, xdp_tx_active therefore stays
non-zero for the lifetime of the ring. ice_clean_xdp_irq_zc() then
always takes the per-descriptor slow path.

ice_xsk_clean_xdp_ring() used to decrement the counter for the XDP_TX
buffers it freed, through ice_clean_xdp_tx_buf(), until that helper was
replaced with a plain xsk_buff_free(). Decrement it again for each
XDP_TX buffer it frees. ice_unmap_and_free_tx_buf() frees buffers on
regular XDP rings, which count XDP_TX and redirected frames rather than
buffers, so reset the counter in ice_clean_tx_ring() as well, so that a
zero-copy socket bound afterwards starts from zero.

Fixes: 59e92bfe4df7 ("ice: xsk: Borrow xdp_tx_active logic from i40e")
Fixes: a24b4c6e9aab ("ice: xsk: Do not convert to buff to frame for XDP_TX")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
v1 -> v2:
- Decrement the counter for each freed XDP_TX buffer (Maciej)
- v1: https://lore.kernel.org/intel-wired-lan/20261118135952.1063685-1-magnus.karlsson@intel.com/
---
 drivers/net/ethernet/intel/ice/ice_txrx.c | 1 +
 drivers/net/ethernet/intel/ice/ice_xsk.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index 35a480a1e172..f26646825a1e 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -228,6 +228,7 @@ void ice_clean_tx_ring(struct ice_tx_ring *tx_ring)
 
 	tx_ring->next_to_use = 0;
 	tx_ring->next_to_clean = 0;
+	tx_ring->xdp_tx_active = 0;
 
 	if (!tx_ring->netdev)
 		return;
diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index 0c1ce3e86a45..2d9dbdb82cdd 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -942,6 +942,7 @@ void ice_xsk_clean_xdp_ring(struct ice_tx_ring *xdp_ring)
 		if (tx_buf->type == ICE_TX_BUF_XSK_TX) {
 			tx_buf->type = ICE_TX_BUF_EMPTY;
 			xsk_buff_free(tx_buf->xdp);
+			xdp_ring->xdp_tx_active--;
 		} else {
 			xsk_frames++;
 		}
-- 
2.38.1


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

end of thread, other threads:[~2026-11-24 14:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:29 [PATCH iwl-net v2] ice: account for XDP_TX buffers when cleaning a Tx ring Magnus Karlsson
2026-11-24 14:19 ` Loktionov, Aleksandr
2026-11-24 14:30   ` Maciej Fijalkowski

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