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 5/8] bus/pci: implement ctrl operator
Date: Thu, 12 Oct 2017 10:18:27 +0200	[thread overview]
Message-ID: <6e6c6a656646fb834400030518193bbc7fda86b0.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>

Add the PCI bus control operator.

This operator gives access to the probe policy setting, allowing to
read and write this configuration item. The previous existing
functionality is thus restored to the same level.

Probe policy is blacklist mode by default for the PCI bus. Configuration
is allowed once, and is then considered immutable.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/bus/pci/include/rte_bus_pci.h |  1 +
 drivers/bus/pci/pci_common.c          | 52 ++++++++++++++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/pci/include/rte_bus_pci.h b/drivers/bus/pci/include/rte_bus_pci.h
index e6a7998..f662705 100644
--- a/drivers/bus/pci/include/rte_bus_pci.h
+++ b/drivers/bus/pci/include/rte_bus_pci.h
@@ -155,6 +155,7 @@ struct rte_pci_driver {
  */
 struct rte_pci_bus {
 	struct rte_bus bus;               /**< Inherit the generic class */
+	enum rte_bus_probe_mode probe_mode; /**< Probe policy */
 	struct rte_pci_device_list device_list;  /**< List of PCI devices */
 	struct rte_pci_driver_list driver_list;  /**< List of PCI drivers */
 };
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index dc69113..358e232 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -370,9 +370,12 @@ rte_pci_probe(void)
 	struct rte_pci_device *dev = NULL;
 	size_t probed = 0, failed = 0;
 	struct rte_devargs *devargs;
-	int probe_all = 1;
+	int probe_all = 0;
 	int ret = 0;
 
+	if (rte_pci_bus.probe_mode != RTE_BUS_PROBE_WHITELIST)
+		probe_all = 1;
+
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
 		probed++;
 
@@ -515,6 +518,51 @@ pci_unplug(struct rte_device *dev)
 	return ret;
 }
 
+static int
+pci_probe_mode_get(void *_mode)
+{
+	enum rte_bus_probe_mode *mode = _mode;
+
+	*mode = rte_pci_bus.probe_mode;
+	return 0;
+}
+
+static int
+pci_probe_mode_set(void *_mode)
+{
+	enum rte_bus_probe_mode *mode = _mode;
+	static int conf_done;
+
+	if (conf_done &&
+	    *mode != rte_pci_bus.probe_mode) {
+		RTE_LOG(ERR, EAL, "Cannot set PCI to %s mode, bus is already configured.\n",
+			 (*mode == RTE_BUS_PROBE_BLACKLIST) ?
+			 "blacklist" : "whitelist");
+		return -1;
+	}
+	rte_pci_bus.probe_mode = *mode;
+	conf_done = 1;
+	return 0;
+}
+
+static rte_bus_ctrl_t pci_ctrl_ops[][RTE_BUS_CTRL_OP_MAX] = {
+	[RTE_BUS_CTRL_PROBE_MODE] = {
+		[RTE_BUS_CTRL_GET] = pci_probe_mode_get,
+		[RTE_BUS_CTRL_SET] = pci_probe_mode_set,
+	},
+};
+
+static rte_bus_ctrl_t
+pci_ctrl(enum rte_bus_ctrl_op op,
+	 enum rte_bus_ctrl_item item)
+{
+	if (item > RTE_DIM(pci_ctrl_ops))
+		return NULL;
+	if (op > RTE_DIM(pci_ctrl_ops[item]))
+		return NULL;
+	return pci_ctrl_ops[item][op];
+}
+
 struct rte_pci_bus rte_pci_bus = {
 	.bus = {
 		.scan = rte_pci_scan,
@@ -524,7 +572,9 @@ struct rte_pci_bus rte_pci_bus = {
 		.unplug = pci_unplug,
 		.parse = pci_parse,
 		.get_iommu_class = rte_pci_get_iommu_class,
+		.ctrl = pci_ctrl,
 	},
+	.probe_mode = RTE_BUS_PROBE_BLACKLIST,
 	.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
 	.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
 };
-- 
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 ` Gaetan Rivet [this message]
2017-10-12  8:18 ` [dpdk-dev] [PATCH v1 6/8] bus: add IOVA mode as a ctrl operation Gaetan Rivet
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=6e6c6a656646fb834400030518193bbc7fda86b0.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).