[dpdk-dev] [PATCH v4 01/10] devargs: introduce iterator

Stephen Hemminger stephen at networkplumber.org
Tue Apr 24 01:54:17 CEST 2018


On Tue, 24 Apr 2018 00:41:01 +0200
Gaetan Rivet <gaetan.rivet at 6wind.com> wrote:

> 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 at 6wind.com>
> ---
>  lib/librte_eal/common/eal_common_devargs.c  | 20 ++++++++++++++++++++
>  lib/librte_eal/common/include/rte_devargs.h | 20 ++++++++++++++++++++
>  lib/librte_eal/rte_eal_version.map          |  1 +
>  3 files changed, 41 insertions(+)
> 
> diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
> index 810b3e18f..c6c5eabcf 100644
> --- a/lib/librte_eal/common/eal_common_devargs.c
> +++ b/lib/librte_eal/common/eal_common_devargs.c
> @@ -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;
> +}

Can this be made to return a const pointer? It seems unsymmetrical to
get the next value as a non-const pointer when passed a const based on last value.



More information about the dev mailing list