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