diff --git a/include/spdk/env.h b/include/spdk/env.h index 2d2c7faa59..53eb545336 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -573,6 +573,13 @@ size_t spdk_ring_enqueue(struct spdk_ring *ring, void **objs, size_t count); */ size_t spdk_ring_dequeue(struct spdk_ring *ring, void **objs, size_t count); +/** + * Reports whether the SPDK application is using the IOMMU for DMA + * + * \return True if we are using the IOMMU, false otherwise. + */ +bool spdk_iommu_is_enabled(void); + #define SPDK_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL) /** diff --git a/lib/env_dpdk/memory.c b/lib/env_dpdk/memory.c index 9afd5ad59f..ed26a72958 100644 --- a/lib/env_dpdk/memory.c +++ b/lib/env_dpdk/memory.c @@ -779,6 +779,16 @@ spdk_mem_map_init(void) return 0; } +bool +spdk_iommu_is_enabled(void) +{ +#if SPDK_VFIO_ENABLED + return g_vfio.enabled && !g_vfio.noiommu_enabled; +#else + return false; +#endif +} + struct spdk_vtophys_pci_device { struct rte_pci_device *pci_device; TAILQ_ENTRY(spdk_vtophys_pci_device) tailq;