public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Subject: [PATCH 7/8] bus: remove per bus scan mode
Date: Mon, 23 Mar 2026 11:53:01 +0100	[thread overview]
Message-ID: <20260323105306.1531689-8-david.marchand@redhat.com> (raw)
In-Reply-To: <20260323105306.1531689-1-david.marchand@redhat.com>

Following the refactoring of device selection, it becomes more apparent
that there is no need for a per bus scan mode.
-a / -b options are mutually exclusive.
--vdev option works in parallel of allow/block list scan mode.

Remove this (internal) notion.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/eal/common/eal_common_bus.c     | 20 ++++++++++++++++++-
 lib/eal/common/eal_common_devargs.c |  8 +++-----
 lib/eal/common/eal_private.h        | 31 +++++++++++++++++++++++++++++
 lib/eal/include/bus_driver.h        | 18 -----------------
 4 files changed, 53 insertions(+), 24 deletions(-)

diff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c
index 2ca0af7914..27a31bbefa 100644
--- a/lib/eal/common/eal_common_bus.c
+++ b/lib/eal/common/eal_common_bus.c
@@ -18,6 +18,8 @@
 static struct rte_bus_list rte_bus_list =
 	TAILQ_HEAD_INITIALIZER(rte_bus_list);
 
+static enum rte_bus_scan_mode bus_scan_mode;
+
 RTE_EXPORT_SYMBOL(rte_bus_name)
 const char *
 rte_bus_name(const struct rte_bus *bus)
