1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
9 #ifndef RTE_EXEC_ENV_WINDOWS
16 #ifndef RTE_EXEC_ENV_WINDOWS
20 #include <sys/types.h>
22 #ifndef RTE_EXEC_ENV_WINDOWS
26 #include <rte_string_fns.h>
29 #include <rte_lcore.h>
30 #include <rte_memory.h>
31 #include <rte_tailq.h>
32 #include <rte_version.h>
33 #include <rte_devargs.h>
34 #include <rte_memcpy.h>
35 #ifndef RTE_EXEC_ENV_WINDOWS
36 #include <rte_telemetry.h>
40 #include "eal_internal_cfg.h"
41 #include "eal_options.h"
42 #include "eal_filesystem.h"
43 #include "eal_private.h"
44 #ifndef RTE_EXEC_ENV_WINDOWS
45 #include "eal_trace.h"
48 #define BITS_PER_HEX 4
49 #define LCORE_OPT_LST 1
50 #define LCORE_OPT_MSK 2
51 #define LCORE_OPT_MAP 3
58 "s:" /* service coremask */
62 "S:" /* service corelist */
63 "m:" /* memory size */
64 "n:" /* memory channels */
65 "r:" /* memory ranks */
67 "w:" /* pci-whitelist (deprecated) */
71 eal_long_options[] = {
72 {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM },
73 {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM },
74 {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM },
75 {OPT_HELP, 0, NULL, OPT_HELP_NUM },
76 {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
77 {OPT_HUGE_UNLINK, 0, NULL, OPT_HUGE_UNLINK_NUM },
78 {OPT_IOVA_MODE, 1, NULL, OPT_IOVA_MODE_NUM },
79 {OPT_LCORES, 1, NULL, OPT_LCORES_NUM },
80 {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM },
81 {OPT_TRACE, 1, NULL, OPT_TRACE_NUM },
82 {OPT_TRACE_DIR, 1, NULL, OPT_TRACE_DIR_NUM },
83 {OPT_TRACE_BUF_SIZE, 1, NULL, OPT_TRACE_BUF_SIZE_NUM },
84 {OPT_TRACE_MODE, 1, NULL, OPT_TRACE_MODE_NUM },
85 {OPT_MASTER_LCORE, 1, NULL, OPT_MASTER_LCORE_NUM },
86 {OPT_MAIN_LCORE, 1, NULL, OPT_MAIN_LCORE_NUM },
87 {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
88 {OPT_NO_HPET, 0, NULL, OPT_NO_HPET_NUM },
89 {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM },
90 {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM },
91 {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM },
92 {OPT_IN_MEMORY, 0, NULL, OPT_IN_MEMORY_NUM },
93 {OPT_DEV_BLOCK, 1, NULL, OPT_DEV_BLOCK_NUM },
94 {OPT_DEV_ALLOW, 1, NULL, OPT_DEV_ALLOW_NUM },
95 {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM },
96 {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM },
97 {OPT_SOCKET_LIMIT, 1, NULL, OPT_SOCKET_LIMIT_NUM },
98 {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
99 {OPT_VDEV, 1, NULL, OPT_VDEV_NUM },
100 {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM },
101 {OPT_VFIO_VF_TOKEN, 1, NULL, OPT_VFIO_VF_TOKEN_NUM },
102 {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
103 {OPT_LEGACY_MEM, 0, NULL, OPT_LEGACY_MEM_NUM },
104 {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
105 {OPT_MATCH_ALLOCATIONS, 0, NULL, OPT_MATCH_ALLOCATIONS_NUM},
106 {OPT_TELEMETRY, 0, NULL, OPT_TELEMETRY_NUM },
107 {OPT_NO_TELEMETRY, 0, NULL, OPT_NO_TELEMETRY_NUM },
108 {OPT_FORCE_MAX_SIMD_BITWIDTH, 1, NULL, OPT_FORCE_MAX_SIMD_BITWIDTH_NUM},
110 /* legacy options that will be removed in future */
111 {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM },
112 {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM },
117 TAILQ_HEAD(shared_driver_list, shared_driver);
119 /* Definition for shared object drivers. */
120 struct shared_driver {
121 TAILQ_ENTRY(shared_driver) next;
127 /* List of external loadable drivers */
128 static struct shared_driver_list solib_list =
129 TAILQ_HEAD_INITIALIZER(solib_list);
131 #ifndef RTE_EXEC_ENV_WINDOWS
132 /* Default path of external loadable drivers */
133 static const char *default_solib_dir = RTE_EAL_PMD_PATH;
137 * Stringified version of solib path used by dpdk-pmdinfo.py
138 * Note: PLEASE DO NOT ALTER THIS without making a corresponding
139 * change to usertools/dpdk-pmdinfo.py
141 static const char dpdk_solib_path[] __rte_used =
142 "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
144 TAILQ_HEAD(device_option_list, device_option);
146 struct device_option {
147 TAILQ_ENTRY(device_option) next;
149 enum rte_devtype type;
153 static struct device_option_list devopt_list =
154 TAILQ_HEAD_INITIALIZER(devopt_list);
156 static int main_lcore_parsed;
157 static int mem_parsed;
158 static int core_parsed;
160 /* Allow the application to print its usage message too if set */
161 static rte_usage_hook_t rte_application_usage_hook;
163 /* Returns rte_usage_hook_t */
165 eal_get_application_usage_hook(void)
167 return rte_application_usage_hook;
170 /* Set a per-application usage message */
172 rte_set_application_usage_hook(rte_usage_hook_t usage_func)
174 rte_usage_hook_t old_func;
176 /* Will be NULL on the first call to denote the last usage routine. */
177 old_func = rte_application_usage_hook;
178 rte_application_usage_hook = usage_func;
183 #ifndef RTE_EXEC_ENV_WINDOWS
184 static char **eal_args;
185 static char **eal_app_args;
187 #define EAL_PARAM_REQ "/eal/params"
188 #define EAL_APP_PARAM_REQ "/eal/app_params"
190 /* callback handler for telemetry library to report out EAL flags */
192 handle_eal_info_request(const char *cmd, const char *params __rte_unused,
193 struct rte_tel_data *d)
199 if (strcmp(cmd, EAL_PARAM_REQ) == 0)
204 rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
205 if (args == NULL || args[0] == NULL)
208 for ( ; args[i] != NULL; i++)
209 used = rte_tel_data_add_array_string(d, args[i]);
214 eal_save_args(int argc, char **argv)
218 rte_telemetry_register_cmd(EAL_PARAM_REQ, handle_eal_info_request,
219 "Returns EAL commandline parameters used. Takes no parameters");
220 rte_telemetry_register_cmd(EAL_APP_PARAM_REQ, handle_eal_info_request,
221 "Returns app commandline parameters used. Takes no parameters");
223 /* clone argv to report out later. We overprovision, but
224 * this does not waste huge amounts of memory
226 eal_args = calloc(argc + 1, sizeof(*eal_args));
227 if (eal_args == NULL)
230 for (i = 0; i < argc; i++) {
231 eal_args[i] = strdup(argv[i]);
232 if (strcmp(argv[i], "--") == 0)
235 eal_args[i++] = NULL; /* always finish with NULL */
237 /* allow reporting of any app args we know about too */
241 eal_app_args = calloc(argc - i + 1, sizeof(*eal_args));
242 if (eal_app_args == NULL)
245 for (j = 0; i < argc; j++, i++)
246 eal_app_args[j] = strdup(argv[i]);
247 eal_app_args[j] = NULL;
254 eal_option_device_add(enum rte_devtype type, const char *optarg)
256 struct device_option *devopt;
260 optlen = strlen(optarg) + 1;
261 devopt = calloc(1, sizeof(*devopt) + optlen);
262 if (devopt == NULL) {
263 RTE_LOG(ERR, EAL, "Unable to allocate device option\n");
268 ret = strlcpy(devopt->arg, optarg, optlen);
270 RTE_LOG(ERR, EAL, "Unable to copy device option\n");
274 TAILQ_INSERT_TAIL(&devopt_list, devopt, next);
279 eal_option_device_parse(void)
281 struct device_option *devopt;
285 TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
287 ret = rte_devargs_add(devopt->type, devopt->arg);
289 RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n",
292 TAILQ_REMOVE(&devopt_list, devopt, next);
299 eal_get_hugefile_prefix(void)
301 const struct internal_config *internal_conf =
302 eal_get_internal_configuration();
304 if (internal_conf->hugefile_prefix != NULL)
305 return internal_conf->hugefile_prefix;
306 return HUGEFILE_PREFIX_DEFAULT;
310 eal_reset_internal_config(struct internal_config *internal_cfg)
314 internal_cfg->memory = 0;
315 internal_cfg->force_nrank = 0;
316 internal_cfg->force_nchannel = 0;
317 internal_cfg->hugefile_prefix = NULL;
318 internal_cfg->hugepage_dir = NULL;
319 internal_cfg->force_sockets = 0;
320 /* zero out the NUMA config */
321 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
322 internal_cfg->socket_mem[i] = 0;
323 internal_cfg->force_socket_limits = 0;
324 /* zero out the NUMA limits config */
325 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
326 internal_cfg->socket_limit[i] = 0;
327 /* zero out hugedir descriptors */
328 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) {
329 memset(&internal_cfg->hugepage_info[i], 0,
330 sizeof(internal_cfg->hugepage_info[0]));
331 internal_cfg->hugepage_info[i].lock_descriptor = -1;
333 internal_cfg->base_virtaddr = 0;
336 internal_cfg->syslog_facility = LOG_DAEMON;
339 /* if set to NONE, interrupt mode is determined automatically */
340 internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
341 memset(internal_cfg->vfio_vf_token, 0,
342 sizeof(internal_cfg->vfio_vf_token));
344 #ifdef RTE_LIBEAL_USE_HPET
345 internal_cfg->no_hpet = 0;
347 internal_cfg->no_hpet = 1;
349 internal_cfg->vmware_tsc_map = 0;
350 internal_cfg->create_uio_dev = 0;
351 internal_cfg->iova_mode = RTE_IOVA_DC;
352 internal_cfg->user_mbuf_pool_ops_name = NULL;
353 CPU_ZERO(&internal_cfg->ctrl_cpuset);
354 internal_cfg->init_complete = 0;
355 internal_cfg->max_simd_bitwidth.bitwidth = RTE_VECT_DEFAULT_SIMD_BITWIDTH;
356 internal_cfg->max_simd_bitwidth.forced = 0;
360 eal_plugin_add(const char *path)
362 struct shared_driver *solib;
364 solib = malloc(sizeof(*solib));
366 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
369 memset(solib, 0, sizeof(*solib));
370 strlcpy(solib->name, path, PATH_MAX);
371 TAILQ_INSERT_TAIL(&solib_list, solib, next);
376 #ifdef RTE_EXEC_ENV_WINDOWS
378 eal_plugins_init(void)
385 eal_plugindir_init(const char *path)
388 struct dirent *dent = NULL;
389 char sopath[PATH_MAX];
391 if (path == NULL || *path == '\0')
396 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
397 path, strerror(errno));
401 while ((dent = readdir(d)) != NULL) {
403 int nlen = strnlen(dent->d_name, sizeof(dent->d_name));
405 /* check if name ends in .so or .so.ABI_VERSION */
406 if (strcmp(&dent->d_name[nlen - 3], ".so") != 0 &&
407 strcmp(&dent->d_name[nlen - 4 - strlen(ABI_VERSION)],
408 ".so."ABI_VERSION) != 0)
411 snprintf(sopath, sizeof(sopath), "%s/%s", path, dent->d_name);
413 /* if a regular file, add to list to load */
414 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
417 if (eal_plugin_add(sopath) == -1)
422 /* XXX this ignores failures from readdir() itself */
423 return (dent == NULL) ? 0 : -1;
427 verify_perms(const char *dirpath)
431 /* if not root, check down one level first */
432 if (strcmp(dirpath, "/") != 0) {
433 static __thread char last_dir_checked[PATH_MAX];
437 strlcpy(copy, dirpath, PATH_MAX);
439 if (strncmp(dir, last_dir_checked, PATH_MAX) != 0) {
440 if (verify_perms(dir) != 0)
442 strlcpy(last_dir_checked, dir, PATH_MAX);
446 /* call stat to check for permissions and ensure not world writable */
447 if (stat(dirpath, &st) != 0) {
448 RTE_LOG(ERR, EAL, "Error with stat on %s, %s\n",
449 dirpath, strerror(errno));
452 if (st.st_mode & S_IWOTH) {
454 "Error, directory path %s is world-writable and insecure\n",
463 eal_dlopen(const char *pathname)
466 char *realp = realpath(pathname, NULL);
468 if (realp == NULL && errno == ENOENT) {
469 /* not a full or relative path, try a load from system dirs */
470 retval = dlopen(pathname, RTLD_NOW);
472 RTE_LOG(ERR, EAL, "%s\n", dlerror());
476 RTE_LOG(ERR, EAL, "Error with realpath for %s, %s\n",
477 pathname, strerror(errno));
480 if (strnlen(realp, PATH_MAX) == PATH_MAX) {
481 RTE_LOG(ERR, EAL, "Error, driver path greater than PATH_MAX\n");
485 /* do permissions checks */
486 if (verify_perms(realp) != 0)
489 retval = dlopen(realp, RTLD_NOW);
491 RTE_LOG(ERR, EAL, "%s\n", dlerror());
498 eal_plugins_init(void)
500 struct shared_driver *solib = NULL;
503 /* If we are not statically linked, add default driver loading
504 * path if it exists as a directory.
505 * (Using dlopen with NOLOAD flag on EAL, will return NULL if the EAL
506 * shared library is not already loaded i.e. it's statically linked.)
508 if (dlopen("librte_eal.so."ABI_VERSION, RTLD_LAZY | RTLD_NOLOAD) != NULL &&
509 *default_solib_dir != '\0' &&
510 stat(default_solib_dir, &sb) == 0 &&
512 eal_plugin_add(default_solib_dir);
514 TAILQ_FOREACH(solib, &solib_list, next) {
516 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
517 if (eal_plugindir_init(solib->name) == -1) {
519 "Cannot init plugin directory %s\n",
524 RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
526 solib->lib_handle = eal_dlopen(solib->name);
527 if (solib->lib_handle == NULL)
537 * Parse the coremask given as argument (hexadecimal string) and fill
538 * the global configuration (core role and core count) with the parsed
541 static int xdigit2val(unsigned char c)
555 eal_parse_service_coremask(const char *coremask)
557 struct rte_config *cfg = rte_eal_get_configuration();
559 unsigned int count = 0;
562 uint32_t taken_lcore_count = 0;
564 if (coremask == NULL)
566 /* Remove all blank characters ahead and after .
567 * Remove 0x/0X if exists.
569 while (isblank(*coremask))
571 if (coremask[0] == '0' && ((coremask[1] == 'x')
572 || (coremask[1] == 'X')))
574 i = strlen(coremask);
575 while ((i > 0) && isblank(coremask[i - 1]))
581 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
583 if (isxdigit(c) == 0) {
584 /* invalid characters */
588 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
590 if ((1 << j) & val) {
591 /* handle main lcore already parsed */
592 uint32_t lcore = idx;
593 if (main_lcore_parsed &&
594 cfg->main_lcore == lcore) {
596 "lcore %u is main lcore, cannot use as service core\n",
601 if (eal_cpu_detected(idx) == 0) {
603 "lcore %u unavailable\n", idx);
607 if (cfg->lcore_role[idx] == ROLE_RTE)
610 lcore_config[idx].core_role = ROLE_SERVICE;
617 if (coremask[i] != '0')
620 for (; idx < RTE_MAX_LCORE; idx++)
621 lcore_config[idx].core_index = -1;
626 if (core_parsed && taken_lcore_count != count) {
627 RTE_LOG(WARNING, EAL,
628 "Not all service cores are in the coremask. "
629 "Please ensure -c or -l includes service cores\n");
632 cfg->service_lcore_count = count;
637 eal_service_cores_parsed(void)
640 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
641 if (lcore_config[idx].core_role == ROLE_SERVICE)
648 update_lcore_config(int *cores)
650 struct rte_config *cfg = rte_eal_get_configuration();
651 unsigned int count = 0;
655 for (i = 0; i < RTE_MAX_LCORE; i++) {
656 if (cores[i] != -1) {
657 if (eal_cpu_detected(i) == 0) {
658 RTE_LOG(ERR, EAL, "lcore %u unavailable\n", i);
662 cfg->lcore_role[i] = ROLE_RTE;
665 cfg->lcore_role[i] = ROLE_OFF;
667 lcore_config[i].core_index = cores[i];
670 cfg->lcore_count = count;
675 eal_parse_coremask(const char *coremask, int *cores)
682 for (idx = 0; idx < RTE_MAX_LCORE; idx++)
686 /* Remove all blank characters ahead and after .
687 * Remove 0x/0X if exists.
689 while (isblank(*coremask))
691 if (coremask[0] == '0' && ((coremask[1] == 'x')
692 || (coremask[1] == 'X')))
694 i = strlen(coremask);
695 while ((i > 0) && isblank(coremask[i - 1]))
700 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
702 if (isxdigit(c) == 0) {
703 /* invalid characters */
707 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
709 if ((1 << j) & val) {
716 if (coremask[i] != '0')
724 eal_parse_service_corelist(const char *corelist)
726 struct rte_config *cfg = rte_eal_get_configuration();
731 uint32_t taken_lcore_count = 0;
733 if (corelist == NULL)
736 /* Remove all blank characters ahead and after */
737 while (isblank(*corelist))
739 i = strlen(corelist);
740 while ((i > 0) && isblank(corelist[i - 1]))
743 /* Get list of cores */
746 while (isblank(*corelist))
748 if (*corelist == '\0')
751 idx = strtoul(corelist, &end, 10);
752 if (errno || end == NULL)
754 while (isblank(*end))
758 } else if ((*end == ',') || (*end == '\0')) {
760 if (min == RTE_MAX_LCORE)
762 for (idx = min; idx <= max; idx++) {
763 if (cfg->lcore_role[idx] != ROLE_SERVICE) {
764 /* handle main lcore already parsed */
765 uint32_t lcore = idx;
766 if (cfg->main_lcore == lcore &&
769 "Error: lcore %u is main lcore, cannot use as service core\n",
773 if (cfg->lcore_role[idx] == ROLE_RTE)
776 lcore_config[idx].core_role =
785 } while (*end != '\0');
790 if (core_parsed && taken_lcore_count != count) {
791 RTE_LOG(WARNING, EAL,
792 "Not all service cores were in the coremask. "
793 "Please ensure -c or -l includes service cores\n");
800 eal_parse_corelist(const char *corelist, int *cores)
807 for (idx = 0; idx < RTE_MAX_LCORE; idx++)
810 /* Remove all blank characters ahead */
811 while (isblank(*corelist))
814 /* Get list of cores */
817 while (isblank(*corelist))
819 if (*corelist == '\0')
822 idx = strtol(corelist, &end, 10);
823 if (errno || end == NULL)
825 if (idx < 0 || idx >= RTE_MAX_LCORE)
827 while (isblank(*end))
831 } else if ((*end == ',') || (*end == '\0')) {
833 if (min == RTE_MAX_LCORE)
835 for (idx = min; idx <= max; idx++) {
836 if (cores[idx] == -1) {
845 } while (*end != '\0');
852 /* Changes the lcore id of the main thread */
854 eal_parse_main_lcore(const char *arg)
857 struct rte_config *cfg = rte_eal_get_configuration();
860 cfg->main_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
861 if (errno || parsing_end[0] != 0)
863 if (cfg->main_lcore >= RTE_MAX_LCORE)
865 main_lcore_parsed = 1;
867 /* ensure main core is not used as service core */
868 if (lcore_config[cfg->main_lcore].core_role == ROLE_SERVICE) {
870 "Error: Main lcore is used as a service core\n");
878 * Parse elem, the elem could be single number/range or '(' ')' group
879 * 1) A single number elem, it's just a simple digit. e.g. 9
880 * 2) A single range elem, two digits with a '-' between. e.g. 2-6
881 * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
882 * Within group elem, '-' used for a range separator;
883 * ',' used for a single number.
886 eal_parse_set(const char *input, rte_cpuset_t *set)
889 const char *str = input;
895 while (isblank(*str))
898 /* only digit or left bracket is qualify for start point */
899 if ((!isdigit(*str) && *str != '(') || *str == '\0')
902 /* process single number or single range of number */
905 idx = strtoul(str, &end, 10);
906 if (errno || end == NULL || idx >= CPU_SETSIZE)
909 while (isblank(*end))
915 /* process single <number>-<number> */
917 while (isblank(*end))
923 idx = strtoul(end, &end, 10);
924 if (errno || end == NULL || idx >= CPU_SETSIZE)
927 while (isblank(*end))
929 if (*end != ',' && *end != '\0')
933 if (*end != ',' && *end != '\0' &&
937 for (idx = RTE_MIN(min, max);
938 idx <= RTE_MAX(min, max); idx++)
945 /* process set within bracket */
947 while (isblank(*str))
955 /* go ahead to the first digit */
956 while (isblank(*str))
961 /* get the digit value */
963 idx = strtoul(str, &end, 10);
964 if (errno || end == NULL || idx >= CPU_SETSIZE)
967 /* go ahead to separator '-',',' and ')' */
968 while (isblank(*end))
971 if (min == RTE_MAX_LCORE)
973 else /* avoid continuous '-' */
975 } else if ((*end == ',') || (*end == ')')) {
977 if (min == RTE_MAX_LCORE)
979 for (idx = RTE_MIN(min, max);
980 idx <= RTE_MAX(min, max); idx++)
988 } while (*end != '\0' && *end != ')');
991 * to avoid failure that tail blank makes end character check fail
992 * in eal_parse_lcores( )
994 while (isblank(*str))
1001 check_cpuset(rte_cpuset_t *set)
1005 for (idx = 0; idx < CPU_SETSIZE; idx++) {
1006 if (!CPU_ISSET(idx, set))
1009 if (eal_cpu_detected(idx) == 0) {
1010 RTE_LOG(ERR, EAL, "core %u "
1011 "unavailable\n", idx);
1019 * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
1020 * lcores, cpus could be a single digit/range or a group.
1021 * '(' and ')' are necessary if it's a group.
1022 * If not supply '@cpus', the value of cpus uses the same as lcores.
1023 * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
1024 * lcore 0 runs on cpuset 0x41 (cpu 0,6)
1025 * lcore 1 runs on cpuset 0x2 (cpu 1)
1026 * lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
1027 * lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
1028 * lcore 6 runs on cpuset 0x41 (cpu 0,6)
1029 * lcore 7 runs on cpuset 0x80 (cpu 7)
1030 * lcore 8 runs on cpuset 0x100 (cpu 8)
1033 eal_parse_lcores(const char *lcores)
1035 struct rte_config *cfg = rte_eal_get_configuration();
1036 rte_cpuset_t lcore_set;
1037 unsigned int set_count;
1040 const char *lcore_start = NULL;
1041 const char *end = NULL;
1043 rte_cpuset_t cpuset;
1050 /* Remove all blank characters ahead and after */
1051 while (isblank(*lcores))
1056 /* Reset lcore config */
1057 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1058 cfg->lcore_role[idx] = ROLE_OFF;
1059 lcore_config[idx].core_index = -1;
1060 CPU_ZERO(&lcore_config[idx].cpuset);
1063 /* Get list of cores */
1065 while (isblank(*lcores))
1067 if (*lcores == '\0')
1072 /* record lcore_set start point */
1073 lcore_start = lcores;
1075 /* go across a complete bracket */
1076 if (*lcore_start == '(') {
1077 lcores += strcspn(lcores, ")");
1078 if (*lcores++ == '\0')
1082 /* scan the separator '@', ','(next) or '\0'(finish) */
1083 lcores += strcspn(lcores, "@,");
1085 if (*lcores == '@') {
1086 /* explicit assign cpuset and update the end cursor */
1087 offset = eal_parse_set(lcores + 1, &cpuset);
1090 end = lcores + 1 + offset;
1091 } else { /* ',' or '\0' */
1092 /* haven't given cpuset, current loop done */
1095 /* go back to check <number>-<number> */
1096 offset = strcspn(lcore_start, "(-");
1097 if (offset < (end - lcore_start) &&
1098 *(lcore_start + offset) != '(')
1102 if (*end != ',' && *end != '\0')
1105 /* parse lcore_set from start point */
1106 if (eal_parse_set(lcore_start, &lcore_set) < 0)
1109 /* without '@', by default using lcore_set as cpuset */
1111 rte_memcpy(&cpuset, &lcore_set, sizeof(cpuset));
1113 set_count = CPU_COUNT(&lcore_set);
1114 /* start to update lcore_set */
1115 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1116 if (!CPU_ISSET(idx, &lcore_set))
1120 if (cfg->lcore_role[idx] != ROLE_RTE) {
1121 lcore_config[idx].core_index = count;
1122 cfg->lcore_role[idx] = ROLE_RTE;
1128 CPU_SET(idx, &cpuset);
1131 if (check_cpuset(&cpuset) < 0)
1133 rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
1134 sizeof(rte_cpuset_t));
1137 /* some cores from the lcore_set can't be handled by EAL */
1142 } while (*end != '\0');
1147 cfg->lcore_count = count;
1155 #ifndef RTE_EXEC_ENV_WINDOWS
1157 eal_parse_syslog(const char *facility, struct internal_config *conf)
1160 static const struct {
1164 { "auth", LOG_AUTH },
1165 { "cron", LOG_CRON },
1166 { "daemon", LOG_DAEMON },
1168 { "kern", LOG_KERN },
1170 { "mail", LOG_MAIL },
1171 { "news", LOG_NEWS },
1172 { "syslog", LOG_SYSLOG },
1173 { "user", LOG_USER },
1174 { "uucp", LOG_UUCP },
1175 { "local0", LOG_LOCAL0 },
1176 { "local1", LOG_LOCAL1 },
1177 { "local2", LOG_LOCAL2 },
1178 { "local3", LOG_LOCAL3 },
1179 { "local4", LOG_LOCAL4 },
1180 { "local5", LOG_LOCAL5 },
1181 { "local6", LOG_LOCAL6 },
1182 { "local7", LOG_LOCAL7 },
1186 for (i = 0; map[i].name; i++) {
1187 if (!strcmp(facility, map[i].name)) {
1188 conf->syslog_facility = map[i].value;
1197 eal_parse_log_priority(const char *level)
1199 static const char * const levels[] = {
1200 [RTE_LOG_EMERG] = "emergency",
1201 [RTE_LOG_ALERT] = "alert",
1202 [RTE_LOG_CRIT] = "critical",
1203 [RTE_LOG_ERR] = "error",
1204 [RTE_LOG_WARNING] = "warning",
1205 [RTE_LOG_NOTICE] = "notice",
1206 [RTE_LOG_INFO] = "info",
1207 [RTE_LOG_DEBUG] = "debug",
1209 size_t len = strlen(level);
1217 /* look for named values, skip 0 which is not a valid level */
1218 for (i = 1; i < RTE_DIM(levels); i++) {
1219 if (strncmp(levels[i], level, len) == 0)
1223 /* not a string, maybe it is numeric */
1225 tmp = strtoul(level, &end, 0);
1227 /* check for errors */
1228 if (errno != 0 || end == NULL || *end != '\0' ||
1236 eal_parse_log_level(const char *arg)
1238 const char *pattern = NULL;
1239 const char *regex = NULL;
1247 if ((level = strchr(str, ','))) {
1250 } else if ((level = strchr(str, ':'))) {
1257 priority = eal_parse_log_priority(level);
1259 fprintf(stderr, "invalid log priority: %s\n", level);
1264 if (rte_log_set_level_regexp(regex, priority) < 0) {
1265 fprintf(stderr, "cannot set log level %s,%d\n",
1269 if (rte_log_save_regexp(regex, priority) < 0)
1271 } else if (pattern) {
1272 if (rte_log_set_level_pattern(pattern, priority) < 0) {
1273 fprintf(stderr, "cannot set log level %s:%d\n",
1277 if (rte_log_save_pattern(pattern, priority) < 0)
1280 rte_log_set_global_level(priority);
1291 static enum rte_proc_type_t
1292 eal_parse_proc_type(const char *arg)
1294 if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
1295 return RTE_PROC_PRIMARY;
1296 if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
1297 return RTE_PROC_SECONDARY;
1298 if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
1299 return RTE_PROC_AUTO;
1301 return RTE_PROC_INVALID;
1305 eal_parse_iova_mode(const char *name)
1308 struct internal_config *internal_conf =
1309 eal_get_internal_configuration();
1314 if (!strcmp("pa", name))
1316 else if (!strcmp("va", name))
1321 internal_conf->iova_mode = mode;
1326 eal_parse_simd_bitwidth(const char *arg)
1329 unsigned long bitwidth;
1331 struct internal_config *internal_conf =
1332 eal_get_internal_configuration();
1334 if (arg == NULL || arg[0] == '\0')
1338 bitwidth = strtoul(arg, &end, 0);
1340 /* check for errors */
1341 if (errno != 0 || end == NULL || *end != '\0' || bitwidth > RTE_VECT_SIMD_MAX)
1345 bitwidth = (unsigned long) RTE_VECT_SIMD_MAX;
1346 ret = rte_vect_set_max_simd_bitwidth(bitwidth);
1349 internal_conf->max_simd_bitwidth.forced = 1;
1354 eal_parse_base_virtaddr(const char *arg)
1358 struct internal_config *internal_conf =
1359 eal_get_internal_configuration();
1362 addr = strtoull(arg, &end, 16);
1364 /* check for errors */
1365 if ((errno != 0) || (arg[0] == '\0') || end == NULL || (*end != '\0'))
1368 /* make sure we don't exceed 32-bit boundary on 32-bit target */
1370 if (addr >= UINTPTR_MAX)
1374 /* align the addr on 16M boundary, 16MB is the minimum huge page
1375 * size on IBM Power architecture. If the addr is aligned to 16MB,
1376 * it can align to 2MB for x86. So this alignment can also be used
1377 * on x86 and other architectures.
1379 internal_conf->base_virtaddr =
1380 RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M);
1385 /* caller is responsible for freeing the returned string */
1387 available_cores(void)
1395 /* find the first available cpu */
1396 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1397 if (eal_cpu_detected(idx) == 0)
1401 if (idx >= RTE_MAX_LCORE)
1404 /* first sequence */
1405 if (asprintf(&str, "%d", idx) < 0)
1410 for (idx++ ; idx < RTE_MAX_LCORE; idx++) {
1411 if (eal_cpu_detected(idx) == 0)
1414 if (idx == previous + 1) {
1420 /* finish current sequence */
1422 if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
1431 if (asprintf(&tmp, "%s,%d", str, idx) < 0) {
1441 /* finish last sequence */
1443 if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
1455 eal_parse_common_option(int opt, const char *optarg,
1456 struct internal_config *conf)
1462 case OPT_PCI_BLACKLIST_NUM:
1464 "Option --pci-blacklist is deprecated, use -b, --block instead\n");
1469 if (eal_option_device_add(RTE_DEVTYPE_BLOCKED, optarg) < 0)
1476 "Option -w, --pci-whitelist is deprecated, use -a, --allow option instead\n");
1481 if (eal_option_device_add(RTE_DEVTYPE_ALLOWED, optarg) < 0)
1487 int lcore_indexes[RTE_MAX_LCORE];
1489 if (eal_service_cores_parsed())
1490 RTE_LOG(WARNING, EAL,
1491 "Service cores parsed before dataplane cores. Please ensure -c is before -s or -S\n");
1492 if (eal_parse_coremask(optarg, lcore_indexes) < 0) {
1493 RTE_LOG(ERR, EAL, "invalid coremask syntax\n");
1496 if (update_lcore_config(lcore_indexes) < 0) {
1497 char *available = available_cores();
1500 "invalid coremask, please check specified cores are part of %s\n",
1507 RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s) is set!\n",
1508 (core_parsed == LCORE_OPT_LST) ? "-l" :
1509 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1514 core_parsed = LCORE_OPT_MSK;
1519 int lcore_indexes[RTE_MAX_LCORE];
1521 if (eal_service_cores_parsed())
1522 RTE_LOG(WARNING, EAL,
1523 "Service cores parsed before dataplane cores. Please ensure -l is before -s or -S\n");
1525 if (eal_parse_corelist(optarg, lcore_indexes) < 0) {
1526 RTE_LOG(ERR, EAL, "invalid core list syntax\n");
1529 if (update_lcore_config(lcore_indexes) < 0) {
1530 char *available = available_cores();
1533 "invalid core list, please check specified cores are part of %s\n",
1540 RTE_LOG(ERR, EAL, "Option -l is ignored, because (%s) is set!\n",
1541 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1542 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1547 core_parsed = LCORE_OPT_LST;
1550 /* service coremask */
1552 if (eal_parse_service_coremask(optarg) < 0) {
1553 RTE_LOG(ERR, EAL, "invalid service coremask\n");
1557 /* service corelist */
1559 if (eal_parse_service_corelist(optarg) < 0) {
1560 RTE_LOG(ERR, EAL, "invalid service core list\n");
1564 /* size of memory */
1566 conf->memory = atoi(optarg);
1567 conf->memory *= 1024ULL;
1568 conf->memory *= 1024ULL;
1571 /* force number of channels */
1573 conf->force_nchannel = atoi(optarg);
1574 if (conf->force_nchannel == 0) {
1575 RTE_LOG(ERR, EAL, "invalid channel number\n");
1579 /* force number of ranks */
1581 conf->force_nrank = atoi(optarg);
1582 if (conf->force_nrank == 0 ||
1583 conf->force_nrank > 16) {
1584 RTE_LOG(ERR, EAL, "invalid rank number\n");
1588 /* force loading of external driver */
1590 if (eal_plugin_add(optarg) == -1)
1594 /* since message is explicitly requested by user, we
1595 * write message at highest log level so it can always
1597 * even if info or warning messages are disabled */
1598 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
1602 case OPT_HUGE_UNLINK_NUM:
1603 conf->hugepage_unlink = 1;
1606 case OPT_NO_HUGE_NUM:
1607 conf->no_hugetlbfs = 1;
1608 /* no-huge is legacy mem */
1609 conf->legacy_mem = 1;
1612 case OPT_NO_PCI_NUM:
1616 case OPT_NO_HPET_NUM:
1620 case OPT_VMWARE_TSC_MAP_NUM:
1621 conf->vmware_tsc_map = 1;
1624 case OPT_NO_SHCONF_NUM:
1625 conf->no_shconf = 1;
1628 case OPT_IN_MEMORY_NUM:
1629 conf->in_memory = 1;
1630 /* in-memory is a superset of noshconf and huge-unlink */
1631 conf->no_shconf = 1;
1632 conf->hugepage_unlink = 1;
1635 case OPT_PROC_TYPE_NUM:
1636 conf->process_type = eal_parse_proc_type(optarg);
1639 case OPT_MASTER_LCORE_NUM:
1641 "Option --" OPT_MASTER_LCORE
1642 " is deprecated use " OPT_MAIN_LCORE "\n");
1644 case OPT_MAIN_LCORE_NUM:
1645 if (eal_parse_main_lcore(optarg) < 0) {
1646 RTE_LOG(ERR, EAL, "invalid parameter for --"
1647 OPT_MAIN_LCORE "\n");
1653 if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1659 #ifndef RTE_EXEC_ENV_WINDOWS
1660 case OPT_SYSLOG_NUM:
1661 if (eal_parse_syslog(optarg, conf) < 0) {
1662 RTE_LOG(ERR, EAL, "invalid parameters for --"
1669 case OPT_LOG_LEVEL_NUM: {
1670 if (eal_parse_log_level(optarg) < 0) {
1672 "invalid parameters for --"
1673 OPT_LOG_LEVEL "\n");
1679 #ifndef RTE_EXEC_ENV_WINDOWS
1680 case OPT_TRACE_NUM: {
1681 if (eal_trace_args_save(optarg) < 0) {
1682 RTE_LOG(ERR, EAL, "invalid parameters for --"
1689 case OPT_TRACE_DIR_NUM: {
1690 if (eal_trace_dir_args_save(optarg) < 0) {
1691 RTE_LOG(ERR, EAL, "invalid parameters for --"
1692 OPT_TRACE_DIR "\n");
1698 case OPT_TRACE_BUF_SIZE_NUM: {
1699 if (eal_trace_bufsz_args_save(optarg) < 0) {
1700 RTE_LOG(ERR, EAL, "invalid parameters for --"
1701 OPT_TRACE_BUF_SIZE "\n");
1707 case OPT_TRACE_MODE_NUM: {
1708 if (eal_trace_mode_args_save(optarg) < 0) {
1709 RTE_LOG(ERR, EAL, "invalid parameters for --"
1710 OPT_TRACE_MODE "\n");
1715 #endif /* !RTE_EXEC_ENV_WINDOWS */
1717 case OPT_LCORES_NUM:
1718 if (eal_parse_lcores(optarg) < 0) {
1719 RTE_LOG(ERR, EAL, "invalid parameter for --"
1725 RTE_LOG(ERR, EAL, "Option --lcore is ignored, because (%s) is set!\n",
1726 (core_parsed == LCORE_OPT_LST) ? "-l" :
1727 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1732 core_parsed = LCORE_OPT_MAP;
1734 case OPT_LEGACY_MEM_NUM:
1735 conf->legacy_mem = 1;
1737 case OPT_SINGLE_FILE_SEGMENTS_NUM:
1738 conf->single_file_segments = 1;
1740 case OPT_IOVA_MODE_NUM:
1741 if (eal_parse_iova_mode(optarg) < 0) {
1742 RTE_LOG(ERR, EAL, "invalid parameters for --"
1743 OPT_IOVA_MODE "\n");
1747 case OPT_BASE_VIRTADDR_NUM:
1748 if (eal_parse_base_virtaddr(optarg) < 0) {
1749 RTE_LOG(ERR, EAL, "invalid parameter for --"
1750 OPT_BASE_VIRTADDR "\n");
1754 case OPT_TELEMETRY_NUM:
1756 case OPT_NO_TELEMETRY_NUM:
1757 conf->no_telemetry = 1;
1759 case OPT_FORCE_MAX_SIMD_BITWIDTH_NUM:
1760 if (eal_parse_simd_bitwidth(optarg) < 0) {
1761 RTE_LOG(ERR, EAL, "invalid parameter for --"
1762 OPT_FORCE_MAX_SIMD_BITWIDTH "\n");
1767 /* don't know what to do, leave this to caller */
1777 "Options allow (-a) and block (-b) can't be used at the same time\n");
1782 eal_auto_detect_cores(struct rte_config *cfg)
1784 unsigned int lcore_id;
1785 unsigned int removed = 0;
1786 rte_cpuset_t affinity_set;
1788 if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
1790 CPU_ZERO(&affinity_set);
1792 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1793 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1794 !CPU_ISSET(lcore_id, &affinity_set)) {
1795 cfg->lcore_role[lcore_id] = ROLE_OFF;
1800 cfg->lcore_count -= removed;
1804 compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
1806 rte_cpuset_t *cpuset = &internal_cfg->ctrl_cpuset;
1807 rte_cpuset_t default_set;
1808 unsigned int lcore_id;
1810 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1811 if (rte_lcore_has_role(lcore_id, ROLE_OFF))
1813 RTE_CPU_OR(cpuset, cpuset, &lcore_config[lcore_id].cpuset);
1815 RTE_CPU_NOT(cpuset, cpuset);
1817 if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
1819 CPU_ZERO(&default_set);
1821 RTE_CPU_AND(cpuset, cpuset, &default_set);
1823 /* if no remaining cpu, use main lcore cpu affinity */
1824 if (!CPU_COUNT(cpuset)) {
1825 memcpy(cpuset, &lcore_config[rte_get_main_lcore()].cpuset,
1831 eal_cleanup_config(struct internal_config *internal_cfg)
1833 if (internal_cfg->hugefile_prefix != NULL)
1834 free(internal_cfg->hugefile_prefix);
1835 if (internal_cfg->hugepage_dir != NULL)
1836 free(internal_cfg->hugepage_dir);
1837 if (internal_cfg->user_mbuf_pool_ops_name != NULL)
1838 free(internal_cfg->user_mbuf_pool_ops_name);
1844 eal_adjust_config(struct internal_config *internal_cfg)
1847 struct rte_config *cfg = rte_eal_get_configuration();
1848 struct internal_config *internal_conf =
1849 eal_get_internal_configuration();
1852 eal_auto_detect_cores(cfg);
1854 if (internal_conf->process_type == RTE_PROC_AUTO)
1855 internal_conf->process_type = eal_proc_type_detect();
1857 /* default main lcore is the first one */
1858 if (!main_lcore_parsed) {
1859 cfg->main_lcore = rte_get_next_lcore(-1, 0, 0);
1860 if (cfg->main_lcore >= RTE_MAX_LCORE)
1862 lcore_config[cfg->main_lcore].core_role = ROLE_RTE;
1865 compute_ctrl_threads_cpuset(internal_cfg);
1867 /* if no memory amounts were requested, this will result in 0 and
1868 * will be overridden later, right after eal_hugepage_info_init() */
1869 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1870 internal_cfg->memory += internal_cfg->socket_mem[i];
1876 eal_check_common_options(struct internal_config *internal_cfg)
1878 struct rte_config *cfg = rte_eal_get_configuration();
1879 const struct internal_config *internal_conf =
1880 eal_get_internal_configuration();
1882 if (cfg->lcore_role[cfg->main_lcore] != ROLE_RTE) {
1883 RTE_LOG(ERR, EAL, "Main lcore is not enabled for DPDK\n");
1887 if (internal_cfg->process_type == RTE_PROC_INVALID) {
1888 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1891 if (internal_cfg->hugefile_prefix != NULL &&
1892 strlen(internal_cfg->hugefile_prefix) < 1) {
1893 RTE_LOG(ERR, EAL, "Invalid length of --" OPT_FILE_PREFIX " option\n");
1896 if (internal_cfg->hugepage_dir != NULL &&
1897 strlen(internal_cfg->hugepage_dir) < 1) {
1898 RTE_LOG(ERR, EAL, "Invalid length of --" OPT_HUGE_DIR" option\n");
1901 if (internal_cfg->user_mbuf_pool_ops_name != NULL &&
1902 strlen(internal_cfg->user_mbuf_pool_ops_name) < 1) {
1903 RTE_LOG(ERR, EAL, "Invalid length of --" OPT_MBUF_POOL_OPS_NAME" option\n");
1906 if (index(eal_get_hugefile_prefix(), '%') != NULL) {
1907 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1911 if (mem_parsed && internal_cfg->force_sockets == 1) {
1912 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1913 "be specified at the same time\n");
1916 if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1917 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1918 "be specified together with --"OPT_NO_HUGE"\n");
1921 if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink &&
1922 !internal_cfg->in_memory) {
1923 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1924 "be specified together with --"OPT_NO_HUGE"\n");
1927 if (internal_conf->force_socket_limits && internal_conf->legacy_mem) {
1928 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_LIMIT
1929 " is only supported in non-legacy memory mode\n");
1931 if (internal_cfg->single_file_segments &&
1932 internal_cfg->hugepage_unlink &&
1933 !internal_cfg->in_memory) {
1934 RTE_LOG(ERR, EAL, "Option --"OPT_SINGLE_FILE_SEGMENTS" is "
1935 "not compatible with --"OPT_HUGE_UNLINK"\n");
1938 if (internal_cfg->legacy_mem &&
1939 internal_cfg->in_memory) {
1940 RTE_LOG(ERR, EAL, "Option --"OPT_LEGACY_MEM" is not compatible "
1941 "with --"OPT_IN_MEMORY"\n");
1944 if (internal_cfg->legacy_mem && internal_cfg->match_allocations) {
1945 RTE_LOG(ERR, EAL, "Option --"OPT_LEGACY_MEM" is not compatible "
1946 "with --"OPT_MATCH_ALLOCATIONS"\n");
1949 if (internal_cfg->no_hugetlbfs && internal_cfg->match_allocations) {
1950 RTE_LOG(ERR, EAL, "Option --"OPT_NO_HUGE" is not compatible "
1951 "with --"OPT_MATCH_ALLOCATIONS"\n");
1954 if (internal_cfg->legacy_mem && internal_cfg->memory == 0) {
1955 RTE_LOG(NOTICE, EAL, "Static memory layout is selected, "
1956 "amount of reserved memory can be adjusted with "
1957 "-m or --"OPT_SOCKET_MEM"\n");
1964 rte_vect_get_max_simd_bitwidth(void)
1966 const struct internal_config *internal_conf =
1967 eal_get_internal_configuration();
1968 return internal_conf->max_simd_bitwidth.bitwidth;
1972 rte_vect_set_max_simd_bitwidth(uint16_t bitwidth)
1974 struct internal_config *internal_conf =
1975 eal_get_internal_configuration();
1976 if (internal_conf->max_simd_bitwidth.forced) {
1977 RTE_LOG(NOTICE, EAL, "Cannot set max SIMD bitwidth - user runtime override enabled");
1981 if (bitwidth < RTE_VECT_SIMD_DISABLED || !rte_is_power_of_2(bitwidth)) {
1982 RTE_LOG(ERR, EAL, "Invalid bitwidth value!\n");
1985 internal_conf->max_simd_bitwidth.bitwidth = bitwidth;
1990 eal_common_usage(void)
1992 printf("[options]\n\n"
1993 "EAL common options:\n"
1994 " -c COREMASK Hexadecimal bitmask of cores to run on\n"
1995 " -l CORELIST List of cores to run on\n"
1996 " The argument format is <c1>[-c2][,c3[-c4],...]\n"
1997 " where c1, c2, etc are core indexes between 0 and %d\n"
1998 " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
1999 " The argument format is\n"
2000 " '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
2001 " lcores and cpus list are grouped by '(' and ')'\n"
2002 " Within the group, '-' is used for range separator,\n"
2003 " ',' is used for single number separator.\n"
2004 " '( )' can be omitted for single element group,\n"
2005 " '@' can be omitted if cpus and lcores have the same value\n"
2006 " -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
2007 " --"OPT_MAIN_LCORE" ID Core ID that is used as main\n"
2008 " --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
2009 " -n CHANNELS Number of memory channels\n"
2010 " -m MB Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
2011 " -r RANKS Force number of memory ranks (don't detect)\n"
2012 " -b, --block Add a device to the blocked list.\n"
2013 " Prevent EAL from using this device. The argument\n"
2014 " format for PCI devices is <domain:bus:devid.func>.\n"
2015 " -a, --allow Add a device to the allow list.\n"
2016 " Only use the specified devices. The argument format\n"
2017 " for PCI devices is <[domain:]bus:devid.func>.\n"
2018 " This option can be present several times.\n"
2019 " [NOTE: " OPT_DEV_ALLOW " cannot be used with "OPT_DEV_BLOCK" option]\n"
2020 " --"OPT_VDEV" Add a virtual device.\n"
2021 " The argument format is <driver><id>[,key=val,...]\n"
2022 " (ex: --vdev=net_pcap0,iface=eth2).\n"
2023 " --"OPT_IOVA_MODE" Set IOVA mode. 'pa' for IOVA_PA\n"
2024 " 'va' for IOVA_VA\n"
2025 " -d LIB.so|DIR Add a driver or driver directory\n"
2026 " (can be used multiple times)\n"
2027 " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n"
2028 " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n"
2029 #ifndef RTE_EXEC_ENV_WINDOWS
2030 " --"OPT_SYSLOG" Set syslog facility\n"
2032 " --"OPT_LOG_LEVEL"=<int> Set global log level\n"
2033 " --"OPT_LOG_LEVEL"=<type-match>:<int>\n"
2034 " Set specific log level\n"
2035 #ifndef RTE_EXEC_ENV_WINDOWS
2036 " --"OPT_TRACE"=<regex-match>\n"
2037 " Enable trace based on regular expression trace name.\n"
2038 " By default, the trace is disabled.\n"
2039 " User must specify this option to enable trace.\n"
2040 " --"OPT_TRACE_DIR"=<directory path>\n"
2041 " Specify trace directory for trace output.\n"
2042 " By default, trace output will created at\n"
2043 " $HOME directory and parameter must be\n"
2044 " specified once only.\n"
2045 " --"OPT_TRACE_BUF_SIZE"=<int>\n"
2046 " Specify maximum size of allocated memory\n"
2047 " for trace output for each thread. Valid\n"
2048 " unit can be either 'B|K|M' for 'Bytes',\n"
2049 " 'KBytes' and 'MBytes' respectively.\n"
2050 " Default is 1MB and parameter must be\n"
2051 " specified once only.\n"
2052 " --"OPT_TRACE_MODE"=<o[verwrite] | d[iscard]>\n"
2053 " Specify the mode of update of trace\n"
2054 " output file. Either update on a file can\n"
2055 " be wrapped or discarded when file size\n"
2056 " reaches its maximum limit.\n"
2057 " Default mode is 'overwrite' and parameter\n"
2058 " must be specified once only.\n"
2059 #endif /* !RTE_EXEC_ENV_WINDOWS */
2060 " -v Display version information on startup\n"
2061 " -h, --help This help\n"
2062 " --"OPT_IN_MEMORY" Operate entirely in memory. This will\n"
2063 " disable secondary process support\n"
2064 " --"OPT_BASE_VIRTADDR" Base virtual address\n"
2065 " --"OPT_TELEMETRY" Enable telemetry support (on by default)\n"
2066 " --"OPT_NO_TELEMETRY" Disable telemetry support\n"
2067 " --"OPT_FORCE_MAX_SIMD_BITWIDTH" Force the max SIMD bitwidth\n"
2068 "\nEAL options for DEBUG use only:\n"
2069 " --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n"
2070 " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
2071 " --"OPT_NO_PCI" Disable PCI\n"
2072 " --"OPT_NO_HPET" Disable HPET\n"
2073 " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
2074 "\n", RTE_MAX_LCORE);