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.j...@nxp.com>
Reviewed-by: Ferruh Yigit <ferruh.yi...@intel.com>
---
 lib/librte_eal/common/eal_common_bus.c  |  1 +
 lib/librte_eal/common/include/rte_bus.h | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_bus.c 
b/lib/librte_eal/common/eal_common_bus.c
index aaba10a..3f529e6 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -52,6 +52,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(DEBUG, 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 ba7d866..17583ad 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -73,12 +73,25 @@ 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.
+ *
+ * @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 */
 };
 
 /**
-- 
2.7.4

Reply via email to