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 7880FA0350 for ; Mon, 28 Feb 2022 22:22:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7414A41181; Mon, 28 Feb 2022 22:22:02 +0100 (CET) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by mails.dpdk.org (Postfix) with ESMTP id F1A744068C for ; Mon, 28 Feb 2022 22:21:59 +0100 (CET) Received: by mail-wr1-f52.google.com with SMTP id r10so17459122wrp.3 for ; Mon, 28 Feb 2022 13:21:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qzyb9ScqItx/dHG8zcG5pcWWCgywRvP9exFOJ9r5E3Q=; b=V2jKqJiRftEI4Wq/409IJDIwXl4d7fc8hP9+fTrOMknPxKHRQ4PMf+LKE9aST1vKWQ IkFCqhfNIHK3MU5HZm+uxcEnT5Ks+iim4mQTHl47ZjmGJc0d8vKLmppV4+lh57e/wfpr L51bkyk56zWAdZuEtZc2t37tMxfdzXjN8JeBnVkreASLkqddzAgps3lYb77sfgLgLYQ7 9oix/hUNc+ZLuovzrNW1T75D3MNZxxsGyY1zS9HMdkcIEpdRYgjKJaxB83d81tvwb1vx ATfT1OZdAIBNBSLKcw0SHTihfIthXjoatcoHGPR27EoODXetBfTxPkInc1gQ7dhSolPQ SQ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qzyb9ScqItx/dHG8zcG5pcWWCgywRvP9exFOJ9r5E3Q=; b=OIxDp86pQDu7vWVjmRQwR5HrXqRDpaULh6kocgBbs+zsfBS43goLfd9MGirddy96zt 5MlVnnThOUs7ftsYNPgrLbL7YJW04kdMPviGo3rZkVEG1Nz4XEScRmL4B0GODWuFs5jB 7VkxcBJFqcedz1LDYg3bwxiUSV8YO2z2BcVRMNyP1EkpcDxaPDzIONd4lefuHQ/WxKXE 2Q3WmvDlBINpI2jFB6px0z5wdfLBea/uByrL8E2QA/RJFUvid4yPqkkjF5oX6Qs1PF+N 4f1eEIIBKj4N5lrTHJYFJQa/XwW3cUJ/JX4hccev9wXQMdq7O+kOwskIh4tv0SHSKti+ RA5Q== X-Gm-Message-State: AOAM530OkzociXXHCUkW01v1Q48Os3fjYXMQdmB/tRQYrZB2vpq72HHR 7hdYICmiwD3V4PKLNyHm6hgnvLPcd2rd4w== X-Google-Smtp-Source: ABdhPJyRYOh1qifew3+0cB9qPrWveOrzxkDBtMHbOvg65vmIoej43YeRWYha7aDcWl35daYbfJ480A== X-Received: by 2002:a5d:568d:0:b0:1ed:e3d4:580a with SMTP id f13-20020a5d568d000000b001ede3d4580amr17122161wrv.391.1646083319649; Mon, 28 Feb 2022 13:21:59 -0800 (PST) Received: from localhost ([2a01:4b00:f41a:3600:360b:9754:2e3a:c344]) by smtp.gmail.com with ESMTPSA id n7-20020a5d51c7000000b001a38105483dsm11556069wrv.24.2022.02.28.13.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 13:21:59 -0800 (PST) From: luca.boccassi@gmail.com To: Xuan Ding Cc: Maxime Coquelin , dpdk stable Subject: patch 'vhost: fix field naming in guest page struct' has been queued to stable release 20.11.5 Date: Mon, 28 Feb 2022 21:20:21 +0000 Message-Id: <20220228212047.3341966-25-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220228212047.3341966-1-luca.boccassi@gmail.com> References: <20220218123931.1749595-122-luca.boccassi@gmail.com> <20220228212047.3341966-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 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 Reviewed-by: Maxime Coquelin --- 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@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;