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"
30 #include "eal_private.h"
32 #define BITS_PER_HEX 4
33 #define LCORE_OPT_LST 1
34 #define LCORE_OPT_MSK 2
35 #define LCORE_OPT_MAP 3
39 "b:" /* pci-blacklist */
41 "s:" /* service coremask */
45 "S:" /* service corelist */
46 "m:" /* memory size */
47 "n:" /* memory channels */
48 "r:" /* memory ranks */
50 "w:" /* pci-whitelist */
54 eal_long_options[] = {
55 {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM },
56 {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM },
57 {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM },
58 {OPT_HELP, 0, NULL, OPT_HELP_NUM },
59 {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
60 {OPT_HUGE_UNLINK, 0, NULL, OPT_HUGE_UNLINK_NUM },
61 {OPT_LCORES, 1, NULL, OPT_LCORES_NUM },
62 {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM },
63 {OPT_MASTER_LCORE, 1, NULL, OPT_MASTER_LCORE_NUM },
64 {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
65 {OPT_NO_HPET, 0, NULL, OPT_NO_HPET_NUM },
66 {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM },
67 {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM },
68 {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM },
69 {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM },
70 {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM },
71 {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM },
72 {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM },
73 {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
74 {OPT_VDEV, 1, NULL, OPT_VDEV_NUM },
75 {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM },
76 {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
77 {OPT_LEGACY_MEM, 0, NULL, OPT_LEGACY_MEM_NUM },
78 {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
82 TAILQ_HEAD(shared_driver_list, shared_driver);
84 /* Definition for shared object drivers. */
85 struct shared_driver {
86 TAILQ_ENTRY(shared_driver) next;
92 /* List of external loadable drivers */
93 static struct shared_driver_list solib_list =
94 TAILQ_HEAD_INITIALIZER(solib_list);
96 /* Default path of external loadable drivers */
97 static const char *default_solib_dir = RTE_EAL_PMD_PATH;
100 * Stringified version of solib path used by dpdk-pmdinfo.py
101 * Note: PLEASE DO NOT ALTER THIS without making a corresponding
102 * change to usertools/dpdk-pmdinfo.py
104 static const char dpdk_solib_path[] __attribute__((used)) =
105 "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
107 TAILQ_HEAD(device_option_list, device_option);
109 struct device_option {
110 TAILQ_ENTRY(device_option) next;
112 enum rte_devtype type;
116 static struct device_option_list devopt_list =
117 TAILQ_HEAD_INITIALIZER(devopt_list);
119 static int master_lcore_parsed;
120 static int mem_parsed;
121 static int core_parsed;
124 eal_option_device_add(enum rte_devtype type, const char *optarg)
126 struct device_option *devopt;
130 optlen = strlen(optarg) + 1;
131 devopt = calloc(1, sizeof(*devopt) + optlen);
132 if (devopt == NULL) {
133 RTE_LOG(ERR, EAL, "Unable to allocate device option\n");
138 ret = snprintf(devopt->arg, optlen, "%s", optarg);
140 RTE_LOG(ERR, EAL, "Unable to copy device option\n");
144 TAILQ_INSERT_TAIL(&devopt_list, devopt, next);
149 eal_option_device_parse(void)
151 struct device_option *devopt;
155 TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
157 ret = rte_devargs_add(devopt->type, devopt->arg);
159 RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n",
162 TAILQ_REMOVE(&devopt_list, devopt, next);
169 eal_reset_internal_config(struct internal_config *internal_cfg)
173 internal_cfg->memory = 0;
174 internal_cfg->force_nrank = 0;
175 internal_cfg->force_nchannel = 0;
176 internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
177 internal_cfg->hugepage_dir = NULL;
178 internal_cfg->force_sockets = 0;
179 /* zero out the NUMA config */
180 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
181 internal_cfg->socket_mem[i] = 0;
182 /* zero out hugedir descriptors */
183 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) {
184 memset(&internal_cfg->hugepage_info[i], 0,
185 sizeof(internal_cfg->hugepage_info[0]));
186 internal_cfg->hugepage_info[i].lock_descriptor = -1;
188 internal_cfg->base_virtaddr = 0;
190 internal_cfg->syslog_facility = LOG_DAEMON;
192 /* if set to NONE, interrupt mode is determined automatically */
193 internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
195 #ifdef RTE_LIBEAL_USE_HPET
196 internal_cfg->no_hpet = 0;
198 internal_cfg->no_hpet = 1;
200 internal_cfg->vmware_tsc_map = 0;
201 internal_cfg->create_uio_dev = 0;
202 internal_cfg->user_mbuf_pool_ops_name = NULL;
203 internal_cfg->init_complete = 0;
207 eal_plugin_add(const char *path)
209 struct shared_driver *solib;
211 solib = malloc(sizeof(*solib));
213 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
216 memset(solib, 0, sizeof(*solib));
217 strncpy(solib->name, path, PATH_MAX-1);
218 solib->name[PATH_MAX-1] = 0;
219 TAILQ_INSERT_TAIL(&solib_list, solib, next);
225 eal_plugindir_init(const char *path)
228 struct dirent *dent = NULL;
229 char sopath[PATH_MAX];
231 if (path == NULL || *path == '\0')
236 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
237 path, strerror(errno));
241 while ((dent = readdir(d)) != NULL) {
244 snprintf(sopath, PATH_MAX-1, "%s/%s", path, dent->d_name);
245 sopath[PATH_MAX-1] = 0;
247 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
250 if (eal_plugin_add(sopath) == -1)
255 /* XXX this ignores failures from readdir() itself */
256 return (dent == NULL) ? 0 : -1;
260 eal_plugins_init(void)
262 struct shared_driver *solib = NULL;
265 if (*default_solib_dir != '\0' && stat(default_solib_dir, &sb) == 0 &&
267 eal_plugin_add(default_solib_dir);
269 TAILQ_FOREACH(solib, &solib_list, next) {
271 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
272 if (eal_plugindir_init(solib->name) == -1) {
274 "Cannot init plugin directory %s\n",
279 RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
281 solib->lib_handle = dlopen(solib->name, RTLD_NOW);
282 if (solib->lib_handle == NULL) {
283 RTE_LOG(ERR, EAL, "%s\n", dlerror());
293 * Parse the coremask given as argument (hexadecimal string) and fill
294 * the global configuration (core role and core count) with the parsed
297 static int xdigit2val(unsigned char c)
311 eal_parse_service_coremask(const char *coremask)
313 struct rte_config *cfg = rte_eal_get_configuration();
315 unsigned int count = 0;
319 if (coremask == NULL)
321 /* Remove all blank characters ahead and after .
322 * Remove 0x/0X if exists.
324 while (isblank(*coremask))
326 if (coremask[0] == '0' && ((coremask[1] == 'x')
327 || (coremask[1] == 'X')))
329 i = strlen(coremask);
330 while ((i > 0) && isblank(coremask[i - 1]))
336 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
338 if (isxdigit(c) == 0) {
339 /* invalid characters */
343 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
345 if ((1 << j) & val) {
346 /* handle master lcore already parsed */
347 uint32_t lcore = idx;
348 if (master_lcore_parsed &&
349 cfg->master_lcore == lcore) {
351 "Error: lcore %u is master lcore, cannot use as service core\n",
356 if (!lcore_config[idx].detected) {
358 "lcore %u unavailable\n", idx);
361 lcore_config[idx].core_role = ROLE_SERVICE;
368 if (coremask[i] != '0')
371 for (; idx < RTE_MAX_LCORE; idx++)
372 lcore_config[idx].core_index = -1;
377 cfg->service_lcore_count = count;
382 eal_parse_coremask(const char *coremask)
384 struct rte_config *cfg = rte_eal_get_configuration();
390 if (coremask == NULL)
392 /* Remove all blank characters ahead and after .
393 * Remove 0x/0X if exists.
395 while (isblank(*coremask))
397 if (coremask[0] == '0' && ((coremask[1] == 'x')
398 || (coremask[1] == 'X')))
400 i = strlen(coremask);
401 while ((i > 0) && isblank(coremask[i - 1]))
406 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
408 if (isxdigit(c) == 0) {
409 /* invalid characters */
413 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
415 if ((1 << j) & val) {
416 if (!lcore_config[idx].detected) {
417 RTE_LOG(ERR, EAL, "lcore %u "
418 "unavailable\n", idx);
421 cfg->lcore_role[idx] = ROLE_RTE;
422 lcore_config[idx].core_index = count;
425 cfg->lcore_role[idx] = ROLE_OFF;
426 lcore_config[idx].core_index = -1;
431 if (coremask[i] != '0')
433 for (; idx < RTE_MAX_LCORE; idx++) {
434 cfg->lcore_role[idx] = ROLE_OFF;
435 lcore_config[idx].core_index = -1;
439 /* Update the count of enabled logical cores of the EAL configuration */
440 cfg->lcore_count = count;
445 eal_parse_service_corelist(const char *corelist)
447 struct rte_config *cfg = rte_eal_get_configuration();
453 if (corelist == NULL)
456 /* Remove all blank characters ahead and after */
457 while (isblank(*corelist))
459 i = strlen(corelist);
460 while ((i > 0) && isblank(corelist[i - 1]))
463 /* Get list of cores */
466 while (isblank(*corelist))
468 if (*corelist == '\0')
471 idx = strtoul(corelist, &end, 10);
472 if (errno || end == NULL)
474 while (isblank(*end))
478 } else if ((*end == ',') || (*end == '\0')) {
480 if (min == RTE_MAX_LCORE)
482 for (idx = min; idx <= max; idx++) {
483 if (cfg->lcore_role[idx] != ROLE_SERVICE) {
484 /* handle master lcore already parsed */
485 uint32_t lcore = idx;
486 if (cfg->master_lcore == lcore &&
487 master_lcore_parsed) {
489 "Error: lcore %u is master lcore, cannot use as service core\n",
493 lcore_config[idx].core_role =
502 } while (*end != '\0');
511 eal_parse_corelist(const char *corelist)
513 struct rte_config *cfg = rte_eal_get_configuration();
519 if (corelist == NULL)
522 /* Remove all blank characters ahead and after */
523 while (isblank(*corelist))
525 i = strlen(corelist);
526 while ((i > 0) && isblank(corelist[i - 1]))
530 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
531 cfg->lcore_role[idx] = ROLE_OFF;
532 lcore_config[idx].core_index = -1;
535 /* Get list of cores */
538 while (isblank(*corelist))
540 if (*corelist == '\0')
543 idx = strtoul(corelist, &end, 10);
544 if (errno || end == NULL)
546 while (isblank(*end))
550 } else if ((*end == ',') || (*end == '\0')) {
552 if (min == RTE_MAX_LCORE)
554 for (idx = min; idx <= max; idx++) {
555 if (cfg->lcore_role[idx] != ROLE_RTE) {
556 cfg->lcore_role[idx] = ROLE_RTE;
557 lcore_config[idx].core_index = count;
565 } while (*end != '\0');
570 /* Update the count of enabled logical cores of the EAL configuration */
571 cfg->lcore_count = count;
576 /* Changes the lcore id of the master thread */
578 eal_parse_master_lcore(const char *arg)
581 struct rte_config *cfg = rte_eal_get_configuration();
584 cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
585 if (errno || parsing_end[0] != 0)
587 if (cfg->master_lcore >= RTE_MAX_LCORE)
589 master_lcore_parsed = 1;
591 /* ensure master core is not used as service core */
592 if (lcore_config[cfg->master_lcore].core_role == ROLE_SERVICE) {
593 RTE_LOG(ERR, EAL, "Error: Master lcore is used as a service core.\n");
601 * Parse elem, the elem could be single number/range or '(' ')' group
602 * 1) A single number elem, it's just a simple digit. e.g. 9
603 * 2) A single range elem, two digits with a '-' between. e.g. 2-6
604 * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
605 * Within group elem, '-' used for a range separator;
606 * ',' used for a single number.
609 eal_parse_set(const char *input, uint16_t set[], unsigned num)
612 const char *str = input;
616 memset(set, 0, num * sizeof(uint16_t));
618 while (isblank(*str))
621 /* only digit or left bracket is qualify for start point */
622 if ((!isdigit(*str) && *str != '(') || *str == '\0')
625 /* process single number or single range of number */
628 idx = strtoul(str, &end, 10);
629 if (errno || end == NULL || idx >= num)
632 while (isblank(*end))
638 /* process single <number>-<number> */
640 while (isblank(*end))
646 idx = strtoul(end, &end, 10);
647 if (errno || end == NULL || idx >= num)
650 while (isblank(*end))
652 if (*end != ',' && *end != '\0')
656 if (*end != ',' && *end != '\0' &&
660 for (idx = RTE_MIN(min, max);
661 idx <= RTE_MAX(min, max); idx++)
668 /* process set within bracket */
670 while (isblank(*str))
678 /* go ahead to the first digit */
679 while (isblank(*str))
684 /* get the digit value */
686 idx = strtoul(str, &end, 10);
687 if (errno || end == NULL || idx >= num)
690 /* go ahead to separator '-',',' and ')' */
691 while (isblank(*end))
694 if (min == RTE_MAX_LCORE)
696 else /* avoid continuous '-' */
698 } else if ((*end == ',') || (*end == ')')) {
700 if (min == RTE_MAX_LCORE)
702 for (idx = RTE_MIN(min, max);
703 idx <= RTE_MAX(min, max); idx++)
711 } while (*end != '\0' && *end != ')');
714 * to avoid failure that tail blank makes end character check fail
715 * in eal_parse_lcores( )
717 while (isblank(*str))
723 /* convert from set array to cpuset bitmap */
725 convert_to_cpuset(rte_cpuset_t *cpusetp,
726 uint16_t *set, unsigned num)
732 for (idx = 0; idx < num; idx++) {
736 if (!lcore_config[idx].detected) {
737 RTE_LOG(ERR, EAL, "core %u "
738 "unavailable\n", idx);
742 CPU_SET(idx, cpusetp);
749 * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
750 * lcores, cpus could be a single digit/range or a group.
751 * '(' and ')' are necessary if it's a group.
752 * If not supply '@cpus', the value of cpus uses the same as lcores.
753 * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
754 * lcore 0 runs on cpuset 0x41 (cpu 0,6)
755 * lcore 1 runs on cpuset 0x2 (cpu 1)
756 * lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
757 * lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
758 * lcore 6 runs on cpuset 0x41 (cpu 0,6)
759 * lcore 7 runs on cpuset 0x80 (cpu 7)
760 * lcore 8 runs on cpuset 0x100 (cpu 8)
763 eal_parse_lcores(const char *lcores)
765 struct rte_config *cfg = rte_eal_get_configuration();
766 static uint16_t set[RTE_MAX_LCORE];
769 const char *lcore_start = NULL;
770 const char *end = NULL;
779 /* Remove all blank characters ahead and after */
780 while (isblank(*lcores))
785 /* Reset lcore config */
786 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
787 cfg->lcore_role[idx] = ROLE_OFF;
788 lcore_config[idx].core_index = -1;
789 CPU_ZERO(&lcore_config[idx].cpuset);
792 /* Get list of cores */
794 while (isblank(*lcores))
801 /* record lcore_set start point */
802 lcore_start = lcores;
804 /* go across a complete bracket */
805 if (*lcore_start == '(') {
806 lcores += strcspn(lcores, ")");
807 if (*lcores++ == '\0')
811 /* scan the separator '@', ','(next) or '\0'(finish) */
812 lcores += strcspn(lcores, "@,");
814 if (*lcores == '@') {
815 /* explicit assign cpu_set */
816 offset = eal_parse_set(lcores + 1, set, RTE_DIM(set));
820 /* prepare cpu_set and update the end cursor */
821 if (0 > convert_to_cpuset(&cpuset,
824 end = lcores + 1 + offset;
825 } else { /* ',' or '\0' */
826 /* haven't given cpu_set, current loop done */
829 /* go back to check <number>-<number> */
830 offset = strcspn(lcore_start, "(-");
831 if (offset < (end - lcore_start) &&
832 *(lcore_start + offset) != '(')
836 if (*end != ',' && *end != '\0')
839 /* parse lcore_set from start point */
840 if (0 > eal_parse_set(lcore_start, set, RTE_DIM(set)))
843 /* without '@', by default using lcore_set as cpu_set */
844 if (*lcores != '@' &&
845 0 > convert_to_cpuset(&cpuset, set, RTE_DIM(set)))
848 /* start to update lcore_set */
849 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
853 if (cfg->lcore_role[idx] != ROLE_RTE) {
854 lcore_config[idx].core_index = count;
855 cfg->lcore_role[idx] = ROLE_RTE;
861 CPU_SET(idx, &cpuset);
863 rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
864 sizeof(rte_cpuset_t));
868 } while (*end != '\0');
873 cfg->lcore_count = count;
882 eal_parse_syslog(const char *facility, struct internal_config *conf)
885 static const struct {
889 { "auth", LOG_AUTH },
890 { "cron", LOG_CRON },
891 { "daemon", LOG_DAEMON },
893 { "kern", LOG_KERN },
895 { "mail", LOG_MAIL },
896 { "news", LOG_NEWS },
897 { "syslog", LOG_SYSLOG },
898 { "user", LOG_USER },
899 { "uucp", LOG_UUCP },
900 { "local0", LOG_LOCAL0 },
901 { "local1", LOG_LOCAL1 },
902 { "local2", LOG_LOCAL2 },
903 { "local3", LOG_LOCAL3 },
904 { "local4", LOG_LOCAL4 },
905 { "local5", LOG_LOCAL5 },
906 { "local6", LOG_LOCAL6 },
907 { "local7", LOG_LOCAL7 },
911 for (i = 0; map[i].name; i++) {
912 if (!strcmp(facility, map[i].name)) {
913 conf->syslog_facility = map[i].value;
921 eal_parse_log_priority(const char *level)
923 static const char * const levels[] = {
924 [RTE_LOG_EMERG] = "emergency",
925 [RTE_LOG_ALERT] = "alert",
926 [RTE_LOG_CRIT] = "critical",
927 [RTE_LOG_ERR] = "error",
928 [RTE_LOG_WARNING] = "warning",
929 [RTE_LOG_NOTICE] = "notice",
930 [RTE_LOG_INFO] = "info",
931 [RTE_LOG_DEBUG] = "debug",
933 size_t len = strlen(level);
941 /* look for named values, skip 0 which is not a valid level */
942 for (i = 1; i < RTE_DIM(levels); i++) {
943 if (strncmp(levels[i], level, len) == 0)
947 /* not a string, maybe it is numeric */
949 tmp = strtoul(level, &end, 0);
951 /* check for errors */
952 if (errno != 0 || end == NULL || *end != '\0' ||
960 eal_parse_log_level(const char *arg)
962 const char *pattern = NULL;
963 const char *regex = NULL;
971 if ((level = strchr(str, ','))) {
974 } else if ((level = strchr(str, ':'))) {
981 priority = eal_parse_log_priority(level);
983 fprintf(stderr, "invalid log priority: %s\n", level);
988 if (rte_log_set_level_regexp(regex, priority) < 0) {
989 fprintf(stderr, "cannot set log level %s,%d\n",
993 if (rte_log_save_regexp(regex, priority) < 0)
995 } else if (pattern) {
996 if (rte_log_set_level_pattern(pattern, priority) < 0) {
997 fprintf(stderr, "cannot set log level %s:%d\n",
1001 if (rte_log_save_pattern(pattern, priority) < 0)
1004 rte_log_set_global_level(priority);
1015 static enum rte_proc_type_t
1016 eal_parse_proc_type(const char *arg)
1018 if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
1019 return RTE_PROC_PRIMARY;
1020 if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
1021 return RTE_PROC_SECONDARY;
1022 if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
1023 return RTE_PROC_AUTO;
1025 return RTE_PROC_INVALID;
1029 eal_parse_common_option(int opt, const char *optarg,
1030 struct internal_config *conf)
1040 if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI,
1050 if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI,
1058 if (eal_parse_coremask(optarg) < 0) {
1059 RTE_LOG(ERR, EAL, "invalid coremask\n");
1064 RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s) is set!\n",
1065 (core_parsed == LCORE_OPT_LST) ? "-l" :
1066 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1071 core_parsed = LCORE_OPT_MSK;
1075 if (eal_parse_corelist(optarg) < 0) {
1076 RTE_LOG(ERR, EAL, "invalid core list\n");
1081 RTE_LOG(ERR, EAL, "Option -l is ignored, because (%s) is set!\n",
1082 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1083 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1088 core_parsed = LCORE_OPT_LST;
1090 /* service coremask */
1092 if (eal_parse_service_coremask(optarg) < 0) {
1093 RTE_LOG(ERR, EAL, "invalid service coremask\n");
1097 /* service corelist */
1099 if (eal_parse_service_corelist(optarg) < 0) {
1100 RTE_LOG(ERR, EAL, "invalid service core list\n");
1104 /* size of memory */
1106 conf->memory = atoi(optarg);
1107 conf->memory *= 1024ULL;
1108 conf->memory *= 1024ULL;
1111 /* force number of channels */
1113 conf->force_nchannel = atoi(optarg);
1114 if (conf->force_nchannel == 0) {
1115 RTE_LOG(ERR, EAL, "invalid channel number\n");
1119 /* force number of ranks */
1121 conf->force_nrank = atoi(optarg);
1122 if (conf->force_nrank == 0 ||
1123 conf->force_nrank > 16) {
1124 RTE_LOG(ERR, EAL, "invalid rank number\n");
1128 /* force loading of external driver */
1130 if (eal_plugin_add(optarg) == -1)
1134 /* since message is explicitly requested by user, we
1135 * write message at highest log level so it can always
1137 * even if info or warning messages are disabled */
1138 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
1142 case OPT_HUGE_UNLINK_NUM:
1143 conf->hugepage_unlink = 1;
1146 case OPT_NO_HUGE_NUM:
1147 conf->no_hugetlbfs = 1;
1148 /* no-huge is legacy mem */
1149 conf->legacy_mem = 1;
1152 case OPT_NO_PCI_NUM:
1156 case OPT_NO_HPET_NUM:
1160 case OPT_VMWARE_TSC_MAP_NUM:
1161 conf->vmware_tsc_map = 1;
1164 case OPT_NO_SHCONF_NUM:
1165 conf->no_shconf = 1;
1168 case OPT_PROC_TYPE_NUM:
1169 conf->process_type = eal_parse_proc_type(optarg);
1172 case OPT_MASTER_LCORE_NUM:
1173 if (eal_parse_master_lcore(optarg) < 0) {
1174 RTE_LOG(ERR, EAL, "invalid parameter for --"
1175 OPT_MASTER_LCORE "\n");
1181 if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1187 case OPT_SYSLOG_NUM:
1188 if (eal_parse_syslog(optarg, conf) < 0) {
1189 RTE_LOG(ERR, EAL, "invalid parameters for --"
1195 case OPT_LOG_LEVEL_NUM: {
1196 if (eal_parse_log_level(optarg) < 0) {
1198 "invalid parameters for --"
1199 OPT_LOG_LEVEL "\n");
1204 case OPT_LCORES_NUM:
1205 if (eal_parse_lcores(optarg) < 0) {
1206 RTE_LOG(ERR, EAL, "invalid parameter for --"
1212 RTE_LOG(ERR, EAL, "Option --lcore is ignored, because (%s) is set!\n",
1213 (core_parsed == LCORE_OPT_LST) ? "-l" :
1214 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1219 core_parsed = LCORE_OPT_MAP;
1221 case OPT_LEGACY_MEM_NUM:
1222 conf->legacy_mem = 1;
1224 case OPT_SINGLE_FILE_SEGMENTS_NUM:
1225 conf->single_file_segments = 1;
1228 /* don't know what to do, leave this to caller */
1236 RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
1237 "cannot be used at the same time\n");
1242 eal_auto_detect_cores(struct rte_config *cfg)
1244 unsigned int lcore_id;
1245 unsigned int removed = 0;
1246 rte_cpuset_t affinity_set;
1247 pthread_t tid = pthread_self();
1249 if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t),
1251 CPU_ZERO(&affinity_set);
1253 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1254 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1255 !CPU_ISSET(lcore_id, &affinity_set)) {
1256 cfg->lcore_role[lcore_id] = ROLE_OFF;
1261 cfg->lcore_count -= removed;
1265 eal_adjust_config(struct internal_config *internal_cfg)
1268 struct rte_config *cfg = rte_eal_get_configuration();
1271 eal_auto_detect_cores(cfg);
1273 if (internal_config.process_type == RTE_PROC_AUTO)
1274 internal_config.process_type = eal_proc_type_detect();
1276 /* default master lcore is the first one */
1277 if (!master_lcore_parsed) {
1278 cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
1279 lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
1282 /* if no memory amounts were requested, this will result in 0 and
1283 * will be overridden later, right after eal_hugepage_info_init() */
1284 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1285 internal_cfg->memory += internal_cfg->socket_mem[i];
1291 eal_check_common_options(struct internal_config *internal_cfg)
1293 struct rte_config *cfg = rte_eal_get_configuration();
1295 if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
1296 RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
1300 if (internal_cfg->process_type == RTE_PROC_INVALID) {
1301 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1304 if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
1305 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1309 if (mem_parsed && internal_cfg->force_sockets == 1) {
1310 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1311 "be specified at the same time\n");
1314 if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1315 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1316 "be specified together with --"OPT_NO_HUGE"\n");
1320 if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink) {
1321 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1322 "be specified together with --"OPT_NO_HUGE"\n");
1330 eal_common_usage(void)
1332 printf("[options]\n\n"
1333 "EAL common options:\n"
1334 " -c COREMASK Hexadecimal bitmask of cores to run on\n"
1335 " -l CORELIST List of cores to run on\n"
1336 " The argument format is <c1>[-c2][,c3[-c4],...]\n"
1337 " where c1, c2, etc are core indexes between 0 and %d\n"
1338 " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
1339 " The argument format is\n"
1340 " '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
1341 " lcores and cpus list are grouped by '(' and ')'\n"
1342 " Within the group, '-' is used for range separator,\n"
1343 " ',' is used for single number separator.\n"
1344 " '( )' can be omitted for single element group,\n"
1345 " '@' can be omitted if cpus and lcores have the same value\n"
1346 " -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
1347 " --"OPT_MASTER_LCORE" ID Core ID that is used as master\n"
1348 " --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
1349 " -n CHANNELS Number of memory channels\n"
1350 " -m MB Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
1351 " -r RANKS Force number of memory ranks (don't detect)\n"
1352 " -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
1353 " Prevent EAL from using this PCI device. The argument\n"
1354 " format is <domain:bus:devid.func>.\n"
1355 " -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
1356 " Only use the specified PCI devices. The argument format\n"
1357 " is <[domain:]bus:devid.func>. This option can be present\n"
1358 " several times (once per device).\n"
1359 " [NOTE: PCI whitelist cannot be used with -b option]\n"
1360 " --"OPT_VDEV" Add a virtual device.\n"
1361 " The argument format is <driver><id>[,key=val,...]\n"
1362 " (ex: --vdev=net_pcap0,iface=eth2).\n"
1363 " -d LIB.so|DIR Add a driver or driver directory\n"
1364 " (can be used multiple times)\n"
1365 " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n"
1366 " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n"
1367 " --"OPT_SYSLOG" Set syslog facility\n"
1368 " --"OPT_LOG_LEVEL"=<int> Set global log level\n"
1369 " --"OPT_LOG_LEVEL"=<type-match>:<int>\n"
1370 " Set specific log level\n"
1371 " -v Display version information on startup\n"
1372 " -h, --help This help\n"
1373 "\nEAL options for DEBUG use only:\n"
1374 " --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n"
1375 " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
1376 " --"OPT_NO_PCI" Disable PCI\n"
1377 " --"OPT_NO_HPET" Disable HPET\n"
1378 " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
1379 "\n", RTE_MAX_LCORE);