Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis, ena}()
@ 2026-11-18 13:59 Magnus Karlsson
  2026-11-18 14:26 ` [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis,ena}() Maciej Fijalkowski
  2026-11-18 14:35 ` [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis, ena}() sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Magnus Karlsson @ 2026-11-18 13:59 UTC (permalink / raw)
  To: magnus.karlsson, magnus.karlsson, intel-wired-lan,
	anthony.l.nguyen, maciej.fijalkowski, przemyslaw.kitszel

Since commit 9ead7e74bfd6 ("ice: xsk: use Rx ring's XDP ring when picking
NAPI context"), an Rx ring uses the XDP ring that is first on its queue
vector's Tx ring list, both for XDP_TX and for AF_XDP zero-copy Tx. With
fewer queue vectors than CPUs, a vector carries several XDP rings, so Rx
ring N then does not use XDP ring N. ice_qp_dis(), ice_qp_ena() and the
ring cleaning and stats reset they call still operate on
vsi->xdp_rings[q_idx].

As a result, a zero-copy pool is attached to and detached from an XDP ring
that is never stopped, cleaned or reconfigured. At the same time, another
XDP ring is stopped and cleaned, possibly while it is in use from another
queue vector whose NAPI context keeps running.

With 4 channels on a machine with 8 CPUs, for example, queue vector 0
carries XDP rings 0 and 1, and Rx ring 0 uses XDP ring 1. Disabling queue
pair 1 then disables the NAPI context of vector 1, but stops and cleans
XDP ring 1, which vector 0 is still using.

Use rx_rings[q_idx]->xdp_ring, the ring that ice_tx_xsk_pool() assigns
the pool to, in all of these places. ice_vsi_cfg_single_txq() checks
its index against the number of LAN Tx queues, which an XDP ring index
can exceed, so configure that ring with ice_vsi_cfg_txq() directly.

Fixes: 9ead7e74bfd6 ("ice: xsk: use Rx ring's XDP ring when picking NAPI context")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_base.c | 42 +++++++++++++++++------
 1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
index 1667f686ff75..aa0ad313a97c 100644
--- a/drivers/net/ethernet/intel/ice/ice_base.c
+++ b/drivers/net/ethernet/intel/ice/ice_base.c
@@ -1386,6 +1386,22 @@ ice_fill_txq_meta(const struct ice_vsi *vsi, struct ice_tx_ring *ring,
 	}
 }
 
+/**
+ * ice_qp_xdp_ring - Get the XDP ring used by a queue pair
+ * @vsi: VSI that contains rings of interest
+ * @q_idx: ring index in array
+ *
+ * A queue vector can carry more than one XDP ring, and Rx ring @q_idx then
+ * does not use XDP ring @q_idx. Return the XDP ring that XDP_TX and AF_XDP
+ * zero-copy use for this queue pair, as picked by ice_map_xdp_rings().
+ *
+ * Return: the XDP ring, or NULL if XDP rings are not configured.
+ */
+static struct ice_tx_ring *ice_qp_xdp_ring(struct ice_vsi *vsi, u16 q_idx)
+{
+	return vsi->xdp_rings ? vsi->rx_rings[q_idx]->xdp_ring : NULL;
+}
+
 /**
  * ice_qp_reset_stats - Resets all stats for rings of given index
  * @vsi: VSI that contains rings of interest
@@ -1393,6 +1409,7 @@ ice_fill_txq_meta(const struct ice_vsi *vsi, struct ice_tx_ring *ring,
  */
 static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)
 {
+	struct ice_tx_ring *xdp_ring = ice_qp_xdp_ring(vsi, q_idx);
 	struct ice_vsi_stats *vsi_stat;
 	struct ice_pf *pf;
 
@@ -1408,9 +1425,9 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)
 	       sizeof(vsi_stat->rx_ring_stats[q_idx]->stats));
 	memset(&vsi_stat->tx_ring_stats[q_idx]->stats, 0,
 	       sizeof(vsi_stat->tx_ring_stats[q_idx]->stats));
-	if (vsi->xdp_rings)
-		memset(&vsi->xdp_rings[q_idx]->ring_stats->stats, 0,
-		       sizeof(vsi->xdp_rings[q_idx]->ring_stats->stats));
+	if (xdp_ring)
+		memset(&xdp_ring->ring_stats->stats, 0,
+		       sizeof(xdp_ring->ring_stats->stats));
 }
 
 /**
@@ -1420,9 +1437,11 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)
  */
 static void ice_qp_clean_rings(struct ice_vsi *vsi, u16 q_idx)
 {
+	struct ice_tx_ring *xdp_ring = ice_qp_xdp_ring(vsi, q_idx);
+
 	ice_clean_tx_ring(vsi->tx_rings[q_idx]);
-	if (vsi->xdp_rings)
-		ice_clean_tx_ring(vsi->xdp_rings[q_idx]);
+	if (xdp_ring)
+		ice_clean_tx_ring(xdp_ring);
 	ice_clean_rx_ring(vsi->rx_rings[q_idx]);
 }
 
@@ -1435,9 +1454,9 @@ static void ice_qp_clean_rings(struct ice_vsi *vsi, u16 q_idx)
  */
 int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx)
 {
+	struct ice_tx_ring *tx_ring, *xdp_ring;
 	struct ice_txq_meta txq_meta = { };
 	struct ice_q_vector *q_vector;
-	struct ice_tx_ring *tx_ring;
 	struct ice_rx_ring *rx_ring;
 	int fail = 0;
 	int err;
@@ -1447,6 +1466,7 @@ int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx)
 
 	tx_ring = vsi->tx_rings[q_idx];
 	rx_ring = vsi->rx_rings[q_idx];
+	xdp_ring = ice_qp_xdp_ring(vsi, q_idx);
 	q_vector = rx_ring->q_vector;
 
 	synchronize_net();
@@ -1460,9 +1480,7 @@ int ice_qp_dis(struct ice_vsi *vsi, u16 q_idx)
 	err = ice_vsi_stop_tx_ring(vsi, ICE_NO_RESET, 0, tx_ring, &txq_meta);
 	if (!fail)
 		fail = err;
-	if (vsi->xdp_rings) {
-		struct ice_tx_ring *xdp_ring = vsi->xdp_rings[q_idx];
-
+	if (xdp_ring) {
 		memset(&txq_meta, 0, sizeof(txq_meta));
 		ice_fill_txq_meta(vsi, xdp_ring, &txq_meta);
 		err = ice_vsi_stop_tx_ring(vsi, ICE_NO_RESET, 0, xdp_ring,
@@ -1497,9 +1515,11 @@ int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)
 		fail = err;
 
 	if (ice_is_xdp_ena_vsi(vsi)) {
-		struct ice_tx_ring *xdp_ring = vsi->xdp_rings[q_idx];
+		DEFINE_RAW_FLEX(struct ice_aqc_add_tx_qgrp, qg_buf, txqs, 1);
+		struct ice_tx_ring *xdp_ring = ice_qp_xdp_ring(vsi, q_idx);
 
-		err = ice_vsi_cfg_single_txq(vsi, vsi->xdp_rings, q_idx);
+		qg_buf->num_txqs = 1;
+		err = ice_vsi_cfg_txq(vsi, xdp_ring, qg_buf);
 		if (!fail)
 			fail = err;
 		ice_set_ring_xdp(xdp_ring);
-- 
2.38.1


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 13:59 [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis, ena}() Magnus Karlsson
2026-11-18 14:26 ` [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis,ena}() Maciej Fijalkowski
2026-11-18 14:35 ` [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis, ena}() sashiko-bot

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