DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] vhost: support async copy free segmentations
@ 2020-07-15  7:46 patrick.fu
  2020-07-15 11:15 ` [dpdk-dev] [PATCH v2] " patrick.fu
  2020-07-21  5:47 ` [dpdk-dev] [PATCH v3] vhost: fix wrong async completion of multi-seg packets patrick.fu
  0 siblings, 2 replies; 10+ messages in thread
From: patrick.fu @ 2020-07-15  7:46 UTC (permalink / raw)
  To: dev, maxime.coquelin, chenbo.xia; +Cc: Patrick Fu

From: Patrick Fu <patrick.fu@intel.com>

Vhost async enqueue assumes that all async copies should break at packet
boundary. i.e. if a packet is splited into multiple copy segments, the
async engine should always report copy completion when entire packet is
finished. This patch removes the assumption.

Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")

Signed-off-by: Patrick Fu <patrick.fu@intel.com>
---
 lib/librte_vhost/vhost.h      |  3 +++
 lib/librte_vhost/virtio_net.c | 12 ++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 8c01cee42..0f7212f88 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -46,6 +46,8 @@
 
 #define MAX_PKT_BURST 32
 
+#define ASYNC_MAX_POLL_SEG 255
+
 #define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST * 2)
 #define VHOST_MAX_ASYNC_VEC (BUF_VECTOR_MAX * 2)
 
@@ -225,6 +227,7 @@ struct vhost_virtqueue {
 	uint64_t	*async_pending_info;
 	uint16_t	async_pkts_idx;
 	uint16_t	async_pkts_inflight_n;
+	uint16_t	async_last_seg_n;
 
 	/* vq async features */
 	bool		async_inorder;
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 1d0be3dd4..c6fa33f37 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1652,12 +1652,14 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 	start_idx = virtio_dev_rx_async_get_info_idx(pkts_idx,
 		vq_size, vq->async_pkts_inflight_n);
 
-	n_pkts_cpl =
-		vq->async_ops.check_completed_copies(vid, queue_id, 0, count);
+	n_pkts_cpl = vq->async_ops.check_completed_copies(vid, queue_id,
+		0, ASYNC_MAX_POLL_SEG - vq->async_last_seg_n) +
+		vq->async_last_seg_n;
 
 	rte_smp_wmb();
 
-	while (likely(((start_idx + n_pkts_put) & (vq_size - 1)) != pkts_idx)) {
+	while (likely((n_pkts_put < count) &&
+		(((start_idx + n_pkts_put) & (vq_size - 1)) != pkts_idx))) {
 		uint64_t info = async_pending_info[
 			(start_idx + n_pkts_put) & (vq_size - 1)];
 		uint64_t n_segs;
@@ -1666,7 +1668,7 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 		n_segs = info >> ASYNC_PENDING_INFO_N_SFT;
 
 		if (n_segs) {
-			if (!n_pkts_cpl || n_pkts_cpl < n_segs) {
+			if (unlikely(n_pkts_cpl < n_segs)) {
 				n_pkts_put--;
 				n_descs -= info & ASYNC_PENDING_INFO_N_MSK;
 				if (n_pkts_cpl) {
@@ -1684,6 +1686,8 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 		}
 	}
 
+	vq->async_last_seg_n = n_pkts_cpl;
+
 	if (n_pkts_put) {
 		vq->async_pkts_inflight_n -= n_pkts_put;
 		__atomic_add_fetch(&vq->used->idx, n_descs, __ATOMIC_RELEASE);
-- 
2.18.4


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-07-21 14:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15  7:46 [dpdk-dev] [PATCH v1] vhost: support async copy free segmentations patrick.fu
2020-07-15 11:15 ` [dpdk-dev] [PATCH v2] " patrick.fu
2020-07-17  3:21   ` Xia, Chenbo
2020-07-17 11:52     ` Ferruh Yigit
2020-07-20 14:58   ` Maxime Coquelin
2020-07-20 16:49     ` Ferruh Yigit
2020-07-21  5:52     ` Fu, Patrick
2020-07-21  5:47 ` [dpdk-dev] [PATCH v3] vhost: fix wrong async completion of multi-seg packets patrick.fu
2020-07-21  8:40   ` Maxime Coquelin
2020-07-21 14:57     ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).