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

Function parse_ringnuma_config

dpdk/app/test-pmd/parameters.c:351–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351static int
352parse_ringnuma_config(const char *q_arg)
353{
354 char s[256];
355 const char *p, *p0 = q_arg;
356 char *end;
357 uint8_t i, ring_flag, socket_id;
358 portid_t port_id;
359 unsigned size;
360 enum fieldnames {
361 FLD_PORT = 0,
362 FLD_FLAG,
363 FLD_SOCKET,
364 _NUM_FLD
365 };
366 unsigned long int_fld[_NUM_FLD];
367 char *str_fld[_NUM_FLD];
368 #define RX_RING_ONLY 0x1
369 #define TX_RING_ONLY 0x2
370 #define RXTX_RING 0x3
371
372 /* reset from value set at definition */
373 while ((p = strchr(p0,'(')) != NULL) {
374 ++p;
375 if((p0 = strchr(p,')')) == NULL)
376 return -1;
377
378 size = p0 - p;
379 if(size >= sizeof(s))
380 return -1;
381
382 snprintf(s, sizeof(s), "%.*s", size, p);
383 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
384 return -1;
385 for (i = 0; i < _NUM_FLD; i++) {
386 errno = 0;
387 int_fld[i] = strtoul(str_fld[i], &end, 0);
388 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
389 return -1;
390 }
391 port_id = (portid_t)int_fld[FLD_PORT];
392 if (port_id_is_invalid(port_id, ENABLED_WARN) ||
393 port_id == (portid_t)RTE_PORT_ALL) {
394 print_valid_ports();
395 return -1;
396 }
397 socket_id = (uint8_t)int_fld[FLD_SOCKET];
398 if (new_socket_id(socket_id)) {
399 if (num_sockets >= RTE_MAX_NUMA_NODES) {
400 print_invalid_socket_id_error();
401 return -1;
402 }
403 socket_ids[num_sockets++] = socket_id;
404 }
405 ring_flag = (uint8_t)int_fld[FLD_FLAG];
406 if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
407 fprintf(stderr,
408 "Invalid ring-flag=%d config for port =%d\n",

Callers 1

launch_args_parseFunction · 0.85

Calls 8

strchrFunction · 0.85
snprintfFunction · 0.85
rte_strsplitFunction · 0.85
strtoulFunction · 0.85
port_id_is_invalidFunction · 0.85
print_valid_portsFunction · 0.85
new_socket_idFunction · 0.85

Tested by

no test coverage detected