summaryrefslogtreecommitdiff
path: root/lib/librte_eal/common/eal_common_bus.c
diff options
context:
space:
mode:
authorShreyansh Jain <shreyansh.jain@nxp.com>2017-01-18 19:35:21 +0530
committerThomas Monjalon <thomas.monjalon@6wind.com>2017-01-19 04:58:12 +0100
commitf44abbc12fa00a603b50c401828c4d03f74d4f76 (patch)
tree0623af12bdadd841718ac7bd5113284287a8c282 /lib/librte_eal/common/eal_common_bus.c
parenta97725791eec933a07f160e3632975f0cc836ab4 (diff)
downloaddpdk-f44abbc12fa00a603b50c401828c4d03f74d4f76.zip
dpdk-f44abbc12fa00a603b50c401828c4d03f74d4f76.tar.gz
dpdk-f44abbc12fa00a603b50c401828c4d03f74d4f76.tar.xz
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>
Diffstat (limited to 'lib/librte_eal/common/eal_common_bus.c')
-rw-r--r--lib/librte_eal/common/eal_common_bus.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index e9b1470..ef10390 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -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)