summaryrefslogtreecommitdiff
path: root/lib/librte_eal/common/eal_common_bus.c
diff options
context:
space:
mode:
authorSantosh Shukla <santosh.shukla@caviumnetworks.com>2017-10-06 16:33:41 +0530
committerThomas Monjalon <thomas@monjalon.net>2017-10-06 20:39:07 +0200
commit39bef5cb98aab92cd6be69929b183854ccdb0f39 (patch)
treea644b08ce7519bdc00d678e472c4ae2ca4c80389 /lib/librte_eal/common/eal_common_bus.c
parent815c7deaed2d9e325968e82cb599984088a5c55a (diff)
downloaddpdk-39bef5cb98aab92cd6be69929b183854ccdb0f39.zip
dpdk-39bef5cb98aab92cd6be69929b183854ccdb0f39.tar.gz
dpdk-39bef5cb98aab92cd6be69929b183854ccdb0f39.tar.xz
bus: get IOMMU class
API(rte_bus_get_iommu_class) helps to automatically detect and select appropriate iova mapping scheme for iommu capable device on that bus. Algorithm for iova scheme selection for bus: 0. Iterate through bus_list. 1. Collect each bus iova mode value and update into 'mode' var. 2. Mode selection scheme is: if mode == 0 then iova mode is _pa, if mode == 1 then iova mode is _pa, if mode == 2 then iova mode is _va, if mode == 3 then iova mode ia _pa. So mode !=2 will be default iova mode (_pa). Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com> Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com> Tested-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Diffstat (limited to 'lib/librte_eal/common/eal_common_bus.c')
-rw-r--r--lib/librte_eal/common/eal_common_bus.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 08bec2d..a30a898 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -222,3 +222,26 @@ rte_bus_find_by_device_name(const char *str)
c[0] = '\0';
return rte_bus_find(NULL, bus_can_parse, name);
}
+
+
+/*
+ * 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) {
+ /* Use default IOVA mode */
+ mode = RTE_IOVA_PA;
+ }
+ return mode;
+}