[dpdk-dev,v4,6/9] bus: add helper to find a bus from a bus name
Checks
Commit Message
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 7 +++++++
lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++++++
lib/librte_eal/common/include/rte_bus.h | 14 ++++++++++++++
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 7 +++++++
4 files changed, 47 insertions(+)
@@ -197,3 +197,10 @@ DPDK_17.05 {
vfio_get_group_no;
} DPDK_17.02;
+
+DPDK_17.08 {
+ global:
+
+ rte_bus_from_name;
+
+} DPDK_17.05;
@@ -220,3 +220,22 @@ rte_bus_name_valid(const char *name)
i++;
return i;
}
+
+static int
+bus_cmp_name(const struct rte_bus *bus, const void *_name)
+{
+ const char *name = _name;
+ size_t i = 0;
+
+ i = rte_bus_name_valid(name);
+ return strncmp(bus->name, name, i);
+}
+
+/* find a bus by its name */
+struct rte_bus *
+rte_bus_from_name(const char *str)
+{
+ if (rte_bus_name_valid(str) == 0)
+ return NULL;
+ return rte_bus_find(bus_cmp_name, str);
+}
@@ -261,6 +261,20 @@ rte_bus_find_device(const struct rte_device *start,
*/
struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
+/*
+ * Find a bus handle by its name.
+ * Compares the name of each bus up until any invalid character
+ * in the matched pattern.
+ *
+ * @param str
+ * A null terminated character string.
+ *
+ * @return
+ * A pointer to a bus if found.
+ * NULL if no bus matches.
+ */
+struct rte_bus *rte_bus_from_name(const char *str);
+
/**
* Helper for Bus registration.
* The constructor has higher priority than PMD constructors.
@@ -201,3 +201,10 @@ DPDK_17.05 {
vfio_get_group_no;
} DPDK_17.02;
+
+DPDK_17.08 {
+ global:
+
+ rte_bus_from_name;
+
+} DPDK_17.05;