All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Magnus Karlsson <magnus.karlsson@intel.com>
Cc: <magnus.karlsson@gmail.com>, <intel-wired-lan@lists.osuosl.org>,
	<anthony.l.nguyen@intel.com>, <przemyslaw.kitszel@intel.com>
Subject: Re: [PATCH iwl-net] ice: use the queue pair's XDP ring in ice_qp_{dis,ena}()
Date: Wed, 18 Nov 2026 15:26:57 +0100	[thread overview]
Message-ID: <av21sWxL2vEiJspz@boxer> (raw)
In-Reply-To: <20261118135952.1063685-1-magnus.karlsson@intel.com>

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
> 

  reply	other threads:[~2026-11-18 14:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-11-18 14:35 ` sashiko-bot
2026-11-19 10:30   ` Karlsson, Magnus
2026-11-19 11:10 ` Alexander Lobakin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=av21sWxL2vEiJspz@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=magnus.karlsson@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=przemyslaw.kitszel@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.