Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2014 Intel Corporation.
3 : : * Copyright(c) 2014 6WIND S.A.
4 : : */
5 : :
6 : : #include <stdlib.h>
7 : : #include <string.h>
8 : : #include <pthread.h>
9 : : #ifndef RTE_EXEC_ENV_WINDOWS
10 : : #include <syslog.h>
11 : : #endif
12 : : #include <ctype.h>
13 : : #include <limits.h>
14 : : #include <errno.h>
15 : : #include <getopt.h>
16 : : #ifndef RTE_EXEC_ENV_WINDOWS
17 : : #include <dlfcn.h>
18 : : #include <libgen.h>
19 : : #endif
20 : : #include <sys/stat.h>
21 : : #ifndef RTE_EXEC_ENV_WINDOWS
22 : : #include <dirent.h>
23 : : #endif
24 : :
25 : : #include <rte_string_fns.h>
26 : : #include <rte_eal.h>
27 : : #include <rte_log.h>
28 : : #include <rte_lcore.h>
29 : : #include <rte_memory.h>
30 : : #include <rte_tailq.h>
31 : : #include <rte_version.h>
32 : : #include <rte_devargs.h>
33 : : #include <rte_memcpy.h>
34 : : #ifndef RTE_EXEC_ENV_WINDOWS
35 : : #include <rte_telemetry.h>
36 : : #endif
37 : : #include <rte_vect.h>
38 : :
39 : : #include "eal_internal_cfg.h"
40 : : #include "eal_options.h"
41 : : #include "eal_filesystem.h"
42 : : #include "eal_private.h"
43 : : #include "log_internal.h"
44 : : #ifndef RTE_EXEC_ENV_WINDOWS
45 : : #include "eal_trace.h"
46 : : #endif
47 : :
48 : : #define BITS_PER_HEX 4
49 : : #define LCORE_OPT_LST 1
50 : : #define LCORE_OPT_MSK 2
51 : : #define LCORE_OPT_MAP 3
52 : :
53 : : const char
54 : : eal_short_options[] =
55 : : "a:" /* allow */
56 : : "b:" /* block */
57 : : "c:" /* coremask */
58 : : "s:" /* service coremask */
59 : : "d:" /* driver */
60 : : "h" /* help */
61 : : "l:" /* corelist */
62 : : "S:" /* service corelist */
63 : : "m:" /* memory size */
64 : : "n:" /* memory channels */
65 : : "r:" /* memory ranks */
66 : : "v" /* version */
67 : : ;
68 : :
69 : : const struct option
70 : : eal_long_options[] = {
71 : : {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM },
72 : : {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM },
73 : : {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM },
74 : : {OPT_HELP, 0, NULL, OPT_HELP_NUM },
75 : : {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
76 : : {OPT_HUGE_UNLINK, 2, NULL, OPT_HUGE_UNLINK_NUM },
77 : : {OPT_IOVA_MODE, 1, NULL, OPT_IOVA_MODE_NUM },
78 : : {OPT_LCORES, 1, NULL, OPT_LCORES_NUM },
79 : : {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM },
80 : : {OPT_TRACE, 1, NULL, OPT_TRACE_NUM },
81 : : {OPT_TRACE_DIR, 1, NULL, OPT_TRACE_DIR_NUM },
82 : : {OPT_TRACE_BUF_SIZE, 1, NULL, OPT_TRACE_BUF_SIZE_NUM },
83 : : {OPT_TRACE_MODE, 1, NULL, OPT_TRACE_MODE_NUM },
84 : : {OPT_MAIN_LCORE, 1, NULL, OPT_MAIN_LCORE_NUM },
85 : : {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
86 : : {OPT_NO_HPET, 0, NULL, OPT_NO_HPET_NUM },
87 : : {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM },
88 : : {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM },
89 : : {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM },
90 : : {OPT_IN_MEMORY, 0, NULL, OPT_IN_MEMORY_NUM },
91 : : {OPT_DEV_BLOCK, 1, NULL, OPT_DEV_BLOCK_NUM },
92 : : {OPT_DEV_ALLOW, 1, NULL, OPT_DEV_ALLOW_NUM },
93 : : {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM },
94 : : {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM },
95 : : {OPT_SOCKET_LIMIT, 1, NULL, OPT_SOCKET_LIMIT_NUM },
96 : : {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
97 : : {OPT_VDEV, 1, NULL, OPT_VDEV_NUM },
98 : : {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM },
99 : : {OPT_VFIO_VF_TOKEN, 1, NULL, OPT_VFIO_VF_TOKEN_NUM },
100 : : {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
101 : : {OPT_LEGACY_MEM, 0, NULL, OPT_LEGACY_MEM_NUM },
102 : : {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
103 : : {OPT_MATCH_ALLOCATIONS, 0, NULL, OPT_MATCH_ALLOCATIONS_NUM},
104 : : {OPT_TELEMETRY, 0, NULL, OPT_TELEMETRY_NUM },
105 : : {OPT_NO_TELEMETRY, 0, NULL, OPT_NO_TELEMETRY_NUM },
106 : : {OPT_FORCE_MAX_SIMD_BITWIDTH, 1, NULL, OPT_FORCE_MAX_SIMD_BITWIDTH_NUM},
107 : : {OPT_HUGE_WORKER_STACK, 2, NULL, OPT_HUGE_WORKER_STACK_NUM },
108 : :
109 : : {0, 0, NULL, 0 }
110 : : };
111 : :
112 : : TAILQ_HEAD(shared_driver_list, shared_driver);
113 : :
114 : : /* Definition for shared object drivers. */
115 : : struct shared_driver {
116 : : TAILQ_ENTRY(shared_driver) next;
117 : :
118 : : char name[PATH_MAX];
119 : : void* lib_handle;
120 : : };
121 : :
122 : : /* List of external loadable drivers */
123 : : static struct shared_driver_list solib_list =
124 : : TAILQ_HEAD_INITIALIZER(solib_list);
125 : :
126 : : #ifndef RTE_EXEC_ENV_WINDOWS
127 : : /* Default path of external loadable drivers */
128 : : static const char *default_solib_dir = RTE_EAL_PMD_PATH;
129 : : #endif
130 : :
131 : : /*
132 : : * Stringified version of solib path used by dpdk-pmdinfo.py
133 : : * Note: PLEASE DO NOT ALTER THIS without making a corresponding
134 : : * change to usertools/dpdk-pmdinfo.py
135 : : */
136 : : static const char dpdk_solib_path[] __rte_used =
137 : : "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
138 : :
139 : : TAILQ_HEAD(device_option_list, device_option);
140 : :
141 : : struct device_option {
142 : : TAILQ_ENTRY(device_option) next;
143 : :
144 : : enum rte_devtype type;
145 : : char arg[];
146 : : };
147 : :
148 : : static struct device_option_list devopt_list =
149 : : TAILQ_HEAD_INITIALIZER(devopt_list);
150 : :
151 : : static int main_lcore_parsed;
152 : : static int mem_parsed;
153 : : static int core_parsed;
154 : :
155 : : /* Allow the application to print its usage message too if set */
156 : : static rte_usage_hook_t rte_application_usage_hook;
157 : :
158 : : /* Returns rte_usage_hook_t */
159 : : rte_usage_hook_t
160 : 52 : eal_get_application_usage_hook(void)
161 : : {
162 : 52 : return rte_application_usage_hook;
163 : : }
164 : :
165 : : /* Set a per-application usage message */
166 : : rte_usage_hook_t
167 : 2 : rte_set_application_usage_hook(rte_usage_hook_t usage_func)
168 : : {
169 : : rte_usage_hook_t old_func;
170 : :
171 : : /* Will be NULL on the first call to denote the last usage routine. */
172 : 2 : old_func = rte_application_usage_hook;
173 : 2 : rte_application_usage_hook = usage_func;
174 : :
175 : 2 : return old_func;
176 : : }
177 : :
178 : : #ifndef RTE_EXEC_ENV_WINDOWS
179 : : static char **eal_args;
180 : : static char **eal_app_args;
181 : :
182 : : #define EAL_PARAM_REQ "/eal/params"
183 : : #define EAL_APP_PARAM_REQ "/eal/app_params"
184 : :
185 : : /* callback handler for telemetry library to report out EAL flags */
186 : : int
187 : 0 : handle_eal_info_request(const char *cmd, const char *params __rte_unused,
188 : : struct rte_tel_data *d)
189 : : {
190 : : char **args;
191 : : int used = 0;
192 : : int i = 0;
193 : :
194 [ # # ]: 0 : if (strcmp(cmd, EAL_PARAM_REQ) == 0)
195 : 0 : args = eal_args;
196 : : else
197 : 0 : args = eal_app_args;
198 : :
199 : 0 : rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
200 [ # # # # ]: 0 : if (args == NULL || args[0] == NULL)
201 : : return 0;
202 : :
203 [ # # ]: 0 : for ( ; args[i] != NULL; i++)
204 : 0 : used = rte_tel_data_add_array_string(d, args[i]);
205 : : return used;
206 : : }
207 : :
208 : : int
209 : 238 : eal_save_args(int argc, char **argv)
210 : : {
211 : : int i, j;
212 : :
213 : 238 : rte_telemetry_register_cmd(EAL_PARAM_REQ, handle_eal_info_request,
214 : : "Returns EAL commandline parameters used. Takes no parameters");
215 : 238 : rte_telemetry_register_cmd(EAL_APP_PARAM_REQ, handle_eal_info_request,
216 : : "Returns app commandline parameters used. Takes no parameters");
217 : :
218 : : /* clone argv to report out later. We overprovision, but
219 : : * this does not waste huge amounts of memory
220 : : */
221 : 238 : eal_args = calloc(argc + 1, sizeof(*eal_args));
222 [ + - ]: 238 : if (eal_args == NULL)
223 : : return -1;
224 : :
225 [ + + ]: 1201 : for (i = 0; i < argc; i++) {
226 [ + - ]: 963 : if (strcmp(argv[i], "--") == 0)
227 : : break;
228 : 963 : eal_args[i] = strdup(argv[i]);
229 [ - + ]: 963 : if (eal_args[i] == NULL)
230 : 0 : goto error;
231 : : }
232 : 238 : eal_args[i++] = NULL; /* always finish with NULL */
233 : :
234 : : /* allow reporting of any app args we know about too */
235 [ - + ]: 238 : if (i >= argc)
236 : : return 0;
237 : :
238 : 0 : eal_app_args = calloc(argc - i + 1, sizeof(*eal_args));
239 [ # # ]: 0 : if (eal_app_args == NULL)
240 : 0 : goto error;
241 : :
242 [ # # ]: 0 : for (j = 0; i < argc; j++, i++) {
243 : 0 : eal_app_args[j] = strdup(argv[i]);
244 [ # # ]: 0 : if (eal_app_args[j] == NULL)
245 : 0 : goto error;
246 : : }
247 : 0 : eal_app_args[j] = NULL;
248 : :
249 : 0 : return 0;
250 : :
251 : 0 : error:
252 [ # # ]: 0 : if (eal_app_args != NULL) {
253 : : i = 0;
254 [ # # ]: 0 : while (eal_app_args[i] != NULL)
255 : 0 : free(eal_app_args[i++]);
256 : 0 : free(eal_app_args);
257 : 0 : eal_app_args = NULL;
258 : : }
259 : : i = 0;
260 [ # # ]: 0 : while (eal_args[i] != NULL)
261 : 0 : free(eal_args[i++]);
262 : 0 : free(eal_args);
263 : 0 : eal_args = NULL;
264 : 0 : return -1;
265 : : }
266 : : #endif
267 : :
268 : : static int
269 : 31 : eal_option_device_add(enum rte_devtype type, const char *optarg)
270 : : {
271 : : struct device_option *devopt;
272 : : size_t optlen;
273 : : int ret;
274 : :
275 : 31 : optlen = strlen(optarg) + 1;
276 : 31 : devopt = calloc(1, sizeof(*devopt) + optlen);
277 [ - + ]: 31 : if (devopt == NULL) {
278 : 0 : EAL_LOG(ERR, "Unable to allocate device option");
279 : 0 : return -ENOMEM;
280 : : }
281 : :
282 : 31 : devopt->type = type;
283 [ - + ]: 31 : ret = strlcpy(devopt->arg, optarg, optlen);
284 [ - + ]: 31 : if (ret < 0) {
285 : 0 : EAL_LOG(ERR, "Unable to copy device option");
286 : 0 : free(devopt);
287 : 0 : return -EINVAL;
288 : : }
289 : 31 : TAILQ_INSERT_TAIL(&devopt_list, devopt, next);
290 : 31 : return 0;
291 : : }
292 : :
293 : : int
294 : 186 : eal_option_device_parse(void)
295 : : {
296 : : struct device_option *devopt;
297 : : void *tmp;
298 : : int ret = 0;
299 : :
300 [ + + ]: 217 : RTE_TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
301 [ + - ]: 31 : if (ret == 0) {
302 : 31 : ret = rte_devargs_add(devopt->type, devopt->arg);
303 [ + + ]: 31 : if (ret)
304 : 13 : EAL_LOG(ERR, "Unable to parse device '%s'",
305 : : devopt->arg);
306 : : }
307 [ + + ]: 31 : TAILQ_REMOVE(&devopt_list, devopt, next);
308 : 31 : free(devopt);
309 : : }
310 : 186 : return ret;
311 : : }
312 : :
313 : : const char *
314 : 8822 : eal_get_hugefile_prefix(void)
315 : : {
316 : : const struct internal_config *internal_conf =
317 : 8822 : eal_get_internal_configuration();
318 : :
319 [ + + ]: 8822 : if (internal_conf->hugefile_prefix != NULL)
320 : 5423 : return internal_conf->hugefile_prefix;
321 : : return HUGEFILE_PREFIX_DEFAULT;
322 : : }
323 : :
324 : : void
325 : 238 : eal_reset_internal_config(struct internal_config *internal_cfg)
326 : : {
327 : : int i;
328 : :
329 : 238 : internal_cfg->memory = 0;
330 : 238 : internal_cfg->force_nrank = 0;
331 : 238 : internal_cfg->force_nchannel = 0;
332 : 238 : internal_cfg->hugefile_prefix = NULL;
333 : 238 : internal_cfg->hugepage_dir = NULL;
334 : 238 : internal_cfg->hugepage_file.unlink_before_mapping = false;
335 : 238 : internal_cfg->hugepage_file.unlink_existing = true;
336 : 238 : internal_cfg->force_sockets = 0;
337 : : /* zero out the NUMA config */
338 [ + + ]: 7854 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
339 : 7616 : internal_cfg->socket_mem[i] = 0;
340 : 238 : internal_cfg->force_socket_limits = 0;
341 : : /* zero out the NUMA limits config */
342 [ + + ]: 7854 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
343 : 7616 : internal_cfg->socket_limit[i] = 0;
344 : : /* zero out hugedir descriptors */
345 [ + + ]: 952 : for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) {
346 : 714 : memset(&internal_cfg->hugepage_info[i], 0,
347 : : sizeof(internal_cfg->hugepage_info[0]));
348 : 714 : internal_cfg->hugepage_info[i].lock_descriptor = -1;
349 : : }
350 : 238 : internal_cfg->base_virtaddr = 0;
351 : :
352 : : #ifdef LOG_DAEMON
353 : 238 : internal_cfg->syslog_facility = LOG_DAEMON;
354 : : #endif
355 : :
356 : : /* if set to NONE, interrupt mode is determined automatically */
357 : 238 : internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
358 : 238 : memset(internal_cfg->vfio_vf_token, 0,
359 : : sizeof(internal_cfg->vfio_vf_token));
360 : :
361 : : #ifdef RTE_LIBEAL_USE_HPET
362 : : internal_cfg->no_hpet = 0;
363 : : #else
364 : 238 : internal_cfg->no_hpet = 1;
365 : : #endif
366 : 238 : internal_cfg->vmware_tsc_map = 0;
367 : 238 : internal_cfg->create_uio_dev = 0;
368 : 238 : internal_cfg->iova_mode = RTE_IOVA_DC;
369 : 238 : internal_cfg->user_mbuf_pool_ops_name = NULL;
370 : 238 : CPU_ZERO(&internal_cfg->ctrl_cpuset);
371 : 238 : internal_cfg->init_complete = 0;
372 : 238 : internal_cfg->max_simd_bitwidth.bitwidth = RTE_VECT_DEFAULT_SIMD_BITWIDTH;
373 : 238 : internal_cfg->max_simd_bitwidth.forced = 0;
374 : 238 : }
375 : :
376 : : static int
377 : 0 : eal_plugin_add(const char *path)
378 : : {
379 : : struct shared_driver *solib;
380 : :
381 : 0 : solib = malloc(sizeof(*solib));
382 [ # # ]: 0 : if (solib == NULL) {
383 : 0 : EAL_LOG(ERR, "malloc(solib) failed");
384 : 0 : return -1;
385 : : }
386 : : memset(solib, 0, sizeof(*solib));
387 : 0 : strlcpy(solib->name, path, PATH_MAX);
388 : 0 : TAILQ_INSERT_TAIL(&solib_list, solib, next);
389 : :
390 : 0 : return 0;
391 : : }
392 : :
393 : : #ifdef RTE_EXEC_ENV_WINDOWS
394 : : int
395 : : eal_plugins_init(void)
396 : : {
397 : : return 0;
398 : : }
399 : : #else
400 : :
401 : : static int
402 : 0 : eal_plugindir_init(const char *path)
403 : : {
404 : : DIR *d = NULL;
405 : : struct dirent *dent = NULL;
406 : : char sopath[PATH_MAX];
407 : :
408 [ # # # # ]: 0 : if (path == NULL || *path == '\0')
409 : : return 0;
410 : :
411 : 0 : d = opendir(path);
412 [ # # ]: 0 : if (d == NULL) {
413 : 0 : EAL_LOG(ERR, "failed to open directory %s: %s",
414 : : path, strerror(errno));
415 : 0 : return -1;
416 : : }
417 : :
418 [ # # ]: 0 : while ((dent = readdir(d)) != NULL) {
419 : : struct stat sb;
420 : 0 : int nlen = strnlen(dent->d_name, sizeof(dent->d_name));
421 : :
422 : : /* check if name ends in .so or .so.ABI_VERSION */
423 [ # # ]: 0 : if (strcmp(&dent->d_name[nlen - 3], ".so") != 0 &&
424 [ # # ]: 0 : strcmp(&dent->d_name[nlen - 4 - strlen(ABI_VERSION)],
425 : : ".so."ABI_VERSION) != 0)
426 : 0 : continue;
427 : :
428 : : snprintf(sopath, sizeof(sopath), "%s/%s", path, dent->d_name);
429 : :
430 : : /* if a regular file, add to list to load */
431 [ # # # # ]: 0 : if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
432 : 0 : continue;
433 : :
434 [ # # ]: 0 : if (eal_plugin_add(sopath) == -1)
435 : : break;
436 : : }
437 : :
438 : 0 : closedir(d);
439 : : /* XXX this ignores failures from readdir() itself */
440 [ # # ]: 0 : return (dent == NULL) ? 0 : -1;
441 : : }
442 : :
443 : : static int
444 : 0 : verify_perms(const char *dirpath)
445 : : {
446 : : struct stat st;
447 : :
448 : : /* if not root, check down one level first */
449 [ # # ]: 0 : if (strcmp(dirpath, "/") != 0) {
450 : : static __thread char last_dir_checked[PATH_MAX];
451 : : char copy[PATH_MAX];
452 : : const char *dir;
453 : :
454 : : strlcpy(copy, dirpath, PATH_MAX);
455 : 0 : dir = dirname(copy);
456 [ # # ]: 0 : if (strncmp(dir, last_dir_checked, PATH_MAX) != 0) {
457 [ # # ]: 0 : if (verify_perms(dir) != 0)
458 : 0 : return -1;
459 : : strlcpy(last_dir_checked, dir, PATH_MAX);
460 : : }
461 : : }
462 : :
463 : : /* call stat to check for permissions and ensure not world writable */
464 [ # # ]: 0 : if (stat(dirpath, &st) != 0) {
465 : 0 : EAL_LOG(ERR, "Error with stat on %s, %s",
466 : : dirpath, strerror(errno));
467 : 0 : return -1;
468 : : }
469 [ # # ]: 0 : if (st.st_mode & S_IWOTH) {
470 : 0 : EAL_LOG(ERR,
471 : : "Error, directory path %s is world-writable and insecure",
472 : : dirpath);
473 : 0 : return -1;
474 : : }
475 : :
476 : : return 0;
477 : : }
478 : :
479 : : static void *
480 [ # # ]: 0 : eal_dlopen(const char *pathname)
481 : : {
482 : : void *retval = NULL;
483 : : char *realp = realpath(pathname, NULL);
484 : :
485 [ # # # # ]: 0 : if (realp == NULL && errno == ENOENT) {
486 : : /* not a full or relative path, try a load from system dirs */
487 : 0 : retval = dlopen(pathname, RTLD_NOW);
488 [ # # ]: 0 : if (retval == NULL)
489 : 0 : EAL_LOG(ERR, "%s", dlerror());
490 : 0 : return retval;
491 : : }
492 [ # # ]: 0 : if (realp == NULL) {
493 : 0 : EAL_LOG(ERR, "Error with realpath for %s, %s",
494 : : pathname, strerror(errno));
495 : 0 : goto out;
496 : : }
497 [ # # ]: 0 : if (strnlen(realp, PATH_MAX) == PATH_MAX) {
498 : 0 : EAL_LOG(ERR, "Error, driver path greater than PATH_MAX");
499 : 0 : goto out;
500 : : }
501 : :
502 : : /* do permissions checks */
503 [ # # ]: 0 : if (verify_perms(realp) != 0)
504 : 0 : goto out;
505 : :
506 : 0 : retval = dlopen(realp, RTLD_NOW);
507 [ # # ]: 0 : if (retval == NULL)
508 : 0 : EAL_LOG(ERR, "%s", dlerror());
509 : 0 : out:
510 : 0 : free(realp);
511 : 0 : return retval;
512 : : }
513 : :
514 : : static int
515 [ - + ]: 186 : is_shared_build(void)
516 : : {
517 : : #define EAL_SO "librte_eal.so"
518 : : char soname[32];
519 : : size_t len, minlen = strlen(EAL_SO);
520 : :
521 : : len = strlcpy(soname, EAL_SO"."ABI_VERSION, sizeof(soname));
522 [ - + ]: 186 : if (len > sizeof(soname)) {
523 : 0 : EAL_LOG(ERR, "Shared lib name too long in shared build check");
524 : : len = sizeof(soname) - 1;
525 : : }
526 : :
527 [ + + ]: 744 : while (len >= minlen) {
528 : : void *handle;
529 : :
530 : : /* check if we have this .so loaded, if so - shared build */
531 : 558 : EAL_LOG(DEBUG, "Checking presence of .so '%s'", soname);
532 : 558 : handle = dlopen(soname, RTLD_LAZY | RTLD_NOLOAD);
533 [ - + ]: 558 : if (handle != NULL) {
534 : 0 : EAL_LOG(INFO, "Detected shared linkage of DPDK");
535 : 0 : dlclose(handle);
536 : 0 : return 1;
537 : : }
538 : :
539 : : /* remove any version numbers off the end to retry */
540 [ + - ]: 1488 : while (len-- > 0)
541 [ + + ]: 1488 : if (soname[len] == '.') {
542 : 558 : soname[len] = '\0';
543 : 558 : break;
544 : : }
545 : : }
546 : :
547 : 186 : EAL_LOG(INFO, "Detected static linkage of DPDK");
548 : 186 : return 0;
549 : : }
550 : :
551 : : int
552 : 186 : eal_plugins_init(void)
553 : : {
554 : : struct shared_driver *solib = NULL;
555 : : struct stat sb;
556 : :
557 : : /* If we are not statically linked, add default driver loading
558 : : * path if it exists as a directory.
559 : : * (Using dlopen with NOLOAD flag on EAL, will return NULL if the EAL
560 : : * shared library is not already loaded i.e. it's statically linked.)
561 : : */
562 [ - + ]: 186 : if (is_shared_build() &&
563 [ # # # # ]: 0 : *default_solib_dir != '\0' &&
564 : 0 : stat(default_solib_dir, &sb) == 0 &&
565 [ # # ]: 0 : S_ISDIR(sb.st_mode))
566 : 0 : eal_plugin_add(default_solib_dir);
567 : :
568 [ - + ]: 186 : TAILQ_FOREACH(solib, &solib_list, next) {
569 : :
570 [ # # # # ]: 0 : if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
571 [ # # ]: 0 : if (eal_plugindir_init(solib->name) == -1) {
572 : 0 : EAL_LOG(ERR,
573 : : "Cannot init plugin directory %s",
574 : : solib->name);
575 : 0 : return -1;
576 : : }
577 : : } else {
578 : 0 : EAL_LOG(DEBUG, "open shared lib %s",
579 : : solib->name);
580 : 0 : solib->lib_handle = eal_dlopen(solib->name);
581 [ # # ]: 0 : if (solib->lib_handle == NULL)
582 : : return -1;
583 : : }
584 : :
585 : : }
586 : : return 0;
587 : : }
588 : : #endif
589 : :
590 : : /*
591 : : * Parse the coremask given as argument (hexadecimal string) and fill
592 : : * the global configuration (core role and core count) with the parsed
593 : : * value.
594 : : */
595 : 12 : static int xdigit2val(unsigned char c)
596 : : {
597 : : int val;
598 : :
599 [ + - ]: 12 : if (isdigit(c))
600 : 12 : val = c - '0';
601 [ # # ]: 0 : else if (isupper(c))
602 : 0 : val = c - 'A' + 10;
603 : : else
604 : 0 : val = c - 'a' + 10;
605 : 12 : return val;
606 : : }
607 : :
608 : : static int
609 : 0 : eal_parse_service_coremask(const char *coremask)
610 : : {
611 : 0 : struct rte_config *cfg = rte_eal_get_configuration();
612 : : int i, j, idx = 0;
613 : : unsigned int count = 0;
614 : : char c;
615 : : int val;
616 : : uint32_t taken_lcore_count = 0;
617 : :
618 [ # # ]: 0 : if (coremask == NULL)
619 : : return -1;
620 : : /* Remove all blank characters ahead and after .
621 : : * Remove 0x/0X if exists.
622 : : */
623 [ # # ]: 0 : while (isblank(*coremask))
624 : 0 : coremask++;
625 [ # # ]: 0 : if (coremask[0] == '0' && ((coremask[1] == 'x')
626 [ # # ]: 0 : || (coremask[1] == 'X')))
627 : 0 : coremask += 2;
628 : 0 : i = strlen(coremask);
629 [ # # # # ]: 0 : while ((i > 0) && isblank(coremask[i - 1]))
630 : 0 : i--;
631 : :
632 [ # # ]: 0 : if (i == 0)
633 : : return -1;
634 : :
635 [ # # ]: 0 : for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
636 : 0 : c = coremask[i];
637 [ # # ]: 0 : if (isxdigit(c) == 0) {
638 : : /* invalid characters */
639 : : return -1;
640 : : }
641 : 0 : val = xdigit2val(c);
642 [ # # ]: 0 : for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
643 : 0 : j++, idx++) {
644 [ # # ]: 0 : if ((1 << j) & val) {
645 : : /* handle main lcore already parsed */
646 : 0 : uint32_t lcore = idx;
647 [ # # ]: 0 : if (main_lcore_parsed &&
648 [ # # ]: 0 : cfg->main_lcore == lcore) {
649 : 0 : EAL_LOG(ERR,
650 : : "lcore %u is main lcore, cannot use as service core",
651 : : idx);
652 : 0 : return -1;
653 : : }
654 : :
655 [ # # ]: 0 : if (eal_cpu_detected(idx) == 0) {
656 : 0 : EAL_LOG(ERR,
657 : : "lcore %u unavailable", idx);
658 : 0 : return -1;
659 : : }
660 : :
661 [ # # ]: 0 : if (cfg->lcore_role[idx] == ROLE_RTE)
662 : 0 : taken_lcore_count++;
663 : :
664 : 0 : lcore_config[idx].core_role = ROLE_SERVICE;
665 : 0 : count++;
666 : : }
667 : : }
668 : : }
669 : :
670 [ # # ]: 0 : for (; i >= 0; i--)
671 [ # # ]: 0 : if (coremask[i] != '0')
672 : : return -1;
673 : :
674 [ # # ]: 0 : for (; idx < RTE_MAX_LCORE; idx++)
675 : 0 : lcore_config[idx].core_index = -1;
676 : :
677 [ # # ]: 0 : if (count == 0)
678 : : return -1;
679 : :
680 [ # # # # ]: 0 : if (core_parsed && taken_lcore_count != count) {
681 : 0 : EAL_LOG(WARNING,
682 : : "Not all service cores are in the coremask. "
683 : : "Please ensure -c or -l includes service cores");
684 : : }
685 : :
686 : 0 : cfg->service_lcore_count = count;
687 : 0 : return 0;
688 : : }
689 : :
690 : : static int
691 : : eal_service_cores_parsed(void)
692 : : {
693 : : int idx;
694 [ + + + + ]: 2838 : for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
695 [ + - + - ]: 2816 : if (lcore_config[idx].core_role == ROLE_SERVICE)
696 : : return 1;
697 : : }
698 : : return 0;
699 : : }
700 : :
701 : : static int
702 : 12 : update_lcore_config(int *cores)
703 : : {
704 : 12 : struct rte_config *cfg = rte_eal_get_configuration();
705 : : unsigned int count = 0;
706 : : unsigned int i;
707 : : int ret = 0;
708 : :
709 [ + + ]: 1548 : for (i = 0; i < RTE_MAX_LCORE; i++) {
710 [ + + ]: 1536 : if (cores[i] != -1) {
711 [ - + ]: 18 : if (eal_cpu_detected(i) == 0) {
712 : 0 : EAL_LOG(ERR, "lcore %u unavailable", i);
713 : : ret = -1;
714 : 0 : continue;
715 : : }
716 : 18 : cfg->lcore_role[i] = ROLE_RTE;
717 : 18 : count++;
718 : : } else {
719 : 1518 : cfg->lcore_role[i] = ROLE_OFF;
720 : : }
721 : 1536 : lcore_config[i].core_index = cores[i];
722 : : }
723 [ + - ]: 12 : if (!ret)
724 : 12 : cfg->lcore_count = count;
725 : 12 : return ret;
726 : : }
727 : :
728 : : static int
729 : 14 : check_core_list(int *lcores, unsigned int count)
730 : : {
731 : : char lcorestr[RTE_MAX_LCORE * 10];
732 : : bool overflow = false;
733 : : int len = 0, ret;
734 : : unsigned int i;
735 : :
736 [ + + ]: 161 : for (i = 0; i < count; i++) {
737 [ + + ]: 147 : if (lcores[i] < RTE_MAX_LCORE)
738 : 145 : continue;
739 : :
740 : 2 : EAL_LOG(ERR, "lcore %d >= RTE_MAX_LCORE (%d)",
741 : : lcores[i], RTE_MAX_LCORE);
742 : : overflow = true;
743 : : }
744 [ + + ]: 14 : if (!overflow)
745 : : return 0;
746 : :
747 : : /*
748 : : * We've encountered a core that's greater than RTE_MAX_LCORE,
749 : : * suggest using --lcores option to map lcores onto physical cores
750 : : * greater than RTE_MAX_LCORE.
751 : : */
752 [ + + ]: 131 : for (i = 0; i < count; i++) {
753 : 129 : ret = snprintf(&lcorestr[len], sizeof(lcorestr) - len,
754 [ + - ]: 129 : "%d@%d,", i, lcores[i]);
755 [ + - ]: 129 : if (ret > 0)
756 : 129 : len = len + ret;
757 : : }
758 [ + - ]: 2 : if (len > 0)
759 : 2 : lcorestr[len - 1] = 0;
760 : 2 : EAL_LOG(ERR, "To use high physical core ids, "
761 : : "please use --lcores to map them to lcore ids below RTE_MAX_LCORE, "
762 : : "e.g. --lcores %s", lcorestr);
763 : 2 : return -1;
764 : : }
765 : :
766 : : int
767 : 13 : rte_eal_parse_coremask(const char *coremask, int *cores)
768 : : {
769 : : const char *coremask_orig = coremask;
770 : : int lcores[RTE_MAX_LCORE];
771 : : unsigned int count = 0;
772 : : int i, j, idx;
773 : : int val;
774 : : char c;
775 : :
776 [ + + ]: 1677 : for (idx = 0; idx < RTE_MAX_LCORE; idx++)
777 : 1664 : cores[idx] = -1;
778 : : idx = 0;
779 : :
780 : : /* Remove all blank characters ahead and after .
781 : : * Remove 0x/0X if exists.
782 : : */
783 [ - + ]: 13 : while (isblank(*coremask))
784 : 0 : coremask++;
785 [ - + ]: 13 : if (coremask[0] == '0' && ((coremask[1] == 'x')
786 [ # # ]: 0 : || (coremask[1] == 'X')))
787 : 0 : coremask += 2;
788 : 13 : i = strlen(coremask);
789 [ + - - + ]: 13 : while ((i > 0) && isblank(coremask[i - 1]))
790 : 0 : i--;
791 [ - + ]: 13 : if (i == 0) {
792 : 0 : EAL_LOG(ERR, "No lcores in coremask: [%s]",
793 : : coremask_orig);
794 : 0 : return -1;
795 : : }
796 : :
797 [ + + ]: 25 : for (i = i - 1; i >= 0; i--) {
798 : 13 : c = coremask[i];
799 [ + + ]: 13 : if (isxdigit(c) == 0) {
800 : : /* invalid characters */
801 : 1 : EAL_LOG(ERR, "invalid characters in coremask: [%s]",
802 : : coremask_orig);
803 : 1 : return -1;
804 : : }
805 : 12 : val = xdigit2val(c);
806 [ + + ]: 60 : for (j = 0; j < BITS_PER_HEX; j++, idx++)
807 : : {
808 [ + + ]: 48 : if ((1 << j) & val) {
809 [ - + ]: 18 : if (count >= RTE_MAX_LCORE) {
810 : 0 : EAL_LOG(ERR, "Too many lcores provided. Cannot exceed RTE_MAX_LCORE (%d)",
811 : : RTE_MAX_LCORE);
812 : 0 : return -1;
813 : : }
814 : 18 : lcores[count++] = idx;
815 : : }
816 : : }
817 : : }
818 [ - + ]: 12 : if (count == 0) {
819 : 0 : EAL_LOG(ERR, "No lcores in coremask: [%s]",
820 : : coremask_orig);
821 : 0 : return -1;
822 : : }
823 : :
824 [ + - ]: 12 : if (check_core_list(lcores, count))
825 : : return -1;
826 : :
827 : : /*
828 : : * Now that we've got a list of cores no longer than RTE_MAX_LCORE,
829 : : * and no lcore in that list is greater than RTE_MAX_LCORE, populate
830 : : * the cores array.
831 : : */
832 : : do {
833 : 18 : count--;
834 : 18 : cores[lcores[count]] = count;
835 [ + + ]: 18 : } while (count != 0);
836 : :
837 : : return 0;
838 : : }
839 : :
840 : : static int
841 : 0 : eal_parse_service_corelist(const char *corelist)
842 : : {
843 : 0 : struct rte_config *cfg = rte_eal_get_configuration();
844 : : int i;
845 : : unsigned count = 0;
846 : 0 : char *end = NULL;
847 : : uint32_t min, max, idx;
848 : : uint32_t taken_lcore_count = 0;
849 : :
850 [ # # ]: 0 : if (corelist == NULL)
851 : : return -1;
852 : :
853 : : /* Remove all blank characters ahead and after */
854 [ # # ]: 0 : while (isblank(*corelist))
855 : 0 : corelist++;
856 : : i = strlen(corelist);
857 : : while ((i > 0) && isblank(corelist[i - 1]))
858 : : i--;
859 : :
860 : : /* Get list of cores */
861 : : min = RTE_MAX_LCORE;
862 : : do {
863 [ # # ]: 0 : while (isblank(*corelist))
864 : 0 : corelist++;
865 [ # # ]: 0 : if (*corelist == '\0')
866 : : return -1;
867 : 0 : errno = 0;
868 : 0 : idx = strtoul(corelist, &end, 10);
869 [ # # # # ]: 0 : if (errno || end == NULL)
870 : : return -1;
871 [ # # ]: 0 : if (idx >= RTE_MAX_LCORE)
872 : : return -1;
873 [ # # ]: 0 : while (isblank(*end))
874 : 0 : end++;
875 [ # # ]: 0 : if (*end == '-') {
876 : : min = idx;
877 [ # # ]: 0 : } else if ((*end == ',') || (*end == '\0')) {
878 : : max = idx;
879 [ # # ]: 0 : if (min == RTE_MAX_LCORE)
880 : : min = idx;
881 [ # # ]: 0 : for (idx = min; idx <= max; idx++) {
882 [ # # ]: 0 : if (cfg->lcore_role[idx] != ROLE_SERVICE) {
883 : : /* handle main lcore already parsed */
884 : : uint32_t lcore = idx;
885 [ # # # # ]: 0 : if (cfg->main_lcore == lcore &&
886 : : main_lcore_parsed) {
887 : 0 : EAL_LOG(ERR,
888 : : "Error: lcore %u is main lcore, cannot use as service core",
889 : : idx);
890 : 0 : return -1;
891 : : }
892 [ # # ]: 0 : if (cfg->lcore_role[idx] == ROLE_RTE)
893 : 0 : taken_lcore_count++;
894 : :
895 : 0 : lcore_config[idx].core_role =
896 : : ROLE_SERVICE;
897 : 0 : count++;
898 : : }
899 : : }
900 : : min = RTE_MAX_LCORE;
901 : : } else
902 : : return -1;
903 : 0 : corelist = end + 1;
904 [ # # ]: 0 : } while (*end != '\0');
905 : :
906 [ # # ]: 0 : if (count == 0)
907 : : return -1;
908 : :
909 [ # # # # ]: 0 : if (core_parsed && taken_lcore_count != count) {
910 : 0 : EAL_LOG(WARNING,
911 : : "Not all service cores were in the coremask. "
912 : : "Please ensure -c or -l includes service cores");
913 : : }
914 : :
915 : : return 0;
916 : : }
917 : :
918 : : static int
919 : 9 : eal_parse_corelist(const char *corelist, int *cores)
920 : : {
921 : : unsigned int count = 0, i;
922 : : int lcores[RTE_MAX_LCORE];
923 : 9 : char *end = NULL;
924 : : int min, max;
925 : : int idx;
926 : :
927 [ + + ]: 1161 : for (idx = 0; idx < RTE_MAX_LCORE; idx++)
928 : 1152 : cores[idx] = -1;
929 : :
930 : : /* Remove all blank characters ahead */
931 [ + + ]: 10 : while (isblank(*corelist))
932 : 1 : corelist++;
933 : :
934 : : /* Get list of cores */
935 : : min = -1;
936 : : do {
937 [ - + ]: 12 : while (isblank(*corelist))
938 : 0 : corelist++;
939 [ + + ]: 12 : if (*corelist == '\0')
940 : : return -1;
941 : 9 : errno = 0;
942 : 9 : idx = strtol(corelist, &end, 10);
943 [ + - + - ]: 9 : if (errno || end == NULL)
944 : : return -1;
945 [ + + ]: 9 : if (idx < 0)
946 : : return -1;
947 [ - + ]: 7 : while (isblank(*end))
948 : 0 : end++;
949 [ + + ]: 7 : if (*end == '-') {
950 : : min = idx;
951 [ + + ]: 5 : } else if ((*end == ',') || (*end == '\0')) {
952 : : max = idx;
953 [ + + ]: 3 : if (min == -1)
954 : : min = idx;
955 [ + + ]: 133 : for (idx = min; idx <= max; idx++) {
956 : : bool dup = false;
957 : :
958 : : /* Check if this idx is already present */
959 [ + + ]: 8258 : for (i = 0; i < count; i++) {
960 [ - + ]: 8128 : if (lcores[i] == idx)
961 : : dup = true;
962 : : }
963 [ - + ]: 130 : if (dup)
964 : 0 : continue;
965 [ - + ]: 130 : if (count >= RTE_MAX_LCORE) {
966 : 0 : EAL_LOG(ERR, "Too many lcores provided. Cannot exceed RTE_MAX_LCORE (%d)",
967 : : RTE_MAX_LCORE);
968 : 0 : return -1;
969 : : }
970 : 130 : lcores[count++] = idx;
971 : : }
972 : : min = -1;
973 : : } else
974 : : return -1;
975 : 5 : corelist = end + 1;
976 [ + + ]: 5 : } while (*end != '\0');
977 : :
978 [ + - ]: 2 : if (count == 0)
979 : : return -1;
980 : :
981 [ - + ]: 2 : if (check_core_list(lcores, count))
982 : : return -1;
983 : :
984 : : /*
985 : : * Now that we've got a list of cores no longer than RTE_MAX_LCORE,
986 : : * and no lcore in that list is greater than RTE_MAX_LCORE, populate
987 : : * the cores array.
988 : : */
989 : : do {
990 : 0 : count--;
991 : 0 : cores[lcores[count]] = count;
992 [ # # ]: 0 : } while (count != 0);
993 : :
994 : : return 0;
995 : : }
996 : :
997 : : /* Changes the lcore id of the main thread */
998 : : static int
999 : 5 : eal_parse_main_lcore(const char *arg)
1000 : : {
1001 : : char *parsing_end;
1002 : 5 : struct rte_config *cfg = rte_eal_get_configuration();
1003 : :
1004 : 5 : errno = 0;
1005 : 5 : cfg->main_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
1006 [ + - + + ]: 5 : if (errno || parsing_end[0] != 0)
1007 : : return -1;
1008 [ + + ]: 4 : if (cfg->main_lcore >= RTE_MAX_LCORE)
1009 : : return -1;
1010 : 3 : main_lcore_parsed = 1;
1011 : :
1012 : : /* ensure main core is not used as service core */
1013 [ - + ]: 3 : if (lcore_config[cfg->main_lcore].core_role == ROLE_SERVICE) {
1014 : 0 : EAL_LOG(ERR,
1015 : : "Error: Main lcore is used as a service core");
1016 : 0 : return -1;
1017 : : }
1018 : :
1019 : : return 0;
1020 : : }
1021 : :
1022 : : /*
1023 : : * Parse elem, the elem could be single number/range or '(' ')' group
1024 : : * 1) A single number elem, it's just a simple digit. e.g. 9
1025 : : * 2) A single range elem, two digits with a '-' between. e.g. 2-6
1026 : : * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
1027 : : * Within group elem, '-' used for a range separator;
1028 : : * ',' used for a single number.
1029 : : */
1030 : : static int
1031 : 16 : eal_parse_set(const char *input, rte_cpuset_t *set)
1032 : : {
1033 : : unsigned idx;
1034 : : const char *str = input;
1035 : 16 : char *end = NULL;
1036 : : unsigned min, max;
1037 : :
1038 : 16 : CPU_ZERO(set);
1039 : :
1040 [ - + ]: 16 : while (isblank(*str))
1041 : 0 : str++;
1042 : :
1043 : : /* only digit or left bracket is qualify for start point */
1044 [ + + + + : 16 : if ((!isdigit(*str) && *str != '(') || *str == '\0')
+ - ]
1045 : : return -1;
1046 : :
1047 : : /* process single number or single range of number */
1048 [ + + ]: 14 : if (*str != '(') {
1049 : 6 : errno = 0;
1050 : 6 : idx = strtoul(str, &end, 10);
1051 [ + - + - : 6 : if (errno || end == NULL || idx >= CPU_SETSIZE)
+ + ]
1052 : : return -1;
1053 : : else {
1054 [ - + ]: 5 : while (isblank(*end))
1055 : 0 : end++;
1056 : :
1057 : : min = idx;
1058 : : max = idx;
1059 [ + + ]: 5 : if (*end == '-') {
1060 : : /* process single <number>-<number> */
1061 : 4 : end++;
1062 [ - + ]: 4 : while (isblank(*end))
1063 : 0 : end++;
1064 [ + + ]: 4 : if (!isdigit(*end))
1065 : : return -1;
1066 : :
1067 : 3 : errno = 0;
1068 : 3 : idx = strtoul(end, &end, 10);
1069 [ + - + - : 3 : if (errno || end == NULL || idx >= CPU_SETSIZE)
+ - ]
1070 : : return -1;
1071 : : max = idx;
1072 [ - + ]: 3 : while (isblank(*end))
1073 : 0 : end++;
1074 [ + + ]: 3 : if (*end != ',' && *end != '\0')
1075 : : return -1;
1076 : : }
1077 : :
1078 [ + + - + ]: 2 : if (*end != ',' && *end != '\0' &&
1079 : : *end != '@')
1080 : : return -1;
1081 : :
1082 : 1 : for (idx = RTE_MIN(min, max);
1083 [ + + ]: 3 : idx <= RTE_MAX(min, max); idx++)
1084 [ + - ]: 2 : CPU_SET(idx, set);
1085 : :
1086 : 1 : return end - input;
1087 : : }
1088 : : }
1089 : :
1090 : : /* process set within bracket */
1091 : 8 : str++;
1092 [ - + ]: 8 : while (isblank(*str))
1093 : 0 : str++;
1094 [ + - ]: 8 : if (*str == '\0')
1095 : : return -1;
1096 : :
1097 : : min = RTE_MAX_LCORE;
1098 : : do {
1099 : :
1100 : : /* go ahead to the first digit */
1101 [ - + ]: 13 : while (isblank(*str))
1102 : 0 : str++;
1103 [ + + ]: 13 : if (!isdigit(*str))
1104 : : return -1;
1105 : :
1106 : : /* get the digit value */
1107 : 9 : errno = 0;
1108 : 9 : idx = strtoul(str, &end, 10);
1109 [ + - + - : 9 : if (errno || end == NULL || idx >= CPU_SETSIZE)
+ - ]
1110 : : return -1;
1111 : :
1112 : : /* go ahead to separator '-',',' and ')' */
1113 [ - + ]: 9 : while (isblank(*end))
1114 : 0 : end++;
1115 [ + + ]: 9 : if (*end == '-') {
1116 [ + + ]: 4 : if (min == RTE_MAX_LCORE)
1117 : : min = idx;
1118 : : else /* avoid continuous '-' */
1119 : : return -1;
1120 [ + - ]: 5 : } else if ((*end == ',') || (*end == ')')) {
1121 : : max = idx;
1122 [ + + ]: 5 : if (min == RTE_MAX_LCORE)
1123 : : min = idx;
1124 : 5 : for (idx = RTE_MIN(min, max);
1125 [ + + ]: 13 : idx <= RTE_MAX(min, max); idx++)
1126 [ + - ]: 8 : CPU_SET(idx, set);
1127 : :
1128 : : min = RTE_MAX_LCORE;
1129 : : } else
1130 : : return -1;
1131 : :
1132 : 8 : str = end + 1;
1133 [ + + ]: 8 : } while (*end != '\0' && *end != ')');
1134 : :
1135 : : /*
1136 : : * to avoid failure that tail blank makes end character check fail
1137 : : * in eal_parse_lcores( )
1138 : : */
1139 [ - + ]: 3 : while (isblank(*str))
1140 : 0 : str++;
1141 : :
1142 : 3 : return str - input;
1143 : : }
1144 : :
1145 : : static int
1146 : 6 : check_cpuset(rte_cpuset_t *set)
1147 : : {
1148 : : unsigned int idx;
1149 : :
1150 [ + + ]: 6150 : for (idx = 0; idx < CPU_SETSIZE; idx++) {
1151 [ + + ]: 6144 : if (!CPU_ISSET(idx, set))
1152 : 6126 : continue;
1153 : :
1154 [ - + ]: 18 : if (eal_cpu_detected(idx) == 0) {
1155 : 0 : EAL_LOG(ERR, "core %u "
1156 : : "unavailable", idx);
1157 : 0 : return -1;
1158 : : }
1159 : : }
1160 : : return 0;
1161 : : }
1162 : :
1163 : : /*
1164 : : * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
1165 : : * lcores, cpus could be a single digit/range or a group.
1166 : : * '(' and ')' are necessary if it's a group.
1167 : : * If not supply '@cpus', the value of cpus uses the same as lcores.
1168 : : * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
1169 : : * lcore 0 runs on cpuset 0x41 (cpu 0,6)
1170 : : * lcore 1 runs on cpuset 0x2 (cpu 1)
1171 : : * lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
1172 : : * lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
1173 : : * lcore 6 runs on cpuset 0x41 (cpu 0,6)
1174 : : * lcore 7 runs on cpuset 0x80 (cpu 7)
1175 : : * lcore 8 runs on cpuset 0x100 (cpu 8)
1176 : : */
1177 : : static int
1178 : 13 : eal_parse_lcores(const char *lcores)
1179 : : {
1180 : 13 : struct rte_config *cfg = rte_eal_get_configuration();
1181 : : rte_cpuset_t lcore_set;
1182 : : unsigned int set_count;
1183 : : unsigned idx = 0;
1184 : : unsigned count = 0;
1185 : : const char *lcore_start = NULL;
1186 : : const char *end = NULL;
1187 : : int offset;
1188 : : rte_cpuset_t cpuset;
1189 : : int lflags;
1190 : : int ret = -1;
1191 : :
1192 [ + - ]: 13 : if (lcores == NULL)
1193 : : return -1;
1194 : :
1195 : : /* Remove all blank characters ahead and after */
1196 [ + + ]: 14 : while (isblank(*lcores))
1197 : 1 : lcores++;
1198 : :
1199 : 13 : CPU_ZERO(&cpuset);
1200 : :
1201 : : /* Reset lcore config */
1202 [ + + ]: 1677 : for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1203 : 1664 : cfg->lcore_role[idx] = ROLE_OFF;
1204 : 1664 : lcore_config[idx].core_index = -1;
1205 : 1664 : CPU_ZERO(&lcore_config[idx].cpuset);
1206 : : }
1207 : :
1208 : : /* Get list of cores */
1209 : : do {
1210 [ - + ]: 15 : while (isblank(*lcores))
1211 : 0 : lcores++;
1212 [ + + ]: 15 : if (*lcores == '\0')
1213 : 1 : goto err;
1214 : :
1215 : : lflags = 0;
1216 : :
1217 : : /* record lcore_set start point */
1218 : : lcore_start = lcores;
1219 : :
1220 : : /* go across a complete bracket */
1221 [ + + ]: 14 : if (*lcore_start == '(') {
1222 : 5 : lcores += strcspn(lcores, ")");
1223 [ - + ]: 5 : if (*lcores++ == '\0')
1224 : 0 : goto err;
1225 : : }
1226 : :
1227 : : /* scan the separator '@', ','(next) or '\0'(finish) */
1228 : 14 : lcores += strcspn(lcores, "@,");
1229 : :
1230 [ + + ]: 14 : if (*lcores == '@') {
1231 : : /* explicit assign cpuset and update the end cursor */
1232 : 5 : offset = eal_parse_set(lcores + 1, &cpuset);
1233 [ + + ]: 5 : if (offset < 0)
1234 : 3 : goto err;
1235 : 2 : end = lcores + 1 + offset;
1236 : : } else { /* ',' or '\0' */
1237 : : /* haven't given cpuset, current loop done */
1238 : : end = lcores;
1239 : :
1240 : : /* go back to check <number>-<number> */
1241 : 9 : offset = strcspn(lcore_start, "(-");
1242 [ + + ]: 9 : if (offset < (end - lcore_start) &&
1243 [ + + ]: 7 : *(lcore_start + offset) != '(')
1244 : : lflags = 1;
1245 : : }
1246 : :
1247 [ - + ]: 11 : if (*end != ',' && *end != '\0')
1248 : 0 : goto err;
1249 : :
1250 : : /* parse lcore_set from start point */
1251 [ + + ]: 11 : if (eal_parse_set(lcore_start, &lcore_set) < 0)
1252 : 9 : goto err;
1253 : :
1254 : : /* without '@', by default using lcore_set as cpuset */
1255 [ + - ]: 2 : if (*lcores != '@')
1256 : : rte_memcpy(&cpuset, &lcore_set, sizeof(cpuset));
1257 : :
1258 : 2 : set_count = CPU_COUNT(&lcore_set);
1259 : : /* start to update lcore_set */
1260 [ + + ]: 258 : for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1261 [ + + ]: 256 : if (!CPU_ISSET(idx, &lcore_set))
1262 : 250 : continue;
1263 : 6 : set_count--;
1264 : :
1265 [ + - ]: 6 : if (cfg->lcore_role[idx] != ROLE_RTE) {
1266 : 6 : lcore_config[idx].core_index = count;
1267 : 6 : cfg->lcore_role[idx] = ROLE_RTE;
1268 : 6 : count++;
1269 : : }
1270 : :
1271 [ + + ]: 6 : if (lflags) {
1272 : 2 : CPU_ZERO(&cpuset);
1273 : 2 : CPU_SET(idx, &cpuset);
1274 : : }
1275 : :
1276 [ - + ]: 6 : if (check_cpuset(&cpuset) < 0)
1277 : 0 : goto err;
1278 [ - + ]: 6 : rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
1279 : : sizeof(rte_cpuset_t));
1280 : : }
1281 : :
1282 : : /* some cores from the lcore_set can't be handled by EAL */
1283 [ - + ]: 2 : if (set_count != 0)
1284 : 0 : goto err;
1285 : :
1286 : 2 : lcores = end + 1;
1287 [ + - ]: 2 : } while (*end != '\0');
1288 : :
1289 [ # # ]: 0 : if (count == 0)
1290 : 0 : goto err;
1291 : :
1292 : 0 : cfg->lcore_count = count;
1293 : : ret = 0;
1294 : :
1295 : : err:
1296 : :
1297 : : return ret;
1298 : : }
1299 : :
1300 : : #ifndef RTE_EXEC_ENV_WINDOWS
1301 : : static int
1302 : 2 : eal_parse_syslog(const char *facility, struct internal_config *conf)
1303 : : {
1304 : : int i;
1305 : : static const struct {
1306 : : const char *name;
1307 : : int value;
1308 : : } map[] = {
1309 : : { "auth", LOG_AUTH },
1310 : : { "cron", LOG_CRON },
1311 : : { "daemon", LOG_DAEMON },
1312 : : { "ftp", LOG_FTP },
1313 : : { "kern", LOG_KERN },
1314 : : { "lpr", LOG_LPR },
1315 : : { "mail", LOG_MAIL },
1316 : : { "news", LOG_NEWS },
1317 : : { "syslog", LOG_SYSLOG },
1318 : : { "user", LOG_USER },
1319 : : { "uucp", LOG_UUCP },
1320 : : { "local0", LOG_LOCAL0 },
1321 : : { "local1", LOG_LOCAL1 },
1322 : : { "local2", LOG_LOCAL2 },
1323 : : { "local3", LOG_LOCAL3 },
1324 : : { "local4", LOG_LOCAL4 },
1325 : : { "local5", LOG_LOCAL5 },
1326 : : { "local6", LOG_LOCAL6 },
1327 : : { "local7", LOG_LOCAL7 },
1328 : : { NULL, 0 }
1329 : : };
1330 : :
1331 [ + + ]: 29 : for (i = 0; map[i].name; i++) {
1332 [ + + ]: 28 : if (!strcmp(facility, map[i].name)) {
1333 : 1 : conf->syslog_facility = map[i].value;
1334 : 1 : return 0;
1335 : : }
1336 : : }
1337 : : return -1;
1338 : : }
1339 : : #endif
1340 : :
1341 : : static void
1342 : 0 : eal_log_usage(void)
1343 : : {
1344 : : unsigned int level;
1345 : :
1346 : : printf("Log type is a pattern matching items of this list"
1347 : : " (plugins may be missing):\n");
1348 : 0 : rte_log_list_types(stdout, "\t");
1349 : : printf("\n");
1350 : : printf("Syntax using globbing pattern: ");
1351 : : printf("--"OPT_LOG_LEVEL" pattern:level\n");
1352 : : printf("Syntax using regular expression: ");
1353 : : printf("--"OPT_LOG_LEVEL" regexp,level\n");
1354 : : printf("Syntax for the global level: ");
1355 : : printf("--"OPT_LOG_LEVEL" level\n");
1356 : : printf("Logs are emitted if allowed by both global and specific levels.\n");
1357 : : printf("\n");
1358 : : printf("Log level can be a number or the first letters of its name:\n");
1359 [ # # ]: 0 : for (level = 1; level <= RTE_LOG_MAX; level++)
1360 : 0 : printf("\t%d %s\n", level, eal_log_level2str(level));
1361 : 0 : }
1362 : :
1363 : : static int
1364 : 0 : eal_parse_log_priority(const char *level)
1365 : : {
1366 : 0 : size_t len = strlen(level);
1367 : : unsigned long tmp;
1368 : : char *end;
1369 : : unsigned int i;
1370 : :
1371 [ # # ]: 0 : if (len == 0)
1372 : : return -1;
1373 : :
1374 : : /* look for named values, skip 0 which is not a valid level */
1375 [ # # ]: 0 : for (i = 1; i <= RTE_LOG_MAX; i++) {
1376 [ # # ]: 0 : if (strncmp(eal_log_level2str(i), level, len) == 0)
1377 : 0 : return i;
1378 : : }
1379 : :
1380 : : /* not a string, maybe it is numeric */
1381 : 0 : errno = 0;
1382 : 0 : tmp = strtoul(level, &end, 0);
1383 : :
1384 : : /* check for errors */
1385 [ # # # # : 0 : if (errno != 0 || end == NULL || *end != '\0' ||
# # # # ]
1386 : : tmp >= UINT32_MAX)
1387 : : return -1;
1388 : :
1389 : 0 : return tmp;
1390 : : }
1391 : :
1392 : : static int
1393 : 0 : eal_parse_log_level(const char *arg)
1394 : : {
1395 : : const char *pattern = NULL;
1396 : : const char *regex = NULL;
1397 : : char *str, *level;
1398 : : int priority;
1399 : :
1400 [ # # ]: 0 : if (strcmp(arg, "help") == 0) {
1401 : 0 : eal_log_usage();
1402 : 0 : exit(EXIT_SUCCESS);
1403 : : }
1404 : :
1405 : 0 : str = strdup(arg);
1406 [ # # ]: 0 : if (str == NULL)
1407 : : return -1;
1408 : :
1409 [ # # ]: 0 : if ((level = strchr(str, ','))) {
1410 : : regex = str;
1411 : 0 : *level++ = '\0';
1412 [ # # ]: 0 : } else if ((level = strchr(str, ':'))) {
1413 : : pattern = str;
1414 : 0 : *level++ = '\0';
1415 : : } else {
1416 : : level = str;
1417 : : }
1418 : :
1419 : 0 : priority = eal_parse_log_priority(level);
1420 [ # # ]: 0 : if (priority <= 0) {
1421 : 0 : fprintf(stderr, "Invalid log level: %s\n", level);
1422 : 0 : goto fail;
1423 : : }
1424 [ # # ]: 0 : if (priority > (int)RTE_LOG_MAX) {
1425 : 0 : fprintf(stderr, "Log level %d higher than maximum (%d)\n",
1426 : : priority, RTE_LOG_MAX);
1427 : : priority = RTE_LOG_MAX;
1428 : : }
1429 : :
1430 [ # # ]: 0 : if (regex) {
1431 [ # # ]: 0 : if (rte_log_set_level_regexp(regex, priority) < 0) {
1432 : 0 : fprintf(stderr, "cannot set log level %s,%d\n",
1433 : : regex, priority);
1434 : 0 : goto fail;
1435 : : }
1436 [ # # ]: 0 : if (eal_log_save_regexp(regex, priority) < 0)
1437 : 0 : goto fail;
1438 [ # # ]: 0 : } else if (pattern) {
1439 [ # # ]: 0 : if (rte_log_set_level_pattern(pattern, priority) < 0) {
1440 : 0 : fprintf(stderr, "cannot set log level %s:%d\n",
1441 : : pattern, priority);
1442 : 0 : goto fail;
1443 : : }
1444 [ # # ]: 0 : if (eal_log_save_pattern(pattern, priority) < 0)
1445 : 0 : goto fail;
1446 : : } else {
1447 : 0 : rte_log_set_global_level(priority);
1448 : : }
1449 : :
1450 : 0 : free(str);
1451 : 0 : return 0;
1452 : :
1453 : 0 : fail:
1454 : 0 : free(str);
1455 : 0 : return -1;
1456 : : }
1457 : :
1458 : : static enum rte_proc_type_t
1459 : 75 : eal_parse_proc_type(const char *arg)
1460 : : {
1461 [ + - ]: 75 : if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
1462 : : return RTE_PROC_PRIMARY;
1463 [ + + ]: 75 : if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
1464 : : return RTE_PROC_SECONDARY;
1465 [ + + ]: 4 : if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
1466 : 3 : return RTE_PROC_AUTO;
1467 : :
1468 : : return RTE_PROC_INVALID;
1469 : : }
1470 : :
1471 : : static int
1472 : 0 : eal_parse_iova_mode(const char *name)
1473 : : {
1474 : : int mode;
1475 : : struct internal_config *internal_conf =
1476 : 0 : eal_get_internal_configuration();
1477 : :
1478 [ # # ]: 0 : if (name == NULL)
1479 : : return -1;
1480 : :
1481 [ # # ]: 0 : if (!strcmp("pa", name))
1482 : : mode = RTE_IOVA_PA;
1483 [ # # ]: 0 : else if (!strcmp("va", name))
1484 : : mode = RTE_IOVA_VA;
1485 : : else
1486 : : return -1;
1487 : :
1488 : 0 : internal_conf->iova_mode = mode;
1489 : 0 : return 0;
1490 : : }
1491 : :
1492 : : static int
1493 : 0 : eal_parse_simd_bitwidth(const char *arg)
1494 : : {
1495 : : char *end;
1496 : : unsigned long bitwidth;
1497 : : int ret;
1498 : : struct internal_config *internal_conf =
1499 : 0 : eal_get_internal_configuration();
1500 : :
1501 [ # # # # ]: 0 : if (arg == NULL || arg[0] == '\0')
1502 : : return -1;
1503 : :
1504 : 0 : errno = 0;
1505 : 0 : bitwidth = strtoul(arg, &end, 0);
1506 : :
1507 : : /* check for errors */
1508 [ # # # # : 0 : if (errno != 0 || end == NULL || *end != '\0' || bitwidth > RTE_VECT_SIMD_MAX)
# # # # ]
1509 : : return -1;
1510 : :
1511 [ # # ]: 0 : if (bitwidth == 0)
1512 : : bitwidth = (unsigned long) RTE_VECT_SIMD_MAX;
1513 : 0 : ret = rte_vect_set_max_simd_bitwidth(bitwidth);
1514 [ # # ]: 0 : if (ret < 0)
1515 : : return -1;
1516 : 0 : internal_conf->max_simd_bitwidth.forced = 1;
1517 : 0 : return 0;
1518 : : }
1519 : :
1520 : : static int
1521 : 1 : eal_parse_base_virtaddr(const char *arg)
1522 : : {
1523 : : char *end;
1524 : : uint64_t addr;
1525 : : struct internal_config *internal_conf =
1526 : 1 : eal_get_internal_configuration();
1527 : :
1528 : 1 : errno = 0;
1529 : 1 : addr = strtoull(arg, &end, 16);
1530 : :
1531 : : /* check for errors */
1532 [ + - + - : 1 : if ((errno != 0) || (arg[0] == '\0') || end == NULL || (*end != '\0'))
+ - + - ]
1533 : : return -1;
1534 : :
1535 : : /* make sure we don't exceed 32-bit boundary on 32-bit target */
1536 : : #ifndef RTE_ARCH_64
1537 : : if (addr >= UINTPTR_MAX)
1538 : : return -1;
1539 : : #endif
1540 : :
1541 : : /* align the addr on 16M boundary, 16MB is the minimum huge page
1542 : : * size on IBM Power architecture. If the addr is aligned to 16MB,
1543 : : * it can align to 2MB for x86. So this alignment can also be used
1544 : : * on x86 and other architectures.
1545 : : */
1546 : 1 : internal_conf->base_virtaddr =
1547 : 1 : RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M);
1548 : :
1549 : 1 : return 0;
1550 : : }
1551 : :
1552 : : /* caller is responsible for freeing the returned string */
1553 : : static char *
1554 : 0 : available_cores(void)
1555 : : {
1556 : 0 : char *str = NULL;
1557 : : int previous;
1558 : : int sequence;
1559 : : char *tmp;
1560 : : int idx;
1561 : :
1562 : : /* find the first available cpu */
1563 [ # # ]: 0 : for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1564 [ # # ]: 0 : if (eal_cpu_detected(idx) == 0)
1565 : : continue;
1566 : : break;
1567 : : }
1568 [ # # ]: 0 : if (idx >= RTE_MAX_LCORE)
1569 : : return NULL;
1570 : :
1571 : : /* first sequence */
1572 [ # # ]: 0 : if (asprintf(&str, "%d", idx) < 0)
1573 : : return NULL;
1574 : : previous = idx;
1575 : : sequence = 0;
1576 : :
1577 [ # # ]: 0 : for (idx++ ; idx < RTE_MAX_LCORE; idx++) {
1578 [ # # ]: 0 : if (eal_cpu_detected(idx) == 0)
1579 : 0 : continue;
1580 : :
1581 [ # # ]: 0 : if (idx == previous + 1) {
1582 : : previous = idx;
1583 : : sequence = 1;
1584 : 0 : continue;
1585 : : }
1586 : :
1587 : : /* finish current sequence */
1588 [ # # ]: 0 : if (sequence) {
1589 [ # # ]: 0 : if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
1590 : 0 : free(str);
1591 : 0 : return NULL;
1592 : : }
1593 : 0 : free(str);
1594 : 0 : str = tmp;
1595 : : }
1596 : :
1597 : : /* new sequence */
1598 [ # # ]: 0 : if (asprintf(&tmp, "%s,%d", str, idx) < 0) {
1599 : 0 : free(str);
1600 : 0 : return NULL;
1601 : : }
1602 : 0 : free(str);
1603 : 0 : str = tmp;
1604 : : previous = idx;
1605 : : sequence = 0;
1606 : : }
1607 : :
1608 : : /* finish last sequence */
1609 [ # # ]: 0 : if (sequence) {
1610 [ # # ]: 0 : if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
1611 : 0 : free(str);
1612 : 0 : return NULL;
1613 : : }
1614 : 0 : free(str);
1615 : 0 : str = tmp;
1616 : : }
1617 : :
1618 : 0 : return str;
1619 : : }
1620 : :
1621 : : #define HUGE_UNLINK_NEVER "never"
1622 : :
1623 : : static int
1624 : 1 : eal_parse_huge_unlink(const char *arg, struct hugepage_file_discipline *out)
1625 : : {
1626 [ + - - + ]: 1 : if (arg == NULL || strcmp(arg, "always") == 0) {
1627 : 0 : out->unlink_before_mapping = true;
1628 : 0 : return 0;
1629 : : }
1630 [ + - ]: 1 : if (strcmp(arg, "existing") == 0) {
1631 : : /* same as not specifying the option */
1632 : : return 0;
1633 : : }
1634 [ + - ]: 1 : if (strcmp(arg, HUGE_UNLINK_NEVER) == 0) {
1635 : 1 : EAL_LOG(WARNING, "Using --"OPT_HUGE_UNLINK"="
1636 : : HUGE_UNLINK_NEVER" may create data leaks.");
1637 : 1 : out->unlink_existing = false;
1638 : 1 : return 0;
1639 : : }
1640 : : return -1;
1641 : : }
1642 : :
1643 : : int
1644 : 521 : eal_parse_common_option(int opt, const char *optarg,
1645 : : struct internal_config *conf)
1646 : : {
1647 : : static int b_used;
1648 : : static int a_used;
1649 : :
1650 [ + + + + : 521 : switch (opt) {
- - + + +
- + + + +
+ - + + +
+ + + - +
+ - - + +
+ - + - -
- + ]
1651 : 7 : case 'b':
1652 [ - + ]: 7 : if (a_used)
1653 : 0 : goto ba_conflict;
1654 [ + - ]: 7 : if (eal_option_device_add(RTE_DEVTYPE_BLOCKED, optarg) < 0)
1655 : : return -1;
1656 : 7 : b_used = 1;
1657 : 7 : break;
1658 : :
1659 : 13 : case 'a':
1660 [ - + ]: 13 : if (b_used)
1661 : 0 : goto ba_conflict;
1662 [ + - ]: 13 : if (eal_option_device_add(RTE_DEVTYPE_ALLOWED, optarg) < 0)
1663 : : return -1;
1664 : 13 : a_used = 1;
1665 : 13 : break;
1666 : : /* coremask */
1667 : : case 'c': {
1668 : : int lcore_indexes[RTE_MAX_LCORE];
1669 : :
1670 [ - + ]: 13 : if (eal_service_cores_parsed())
1671 : 0 : EAL_LOG(WARNING,
1672 : : "Service cores parsed before dataplane cores. Please ensure -c is before -s or -S");
1673 [ + + ]: 13 : if (rte_eal_parse_coremask(optarg, lcore_indexes) < 0) {
1674 : 1 : EAL_LOG(ERR, "invalid coremask syntax");
1675 : 1 : return -1;
1676 : : }
1677 [ - + ]: 12 : if (update_lcore_config(lcore_indexes) < 0) {
1678 : 0 : char *available = available_cores();
1679 : :
1680 : 0 : EAL_LOG(ERR,
1681 : : "invalid coremask, please check specified cores are part of %s",
1682 : : available);
1683 : 0 : free(available);
1684 : 0 : return -1;
1685 : : }
1686 : :
1687 [ - + ]: 12 : if (core_parsed) {
1688 [ # # # # ]: 0 : EAL_LOG(ERR, "Option -c is ignored, because (%s) is set!",
1689 : : (core_parsed == LCORE_OPT_LST) ? "-l" :
1690 : : (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1691 : : "-c");
1692 : 0 : return -1;
1693 : : }
1694 : :
1695 : 12 : core_parsed = LCORE_OPT_MSK;
1696 : 12 : break;
1697 : : }
1698 : : /* corelist */
1699 : : case 'l': {
1700 : : int lcore_indexes[RTE_MAX_LCORE];
1701 : :
1702 [ - + ]: 9 : if (eal_service_cores_parsed())
1703 : 0 : EAL_LOG(WARNING,
1704 : : "Service cores parsed before dataplane cores. Please ensure -l is before -s or -S");
1705 : :
1706 [ + - ]: 9 : if (eal_parse_corelist(optarg, lcore_indexes) < 0) {
1707 : 9 : EAL_LOG(ERR, "invalid core list syntax");
1708 : 9 : return -1;
1709 : : }
1710 [ # # ]: 0 : if (update_lcore_config(lcore_indexes) < 0) {
1711 : 0 : char *available = available_cores();
1712 : :
1713 : 0 : EAL_LOG(ERR,
1714 : : "invalid core list, please check specified cores are part of %s",
1715 : : available);
1716 : 0 : free(available);
1717 : 0 : return -1;
1718 : : }
1719 : :
1720 [ # # ]: 0 : if (core_parsed) {
1721 [ # # # # ]: 0 : EAL_LOG(ERR, "Option -l is ignored, because (%s) is set!",
1722 : : (core_parsed == LCORE_OPT_MSK) ? "-c" :
1723 : : (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1724 : : "-l");
1725 : 0 : return -1;
1726 : : }
1727 : :
1728 : 0 : core_parsed = LCORE_OPT_LST;
1729 : 0 : break;
1730 : : }
1731 : : /* service coremask */
1732 : 0 : case 's':
1733 [ # # ]: 0 : if (eal_parse_service_coremask(optarg) < 0) {
1734 : 0 : EAL_LOG(ERR, "invalid service coremask");
1735 : 0 : return -1;
1736 : : }
1737 : : break;
1738 : : /* service corelist */
1739 : 0 : case 'S':
1740 [ # # ]: 0 : if (eal_parse_service_corelist(optarg) < 0) {
1741 : 0 : EAL_LOG(ERR, "invalid service core list");
1742 : 0 : return -1;
1743 : : }
1744 : : break;
1745 : : /* size of memory */
1746 : : case 'm':
1747 : 103 : conf->memory = atoi(optarg);
1748 : 103 : conf->memory *= 1024ULL;
1749 : 103 : conf->memory *= 1024ULL;
1750 : 103 : mem_parsed = 1;
1751 : 103 : break;
1752 : : /* force number of channels */
1753 : : case 'n':
1754 : 3 : conf->force_nchannel = atoi(optarg);
1755 [ + + ]: 3 : if (conf->force_nchannel == 0) {
1756 : 2 : EAL_LOG(ERR, "invalid channel number");
1757 : 2 : return -1;
1758 : : }
1759 : : break;
1760 : : /* force number of ranks */
1761 : : case 'r':
1762 : 5 : conf->force_nrank = atoi(optarg);
1763 [ + + ]: 5 : if (conf->force_nrank == 0 ||
1764 [ + + ]: 3 : conf->force_nrank > 16) {
1765 : 4 : EAL_LOG(ERR, "invalid rank number");
1766 : 4 : return -1;
1767 : : }
1768 : : break;
1769 : : /* force loading of external driver */
1770 : 0 : case 'd':
1771 [ # # ]: 0 : if (eal_plugin_add(optarg) == -1)
1772 : 0 : return -1;
1773 : : break;
1774 : 1 : case 'v':
1775 : : /* since message is explicitly requested by user, we
1776 : : * write message at highest log level so it can always
1777 : : * be seen
1778 : : * even if info or warning messages are disabled */
1779 : 1 : EAL_LOG(CRIT, "RTE Version: '%s'", rte_version());
1780 : 1 : break;
1781 : :
1782 : : /* long options */
1783 : 1 : case OPT_HUGE_UNLINK_NUM:
1784 [ - + ]: 1 : if (eal_parse_huge_unlink(optarg, &conf->hugepage_file) < 0) {
1785 : 0 : EAL_LOG(ERR, "invalid --"OPT_HUGE_UNLINK" option");
1786 : 0 : return -1;
1787 : : }
1788 : : break;
1789 : :
1790 : 99 : case OPT_NO_HUGE_NUM:
1791 : 99 : conf->no_hugetlbfs = 1;
1792 : : /* no-huge is legacy mem */
1793 : 99 : conf->legacy_mem = 1;
1794 : 99 : break;
1795 : :
1796 : 1 : case OPT_NO_PCI_NUM:
1797 : 1 : conf->no_pci = 1;
1798 : 1 : break;
1799 : :
1800 : 1 : case OPT_NO_HPET_NUM:
1801 : 1 : conf->no_hpet = 1;
1802 : 1 : break;
1803 : :
1804 : 0 : case OPT_VMWARE_TSC_MAP_NUM:
1805 : 0 : conf->vmware_tsc_map = 1;
1806 : 0 : break;
1807 : :
1808 : 7 : case OPT_NO_SHCONF_NUM:
1809 : 7 : conf->no_shconf = 1;
1810 : 7 : break;
1811 : :
1812 : 3 : case OPT_IN_MEMORY_NUM:
1813 : 3 : conf->in_memory = 1;
1814 : : /* in-memory is a superset of noshconf and huge-unlink */
1815 : 3 : conf->no_shconf = 1;
1816 : 3 : conf->hugepage_file.unlink_before_mapping = true;
1817 : 3 : break;
1818 : :
1819 : 75 : case OPT_PROC_TYPE_NUM:
1820 : 75 : conf->process_type = eal_parse_proc_type(optarg);
1821 : 75 : break;
1822 : :
1823 : 5 : case OPT_MAIN_LCORE_NUM:
1824 [ + + ]: 5 : if (eal_parse_main_lcore(optarg) < 0) {
1825 : 2 : EAL_LOG(ERR, "invalid parameter for --"
1826 : : OPT_MAIN_LCORE);
1827 : 2 : return -1;
1828 : : }
1829 : : break;
1830 : :
1831 : 11 : case OPT_VDEV_NUM:
1832 [ - + ]: 11 : if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1833 : : optarg) < 0) {
1834 : 0 : return -1;
1835 : : }
1836 : : break;
1837 : :
1838 : : #ifndef RTE_EXEC_ENV_WINDOWS
1839 : 2 : case OPT_SYSLOG_NUM:
1840 [ + + ]: 2 : if (eal_parse_syslog(optarg, conf) < 0) {
1841 : 1 : EAL_LOG(ERR, "invalid parameters for --"
1842 : : OPT_SYSLOG);
1843 : 1 : return -1;
1844 : : }
1845 : : break;
1846 : : #endif
1847 : :
1848 : 0 : case OPT_LOG_LEVEL_NUM: {
1849 [ # # ]: 0 : if (eal_parse_log_level(optarg) < 0) {
1850 : 0 : EAL_LOG(ERR,
1851 : : "invalid parameters for --"
1852 : : OPT_LOG_LEVEL);
1853 : 0 : return -1;
1854 : : }
1855 : : break;
1856 : : }
1857 : :
1858 : : #ifndef RTE_EXEC_ENV_WINDOWS
1859 : 1 : case OPT_TRACE_NUM: {
1860 [ - + ]: 1 : if (eal_trace_args_save(optarg) < 0) {
1861 : 0 : EAL_LOG(ERR, "invalid parameters for --"
1862 : : OPT_TRACE);
1863 : 0 : return -1;
1864 : : }
1865 : : break;
1866 : : }
1867 : :
1868 : 1 : case OPT_TRACE_DIR_NUM: {
1869 [ - + ]: 1 : if (eal_trace_dir_args_save(optarg) < 0) {
1870 : 0 : EAL_LOG(ERR, "invalid parameters for --"
1871 : : OPT_TRACE_DIR);
1872 : 0 : return -1;
1873 : : }
1874 : : break;
1875 : : }
1876 : :
1877 : 0 : case OPT_TRACE_BUF_SIZE_NUM: {
1878 [ # # ]: 0 : if (eal_trace_bufsz_args_save(optarg) < 0) {
1879 : 0 : EAL_LOG(ERR, "invalid parameters for --"
1880 : : OPT_TRACE_BUF_SIZE);
1881 : 0 : return -1;
1882 : : }
1883 : : break;
1884 : : }
1885 : :
1886 : 0 : case OPT_TRACE_MODE_NUM: {
1887 [ # # ]: 0 : if (eal_trace_mode_args_save(optarg) < 0) {
1888 : 0 : EAL_LOG(ERR, "invalid parameters for --"
1889 : : OPT_TRACE_MODE);
1890 : 0 : return -1;
1891 : : }
1892 : : break;
1893 : : }
1894 : : #endif /* !RTE_EXEC_ENV_WINDOWS */
1895 : :
1896 : 13 : case OPT_LCORES_NUM:
1897 [ + - ]: 13 : if (eal_parse_lcores(optarg) < 0) {
1898 : 13 : EAL_LOG(ERR, "invalid parameter for --"
1899 : : OPT_LCORES);
1900 : 13 : return -1;
1901 : : }
1902 : :
1903 [ # # ]: 0 : if (core_parsed) {
1904 [ # # # # ]: 0 : EAL_LOG(ERR, "Option --lcore is ignored, because (%s) is set!",
1905 : : (core_parsed == LCORE_OPT_LST) ? "-l" :
1906 : : (core_parsed == LCORE_OPT_MSK) ? "-c" :
1907 : : "--lcore");
1908 : 0 : return -1;
1909 : : }
1910 : :
1911 : 0 : core_parsed = LCORE_OPT_MAP;
1912 : 0 : break;
1913 : 2 : case OPT_LEGACY_MEM_NUM:
1914 : 2 : conf->legacy_mem = 1;
1915 : 2 : break;
1916 : 1 : case OPT_SINGLE_FILE_SEGMENTS_NUM:
1917 : 1 : conf->single_file_segments = 1;
1918 : 1 : break;
1919 : 0 : case OPT_IOVA_MODE_NUM:
1920 [ # # ]: 0 : if (eal_parse_iova_mode(optarg) < 0) {
1921 : 0 : EAL_LOG(ERR, "invalid parameters for --"
1922 : : OPT_IOVA_MODE);
1923 : 0 : return -1;
1924 : : }
1925 : : break;
1926 : 1 : case OPT_BASE_VIRTADDR_NUM:
1927 [ - + ]: 1 : if (eal_parse_base_virtaddr(optarg) < 0) {
1928 : 0 : EAL_LOG(ERR, "invalid parameter for --"
1929 : : OPT_BASE_VIRTADDR);
1930 : 0 : return -1;
1931 : : }
1932 : : break;
1933 : : case OPT_TELEMETRY_NUM:
1934 : : break;
1935 : 0 : case OPT_NO_TELEMETRY_NUM:
1936 : 0 : conf->no_telemetry = 1;
1937 : 0 : break;
1938 : 0 : case OPT_FORCE_MAX_SIMD_BITWIDTH_NUM:
1939 [ # # ]: 0 : if (eal_parse_simd_bitwidth(optarg) < 0) {
1940 : 0 : EAL_LOG(ERR, "invalid parameter for --"
1941 : : OPT_FORCE_MAX_SIMD_BITWIDTH);
1942 : 0 : return -1;
1943 : : }
1944 : : break;
1945 : :
1946 : : /* don't know what to do, leave this to caller */
1947 : : default:
1948 : : return 1;
1949 : :
1950 : : }
1951 : :
1952 : : return 0;
1953 : :
1954 : 0 : ba_conflict:
1955 : 0 : EAL_LOG(ERR,
1956 : : "Options allow (-a) and block (-b) can't be used at the same time");
1957 : 0 : return -1;
1958 : : }
1959 : :
1960 : : static void
1961 : 184 : eal_auto_detect_cores(struct rte_config *cfg)
1962 : : {
1963 : : unsigned int lcore_id;
1964 : : unsigned int removed = 0;
1965 : : rte_cpuset_t affinity_set;
1966 : :
1967 [ - + ]: 184 : if (rte_thread_get_affinity_by_id(rte_thread_self(), &affinity_set) != 0)
1968 : 0 : CPU_ZERO(&affinity_set);
1969 : :
1970 [ + + ]: 23736 : for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1971 [ + + ]: 23552 : if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1972 [ + + ]: 2944 : !CPU_ISSET(lcore_id, &affinity_set)) {
1973 : 2642 : cfg->lcore_role[lcore_id] = ROLE_OFF;
1974 : 2642 : removed++;
1975 : : }
1976 : : }
1977 : :
1978 : 184 : cfg->lcore_count -= removed;
1979 : 184 : }
1980 : :
1981 : : static void
1982 : 193 : compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
1983 : : {
1984 : 193 : rte_cpuset_t *cpuset = &internal_cfg->ctrl_cpuset;
1985 : : rte_cpuset_t default_set;
1986 : : unsigned int lcore_id;
1987 : :
1988 [ + + ]: 24897 : for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1989 [ + + ]: 24704 : if (rte_lcore_has_role(lcore_id, ROLE_OFF))
1990 : 24390 : continue;
1991 [ + + ]: 5338 : RTE_CPU_OR(cpuset, cpuset, &lcore_config[lcore_id].cpuset);
1992 : : }
1993 [ + + + + ]: 200913 : RTE_CPU_NOT(cpuset, cpuset);
1994 : :
1995 [ - + ]: 193 : if (rte_thread_get_affinity_by_id(rte_thread_self(), &default_set) != 0)
1996 : 0 : CPU_ZERO(&default_set);
1997 : :
1998 [ + + ]: 3281 : RTE_CPU_AND(cpuset, cpuset, &default_set);
1999 : :
2000 : : /* if no remaining cpu, use main lcore cpu affinity */
2001 [ + - ]: 193 : if (!CPU_COUNT(cpuset)) {
2002 : 193 : memcpy(cpuset, &lcore_config[rte_get_main_lcore()].cpuset,
2003 : : sizeof(*cpuset));
2004 : : }
2005 : 193 : }
2006 : :
2007 : : int
2008 : 238 : eal_cleanup_config(struct internal_config *internal_cfg)
2009 : : {
2010 : 238 : free(internal_cfg->hugefile_prefix);
2011 : 238 : free(internal_cfg->hugepage_dir);
2012 : 238 : free(internal_cfg->user_mbuf_pool_ops_name);
2013 : :
2014 : 238 : return 0;
2015 : : }
2016 : :
2017 : : int
2018 : 193 : eal_adjust_config(struct internal_config *internal_cfg)
2019 : : {
2020 : : int i;
2021 : 193 : struct rte_config *cfg = rte_eal_get_configuration();
2022 : : struct internal_config *internal_conf =
2023 : 193 : eal_get_internal_configuration();
2024 : :
2025 [ + + ]: 193 : if (!core_parsed)
2026 : 184 : eal_auto_detect_cores(cfg);
2027 : :
2028 [ + + ]: 193 : if (internal_conf->process_type == RTE_PROC_AUTO)
2029 : 3 : internal_conf->process_type = eal_proc_type_detect();
2030 : :
2031 : : /* default main lcore is the first one */
2032 [ + + ]: 193 : if (!main_lcore_parsed) {
2033 : 190 : cfg->main_lcore = rte_get_next_lcore(-1, 0, 0);
2034 [ + - ]: 190 : if (cfg->main_lcore >= RTE_MAX_LCORE)
2035 : : return -1;
2036 : 190 : lcore_config[cfg->main_lcore].core_role = ROLE_RTE;
2037 : : }
2038 : :
2039 : 193 : compute_ctrl_threads_cpuset(internal_cfg);
2040 : :
2041 : : /* if no memory amounts were requested, this will result in 0 and
2042 : : * will be overridden later, right after eal_hugepage_info_init() */
2043 [ + + ]: 6369 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
2044 : 6176 : internal_cfg->memory += internal_cfg->socket_mem[i];
2045 : :
2046 : : return 0;
2047 : : }
2048 : :
2049 : : int
2050 : 193 : eal_check_common_options(struct internal_config *internal_cfg)
2051 : : {
2052 : 193 : struct rte_config *cfg = rte_eal_get_configuration();
2053 : : const struct internal_config *internal_conf =
2054 : 193 : eal_get_internal_configuration();
2055 : :
2056 [ + + ]: 193 : if (cfg->lcore_role[cfg->main_lcore] != ROLE_RTE) {
2057 : 1 : EAL_LOG(ERR, "Main lcore is not enabled for DPDK");
2058 : 1 : return -1;
2059 : : }
2060 : :
2061 [ + + ]: 192 : if (internal_cfg->process_type == RTE_PROC_INVALID) {
2062 : 1 : EAL_LOG(ERR, "Invalid process type specified");
2063 : 1 : return -1;
2064 : : }
2065 [ + + ]: 191 : if (internal_cfg->hugefile_prefix != NULL &&
2066 [ - + ]: 72 : strlen(internal_cfg->hugefile_prefix) < 1) {
2067 : 0 : EAL_LOG(ERR, "Invalid length of --" OPT_FILE_PREFIX " option");
2068 : 0 : return -1;
2069 : : }
2070 [ + + ]: 191 : if (internal_cfg->hugepage_dir != NULL &&
2071 [ - + ]: 5 : strlen(internal_cfg->hugepage_dir) < 1) {
2072 : 0 : EAL_LOG(ERR, "Invalid length of --" OPT_HUGE_DIR" option");
2073 : 0 : return -1;
2074 : : }
2075 [ - + ]: 191 : if (internal_cfg->user_mbuf_pool_ops_name != NULL &&
2076 [ # # ]: 0 : strlen(internal_cfg->user_mbuf_pool_ops_name) < 1) {
2077 : 0 : EAL_LOG(ERR, "Invalid length of --" OPT_MBUF_POOL_OPS_NAME" option");
2078 : 0 : return -1;
2079 : : }
2080 [ - + ]: 191 : if (strchr(eal_get_hugefile_prefix(), '%') != NULL) {
2081 : 0 : EAL_LOG(ERR, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
2082 : : "option");
2083 : 0 : return -1;
2084 : : }
2085 [ + + + + ]: 191 : if (mem_parsed && internal_cfg->force_sockets == 1) {
2086 : 2 : EAL_LOG(ERR, "Options -m and --"OPT_SOCKET_MEM" cannot "
2087 : : "be specified at the same time");
2088 : 2 : return -1;
2089 : : }
2090 [ + + + + ]: 189 : if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
2091 : 1 : EAL_LOG(ERR, "Option --"OPT_SOCKET_MEM" cannot "
2092 : : "be specified together with --"OPT_NO_HUGE);
2093 : 1 : return -1;
2094 : : }
2095 [ + + ]: 188 : if (internal_cfg->no_hugetlbfs &&
2096 [ - + ]: 94 : internal_cfg->hugepage_file.unlink_before_mapping &&
2097 [ # # ]: 0 : !internal_cfg->in_memory) {
2098 : 0 : EAL_LOG(ERR, "Option --"OPT_HUGE_UNLINK" cannot "
2099 : : "be specified together with --"OPT_NO_HUGE);
2100 : 0 : return -1;
2101 : : }
2102 [ + + ]: 188 : if (internal_cfg->no_hugetlbfs &&
2103 [ + + ]: 94 : internal_cfg->huge_worker_stack_size != 0) {
2104 : 2 : EAL_LOG(ERR, "Option --"OPT_HUGE_WORKER_STACK" cannot "
2105 : : "be specified together with --"OPT_NO_HUGE);
2106 : 2 : return -1;
2107 : : }
2108 [ - + - - ]: 186 : if (internal_conf->force_socket_limits && internal_conf->legacy_mem) {
2109 : 0 : EAL_LOG(ERR, "Option --"OPT_SOCKET_LIMIT
2110 : : " is only supported in non-legacy memory mode");
2111 : : }
2112 [ + + ]: 186 : if (internal_cfg->single_file_segments &&
2113 [ - + ]: 1 : internal_cfg->hugepage_file.unlink_before_mapping &&
2114 [ # # ]: 0 : !internal_cfg->in_memory) {
2115 : 0 : EAL_LOG(ERR, "Option --"OPT_SINGLE_FILE_SEGMENTS" is "
2116 : : "not compatible with --"OPT_HUGE_UNLINK);
2117 : 0 : return -1;
2118 : : }
2119 [ + + ]: 186 : if (!internal_cfg->hugepage_file.unlink_existing &&
2120 [ - + ]: 1 : internal_cfg->in_memory) {
2121 : 0 : EAL_LOG(ERR, "Option --"OPT_IN_MEMORY" is not compatible "
2122 : : "with --"OPT_HUGE_UNLINK"="HUGE_UNLINK_NEVER);
2123 : 0 : return -1;
2124 : : }
2125 [ + + ]: 186 : if (internal_cfg->legacy_mem &&
2126 [ - + ]: 94 : internal_cfg->in_memory) {
2127 : 0 : EAL_LOG(ERR, "Option --"OPT_LEGACY_MEM" is not compatible "
2128 : : "with --"OPT_IN_MEMORY);
2129 : 0 : return -1;
2130 : : }
2131 [ + + - + ]: 186 : if (internal_cfg->legacy_mem && internal_cfg->match_allocations) {
2132 : 0 : EAL_LOG(ERR, "Option --"OPT_LEGACY_MEM" is not compatible "
2133 : : "with --"OPT_MATCH_ALLOCATIONS);
2134 : 0 : return -1;
2135 : : }
2136 [ + + - + ]: 186 : if (internal_cfg->no_hugetlbfs && internal_cfg->match_allocations) {
2137 : 0 : EAL_LOG(ERR, "Option --"OPT_NO_HUGE" is not compatible "
2138 : : "with --"OPT_MATCH_ALLOCATIONS);
2139 : 0 : return -1;
2140 : : }
2141 [ + + + + ]: 186 : if (internal_cfg->legacy_mem && internal_cfg->memory == 0) {
2142 : 8 : EAL_LOG(NOTICE, "Static memory layout is selected, "
2143 : : "amount of reserved memory can be adjusted with "
2144 : : "-m or --"OPT_SOCKET_MEM);
2145 : : }
2146 : :
2147 : : return 0;
2148 : : }
2149 : :
2150 : : uint16_t
2151 : 66447 : rte_vect_get_max_simd_bitwidth(void)
2152 : : {
2153 : : const struct internal_config *internal_conf =
2154 : 66447 : eal_get_internal_configuration();
2155 : 66447 : return internal_conf->max_simd_bitwidth.bitwidth;
2156 : : }
2157 : :
2158 : : int
2159 : 0 : rte_vect_set_max_simd_bitwidth(uint16_t bitwidth)
2160 : : {
2161 : : struct internal_config *internal_conf =
2162 : 0 : eal_get_internal_configuration();
2163 [ # # ]: 0 : if (internal_conf->max_simd_bitwidth.forced) {
2164 : 0 : EAL_LOG(NOTICE, "Cannot set max SIMD bitwidth - user runtime override enabled");
2165 : 0 : return -EPERM;
2166 : : }
2167 : :
2168 [ # # # # ]: 0 : if (bitwidth < RTE_VECT_SIMD_DISABLED || !rte_is_power_of_2(bitwidth)) {
2169 : 0 : EAL_LOG(ERR, "Invalid bitwidth value!");
2170 : 0 : return -EINVAL;
2171 : : }
2172 : 0 : internal_conf->max_simd_bitwidth.bitwidth = bitwidth;
2173 : 0 : return 0;
2174 : : }
2175 : :
2176 : : void
2177 : 52 : eal_common_usage(void)
2178 : : {
2179 : : printf("[options]\n\n"
2180 : : "EAL common options:\n"
2181 : : " -c COREMASK Hexadecimal bitmask of cores to run on\n"
2182 : : " -l CORELIST List of cores to run on\n"
2183 : : " The argument format is <c1>[-c2][,c3[-c4],...]\n"
2184 : : " where c1, c2, etc are core indexes between 0 and %d\n"
2185 : : " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
2186 : : " The argument format is\n"
2187 : : " '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
2188 : : " lcores and cpus list are grouped by '(' and ')'\n"
2189 : : " Within the group, '-' is used for range separator,\n"
2190 : : " ',' is used for single number separator.\n"
2191 : : " '( )' can be omitted for single element group,\n"
2192 : : " '@' can be omitted if cpus and lcores have the same value\n"
2193 : : " -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
2194 : : " --"OPT_MAIN_LCORE" ID Core ID that is used as main\n"
2195 : : " --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
2196 : : " -n CHANNELS Number of memory channels\n"
2197 : : " -m MB Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
2198 : : " -r RANKS Force number of memory ranks (don't detect)\n"
2199 : : " -b, --block Add a device to the blocked list.\n"
2200 : : " Prevent EAL from using this device. The argument\n"
2201 : : " format for PCI devices is <domain:bus:devid.func>.\n"
2202 : : " -a, --allow Add a device to the allow list.\n"
2203 : : " Only use the specified devices. The argument format\n"
2204 : : " for PCI devices is <[domain:]bus:devid.func>.\n"
2205 : : " This option can be present several times.\n"
2206 : : " [NOTE: " OPT_DEV_ALLOW " cannot be used with "OPT_DEV_BLOCK" option]\n"
2207 : : " --"OPT_VDEV" Add a virtual device.\n"
2208 : : " The argument format is <driver><id>[,key=val,...]\n"
2209 : : " (ex: --vdev=net_pcap0,iface=eth2).\n"
2210 : : " --"OPT_IOVA_MODE" Set IOVA mode. 'pa' for IOVA_PA\n"
2211 : : " 'va' for IOVA_VA\n"
2212 : : " -d LIB.so|DIR Add a driver or driver directory\n"
2213 : : " (can be used multiple times)\n"
2214 : : " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n"
2215 : : " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n"
2216 : : #ifndef RTE_EXEC_ENV_WINDOWS
2217 : : " --"OPT_SYSLOG" Set syslog facility\n"
2218 : : #endif
2219 : : " --"OPT_LOG_LEVEL"=<level> Set global log level\n"
2220 : : " --"OPT_LOG_LEVEL"=<type-match>:<level>\n"
2221 : : " Set specific log level\n"
2222 : : " --"OPT_LOG_LEVEL"=help Show log types and levels\n"
2223 : : #ifndef RTE_EXEC_ENV_WINDOWS
2224 : : " --"OPT_TRACE"=<regex-match>\n"
2225 : : " Enable trace based on regular expression trace name.\n"
2226 : : " By default, the trace is disabled.\n"
2227 : : " User must specify this option to enable trace.\n"
2228 : : " --"OPT_TRACE_DIR"=<directory path>\n"
2229 : : " Specify trace directory for trace output.\n"
2230 : : " By default, trace output will created at\n"
2231 : : " $HOME directory and parameter must be\n"
2232 : : " specified once only.\n"
2233 : : " --"OPT_TRACE_BUF_SIZE"=<int>\n"
2234 : : " Specify maximum size of allocated memory\n"
2235 : : " for trace output for each thread. Valid\n"
2236 : : " unit can be either 'B|K|M' for 'Bytes',\n"
2237 : : " 'KBytes' and 'MBytes' respectively.\n"
2238 : : " Default is 1MB and parameter must be\n"
2239 : : " specified once only.\n"
2240 : : " --"OPT_TRACE_MODE"=<o[verwrite] | d[iscard]>\n"
2241 : : " Specify the mode of update of trace\n"
2242 : : " output file. Either update on a file can\n"
2243 : : " be wrapped or discarded when file size\n"
2244 : : " reaches its maximum limit.\n"
2245 : : " Default mode is 'overwrite' and parameter\n"
2246 : : " must be specified once only.\n"
2247 : : #endif /* !RTE_EXEC_ENV_WINDOWS */
2248 : : " -v Display version information on startup\n"
2249 : : " -h, --"OPT_HELP" This help\n"
2250 : : " --"OPT_IN_MEMORY" Operate entirely in memory. This will\n"
2251 : : " disable secondary process support\n"
2252 : : " --"OPT_BASE_VIRTADDR" Base virtual address\n"
2253 : : " --"OPT_TELEMETRY" Enable telemetry support (on by default)\n"
2254 : : " --"OPT_NO_TELEMETRY" Disable telemetry support\n"
2255 : : " --"OPT_FORCE_MAX_SIMD_BITWIDTH" Force the max SIMD bitwidth\n"
2256 : : "\nEAL options for DEBUG use only:\n"
2257 : : " --"OPT_HUGE_UNLINK"[=existing|always|never]\n"
2258 : : " When to unlink files in hugetlbfs\n"
2259 : : " ('existing' by default, no value means 'always')\n"
2260 : : " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
2261 : : " --"OPT_NO_PCI" Disable PCI\n"
2262 : : " --"OPT_NO_HPET" Disable HPET\n"
2263 : : " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
2264 : : "\n", RTE_MAX_LCORE);
2265 : 52 : }
|