4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #include <sys/types.h>
49 #include <rte_lcore.h>
50 #include <rte_version.h>
51 #include <rte_devargs.h>
52 #include <rte_memcpy.h>
54 #include "eal_internal_cfg.h"
55 #include "eal_options.h"
56 #include "eal_filesystem.h"
58 #define BITS_PER_HEX 4
62 "b:" /* pci-blacklist */
64 "s:" /* service coremask */
68 "m:" /* memory size */
69 "n:" /* memory channels */
70 "r:" /* memory ranks */
72 "w:" /* pci-whitelist */
76 eal_long_options[] = {
77 {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM },
78 {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM },
79 {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM },
80 {OPT_HELP, 0, NULL, OPT_HELP_NUM },
81 {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
82 {OPT_HUGE_UNLINK, 0, NULL, OPT_HUGE_UNLINK_NUM },
83 {OPT_LCORES, 1, NULL, OPT_LCORES_NUM },
84 {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM },
85 {OPT_MASTER_LCORE, 1, NULL, OPT_MASTER_LCORE_NUM },
86 {OPT_NO_HPET, 0, NULL, OPT_NO_HPET_NUM },
87 {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM },
88 {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM },
89 {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM },
90 {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM },
91 {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM },
92 {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM },
93 {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM },
94 {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
95 {OPT_VDEV, 1, NULL, OPT_VDEV_NUM },
96 {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM },
97 {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
98 {OPT_XEN_DOM0, 0, NULL, OPT_XEN_DOM0_NUM },
102 TAILQ_HEAD(shared_driver_list, shared_driver);
104 /* Definition for shared object drivers. */
105 struct shared_driver {
106 TAILQ_ENTRY(shared_driver) next;
112 /* List of external loadable drivers */
113 static struct shared_driver_list solib_list =
114 TAILQ_HEAD_INITIALIZER(solib_list);
116 /* Default path of external loadable drivers */
117 static const char *default_solib_dir = RTE_EAL_PMD_PATH;
120 * Stringified version of solib path used by dpdk-pmdinfo.py
121 * Note: PLEASE DO NOT ALTER THIS without making a corresponding
122 * change to usertools/dpdk-pmdinfo.py
124 static const char dpdk_solib_path[] __attribute__((used)) =
125 "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
128 static int master_lcore_parsed;
129 static int mem_parsed;
130 static int core_parsed;
133 eal_reset_internal_config(struct internal_config *internal_cfg)
137 internal_cfg->memory = 0;
138 internal_cfg->force_nrank = 0;
139 internal_cfg->force_nchannel = 0;
140 internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
141 internal_cfg->hugepage_dir = NULL;
142 internal_cfg->force_sockets = 0;
143 /* zero out the NUMA config */
144 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
145 internal_cfg->socket_mem[i] = 0;
146 /* zero out hugedir descriptors */
147 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
148 internal_cfg->hugepage_info[i].lock_descriptor = -1;
149 internal_cfg->base_virtaddr = 0;
151 internal_cfg->syslog_facility = LOG_DAEMON;
153 internal_cfg->xen_dom0_support = 0;
155 /* if set to NONE, interrupt mode is determined automatically */
156 internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
158 #ifdef RTE_LIBEAL_USE_HPET
159 internal_cfg->no_hpet = 0;
161 internal_cfg->no_hpet = 1;
163 internal_cfg->vmware_tsc_map = 0;
164 internal_cfg->create_uio_dev = 0;
168 eal_plugin_add(const char *path)
170 struct shared_driver *solib;
172 solib = malloc(sizeof(*solib));
174 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
177 memset(solib, 0, sizeof(*solib));
178 strncpy(solib->name, path, PATH_MAX-1);
179 solib->name[PATH_MAX-1] = 0;
180 TAILQ_INSERT_TAIL(&solib_list, solib, next);
186 eal_plugindir_init(const char *path)
189 struct dirent *dent = NULL;
190 char sopath[PATH_MAX];
192 if (path == NULL || *path == '\0')
197 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
198 path, strerror(errno));
202 while ((dent = readdir(d)) != NULL) {
205 snprintf(sopath, PATH_MAX-1, "%s/%s", path, dent->d_name);
206 sopath[PATH_MAX-1] = 0;
208 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
211 if (eal_plugin_add(sopath) == -1)
216 /* XXX this ignores failures from readdir() itself */
217 return (dent == NULL) ? 0 : -1;
221 eal_plugins_init(void)
223 struct shared_driver *solib = NULL;
225 if (*default_solib_dir != '\0')
226 eal_plugin_add(default_solib_dir);
228 TAILQ_FOREACH(solib, &solib_list, next) {
231 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
232 if (eal_plugindir_init(solib->name) == -1) {
234 "Cannot init plugin directory %s\n",
239 RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
241 solib->lib_handle = dlopen(solib->name, RTLD_NOW);
242 if (solib->lib_handle == NULL) {
243 RTE_LOG(ERR, EAL, "%s\n", dlerror());
253 * Parse the coremask given as argument (hexadecimal string) and fill
254 * the global configuration (core role and core count) with the parsed
257 static int xdigit2val(unsigned char c)
271 eal_parse_service_coremask(const char *coremask)
273 struct rte_config *cfg = rte_eal_get_configuration();
275 unsigned int count = 0;
279 if (coremask == NULL)
281 /* Remove all blank characters ahead and after .
282 * Remove 0x/0X if exists.
284 while (isblank(*coremask))
286 if (coremask[0] == '0' && ((coremask[1] == 'x')
287 || (coremask[1] == 'X')))
289 i = strlen(coremask);
290 while ((i > 0) && isblank(coremask[i - 1]))
296 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
298 if (isxdigit(c) == 0) {
299 /* invalid characters */
303 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
305 if ((1 << j) & val) {
306 /* handle master lcore already parsed */
307 uint32_t lcore = idx;
308 if (master_lcore_parsed &&
309 cfg->master_lcore == lcore) {
311 "Error: lcore %u is master lcore, cannot use as service core\n",
316 if (!lcore_config[idx].detected) {
318 "lcore %u unavailable\n", idx);
321 lcore_config[idx].core_role = ROLE_SERVICE;
328 if (coremask[i] != '0')
331 for (; idx < RTE_MAX_LCORE; idx++)
332 lcore_config[idx].core_index = -1;
337 cfg->service_lcore_count = count;
342 eal_parse_coremask(const char *coremask)
344 struct rte_config *cfg = rte_eal_get_configuration();
350 if (coremask == NULL)
352 /* Remove all blank characters ahead and after .
353 * Remove 0x/0X if exists.
355 while (isblank(*coremask))
357 if (coremask[0] == '0' && ((coremask[1] == 'x')
358 || (coremask[1] == 'X')))
360 i = strlen(coremask);
361 while ((i > 0) && isblank(coremask[i - 1]))
366 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
368 if (isxdigit(c) == 0) {
369 /* invalid characters */
373 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
375 if ((1 << j) & val) {
376 if (!lcore_config[idx].detected) {
377 RTE_LOG(ERR, EAL, "lcore %u "
378 "unavailable\n", idx);
381 cfg->lcore_role[idx] = ROLE_RTE;
382 lcore_config[idx].core_index = count;
385 cfg->lcore_role[idx] = ROLE_OFF;
386 lcore_config[idx].core_index = -1;
391 if (coremask[i] != '0')
393 for (; idx < RTE_MAX_LCORE; idx++) {
394 cfg->lcore_role[idx] = ROLE_OFF;
395 lcore_config[idx].core_index = -1;
399 /* Update the count of enabled logical cores of the EAL configuration */
400 cfg->lcore_count = count;
405 eal_parse_corelist(const char *corelist)
407 struct rte_config *cfg = rte_eal_get_configuration();
413 if (corelist == NULL)
416 /* Remove all blank characters ahead and after */
417 while (isblank(*corelist))
419 i = strlen(corelist);
420 while ((i > 0) && isblank(corelist[i - 1]))
424 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
425 cfg->lcore_role[idx] = ROLE_OFF;
426 lcore_config[idx].core_index = -1;
429 /* Get list of cores */
432 while (isblank(*corelist))
434 if (*corelist == '\0')
437 idx = strtoul(corelist, &end, 10);
438 if (errno || end == NULL)
440 while (isblank(*end))
444 } else if ((*end == ',') || (*end == '\0')) {
446 if (min == RTE_MAX_LCORE)
448 for (idx = min; idx <= max; idx++) {
449 if (cfg->lcore_role[idx] != ROLE_RTE) {
450 cfg->lcore_role[idx] = ROLE_RTE;
451 lcore_config[idx].core_index = count;
459 } while (*end != '\0');
464 /* Update the count of enabled logical cores of the EAL configuration */
465 cfg->lcore_count = count;
470 /* Changes the lcore id of the master thread */
472 eal_parse_master_lcore(const char *arg)
475 struct rte_config *cfg = rte_eal_get_configuration();
478 cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
479 if (errno || parsing_end[0] != 0)
481 if (cfg->master_lcore >= RTE_MAX_LCORE)
483 master_lcore_parsed = 1;
485 /* ensure master core is not used as service core */
486 if (lcore_config[cfg->master_lcore].core_role == ROLE_SERVICE) {
487 RTE_LOG(ERR, EAL, "Error: Master lcore is used as a service core.\n");
495 * Parse elem, the elem could be single number/range or '(' ')' group
496 * 1) A single number elem, it's just a simple digit. e.g. 9
497 * 2) A single range elem, two digits with a '-' between. e.g. 2-6
498 * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
499 * Within group elem, '-' used for a range separator;
500 * ',' used for a single number.
503 eal_parse_set(const char *input, uint16_t set[], unsigned num)
506 const char *str = input;
510 memset(set, 0, num * sizeof(uint16_t));
512 while (isblank(*str))
515 /* only digit or left bracket is qualify for start point */
516 if ((!isdigit(*str) && *str != '(') || *str == '\0')
519 /* process single number or single range of number */
522 idx = strtoul(str, &end, 10);
523 if (errno || end == NULL || idx >= num)
526 while (isblank(*end))
532 /* process single <number>-<number> */
534 while (isblank(*end))
540 idx = strtoul(end, &end, 10);
541 if (errno || end == NULL || idx >= num)
544 while (isblank(*end))
546 if (*end != ',' && *end != '\0')
550 if (*end != ',' && *end != '\0' &&
554 for (idx = RTE_MIN(min, max);
555 idx <= RTE_MAX(min, max); idx++)
562 /* process set within bracket */
564 while (isblank(*str))
572 /* go ahead to the first digit */
573 while (isblank(*str))
578 /* get the digit value */
580 idx = strtoul(str, &end, 10);
581 if (errno || end == NULL || idx >= num)
584 /* go ahead to separator '-',',' and ')' */
585 while (isblank(*end))
588 if (min == RTE_MAX_LCORE)
590 else /* avoid continuous '-' */
592 } else if ((*end == ',') || (*end == ')')) {
594 if (min == RTE_MAX_LCORE)
596 for (idx = RTE_MIN(min, max);
597 idx <= RTE_MAX(min, max); idx++)
605 } while (*end != '\0' && *end != ')');
608 * to avoid failure that tail blank makes end character check fail
609 * in eal_parse_lcores( )
611 while (isblank(*str))
617 /* convert from set array to cpuset bitmap */
619 convert_to_cpuset(rte_cpuset_t *cpusetp,
620 uint16_t *set, unsigned num)
626 for (idx = 0; idx < num; idx++) {
630 if (!lcore_config[idx].detected) {
631 RTE_LOG(ERR, EAL, "core %u "
632 "unavailable\n", idx);
636 CPU_SET(idx, cpusetp);
643 * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
644 * lcores, cpus could be a single digit/range or a group.
645 * '(' and ')' are necessary if it's a group.
646 * If not supply '@cpus', the value of cpus uses the same as lcores.
647 * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
648 * lcore 0 runs on cpuset 0x41 (cpu 0,6)
649 * lcore 1 runs on cpuset 0x2 (cpu 1)
650 * lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
651 * lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
652 * lcore 6 runs on cpuset 0x41 (cpu 0,6)
653 * lcore 7 runs on cpuset 0x80 (cpu 7)
654 * lcore 8 runs on cpuset 0x100 (cpu 8)
657 eal_parse_lcores(const char *lcores)
659 struct rte_config *cfg = rte_eal_get_configuration();
660 static uint16_t set[RTE_MAX_LCORE];
663 const char *lcore_start = NULL;
664 const char *end = NULL;
673 /* Remove all blank characters ahead and after */
674 while (isblank(*lcores))
679 /* Reset lcore config */
680 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
681 cfg->lcore_role[idx] = ROLE_OFF;
682 lcore_config[idx].core_index = -1;
683 CPU_ZERO(&lcore_config[idx].cpuset);
686 /* Get list of cores */
688 while (isblank(*lcores))
695 /* record lcore_set start point */
696 lcore_start = lcores;
698 /* go across a complete bracket */
699 if (*lcore_start == '(') {
700 lcores += strcspn(lcores, ")");
701 if (*lcores++ == '\0')
705 /* scan the separator '@', ','(next) or '\0'(finish) */
706 lcores += strcspn(lcores, "@,");
708 if (*lcores == '@') {
709 /* explicit assign cpu_set */
710 offset = eal_parse_set(lcores + 1, set, RTE_DIM(set));
714 /* prepare cpu_set and update the end cursor */
715 if (0 > convert_to_cpuset(&cpuset,
718 end = lcores + 1 + offset;
719 } else { /* ',' or '\0' */
720 /* haven't given cpu_set, current loop done */
723 /* go back to check <number>-<number> */
724 offset = strcspn(lcore_start, "(-");
725 if (offset < (end - lcore_start) &&
726 *(lcore_start + offset) != '(')
730 if (*end != ',' && *end != '\0')
733 /* parse lcore_set from start point */
734 if (0 > eal_parse_set(lcore_start, set, RTE_DIM(set)))
737 /* without '@', by default using lcore_set as cpu_set */
738 if (*lcores != '@' &&
739 0 > convert_to_cpuset(&cpuset, set, RTE_DIM(set)))
742 /* start to update lcore_set */
743 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
747 if (cfg->lcore_role[idx] != ROLE_RTE) {
748 lcore_config[idx].core_index = count;
749 cfg->lcore_role[idx] = ROLE_RTE;
755 CPU_SET(idx, &cpuset);
757 rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
758 sizeof(rte_cpuset_t));
762 } while (*end != '\0');
767 cfg->lcore_count = count;
776 eal_parse_syslog(const char *facility, struct internal_config *conf)
783 { "auth", LOG_AUTH },
784 { "cron", LOG_CRON },
785 { "daemon", LOG_DAEMON },
787 { "kern", LOG_KERN },
789 { "mail", LOG_MAIL },
790 { "news", LOG_NEWS },
791 { "syslog", LOG_SYSLOG },
792 { "user", LOG_USER },
793 { "uucp", LOG_UUCP },
794 { "local0", LOG_LOCAL0 },
795 { "local1", LOG_LOCAL1 },
796 { "local2", LOG_LOCAL2 },
797 { "local3", LOG_LOCAL3 },
798 { "local4", LOG_LOCAL4 },
799 { "local5", LOG_LOCAL5 },
800 { "local6", LOG_LOCAL6 },
801 { "local7", LOG_LOCAL7 },
805 for (i = 0; map[i].name; i++) {
806 if (!strcmp(facility, map[i].name)) {
807 conf->syslog_facility = map[i].value;
815 eal_parse_log_level(const char *arg)
817 char *end, *str, *type, *level;
824 if (strchr(str, ',') == NULL) {
828 type = strsep(&str, ",");
829 level = strsep(&str, ",");
833 tmp = strtoul(level, &end, 0);
835 /* check for errors */
836 if ((errno != 0) || (level[0] == '\0') ||
837 end == NULL || (*end != '\0'))
840 /* log_level is a uint32_t */
841 if (tmp >= UINT32_MAX)
845 rte_log_set_global_level(tmp);
846 } else if (rte_log_set_level_regexp(type, tmp) < 0) {
847 printf("cannot set log level %s,%lu\n",
860 static enum rte_proc_type_t
861 eal_parse_proc_type(const char *arg)
863 if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
864 return RTE_PROC_PRIMARY;
865 if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
866 return RTE_PROC_SECONDARY;
867 if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
868 return RTE_PROC_AUTO;
870 return RTE_PROC_INVALID;
874 eal_parse_common_option(int opt, const char *optarg,
875 struct internal_config *conf)
880 if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
887 if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
894 if (eal_parse_coremask(optarg) < 0) {
895 RTE_LOG(ERR, EAL, "invalid coremask\n");
902 if (eal_parse_corelist(optarg) < 0) {
903 RTE_LOG(ERR, EAL, "invalid core list\n");
908 /* service coremask */
910 if (eal_parse_service_coremask(optarg) < 0) {
911 RTE_LOG(ERR, EAL, "invalid service coremask\n");
917 conf->memory = atoi(optarg);
918 conf->memory *= 1024ULL;
919 conf->memory *= 1024ULL;
922 /* force number of channels */
924 conf->force_nchannel = atoi(optarg);
925 if (conf->force_nchannel == 0) {
926 RTE_LOG(ERR, EAL, "invalid channel number\n");
930 /* force number of ranks */
932 conf->force_nrank = atoi(optarg);
933 if (conf->force_nrank == 0 ||
934 conf->force_nrank > 16) {
935 RTE_LOG(ERR, EAL, "invalid rank number\n");
939 /* force loading of external driver */
941 if (eal_plugin_add(optarg) == -1)
945 /* since message is explicitly requested by user, we
946 * write message at highest log level so it can always
948 * even if info or warning messages are disabled */
949 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
953 case OPT_HUGE_UNLINK_NUM:
954 conf->hugepage_unlink = 1;
957 case OPT_NO_HUGE_NUM:
958 conf->no_hugetlbfs = 1;
965 case OPT_NO_HPET_NUM:
969 case OPT_VMWARE_TSC_MAP_NUM:
970 conf->vmware_tsc_map = 1;
973 case OPT_NO_SHCONF_NUM:
977 case OPT_PROC_TYPE_NUM:
978 conf->process_type = eal_parse_proc_type(optarg);
981 case OPT_MASTER_LCORE_NUM:
982 if (eal_parse_master_lcore(optarg) < 0) {
983 RTE_LOG(ERR, EAL, "invalid parameter for --"
984 OPT_MASTER_LCORE "\n");
990 if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
997 if (eal_parse_syslog(optarg, conf) < 0) {
998 RTE_LOG(ERR, EAL, "invalid parameters for --"
1004 case OPT_LOG_LEVEL_NUM: {
1005 if (eal_parse_log_level(optarg) < 0) {
1007 "invalid parameters for --"
1008 OPT_LOG_LEVEL "\n");
1013 case OPT_LCORES_NUM:
1014 if (eal_parse_lcores(optarg) < 0) {
1015 RTE_LOG(ERR, EAL, "invalid parameter for --"
1022 /* don't know what to do, leave this to caller */
1032 eal_auto_detect_cores(struct rte_config *cfg)
1034 unsigned int lcore_id;
1035 unsigned int removed = 0;
1036 rte_cpuset_t affinity_set;
1037 pthread_t tid = pthread_self();
1039 if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t),
1041 CPU_ZERO(&affinity_set);
1043 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1044 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1045 !CPU_ISSET(lcore_id, &affinity_set)) {
1046 cfg->lcore_role[lcore_id] = ROLE_OFF;
1051 cfg->lcore_count -= removed;
1055 eal_adjust_config(struct internal_config *internal_cfg)
1058 struct rte_config *cfg = rte_eal_get_configuration();
1061 eal_auto_detect_cores(cfg);
1063 if (internal_config.process_type == RTE_PROC_AUTO)
1064 internal_config.process_type = eal_proc_type_detect();
1066 /* default master lcore is the first one */
1067 if (!master_lcore_parsed) {
1068 cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
1069 lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
1072 /* if no memory amounts were requested, this will result in 0 and
1073 * will be overridden later, right after eal_hugepage_info_init() */
1074 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1075 internal_cfg->memory += internal_cfg->socket_mem[i];
1081 eal_check_common_options(struct internal_config *internal_cfg)
1083 struct rte_config *cfg = rte_eal_get_configuration();
1085 if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
1086 RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
1090 if (internal_cfg->process_type == RTE_PROC_INVALID) {
1091 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1094 if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
1095 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1099 if (mem_parsed && internal_cfg->force_sockets == 1) {
1100 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1101 "be specified at the same time\n");
1104 if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1105 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1106 "be specified together with --"OPT_NO_HUGE"\n");
1110 if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink) {
1111 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1112 "be specified together with --"OPT_NO_HUGE"\n");
1120 eal_common_usage(void)
1122 printf("[options]\n\n"
1123 "EAL common options:\n"
1124 " -c COREMASK Hexadecimal bitmask of cores to run on\n"
1125 " -l CORELIST List of cores to run on\n"
1126 " The argument format is <c1>[-c2][,c3[-c4],...]\n"
1127 " where c1, c2, etc are core indexes between 0 and %d\n"
1128 " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
1129 " The argument format is\n"
1130 " '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
1131 " lcores and cpus list are grouped by '(' and ')'\n"
1132 " Within the group, '-' is used for range separator,\n"
1133 " ',' is used for single number separator.\n"
1134 " '( )' can be omitted for single element group,\n"
1135 " '@' can be omitted if cpus and lcores have the same value\n"
1136 " -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
1137 " --"OPT_MASTER_LCORE" ID Core ID that is used as master\n"
1138 " -n CHANNELS Number of memory channels\n"
1139 " -m MB Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
1140 " -r RANKS Force number of memory ranks (don't detect)\n"
1141 " -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
1142 " Prevent EAL from using this PCI device. The argument\n"
1143 " format is <domain:bus:devid.func>.\n"
1144 " -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
1145 " Only use the specified PCI devices. The argument format\n"
1146 " is <[domain:]bus:devid.func>. This option can be present\n"
1147 " several times (once per device).\n"
1148 " [NOTE: PCI whitelist cannot be used with -b option]\n"
1149 " --"OPT_VDEV" Add a virtual device.\n"
1150 " The argument format is <driver><id>[,key=val,...]\n"
1151 " (ex: --vdev=net_pcap0,iface=eth2).\n"
1152 " -d LIB.so|DIR Add a driver or driver directory\n"
1153 " (can be used multiple times)\n"
1154 " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n"
1155 " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n"
1156 " --"OPT_SYSLOG" Set syslog facility\n"
1157 " --"OPT_LOG_LEVEL"=<int> Set global log level\n"
1158 " --"OPT_LOG_LEVEL"=<type-regexp>,<int>\n"
1159 " Set specific log level\n"
1160 " -v Display version information on startup\n"
1161 " -h, --help This help\n"
1162 "\nEAL options for DEBUG use only:\n"
1163 " --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n"
1164 " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
1165 " --"OPT_NO_PCI" Disable PCI\n"
1166 " --"OPT_NO_HPET" Disable HPET\n"
1167 " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
1168 "\n", RTE_MAX_LCORE);