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

Function rte_devargs_layers_parse

dpdk/lib/eal/common/eal_common_devargs.c:54–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54int
55rte_devargs_layers_parse(struct rte_devargs *devargs,
56 const char *devstr)
57{
58 struct {
59 const char *key;
60 const char *str;
61 struct rte_kvargs *kvlist;
62 } layers[] = {
63 { RTE_DEVARGS_KEY_BUS "=", NULL, NULL, },
64 { RTE_DEVARGS_KEY_CLASS "=", NULL, NULL, },
65 { RTE_DEVARGS_KEY_DRIVER "=", NULL, NULL, },
66 };
67 struct rte_kvargs_pair *kv = NULL;
68 struct rte_kvargs *bus_kvlist = NULL;
69 char *s;
70 size_t nblayer = 0;
71 size_t i;
72 int ret = 0;
73 bool allocated_data = false;
74
75 /* If the devargs points the devstr
76 * as source data, then it should not allocate
77 * anything and keep referring only to it.
78 */
79 if (devargs->data != devstr) {
80 devargs->data = strdup(devstr);
81 if (devargs->data == NULL) {
82 RTE_LOG(ERR, EAL, "OOM\n");
83 ret = -ENOMEM;
84 goto get_out;
85 }
86 allocated_data = true;
87 }
88 s = devargs->data;
89
90 while (s != NULL) {
91 if (nblayer >= RTE_DIM(layers)) {
92 ret = -E2BIG;
93 goto get_out;
94 }
95 layers[nblayer].str = s;
96
97 /* Locate next layer starts with valid layer key. */
98 while (s != NULL) {
99 s = strchr(s, '/');
100 if (s == NULL)
101 break;
102 for (i = 0; i < RTE_DIM(layers); i++) {
103 if (strncmp(s + 1, layers[i].key,
104 strlen(layers[i].key)) == 0) {
105 *s = '\0';
106 break;
107 }
108 }
109 s++;
110 if (i < RTE_DIM(layers))
111 break;

Callers 2

rte_dev_iterator_initFunction · 0.85
rte_devargs_parseFunction · 0.85

Calls 10

strdupFunction · 0.85
strchrFunction · 0.85
strncmpFunction · 0.85
rte_kvargs_parseFunction · 0.85
strcmpFunction · 0.85
rte_bus_find_by_nameFunction · 0.85
rte_class_find_by_nameFunction · 0.85
rte_kvargs_freeFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected