* [PATCH 19.11] vhost: fix field naming in guest page struct
@ 2022-03-15 7:26 xuan.ding
0 siblings, 0 replies; 2+ messages in thread
From: xuan.ding @ 2022-03-15 7:26 UTC (permalink / raw)
To: christian.ehrhardt; +Cc: stable, Xuan Ding
From: Xuan Ding <xuan.ding@intel.com>
[ 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@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/librte_vhost/vhost.h | 4 ++--
lib/librte_vhost/vhost_user.c | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index deeca18f8..5611d0959 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -310,7 +310,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;
};
@@ -536,7 +536,7 @@ gpa_to_hpa(struct virtio_net *dev, uint64_t gpa, uint64_t size)
if (gpa >= page->guest_phys_addr &&
gpa + size < page->guest_phys_addr + page->size) {
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 af44d1e69..3264bf7dd 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -931,7 +931,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;
@@ -952,7 +952,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;
@@ -961,7 +961,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;
@@ -974,14 +974,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;
@@ -990,10 +990,10 @@ 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,
- size) < 0)
+ if (add_one_guest_page(dev, guest_phys_addr,
+ host_iova, size) < 0)
return -1;
host_user_addr += size;
@@ -1018,11 +1018,11 @@ dump_guest_pages(struct virtio_net *dev)
RTE_LOG(INFO, VHOST_CONFIG,
"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);
}
}
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 19.11] vhost: fix field naming in guest page struct
@ 2022-03-15 7:17 xuan.ding
0 siblings, 0 replies; 2+ messages in thread
From: xuan.ding @ 2022-03-15 7:17 UTC (permalink / raw)
To: christian.ehrhardt; +Cc: stable, Xuan Ding
From: Xuan Ding <xuan.ding@intel.com>
[ 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@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/librte_vhost/vhost.h | 4 ++--
lib/librte_vhost/vhost_user.c | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index deeca18f8..5611d0959 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -310,7 +310,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;
};
@@ -536,7 +536,7 @@ gpa_to_hpa(struct virtio_net *dev, uint64_t gpa, uint64_t size)
if (gpa >= page->guest_phys_addr &&
gpa + size < page->guest_phys_addr + page->size) {
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 af44d1e69..b08e3865c 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -931,7 +931,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;
@@ -952,7 +952,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;
@@ -961,7 +961,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;
@@ -974,14 +974,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;
@@ -990,10 +990,10 @@ 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,
- size) < 0)
+ if (add_one_guest_page(dev, guest_phys_addr,
+ host_iova, size) < 0)
return -1;
host_user_addr += size;
@@ -1018,11 +1018,11 @@ dump_guest_pages(struct virtio_net *dev)
RTE_LOG(INFO, VHOST_CONFIG,
"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);
}
}
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-15 7:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 7:26 [PATCH 19.11] vhost: fix field naming in guest page struct xuan.ding
-- strict thread matches above, loose matches on Subject: below --
2022-03-15 7:17 xuan.ding
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).