Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 78 ++++++++++++++++++++++--------------------
 drivers/event/dpaa2/Makefile   |  3 ++
 drivers/mempool/dpaa2/Makefile |  3 ++
 drivers/net/dpaa2/Makefile     |  3 ++
 drivers/net/dpaa2/meson.build  |  3 ++
 drivers/net/octeontx/Makefile  |  3 ++
 6 files changed, 56 insertions(+), 37 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1310190..ccdbeff 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -193,17 +193,51 @@ static int vfio_map_irq_region(struct fslmc_vfio_group 
*group)
        return -errno;
 }
 
-int rte_fslmc_vfio_dmamap(void)
+static int
+fslmc_vfio_map(const struct rte_memseg *ms, void *arg)
 {
-       int ret;
+       int *n_segs = arg;
        struct fslmc_vfio_group *group;
        struct vfio_iommu_type1_dma_map dma_map = {
                .argsz = sizeof(struct vfio_iommu_type1_dma_map),
                .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
        };
+       int ret;
+
+       dma_map.size = ms->len;
+       dma_map.vaddr = ms->addr_64;
+#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA
+       dma_map.iova = ms->iova;
+#else
+       dma_map.iova = dma_map.vaddr;
+#endif
+
+       /* SET DMA MAP for IOMMU */
+       group = &vfio_group;
+
+       if (!group->container) {
+               FSLMC_VFIO_LOG(ERR, "Container is not connected ");
+               return -1;
+       }
+
+       FSLMC_VFIO_LOG(DEBUG, "-->Initial SHM Virtual ADDR %llX",
+                    dma_map.vaddr);
+       FSLMC_VFIO_LOG(DEBUG, "-----> DMA size 0x%llX", dma_map.size);
+       ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA,
+                       &dma_map);
+       if (ret) {
+               FSLMC_VFIO_LOG(ERR, "VFIO_IOMMU_MAP_DMA API(errno = %d)",
+                               errno);
+               return -1;
+       }
+       (*n_segs)++;
+       return 0;
+}
 
-       int i;
+int rte_fslmc_vfio_dmamap(void)
+{
        const struct rte_memseg *memseg;
+       int i = 0;
 
        if (is_dma_done)
                return 0;
@@ -214,51 +248,21 @@ int rte_fslmc_vfio_dmamap(void)
                return -ENODEV;
        }
 
-       for (i = 0; i < RTE_MAX_MEMSEG; i++) {
-               if (memseg[i].addr == NULL && memseg[i].len == 0) {
-                       FSLMC_VFIO_LOG(DEBUG, "Total %d segments found.", i);
-                       break;
-               }
-
-               dma_map.size = memseg[i].len;
-               dma_map.vaddr = memseg[i].addr_64;
-#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA
-               dma_map.iova = memseg[i].iova;
-#else
-               dma_map.iova = dma_map.vaddr;
-#endif
-
-               /* SET DMA MAP for IOMMU */
-               group = &vfio_group;
-
-               if (!group->container) {
-                       FSLMC_VFIO_LOG(ERR, "Container is not connected ");
-                       return -1;
-               }
-
-               FSLMC_VFIO_LOG(DEBUG, "-->Initial SHM Virtual ADDR %llX",
-                            dma_map.vaddr);
-               FSLMC_VFIO_LOG(DEBUG, "-----> DMA size 0x%llX", dma_map.size);
-               ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA,
-                           &dma_map);
-               if (ret) {
-                       FSLMC_VFIO_LOG(ERR, "VFIO_IOMMU_MAP_DMA API(errno = 
%d)",
-                                      errno);
-                       return ret;
-               }
-       }
+       if (rte_memseg_walk(fslmc_vfio_map, &i) < 0)
+               return -1;
 
        /* Verifying that at least single segment is available */
        if (i <= 0) {
                FSLMC_VFIO_LOG(ERR, "No Segments found for VFIO Mapping");
                return -1;
        }
+       FSLMC_VFIO_LOG(DEBUG, "Total %d segments found.", i);
 
        /* TODO - This is a W.A. as VFIO currently does not add the mapping of
         * the interrupt region to SMMU. This should be removed once the
         * support is added in the Kernel.
         */
-       vfio_map_irq_region(group);
+       vfio_map_irq_region(&vfio_group);
 
        is_dma_done = 1;
 
diff --git a/drivers/event/dpaa2/Makefile b/drivers/event/dpaa2/Makefile
index b26862c..a5b68b4 100644
--- a/drivers/event/dpaa2/Makefile
+++ b/drivers/event/dpaa2/Makefile
@@ -28,6 +28,9 @@ EXPORT_MAP := rte_pmd_dpaa2_event_version.map
 
 LIBABIVER := 1
 
+# depends on fslmc bus which uses experimental API
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 #
 # all source are stored in SRCS-y
 #
diff --git a/drivers/mempool/dpaa2/Makefile b/drivers/mempool/dpaa2/Makefile
index efaac96..c1cc2a3 100644
--- a/drivers/mempool/dpaa2/Makefile
+++ b/drivers/mempool/dpaa2/Makefile
@@ -27,6 +27,9 @@ EXPORT_MAP := rte_mempool_dpaa2_version.map
 # Lbrary version
 LIBABIVER := 1
 
+# depends on fslmc bus which uses experimental API
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_MEMPOOL) += dpaa2_hw_mempool.c
diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index 068e9d3..cc5627c 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -33,6 +33,9 @@ EXPORT_MAP := rte_pmd_dpaa2_version.map
 # library version
 LIBABIVER := 1
 
+# depends on fslmc bus which uses experimental API
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += base/dpaa2_hw_dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index ad1724d..8e96b5a 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -13,3 +13,6 @@ sources = files('base/dpaa2_hw_dpni.c',
                'mc/dpni.c')
 
 includes += include_directories('base', 'mc')
+
+# depends on fslmc bus which uses experimental API
+allow_experimental_apis = true
diff --git a/drivers/net/octeontx/Makefile b/drivers/net/octeontx/Makefile
index 3e4a106..5f488b9 100644
--- a/drivers/net/octeontx/Makefile
+++ b/drivers/net/octeontx/Makefile
@@ -16,6 +16,9 @@ EXPORT_MAP := rte_pmd_octeontx_version.map
 
 LIBABIVER := 1
 
+# depends on fslmc bus which uses experimental API
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 OBJS_BASE_DRIVER=$(patsubst %.c,%.o,$(notdir $(wildcard $(SRCDIR)/base/*.c)))
 $(foreach obj, $(OBJS_BASE_DRIVER), $(eval 
CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER)))
 
-- 
2.7.4

Reply via email to