Thanks.
Hi,
FYI, your patch has been queued to stable release 24.11.3
Note it hasn't been pushed to
https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdpdk.org%2fbrowse%2fdpdk-stable&c=E,1,3Suy4ri3RXJY7WvlDm4o0HlWW7YGi5f8DkoMo21K2P6u4x7bSnte4JjbHh7IEOZllLnwtcUgs85ON-NKs_usq60lx2EM02LQ4heXpVuseKDlZfpB8Q,,&typo=1 yet.
It will be pushed if I get no objections before 07/23/25. 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/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/4719664fc8d68658bd2187851a72a0ec5e752c18
Thanks.
Kevin
---
From 4719664fc8d68658bd2187851a72a0ec5e752c18 Mon Sep 17 00:00:00 2001
From: Oleksandr Kolomeiets <okl-plv@napatech.com>
Date: Tue, 1 Jul 2025 12:20:27 +0200
Subject: [PATCH] net/ntnic: unmap DMA during queue release
[ upstream commit 842c1cee225ca8c79a8a321e2194f83d54a4495a ]
Perform unmapping in a default container, which is used by queues.
Handle multiple mappings when IOMMU is unoptimized.
Fixes: c1c139535591 ("net/ntnic: add VFIO module")
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/include/ntos_drv.h | 1 +
drivers/net/ntnic/ntnic_ethdev.c | 26 ++++++++++++++++++++++++--
drivers/net/ntnic/ntnic_vfio.c | 3 ---
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ntnic/include/ntos_drv.h b/drivers/net/ntnic/include/ntos_drv.h
index f6ce442d17..cf3bb2396b 100644
--- a/drivers/net/ntnic/include/ntos_drv.h
+++ b/drivers/net/ntnic/include/ntos_drv.h
@@ -52,4 +52,5 @@ struct hwq_s {
int vf_num;
struct nthw_memory_descriptor virt_queues_ctrl;
+ struct nthw_memory_descriptor pkt_buffers_ctrl;
struct nthw_memory_descriptor *pkt_buffers;
};
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index 2a2643a106..3c668a41ef 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -879,4 +879,8 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
return -1;
+ hwq->pkt_buffers_ctrl.virt_addr = virt_addr;
+ hwq->pkt_buffers_ctrl.phys_addr = (void *)iova_addr;
+ hwq->pkt_buffers_ctrl.len = size;
+
for (i = 0; i < num_descr; i++) {
hwq->pkt_buffers[i].virt_addr =
@@ -900,7 +904,11 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
hwq->virt_queues_ctrl.virt_addr = virt;
hwq->virt_queues_ctrl.phys_addr = (void *)(iova_addr);
- hwq->virt_queues_ctrl.len = 0x100000;
+ hwq->virt_queues_ctrl.len = ONE_G_SIZE;
iova_addr += 0x100000;
+ hwq->pkt_buffers_ctrl.virt_addr = NULL;
+ hwq->pkt_buffers_ctrl.phys_addr = NULL;
+ hwq->pkt_buffers_ctrl.len = 0;
+
NT_LOG(DBG, NTNIC,
"VFIO MMAP: virt_addr=%p phys_addr=%p size=%" PRIX32 " hpa=%" PRIX64 "",
@@ -947,5 +955,5 @@ static int deallocate_hw_virtio_queues(struct hwq_s *hwq)
int res = nt_vfio_dma_unmap(vf_num, hwq->virt_queues_ctrl.virt_addr,
- (uint64_t)hwq->virt_queues_ctrl.phys_addr, ONE_G_SIZE);
+ (uint64_t)hwq->virt_queues_ctrl.phys_addr, hwq->virt_queues_ctrl.len);
if (res != 0) {
@@ -954,4 +962,18 @@ static int deallocate_hw_virtio_queues(struct hwq_s *hwq)
}
+ if (hwq->pkt_buffers_ctrl.virt_addr != NULL &&
+ hwq->pkt_buffers_ctrl.phys_addr != NULL &&
+ hwq->pkt_buffers_ctrl.len > 0) {
+ int res = nt_vfio_dma_unmap(vf_num,
+ hwq->pkt_buffers_ctrl.virt_addr,
+ (uint64_t)hwq->pkt_buffers_ctrl.phys_addr,
+ hwq->pkt_buffers_ctrl.len);
+
+ if (res != 0) {
+ NT_LOG(ERR, NTNIC, "VFIO UNMMAP FAILED! res %i, vf_num %i", res, vf_num);
+ return -1;
+ }
+ }
+
release_hw_virtio_queues(hwq);
rte_free(hwq->pkt_buffers);
diff --git a/drivers/net/ntnic/ntnic_vfio.c b/drivers/net/ntnic/ntnic_vfio.c
index a62234353b..8ddf676b99 100644
--- a/drivers/net/ntnic/ntnic_vfio.c
+++ b/drivers/net/ntnic/ntnic_vfio.c
@@ -213,7 +213,4 @@ nt_vfio_dma_unmap(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size
}
- if (vfio->container_fd == -1)
- return 0;
-
int res = rte_vfio_container_dma_unmap(vfio->container_fd, gp_virt_base, iova_addr, size);
--
2.50.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-07-18 20:29:15.807999110 +0100
+++ 0136-net-ntnic-unmap-DMA-during-queue-release.patch 2025-07-18 20:29:11.097907843 +0100
@@ -1 +1 @@
-From 842c1cee225ca8c79a8a321e2194f83d54a4495a Mon Sep 17 00:00:00 2001
+From 4719664fc8d68658bd2187851a72a0ec5e752c18 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 842c1cee225ca8c79a8a321e2194f83d54a4495a ]
+
@@ -10 +11,0 @@
-Cc: stable@dpdk.org
@@ -20 +21 @@
-index cef3c5c277..047c077057 100644
+index f6ce442d17..cf3bb2396b 100644
@@ -30 +31 @@
-index d875e7c236..79ef9e7e7c 100644
+index 2a2643a106..3c668a41ef 100644
@@ -33 +34 @@
-@@ -880,4 +880,8 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
+@@ -879,4 +879,8 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
@@ -42 +43 @@
-@@ -901,7 +905,11 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
+@@ -900,7 +904,11 @@ static int allocate_hw_virtio_queues(struct rte_eth_dev *eth_dev, int vf_num, st
@@ -55 +56 @@
-@@ -949,5 +957,5 @@ static int deallocate_hw_virtio_queues(struct hwq_s *hwq)
+@@ -947,5 +955,5 @@ static int deallocate_hw_virtio_queues(struct hwq_s *hwq)
@@ -62 +63 @@
-@@ -956,4 +964,18 @@ static int deallocate_hw_virtio_queues(struct hwq_s *hwq)
+@@ -954,4 +962,18 @@ static int deallocate_hw_virtio_queues(struct hwq_s *hwq)
@@ -82 +83 @@
-index 8d955e8342..1031b3cf67 100644
+index a62234353b..8ddf676b99 100644
@@ -85 +86 @@
-@@ -212,7 +212,4 @@ nt_vfio_dma_unmap(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size
+@@ -213,7 +213,4 @@ nt_vfio_dma_unmap(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size