@@ -252,7 +254,7 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name)
 {
 	struct rte_devargs *devargs = rte_bus_find_devargs(bus, dev_name);
 
-	switch (bus->conf.scan_mode) {
+	switch (rte_bus_scan_mode_get()) {
 	case RTE_BUS_SCAN_ALLOWLIST:
 		if (devargs && devargs->policy == RTE_DEV_ALLOWED)
 			return false;
@@ -266,6 +268,22 @@ rte_bus_is_ignored_device(const struct rte_bus *bus, const char *dev_name)
 	return true;
 }
 
+enum rte_bus_scan_mode
+rte_bus_scan_mode_get(void)
+{
+	return bus_scan_mode;
+}
+
+int
+rte_bus_scan_mode_set(enum rte_bus_scan_mode scan_mode)
+{
+	if (bus_scan_mode != RTE_BUS_SCAN_UNDEFINED)
+		return -EINVAL;
+
+	bus_scan_mode = scan_mode;
+	return 0;
+}
+
 /*
  * Get iommu class of devices on the bus.
  */
diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c
index c523429d67..8083bdebc2 100644
--- a/lib/eal/common/eal_common_devargs.c
+++ b/lib/eal/common/eal_common_devargs.c
@@ -330,7 +330,6 @@ int
 rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 {
 	struct rte_devargs *devargs = NULL;
-	struct rte_bus *bus = NULL;
 	const char *dev = devargs_str;
 
 	/* use calloc instead of rte_zmalloc as it's called early at init */
@@ -341,14 +340,13 @@ rte_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_devargs_parse(devargs, dev))
 		goto fail;
 	devargs->type = devtype;
-	bus = devargs->bus;
 	if (devargs->type == RTE_DEVTYPE_BLOCKED)
 		devargs->policy = RTE_DEV_BLOCKED;
-	if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+	if (rte_bus_scan_mode_get() == RTE_BUS_SCAN_UNDEFINED) {
 		if (devargs->policy == RTE_DEV_ALLOWED)
-			bus->conf.scan_mode = RTE_BUS_SCAN_ALLOWLIST;
+			rte_bus_scan_mode_set(RTE_BUS_SCAN_ALLOWLIST);
 		else if (devargs->policy == RTE_DEV_BLOCKED)
-			bus->conf.scan_mode = RTE_BUS_SCAN_BLOCKLIST;
+			rte_bus_scan_mode_set(RTE_BUS_SCAN_BLOCKLIST);
 	}
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
 	return 0;
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index e032dd10c9..12db04dce2 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -469,6 +469,37 @@ int rte_eal_memory_detach(void);
  */
 struct rte_bus *rte_bus_find_by_device_name(const char *str);
 
+/**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_ALLOWLIST,
+	RTE_BUS_SCAN_BLOCKLIST,
+};
+
+/**
+ * Retrieve the current bus scanning mode.
+ *
+ * @return
+ *   The current bus scanning mode.
+ */
+enum rte_bus_scan_mode rte_bus_scan_mode_get(void);
+
+/**
+ * Change the bus scanning mode.
+ * Changing the mode can only be done once from undefined to allow list or to block list.
+ * No change from allow to block (or vice versa) is allowed.
+ *
+ * @param scan_mode
+ *   The scanning mode to apply.
+ *
+ * @return
+ *   0 on successful change.
+ *   < 0 on failure.
+ */
+int rte_bus_scan_mode_set(enum rte_bus_scan_mode scan_mode);
+
 /**
  * For each device on the buses, call the driver-specific function for
  * device cleanup.
diff --git a/lib/eal/include/bus_driver.h b/lib/eal/include/bus_driver.h
index e67e052404..9045d64816 100644
--- a/lib/eal/include/bus_driver.h
+++ b/lib/eal/include/bus_driver.h
@@ -232,23 +232,6 @@ typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
  */
 typedef int (*rte_bus_cleanup_t)(void);
 
-/**
- * Bus scan policies
- */
-enum rte_bus_scan_mode {
-	RTE_BUS_SCAN_UNDEFINED,
-	RTE_BUS_SCAN_ALLOWLIST,
-	RTE_BUS_SCAN_BLOCKLIST,
-};
-
-/**
- * A structure used to configure bus operations.
- */
-struct rte_bus_conf {
-	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
-};
-
-
 /**
  * Get common iommu class of the all the devices on the bus. The bus may
  * check that those devices are attached to iommu driver.
@@ -277,7 +260,6 @@ struct rte_bus {
 	rte_bus_devargs_parse_t devargs_parse; /**< Parse bus devargs */
 	rte_dev_dma_map_t dma_map;   /**< DMA map for device in the bus */
 	rte_dev_dma_unmap_t dma_unmap; /**< DMA unmap for device in the bus */
-	struct rte_bus_conf conf;    /**< Bus configuration */
 	rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */
 	rte_dev_iterate_t dev_iterate; /**< Device iterator. */
 	rte_bus_hot_unplug_handler_t hot_unplug_handler;
-- 
2.53.0


  parent reply	other threads:[~2026-03-23 10:54 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 10:52 [PATCH 0/8] Rework device probing David Marchand
2026-03-23 10:52 ` [PATCH 1/8] devtools: check packet forwarding in null test David Marchand
2026-03-23 10:52 ` [PATCH 2/8] bus/fslmc: fix bus cleanup David Marchand
2026-03-23 16:59   ` Kevin Traynor
2026-03-26  8:22     ` David Marchand
2026-03-26  8:49       ` Kevin Traynor
2026-03-24  5:15   ` Hemant Agrawal
2026-03-24  5:15   ` Hemant Agrawal
2026-03-23 10:52 ` [PATCH 3/8] drivers/bus: require probe function for NXP drivers David Marchand
2026-03-23 16:59   ` Kevin Traynor
2026-03-24  5:15   ` Hemant Agrawal
2026-03-23 10:52 ` [PATCH 4/8] drivers: cleanup devargs lookup in bus scan David Marchand
2026-03-24  5:16   ` Hemant Agrawal
2026-03-24 14:13   ` Kevin Traynor
2026-03-24 16:10   ` Stephen Hemminger
2026-03-23 10:52 ` [PATCH 5/8] bus: factorize devargs lookup David Marchand
2026-03-24 14:16   ` Kevin Traynor
2026-03-24 16:11   ` Stephen Hemminger
2026-03-23 10:53 ` [PATCH 6/8] bus: factorize device selection David Marchand
2026-03-24 14:15   ` Kevin Traynor
2026-03-26  8:48     ` David Marchand
2026-03-24 16:12   ` Stephen Hemminger
2026-03-23 10:53 ` David Marchand [this message]
2026-03-24 16:02   ` [PATCH 7/8] bus: remove per bus scan mode Kevin Traynor
2026-03-24 16:27     ` Kevin Traynor
2026-03-26  8:54     ` David Marchand
2026-03-23 10:53 ` [PATCH 8/8] eal: configure initial device probing David Marchand
2026-03-25 10:57   ` Kevin Traynor
2026-03-24  5:17 ` [PATCH 0/8] Rework " Hemant Agrawal
2026-03-25 15:22 ` Maxime Leroy
2026-03-26 10:24 ` [PATCH v2 0/7] " David Marchand
2026-03-26 10:24   ` [PATCH v2 1/7] devtools: check packet forwarding in null test David Marchand
2026-03-26 10:24   ` [PATCH v2 2/7] bus/fslmc: fix bus cleanup David Marchand
2026-03-26 11:50     ` Kevin Traynor
2026-03-26 10:24   ` [PATCH v2 3/7] drivers/bus: require probe function for NXP drivers David Marchand
2026-03-26 10:24   ` [PATCH v2 4/7] drivers: cleanup devargs lookup in bus scan David Marchand
2026-03-28  3:13     ` fengchengwen
2026-03-26 10:24   ` [PATCH v2 5/7] bus: factorize devargs lookup David Marchand
2026-03-26 11:51     ` Kevin Traynor
2026-03-28  3:33     ` fengchengwen
2026-04-03 14:22       ` David Marchand
2026-03-26 10:24   ` [PATCH v2 6/7] bus: factorize device selection David Marchand
2026-03-26 11:52     ` Kevin Traynor
2026-03-28  3:38     ` fengchengwen
2026-03-26 10:24   ` [PATCH v2 7/7] eal: configure initial device probing David Marchand
2026-03-28  4:00     ` fengchengwen
2026-04-03 14:25       ` David Marchand
2026-04-07 11:52 ` [PATCH v3 0/7] Rework " David Marchand
2026-04-07 11:52   ` [PATCH v3 1/7] devtools: check packet forwarding in null test David Marchand
2026-04-07 11:52   ` [PATCH v3 2/7] bus/fslmc: fix bus cleanup David Marchand
2026-04-07 11:52   ` [PATCH v3 3/7] drivers/bus: require probe function for NXP drivers David Marchand
2026-04-07 11:52   ` [PATCH v3 4/7] drivers/bus: cleanup devargs lookup in scan David Marchand
2026-04-07 11:52   ` [PATCH v3 5/7] bus: factorize devargs lookup David Marchand
2026-04-08  1:18     ` fengchengwen
2026-04-07 11:52   ` [PATCH v3 6/7] bus: factorize device selection David Marchand
2026-04-07 11:52   ` [PATCH v3 7/7] eal: configure initial device probing David Marchand
2026-04-08  1:44     ` fengchengwen
2026-04-07 11:58   ` [PATCH v3 0/7] Rework " David Marchand
2026-04-07 15:12   ` Stephen Hemminger
2026-04-10 14:34   ` Morten Brørup
2026-04-10 15:16     ` Kevin Traynor
2026-04-10 17:37     ` Stephen Hemminger
2026-04-10 21:13       ` [EXTERNAL] " Long Li
2026-04-10 22:50         ` Stephen Hemminger
2026-04-11  7:30         ` Morten Brørup
2026-04-11 10:10     ` David Marchand
2026-04-11 10:23       ` David Marchand

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=20260323105306.1531689-8-david.marchand@redhat.com \
    --to=david.marchand@redhat.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