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 <[email protected]> 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/[email protected]?part=3
