[dpdk-dev,v8,5/9] eal/bus: introduce support for bus probing

Message ID 1484660264-6531-6-git-send-email-shreyansh.jain@nxp.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation fail Compilation issues

Commit Message

Shreyansh Jain Jan. 17, 2017, 1:37 p.m. UTC
  Bus implementations can implement a probe handler to match the devices
scanned against the drivers registered.

This patch introduces the callback which would be implemented for PCI
in subsequent patch.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/common/eal_common_bus.c  |  1 +
 lib/librte_eal/common/include/rte_bus.h | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
  

Comments

Thomas Monjalon Jan. 17, 2017, 11:38 p.m. UTC | #1
2017-01-17 19:07, Shreyansh Jain:
> + * This is called while iterating over each registered bus. Bus object is
> + * passed along assuming this is wrapped around (embedded) by Implementation
> + * specific bus object.
> + *
> + * @param bus
> + *     Generic bus object which was registered with EAL

No param bus here.

> + *
> + * @return
> + *     0 for successful probe
> + *     !0 for any error while probing
> + */
> +typedef int (*rte_bus_probe_t)(void);
>
  

Patch

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 35baff8..9c4b014 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -53,6 +53,7 @@  rte_bus_register(struct rte_bus *bus)
 	RTE_VERIFY(bus->name && strlen(bus->name));
 	/* A bus should mandatorily have the scan implemented */
 	RTE_VERIFY(bus->scan);
+	RTE_VERIFY(bus->probe);
 
 	TAILQ_INSERT_TAIL(&rte_bus_list, bus, next);
 	RTE_LOG(INFO, EAL, "Registered [%s] bus.\n", bus->name);
diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 152451c..eb5c677 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -77,12 +77,30 @@  extern struct rte_bus_list rte_bus_list;
 typedef int (*rte_bus_scan_t)(void);
 
 /**
+ * Implementation specific probe function which is responsible for linking
+ * devices on that bus with applicable drivers.
+ *
+ * This is called while iterating over each registered bus. Bus object is
+ * passed along assuming this is wrapped around (embedded) by Implementation
+ * specific bus object.
+ *
+ * @param bus
+ *	Generic bus object which was registered with EAL
+ *
+ * @return
+ *	0 for successful probe
+ *	!0 for any error while probing
+ */
+typedef int (*rte_bus_probe_t)(void);
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
 	TAILQ_ENTRY(rte_bus) next;   /**< Next bus object in linked list */
 	const char *name;            /**< Name of the bus */
 	rte_bus_scan_t scan;         /**< Scan for devices attached to bus */
+	rte_bus_probe_t probe;       /**< Probe devices on bus */
 };
 
 /**