* [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
* Re: [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis,ena}()
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 ` 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
1 sibling, 0 replies; 3+ messages in thread
From: Maciej Fijalkowski @ 2026-11-18 14:26 UTC (permalink / raw)
To: Magnus Karlsson
Cc: magnus.karlsson, intel-wired-lan, anthony.l.nguyen,
przemyslaw.kitszel
On Wed, Nov 18, 2026 at 02:59:52PM +0100, Magnus Karlsson wrote:
> 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>
Yikes! Good catch!
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@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 [flat|nested] 3+ messages in thread
* Re: [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis, ena}()
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 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-18 14:35 UTC (permalink / raw)
To: Magnus Karlsson, intel-wired-lan
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ice: XDP ring QINT_TQCTL interrupt mismatch in ice_qp_dis() and
ice_qp_ena()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] ice: incorrect XDP queue indexing in
ice_cfg_txq_interrupt() [1]
--
commit 16196a7c47f74a832fc91f862f75e019be2f6418
Author: Magnus Karlsson <magnus.karlsson@intel.com>
ice: use the queue pair's XDP ring in ice_qp_{dis, ena}()
This commit updates ice_qp_dis(), ice_qp_ena(), ice_qp_clean_rings(), and
ice_qp_reset_stats() to operate on vsi->rx_rings[q_idx]->xdp_ring instead
of vsi->xdp_rings[q_idx].
> diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
> index 1667f686ff751..aa0ad313a97cd 100644
> --- a/drivers/net/ethernet/intel/ice/ice_base.c
> +++ b/drivers/net/ethernet/intel/ice/ice_base.c
[ ... ]
> @@ -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);
[Severity: High]
Does ice_qp_ena() leave QINT_TQCTL_CAUSE_ENA_M cleared on xdp_ring after
ice_qp_dis() stops it?
In ice_qp_dis(), ice_vsi_stop_tx_ring() clears QINT_TQCTL_CAUSE_ENA_M in
QINT_TQCTL(xdp_ring->reg_idx). When ice_qp_ena() re-enables the queue
pair, it configures MSI-X via ice_qvec_cfg_msix() ->
ice_cfg_txq_interrupt(), which still writes to a different queue index:
drivers/net/ethernet/intel/ice/ice_base.c:ice_cfg_txq_interrupt() {
...
wr32(hw, QINT_TQCTL(vsi->txq_map[txq]), val);
if (ice_is_xdp_ena_vsi(vsi)) {
u32 xdp_txq = txq + vsi->num_xdp_txq;
wr32(hw, QINT_TQCTL(vsi->txq_map[xdp_txq]),
val);
}
...
}
When there are fewer queue vectors than CPUs, vsi->txq_map[q_idx +
vsi->num_xdp_txq] is not xdp_ring->reg_idx. As a result, xdp_ring's Tx
interrupt remains disabled (breaking AF_XDP zero-copy Tx completions), and
another ring's QINT_TQCTL is overwritten with this queue vector's MSI-X
index.
[Severity: Critical]
This problem wasn't introduced by this patch, but ice_cfg_txq_interrupt()
and ice_vsi_release_msix() also compute the XDP queue offset in
vsi->txq_map as txq + vsi->num_xdp_txq [1], whereas
ice_prepare_xdp_rings() places XDP rings in vsi->txq_map starting at
vsi->alloc_txq.
When the allocated LAN Tx queue count differs from vsi->num_xdp_txq (for
example, after changing the channel count with ethtool), indexing
vsi->txq_map[txq + vsi->num_xdp_txq] can access past the end of
vsi->txq_map or corrupt QINT_TQCTL for the wrong hardware queues. In
addition, ice_vsi_release_msix() only iterates up to q_vector->num_ring_tx,
which leaves the remaining XDP rings' QINT_TQCTL interrupt mappings active
when there are fewer LAN Tx queues than XDP queues.
[1] https://sashiko.dev/#/bug/linux-0b308224-7107-4d23-9bbc-9ae5c80b362b
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118135952.1063685-1-magnus.karlsson@intel.com?part=1
^ permalink raw reply [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