Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexander Lobakin" <aleksander.lobakin@intel.com>,
	intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH iwl-next v3 3/3] idpf: add flow-based XDP fallback for FWs without Tx FIFO support
Date: Thu, 19 Nov 2026 15:02:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-223336@kernel.org> (raw)
In-Reply-To: <20261119140938.1363722-4-aleksander.lobakin@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] idpf: unchecked cpu_to_mem() for i >= nr_cpu_ids in
  idpf_xdpsqs_get()
- [Medium] idpf: premature CQE poll exit on out-of-order CQEs in
  idpf_xdpsq_poll_fb()
--

commit 6119bbbc742528036710b0619a594398135c70b2
Author: Alexander Lobakin <aleksander.lobakin@intel.com>

idpf: add flow-based XDP fallback for FWs without Tx FIFO support

This commit introduces a flow-based Tx scheduling fallback for XDP and
AF_XDP on firmware that lacks queue-based (FIFO) Tx scheduling support,
using a per-queue bitmap to serialize out-of-order per-packet completion
tags into contiguous descriptor ranges.

> diff --git a/drivers/net/ethernet/intel/idpf/xdp.c b/drivers/net/ethernet/intel/idpf/xdp.c
> index 48320ea004dfb..0b4ead7fbcaf6 100644
> --- a/drivers/net/ethernet/intel/idpf/xdp.c
> +++ b/drivers/net/ethernet/intel/idpf/xdp.c

[ ... ]

> @@ -169,13 +173,42 @@ int idpf_xdpsqs_get(const struct idpf_vport *vport)
>  			for (int j = i - 1; j >= 0; j--)
>  				kfree(timers[j]);
>  
> -			return -ENOMEM;
> +			goto err_timers;
>  		}
>  	}
>  
>  	dev = vport->netdev;
>  	sqs = vport->dflt_qv_rsrc.xdp_txq_offset;
>  
> +	fb = !idpf_is_cap_ena(vport->adapter, IDPF_OTHER_CAPS,
> +			      VIRTCHNL2_CAP_SPLITQ_QSCHED);
> +	if (!fb)
> +		goto setup;
> +
> +	masks = kvzalloc_objs(*masks, vport->num_xdp_txq);
> +	if (!masks)
> +		goto err_masks;
> +
> +	for (u32 i = 0; i < vport->num_xdp_txq; i++) {
> +		masks[i] = bitmap_zalloc_node(vport->txqs[sqs + i]->desc_count,
> +					      GFP_KERNEL, cpu_to_mem(i));

[Severity: High]
Can cpu_to_mem(i) index past nr_cpu_ids when vport->num_xdp_txq exceeds
the number of CPUs?

idpf_vport_calc_total_qs() sizes num_xdp_txq via libeth_xdpsq_num(),
which returns min(max(nr_cpu_ids, rxq), max - txq).  When an
administrator configures more Rx queues than nr_cpu_ids via ethtool -L,
i reaches >= nr_cpu_ids (as it also does in the pre-existing timers[i]
loop above), indexing an uninitialized or out-of-bounds
__per_cpu_offset[i] entry on NUMA kernels.  idpf_q_vector_to_mem() guards
this with:

  cpu < nr_cpu_ids ? cpu_to_mem(cpu) : NUMA_NO_NODE

[ ... ]

> @@ -255,6 +319,65 @@ static int idpf_xdp_parse_cqe(const struct idpf_splitq_4b_tx_compl_desc *desc,
>  #endif
>  }
>  
> +static u32 idpf_xdpsq_poll_fb(struct idpf_tx_queue *xdpsq, u32 budget)
> +{
> +	struct idpf_compl_queue *cq = xdpsq->complq;
> +	unsigned long *mask = xdpsq->pending_mask;
> +	u32 done_frames, tx_cnt, new_ntc;
> +	u32 ntc = cq->next_to_clean;
> +	u32 cnt = cq->desc_count;
> +	bool gen;
> +
> +	gen = idpf_queue_has(GEN_CHK, cq);
> +
> +	for (done_frames = 0; done_frames < budget; ) {
> +		int ret;
> +
> +		ret = idpf_xdp_parse_cqe(&cq->comp[ntc].common, gen);
> +		if (ret >= 0) {
> +			__clear_bit(ret, mask);
> +			done_frames++;
> +
> +			goto next;
> +		}
> +
> +		switch (ret) {
> +		case -ENODATA:
> +			goto out;
> +		case -EINVAL:
> +			break;
> +		}
> +
> +next:
> +		if (unlikely(++ntc == cnt)) {
> +			ntc = 0;
> +			gen = !gen;
> +			idpf_queue_change(GEN_CHK, cq);
> +		}
> +	}
> +
> +out:
> +	cq->next_to_clean = ntc;
> +
> +	if (unlikely(!done_frames))
> +		return 0;
> +
> +	tx_cnt = xdpsq->desc_count;
> +
> +	/* Don't go past next_to_use */
> +	__set_bit(xdpsq->next_to_use, mask);
> +
> +	new_ntc = find_next_bit(mask, tx_cnt, xdpsq->next_to_clean);
> +	done_frames = new_ntc - xdpsq->next_to_clean;
> +
> +	if (new_ntc == tx_cnt)
> +		done_frames += find_first_bit(mask, tx_cnt);
> +
> +	__clear_bit(xdpsq->next_to_use, mask);
> +
> +	return done_frames;
> +}

[Severity: Medium]
Can idpf_xdpsq_poll_fb() return 0 after consuming out-of-order CQEs if
the descriptor at xdpsq->next_to_clean has not completed yet?

The loop stops after reading budget raw CQEs, but the return value is
overwritten with the contiguous run of cleared bits starting at
xdpsq->next_to_clean.  If budget younger packets complete ahead of
xdpsq->next_to_clean, idpf_xdp_tx_prep() (which passes budget =
xdpsq->thresh) gets 0 reclaimed descriptors and drops frames when the
ring is full even if the CQE for xdpsq->next_to_clean is already waiting
next in cq.  In addition, if the delayed cleanup timer runs
libeth_xdpsq_run_timer() and consumes out-of-order CQEs while
xdpsq->next_to_clean is still in flight in hardware, poll() returns 0 and
libeth_xdpsq_run_timer() stops re-arming the timer with pending frames
still on the queue.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119140938.1363722-1-aleksander.lobakin@intel.com?part=3

      reply	other threads:[~2026-11-19 15:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:09 [PATCH iwl-next v3 0/3] idpf: add flow-based XDP fallback for FWs without Tx FIFO support Alexander Lobakin
2026-11-19 14:09 ` [PATCH iwl-next v3 1/3] idpf: always reserve one empty descriptor on XDPSQs Alexander Lobakin
2026-11-19 14:09 ` [PATCH iwl-next v3 2/3] idpf: enforce strict ordering on BE when reading XDPCQEs Alexander Lobakin
2026-11-19 14:09 ` [PATCH iwl-next v3 3/3] idpf: add flow-based XDP fallback for FWs without Tx FIFO support Alexander Lobakin
2026-11-19 15:02   ` sashiko-bot [this message]

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-223336@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --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