Thread (123 messages) 123 messages, 7 authors, 2017-07-08
STALE3307d

[PATCH v5 5/7] bus: add helper to find a bus from a device name

From: Gaetan Rivet <hidden>
Date: 2017-06-20 23:30:55
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

Find which bus should be able to parse this device name into an internal
device representation.

Signed-off-by: Gaetan Rivet <redacted>
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_bus.c          | 15 +++++++++++++++
 lib/librte_eal/common/include/rte_bus.h         | 12 ++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 29 insertions(+)
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 3517d74..04fa882 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -202,5 +202,6 @@ DPDK_17.08 {
 	global:
 
 	rte_bus_from_name;
+	rte_bus_from_dev;
 
 } DPDK_17.05;
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index e69ce38..e9fbc03 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -231,3 +231,18 @@ rte_bus_from_name(const char *str)
 {
 	return rte_bus_find(bus_cmp_name, str, NULL);
 }
+
+static int
+bus_can_parse(const struct rte_bus *bus, const void *_name)
+{
+	const char *name = _name;
+
+	return !(bus->parse && bus->parse(name, NULL) == 0);
+}
+
+/* find a bus capable of parsing a device description */
+struct rte_bus *
+rte_bus_from_dev(const char *str)
+{
+	return rte_bus_find(bus_can_parse, str, NULL);
+}
diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index da8b8a1..61d9e6e 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -283,6 +283,18 @@ struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
 struct rte_bus *rte_bus_from_name(const char *str);
 
 /**
+ * Find a bus capable of identifying a device.
+ *
+ * @param str
+ *   A device identifier (PCI address, virtual PMD name, ...).
+ *
+ * @return
+ *   A valid bus handle if found.
+ *   NULL if no bus is able to parse this device.
+ */
+struct rte_bus *rte_bus_from_dev(const char *str);
+
+/**
  * 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 6607acc..a5127d6 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -206,5 +206,6 @@ DPDK_17.08 {
 	global:
 
 	rte_bus_from_name;
+	rte_bus_from_dev;
 
 } DPDK_17.05;
-- 
2.1.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help