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