MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_config

Function parse_config

dpdk/examples/l3fwd-graph/main.c:402–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402static int
403parse_config(const char *q_arg)
404{
405 enum fieldnames { FLD_PORT = 0, FLD_QUEUE, FLD_LCORE, _NUM_FLD };
406 unsigned long int_fld[_NUM_FLD];
407 const char *p, *p0 = q_arg;
408 char *str_fld[_NUM_FLD];
409 uint32_t size;
410 char s[256];
411 char *end;
412 int i;
413
414 nb_lcore_params = 0;
415
416 while ((p = strchr(p0, '(')) != NULL) {
417 ++p;
418 p0 = strchr(p, ')');
419 if (p0 == NULL)
420 return -1;
421
422 size = p0 - p;
423 if (size >= sizeof(s))
424 return -1;
425
426 memcpy(s, p, size);
427 s[size] = '\0';
428 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') !=
429 _NUM_FLD)
430 return -1;
431 for (i = 0; i < _NUM_FLD; i++) {
432 errno = 0;
433 int_fld[i] = strtoul(str_fld[i], &end, 0);
434 if (errno != 0 || end == str_fld[i])
435 return -1;
436 }
437
438 if (nb_lcore_params >= MAX_LCORE_PARAMS) {
439 printf("Exceeded max number of lcore params: %hu\n",
440 nb_lcore_params);
441 return -1;
442 }
443
444 if (int_fld[FLD_PORT] >= RTE_MAX_ETHPORTS ||
445 int_fld[FLD_LCORE] >= RTE_MAX_LCORE) {
446 printf("Invalid port/lcore id\n");
447 return -1;
448 }
449
450 lcore_params_array[nb_lcore_params].port_id =
451 (uint16_t)int_fld[FLD_PORT];
452 lcore_params_array[nb_lcore_params].queue_id =
453 (uint16_t)int_fld[FLD_QUEUE];
454 lcore_params_array[nb_lcore_params].lcore_id =
455 (uint32_t)int_fld[FLD_LCORE];
456 ++nb_lcore_params;
457 }
458 lcore_params = lcore_params_array;
459

Callers 1

parse_argsFunction · 0.70

Calls 5

strchrFunction · 0.85
rte_strsplitFunction · 0.85
strtoulFunction · 0.85
memcpyFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected