bus: add scanning
Scan for bus discovers the devices available on the bus and adds them to a bus specific device list. Each bus mandatorily implements this method. Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
This commit is contained in:
parent
a97725791e
commit
f44abbc12f
@ -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) {
|
||||
|
||||
/*
|
||||
|
@ -180,6 +180,7 @@ DPDK_17.02 {
|
||||
|
||||
rte_bus_dump;
|
||||
rte_bus_register;
|
||||
rte_bus_scan;
|
||||
rte_bus_unregister;
|
||||
|
||||
} DPDK_16.11;
|
||||
|
@ -47,6 +47,8 @@ rte_bus_register(struct rte_bus *bus)
|
||||
{
|
||||
RTE_VERIFY(bus);
|
||||
RTE_VERIFY(bus->name && strlen(bus->name));
|
||||
/* A bus should mandatorily have the scan implemented */
|
||||
RTE_VERIFY(bus->scan);
|
||||
|
||||
TAILQ_INSERT_TAIL(&rte_bus_list, bus, next);
|
||||
RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name);
|
||||
@ -59,6 +61,25 @@ rte_bus_unregister(struct rte_bus *bus)
|
||||
RTE_LOG(DEBUG, EAL, "Unregistered [%s] bus.\n", bus->name);
|
||||
}
|
||||
|
||||
/* Scan all the buses for registered 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);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Dump information of a single bus */
|
||||
static int
|
||||
bus_dump_one(FILE *f, struct rte_bus *bus)
|
||||
|
@ -56,12 +56,26 @@ extern "C" {
|
||||
/** Double linked list of buses */
|
||||
TAILQ_HEAD(rte_bus_list, rte_bus);
|
||||
|
||||
/**
|
||||
* Bus specific scan for devices attached on the bus.
|
||||
* For each bus object, the scan would be reponsible for finding devices and
|
||||
* adding them to its private device list.
|
||||
*
|
||||
* A bus should mandatorily implement this method.
|
||||
*
|
||||
* @return
|
||||
* 0 for successful scan
|
||||
* <0 for unsuccessful scan with error value
|
||||
*/
|
||||
typedef int (*rte_bus_scan_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 */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -82,6 +96,15 @@ void rte_bus_register(struct rte_bus *bus);
|
||||
*/
|
||||
void rte_bus_unregister(struct rte_bus *bus);
|
||||
|
||||
/**
|
||||
* Scan all the buses.
|
||||
*
|
||||
* @return
|
||||
* 0 in case of success in scanning all buses
|
||||
* !0 in case of failure to scan
|
||||
*/
|
||||
int rte_bus_scan(void);
|
||||
|
||||
/**
|
||||
* Dump information of all the buses registered with EAL.
|
||||
*
|
||||
|
@ -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) {
|
||||
|
||||
/*
|
||||
|
@ -184,6 +184,7 @@ DPDK_17.02 {
|
||||
|
||||
rte_bus_dump;
|
||||
rte_bus_register;
|
||||
rte_bus_scan;
|
||||
rte_bus_unregister;
|
||||
|
||||
} DPDK_16.11;
|
||||
|
Loading…
x
Reference in New Issue
Block a user