Skip to content

Commit

Permalink
net/mlx5: do not poll CQEs when no available elts
Browse files Browse the repository at this point in the history
In certain situations, the receive queue (rxq) fails to replenish its
internal ring with memory buffers (mbufs) from the pool. This can happen
when the pool has a limited number of mbufs allocated, and the user
application holds incoming packets for an extended period, resulting in a
delayed release of mbufs. Consequently, the pool becomes depleted,
preventing the rxq from replenishing from it.

There was a bug in the behavior of the vectorized rxq_cq_process_v routine,
which handled completion queue entries (CQEs) in batches of four. This
routine consistently accessed four mbufs from the internal queue ring,
regardless of whether they had been replenished. As a result, it could
access mbufs that no longer belonged to the poll mode driver (PMD).

The fix involves checking if there are four replenished mbufs available
before allowing rxq_cq_process_v to handle the batch. Once replenishment
succeeds during the polling process, the routine will resume its operation.

Fixes: 1ded262 ("net/mlx5: refactor vectorized Rx")
Cc: stable@dpdk.org

Reported-by: Changqi Dingluo <dingluochangqi.ck@bytedance.com>
Signed-off-by: Gavin Hu <gahu@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  • Loading branch information
gahu-nvidia authored and raslandarawsheh committed Jan 20, 2025
1 parent bd8b518 commit 15a3e55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Chandubabu Namburu <chandu@amd.com>
Chang Miao <chang.miao@corigine.com>
Changchun Ouyang <changchun.ouyang@intel.com>
Changpeng Liu <changpeng.liu@intel.com>
Changqi Dingluo <dingluochangqi.ck@bytedance.com>
Changqing Wu <changqingx.wu@intel.com>
Chaoyong He <chaoyong.he@corigine.com>
Chao Zhu <chaozhu@linux.vnet.ibm.com> <bjzhuc@cn.ibm.com>
Expand Down Expand Up @@ -466,6 +467,7 @@ Gary Mussar <gmussar@ciena.com>
Gaurav Singh <gaurav1086@gmail.com>
Gautam Dawar <gdawar@solarflare.com>
Gavin Hu <gavin.hu@arm.com> <gavin.hu@linaro.org>
Gavin Hu <gahu@nvidia.com>
Gavin Li <gavinl@nvidia.com>
Geoffrey Le Gourriérec <geoffrey.le_gourrierec@6wind.com>
Geoffrey Lv <geoffrey.lv@gmail.com>
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/mlx5/mlx5_rxtx_vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ rxq_burst_v(struct mlx5_rxq_data *rxq, struct rte_mbuf **pkts,
/* Not to cross queue end. */
pkts_n = RTE_MIN(pkts_n, q_n - elts_idx);
pkts_n = RTE_MIN(pkts_n, q_n - cq_idx);
/* Not to move past the allocated mbufs. */
pkts_n = RTE_MIN(pkts_n, RTE_ALIGN_FLOOR(rxq->rq_ci - rxq->rq_pi,
MLX5_VPMD_DESCS_PER_LOOP));
if (!pkts_n) {
*no_cq = !rcvd_pkt;
return rcvd_pkt;
Expand Down

0 comments on commit 15a3e55

Please sign in to comment.