1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
15 #include <sys/types.h>
21 #include <rte_lcore.h>
22 #include <rte_tailq.h>
23 #include <rte_version.h>
24 #include <rte_devargs.h>
25 #include <rte_memcpy.h>
27 #include "eal_internal_cfg.h"
28 #include "eal_options.h"
29 #include "eal_filesystem.h"
31 #define BITS_PER_HEX 4
32 #define LCORE_OPT_LST 1
33 #define LCORE_OPT_MSK 2
34 #define LCORE_OPT_MAP 3
38 "b:" /* pci-blacklist */
40 "s:" /* service coremask */
44 "S:" /* service corelist */
45 "m:" /* memory size */
46 "n:" /* memory channels */
47 "r:" /* memory ranks */
49 "w:" /* pci-whitelist */
53 eal_long_options[] = {
54 {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM },
55 {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM },
56 {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM },
57 {OPT_HELP, 0, NULL, OPT_HELP_NUM },
58 {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
59 {OPT_HUGE_UNLINK, 0, NULL, OPT_HUGE_UNLINK_NUM },
60 {OPT_LCORES, 1, NULL, OPT_LCORES_NUM },
61 {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM },
62 {OPT_MASTER_LCORE, 1, NULL, OPT_MASTER_LCORE_NUM },
63 {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
64 {OPT_NO_HPET, 0, NULL, OPT_NO_HPET_NUM },
65 {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM },
66 {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM },
67 {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM },
68 {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM },
69 {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM },
70 {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM },
71 {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM },
72 {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
73 {OPT_VDEV, 1, NULL, OPT_VDEV_NUM },
74 {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM },
75 {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
76 {OPT_LEGACY_MEM, 0, NULL, OPT_LEGACY_MEM_NUM },
77 {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
81 TAILQ_HEAD(shared_driver_list, shared_driver);
83 /* Definition for shared object drivers. */
84 struct shared_driver {
85 TAILQ_ENTRY(shared_driver) next;
91 /* List of external loadable drivers */
92 static struct shared_driver_list solib_list =
93 TAILQ_HEAD_INITIALIZER(solib_list);
95 /* Default path of external loadable drivers */
96 static const char *default_solib_dir = RTE_EAL_PMD_PATH;
99 * Stringified version of solib path used by dpdk-pmdinfo.py
100 * Note: PLEASE DO NOT ALTER THIS without making a corresponding
101 * change to usertools/dpdk-pmdinfo.py
103 static const char dpdk_solib_path[] __attribute__((used)) =
104 "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
106 TAILQ_HEAD(device_option_list, device_option);
108 struct device_option {
109 TAILQ_ENTRY(device_option) next;
111 enum rte_devtype type;
115 static struct device_option_list devopt_list =
116 TAILQ_HEAD_INITIALIZER(devopt_list);
118 static int master_lcore_parsed;
119 static int mem_parsed;
120 static int core_parsed;
123 eal_option_device_add(enum rte_devtype type, const char *optarg)
125 struct device_option *devopt;
129 optlen = strlen(optarg) + 1;
130 devopt = calloc(1, sizeof(*devopt) + optlen);
131 if (devopt == NULL) {
132 RTE_LOG(ERR, EAL, "Unable to allocate device option\n");
137 ret = snprintf(devopt->arg, optlen, "%s", optarg);
139 RTE_LOG(ERR, EAL, "Unable to copy device option\n");
143 TAILQ_INSERT_TAIL(&devopt_list, devopt, next);
148 eal_option_device_parse(void)
150 struct device_option *devopt;
154 TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
156 ret = rte_devargs_add(devopt->type, devopt->arg);
158 RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n",
161 TAILQ_REMOVE(&devopt_list, devopt, next);
168 eal_reset_internal_config(struct internal_config *internal_cfg)
172 internal_cfg->memory = 0;
173 internal_cfg->force_nrank = 0;
174 internal_cfg->force_nchannel = 0;
175 internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
176 internal_cfg->hugepage_dir = NULL;
177 internal_cfg->force_sockets = 0;
178 /* zero out the NUMA config */
179 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
180 internal_cfg->socket_mem[i] = 0;
181 /* zero out hugedir descriptors */
182 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) {
183 memset(&internal_cfg->hugepage_info[i], 0,
184 sizeof(internal_cfg->hugepage_info[0]));
185 internal_cfg->hugepage_info[i].lock_descriptor = -1;
187 internal_cfg->base_virtaddr = 0;
189 internal_cfg->syslog_facility = LOG_DAEMON;
191 /* if set to NONE, interrupt mode is determined automatically */
192 internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
194 #ifdef RTE_LIBEAL_USE_HPET
195 internal_cfg->no_hpet = 0;
197 internal_cfg->no_hpet = 1;
199 internal_cfg->vmware_tsc_map = 0;
200 internal_cfg->create_uio_dev = 0;
201 internal_cfg->user_mbuf_pool_ops_name = NULL;
202 internal_cfg->init_complete = 0;
206 eal_plugin_add(const char *path)
208 struct shared_driver *solib;
210 solib = malloc(sizeof(*solib));
212 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
215 memset(solib, 0, sizeof(*solib));
216 strncpy(solib->name, path, PATH_MAX-1);
217 solib->name[PATH_MAX-1] = 0;
218 TAILQ_INSERT_TAIL(&solib_list, solib, next);
224 eal_plugindir_init(const char *path)
227 struct dirent *dent = NULL;
228 char sopath[PATH_MAX];
230 if (path == NULL || *path == '\0')
235 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
236 path, strerror(errno));
240 while ((dent = readdir(d)) != NULL) {
243 snprintf(sopath, PATH_MAX-1, "%s/%s", path, dent->d_name);
244 sopath[PATH_MAX-1] = 0;
246 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
249 if (eal_plugin_add(sopath) == -1)
254 /* XXX this ignores failures from readdir() itself */
255 return (dent == NULL) ? 0 : -1;
259 eal_plugins_init(void)
261 struct shared_driver *solib = NULL;
264 if (*default_solib_dir != '\0' && stat(default_solib_dir, &sb) == 0 &&
266 eal_plugin_add(default_solib_dir);
268 TAILQ_FOREACH(solib, &solib_list, next) {
270 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
271 if (eal_plugindir_init(solib->name) == -1) {
273 "Cannot init plugin directory %s\n",
278 RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
280 solib->lib_handle = dlopen(solib->name, RTLD_NOW);
281 if (solib->lib_handle == NULL) {
282 RTE_LOG(ERR, EAL, "%s\n", dlerror());
292 * Parse the coremask given as argument (hexadecimal string) and fill
293 * the global configuration (core role and core count) with the parsed
296 static int xdigit2val(unsigned char c)
310 eal_parse_service_coremask(const char *coremask)
312 struct rte_config *cfg = rte_eal_get_configuration();
314 unsigned int count = 0;
318 if (coremask == NULL)
320 /* Remove all blank characters ahead and after .
321 * Remove 0x/0X if exists.
323 while (isblank(*coremask))
325 if (coremask[0] == '0' && ((coremask[1] == 'x')
326 || (coremask[1] == 'X')))
328 i = strlen(coremask);
329 while ((i > 0) && isblank(coremask[i - 1]))
335 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
337 if (isxdigit(c) == 0) {
338 /* invalid characters */
342 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
344 if ((1 << j) & val) {
345 /* handle master lcore already parsed */
346 uint32_t lcore = idx;
347 if (master_lcore_parsed &&
348 cfg->master_lcore == lcore) {
350 "Error: lcore %u is master lcore, cannot use as service core\n",
355 if (!lcore_config[idx].detected) {
357 "lcore %u unavailable\n", idx);
360 lcore_config[idx].core_role = ROLE_SERVICE;
367 if (coremask[i] != '0')
370 for (; idx < RTE_MAX_LCORE; idx++)
371 lcore_config[idx].core_index = -1;
376 cfg->service_lcore_count = count;
381 eal_parse_coremask(const char *coremask)
383 struct rte_config *cfg = rte_eal_get_configuration();
389 if (coremask == NULL)
391 /* Remove all blank characters ahead and after .
392 * Remove 0x/0X if exists.
394 while (isblank(*coremask))
396 if (coremask[0] == '0' && ((coremask[1] == 'x')
397 || (coremask[1] == 'X')))
399 i = strlen(coremask);
400 while ((i > 0) && isblank(coremask[i - 1]))
405 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
407 if (isxdigit(c) == 0) {
408 /* invalid characters */
412 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
414 if ((1 << j) & val) {
415 if (!lcore_config[idx].detected) {
416 RTE_LOG(ERR, EAL, "lcore %u "
417 "unavailable\n", idx);
420 cfg->lcore_role[idx] = ROLE_RTE;
421 lcore_config[idx].core_index = count;
424 cfg->lcore_role[idx] = ROLE_OFF;
425 lcore_config[idx].core_index = -1;
430 if (coremask[i] != '0')
432 for (; idx < RTE_MAX_LCORE; idx++) {
433 cfg->lcore_role[idx] = ROLE_OFF;
434 lcore_config[idx].core_index = -1;
438 /* Update the count of enabled logical cores of the EAL configuration */
439 cfg->lcore_count = count;
444 eal_parse_service_corelist(const char *corelist)
446 struct rte_config *cfg = rte_eal_get_configuration();
452 if (corelist == NULL)
455 /* Remove all blank characters ahead and after */
456 while (isblank(*corelist))
458 i = strlen(corelist);
459 while ((i > 0) && isblank(corelist[i - 1]))
462 /* Get list of cores */
465 while (isblank(*corelist))
467 if (*corelist == '\0')
470 idx = strtoul(corelist, &end, 10);
471 if (errno || end == NULL)
473 while (isblank(*end))
477 } else if ((*end == ',') || (*end == '\0')) {
479 if (min == RTE_MAX_LCORE)
481 for (idx = min; idx <= max; idx++) {
482 if (cfg->lcore_role[idx] != ROLE_SERVICE) {
483 /* handle master lcore already parsed */
484 uint32_t lcore = idx;
485 if (cfg->master_lcore == lcore &&
486 master_lcore_parsed) {
488 "Error: lcore %u is master lcore, cannot use as service core\n",
492 lcore_config[idx].core_role =
501 } while (*end != '\0');
510 eal_parse_corelist(const char *corelist)
512 struct rte_config *cfg = rte_eal_get_configuration();
518 if (corelist == NULL)
521 /* Remove all blank characters ahead and after */
522 while (isblank(*corelist))
524 i = strlen(corelist);
525 while ((i > 0) && isblank(corelist[i - 1]))
529 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
530 cfg->lcore_role[idx] = ROLE_OFF;
531 lcore_config[idx].core_index = -1;
534 /* Get list of cores */
537 while (isblank(*corelist))
539 if (*corelist == '\0')
542 idx = strtoul(corelist, &end, 10);
543 if (errno || end == NULL)
545 while (isblank(*end))
549 } else if ((*end == ',') || (*end == '\0')) {
551 if (min == RTE_MAX_LCORE)
553 for (idx = min; idx <= max; idx++) {
554 if (cfg->lcore_role[idx] != ROLE_RTE) {
555 cfg->lcore_role[idx] = ROLE_RTE;
556 lcore_config[idx].core_index = count;
564 } while (*end != '\0');
569 /* Update the count of enabled logical cores of the EAL configuration */
570 cfg->lcore_count = count;
575 /* Changes the lcore id of the master thread */
577 eal_parse_master_lcore(const char *arg)
580 struct rte_config *cfg = rte_eal_get_configuration();
583 cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
584 if (errno || parsing_end[0] != 0)
586 if (cfg->master_lcore >= RTE_MAX_LCORE)
588 master_lcore_parsed = 1;
590 /* ensure master core is not used as service core */
591 if (lcore_config[cfg->master_lcore].core_role == ROLE_SERVICE) {
592 RTE_LOG(ERR, EAL, "Error: Master lcore is used as a service core.\n");
600 * Parse elem, the elem could be single number/range or '(' ')' group
601 * 1) A single number elem, it's just a simple digit. e.g. 9
602 * 2) A single range elem, two digits with a '-' between. e.g. 2-6
603 * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
604 * Within group elem, '-' used for a range separator;
605 * ',' used for a single number.
608 eal_parse_set(const char *input, uint16_t set[], unsigned num)
611 const char *str = input;
615 memset(set, 0, num * sizeof(uint16_t));
617 while (isblank(*str))
620 /* only digit or left bracket is qualify for start point */
621 if ((!isdigit(*str) && *str != '(') || *str == '\0')
624 /* process single number or single range of number */
627 idx = strtoul(str, &end, 10);
628 if (errno || end == NULL || idx >= num)
631 while (isblank(*end))
637 /* process single <number>-<number> */
639 while (isblank(*end))
645 idx = strtoul(end, &end, 10);
646 if (errno || end == NULL || idx >= num)
649 while (isblank(*end))
651 if (*end != ',' && *end != '\0')
655 if (*end != ',' && *end != '\0' &&
659 for (idx = RTE_MIN(min, max);
660 idx <= RTE_MAX(min, max); idx++)
667 /* process set within bracket */
669 while (isblank(*str))
677 /* go ahead to the first digit */
678 while (isblank(*str))
683 /* get the digit value */
685 idx = strtoul(str, &end, 10);
686 if (errno || end == NULL || idx >= num)
689 /* go ahead to separator '-',',' and ')' */
690 while (isblank(*end))
693 if (min == RTE_MAX_LCORE)
695 else /* avoid continuous '-' */
697 } else if ((*end == ',') || (*end == ')')) {
699 if (min == RTE_MAX_LCORE)
701 for (idx = RTE_MIN(min, max);
702 idx <= RTE_MAX(min, max); idx++)
710 } while (*end != '\0' && *end != ')');
713 * to avoid failure that tail blank makes end character check fail
714 * in eal_parse_lcores( )
716 while (isblank(*str))
722 /* convert from set array to cpuset bitmap */
724 convert_to_cpuset(rte_cpuset_t *cpusetp,
725 uint16_t *set, unsigned num)
731 for (idx = 0; idx < num; idx++) {
735 if (!lcore_config[idx].detected) {
736 RTE_LOG(ERR, EAL, "core %u "
737 "unavailable\n", idx);
741 CPU_SET(idx, cpusetp);
748 * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
749 * lcores, cpus could be a single digit/range or a group.
750 * '(' and ')' are necessary if it's a group.
751 * If not supply '@cpus', the value of cpus uses the same as lcores.
752 * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
753 * lcore 0 runs on cpuset 0x41 (cpu 0,6)
754 * lcore 1 runs on cpuset 0x2 (cpu 1)
755 * lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
756 * lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
757 * lcore 6 runs on cpuset 0x41 (cpu 0,6)
758 * lcore 7 runs on cpuset 0x80 (cpu 7)
759 * lcore 8 runs on cpuset 0x100 (cpu 8)
762 eal_parse_lcores(const char *lcores)
764 struct rte_config *cfg = rte_eal_get_configuration();
765 static uint16_t set[RTE_MAX_LCORE];
768 const char *lcore_start = NULL;
769 const char *end = NULL;
778 /* Remove all blank characters ahead and after */
779 while (isblank(*lcores))
784 /* Reset lcore config */
785 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
786 cfg->lcore_role[idx] = ROLE_OFF;
787 lcore_config[idx].core_index = -1;
788 CPU_ZERO(&lcore_config[idx].cpuset);
791 /* Get list of cores */
793 while (isblank(*lcores))
800 /* record lcore_set start point */
801 lcore_start = lcores;
803 /* go across a complete bracket */
804 if (*lcore_start == '(') {
805 lcores += strcspn(lcores, ")");
806 if (*lcores++ == '\0')
810 /* scan the separator '@', ','(next) or '\0'(finish) */
811 lcores += strcspn(lcores, "@,");
813 if (*lcores == '@') {
814 /* explicit assign cpu_set */
815 offset = eal_parse_set(lcores + 1, set, RTE_DIM(set));
819 /* prepare cpu_set and update the end cursor */
820 if (0 > convert_to_cpuset(&cpuset,
823 end = lcores + 1 + offset;
824 } else { /* ',' or '\0' */
825 /* haven't given cpu_set, current loop done */
828 /* go back to check <number>-<number> */
829 offset = strcspn(lcore_start, "(-");
830 if (offset < (end - lcore_start) &&
831 *(lcore_start + offset) != '(')
835 if (*end != ',' && *end != '\0')
838 /* parse lcore_set from start point */
839 if (0 > eal_parse_set(lcore_start, set, RTE_DIM(set)))
842 /* without '@', by default using lcore_set as cpu_set */
843 if (*lcores != '@' &&
844 0 > convert_to_cpuset(&cpuset, set, RTE_DIM(set)))
847 /* start to update lcore_set */
848 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
852 if (cfg->lcore_role[idx] != ROLE_RTE) {
853 lcore_config[idx].core_index = count;
854 cfg->lcore_role[idx] = ROLE_RTE;
860 CPU_SET(idx, &cpuset);
862 rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
863 sizeof(rte_cpuset_t));
867 } while (*end != '\0');
872 cfg->lcore_count = count;
881 eal_parse_syslog(const char *facility, struct internal_config *conf)
884 static const struct {
888 { "auth", LOG_AUTH },
889 { "cron", LOG_CRON },
890 { "daemon", LOG_DAEMON },
892 { "kern", LOG_KERN },
894 { "mail", LOG_MAIL },
895 { "news", LOG_NEWS },
896 { "syslog", LOG_SYSLOG },
897 { "user", LOG_USER },
898 { "uucp", LOG_UUCP },
899 { "local0", LOG_LOCAL0 },
900 { "local1", LOG_LOCAL1 },
901 { "local2", LOG_LOCAL2 },
902 { "local3", LOG_LOCAL3 },
903 { "local4", LOG_LOCAL4 },
904 { "local5", LOG_LOCAL5 },
905 { "local6", LOG_LOCAL6 },
906 { "local7", LOG_LOCAL7 },
910 for (i = 0; map[i].name; i++) {
911 if (!strcmp(facility, map[i].name)) {
912 conf->syslog_facility = map[i].value;
920 eal_parse_log_priority(const char *level)
922 static const char * const levels[] = {
923 [RTE_LOG_EMERG] = "emergency",
924 [RTE_LOG_ALERT] = "alert",
925 [RTE_LOG_CRIT] = "critical",
926 [RTE_LOG_ERR] = "error",
927 [RTE_LOG_WARNING] = "warning",
928 [RTE_LOG_NOTICE] = "notice",
929 [RTE_LOG_INFO] = "info",
930 [RTE_LOG_DEBUG] = "debug",
932 size_t len = strlen(level);
940 /* look for named values, skip 0 which is not a valid level */
941 for (i = 1; i < RTE_DIM(levels); i++) {
942 if (strncmp(levels[i], level, len) == 0)
946 /* not a string, maybe it is numeric */
948 tmp = strtoul(level, &end, 0);
950 /* check for errors */
951 if (errno != 0 || end == NULL || *end != '\0' ||
959 eal_parse_log_level(const char *arg)
961 char *str, *type, *level;
968 if (strchr(str, ',') == NULL) {
972 type = strsep(&str, ",");
973 level = strsep(&str, ",");
976 priority = eal_parse_log_priority(level);
978 fprintf(stderr, "invalid log priority: %s\n", level);
983 rte_log_set_global_level(priority);
984 } else if (rte_log_set_level_regexp(type, priority) < 0) {
985 fprintf(stderr, "cannot set log level %s,%d\n",
989 struct rte_eal_opt_loglevel *opt_ll;
992 * Save the type (regexp string) and the loglevel
993 * in the global storage so that it could be used
994 * to configure dynamic logtypes which are absent
995 * at the moment of EAL option processing but may
996 * be registered during runtime.
998 opt_ll = malloc(sizeof(*opt_ll));
1002 opt_ll->re_type = strdup(type);
1003 if (opt_ll->re_type == NULL) {
1008 opt_ll->level = priority;
1010 TAILQ_INSERT_HEAD(&opt_loglevel_list, opt_ll, next);
1021 static enum rte_proc_type_t
1022 eal_parse_proc_type(const char *arg)
1024 if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
1025 return RTE_PROC_PRIMARY;
1026 if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
1027 return RTE_PROC_SECONDARY;
1028 if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
1029 return RTE_PROC_AUTO;
1031 return RTE_PROC_INVALID;
1035 eal_parse_common_option(int opt, const char *optarg,
1036 struct internal_config *conf)
1046 if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI,
1056 if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI,
1064 if (eal_parse_coremask(optarg) < 0) {
1065 RTE_LOG(ERR, EAL, "invalid coremask\n");
1070 RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s) is set!\n",
1071 (core_parsed == LCORE_OPT_LST) ? "-l" :
1072 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1077 core_parsed = LCORE_OPT_MSK;
1081 if (eal_parse_corelist(optarg) < 0) {
1082 RTE_LOG(ERR, EAL, "invalid core list\n");
1087 RTE_LOG(ERR, EAL, "Option -l is ignored, because (%s) is set!\n",
1088 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1089 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1094 core_parsed = LCORE_OPT_LST;
1096 /* service coremask */
1098 if (eal_parse_service_coremask(optarg) < 0) {
1099 RTE_LOG(ERR, EAL, "invalid service coremask\n");
1103 /* service corelist */
1105 if (eal_parse_service_corelist(optarg) < 0) {
1106 RTE_LOG(ERR, EAL, "invalid service core list\n");
1110 /* size of memory */
1112 conf->memory = atoi(optarg);
1113 conf->memory *= 1024ULL;
1114 conf->memory *= 1024ULL;
1117 /* force number of channels */
1119 conf->force_nchannel = atoi(optarg);
1120 if (conf->force_nchannel == 0) {
1121 RTE_LOG(ERR, EAL, "invalid channel number\n");
1125 /* force number of ranks */
1127 conf->force_nrank = atoi(optarg);
1128 if (conf->force_nrank == 0 ||
1129 conf->force_nrank > 16) {
1130 RTE_LOG(ERR, EAL, "invalid rank number\n");
1134 /* force loading of external driver */
1136 if (eal_plugin_add(optarg) == -1)
1140 /* since message is explicitly requested by user, we
1141 * write message at highest log level so it can always
1143 * even if info or warning messages are disabled */
1144 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
1148 case OPT_HUGE_UNLINK_NUM:
1149 conf->hugepage_unlink = 1;
1152 case OPT_NO_HUGE_NUM:
1153 conf->no_hugetlbfs = 1;
1154 /* no-huge is legacy mem */
1155 conf->legacy_mem = 1;
1158 case OPT_NO_PCI_NUM:
1162 case OPT_NO_HPET_NUM:
1166 case OPT_VMWARE_TSC_MAP_NUM:
1167 conf->vmware_tsc_map = 1;
1170 case OPT_NO_SHCONF_NUM:
1171 conf->no_shconf = 1;
1174 case OPT_PROC_TYPE_NUM:
1175 conf->process_type = eal_parse_proc_type(optarg);
1178 case OPT_MASTER_LCORE_NUM:
1179 if (eal_parse_master_lcore(optarg) < 0) {
1180 RTE_LOG(ERR, EAL, "invalid parameter for --"
1181 OPT_MASTER_LCORE "\n");
1187 if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1193 case OPT_SYSLOG_NUM:
1194 if (eal_parse_syslog(optarg, conf) < 0) {
1195 RTE_LOG(ERR, EAL, "invalid parameters for --"
1201 case OPT_LOG_LEVEL_NUM: {
1202 if (eal_parse_log_level(optarg) < 0) {
1204 "invalid parameters for --"
1205 OPT_LOG_LEVEL "\n");
1210 case OPT_LCORES_NUM:
1211 if (eal_parse_lcores(optarg) < 0) {
1212 RTE_LOG(ERR, EAL, "invalid parameter for --"
1218 RTE_LOG(ERR, EAL, "Option --lcore is ignored, because (%s) is set!\n",
1219 (core_parsed == LCORE_OPT_LST) ? "-l" :
1220 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1225 core_parsed = LCORE_OPT_MAP;
1227 case OPT_LEGACY_MEM_NUM:
1228 conf->legacy_mem = 1;
1230 case OPT_SINGLE_FILE_SEGMENTS_NUM:
1231 conf->single_file_segments = 1;
1234 /* don't know what to do, leave this to caller */
1242 RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
1243 "cannot be used at the same time\n");
1248 eal_auto_detect_cores(struct rte_config *cfg)
1250 unsigned int lcore_id;
1251 unsigned int removed = 0;
1252 rte_cpuset_t affinity_set;
1253 pthread_t tid = pthread_self();
1255 if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t),
1257 CPU_ZERO(&affinity_set);
1259 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1260 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1261 !CPU_ISSET(lcore_id, &affinity_set)) {
1262 cfg->lcore_role[lcore_id] = ROLE_OFF;
1267 cfg->lcore_count -= removed;
1271 eal_adjust_config(struct internal_config *internal_cfg)
1274 struct rte_config *cfg = rte_eal_get_configuration();
1277 eal_auto_detect_cores(cfg);
1279 if (internal_config.process_type == RTE_PROC_AUTO)
1280 internal_config.process_type = eal_proc_type_detect();
1282 /* default master lcore is the first one */
1283 if (!master_lcore_parsed) {
1284 cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
1285 lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
1288 /* if no memory amounts were requested, this will result in 0 and
1289 * will be overridden later, right after eal_hugepage_info_init() */
1290 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1291 internal_cfg->memory += internal_cfg->socket_mem[i];
1297 eal_check_common_options(struct internal_config *internal_cfg)
1299 struct rte_config *cfg = rte_eal_get_configuration();
1301 if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
1302 RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
1306 if (internal_cfg->process_type == RTE_PROC_INVALID) {
1307 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1310 if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
1311 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1315 if (mem_parsed && internal_cfg->force_sockets == 1) {
1316 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1317 "be specified at the same time\n");
1320 if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1321 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1322 "be specified together with --"OPT_NO_HUGE"\n");
1326 if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink) {
1327 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1328 "be specified together with --"OPT_NO_HUGE"\n");
1336 eal_common_usage(void)
1338 printf("[options]\n\n"
1339 "EAL common options:\n"
1340 " -c COREMASK Hexadecimal bitmask of cores to run on\n"
1341 " -l CORELIST List of cores to run on\n"
1342 " The argument format is <c1>[-c2][,c3[-c4],...]\n"
1343 " where c1, c2, etc are core indexes between 0 and %d\n"
1344 " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
1345 " The argument format is\n"
1346 " '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
1347 " lcores and cpus list are grouped by '(' and ')'\n"
1348 " Within the group, '-' is used for range separator,\n"
1349 " ',' is used for single number separator.\n"
1350 " '( )' can be omitted for single element group,\n"
1351 " '@' can be omitted if cpus and lcores have the same value\n"
1352 " -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
1353 " --"OPT_MASTER_LCORE" ID Core ID that is used as master\n"
1354 " --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
1355 " -n CHANNELS Number of memory channels\n"
1356 " -m MB Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
1357 " -r RANKS Force number of memory ranks (don't detect)\n"
1358 " -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
1359 " Prevent EAL from using this PCI device. The argument\n"
1360 " format is <domain:bus:devid.func>.\n"
1361 " -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
1362 " Only use the specified PCI devices. The argument format\n"
1363 " is <[domain:]bus:devid.func>. This option can be present\n"
1364 " several times (once per device).\n"
1365 " [NOTE: PCI whitelist cannot be used with -b option]\n"
1366 " --"OPT_VDEV" Add a virtual device.\n"
1367 " The argument format is <driver><id>[,key=val,...]\n"
1368 " (ex: --vdev=net_pcap0,iface=eth2).\n"
1369 " -d LIB.so|DIR Add a driver or driver directory\n"
1370 " (can be used multiple times)\n"
1371 " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n"
1372 " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n"
1373 " --"OPT_SYSLOG" Set syslog facility\n"
1374 " --"OPT_LOG_LEVEL"=<int> Set global log level\n"
1375 " --"OPT_LOG_LEVEL"=<type-regexp>,<int>\n"
1376 " Set specific log level\n"
1377 " -v Display version information on startup\n"
1378 " -h, --help This help\n"
1379 "\nEAL options for DEBUG use only:\n"
1380 " --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n"
1381 " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
1382 " --"OPT_NO_PCI" Disable PCI\n"
1383 " --"OPT_NO_HPET" Disable HPET\n"
1384 " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
1385 "\n", RTE_MAX_LCORE);