[dpdk-dev,v5,10/19] bus: introduce bus scan policies

Message ID 7052a1a87238f7a1f184b4a853c4fb73c564d3ab.1498001626.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Gaëtan Rivet June 20, 2017, 11:35 p.m. UTC
  Scan policies describe the way a bus should scan the system to search
for possible devices.

Three flags are introduced:
  RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
  RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
  RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Comments

Thomas Monjalon July 4, 2017, 11:01 p.m. UTC | #1
21/06/2017 01:35, Gaetan Rivet:
> Scan policies describe the way a bus should scan the system to search
> for possible devices.
> 
> Three flags are introduced:
>   RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
>   RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
>   RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
[...]
> @@ -148,6 +164,7 @@ struct rte_bus {
>  	rte_bus_plug_t plug;         /**< Probe single device for drivers */
>  	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
>  	rte_bus_parse_t parse;       /**< Parse a device name */
> +	struct rte_bus_conf conf;    /**< Bus configuration */
>  };

You are making explicit what exists currently:
	- the PCI bus has a whitelist/blacklist policy
	- the vdev bus is only a whitelist
It is a good step to deinterlace some spaghettis in the code.

For the next step, the bus should have no policy. It scans everything.
We can have a probing policy, but it should not be stored in the bus.
I suggest to add a callback in the probe function which would implement
the probing policy:
	FOREACH_DEV_IN_BUS {
		if (user_callback(dev, user_data))
			probe_one(dev);
	}

For compatibility, rte_eal_init() would call rte_bus_probe() with a
default callback which checks the whitelists and blacklists for PCI.
  

Patch

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 61d9e6e..793a625 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -137,6 +137,22 @@  typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -148,6 +164,7 @@  struct rte_bus {
 	rte_bus_plug_t plug;         /**< Probe single device for drivers */
 	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**