From: xuan.ding@intel.com
To: maxime.coquelin@redhat.com, chenbo.xia@intel.com
Cc: dev@dpdk.org, jiayu.hu@intel.com, yuanx.wang@intel.com,
Xuan Ding <xuan.ding@intel.com>
Subject: [PATCH v2 1/2] vhost: rename field in guest page struct
Date: Wed, 19 Jan 2022 15:10:15 +0000 [thread overview]
Message-ID: <20220119151016.9970-2-xuan.ding@intel.com> (raw)
In-Reply-To: <20220119151016.9970-1-xuan.ding@intel.com>
From: Xuan Ding <xuan.ding@intel.com>
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.
Signed-off-by: Xuan Ding <xuan.ding@intel.com>
---
lib/vhost/vhost.h | 10 +++++-----
lib/vhost/vhost_user.c | 20 ++++++++++----------
lib/vhost/virtio_net.c | 11 ++++++-----
3 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
index 7085e0885c..ca7f58039d 100644
--- a/lib/vhost/vhost.h
+++ b/lib/vhost/vhost.h
@@ -354,7 +354,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;
};
@@ -604,13 +604,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 {
@@ -621,13 +621,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/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index a781346c4d..95c9df697e 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -978,7 +978,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;
@@ -999,7 +999,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;
@@ -1008,7 +1008,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;
@@ -1021,14 +1021,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;
@@ -1037,9 +1037,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;
@@ -1071,11 +1071,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/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index b3d954aab4..226dcc8b18 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -870,20 +870,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;
- void *hpa;
+ void *host_iova;
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, "(%d) %s: failed to get hpa.\n", dev->vid, __func__);
+ if (unlikely(!host_iova)) {
+ VHOST_LOG_DATA(ERR, "(%d) %s: failed to get host iova.\n",
+ dev->vid, __func__);
return -1;
}
if (unlikely(async_iter_add_iovec(async,
(void *)(uintptr_t)rte_pktmbuf_iova_offset(m,
mbuf_offset),
- hpa, (size_t)mapped_len)))
+ host_iova, (size_t)mapped_len)))
return -1;
cpy_len -= (uint32_t)mapped_len;
--
2.17.1
next prev parent reply other threads:[~2022-01-19 6:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-19 15:10 [PATCH v2 0/2] vhost: fix async address mapping xuan.ding
2022-01-19 15:10 ` xuan.ding [this message]
2022-02-01 8:47 ` [PATCH v2 1/2] vhost: rename field in guest page struct Maxime Coquelin
2022-01-19 15:10 ` [PATCH v2 2/2] vhost: fix physical address mapping xuan.ding
2022-02-01 8:51 ` Maxime Coquelin
2022-02-04 10:43 ` Maxime Coquelin
2022-02-01 8:28 ` [PATCH v2 0/2] vhost: fix async " Maxime Coquelin
2022-02-01 11:29 ` Kevin Traynor
2022-02-04 10:43 ` Maxime Coquelin
2022-02-04 10:56 ` Maxime Coquelin
2022-02-11 2:48 ` Ding, Xuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220119151016.9970-2-xuan.ding@intel.com \
--to=xuan.ding@intel.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=jiayu.hu@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=yuanx.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).