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 <[email protected]>
---
v1 -> v2:
- Decrement the counter for each freed XDP_TX buffer (Maciej)
- v1:
https://lore.kernel.org/intel-wired-lan/[email protected]/
---
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