In preparation to making devargs_list private.

Bus drivers generally need to access rte_devargs pertaining to their
operations. This match is a common operation for bus drivers.

Add a new accessor for the rte_devargs list.

Signed-off-by: Gaetan Rivet <gaetan.ri...@6wind.com>
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 19 +++++++++++++++++++
 lib/librte_eal/common/include/rte_devargs.h     | 18 ++++++++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 39 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 47416a5..01ae0c7 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -189,6 +189,7 @@ EXPERIMENTAL {
        global:
 
        rte_eal_devargs_insert;
+       rte_eal_devargs_next;
        rte_eal_devargs_parse;
        rte_eal_devargs_remove;
        rte_eal_hotplug_add;
diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index 2fddbfa..614f1c5 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -208,3 +208,22 @@ rte_eal_devargs_dump(FILE *f)
                        devargs->name, devargs->args);
        }
 }
+
+/* bus-aware rte_devargs iterator. */
+struct rte_devargs *
+rte_eal_devargs_next(const char *busname, const struct rte_devargs *start)
+{
+       struct rte_devargs *da;
+
+       if (start != NULL)
+               da = TAILQ_NEXT(start, next);
+       else
+               da = TAILQ_FIRST(&devargs_list);
+       while (da != NULL) {
+               if (busname == NULL ||
+                   (strcmp(busname, da->bus->name) == 0))
+                       return da;
+               da = TAILQ_NEXT(da, next);
+       }
+       return NULL;
+}
diff --git a/lib/librte_eal/common/include/rte_devargs.h 
b/lib/librte_eal/common/include/rte_devargs.h
index e50c166..0eec406 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -188,6 +188,24 @@ int rte_eal_devargs_remove(const char *busname, const char 
*devname);
  */
 void rte_eal_devargs_dump(FILE *f);
 
+/**
+ * Find next rte_devargs matching the provided bus name.
+ *
+ * @param busname
+ *   Limit the iteration to bus matching this name.
+ *   Will return any next rte_devargs if NULL.
+ *
+ * @param start
+ *   Starting iteration point. The iteration will start at
+ *   the first rte_devargs if NULL.
+ *
+ * @return
+ *   Next rte_devargs entry matching the requested bus,
+ *   NULL if there is none.
+ */
+struct rte_devargs *
+rte_eal_devargs_next(const char *busname, const struct rte_devargs *start);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index e1e2a50..576de56 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -193,6 +193,7 @@ EXPERIMENTAL {
        global:
 
        rte_eal_devargs_insert;
+       rte_eal_devargs_next;
        rte_eal_devargs_parse;
        rte_eal_devargs_remove;
        rte_eal_hotplug_add;
-- 
2.1.4

Reply via email to