[v4,3/4] lib/eal: add API to check iommu type is set
diff mbox series

Message ID 1567598682-2225-4-git-send-email-tallurix.chaitanya.babu@intel.com
State New
Delegated to: David Marchand
Headers show
Series
  • add unit tests for eal vfio library
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Chaitanya Babu, TalluriX Sept. 4, 2019, 12:04 p.m. UTC
Add rte_vfio_iommu_type_is_set() to check IOMMU
type for default container.

Signed-off-by: Chaitanya Babu Talluri <tallurix.chaitanya.babu@intel.com>
---
 lib/librte_eal/common/include/rte_vfio.h | 11 +++++++++++
 lib/librte_eal/linux/eal/eal_vfio.c      | 16 ++++++++++++++++
 lib/librte_eal/rte_eal_version.map       |  3 +++
 3 files changed, 30 insertions(+)

Patch
diff mbox series

diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h
index b360485fa..e3f80f772 100644
--- a/lib/librte_eal/common/include/rte_vfio.h
+++ b/lib/librte_eal/common/include/rte_vfio.h
@@ -397,6 +397,17 @@  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
+ */
+__rte_experimental
+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 */
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 7cbf82d37..5b1ba6fbd 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -419,4 +419,7 @@  EXPERIMENTAL {
 	rte_mcfg_timer_lock;
 	rte_mcfg_timer_unlock;
 	rte_rand_max;
+
+	# added in 19.11
+	rte_vfio_iommu_type_is_set;
 };