aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2022-12-28 16:42:43 +0200
committerPetri Savolainen <petri.savolainen@nokia.com>2022-12-29 14:49:17 +0200
commitccb7b35bb75366968e316bbadd6a030a976e5b21 (patch)
treef101296ed18d7cf66d943ac4b986cfe55e91acb4
parent50f60d94806d6dcaf15b6459642af2e48a431f71 (diff)
linux-gen: dpdk: fix zero-copy mode with vfio-pci driver
For DPDK zero-copy pktio to work with VFIO the packet pool memory has to be mapped for DMA access. Fixes: https://github.com/OpenDataPlane/odp/issues/1718 Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
-rw-r--r--platform/linux-generic/pktio/dpdk.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c
index 7e9db90ce..fa40d1bde 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -49,6 +49,7 @@
#include <rte_tcp.h>
#include <rte_udp.h>
#include <rte_version.h>
+#include <rte_vfio.h>
/* NUMA is not supported on all platforms */
#ifdef _ODP_HAVE_NUMA_LIBRARY
@@ -438,6 +439,15 @@ static struct rte_mempool *mbuf_pool_create(const char *name,
goto fail;
}
+ /* Map pages for DMA access to enable VFIO usage */
+ for (uint64_t i = 0; i < pool_entry->shm_size; i += page_size) {
+ addr = pool_entry->base_addr + i;
+
+ rte_vfio_container_dma_map(RTE_VFIO_DEFAULT_CONTAINER_FD,
+ (uint64_t)(uintptr_t)addr,
+ rte_mem_virt2iova(addr), page_size);
+ }
+
rte_mempool_obj_iter(mp, pktmbuf_init, NULL);
return mp;