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