Skip to content

Commit

Permalink
net/virtio: fix vectorized Rx queue rearm
Browse files Browse the repository at this point in the history
When Rx queue worked in vectorized mode and rxd <= 512, under traffic of
high PPS rate, testpmd often start and receive packets of rxd without
further growth.

Testpmd started with rxq flush which tried to rx MAX_PKT_BURST(512)
packets and drop. When Rx burst size >= Rx queue size, all descriptors
in used queue consumed without rearm, device can't receive more packets.
The next Rx burst returned at once since no used descriptors found,
rearm logic was skipped, rx vq kept in starving state.

To avoid rx vq starving, this patch always check the available queue,
rearm if needed even no used descriptor reported by device.

Fixes: fc3d662 ("virtio: add vector Rx")
Fixes: 2d7c371 ("net/virtio: add NEON based Rx handler")
Fixes: 52b5a70 ("net/virtio: add Altivec Rx")
Cc: stable@dpdk.org

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
steevenlee authored and mcoquelin committed May 4, 2021
1 parent 0489602 commit d990884
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions drivers/net/virtio/virtio_rxtx_simple_altivec.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
if (unlikely(nb_pkts < RTE_VIRTIO_DESC_PER_LOOP))
return 0;

if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
virtio_rxq_rearm_vec(rxvq);
if (unlikely(virtqueue_kick_prepare(vq)))
virtqueue_notify(vq);
}

nb_used = virtqueue_nused(vq);

rte_compiler_barrier();
Expand All @@ -102,12 +108,6 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,

rte_prefetch0(rused);

if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
virtio_rxq_rearm_vec(rxvq);
if (unlikely(virtqueue_kick_prepare(vq)))
virtqueue_notify(vq);
}

nb_total = nb_used;
ref_rx_pkts = rx_pkts;
for (nb_pkts_received = 0;
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/virtio/virtio_rxtx_simple_neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ virtio_recv_pkts_vec(void *rx_queue,
if (unlikely(nb_pkts < RTE_VIRTIO_DESC_PER_LOOP))
return 0;

if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
virtio_rxq_rearm_vec(rxvq);
if (unlikely(virtqueue_kick_prepare(vq)))
virtqueue_notify(vq);
}

/* virtqueue_nused has a load-acquire or rte_io_rmb inside */
nb_used = virtqueue_nused(vq);

Expand All @@ -100,12 +106,6 @@ virtio_recv_pkts_vec(void *rx_queue,

rte_prefetch_non_temporal(rused);

if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
virtio_rxq_rearm_vec(rxvq);
if (unlikely(virtqueue_kick_prepare(vq)))
virtqueue_notify(vq);
}

nb_total = nb_used;
ref_rx_pkts = rx_pkts;
for (nb_pkts_received = 0;
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/virtio/virtio_rxtx_simple_sse.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
if (unlikely(nb_pkts < RTE_VIRTIO_DESC_PER_LOOP))
return 0;

if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
virtio_rxq_rearm_vec(rxvq);
if (unlikely(virtqueue_kick_prepare(vq)))
virtqueue_notify(vq);
}

nb_used = virtqueue_nused(vq);

if (unlikely(nb_used == 0))
Expand All @@ -100,12 +106,6 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,

rte_prefetch0(rused);

if (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
virtio_rxq_rearm_vec(rxvq);
if (unlikely(virtqueue_kick_prepare(vq)))
virtqueue_notify(vq);
}

nb_total = nb_used;
ref_rx_pkts = rx_pkts;
for (nb_pkts_received = 0;
Expand Down

0 comments on commit d990884

Please sign in to comment.