From 2f517390e5697d2bf8c68050a7dc3e2a5c0a5a31 Mon Sep 17 00:00:00 2001 From: Jan Blunck Date: Fri, 30 Jun 2017 20:19:37 +0200 Subject: [PATCH] bus: add helper to find bus by name Signed-off-by: Jan Blunck --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 14 ++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 5 +++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 21 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 458e3a6f5d..d138a96ea1 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -199,5 +199,6 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; + rte_bus_find_by_name; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index b8a9e3072f..bf2b138a6e 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -188,3 +188,17 @@ rte_bus_find_by_device(const struct rte_device *dev) { return rte_bus_find(NULL, bus_find_device, (const void *)dev); } + +static int +cmp_bus_name(const struct rte_bus *bus, const void *_name) +{ + const char *name = _name; + + return strcmp(bus->name, name); +} + +struct rte_bus * +rte_bus_find_by_name(const char *busname) +{ + return rte_bus_find(NULL, cmp_bus_name, (const void *)busname); +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index f8b321559e..509292d134 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -214,6 +214,11 @@ struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp, */ struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); +/** + * Find the registered bus for a given name. + */ +struct rte_bus *rte_bus_find_by_name(const char *busname); + /** * Helper for Bus registration. * The constructor has higher priority than PMD constructors. diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 3c193e4927..643ec1cc70 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -204,5 +204,6 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; + rte_bus_find_by_name; } DPDK_17.05; -- 2.20.1