[dpdk-dev] [PATCH v8 5/9] eal/bus: introduce support for bus probing
Shreyansh Jain
shreyansh.jain at nxp.com
Tue Jan 17 14:37:40 CET 2017
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 at nxp.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit at 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(+)
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 */
};
/**
--
2.7.4
More information about the dev
mailing list