From: Santosh Shukla Date: Fri, 6 Oct 2017 11:03:39 +0000 (+0530) Subject: pci: get IOMMU class X-Git-Tag: spdx-start~1741 X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=a4f0a2dbe5abc2cadf0300fb4d5767b66254035d pci: get IOMMU class Introducing rte_pci_get_iommu_class API which helps to get iommu class of PCI device on the bus and returns preferred iova mapping mode for PCI bus. Patch also adds rte_pci_get_iommu_class definition for: - bsdapp: api returns default iova mode. - linuxapp: Has stub implementation, Followup patch has complete implementation. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob Reviewed-by: Maxime Coquelin Tested-by: Hemant Agrawal Reviewed-by: Anatoly Burakov --- diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 04eacdcc75..1595988bdd 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -403,6 +403,16 @@ error: return -1; } +/* + * Get iommu class of PCI devices on the bus. + */ +enum rte_iova_mode +rte_pci_get_iommu_class(void) +{ + /* Supports only RTE_KDRV_NIC_UIO */ + return RTE_IOVA_PA; +} + int pci_update_device(const struct rte_pci_addr *addr) { diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index cfbf8fbd03..f8724bd5d7 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -242,6 +242,7 @@ EXPERIMENTAL { DPDK_17.11 { global: + rte_pci_get_iommu_class; rte_pci_match; } DPDK_17.08; diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 8f8b09954a..2501fa26da 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -55,6 +55,21 @@ extern "C" { /** Double linked list of buses */ TAILQ_HEAD(rte_bus_list, rte_bus); + +/** + * IOVA mapping mode. + * + * IOVA mapping mode is iommu programming mode of a device. + * That device (for example: IOMMU backed DMA device) based + * on rte_iova_mode will generate physical or virtual address. + * + */ +enum rte_iova_mode { + RTE_IOVA_DC = 0, /* Don't care mode */ + RTE_IOVA_PA = (1 << 0), /* DMA using physical address */ + RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */ +}; + /** * Bus specific scan for devices attached on the bus. * For each bus object, the scan would be responsible for finding devices and diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index eab84c7a47..0e36de0938 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -381,6 +381,17 @@ int rte_pci_match(const struct rte_pci_driver *pci_drv, const struct rte_pci_device *pci_dev); + +/** + * Get iommu class of PCI devices on the bus. + * And return their preferred iova mapping mode. + * + * @return + * - enum rte_iova_mode. + */ +enum rte_iova_mode +rte_pci_get_iommu_class(void); + /** * Map the PCI device resources in user space virtual memory address * diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 8951ce7420..b1d6fbdce0 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -487,6 +487,15 @@ error: return -1; } +/* + * Get iommu class of PCI devices on the bus. + */ +enum rte_iova_mode +rte_pci_get_iommu_class(void) +{ + return RTE_IOVA_PA; +} + /* Read PCI config space. */ int rte_pci_read_config(const struct rte_pci_device *device, void *buf, size_t len, off_t offset) diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 287cc75cd8..95756e268a 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -247,6 +247,7 @@ EXPERIMENTAL { DPDK_17.11 { global: + rte_pci_get_iommu_class; rte_pci_match; } DPDK_17.08;