patch 'vhost: fix field naming in guest page struct' has been queued to stable release 20.11.5

luca.boccassi at gmail.com luca.boccassi at gmail.com
Mon Feb 28 22:20:21 CET 2022


Hi,

FYI, your patch has been queued to stable release 20.11.5

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/02/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/37936eb9ef29c14517cf5229486f53fb29bfe79e

Thanks.

Luca Boccassi

---
>From 37936eb9ef29c14517cf5229486f53fb29bfe79e Mon Sep 17 00:00:00 2001
From: Xuan Ding <xuan.ding at intel.com>
Date: Tue, 15 Feb 2022 15:02:25 +0000
Subject: [PATCH] vhost: fix field naming in guest page struct

[ upstream commit 2ec359747e61db15ab18a78fa35f503a4f647463 ]

This patch renames the host_phys_addr to host_iova in guest_page
struct. The host_phys_addr is iova, it depends on the DPDK
IOVA mode.

Fixes: e246896178e6 ("vhost: get guest/host physical address mappings")

Signed-off-by: Xuan Ding <xuan.ding at intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/librte_vhost/vhost.h      | 10 +++++-----
 lib/librte_vhost/vhost_user.c | 20 ++++++++++----------
 lib/librte_vhost/virtio_net.c |  8 ++++----
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 36d6fdabd8..92b67a2c6f 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -333,7 +333,7 @@ struct vring_packed_desc_event {
 
 struct guest_page {
 	uint64_t guest_phys_addr;
-	uint64_t host_phys_addr;
+	uint64_t host_iova;
 	uint64_t size;
 };
 
@@ -596,13 +596,13 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
 			if (gpa + gpa_size <=
 					page->guest_phys_addr + page->size) {
 				return gpa - page->guest_phys_addr +
-					page->host_phys_addr;
+					page->host_iova;
 			} else if (gpa < page->guest_phys_addr +
 						page->size) {
 				*hpa_size = page->guest_phys_addr +
 					page->size - gpa;
 				return gpa - page->guest_phys_addr +
-					page->host_phys_addr;
+					page->host_iova;
 			}
 		}
 	} else {
@@ -613,13 +613,13 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
 				if (gpa + gpa_size <=
 					page->guest_phys_addr + page->size) {
 					return gpa - page->guest_phys_addr +
-						page->host_phys_addr;
+						page->host_iova;
 				} else if (gpa < page->guest_phys_addr +
 							page->size) {
 					*hpa_size = page->guest_phys_addr +
 						page->size - gpa;
 					return gpa - page->guest_phys_addr +
-						page->host_phys_addr;
+						page->host_iova;
 				}
 			}
 		}
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 843bfbbfd9..0ee54def9c 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -903,7 +903,7 @@ vhost_user_set_vring_base(struct virtio_net **pdev,
 
 static int
 add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
-		   uint64_t host_phys_addr, uint64_t size)
+		   uint64_t host_iova, uint64_t size)
 {
 	struct guest_page *page, *last_page;
 	struct guest_page *old_pages;
@@ -924,7 +924,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
 	if (dev->nr_guest_pages > 0) {
 		last_page = &dev->guest_pages[dev->nr_guest_pages - 1];
 		/* merge if the two pages are continuous */
-		if (host_phys_addr == last_page->host_phys_addr +
+		if (host_iova == last_page->host_iova +
 				      last_page->size) {
 			last_page->size += size;
 			return 0;
@@ -933,7 +933,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
 
 	page = &dev->guest_pages[dev->nr_guest_pages++];
 	page->guest_phys_addr = guest_phys_addr;
-	page->host_phys_addr  = host_phys_addr;
+	page->host_iova  = host_iova;
 	page->size = size;
 
 	return 0;
@@ -946,14 +946,14 @@ add_guest_pages(struct virtio_net *dev, struct rte_vhost_mem_region *reg,
 	uint64_t reg_size = reg->size;
 	uint64_t host_user_addr  = reg->host_user_addr;
 	uint64_t guest_phys_addr = reg->guest_phys_addr;
-	uint64_t host_phys_addr;
+	uint64_t host_iova;
 	uint64_t size;
 
-	host_phys_addr = rte_mem_virt2iova((void *)(uintptr_t)host_user_addr);
+	host_iova = rte_mem_virt2iova((void *)(uintptr_t)host_user_addr);
 	size = page_size - (guest_phys_addr & (page_size - 1));
 	size = RTE_MIN(size, reg_size);
 
-	if (add_one_guest_page(dev, guest_phys_addr, host_phys_addr, size) < 0)
+	if (add_one_guest_page(dev, guest_phys_addr, host_iova, size) < 0)
 		return -1;
 
 	host_user_addr  += size;
@@ -962,9 +962,9 @@ add_guest_pages(struct virtio_net *dev, struct rte_vhost_mem_region *reg,
 
 	while (reg_size > 0) {
 		size = RTE_MIN(reg_size, page_size);
-		host_phys_addr = rte_mem_virt2iova((void *)(uintptr_t)
+		host_iova = rte_mem_virt2iova((void *)(uintptr_t)
 						  host_user_addr);
-		if (add_one_guest_page(dev, guest_phys_addr, host_phys_addr,
+		if (add_one_guest_page(dev, guest_phys_addr, host_iova,
 				size) < 0)
 			return -1;
 
@@ -996,11 +996,11 @@ dump_guest_pages(struct virtio_net *dev)
 		VHOST_LOG_CONFIG(INFO,
 			"guest physical page region %u\n"
 			"\t guest_phys_addr: %" PRIx64 "\n"
-			"\t host_phys_addr : %" PRIx64 "\n"
+			"\t host_iova      : %" PRIx64 "\n"
 			"\t size           : %" PRIx64 "\n",
 			i,
 			page->guest_phys_addr,
-			page->host_phys_addr,
+			page->host_iova,
 			page->size);
 	}
 }
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index e165a70afc..d4e9da308a 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -990,7 +990,7 @@ async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 
 	uint32_t tlen = 0;
 	int tvec_idx = 0;
-	void *hpa;
+	void *host_iova;
 
 	if (unlikely(m == NULL)) {
 		error = -1;
@@ -1081,11 +1081,11 @@ async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 		cpy_len = RTE_MIN(buf_avail, mbuf_avail);
 
 		while (unlikely(cpy_len && cpy_len >= cpy_threshold)) {
-			hpa = (void *)(uintptr_t)gpa_to_first_hpa(dev,
+			host_iova = (void *)(uintptr_t)gpa_to_first_hpa(dev,
 					buf_iova + buf_offset,
 					cpy_len, &mapped_len);
 
-			if (unlikely(!hpa || mapped_len < cpy_threshold))
+			if (unlikely(!host_iova || mapped_len < cpy_threshold))
 				break;
 
 			async_fill_vec(src_iovec + tvec_idx,
@@ -1093,7 +1093,7 @@ async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 				mbuf_offset), (size_t)mapped_len);
 
 			async_fill_vec(dst_iovec + tvec_idx,
-					hpa, (size_t)mapped_len);
+					host_iova, (size_t)mapped_len);
 
 			tlen += (uint32_t)mapped_len;
 			cpy_len -= (uint32_t)mapped_len;
-- 
2.30.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-02-28 21:17:55.999244109 +0000
+++ 0025-vhost-fix-field-naming-in-guest-page-struct.patch	2022-02-28 21:17:53.904930633 +0000
@@ -1 +1 @@
-From 2ec359747e61db15ab18a78fa35f503a4f647463 Mon Sep 17 00:00:00 2001
+From 37936eb9ef29c14517cf5229486f53fb29bfe79e Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 2ec359747e61db15ab18a78fa35f503a4f647463 ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org
@@ -16,4 +17,4 @@
- lib/vhost/vhost.h      | 10 +++++-----
- lib/vhost/vhost_user.c | 20 ++++++++++----------
- lib/vhost/virtio_net.c | 11 ++++++-----
- 3 files changed, 21 insertions(+), 20 deletions(-)
+ lib/librte_vhost/vhost.h      | 10 +++++-----
+ lib/librte_vhost/vhost_user.c | 20 ++++++++++----------
+ lib/librte_vhost/virtio_net.c |  8 ++++----
+ 3 files changed, 19 insertions(+), 19 deletions(-)
@@ -21,5 +22,5 @@
-diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
-index 64ec76b80e..5606360414 100644
---- a/lib/vhost/vhost.h
-+++ b/lib/vhost/vhost.h
-@@ -424,7 +424,7 @@ struct vring_packed_desc_event {
+diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
+index 36d6fdabd8..92b67a2c6f 100644
+--- a/lib/librte_vhost/vhost.h
++++ b/lib/librte_vhost/vhost.h
+@@ -333,7 +333,7 @@ struct vring_packed_desc_event {
@@ -34 +35 @@
-@@ -687,13 +687,13 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
+@@ -596,13 +596,13 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
@@ -50 +51 @@
-@@ -704,13 +704,13 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
+@@ -613,13 +613,13 @@ gpa_to_first_hpa(struct virtio_net *dev, uint64_t gpa,
@@ -66,5 +67,5 @@
-diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
-index 4f135f1f72..8257a92e12 100644
---- a/lib/vhost/vhost_user.c
-+++ b/lib/vhost/vhost_user.c
-@@ -986,7 +986,7 @@ vhost_user_set_vring_base(struct virtio_net **pdev,
+diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
+index 843bfbbfd9..0ee54def9c 100644
+--- a/lib/librte_vhost/vhost_user.c
++++ b/lib/librte_vhost/vhost_user.c
+@@ -903,7 +903,7 @@ vhost_user_set_vring_base(struct virtio_net **pdev,
@@ -79 +80 @@
-@@ -1007,7 +1007,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
+@@ -924,7 +924,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
@@ -88 +89 @@
-@@ -1016,7 +1016,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
+@@ -933,7 +933,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
@@ -97 +98 @@
-@@ -1029,14 +1029,14 @@ add_guest_pages(struct virtio_net *dev, struct rte_vhost_mem_region *reg,
+@@ -946,14 +946,14 @@ add_guest_pages(struct virtio_net *dev, struct rte_vhost_mem_region *reg,
@@ -115 +116 @@
-@@ -1045,9 +1045,9 @@ add_guest_pages(struct virtio_net *dev, struct rte_vhost_mem_region *reg,
+@@ -962,9 +962,9 @@ add_guest_pages(struct virtio_net *dev, struct rte_vhost_mem_region *reg,
@@ -127,10 +128,12 @@
-@@ -1080,8 +1080,8 @@ dump_guest_pages(struct virtio_net *dev)
- 				dev->ifname, i);
- 		VHOST_LOG_CONFIG(INFO, "(%s)\tguest_phys_addr: %" PRIx64 "\n",
- 				dev->ifname, page->guest_phys_addr);
--		VHOST_LOG_CONFIG(INFO, "(%s)\thost_phys_addr : %" PRIx64 "\n",
--				dev->ifname, page->host_phys_addr);
-+		VHOST_LOG_CONFIG(INFO, "(%s)\thost_iova : %" PRIx64 "\n",
-+				dev->ifname, page->host_iova);
- 		VHOST_LOG_CONFIG(INFO, "(%s)\tsize           : %" PRIx64 "\n",
- 				dev->ifname, page->size);
+@@ -996,11 +996,11 @@ dump_guest_pages(struct virtio_net *dev)
+ 		VHOST_LOG_CONFIG(INFO,
+ 			"guest physical page region %u\n"
+ 			"\t guest_phys_addr: %" PRIx64 "\n"
+-			"\t host_phys_addr : %" PRIx64 "\n"
++			"\t host_iova      : %" PRIx64 "\n"
+ 			"\t size           : %" PRIx64 "\n",
+ 			i,
+ 			page->guest_phys_addr,
+-			page->host_phys_addr,
++			page->host_iova,
+ 			page->size);
@@ -138,8 +141,9 @@
-diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
-index 886e076b28..5f432b0d77 100644
---- a/lib/vhost/virtio_net.c
-+++ b/lib/vhost/virtio_net.c
-@@ -1004,20 +1004,21 @@ async_mbuf_to_desc_seg(struct virtio_net *dev, struct vhost_virtqueue *vq,
- 	struct vhost_async *async = vq->async;
- 	uint64_t mapped_len;
- 	uint32_t buf_offset = 0;
+ }
+diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
+index e165a70afc..d4e9da308a 100644
+--- a/lib/librte_vhost/virtio_net.c
++++ b/lib/librte_vhost/virtio_net.c
+@@ -990,7 +990,7 @@ async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
+ 
+ 	uint32_t tlen = 0;
+ 	int tvec_idx = 0;
@@ -149,18 +153,22 @@
- 	while (cpy_len) {
--		hpa = (void *)(uintptr_t)gpa_to_first_hpa(dev,
-+		host_iova = (void *)(uintptr_t)gpa_to_first_hpa(dev,
- 				buf_iova + buf_offset, cpy_len, &mapped_len);
--		if (unlikely(!hpa)) {
--			VHOST_LOG_DATA(ERR, "(%s) %s: failed to get hpa.\n", dev->ifname, __func__);
-+		if (unlikely(!host_iova)) {
-+			VHOST_LOG_DATA(ERR, "(%s) %s: failed to get host iova.\n",
-+				       dev->ifname, __func__);
- 			return -1;
- 		}
- 
- 		if (unlikely(async_iter_add_iovec(dev, async,
- 						(void *)(uintptr_t)rte_pktmbuf_iova_offset(m,
- 							mbuf_offset),
--						hpa, (size_t)mapped_len)))
-+						host_iova, (size_t)mapped_len)))
- 			return -1;
+ 	if (unlikely(m == NULL)) {
+ 		error = -1;
+@@ -1081,11 +1081,11 @@ async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
+ 		cpy_len = RTE_MIN(buf_avail, mbuf_avail);
+ 
+ 		while (unlikely(cpy_len && cpy_len >= cpy_threshold)) {
+-			hpa = (void *)(uintptr_t)gpa_to_first_hpa(dev,
++			host_iova = (void *)(uintptr_t)gpa_to_first_hpa(dev,
+ 					buf_iova + buf_offset,
+ 					cpy_len, &mapped_len);
+ 
+-			if (unlikely(!hpa || mapped_len < cpy_threshold))
++			if (unlikely(!host_iova || mapped_len < cpy_threshold))
+ 				break;
+ 
+ 			async_fill_vec(src_iovec + tvec_idx,
+@@ -1093,7 +1093,7 @@ async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
+ 				mbuf_offset), (size_t)mapped_len);
+ 
+ 			async_fill_vec(dst_iovec + tvec_idx,
+-					hpa, (size_t)mapped_len);
++					host_iova, (size_t)mapped_len);
@@ -168 +176,2 @@
- 		cpy_len -= (uint32_t)mapped_len;
+ 			tlen += (uint32_t)mapped_len;
+ 			cpy_len -= (uint32_t)mapped_len;


More information about the stable mailing list