[dpdk-dev,v1,6/8] bus: add IOVA mode as a ctrl operation
Checks
Commit Message
Leverage the new bus control framework for the IOVA mode
configuration item.
The previous version is left for the transition in drivers
implementation and will be removed afterward.
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 -
lib/librte_eal/common/eal_common_bus.c | 24 +++++++++++------
lib/librte_eal/common/include/rte_bus.h | 34 ++++++++++++++-----------
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 -
4 files changed, 35 insertions(+), 25 deletions(-)
@@ -228,7 +228,6 @@ DPDK_17.11 {
rte_eal_iova_mode;
rte_eal_mbuf_default_mempool_ops;
rte_lcore_has_role;
- rte_pci_get_iommu_class;
rte_pci_match;
} DPDK_17.08;
@@ -258,18 +258,26 @@ rte_bus_find_by_device_name(const char *str)
enum rte_iova_mode
rte_bus_get_iommu_class(void)
{
- int mode = RTE_IOVA_DC;
+ enum rte_iova_mode result;
struct rte_bus *bus;
+ result = RTE_IOVA_DC;
TAILQ_FOREACH(bus, &rte_bus_list, next) {
+ rte_bus_ctrl_t iova_mode_get;
+ enum rte_iova_mode mode;
- if (bus->get_iommu_class)
- mode |= bus->get_iommu_class();
+ iova_mode_get = bus->ctrl(RTE_BUS_CTRL_GET,
+ RTE_BUS_CTRL_IOVA_MODE);
+ if (iova_mode_get != NULL) {
+ if (iova_mode_get(&mode))
+ RTE_LOG(ERR, EAL, "Bus %s: error reading IOMMU class\n",
+ bus->name);
+ else
+ result |= mode;
+ }
}
-
- if (mode != RTE_IOVA_VA) {
+ if (result != RTE_IOVA_VA)
/* Use default IOVA mode */
- mode = RTE_IOVA_PA;
- }
- return mode;
+ result = RTE_IOVA_PA;
+ return result;
}
@@ -55,21 +55,6 @@ 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
@@ -177,10 +162,29 @@ enum rte_bus_probe_mode {
};
/**
+ * 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 configuration items.
*/
enum rte_bus_ctrl_item {
RTE_BUS_CTRL_PROBE_MODE = 0,
+ /**
+ * IOMMU class common to all devices on the bus.
+ * If irrelevant, the bus may return RTE_IOVA_DC.
+ */
+ RTE_BUS_CTRL_IOVA_MODE,
RTE_BUS_CTRL_ITEM_MAX,
};
@@ -232,7 +232,6 @@ DPDK_17.11 {
rte_eal_iova_mode;
rte_eal_mbuf_default_mempool_ops;
rte_lcore_has_role;
- rte_pci_get_iommu_class;
rte_pci_match;
} DPDK_17.08;