Skip to contentSkip to conversation

vhost: fix sync dequeue offload

PATCH Applied [email protected] 4 participants 4 messages Jun 24, 2022 – Jul 1, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: fix sync dequeue offload

From: Xuan Ding <[email protected]>

This patch fixes the missing virtio net header copy in sync dequeue path caused by refactoring, which affects dequeue offloading.

Fixes 6d823bb302c7("vhost: prepare sync for descriptor to mbuf refactoring")
---
 lib/vhost/virtio_net.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
lib/vhost/virtio_net.c +11 -3
index 68a26eb17d..d5a9f7c691 100644
@@ -2635,9 +2635,17 @@ desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
 					   buf_iova + buf_offset, cpy_len, false) < 0)
 				goto error;
 		} else {
-			sync_fill_seg(dev, vq, cur, mbuf_offset,
-				      buf_addr + buf_offset,
-				      buf_iova + buf_offset, cpy_len, false);
+			if (hdr && cur == m) {
+				rte_memcpy(rte_pktmbuf_mtod_offset(cur, void *, mbuf_offset),
+					(void *)((uintptr_t)(buf_addr + buf_offset)),
+					cpy_len);
+				vhost_log_cache_write_iova(dev, vq, buf_iova + buf_offset, cpy_len);
+				PRINT_PACKET(dev, (uintptr_t)(buf_addr + buf_offset), cpy_len, 0);
+			} else {
+				sync_fill_seg(dev, vq, cur, mbuf_offset,
+					buf_addr + buf_offset,
+					buf_iova + buf_offset, cpy_len, false);
+			}
 		}
 
 		mbuf_avail  -= cpy_len;
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#1 lore raw
Quoted 13 lines

-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Friday, June 24, 2022 1:38 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ling, WeiX <[email protected]>; Ding, Xuan <[email protected]>
Subject: [PATCH] vhost: fix sync dequeue offload

From: Xuan Ding <[email protected]>

This patch fixes the missing virtio net header copy in sync dequeue path caused by refactoring, which affects dequeue offloading.

Quoted 7 lines
Fixes 6d823bb302c7("vhost: prepare sync for descriptor to mbuf refactoring")
---
 lib/vhost/virtio_net.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 43 lines

-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Friday, June 24, 2022 1:38 PM
To: [email protected]; Xia, Chenbo <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; Ling, WeiX <[email protected]>; Ding, Xuan <[email protected]>
Subject: [PATCH] vhost: fix sync dequeue offload

From: Xuan Ding <[email protected]>

This patch fixes the missing virtio net header copy in sync dequeue path caused by refactoring, which affects dequeue offloading.

Fixes 6d823bb302c7("vhost: prepare sync for descriptor to mbuf

refactoring")

---
 lib/vhost/virtio_net.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
lib/vhost/virtio_net.c +5 -3
index 68a26eb17d..d5a9f7c691 100644
@@ -2635,9 +2635,17 @@ desc_to_mbuf(struct virtio_net *dev, struct
 vhost_virtqueue *vq,
 					   buf_iova + buf_offset, cpy_len, false) <
 0)
 				goto error;
 		} else {
-			sync_fill_seg(dev, vq, cur, mbuf_offset,
-				      buf_addr + buf_offset,
-				      buf_iova + buf_offset, cpy_len, false);
+			if (hdr && cur == m) {
+				rte_memcpy(rte_pktmbuf_mtod_offset(cur, void *,
 mbuf_offset),
+					(void *)((uintptr_t)(buf_addr + buf_offset)),
+					cpy_len);
+				vhost_log_cache_write_iova(dev, vq, buf_iova +

buf_offset, cpy_len);

lib/vhost/virtio_net.c +1 -0
+				PRINT_PACKET(dev, (uintptr_t)(buf_addr +
Quoted 1 line

buf_offset), cpy_len, 0);

Although above logic can also be included in func sync_fill_seg, but it will need to add a new dequeue-specific param, so I would think this patch is fine.

During review of this patch, I also notice one bug that writes dirty page log when doing dequeue. But it's not related to this patch. So:

Quoted 10 lines
lib/vhost/virtio_net.c +5 -1
+			} else {
+				sync_fill_seg(dev, vq, cur, mbuf_offset,
+					buf_addr + buf_offset,
+					buf_iova + buf_offset, cpy_len, false);
+			}
 		}
 
 		mbuf_avail  -= cpy_len;
--

2.17.1

#3 lore raw
In reply to [email protected]
Quoted 6 lines · On 6/24/22 07:38, [email protected] wrote:

From: Xuan Ding <[email protected]>

This patch fixes the missing virtio net header copy in sync dequeue path caused by refactoring, which affects dequeue offloading.

Quoted 7 lines
Fixes 6d823bb302c7("vhost: prepare sync for descriptor to mbuf refactoring")
---
  lib/vhost/virtio_net.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)

Applied to dpdk-next-virtio/main.

Thanks,
Maxime