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_eal_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 internal_cfg->hugepage_info[i].lock_descriptor = -1;
184 internal_cfg->base_virtaddr = 0;
186 internal_cfg->syslog_facility = LOG_DAEMON;
188 /* if set to NONE, interrupt mode is determined automatically */
189 internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
191 #ifdef RTE_LIBEAL_USE_HPET
192 internal_cfg->no_hpet = 0;
194 internal_cfg->no_hpet = 1;
196 internal_cfg->vmware_tsc_map = 0;
197 internal_cfg->create_uio_dev = 0;
198 internal_cfg->user_mbuf_pool_ops_name = NULL;
199 internal_cfg->init_complete = 0;
203 eal_plugin_add(const char *path)
205 struct shared_driver *solib;
207 solib = malloc(sizeof(*solib));
209 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
212 memset(solib, 0, sizeof(*solib));
213 strncpy(solib->name, path, PATH_MAX-1);
214 solib->name[PATH_MAX-1] = 0;
215 TAILQ_INSERT_TAIL(&solib_list, solib, next);
221 eal_plugindir_init(const char *path)
224 struct dirent *dent = NULL;
225 char sopath[PATH_MAX];
227 if (path == NULL || *path == '\0')
232 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
233 path, strerror(errno));
237 while ((dent = readdir(d)) != NULL) {
240 snprintf(sopath, PATH_MAX-1, "%s/%s", path, dent->d_name);
241 sopath[PATH_MAX-1] = 0;
243 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
246 if (eal_plugin_add(sopath) == -1)
251 /* XXX this ignores failures from readdir() itself */
252 return (dent == NULL) ? 0 : -1;
256 eal_plugins_init(void)
258 struct shared_driver *solib = NULL;
261 if (*default_solib_dir != '\0' && stat(default_solib_dir, &sb) == 0 &&
263 eal_plugin_add(default_solib_dir);
265 TAILQ_FOREACH(solib, &solib_list, next) {
267 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
268 if (eal_plugindir_init(solib->name) == -1) {
270 "Cannot init plugin directory %s\n",
275 RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
277 solib->lib_handle = dlopen(solib->name, RTLD_NOW);
278 if (solib->lib_handle == NULL) {
279 RTE_LOG(ERR, EAL, "%s\n", dlerror());
289 * Parse the coremask given as argument (hexadecimal string) and fill
290 * the global configuration (core role and core count) with the parsed
293 static int xdigit2val(unsigned char c)
307 eal_parse_service_coremask(const char *coremask)
309 struct rte_config *cfg = rte_eal_get_configuration();
311 unsigned int count = 0;
315 if (coremask == NULL)
317 /* Remove all blank characters ahead and after .
318 * Remove 0x/0X if exists.
320 while (isblank(*coremask))
322 if (coremask[0] == '0' && ((coremask[1] == 'x')
323 || (coremask[1] == 'X')))
325 i = strlen(coremask);
326 while ((i > 0) && isblank(coremask[i - 1]))
332 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
334 if (isxdigit(c) == 0) {
335 /* invalid characters */
339 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
341 if ((1 << j) & val) {
342 /* handle master lcore already parsed */
343 uint32_t lcore = idx;
344 if (master_lcore_parsed &&
345 cfg->master_lcore == lcore) {
347 "Error: lcore %u is master lcore, cannot use as service core\n",
352 if (!lcore_config[idx].detected) {
354 "lcore %u unavailable\n", idx);
357 lcore_config[idx].core_role = ROLE_SERVICE;
364 if (coremask[i] != '0')
367 for (; idx < RTE_MAX_LCORE; idx++)
368 lcore_config[idx].core_index = -1;
373 cfg->service_lcore_count = count;
378 eal_parse_coremask(const char *coremask)
380 struct rte_config *cfg = rte_eal_get_configuration();
386 if (coremask == NULL)
388 /* Remove all blank characters ahead and after .
389 * Remove 0x/0X if exists.
391 while (isblank(*coremask))
393 if (coremask[0] == '0' && ((coremask[1] == 'x')
394 || (coremask[1] == 'X')))
396 i = strlen(coremask);
397 while ((i > 0) && isblank(coremask[i - 1]))
402 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
404 if (isxdigit(c) == 0) {
405 /* invalid characters */
409 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
411 if ((1 << j) & val) {
412 if (!lcore_config[idx].detected) {
413 RTE_LOG(ERR, EAL, "lcore %u "
414 "unavailable\n", idx);
417 cfg->lcore_role[idx] = ROLE_RTE;
418 lcore_config[idx].core_index = count;
421 cfg->lcore_role[idx] = ROLE_OFF;
422 lcore_config[idx].core_index = -1;
427 if (coremask[i] != '0')
429 for (; idx < RTE_MAX_LCORE; idx++) {
430 cfg->lcore_role[idx] = ROLE_OFF;
431 lcore_config[idx].core_index = -1;
435 /* Update the count of enabled logical cores of the EAL configuration */
436 cfg->lcore_count = count;
441 eal_parse_service_corelist(const char *corelist)
443 struct rte_config *cfg = rte_eal_get_configuration();
449 if (corelist == NULL)
452 /* Remove all blank characters ahead and after */
453 while (isblank(*corelist))
455 i = strlen(corelist);
456 while ((i > 0) && isblank(corelist[i - 1]))
459 /* Get list of cores */
462 while (isblank(*corelist))
464 if (*corelist == '\0')
467 idx = strtoul(corelist, &end, 10);
468 if (errno || end == NULL)
470 while (isblank(*end))
474 } else if ((*end == ',') || (*end == '\0')) {
476 if (min == RTE_MAX_LCORE)
478 for (idx = min; idx <= max; idx++) {
479 if (cfg->lcore_role[idx] != ROLE_SERVICE) {
480 /* handle master lcore already parsed */
481 uint32_t lcore = idx;
482 if (cfg->master_lcore == lcore &&
483 master_lcore_parsed) {
485 "Error: lcore %u is master lcore, cannot use as service core\n",
489 lcore_config[idx].core_role =
498 } while (*end != '\0');
507 eal_parse_corelist(const char *corelist)
509 struct rte_config *cfg = rte_eal_get_configuration();
515 if (corelist == NULL)
518 /* Remove all blank characters ahead and after */
519 while (isblank(*corelist))
521 i = strlen(corelist);
522 while ((i > 0) && isblank(corelist[i - 1]))
526 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
527 cfg->lcore_role[idx] = ROLE_OFF;
528 lcore_config[idx].core_index = -1;
531 /* Get list of cores */
534 while (isblank(*corelist))
536 if (*corelist == '\0')
539 idx = strtoul(corelist, &end, 10);
540 if (errno || end == NULL)
542 while (isblank(*end))
546 } else if ((*end == ',') || (*end == '\0')) {
548 if (min == RTE_MAX_LCORE)
550 for (idx = min; idx <= max; idx++) {
551 if (cfg->lcore_role[idx] != ROLE_RTE) {
552 cfg->lcore_role[idx] = ROLE_RTE;
553 lcore_config[idx].core_index = count;
561 } while (*end != '\0');
566 /* Update the count of enabled logical cores of the EAL configuration */
567 cfg->lcore_count = count;
572 /* Changes the lcore id of the master thread */
574 eal_parse_master_lcore(const char *arg)
577 struct rte_config *cfg = rte_eal_get_configuration();
580 cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
581 if (errno || parsing_end[0] != 0)
583 if (cfg->master_lcore >= RTE_MAX_LCORE)
585 master_lcore_parsed = 1;
587 /* ensure master core is not used as service core */
588 if (lcore_config[cfg->master_lcore].core_role == ROLE_SERVICE) {
589 RTE_LOG(ERR, EAL, "Error: Master lcore is used as a service core.\n");
597 * Parse elem, the elem could be single number/range or '(' ')' group
598 * 1) A single number elem, it's just a simple digit. e.g. 9
599 * 2) A single range elem, two digits with a '-' between. e.g. 2-6
600 * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
601 * Within group elem, '-' used for a range separator;
602 * ',' used for a single number.
605 eal_parse_set(const char *input, uint16_t set[], unsigned num)
608 const char *str = input;
612 memset(set, 0, num * sizeof(uint16_t));
614 while (isblank(*str))
617 /* only digit or left bracket is qualify for start point */
618 if ((!isdigit(*str) && *str != '(') || *str == '\0')
621 /* process single number or single range of number */
624 idx = strtoul(str, &end, 10);
625 if (errno || end == NULL || idx >= num)
628 while (isblank(*end))
634 /* process single <number>-<number> */
636 while (isblank(*end))
642 idx = strtoul(end, &end, 10);
643 if (errno || end == NULL || idx >= num)
646 while (isblank(*end))
648 if (*end != ',' && *end != '\0')
652 if (*end != ',' && *end != '\0' &&
656 for (idx = RTE_MIN(min, max);
657 idx <= RTE_MAX(min, max); idx++)
664 /* process set within bracket */
666 while (isblank(*str))
674 /* go ahead to the first digit */
675 while (isblank(*str))
680 /* get the digit value */
682 idx = strtoul(str, &end, 10);
683 if (errno || end == NULL || idx >= num)
686 /* go ahead to separator '-',',' and ')' */
687 while (isblank(*end))
690 if (min == RTE_MAX_LCORE)
692 else /* avoid continuous '-' */
694 } else if ((*end == ',') || (*end == ')')) {
696 if (min == RTE_MAX_LCORE)
698 for (idx = RTE_MIN(min, max);
699 idx <= RTE_MAX(min, max); idx++)
707 } while (*end != '\0' && *end != ')');
710 * to avoid failure that tail blank makes end character check fail
711 * in eal_parse_lcores( )
713 while (isblank(*str))
719 /* convert from set array to cpuset bitmap */
721 convert_to_cpuset(rte_cpuset_t *cpusetp,
722 uint16_t *set, unsigned num)
728 for (idx = 0; idx < num; idx++) {
732 if (!lcore_config[idx].detected) {
733 RTE_LOG(ERR, EAL, "core %u "
734 "unavailable\n", idx);
738 CPU_SET(idx, cpusetp);
745 * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
746 * lcores, cpus could be a single digit/range or a group.
747 * '(' and ')' are necessary if it's a group.
748 * If not supply '@cpus', the value of cpus uses the same as lcores.
749 * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
750 * lcore 0 runs on cpuset 0x41 (cpu 0,6)
751 * lcore 1 runs on cpuset 0x2 (cpu 1)
752 * lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
753 * lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
754 * lcore 6 runs on cpuset 0x41 (cpu 0,6)
755 * lcore 7 runs on cpuset 0x80 (cpu 7)
756 * lcore 8 runs on cpuset 0x100 (cpu 8)
759 eal_parse_lcores(const char *lcores)
761 struct rte_config *cfg = rte_eal_get_configuration();
762 static uint16_t set[RTE_MAX_LCORE];
765 const char *lcore_start = NULL;
766 const char *end = NULL;
775 /* Remove all blank characters ahead and after */
776 while (isblank(*lcores))
781 /* Reset lcore config */
782 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
783 cfg->lcore_role[idx] = ROLE_OFF;
784 lcore_config[idx].core_index = -1;
785 CPU_ZERO(&lcore_config[idx].cpuset);
788 /* Get list of cores */
790 while (isblank(*lcores))
797 /* record lcore_set start point */
798 lcore_start = lcores;
800 /* go across a complete bracket */
801 if (*lcore_start == '(') {
802 lcores += strcspn(lcores, ")");
803 if (*lcores++ == '\0')
807 /* scan the separator '@', ','(next) or '\0'(finish) */
808 lcores += strcspn(lcores, "@,");
810 if (*lcores == '@') {
811 /* explicit assign cpu_set */
812 offset = eal_parse_set(lcores + 1, set, RTE_DIM(set));
816 /* prepare cpu_set and update the end cursor */
817 if (0 > convert_to_cpuset(&cpuset,
820 end = lcores + 1 + offset;
821 } else { /* ',' or '\0' */
822 /* haven't given cpu_set, current loop done */
825 /* go back to check <number>-<number> */
826 offset = strcspn(lcore_start, "(-");
827 if (offset < (end - lcore_start) &&
828 *(lcore_start + offset) != '(')
832 if (*end != ',' && *end != '\0')
835 /* parse lcore_set from start point */
836 if (0 > eal_parse_set(lcore_start, set, RTE_DIM(set)))
839 /* without '@', by default using lcore_set as cpu_set */
840 if (*lcores != '@' &&
841 0 > convert_to_cpuset(&cpuset, set, RTE_DIM(set)))
844 /* start to update lcore_set */
845 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
849 if (cfg->lcore_role[idx] != ROLE_RTE) {
850 lcore_config[idx].core_index = count;
851 cfg->lcore_role[idx] = ROLE_RTE;
857 CPU_SET(idx, &cpuset);
859 rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
860 sizeof(rte_cpuset_t));
864 } while (*end != '\0');
869 cfg->lcore_count = count;
878 eal_parse_syslog(const char *facility, struct internal_config *conf)
885 { "auth", LOG_AUTH },
886 { "cron", LOG_CRON },
887 { "daemon", LOG_DAEMON },
889 { "kern", LOG_KERN },
891 { "mail", LOG_MAIL },
892 { "news", LOG_NEWS },
893 { "syslog", LOG_SYSLOG },
894 { "user", LOG_USER },
895 { "uucp", LOG_UUCP },
896 { "local0", LOG_LOCAL0 },
897 { "local1", LOG_LOCAL1 },
898 { "local2", LOG_LOCAL2 },
899 { "local3", LOG_LOCAL3 },
900 { "local4", LOG_LOCAL4 },
901 { "local5", LOG_LOCAL5 },
902 { "local6", LOG_LOCAL6 },
903 { "local7", LOG_LOCAL7 },
907 for (i = 0; map[i].name; i++) {
908 if (!strcmp(facility, map[i].name)) {
909 conf->syslog_facility = map[i].value;
917 eal_parse_log_level(const char *arg)
919 char *end, *str, *type, *level;
926 if (strchr(str, ',') == NULL) {
930 type = strsep(&str, ",");
931 level = strsep(&str, ",");
935 tmp = strtoul(level, &end, 0);
937 /* check for errors */
938 if ((errno != 0) || (level[0] == '\0') ||
939 end == NULL || (*end != '\0'))
942 /* log_level is a uint32_t */
943 if (tmp >= UINT32_MAX)
947 rte_log_set_global_level(tmp);
948 } else if (rte_log_set_level_regexp(type, tmp) < 0) {
949 printf("cannot set log level %s,%lu\n",
953 struct rte_eal_opt_loglevel *opt_ll;
956 * Save the type (regexp string) and the loglevel
957 * in the global storage so that it could be used
958 * to configure dynamic logtypes which are absent
959 * at the moment of EAL option processing but may
960 * be registered during runtime.
962 opt_ll = malloc(sizeof(*opt_ll));
966 opt_ll->re_type = strdup(type);
967 if (opt_ll->re_type == NULL) {
974 TAILQ_INSERT_HEAD(&opt_loglevel_list, opt_ll, next);
985 static enum rte_proc_type_t
986 eal_parse_proc_type(const char *arg)
988 if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
989 return RTE_PROC_PRIMARY;
990 if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
991 return RTE_PROC_SECONDARY;
992 if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
993 return RTE_PROC_AUTO;
995 return RTE_PROC_INVALID;
999 eal_parse_common_option(int opt, const char *optarg,
1000 struct internal_config *conf)
1010 if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI,
1020 if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI,
1028 if (eal_parse_coremask(optarg) < 0) {
1029 RTE_LOG(ERR, EAL, "invalid coremask\n");
1034 RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s) is set!\n",
1035 (core_parsed == LCORE_OPT_LST) ? "-l" :
1036 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1041 core_parsed = LCORE_OPT_MSK;
1045 if (eal_parse_corelist(optarg) < 0) {
1046 RTE_LOG(ERR, EAL, "invalid core list\n");
1051 RTE_LOG(ERR, EAL, "Option -l is ignored, because (%s) is set!\n",
1052 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1053 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1058 core_parsed = LCORE_OPT_LST;
1060 /* service coremask */
1062 if (eal_parse_service_coremask(optarg) < 0) {
1063 RTE_LOG(ERR, EAL, "invalid service coremask\n");
1067 /* service corelist */
1069 if (eal_parse_service_corelist(optarg) < 0) {
1070 RTE_LOG(ERR, EAL, "invalid service core list\n");
1074 /* size of memory */
1076 conf->memory = atoi(optarg);
1077 conf->memory *= 1024ULL;
1078 conf->memory *= 1024ULL;
1081 /* force number of channels */
1083 conf->force_nchannel = atoi(optarg);
1084 if (conf->force_nchannel == 0) {
1085 RTE_LOG(ERR, EAL, "invalid channel number\n");
1089 /* force number of ranks */
1091 conf->force_nrank = atoi(optarg);
1092 if (conf->force_nrank == 0 ||
1093 conf->force_nrank > 16) {
1094 RTE_LOG(ERR, EAL, "invalid rank number\n");
1098 /* force loading of external driver */
1100 if (eal_plugin_add(optarg) == -1)
1104 /* since message is explicitly requested by user, we
1105 * write message at highest log level so it can always
1107 * even if info or warning messages are disabled */
1108 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
1112 case OPT_HUGE_UNLINK_NUM:
1113 conf->hugepage_unlink = 1;
1116 case OPT_NO_HUGE_NUM:
1117 conf->no_hugetlbfs = 1;
1118 /* no-huge is legacy mem */
1119 conf->legacy_mem = 1;
1122 case OPT_NO_PCI_NUM:
1126 case OPT_NO_HPET_NUM:
1130 case OPT_VMWARE_TSC_MAP_NUM:
1131 conf->vmware_tsc_map = 1;
1134 case OPT_NO_SHCONF_NUM:
1135 conf->no_shconf = 1;
1138 case OPT_PROC_TYPE_NUM:
1139 conf->process_type = eal_parse_proc_type(optarg);
1142 case OPT_MASTER_LCORE_NUM:
1143 if (eal_parse_master_lcore(optarg) < 0) {
1144 RTE_LOG(ERR, EAL, "invalid parameter for --"
1145 OPT_MASTER_LCORE "\n");
1151 if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1157 case OPT_SYSLOG_NUM:
1158 if (eal_parse_syslog(optarg, conf) < 0) {
1159 RTE_LOG(ERR, EAL, "invalid parameters for --"
1165 case OPT_LOG_LEVEL_NUM: {
1166 if (eal_parse_log_level(optarg) < 0) {
1168 "invalid parameters for --"
1169 OPT_LOG_LEVEL "\n");
1174 case OPT_LCORES_NUM:
1175 if (eal_parse_lcores(optarg) < 0) {
1176 RTE_LOG(ERR, EAL, "invalid parameter for --"
1182 RTE_LOG(ERR, EAL, "Option --lcore is ignored, because (%s) is set!\n",
1183 (core_parsed == LCORE_OPT_LST) ? "-l" :
1184 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1189 core_parsed = LCORE_OPT_MAP;
1191 case OPT_LEGACY_MEM_NUM:
1192 conf->legacy_mem = 1;
1194 case OPT_SINGLE_FILE_SEGMENTS_NUM:
1195 conf->single_file_segments = 1;
1198 /* don't know what to do, leave this to caller */
1206 RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
1207 "cannot be used at the same time\n");
1212 eal_auto_detect_cores(struct rte_config *cfg)
1214 unsigned int lcore_id;
1215 unsigned int removed = 0;
1216 rte_cpuset_t affinity_set;
1217 pthread_t tid = pthread_self();
1219 if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t),
1221 CPU_ZERO(&affinity_set);
1223 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1224 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1225 !CPU_ISSET(lcore_id, &affinity_set)) {
1226 cfg->lcore_role[lcore_id] = ROLE_OFF;
1231 cfg->lcore_count -= removed;
1235 eal_adjust_config(struct internal_config *internal_cfg)
1238 struct rte_config *cfg = rte_eal_get_configuration();
1241 eal_auto_detect_cores(cfg);
1243 if (internal_config.process_type == RTE_PROC_AUTO)
1244 internal_config.process_type = eal_proc_type_detect();
1246 /* default master lcore is the first one */
1247 if (!master_lcore_parsed) {
1248 cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
1249 lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
1252 /* if no memory amounts were requested, this will result in 0 and
1253 * will be overridden later, right after eal_hugepage_info_init() */
1254 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1255 internal_cfg->memory += internal_cfg->socket_mem[i];
1261 eal_check_common_options(struct internal_config *internal_cfg)
1263 struct rte_config *cfg = rte_eal_get_configuration();
1265 if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
1266 RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
1270 if (internal_cfg->process_type == RTE_PROC_INVALID) {
1271 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1274 if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
1275 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1279 if (mem_parsed && internal_cfg->force_sockets == 1) {
1280 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1281 "be specified at the same time\n");
1284 if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1285 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1286 "be specified together with --"OPT_NO_HUGE"\n");
1290 if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink) {
1291 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1292 "be specified together with --"OPT_NO_HUGE"\n");
1300 eal_common_usage(void)
1302 printf("[options]\n\n"
1303 "EAL common options:\n"
1304 " -c COREMASK Hexadecimal bitmask of cores to run on\n"
1305 " -l CORELIST List of cores to run on\n"
1306 " The argument format is <c1>[-c2][,c3[-c4],...]\n"
1307 " where c1, c2, etc are core indexes between 0 and %d\n"
1308 " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
1309 " The argument format is\n"
1310 " '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
1311 " lcores and cpus list are grouped by '(' and ')'\n"
1312 " Within the group, '-' is used for range separator,\n"
1313 " ',' is used for single number separator.\n"
1314 " '( )' can be omitted for single element group,\n"
1315 " '@' can be omitted if cpus and lcores have the same value\n"
1316 " -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
1317 " --"OPT_MASTER_LCORE" ID Core ID that is used as master\n"
1318 " --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
1319 " -n CHANNELS Number of memory channels\n"
1320 " -m MB Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
1321 " -r RANKS Force number of memory ranks (don't detect)\n"
1322 " -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
1323 " Prevent EAL from using this PCI device. The argument\n"
1324 " format is <domain:bus:devid.func>.\n"
1325 " -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
1326 " Only use the specified PCI devices. The argument format\n"
1327 " is <[domain:]bus:devid.func>. This option can be present\n"
1328 " several times (once per device).\n"
1329 " [NOTE: PCI whitelist cannot be used with -b option]\n"
1330 " --"OPT_VDEV" Add a virtual device.\n"
1331 " The argument format is <driver><id>[,key=val,...]\n"
1332 " (ex: --vdev=net_pcap0,iface=eth2).\n"
1333 " -d LIB.so|DIR Add a driver or driver directory\n"
1334 " (can be used multiple times)\n"
1335 " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n"
1336 " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n"
1337 " --"OPT_SYSLOG" Set syslog facility\n"
1338 " --"OPT_LOG_LEVEL"=<int> Set global log level\n"
1339 " --"OPT_LOG_LEVEL"=<type-regexp>,<int>\n"
1340 " Set specific log level\n"
1341 " -v Display version information on startup\n"
1342 " -h, --help This help\n"
1343 "\nEAL options for DEBUG use only:\n"
1344 " --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n"
1345 " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
1346 " --"OPT_NO_PCI" Disable PCI\n"
1347 " --"OPT_NO_HPET" Disable HPET\n"
1348 " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
1349 "\n", RTE_MAX_LCORE);