intel-wired-lan.osuosl.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Magnus Karlsson" <magnus.karlsson@intel.com>
Cc: intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH net-next 3/5] xsk: ice: add USO zero-copy support
Date: Fri, 20 Nov 2026 16:54:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-225609@kernel.org> (raw)
In-Reply-To: <20261119165340.1071525-4-magnus.karlsson@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ice: xsk: missing descriptor count check in ice_xsk_bufs_fit()
  and USO parse
- [High] ice: xsk: XDP ring mismatch in ice_tx_xsk_pool() frees active
  USO DMA slots
--

commit 68f04de5ef6583147ab705c136de44a0ff2a4e13
Author: Magnus Karlsson <magnus.karlsson@intel.com>

xsk: ice: add USO zero-copy support

This commit adds AF_XDP zero-copy UDP Segmentation Offload (USO) helpers to
the XSK core and implements zero-copy USO in the ice driver using per-ring
DMA-mapped header slots.

> diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
> index 432da05c48c08..e19929b37e110 100644
> --- a/drivers/net/ethernet/intel/ice/ice.h
> +++ b/drivers/net/ethernet/intel/ice/ice.h
> @@ -833,16 +833,24 @@ static inline void ice_rx_xsk_pool(struct ice_rx_ring *ring)
>   * carries a pointer to one of these XDP rings for its own purposes, such as
>   * handling XDP_TX action, therefore we can piggyback here on the
>   * rx_ring->xdp_ring assignment that was done during XDP rings initialization.
> + * The ring must be stopped, as its USO header slots are matched to the pool.
> + * If they cannot be allocated, the ring keeps the pool without USO.
>   */
>  static inline void ice_tx_xsk_pool(struct ice_vsi *vsi, u16 qid)
>  {
> +	struct xsk_buff_pool *pool;
>  	struct ice_tx_ring *ring;
>  
>  	ring = vsi->rx_rings[qid]->xdp_ring;
>  	if (!ring)
>  		return;
>  
> -	WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
> +	pool = ice_get_xp_from_qid(vsi, qid);
> +	if (ice_xsk_cfg_uso_slots(ring, pool))
> +		netdev_warn(vsi->netdev,
> +			    "Failed to allocate USO header buffers, USO requests on queue %u are ignored\n",
> +			    qid);
> +	WRITE_ONCE(ring->xsk_pool, pool);
>  }

[Severity: High]
Can ice_tx_xsk_pool() free ring->xsk_uso_pages while
vsi->rx_rings[qid]->xdp_ring is still running with in-flight USO
descriptors?

When vsi->num_q_vectors < vsi->num_xdp_txq (for example after reducing
combined queues with ethtool -L, or when fewer CPUs are online than
possible), ice_map_xdp_rings() maps multiple XDP rings per vector and
vsi->rx_rings[qid]->xdp_ring is not vsi->xdp_rings[qid].  On pool teardown,
ice_xsk_pool_setup() calls ice_qp_dis() and ice_qp_ena(), but ice_qp_dis()
and ice_qp_clean_rings() stop and clean vsi->xdp_rings[qid]:

drivers/net/ethernet/intel/ice/ice_base.c:ice_qp_clean_rings() {
	ice_clean_tx_ring(vsi->tx_rings[q_idx]);
	if (vsi->xdp_rings)
		ice_clean_tx_ring(vsi->xdp_rings[q_idx]);
	ice_clean_rx_ring(vsi->rx_rings[q_idx]);
}

ice_qp_ena() then calls ice_tx_xsk_pool() -> ice_xsk_cfg_uso_slots(ring,
NULL) -> ice_xsk_free_uso_slots() on vsi->rx_rings[qid]->xdp_ring while
that ring still has uncleaned ICE_TX_BUF_XSK_USO descriptors in flight.
Aside from unmapping the DMA pages while the NIC may still read them,
ice_xsk_free_uso_slots() zeroes ring->xsk_uso_slots_per_page and clears
ring->xsk_uso_pages, so the next completion in ice_clean_xsk_buf() ->
ice_xsk_uso_slot() divides by zero and dereferences NULL.

Also, if a pool is disabled while ICE_VSI_DOWN is set,
ice_xsk_pool_disable() returns without freeing the USO header slots that
ice_xsk_pool_enable() allocated on vsi->rx_rings[qid]->xdp_ring.

> diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
> index 0c1ce3e86a45b..7fa1127480b66 100644
> --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
> +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c

[ ... ]

> @@ -791,6 +946,272 @@ static void ice_fill_tx_hw_ring(struct ice_tx_ring *xdp_ring,
>  		ice_xmit_pkt(xdp_ring, xsk_pool, &descs[i], total_bytes);
>  }
>  

[ ... ]

> +/* A buffer longer than one data descriptor is split, so a packet without USO
> + * can then need more data descriptors than the hardware allows.
> + */
> +static bool ice_xsk_bufs_fit(const struct xsk_buff_pool *pool,
> +			     const struct xdp_desc *descs, u32 nr)
> +{
> +	u32 buffers = 0, i;
> +
> +	if (likely(pool->chunk_size <= ICE_MAX_DATA_PER_TXD_ALIGNED))
> +		return true;
> +	for (i = 0; i < nr; i++)
> +		buffers += DIV_ROUND_UP(descs[i].len,
> +					ICE_MAX_DATA_PER_TXD_ALIGNED);
> +	return buffers <= ICE_MAX_BUF_TXD;
> +}

[Severity: High]
Does ice_xsk_bufs_fit() allow a non-USO packet with more than
ICE_MAX_BUF_TXD descriptors through when pool->chunk_size <=
ICE_MAX_DATA_PER_TXD_ALIGNED?

When multiple sockets share a UMEM without XDP_UMEM_SG_FLAG,
xsk_tx_peek_release_desc_batch() uses xsk_tx_peek_release_fallback(), which
peeks descriptors via xsk_tx_peek_desc() without enforcing
pool->xdp_zc_max_segs.  In ice_xmit_zc_metadata(), a multi-descriptor chain
with XDP_PKT_CONTD set can therefore accumulate nr > ICE_MAX_BUF_TXD
descriptors into one packet.  With standard 2K or 4K chunks,
ice_xsk_bufs_fit() returns true without checking nr <= ICE_MAX_BUF_TXD, and
ice_xsk_xmit_descs() emits more than 8 hardware descriptors for a single
unsegmented packet, triggering an MDD event on the Tx queue.

For USO packets on that same fallback path, neither xsk_tx_uso_parse() nor
ice_xsk_uso_fits() checks nr <= pool->xdp_zc_max_segs either (since
ice_xsk_uso_fits() resets buffers to 1 at each segment boundary).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119165340.1071525-1-magnus.karlsson@intel.com?part=3

  parent reply	other threads:[~2026-11-20 16:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 16:53 [PATCH net-next 0/5] xsk: ice: USO support for AF_XDP Magnus Karlsson
2026-11-19 16:53 ` [PATCH net-next 1/5] xsk: add USO support for skb path Magnus Karlsson
2026-11-19 18:47   ` Maciej Fijalkowski
2026-11-20  8:55     ` Magnus Karlsson
2026-11-20 11:43       ` Maciej Fijalkowski
2026-11-20 17:22   ` Stanislav Fomichev
2026-11-19 16:53 ` [PATCH net-next 2/5] ice: add Tx descriptor builders and header length check Magnus Karlsson
2026-11-20 11:59   ` Maciej Fijalkowski
2026-11-19 16:53 ` [PATCH net-next 3/5] xsk: ice: add USO zero-copy support Magnus Karlsson
2026-11-20 14:22   ` Maciej Fijalkowski
2026-11-20 16:54   ` sashiko-bot [this message]
2026-11-19 16:53 ` [PATCH net-next 4/5] xsk: add KUnit tests for AF_XDP USO header helpers Magnus Karlsson
2026-11-19 16:53 ` [PATCH net-next 5/5] selftests: net: add AF_XDP USO test Magnus Karlsson
2026-11-19 19:05   ` Maciej Fijalkowski
2026-11-20  8:35     ` Magnus Karlsson
  -- strict thread matches above, loose matches on Subject: below --
2026-11-19 14:10 [PATCH net-next 0/5] xsk: ice: USO support for AF_XDP Magnus Karlsson
2026-11-19 14:10 ` [PATCH net-next 3/5] xsk: ice: add USO zero-copy support Magnus Karlsson
2026-11-19 14:59   ` sashiko-bot

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=sashiko-outbox-225609@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=magnus.karlsson@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).