[v4,3/4] lib/eal: add API to check iommu type is set
Checks
Commit Message
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(+)
@@ -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
@@ -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 */
@@ -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;
};