diff mbox series

[v3,1/2] vhost: support to clear in-flight packets for async dequeue

Message ID 20210922085546.54758-2-yuanx.wang@intel.com (mailing list archive)
State New
Delegated to: Maxime Coquelin
Headers show
Series support to clear in-flight packets for async | expand

Checks

Context Check Description
ci/iol-testing warning apply patch failure
ci/checkpatch success coding style OK

Commit Message

Yuan Wang Sept. 22, 2021, 8:55 a.m. UTC
rte_vhost_clear_queue_thread_unsafe() supports to clear
in-flight packets for async enqueue only. But after
supporting async dequeue, this API should support async dequeue too.

Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
---
 lib/vhost/virtio_net.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Comments

Yang, YvonneX Sept. 23, 2021, 2:43 a.m. UTC | #1
> -----Original Message-----
> From: Wang, YuanX <yuanx.wang@intel.com>
> Sent: Wednesday, September 22, 2021 4:56 PM
> To: dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>; Hu,
> Jiayu <jiayu.hu@intel.com>; Ding, Xuan <xuan.ding@intel.com>; Jiang,
> Cheng1 <cheng1.jiang@intel.com>; Ma, WenwuX <wenwux.ma@intel.com>;
> Yang, YvonneX <yvonnex.yang@intel.com>; Pai G, Sunil
> <sunil.pai.g@intel.com>
> Subject: [PATCH v3 1/2] vhost: support to clear in-flight packets for async
> dequeue
> 
> rte_vhost_clear_queue_thread_unsafe() supports to clear in-flight packets
> for async enqueue only. But after supporting async dequeue, this API should
> support async dequeue too.
> 
> Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
> ---

Tested-by: Yvonne Yang <yvonnex.yang@intel.com>
diff mbox series

Patch

diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 39399d2d31..21afcd1854 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -27,6 +27,11 @@ 
 
 #define VHOST_ASYNC_BATCH_THRESHOLD 32
 
+static __rte_always_inline uint16_t
+async_poll_dequeue_completed_split(struct virtio_net *dev,
+		struct vhost_virtqueue *vq, uint16_t queue_id,
+		struct rte_mbuf **pkts, uint16_t count, bool legacy_ol_flags);
+
 static  __rte_always_inline bool
 rxvq_is_mergeable(struct virtio_net *dev)
 {
@@ -2120,7 +2125,7 @@  rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,
 		return 0;
 
 	VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__);
-	if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {
+	if (unlikely(queue_id >= dev->nr_vring)) {
 		VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n",
 			dev->vid, __func__, queue_id);
 		return 0;
@@ -2134,7 +2139,17 @@  rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,
 		return 0;
 	}
 
-	n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count);
+	if (queue_id % 2 == 0)
+		n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts, count);
+	else {
+		if (unlikely(vq_is_packed(dev)))
+			VHOST_LOG_DATA(ERR,
+				"(%d) %s: async dequeue does not support packed ring.\n",
+				dev->vid, __func__);
+		else
+			n_pkts_cpl = async_poll_dequeue_completed_split(dev, vq, queue_id, pkts,
+						count, dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS);
+	}
 
 	return n_pkts_cpl;
 }