v2: Based on the discussion on the thread [2]. Introducing RTE_PCI_DRV_NEED_IOVA_VA flag for autodetection of iova va mapping. If a PCI driver demand for IOVA as VA scheme then the driver can add it in the PCI driver registration function.
Algorithm to select IOVA as VA for PCI bus case: 0. Look for device attached to vfio kdrv and has .drv_flag set to RTE_PCI_DRV_NEED_IOVA_VA. 1. Look for any device attached to UIO class of driver. 2. Check for vfio-noiommu mode enabled. If 1) & 2) is false and 0) is true then select mapping scheme as iova=va. Otherwise use default mapping scheme (iova_pa). That way, Bus can truly autodetect the iova mapping mode for a device Or a set of the device. v1 --> v2 change history: - Removed override eal option i.e. (--iova-mode=<>) Because we have means to truly autodetect the iova mode. - Introduced RTE_PCI_DRV_NEED_IOVA_VA drv_flag. - Using NEED_IOVA_VA drv_flag in autodetection logic. - Removed Linux version check macro in vfio code, As per Maxime feedback. - Moved rte_pci_match API from local to global. Patch Summary: 0) 1st: Introducing a new flag in rte_pci_drv 1) 2nd: declare rte_pci_match api in pci header. Required for autodetection in follow up patches. 2) 3nd - 4th: autodetection mapping infrastructure for Linux/bsdapp. 3) 5th: Introduces global bus API named rte_bus_get_iommu_class. 4) 6th: iova mode helper API. 5) 7th - 8th: Calls rte_bus_get_iommu_class API for Linux/bsdapp and returns their iova mode. 6) 9th: Check iova mode and accordingly map vfio.dma_map to _pa or _va. 7) 10th - 12th: Check for IOVA_VA mode in below APIs - rte_mem_virt2phy - rte_mempool_virt2phy - rte_malloc_virt2phy Test History: - Tested for x86/XL710 40G NIC card for both modes (iova_va/pa). - Tested for arm64/thunderx vNIC Integrated NIC for both modes - Tested for arm64/Octeontx integrated NICs for only Iova_va mode(It supports only one mode.) - Ran standalone tests like mempool_autotest, mbuf_autotest. - Verified for Doxygen. Work History: For v1, Refer [1]. Checkpatch result: - No error/warning noticed. [1] https://www.mail-archive.com/dev@dpdk.org/msg67438.html [2] https://www.mail-archive.com/dev@dpdk.org/msg70279.html Santosh Shukla (12): eal/pci: introduce PCI driver iova as va flag eal/pci: export match function bsdapp/eal_pci: get iommu class linuxapp/eal_pci: get iommu class bus: get iommu class eal: introduce iova mode helper api linuxapp/eal: auto detect iova mode bsdapp/eal: auto detect iova mapping mode linuxapp/eal_vfio: honor iova mode before mapping linuxapp/eal_memory: honor iova mode in virt2phy mempool: honor iova mode in virt2phy eal/rte_malloc: honor iova mode in virt2phy lib/librte_eal/bsdapp/eal/eal.c | 22 ++++++--- lib/librte_eal/bsdapp/eal/eal_pci.c | 10 ++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 4 ++ lib/librte_eal/common/eal_common_bus.c | 23 +++++++++ lib/librte_eal/common/eal_common_pci.c | 11 +---- lib/librte_eal/common/include/rte_bus.h | 31 ++++++++++++ lib/librte_eal/common/include/rte_eal.h | 12 +++++ lib/librte_eal/common/include/rte_pci.h | 28 +++++++++++ lib/librte_eal/common/rte_malloc.c | 9 +++- lib/librte_eal/linuxapp/eal/eal.c | 22 ++++++--- lib/librte_eal/linuxapp/eal/eal_memory.c | 3 ++ lib/librte_eal/linuxapp/eal/eal_pci.c | 66 +++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_vfio.c | 29 ++++++++++- lib/librte_eal/linuxapp/eal/eal_vfio.h | 4 ++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 4 ++ lib/librte_mempool/rte_mempool.h | 10 +++- 16 files changed, 262 insertions(+), 26 deletions(-) -- 2.13.0