[dpdk-dev,03/10] bus: get iommu class
Checks
Commit Message
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 <santosh.shukla@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
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(+)
@@ -198,5 +198,6 @@ DPDK_17.08 {
global:
rte_pci_get_iommu_class;
+ rte_bus_get_iommu_class;
} DPDK_17.05;
@@ -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;
+}
@@ -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),
@@ -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.
@@ -203,5 +203,6 @@ DPDK_17.08 {
global:
rte_pci_get_iommu_class;
+ rte_bus_get_iommu_class;
} DPDK_17.05;