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_tailq.h>
51 #include <rte_version.h>
52 #include <rte_devargs.h>
53 #include <rte_memcpy.h>
55 #include "eal_internal_cfg.h"
56 #include "eal_options.h"
57 #include "eal_filesystem.h"
59 #define BITS_PER_HEX 4
63 "b:" /* pci-blacklist */
65 "s:" /* service coremask */
69 "S:" /* service corelist */
70 "m:" /* memory size */
71 "n:" /* memory channels */
72 "r:" /* memory ranks */
74 "w:" /* pci-whitelist */
78 eal_long_options[] = {
79 {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM },
80 {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM },
81 {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM },
82 {OPT_HELP, 0, NULL, OPT_HELP_NUM },
83 {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM },
84 {OPT_HUGE_UNLINK, 0, NULL, OPT_HUGE_UNLINK_NUM },
85 {OPT_LCORES, 1, NULL, OPT_LCORES_NUM },
86 {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM },
87 {OPT_MASTER_LCORE, 1, NULL, OPT_MASTER_LCORE_NUM },
88 {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
89 {OPT_NO_HPET, 0, NULL, OPT_NO_HPET_NUM },
90 {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM },
91 {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM },
92 {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM },
93 {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM },
94 {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM },
95 {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM },
96 {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM },
97 {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
98 {OPT_VDEV, 1, NULL, OPT_VDEV_NUM },
99 {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM },
100 {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM },
104 TAILQ_HEAD(shared_driver_list, shared_driver);
106 /* Definition for shared object drivers. */
107 struct shared_driver {
108 TAILQ_ENTRY(shared_driver) next;
114 /* List of external loadable drivers */
115 static struct shared_driver_list solib_list =
116 TAILQ_HEAD_INITIALIZER(solib_list);
118 /* Default path of external loadable drivers */
119 static const char *default_solib_dir = RTE_EAL_PMD_PATH;
122 * Stringified version of solib path used by dpdk-pmdinfo.py
123 * Note: PLEASE DO NOT ALTER THIS without making a corresponding
124 * change to usertools/dpdk-pmdinfo.py
126 static const char dpdk_solib_path[] __attribute__((used)) =
127 "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
129 TAILQ_HEAD(device_option_list, device_option);
131 struct device_option {
132 TAILQ_ENTRY(device_option) next;
134 enum rte_devtype type;
138 static struct device_option_list devopt_list =
139 TAILQ_HEAD_INITIALIZER(devopt_list);
141 static int master_lcore_parsed;
142 static int mem_parsed;
143 static int core_parsed;
146 eal_option_device_add(enum rte_devtype type, const char *optarg)
148 struct device_option *devopt;
152 optlen = strlen(optarg) + 1;
153 devopt = calloc(1, sizeof(*devopt) + optlen);
154 if (devopt == NULL) {
155 RTE_LOG(ERR, EAL, "Unable to allocate device option\n");
160 ret = snprintf(devopt->arg, optlen, "%s", optarg);
162 RTE_LOG(ERR, EAL, "Unable to copy device option\n");
166 TAILQ_INSERT_TAIL(&devopt_list, devopt, next);
171 eal_option_device_parse(void)
173 struct device_option *devopt;
177 TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
179 ret = rte_eal_devargs_add(devopt->type, devopt->arg);
181 RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n",
184 TAILQ_REMOVE(&devopt_list, devopt, next);
191 eal_reset_internal_config(struct internal_config *internal_cfg)
195 internal_cfg->memory = 0;
196 internal_cfg->force_nrank = 0;
197 internal_cfg->force_nchannel = 0;
198 internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
199 internal_cfg->hugepage_dir = NULL;
200 internal_cfg->force_sockets = 0;
201 /* zero out the NUMA config */
202 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
203 internal_cfg->socket_mem[i] = 0;
204 /* zero out hugedir descriptors */
205 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
206 internal_cfg->hugepage_info[i].lock_descriptor = -1;
207 internal_cfg->base_virtaddr = 0;
209 internal_cfg->syslog_facility = LOG_DAEMON;
211 /* if set to NONE, interrupt mode is determined automatically */
212 internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
214 #ifdef RTE_LIBEAL_USE_HPET
215 internal_cfg->no_hpet = 0;
217 internal_cfg->no_hpet = 1;
219 internal_cfg->vmware_tsc_map = 0;
220 internal_cfg->create_uio_dev = 0;
221 internal_cfg->mbuf_pool_ops_name = RTE_MBUF_DEFAULT_MEMPOOL_OPS;
225 eal_plugin_add(const char *path)
227 struct shared_driver *solib;
229 solib = malloc(sizeof(*solib));
231 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
234 memset(solib, 0, sizeof(*solib));
235 strncpy(solib->name, path, PATH_MAX-1);
236 solib->name[PATH_MAX-1] = 0;
237 TAILQ_INSERT_TAIL(&solib_list, solib, next);
243 eal_plugindir_init(const char *path)
246 struct dirent *dent = NULL;
247 char sopath[PATH_MAX];
249 if (path == NULL || *path == '\0')
254 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
255 path, strerror(errno));
259 while ((dent = readdir(d)) != NULL) {
262 snprintf(sopath, PATH_MAX-1, "%s/%s", path, dent->d_name);
263 sopath[PATH_MAX-1] = 0;
265 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
268 if (eal_plugin_add(sopath) == -1)
273 /* XXX this ignores failures from readdir() itself */
274 return (dent == NULL) ? 0 : -1;
278 eal_plugins_init(void)
280 struct shared_driver *solib = NULL;
283 if (*default_solib_dir != '\0' && stat(solib->name, &sb) == 0 &&
285 eal_plugin_add(default_solib_dir);
287 TAILQ_FOREACH(solib, &solib_list, next) {
289 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
290 if (eal_plugindir_init(solib->name) == -1) {
292 "Cannot init plugin directory %s\n",
297 RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
299 solib->lib_handle = dlopen(solib->name, RTLD_NOW);
300 if (solib->lib_handle == NULL) {
301 RTE_LOG(ERR, EAL, "%s\n", dlerror());
311 * Parse the coremask given as argument (hexadecimal string) and fill
312 * the global configuration (core role and core count) with the parsed
315 static int xdigit2val(unsigned char c)
329 eal_parse_service_coremask(const char *coremask)
331 struct rte_config *cfg = rte_eal_get_configuration();
333 unsigned int count = 0;
337 if (coremask == NULL)
339 /* Remove all blank characters ahead and after .
340 * Remove 0x/0X if exists.
342 while (isblank(*coremask))
344 if (coremask[0] == '0' && ((coremask[1] == 'x')
345 || (coremask[1] == 'X')))
347 i = strlen(coremask);
348 while ((i > 0) && isblank(coremask[i - 1]))
354 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
356 if (isxdigit(c) == 0) {
357 /* invalid characters */
361 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
363 if ((1 << j) & val) {
364 /* handle master lcore already parsed */
365 uint32_t lcore = idx;
366 if (master_lcore_parsed &&
367 cfg->master_lcore == lcore) {
369 "Error: lcore %u is master lcore, cannot use as service core\n",
374 if (!lcore_config[idx].detected) {
376 "lcore %u unavailable\n", idx);
379 lcore_config[idx].core_role = ROLE_SERVICE;
386 if (coremask[i] != '0')
389 for (; idx < RTE_MAX_LCORE; idx++)
390 lcore_config[idx].core_index = -1;
395 cfg->service_lcore_count = count;
400 eal_parse_coremask(const char *coremask)
402 struct rte_config *cfg = rte_eal_get_configuration();
408 if (coremask == NULL)
410 /* Remove all blank characters ahead and after .
411 * Remove 0x/0X if exists.
413 while (isblank(*coremask))
415 if (coremask[0] == '0' && ((coremask[1] == 'x')
416 || (coremask[1] == 'X')))
418 i = strlen(coremask);
419 while ((i > 0) && isblank(coremask[i - 1]))
424 for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
426 if (isxdigit(c) == 0) {
427 /* invalid characters */
431 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
433 if ((1 << j) & val) {
434 if (!lcore_config[idx].detected) {
435 RTE_LOG(ERR, EAL, "lcore %u "
436 "unavailable\n", idx);
439 cfg->lcore_role[idx] = ROLE_RTE;
440 lcore_config[idx].core_index = count;
443 cfg->lcore_role[idx] = ROLE_OFF;
444 lcore_config[idx].core_index = -1;
449 if (coremask[i] != '0')
451 for (; idx < RTE_MAX_LCORE; idx++) {
452 cfg->lcore_role[idx] = ROLE_OFF;
453 lcore_config[idx].core_index = -1;
457 /* Update the count of enabled logical cores of the EAL configuration */
458 cfg->lcore_count = count;
463 eal_parse_service_corelist(const char *corelist)
465 struct rte_config *cfg = rte_eal_get_configuration();
471 if (corelist == NULL)
474 /* Remove all blank characters ahead and after */
475 while (isblank(*corelist))
477 i = strlen(corelist);
478 while ((i > 0) && isblank(corelist[i - 1]))
481 /* Get list of cores */
484 while (isblank(*corelist))
486 if (*corelist == '\0')
489 idx = strtoul(corelist, &end, 10);
490 if (errno || end == NULL)
492 while (isblank(*end))
496 } else if ((*end == ',') || (*end == '\0')) {
498 if (min == RTE_MAX_LCORE)
500 for (idx = min; idx <= max; idx++) {
501 if (cfg->lcore_role[idx] != ROLE_SERVICE) {
502 /* handle master lcore already parsed */
503 uint32_t lcore = idx;
504 if (cfg->master_lcore == lcore &&
505 master_lcore_parsed) {
507 "Error: lcore %u is master lcore, cannot use as service core\n",
511 lcore_config[idx].core_role =
520 } while (*end != '\0');
529 eal_parse_corelist(const char *corelist)
531 struct rte_config *cfg = rte_eal_get_configuration();
537 if (corelist == NULL)
540 /* Remove all blank characters ahead and after */
541 while (isblank(*corelist))
543 i = strlen(corelist);
544 while ((i > 0) && isblank(corelist[i - 1]))
548 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
549 cfg->lcore_role[idx] = ROLE_OFF;
550 lcore_config[idx].core_index = -1;
553 /* Get list of cores */
556 while (isblank(*corelist))
558 if (*corelist == '\0')
561 idx = strtoul(corelist, &end, 10);
562 if (errno || end == NULL)
564 while (isblank(*end))
568 } else if ((*end == ',') || (*end == '\0')) {
570 if (min == RTE_MAX_LCORE)
572 for (idx = min; idx <= max; idx++) {
573 if (cfg->lcore_role[idx] != ROLE_RTE) {
574 cfg->lcore_role[idx] = ROLE_RTE;
575 lcore_config[idx].core_index = count;
583 } while (*end != '\0');
588 /* Update the count of enabled logical cores of the EAL configuration */
589 cfg->lcore_count = count;
594 /* Changes the lcore id of the master thread */
596 eal_parse_master_lcore(const char *arg)
599 struct rte_config *cfg = rte_eal_get_configuration();
602 cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
603 if (errno || parsing_end[0] != 0)
605 if (cfg->master_lcore >= RTE_MAX_LCORE)
607 master_lcore_parsed = 1;
609 /* ensure master core is not used as service core */
610 if (lcore_config[cfg->master_lcore].core_role == ROLE_SERVICE) {
611 RTE_LOG(ERR, EAL, "Error: Master lcore is used as a service core.\n");
619 * Parse elem, the elem could be single number/range or '(' ')' group
620 * 1) A single number elem, it's just a simple digit. e.g. 9
621 * 2) A single range elem, two digits with a '-' between. e.g. 2-6
622 * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
623 * Within group elem, '-' used for a range separator;
624 * ',' used for a single number.
627 eal_parse_set(const char *input, uint16_t set[], unsigned num)
630 const char *str = input;
634 memset(set, 0, num * sizeof(uint16_t));
636 while (isblank(*str))
639 /* only digit or left bracket is qualify for start point */
640 if ((!isdigit(*str) && *str != '(') || *str == '\0')
643 /* process single number or single range of number */
646 idx = strtoul(str, &end, 10);
647 if (errno || end == NULL || idx >= num)
650 while (isblank(*end))
656 /* process single <number>-<number> */
658 while (isblank(*end))
664 idx = strtoul(end, &end, 10);
665 if (errno || end == NULL || idx >= num)
668 while (isblank(*end))
670 if (*end != ',' && *end != '\0')
674 if (*end != ',' && *end != '\0' &&
678 for (idx = RTE_MIN(min, max);
679 idx <= RTE_MAX(min, max); idx++)
686 /* process set within bracket */
688 while (isblank(*str))
696 /* go ahead to the first digit */
697 while (isblank(*str))
702 /* get the digit value */
704 idx = strtoul(str, &end, 10);
705 if (errno || end == NULL || idx >= num)
708 /* go ahead to separator '-',',' and ')' */
709 while (isblank(*end))
712 if (min == RTE_MAX_LCORE)
714 else /* avoid continuous '-' */
716 } else if ((*end == ',') || (*end == ')')) {
718 if (min == RTE_MAX_LCORE)
720 for (idx = RTE_MIN(min, max);
721 idx <= RTE_MAX(min, max); idx++)
729 } while (*end != '\0' && *end != ')');
732 * to avoid failure that tail blank makes end character check fail
733 * in eal_parse_lcores( )
735 while (isblank(*str))
741 /* convert from set array to cpuset bitmap */
743 convert_to_cpuset(rte_cpuset_t *cpusetp,
744 uint16_t *set, unsigned num)
750 for (idx = 0; idx < num; idx++) {
754 if (!lcore_config[idx].detected) {
755 RTE_LOG(ERR, EAL, "core %u "
756 "unavailable\n", idx);
760 CPU_SET(idx, cpusetp);
767 * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
768 * lcores, cpus could be a single digit/range or a group.
769 * '(' and ')' are necessary if it's a group.
770 * If not supply '@cpus', the value of cpus uses the same as lcores.
771 * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
772 * lcore 0 runs on cpuset 0x41 (cpu 0,6)
773 * lcore 1 runs on cpuset 0x2 (cpu 1)
774 * lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
775 * lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
776 * lcore 6 runs on cpuset 0x41 (cpu 0,6)
777 * lcore 7 runs on cpuset 0x80 (cpu 7)
778 * lcore 8 runs on cpuset 0x100 (cpu 8)
781 eal_parse_lcores(const char *lcores)
783 struct rte_config *cfg = rte_eal_get_configuration();
784 static uint16_t set[RTE_MAX_LCORE];
787 const char *lcore_start = NULL;
788 const char *end = NULL;
797 /* Remove all blank characters ahead and after */
798 while (isblank(*lcores))
803 /* Reset lcore config */
804 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
805 cfg->lcore_role[idx] = ROLE_OFF;
806 lcore_config[idx].core_index = -1;
807 CPU_ZERO(&lcore_config[idx].cpuset);
810 /* Get list of cores */
812 while (isblank(*lcores))
819 /* record lcore_set start point */
820 lcore_start = lcores;
822 /* go across a complete bracket */
823 if (*lcore_start == '(') {
824 lcores += strcspn(lcores, ")");
825 if (*lcores++ == '\0')
829 /* scan the separator '@', ','(next) or '\0'(finish) */
830 lcores += strcspn(lcores, "@,");
832 if (*lcores == '@') {
833 /* explicit assign cpu_set */
834 offset = eal_parse_set(lcores + 1, set, RTE_DIM(set));
838 /* prepare cpu_set and update the end cursor */
839 if (0 > convert_to_cpuset(&cpuset,
842 end = lcores + 1 + offset;
843 } else { /* ',' or '\0' */
844 /* haven't given cpu_set, current loop done */
847 /* go back to check <number>-<number> */
848 offset = strcspn(lcore_start, "(-");
849 if (offset < (end - lcore_start) &&
850 *(lcore_start + offset) != '(')
854 if (*end != ',' && *end != '\0')
857 /* parse lcore_set from start point */
858 if (0 > eal_parse_set(lcore_start, set, RTE_DIM(set)))
861 /* without '@', by default using lcore_set as cpu_set */
862 if (*lcores != '@' &&
863 0 > convert_to_cpuset(&cpuset, set, RTE_DIM(set)))
866 /* start to update lcore_set */
867 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
871 if (cfg->lcore_role[idx] != ROLE_RTE) {
872 lcore_config[idx].core_index = count;
873 cfg->lcore_role[idx] = ROLE_RTE;
879 CPU_SET(idx, &cpuset);
881 rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
882 sizeof(rte_cpuset_t));
886 } while (*end != '\0');
891 cfg->lcore_count = count;
900 eal_parse_syslog(const char *facility, struct internal_config *conf)
907 { "auth", LOG_AUTH },
908 { "cron", LOG_CRON },
909 { "daemon", LOG_DAEMON },
911 { "kern", LOG_KERN },
913 { "mail", LOG_MAIL },
914 { "news", LOG_NEWS },
915 { "syslog", LOG_SYSLOG },
916 { "user", LOG_USER },
917 { "uucp", LOG_UUCP },
918 { "local0", LOG_LOCAL0 },
919 { "local1", LOG_LOCAL1 },
920 { "local2", LOG_LOCAL2 },
921 { "local3", LOG_LOCAL3 },
922 { "local4", LOG_LOCAL4 },
923 { "local5", LOG_LOCAL5 },
924 { "local6", LOG_LOCAL6 },
925 { "local7", LOG_LOCAL7 },
929 for (i = 0; map[i].name; i++) {
930 if (!strcmp(facility, map[i].name)) {
931 conf->syslog_facility = map[i].value;
939 eal_parse_log_level(const char *arg)
941 char *end, *str, *type, *level;
948 if (strchr(str, ',') == NULL) {
952 type = strsep(&str, ",");
953 level = strsep(&str, ",");
957 tmp = strtoul(level, &end, 0);
959 /* check for errors */
960 if ((errno != 0) || (level[0] == '\0') ||
961 end == NULL || (*end != '\0'))
964 /* log_level is a uint32_t */
965 if (tmp >= UINT32_MAX)
969 rte_log_set_global_level(tmp);
970 } else if (rte_log_set_level_regexp(type, tmp) < 0) {
971 printf("cannot set log level %s,%lu\n",
984 static enum rte_proc_type_t
985 eal_parse_proc_type(const char *arg)
987 if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
988 return RTE_PROC_PRIMARY;
989 if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
990 return RTE_PROC_SECONDARY;
991 if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
992 return RTE_PROC_AUTO;
994 return RTE_PROC_INVALID;
998 eal_parse_common_option(int opt, const char *optarg,
999 struct internal_config *conf)
1009 if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI,
1019 if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI,
1027 if (eal_parse_coremask(optarg) < 0) {
1028 RTE_LOG(ERR, EAL, "invalid coremask\n");
1035 if (eal_parse_corelist(optarg) < 0) {
1036 RTE_LOG(ERR, EAL, "invalid core list\n");
1041 /* service coremask */
1043 if (eal_parse_service_coremask(optarg) < 0) {
1044 RTE_LOG(ERR, EAL, "invalid service coremask\n");
1048 /* service corelist */
1050 if (eal_parse_service_corelist(optarg) < 0) {
1051 RTE_LOG(ERR, EAL, "invalid service core list\n");
1055 /* size of memory */
1057 conf->memory = atoi(optarg);
1058 conf->memory *= 1024ULL;
1059 conf->memory *= 1024ULL;
1062 /* force number of channels */
1064 conf->force_nchannel = atoi(optarg);
1065 if (conf->force_nchannel == 0) {
1066 RTE_LOG(ERR, EAL, "invalid channel number\n");
1070 /* force number of ranks */
1072 conf->force_nrank = atoi(optarg);
1073 if (conf->force_nrank == 0 ||
1074 conf->force_nrank > 16) {
1075 RTE_LOG(ERR, EAL, "invalid rank number\n");
1079 /* force loading of external driver */
1081 if (eal_plugin_add(optarg) == -1)
1085 /* since message is explicitly requested by user, we
1086 * write message at highest log level so it can always
1088 * even if info or warning messages are disabled */
1089 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
1093 case OPT_HUGE_UNLINK_NUM:
1094 conf->hugepage_unlink = 1;
1097 case OPT_NO_HUGE_NUM:
1098 conf->no_hugetlbfs = 1;
1101 case OPT_NO_PCI_NUM:
1105 case OPT_NO_HPET_NUM:
1109 case OPT_VMWARE_TSC_MAP_NUM:
1110 conf->vmware_tsc_map = 1;
1113 case OPT_NO_SHCONF_NUM:
1114 conf->no_shconf = 1;
1117 case OPT_PROC_TYPE_NUM:
1118 conf->process_type = eal_parse_proc_type(optarg);
1121 case OPT_MASTER_LCORE_NUM:
1122 if (eal_parse_master_lcore(optarg) < 0) {
1123 RTE_LOG(ERR, EAL, "invalid parameter for --"
1124 OPT_MASTER_LCORE "\n");
1130 if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1136 case OPT_SYSLOG_NUM:
1137 if (eal_parse_syslog(optarg, conf) < 0) {
1138 RTE_LOG(ERR, EAL, "invalid parameters for --"
1144 case OPT_LOG_LEVEL_NUM: {
1145 if (eal_parse_log_level(optarg) < 0) {
1147 "invalid parameters for --"
1148 OPT_LOG_LEVEL "\n");
1153 case OPT_LCORES_NUM:
1154 if (eal_parse_lcores(optarg) < 0) {
1155 RTE_LOG(ERR, EAL, "invalid parameter for --"
1162 /* don't know what to do, leave this to caller */
1170 RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
1171 "cannot be used at the same time\n");
1176 eal_auto_detect_cores(struct rte_config *cfg)
1178 unsigned int lcore_id;
1179 unsigned int removed = 0;
1180 rte_cpuset_t affinity_set;
1181 pthread_t tid = pthread_self();
1183 if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t),
1185 CPU_ZERO(&affinity_set);
1187 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1188 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1189 !CPU_ISSET(lcore_id, &affinity_set)) {
1190 cfg->lcore_role[lcore_id] = ROLE_OFF;
1195 cfg->lcore_count -= removed;
1199 eal_adjust_config(struct internal_config *internal_cfg)
1202 struct rte_config *cfg = rte_eal_get_configuration();
1205 eal_auto_detect_cores(cfg);
1207 if (internal_config.process_type == RTE_PROC_AUTO)
1208 internal_config.process_type = eal_proc_type_detect();
1210 /* default master lcore is the first one */
1211 if (!master_lcore_parsed) {
1212 cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
1213 lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
1216 /* if no memory amounts were requested, this will result in 0 and
1217 * will be overridden later, right after eal_hugepage_info_init() */
1218 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1219 internal_cfg->memory += internal_cfg->socket_mem[i];
1225 eal_check_common_options(struct internal_config *internal_cfg)
1227 struct rte_config *cfg = rte_eal_get_configuration();
1229 if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
1230 RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
1234 if (internal_cfg->process_type == RTE_PROC_INVALID) {
1235 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1238 if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
1239 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1243 if (mem_parsed && internal_cfg->force_sockets == 1) {
1244 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1245 "be specified at the same time\n");
1248 if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1249 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1250 "be specified together with --"OPT_NO_HUGE"\n");
1254 if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink) {
1255 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1256 "be specified together with --"OPT_NO_HUGE"\n");
1264 eal_common_usage(void)
1266 printf("[options]\n\n"
1267 "EAL common options:\n"
1268 " -c COREMASK Hexadecimal bitmask of cores to run on\n"
1269 " -l CORELIST List of cores to run on\n"
1270 " The argument format is <c1>[-c2][,c3[-c4],...]\n"
1271 " where c1, c2, etc are core indexes between 0 and %d\n"
1272 " --"OPT_LCORES" COREMAP Map lcore set to physical cpu set\n"
1273 " The argument format is\n"
1274 " '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
1275 " lcores and cpus list are grouped by '(' and ')'\n"
1276 " Within the group, '-' is used for range separator,\n"
1277 " ',' is used for single number separator.\n"
1278 " '( )' can be omitted for single element group,\n"
1279 " '@' can be omitted if cpus and lcores have the same value\n"
1280 " -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
1281 " --"OPT_MASTER_LCORE" ID Core ID that is used as master\n"
1282 " --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
1283 " -n CHANNELS Number of memory channels\n"
1284 " -m MB Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
1285 " -r RANKS Force number of memory ranks (don't detect)\n"
1286 " -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
1287 " Prevent EAL from using this PCI device. The argument\n"
1288 " format is <domain:bus:devid.func>.\n"
1289 " -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
1290 " Only use the specified PCI devices. The argument format\n"
1291 " is <[domain:]bus:devid.func>. This option can be present\n"
1292 " several times (once per device).\n"
1293 " [NOTE: PCI whitelist cannot be used with -b option]\n"
1294 " --"OPT_VDEV" Add a virtual device.\n"
1295 " The argument format is <driver><id>[,key=val,...]\n"
1296 " (ex: --vdev=net_pcap0,iface=eth2).\n"
1297 " -d LIB.so|DIR Add a driver or driver directory\n"
1298 " (can be used multiple times)\n"
1299 " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n"
1300 " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n"
1301 " --"OPT_SYSLOG" Set syslog facility\n"
1302 " --"OPT_LOG_LEVEL"=<int> Set global log level\n"
1303 " --"OPT_LOG_LEVEL"=<type-regexp>,<int>\n"
1304 " Set specific log level\n"
1305 " -v Display version information on startup\n"
1306 " -h, --help This help\n"
1307 "\nEAL options for DEBUG use only:\n"
1308 " --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n"
1309 " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
1310 " --"OPT_NO_PCI" Disable PCI\n"
1311 " --"OPT_NO_HPET" Disable HPET\n"
1312 " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
1313 "\n", RTE_MAX_LCORE);