[dpdk-dev,v10,07/13] eal: integrate bus scan and probe with EAL
Checks
Commit Message
Add functions for scanning all the buses and performing probe on all
the buses on EAL initialization.
Presently, no bus exists - in subseqent patches, PCI bus would be
introduced.
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
lib/librte_eal/bsdapp/eal/eal.c | 7 +++++
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++
lib/librte_eal/common/eal_common_bus.c | 40 +++++++++++++++++++++++++
lib/librte_eal/common/include/rte_bus.h | 19 ++++++++++++
lib/librte_eal/linuxapp/eal/eal.c | 8 +++++
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++
6 files changed, 78 insertions(+)
@@ -577,6 +577,9 @@ rte_eal_init(int argc, char **argv)
rte_config.master_lcore, thread_id, cpuset,
ret == 0 ? "" : "...");
+ if (rte_bus_scan())
+ rte_panic("Cannot scan the buses for devices\n");
+
RTE_LCORE_FOREACH_SLAVE(i) {
/*
@@ -613,6 +616,10 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_pci_probe())
rte_panic("Cannot probe PCI\n");
+ /* Probe all the buses and devices/drivers on them */
+ if (rte_bus_probe())
+ rte_panic("Cannot probe devices\n");
+
if (rte_eal_dev_init() < 0)
rte_panic("Cannot init pmd devices\n");
@@ -182,6 +182,8 @@ DPDK_17.02 {
rte_bus_dump;
rte_bus_register;
rte_bus_unregister;
+ rte_bus_probe;
+ rte_bus_scan;
rte_pci_match;
} DPDK_16.11;
@@ -65,6 +65,46 @@ rte_bus_unregister(struct rte_bus *bus)
RTE_LOG(DEBUG, EAL, "Unregistered [%s] bus.\n", bus->name);
}
+/* Scan all the buses for registering devices */
+int
+rte_bus_scan(void)
+{
+ int ret;
+ struct rte_bus *bus = NULL;
+
+ TAILQ_FOREACH(bus, &rte_bus_list, next) {
+ ret = bus->scan();
+ if (ret) {
+ RTE_LOG(ERR, EAL, "Scan for (%s) bus failed.\n",
+ bus->name);
+ /* Error in scanning any bus stops the EAL init. */
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+/* Call bus specific probe */
+int
+rte_bus_probe(void)
+{
+ int ret;
+ struct rte_bus *bus;
+
+ /* For each bus registered with EAL */
+ TAILQ_FOREACH(bus, &rte_bus_list, next) {
+ ret = bus->probe();
+ if (ret) {
+ RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n",
+ bus->name);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
/* Dump information of a single bus */
static int
bus_dump_one(FILE *f, struct rte_bus *bus)
@@ -113,6 +113,25 @@ void rte_bus_register(struct rte_bus *bus);
void rte_bus_unregister(struct rte_bus *bus);
/**
+ * Scan all the buses attached to the framework.
+ *
+ * @return
+ * 0 in case of success in scanning all buses
+ * !0 in case of failure to scan
+ */
+int rte_bus_scan(void);
+
+/**
+ * For each device on the bus, perform a driver 'match' and call the
+ * bus's probe for device initialization.
+ *
+ * @return
+ * 0 for successful match/probe
+ * !0 otherwise
+ */
+int rte_bus_probe(void);
+
+/**
* Dump information of all the buses registered with EAL.
*
* @param f
@@ -69,6 +69,7 @@
#include <rte_string_fns.h>
#include <rte_cpuflags.h>
#include <rte_interrupts.h>
+#include <rte_bus.h>
#include <rte_pci.h>
#include <rte_dev.h>
#include <rte_devargs.h>
@@ -844,6 +845,9 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_intr_init() < 0)
rte_panic("Cannot init interrupt-handling thread\n");
+ if (rte_bus_scan())
+ rte_panic("Cannot scan the buses for devices\n");
+
RTE_LCORE_FOREACH_SLAVE(i) {
/*
@@ -884,6 +888,10 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_pci_probe())
rte_panic("Cannot probe PCI\n");
+ /* Probe all the buses and devices/drivers on them */
+ if (rte_bus_probe())
+ rte_panic("Cannot probe devices\n");
+
if (rte_eal_dev_init() < 0)
rte_panic("Cannot init pmd devices\n");
@@ -186,6 +186,8 @@ DPDK_17.02 {
rte_bus_dump;
rte_bus_register;
rte_bus_unregister;
+ rte_bus_probe;
+ rte_bus_scan;
rte_pci_match;
} DPDK_16.11;