From mboxrd@z Thu Jan 1 00:00:00 1970 From: Santosh Shukla Subject: [PATCH 03/10] bus: get iommu class Date: Thu, 8 Jun 2017 16:35:06 +0530 Message-ID: <20170608110513.22548-4-santosh.shukla@caviumnetworks.com> References: <20170608110513.22548-1-santosh.shukla@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, shreyansh.jain@nxp.com, gaetan.rivet@6wind.com, Santosh Shukla To: thomas@monjalon.net, bruce.richardson@intel.com, dev@dpdk.org Return-path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0067.outbound.protection.outlook.com [104.47.38.67]) by dpdk.org (Postfix) with ESMTP id AC9E02BBD for ; Thu, 8 Jun 2017 13:06:21 +0200 (CEST) In-Reply-To: <20170608110513.22548-1-santosh.shukla@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently there is noway to detect iova address mapping scheme for a device on the bus. API(rte_bus_get_iommu_class) helps to automatically detect and select appropriate iova mapping scheme for iommu capable device on that bus. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 23 +++++++++++++++++++++++ lib/librte_eal/common/eal_common_pci.c | 1 + lib/librte_eal/common/include/rte_bus.h | 21 +++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 5 files changed, 47 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index a9cc3a67e..0beadacfb 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -198,5 +198,6 @@ DPDK_17.08 { global: rte_pci_get_iommu_class; + rte_bus_get_iommu_class; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 8f9baf8b8..04398275d 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -145,3 +145,26 @@ rte_bus_dump(FILE *f) } } } + +/* + * Get iommu class of devices on the bus. + */ +enum rte_iova_mode +rte_bus_get_iommu_class(void) +{ + int mode = RTE_IOVA_DC; + struct rte_bus *bus; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + + if (bus->get_iommu_class) { + mode |= bus->get_iommu_class(); + } + } + + if (mode != RTE_IOVA_VA) { + /* Mapping could be _DC or _PA. Use default IOVA mode */ + mode = RTE_IOVA_PA; + } + return mode; +} diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 5ae520186..9d4ed7927 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -487,6 +487,7 @@ struct rte_pci_bus rte_pci_bus = { .bus = { .scan = rte_pci_scan, .probe = rte_pci_probe, + .get_iommu_class = rte_pci_get_iommu_class, }, .device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list), .driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list), diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 56eacd0c9..734f6f051 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -91,6 +91,16 @@ typedef int (*rte_bus_scan_t)(void); */ typedef int (*rte_bus_probe_t)(void); + +/** + * Get iommu class of devices on the bus. + * Check that those devices are attached to iommu driver. + * + * @return + * enum rte_iova_mode value. + */ +typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void); + /** * A structure describing a generic bus. */ @@ -99,6 +109,7 @@ struct rte_bus { const char *name; /**< Name of the bus */ rte_bus_scan_t scan; /**< Scan for devices attached to bus */ rte_bus_probe_t probe; /**< Probe devices on bus */ + rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */ }; /** @@ -150,6 +161,16 @@ int rte_bus_probe(void); */ void rte_bus_dump(FILE *f); + +/** + * Get iommu class of devices on the bus. + * Check that those devices are attached to iommu driver. + * + * @return + * enum rte_iova_mode value. + */ +enum rte_iova_mode rte_bus_get_iommu_class(void); + /** * Helper for Bus registration. * The constructor has higher priority than PMD constructors. diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 2cea7c272..6c016c82e 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -203,5 +203,6 @@ DPDK_17.08 { global: rte_pci_get_iommu_class; + rte_bus_get_iommu_class; } DPDK_17.05; -- 2.11.0