devargs: introduce iterator
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.rivet@6wind.com> Acked-by: Thomas Monjalon <thomas@monjalon.net>
This commit is contained in:
parent
fa20485454
commit
e53e0fe0c2
@ -207,3 +207,23 @@ rte_eal_devargs_dump(FILE *f)
|
||||
devargs->name, devargs->args);
|
||||
}
|
||||
}
|
||||
|
||||
/* bus-aware rte_devargs iterator. */
|
||||
__rte_experimental
|
||||
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;
|
||||
}
|
||||
|
@ -189,6 +189,34 @@ rte_eal_devargs_type_count(enum rte_devtype devtype);
|
||||
*/
|
||||
void rte_eal_devargs_dump(FILE *f);
|
||||
|
||||
/**
|
||||
* Find next rte_devargs matching the provided bus name.
|
||||
*
|
||||
* @param busname
|
||||
* Limit the iteration to devargs related to buses
|
||||
* 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.
|
||||
*/
|
||||
__rte_experimental
|
||||
struct rte_devargs *
|
||||
rte_eal_devargs_next(const char *busname, const struct rte_devargs *start);
|
||||
|
||||
/**
|
||||
* Iterate over all rte_devargs for a specific bus.
|
||||
*/
|
||||
#define RTE_EAL_DEVARGS_FOREACH(busname, da) \
|
||||
for (da = rte_eal_devargs_next(busname, NULL); \
|
||||
da != NULL; \
|
||||
da = rte_eal_devargs_next(busname, da)) \
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -220,6 +220,7 @@ EXPERIMENTAL {
|
||||
rte_dev_event_monitor_stop;
|
||||
rte_eal_cleanup;
|
||||
rte_eal_devargs_insert;
|
||||
rte_eal_devargs_next;
|
||||
rte_eal_devargs_parse;
|
||||
rte_eal_devargs_remove;
|
||||
rte_eal_hotplug_add;
|
||||
|
Loading…
x
Reference in New Issue
Block a user