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 73B4BA0032; Fri, 14 Jan 2022 08:37:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12DD742771; Fri, 14 Jan 2022 08:37:44 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 5112642764 for ; Fri, 14 Jan 2022 08:37:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642145862; x=1673681862; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ZSOQjRxKCJlO4qWpgAunx/Ni+3NpVpNpZwDqr+IT3AE=; b=F8/qJjwDJo/3tdFaXgWpdWbX2tfT7QxHp4hN21KQ3AISnRj577P5AM+U 9JB5nHfXEHFQRxRL2Im84QfWy9DivX4Ads8vEpd+GfV/9U0PCW1V+I3sW 3D1UNsPyBkGuRSJOSQUtK4r7fEFgsNIkdaCpQpGGtXtmJnTnc3PVw28TK RK+v4jmZ1dlWQEYfO09xSibOxB1/f914ar0U+C/NzuihvF+JVzYO1tFqb lltHVgrMYOlEkYPkdaVlDvvwL+Q3rGnoLWh3Ch/OyfHfM/XA0XaySImTR +rEDMg4cXTY+yvz6CGS9+CaBjNuhLYX8jIQUe/OmlT/v5RFeNt/ErD7sT A==; X-IronPort-AV: E=McAfee;i="6200,9189,10226"; a="244402015" X-IronPort-AV: E=Sophos;i="5.88,287,1635231600"; d="scan'208";a="244402015" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2022 23:37:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,287,1635231600"; d="scan'208";a="516259013" Received: from npg-dpdk-xuan-cbdma.sh.intel.com ([10.67.110.228]) by orsmga007.jf.intel.com with ESMTP; 13 Jan 2022 23:37:34 -0800 From: xuan.ding@intel.com To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, yuanx.wang@intel.com, Xuan Ding Subject: [PATCH 2/2] vhost: rename field in guest page struct Date: Fri, 14 Jan 2022 16:12:00 +0000 Message-Id: <20220114161200.114422-3-xuan.ding@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220114161200.114422-1-xuan.ding@intel.com> References: <20220114161200.114422-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. Signed-off-by: Xuan Ding --- lib/vhost/vhost.h | 10 +++++----- lib/vhost/vhost_user.c | 24 ++++++++++++------------ lib/vhost/virtio_net.c | 11 ++++++----- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h index d246538ca5..9521ae56da 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 host_user_addr; uint64_t size; }; @@ -605,13 +605,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 { @@ -622,13 +622,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 6d888766b0..e2e56308b9 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -154,7 +154,7 @@ async_dma_map(struct virtio_net *dev, bool do_map) page = &dev->guest_pages[i]; ret = rte_vfio_container_dma_map(RTE_VFIO_DEFAULT_CONTAINER_FD, page->host_user_addr, - page->host_phys_addr, + page->host_iova, page->size); if (ret) { /* @@ -182,7 +182,7 @@ async_dma_map(struct virtio_net *dev, bool do_map) page = &dev->guest_pages[i]; ret = rte_vfio_container_dma_unmap(RTE_VFIO_DEFAULT_CONTAINER_FD, page->host_user_addr, - page->host_phys_addr, + page->host_iova, page->size); if (ret) { /* like DMA map, ignore the kernel driver case when unmap. */ @@ -977,7 +977,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 host_user_addr, uint64_t size) + uint64_t host_iova, uint64_t host_user_addr, uint64_t size) { struct guest_page *page, *last_page; struct guest_page *old_pages; @@ -998,7 +998,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 + last_page->size + if (host_iova == last_page->host_iova + last_page->size && guest_phys_addr == last_page->guest_phys_addr + last_page->size && host_user_addr == last_page->host_user_addr + last_page->size) { last_page->size += size; @@ -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->host_user_addr = host_user_addr; page->size = size; @@ -1022,14 +1022,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, + if (add_one_guest_page(dev, guest_phys_addr, host_iova, host_user_addr, size) < 0) return -1; @@ -1039,9 +1039,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, host_user_addr, size) < 0) return -1; @@ -1073,11 +1073,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