From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6052AA00C5; Wed, 16 Feb 2022 03:29:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00D2341142; Wed, 16 Feb 2022 03:29:05 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 21C8A4113F; Wed, 16 Feb 2022 03:29:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644978543; x=1676514543; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=UaHR7A5Ub+LQ7wME2pn3tvWoSJPaZ6dIubWN38r3wg4=; b=C3cDuEL0yP6tAd1EXNZUlfyRE3iP0TesbLBTuIBC6dsCMm6VrQUZ/7OE JPE8K6sEbsmZdtStKY5yTc56Uge7cwjCe6OkzhYIwjMNvPxxd/wG+NHHZ wKk7biBt5STZoq84ILz/t6ZQeADJQmQISdijImJZxAIxUZ7sEnwf2Pr/P hxMskpf0GN3JN1jQtV2REjAfDxqkD4h5P6aezTQYNwImhtOR2XmuZVg0c nKwiHsUlt946TkwI0KykmsnLznXE/rGSW2bhT2zZg0F873U6hvvdPwI3v Vt5G8KwasSSF+dYTrv26DibbDtR+ymCOJ0GazI6U1jmZKQ4cCWMyoAord w==; X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="237910978" X-IronPort-AV: E=Sophos;i="5.88,371,1635231600"; d="scan'208";a="237910978" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2022 18:29:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,371,1635231600"; d="scan'208";a="704087821" Received: from npg-dpdk-xuan-cbdma.sh.intel.com ([10.67.110.228]) by orsmga005.jf.intel.com with ESMTP; 15 Feb 2022 18:29:00 -0800 From: xuan.ding@intel.com To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, ktraynor@redhat.com, ferruh.yigit@intel.com, jiayu.hu@intel.com, yuanx.wang@intel.com, Xuan Ding , stable@dpdk.org Subject: [PATCH v4 1/2] vhost: fix field naming in guest page struct Date: Wed, 16 Feb 2022 02:28:53 +0000 Message-Id: <20220216022854.39057-2-xuan.ding@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220216022854.39057-1-xuan.ding@intel.com> References: <20220114161200.114422-1-xuan.ding@intel.com> <20220216022854.39057-1-xuan.ding@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Xuan Ding 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") Cc: stable@dpdk.org Signed-off-by: Xuan Ding Reviewed-by: Maxime Coquelin --- 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 1c2ee29600..ccac679c25 100644 --- a/lib/vhost/vhost.h +++ b/lib/vhost/vhost.h @@ -426,7 +426,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; }; @@ -689,13 +689,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 { @@ -706,13 +706,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 1d3f89afd8..066adfb464 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -988,7 +988,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; @@ -1009,7 +1009,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; @@ -1018,7 +1018,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; @@ -1031,14 +1031,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; @@ -1047,9 +1047,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; @@ -1082,8 +1082,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); } 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; - 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, "(%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; cpy_len -= (uint32_t)mapped_len; -- 2.17.1