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

Function rte_eth_iterator_init

dpdk/lib/ethdev/rte_ethdev.c:174–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172};
173
174int
175rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str)
176{
177 int ret;
178 struct rte_devargs devargs;
179 const char *bus_param_key;
180 char *bus_str = NULL;
181 char *cls_str = NULL;
182 int str_size;
183
184 if (iter == NULL) {
185 RTE_ETHDEV_LOG(ERR, "Cannot initialize NULL iterator\n");
186 return -EINVAL;
187 }
188
189 if (devargs_str == NULL) {
190 RTE_ETHDEV_LOG(ERR,
191 "Cannot initialize iterator from NULL device description string\n");
192 return -EINVAL;
193 }
194
195 memset(iter, 0, sizeof(*iter));
196 memset(&devargs, 0, sizeof(devargs));
197
198 /*
199 * The devargs string may use various syntaxes:
200 * - 0000:08:00.0,representor=[1-3]
201 * - pci:0000:06:00.0,representor=[0,5]
202 * - class=eth,mac=00:11:22:33:44:55
203 * - bus=X,paramX=x/class=Y,paramY=y/driver=Z,paramZ=z
204 */
205
206 /*
207 * Handle pure class filter (i.e. without any bus-level argument),
208 * from future new syntax.
209 * rte_devargs_parse() is not yet supporting the new syntax,
210 * that's why this simple case is temporarily parsed here.
211 */
212#define iter_anybus_str "class=eth,"
213 if (strncmp(devargs_str, iter_anybus_str,
214 strlen(iter_anybus_str)) == 0) {
215 iter->cls_str = devargs_str + strlen(iter_anybus_str);
216 goto end;
217 }
218
219 /* Split bus, device and parameters. */
220 ret = rte_devargs_parse(&devargs, devargs_str);
221 if (ret != 0)
222 goto error;
223
224 /*
225 * Assume parameters of old syntax can match only at ethdev level.
226 * Extra parameters will be ignored, thanks to "+" prefix.
227 */
228 str_size = strlen(devargs.args) + 2;
229 cls_str = malloc(str_size);
230 if (cls_str == NULL) {
231 ret = -ENOMEM;

Callers

nothing calls this directly

Calls 9

memsetFunction · 0.85
strncmpFunction · 0.85
rte_devargs_parseFunction · 0.85
mallocFunction · 0.85
snprintfFunction · 0.85
strcmpFunction · 0.85
rte_class_find_by_nameFunction · 0.85
rte_devargs_resetFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected