support to clear in-flight packets for async
cover support to clear in-flight packets for async
This patch supports to clear in-flight packets for aysnc dequeue and introduces thread-safe version of this function.
Yuan Wang (2):
vhost: support to clear in-flight packets for async dequeue
vhost: support thread-safe API for clearing in-flight packets in async
vhost
lib/vhost/rte_vhost_async.h | 21 +++++++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 46 ++++++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH 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.
--- lib/vhost/virtio_net.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
lib/vhost/virtio_net.c +10 -6
@@ -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 boolrxvq_is_mergeable (struct virtio_net *dev) {
@@ -2119,11 +2124,6 @@ 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))) { -VHOST_LOG_DATA (ERR ,"(%d) %s: invalid virtqueue idx %d.\n" , - dev->vid, __func__, queue_id); -return 0 ; - } vq = dev->virtqueue[queue_id];
@@ -2133,7 +2133,11 @@ 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 + 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; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH 1/2] vhost: support to clear in-flight packets for async dequeue
Hi Yuan,
Quoted 51 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, September 9, 2021 2:58 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Pai G, Sunil <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH 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 <[email protected]>--- lib/vhost/virtio_net.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)lib/vhost/virtio_net.c +5
-5@@ -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 boolrxvq_is_mergeable (struct virtio_net *dev) {@@ -2119,11 +2124,6 @@ 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))) { -VHOST_LOG_DATA (ERR ,"(%d) %s: invalid virtqueue idx %d.\n" , - dev->vid, __func__, queue_id); -return 0 ; - } vq = dev->virtqueue[queue_id];
lib/vhost/virtio_net.c rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t · line 2137
Quoted 6 lines
lib/vhost/virtio_net.c +1
-1@@ -2133,7 +2133,11 @@ 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 )
You can remove the internal '()'.
lib/vhost/virtio_net.c rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t · line 2142
Quoted 5 lines
lib/vhost/virtio_net.c +3
-0+ n_pkts_cpl =vhost_poll_enqueue_completed (dev, queue_id, pkts, count); + else + n_pkts_cpl = async_poll_dequeue_completed_split(dev, vq, queue_id, pkts, count,
You should check we are using split queue before entering this split queue function.
Thanks,
Chenbo
Quoted 6 lines
lib/vhost/virtio_net.c +1
-0+ dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS);return
n_pkts_cpl;
}
--
2.25.1
Re: [dpdk-dev] [PATCH 1/2] vhost: support to clear in-flight packets for async dequeue
In reply to Yuan WangQuoted 14 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, September 9, 2021 2:58 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Pai G, Sunil <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH 1/2] vhost: support to clear in-flight packets for async dequeue
Quoted 6 lines
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 <[email protected]>---
PATCH 2/2 vhost: support thread-safe API for clearing in-flight packets in async vhost
In reply to Yuan WangThis patch adds thread-safe version for
clearing in-flight packets function.
--- lib/vhost/rte_vhost_async.h | 21 +++++++++++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+)
lib/vhost/rte_vhost_async.h +21 -0
@@ -261,6 +261,27 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);__rte_experimental uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count); + +/** +* This function checks async completion status and clear packets for +* a specific vhost device queue. Packets which are inflight will be +* returned in an array. +* +* @param vid +* ID of vhost device to clear data +* @param queue_id +* Queue id to clear data +* @param pkts +* Blank array to get return packet pointer +* @param count +* Size of the packet array +* @return +* Number of packets returned +*/ +__rte_experimental +uint16_t rte_vhost_clear_queue(int vid, uint16_t queue_id, +struct rte_mbuf **pkts,uint16_t count); +/** * This function tries to receive packets from the guest with offloading * copies to the async channel. The packets that are transfer completed
lib/vhost/version.map +1 -0
@@ -88,4 +88,5 @@ EXPERIMENTAL { # added in 21.11 rte_vhost_async_try_dequeue_burst; + rte_vhost_clear_queue; };
lib/vhost/virtio_net.c +36 -0
@@ -2142,6 +2142,42 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,return n_pkts_cpl; } +uint16_t +rte_vhost_clear_queue (int vid,uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; +uint16_t n_pkts_cpl; + +if (!dev) +return 0 ; + +VHOST_LOG_DATA (DEBUG ,"(%d) %s\n" , dev->vid, __func__); + + vq = dev->virtqueue[queue_id]; + +if (unlikely (!vq->async_registered)) { +VHOST_LOG_DATA (ERR ,"(%d) %s: async not registered for queue id %d.\n" , + dev->vid, __func__, queue_id); +return 0 ; + } + +if (!rte_spinlock_trylock (&vq->access_lock)) { +VHOST_LOG_CONFIG (ERR ,"Failed to clear async queue, virt queue busy.\n" ); +return 0 ; + } + +if ((queue_id %2 ) ==0 ) + n_pkts_cpl =vhost_poll_enqueue_completed (dev, queue_id, pkts, count); +else + n_pkts_cpl =async_poll_dequeue_completed_split (dev, vq, queue_id, pkts, count, + dev->flags &VIRTIO_DEV_LEGACY_OL_FLAGS ); + +rte_spinlock_unlock (&vq->access_lock); + +return n_pkts_cpl; +} + static __rte_always_inline uint32_tvirtio_dev_rx_async_submit (struct virtio_net *dev,uint16_t queue_id,struct rte_mbuf **pkts,uint32_t count)
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH 2/2] vhost: support thread-safe API for clearing in-flight packets in async vhost
Hi Yuan,
Quoted 11 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, September 9, 2021 2:58 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Pai G, Sunil <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH 2/2] vhost: support thread-safe API for clearing in-flight packets in async vhost
support -> add
Quoted 10 lines
This patch adds thread-safe version for
clearing in-flight packets function.Signed-off-by Yuan Wang <[email protected]>--- lib/vhost/rte_vhost_async.h | 21 +++++++++++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+)
Miss update of release note.
Quoted 56 lines
lib/vhost/rte_vhost_async.h +21
-0@@ -261,6 +261,27 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);__rte_experimental uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count); + +/** +* This function checks async completion status and clear packets for +* a specific vhost device queue. Packets which are inflight will be +* returned in an array. +* +* @param vid +* ID of vhost device to clear data +* @param queue_id +* Queue id to clear data +* @param pkts +* Blank array to get return packet pointer +* @param count +* Size of the packet array +* @return +* Number of packets returned +*/ +__rte_experimental +uint16_t rte_vhost_clear_queue(int vid, uint16_t queue_id, +struct rte_mbuf **pkts,uint16_t count); +/** * This function tries to receive packets from the guest with offloading * copies to the async channel. The packets that are transfer completed
lib/vhost/version.map +1
-0@@ -88,4 +88,5 @@ EXPERIMENTAL { # added in 21.11 rte_vhost_async_try_dequeue_burst; + rte_vhost_clear_queue; };lib/vhost/virtio_net.c +2
-0@@ -2142,6 +2142,42 @@ rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id, return n_pkts_cpl; } +uint16_t +rte_vhost_clear_queue (int vid,uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count)
lib/vhost/virtio_net.c rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t · line 2158
Quoted 10 lines
lib/vhost/virtio_net.c +10
-0+{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; +uint16_t n_pkts_cpl; + +if (!dev) +return 0 ; + +VHOST_LOG_DATA (DEBUG ,"(%d) %s\n" , dev->vid, __func__); +
Should check queue id here.
Quoted 11 lines
lib/vhost/virtio_net.c +10
-0+ vq = dev->virtqueue[queue_id]; + +if (unlikely (!vq->async_registered)) { + VHOST_LOG_DATA(ERR, "(%d) %s: async not registered for queue id %d.\n", + dev->vid, __func__, queue_id); +return 0 ; + } + +if (!rte_spinlock_trylock (&vq->access_lock)) { + VHOST_LOG_CONFIG(ERR, "Failed to clear async queue, virt queue
Quoted 1 line
busy.\n");
Should be VHOST_LOG_DATA. And please add vid and qid info in the log.
lib/vhost/virtio_net.c rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id, · line 2170
Quoted 4 lines
lib/vhost/virtio_net.c +4
-0+return 0 ; + } + +if ((queue_id %2 ) ==0 )
You can remove internal '()'
Quoted 5 lines
lib/vhost/virtio_net.c +1
-0+ n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id, pkts,count);
lib/vhost/virtio_net.c +2
-0+else + n_pkts_cpl = async_poll_dequeue_completed_split(dev, vq, queue_id,pkts, count,
Add check to make sure it's split queue.
Thanks,
Chenbo
Quoted 12 lines
lib/vhost/virtio_net.c +7
-1+ dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS); + +rte_spinlock_unlock (&vq->access_lock); + +return n_pkts_cpl; +} + static __rte_always_inline uint32_tvirtio_dev_rx_async_submit (struct virtio_net *dev,uint16_t queue_id,struct rte_mbuf **pkts,uint32_t count) --2.25.1
Re: [dpdk-dev] [PATCH 2/2] vhost: support thread-safe API for clearing in-flight packets in async vhost
In reply to Yuan WangQuoted 14 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, September 9, 2021 2:58 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Pai G, Sunil <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH 2/2] vhost: support thread-safe API for clearing in-flight packets in async vhost
Quoted 5 lines
This patch adds thread-safe version for
clearing in-flight packets function.Signed-off-by Yuan Wang <[email protected]>---
Hi Yuan,
Quoted 11 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, September 9, 2021 2:58 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Pai G, Sunil <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH 0/2] support to clear in-flight packets for async
Quoted 2 lines
This patch supports to clear in-flight packets for aysnc dequeue and introduces thread-safe version of this function.
It'll be better if you can list the patchset this one depends on, otherwise it will increase overhead for reviewers. Luckily I know the dependency, but let's add it in new version.
Thanks,
Chenbo
Quoted 13 lines
Yuan Wang (2):
vhost: support to clear in-flight packets for async dequeue
vhost: support thread-safe API for clearing in-flight packets in async
vhostlib/vhost/rte_vhost_async.h | 21 +++++++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 46 ++++++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 3 deletions(-)--
2.25.1
v2 cover support to clear in-flight packets for async
In reply to Yuan WangThis patch supports to clear in-flight packets for aysnc dequeue and introduces thread-safe version of this function.
note: This patch depends on the following vhost patch
(http://patchwork.dpdk.org/project/dpdk/patch/[email protected]/)
v2:
- Update release note.
- Add check on queue id and split queue.
Yuan Wang (2):
vhost: support to clear in-flight packets for async dequeue
vhost: add thread-safe API for clearing in-flight packets in async
vhost
doc/guides/prog_guide/vhost_lib.rst | 8 +++- lib/vhost/rte_vhost_async.h | 21 +++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 68 ++++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 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.
--- lib/vhost/virtio_net.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
lib/vhost/virtio_net.c +17 -2
@@ -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 boolrxvq_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; }
Signature · 1 line
2.25.1
PATCH v2 2/2 vhost: add thread-safe API for clearing in-flight packets in async vhost
In reply to Yuan WangThis patch adds thread safe version for
clearing in-flight packets function.
--- doc/guides/prog_guide/vhost_lib.rst | 8 ++++- lib/vhost/rte_vhost_async.h | 21 +++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 49 +++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-)
doc/guides/prog_guide/vhost_lib.rst +7 -1
@@ -300,7 +300,13 @@ The following is an overview of some key Vhost API functions: * ``rte_vhost_clear_queue_thread_unsafe(vid, queue_id, **pkts, count)`` - Clear inflight packets which are submitted to DMA engine in vhost async data + Clear in-flight packets which are submitted to async channel in vhost + async data path without performing any locking. Completed packets are + returned to applications through ``pkts``. + +* ``rte_vhost_clear_queue(vid, queue_id, **pkts, count)`` + + Clear in-flight packets which are submitted to async channel in vhost async data path. Completed packets are returned to applications through ``pkts``. * ``rte_vhost_async_try_dequeue_burst(vid, queue_id, mbuf_pool, pkts, count, nr_inflight)``
lib/vhost/rte_vhost_async.h +21 -0
@@ -256,6 +256,27 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);__rte_experimental uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count); + +/** +* This function checks async completion status and clear packets for +* a specific vhost device queue. Packets which are inflight will be +* returned in an array. +* +* @param vid +* ID of vhost device to clear data +* @param queue_id +* Queue id to clear data +* @param pkts +* Blank array to get return packet pointer +* @param count +* Size of the packet array +* @return +* Number of packets returned +*/ +__rte_experimental +uint16_t rte_vhost_clear_queue(int vid, uint16_t queue_id, +struct rte_mbuf **pkts,uint16_t count); +/** * This function tries to receive packets from the guest with offloading * copies to the async channel. The packets that are transfer completed
lib/vhost/version.map +1 -0
@@ -88,4 +88,5 @@ EXPERIMENTAL { # added in 21.11 rte_vhost_async_try_dequeue_burst; + rte_vhost_clear_queue; };
lib/vhost/virtio_net.c +49 -0
55 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 21 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Thursday, September 9, 2021 2:58 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Pai G, Sunil <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH 0/2] support to clear in-flight packets for asyncThis patch supports to clear in-flight packets for aysnc dequeue and introduces thread-safe version of this function.
Yuan Wang (2):
vhost: support to clear in-flight packets for async dequeue
vhost: support thread-safe API for clearing in-flight packets in async
vhost
Quoted 7 lines
lib/vhost/rte_vhost_async.h | 21 +++++++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 46 ++++++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 3 deletions(-)--
2.25.1
v3 cover support to clear in-flight packets for async
In reply to Yuan WangThis patch supports to clear in-flight packets for aysnc dequeue and introduces thread-safe version of this function.
note: This patch depends on the following patch
(http://patchwork.dpdk.org/project/dpdk/patch/[email protected]/)
---
v3:
- Fix uninitialized issue in 2/2.
v2:
- Update release note.
- Add check on queue id and split queue.
Yuan Wang (2):
vhost: support to clear in-flight packets for async dequeue
vhost: add thread-safe API for clearing in-flight packets in async
vhost
doc/guides/prog_guide/vhost_lib.rst | 8 +++- lib/vhost/rte_vhost_async.h | 21 +++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 68 ++++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
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.
--- lib/vhost/virtio_net.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
lib/vhost/virtio_net.c +17 -2
@@ -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 boolrxvq_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; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 1/2] vhost: support to clear in-flight packets for async dequeue
Quoted 14 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Wednesday, September 22, 2021 4:56 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Pai G, Sunil <[email protected]>
Subject: [PATCH v3 1/2] vhost: support to clear in-flight packets for async dequeue
Quoted 6 lines
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 <[email protected]>---
PATCH v3 2/2 vhost: add thread-safe API for clearing in-flight packets in async vhost
In reply to Yuan WangThis patch adds thread safe version for
clearing in-flight packets function.
--- doc/guides/prog_guide/vhost_lib.rst | 8 ++++- lib/vhost/rte_vhost_async.h | 21 +++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 49 +++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-)
doc/guides/prog_guide/vhost_lib.rst +7 -1
@@ -300,7 +300,13 @@ The following is an overview of some key Vhost API functions: * ``rte_vhost_clear_queue_thread_unsafe(vid, queue_id, **pkts, count)`` - Clear inflight packets which are submitted to DMA engine in vhost async data + Clear in-flight packets which are submitted to async channel in vhost + async data path without performing any locking. Completed packets are + returned to applications through ``pkts``. + +* ``rte_vhost_clear_queue(vid, queue_id, **pkts, count)`` + + Clear in-flight packets which are submitted to async channel in vhost async data path. Completed packets are returned to applications through ``pkts``. * ``rte_vhost_async_try_dequeue_burst(vid, queue_id, mbuf_pool, pkts, count, nr_inflight)``
lib/vhost/rte_vhost_async.h +21 -0
@@ -261,6 +261,27 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);__rte_experimental uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count); + +/** +* This function checks async completion status and clear packets for +* a specific vhost device queue. Packets which are inflight will be +* returned in an array. +* +* @param vid +* ID of vhost device to clear data +* @param queue_id +* Queue id to clear data +* @param pkts +* Blank array to get return packet pointer +* @param count +* Size of the packet array +* @return +* Number of packets returned +*/ +__rte_experimental +uint16_t rte_vhost_clear_queue(int vid, uint16_t queue_id, +struct rte_mbuf **pkts,uint16_t count); +/** * This function tries to receive packets from the guest with offloading * copies to the async channel. The packets that are transfer completed
lib/vhost/version.map +1 -0
@@ -88,4 +88,5 @@ EXPERIMENTAL { # added in 21.11 rte_vhost_async_try_dequeue_burst; + rte_vhost_clear_queue; };
lib/vhost/virtio_net.c +49 -0
55 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 2/2] vhost: add thread-safe API for clearing in-flight packets in async vhost
Quoted 14 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Wednesday, September 22, 2021 4:56 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Pai G, Sunil <[email protected]>
Subject: [PATCH v3 2/2] vhost: add thread-safe API for clearing in-flight packets in async vhost
Quoted 5 lines
This patch adds thread safe version for
clearing in-flight packets function.Signed-off-by Yuan Wang <[email protected]>---
Re: [dpdk-dev] [PATCH v3 2/2] vhost: add thread-safe API for clearing in-flight packets in async vhost
In reply to Yuan WangHi Yuan,
Quoted 12 lines
-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Wednesday, September 22, 2021 4:56 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; Hu, Jiayu <[email protected]>; Ding, Xuan <[email protected]>; Jiang, Cheng1 <[email protected]>; Ma, WenwuX <[email protected]>; Yang, YvonneX <[email protected]>; Pai G, Sunil <[email protected]>
Subject: [PATCH v3 2/2] vhost: add thread-safe API for clearing in-flight packets in async vhost
Quoted 2 lines
This patch adds thread safe version for
clearing in-flight packets function.
Maybe the commit log can refined to be more accurate, like when will clear in-flight packets needed? What is the difference between thread safe and unsafe version(whether use lock I think).
Quoted 8 lines
Signed-off-by Yuan Wang <[email protected]>--- doc/guides/prog_guide/vhost_lib.rst | 8 ++++- lib/vhost/rte_vhost_async.h | 21 +++++++++++++ lib/vhost/version.map | 1 + lib/vhost/virtio_net.c | 49 +++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-)
Remember to add the new API explanation in 21.11 rel_note.
Thanks,
Xuan
Quoted 139 lines
doc/guides/prog_guide/vhost_lib.rst +0
-0@@ -300,7 +300,13 @@ The following is an overview of some key Vhost APIfunctions:
* ``rte_vhost_clear_queue_thread_unsafe(vid,
queue_id, **pkts, count)``- Clear inflight packets which are submitted to DMA engine in vhost async data
doc/guides/prog_guide/vhost_lib.rst +7
-0+ Clear in-flight packets which are submitted to async channel in vhost + async data path without performing any locking. Completed packets are + returned to applications through ``pkts``. + +* ``rte_vhost_clear_queue(vid, queue_id, **pkts, count)`` + + Clear in-flight packets which are submitted to async channel in vhost asyncdata
path. Completed packets are returned to applications through ``pkts``.* ``rte_vhost_async_try_dequeue_burst(vid,
queue_id,mbuf_pool, pkts,
count, nr_inflight)``lib/vhost/rte_vhost_async.h +21
-0@@ -261,6 +261,27 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);__rte_experimental uint16_t rte_vhost_clear_queue_thread_unsafe(int vid, uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count); + +/** +* This function checks async completion status and clear packets for +* a specific vhost device queue. Packets which are inflight will be +* returned in an array. +* +* @param vid +* ID of vhost device to clear data +* @param queue_id +* Queue id to clear data +* @param pkts +* Blank array to get return packet pointer +* @param count +* Size of the packet array +* @return +* Number of packets returned +*/ +__rte_experimental +uint16_t rte_vhost_clear_queue(int vid, uint16_t queue_id, +struct rte_mbuf **pkts,uint16_t count); +/** * This function tries to receive packets from the guest with offloading * copies to the async channel. The packets that are transfer completed
lib/vhost/version.map +1
-0@@ -88,4 +88,5 @@ EXPERIMENTAL { # added in 21.11 rte_vhost_async_try_dequeue_burst; + rte_vhost_clear_queue; };lib/vhost/virtio_net.c +21
-0@@ -2154,6 +2154,55 @@ rte_vhost_clear_queue_thread_unsafe(int vid,uint16_t queue_id, return n_pkts_cpl; } +uint16_t +rte_vhost_clear_queue (int vid,uint16_t queue_id,struct rte_mbuf **pkts,uint16_t count) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; +uint16_t n_pkts_cpl =0 ; + +if (!dev) +return 0 ; + +VHOST_LOG_DATA (DEBUG ,"(%d) %s\n" , dev->vid, __func__); +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 ; + } + + vq = dev->virtqueue[queue_id]; + +if (unlikely (!vq->async_registered)) { + VHOST_LOG_DATA(ERR, "(%d) %s: async not registered forqueue id %d.\n",
lib/vhost/virtio_net.c +7
-0+ dev->vid, __func__, queue_id); +return 0 ; + } + +if (!rte_spinlock_trylock (&vq->access_lock)) { + VHOST_LOG_DATA(ERR, + "(%d) %s: failed to clear async queue id %d,virtqueue busy.\n",
lib/vhost/virtio_net.c +6
-0+ dev->vid, __func__, queue_id); +return 0 ; + } + +if (queue_id %2 ==0 ) + n_pkts_cpl = vhost_poll_enqueue_completed(dev,
queue_id, pkts, count);lib/vhost/virtio_net.c +4
-0+else { +if (unlikely (vq_is_packed (dev))) + VHOST_LOG_DATA(ERR, + "(%d) %s: async dequeue does not supportpacked ring.\n",
lib/vhost/virtio_net.c +3
-0+ dev->vid, __func__); + else + n_pkts_cpl =async_poll_dequeue_completed_split(dev, vq,
queue_id, pkts,lib/vhost/virtio_net.c +1
-0+ count, dev->flags &
VIRTIO_DEV_LEGACY_OL_FLAGS);lib/vhost/virtio_net.c +7
-1+ } + +rte_spinlock_unlock (&vq->access_lock); + +return n_pkts_cpl; +} + static __rte_always_inline uint32_tvirtio_dev_rx_async_submit (struct virtio_net *dev,uint16_t queue_id,struct rte_mbuf **pkts,uint32_t count) --2.25.1