DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v1 6/8] bus: add IOVA mode as a ctrl operation
Date: Thu, 12 Oct 2017 10:18:28 +0200	[thread overview]
Message-ID: <c45da150fe5bac4e454954da5c36ec97d51ca160.1507796085.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1507796085.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1507796085.git.gaetan.rivet@6wind.com>

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(-)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 97b3918..573869a 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 5b155c6..3627733 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -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;
 }
diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 93108ce..bb02d9d 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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,
 };
 
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index a8ea4ea..a2709e3 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -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;
-- 
2.1.4

  parent reply	other threads:[~2017-10-12  8:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12  8:18 [dpdk-dev] [PATCH v1 0/8] Bus control framework Gaetan Rivet
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 1/8] bus: rename scan policy as probe policy Gaetan Rivet
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 2/8] bus: introduce opaque control framework Gaetan Rivet
2017-12-11 12:00   ` Shreyansh Jain
2017-12-11 12:43     ` Gaëtan Rivet
2017-12-11 13:36       ` Shreyansh Jain
2017-12-11 14:38         ` Gaëtan Rivet
2017-12-12  7:21           ` Shreyansh Jain
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 3/8] bus: remove probe mode configuration structure Gaetan Rivet
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 4/8] bus: add probe mode setter Gaetan Rivet
2017-12-11 12:39   ` Shreyansh Jain
2017-12-11 12:43     ` Shreyansh Jain
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 5/8] bus/pci: implement ctrl operator Gaetan Rivet
2017-10-12  8:18 ` Gaetan Rivet [this message]
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 7/8] bus/pci: implement IOVA mode getter Gaetan Rivet
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 8/8] bus: remove redundant " Gaetan Rivet
2017-12-11 11:53 ` [dpdk-dev] [PATCH v1 0/8] Bus control framework Shreyansh Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c45da150fe5bac4e454954da5c36ec97d51ca160.1507796085.git.gaetan.rivet@6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).