[dpdk-dev] [PATCH v3 3/4] lib/eal: add API to check iommu type is set

Chaitanya Babu Talluri tallurix.chaitanya.babu at intel.com
Tue Aug 27 13:57:10 CEST 2019


Add rte_vfio_iommu_type_is_set() to check IOMMU
type for default container.

Signed-off-by: Chaitanya Babu Talluri <tallurix.chaitanya.babu at intel.com>
---
 lib/librte_eal/common/include/rte_vfio.h | 10 ++++++++++
 lib/librte_eal/linux/eal/eal_vfio.c      | 16 ++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h
index b360485fa..a62006e5a 100644
--- a/lib/librte_eal/common/include/rte_vfio.h
+++ b/lib/librte_eal/common/include/rte_vfio.h
@@ -397,6 +397,16 @@ int
 rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr,
 		uint64_t iova, uint64_t len);
 
+/**
+ * Check VFIO IOMMU Type is set for default container.
+ *
+ * @return
+ *    0 if successful
+ *   <0 if failed
+ */
+int
+rte_vfio_iommu_type_is_set(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 04c284cb2..a5bb1cff4 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -2071,6 +2071,17 @@ rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova,
 	return container_dma_unmap(vfio_cfg, vaddr, iova, len);
 }
 
+int
+rte_vfio_iommu_type_is_set(void)
+{
+	if (vfio_get_iommu_type() < 0) {
+		RTE_LOG(ERR, EAL, "VFIO IOMMU Type is not set\n");
+		return -1;
+	}
+
+	return 0;
+}
+
 #else
 
 int
@@ -2191,4 +2202,9 @@ rte_vfio_container_dma_unmap(__rte_unused int container_fd,
 	return -1;
 }
 
+int
+rte_vfio_iommu_type_is_set(void)
+{
+	return -1;
+}
 #endif /* VFIO_PRESENT */
-- 
2.17.2



More information about the dev mailing list