[dpdk-dev] [PATCH v4 25/29] l3fwd-graph: add graph based l3fwd skeleton

Andrzej Ostruszka amo at semihalf.com
Fri Apr 10 01:04:20 CEST 2020


On 4/5/20 10:56 AM, jerinj at marvell.com wrote:
> From: Nithin Dabilpuram <ndabilpuram at marvell.com>
> 
> Add graph based l3fwd application skeleton with cmdline
> parsing support inline with normal l3fwd.
> 
> Signed-off-by: Nithin Dabilpuram <ndabilpuram at marvell.com>
[...]
> +static int
> +parse_config(const char *q_arg)
> +{
> +	enum fieldnames { FLD_PORT = 0, FLD_QUEUE, FLD_LCORE, _NUM_FLD };
> +	unsigned long int_fld[_NUM_FLD];
> +	const char *p, *p0 = q_arg;
> +	char *str_fld[_NUM_FLD];
> +	uint32_t size;
> +	char s[256];
> +	char *end;
> +	int i;
> +
> +	nb_lcore_params = 0;
> +
> +	while ((p = strchr(p0, '(')) != NULL) {
> +		++p;
> +		p0 = strchr(p, ')');
> +		if (p0 == NULL)
> +			return -1;
> +
> +		size = p0 - p;
> +		if (size >= sizeof(s))
> +			return -1;
> +
> +		snprintf(s, sizeof(s), "%.*s", size, p);

Could I ask to make this function to be the same as final versions of
l2fwd and l2fwd-event that were recently under review?  There were
couple simple comments there and they apply here also.

> +		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') !=
> +		    _NUM_FLD)
> +			return -1;
> +		for (i = 0; i < _NUM_FLD; i++) {
> +			errno = 0;
> +			int_fld[i] = strtoul(str_fld[i], &end, 0);
> +			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
> +				return -1;
> +		}
> +		if (nb_lcore_params >= MAX_LCORE_PARAMS) {
> +			printf("Exceeded max number of lcore params: %hu\n",
> +			       nb_lcore_params);
> +			return -1;
> +		}
> +		lcore_params_array[nb_lcore_params].port_id =
> +			(uint8_t)int_fld[FLD_PORT];
> +		lcore_params_array[nb_lcore_params].queue_id =
> +			(uint8_t)int_fld[FLD_QUEUE];
> +		lcore_params_array[nb_lcore_params].lcore_id =
> +			(uint8_t)int_fld[FLD_LCORE];
> +		++nb_lcore_params;
> +	}
> +	lcore_params = lcore_params_array;
> +
> +	return 0;
> +}

With regards
Andrzej Ostruszka


More information about the dev mailing list