4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
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.
49 #include <sys/queue.h>
51 #include <rte_common.h>
52 #include <rte_debug.h>
53 #include <rte_memory.h>
54 #include <rte_memzone.h>
55 #include <rte_launch.h>
56 #include <rte_tailq.h>
58 #include <rte_eal_memconfig.h>
59 #include <rte_per_lcore.h>
60 #include <rte_lcore.h>
62 #include <rte_random.h>
63 #include <rte_cycles.h>
64 #include <rte_string_fns.h>
65 #include <rte_cpuflags.h>
66 #include <rte_interrupts.h>
68 #include <rte_common.h>
69 #include <rte_version.h>
70 #include <rte_atomic.h>
71 #include <malloc_heap.h>
73 #include "eal_private.h"
74 #include "eal_thread.h"
75 #include "eal_internal_cfg.h"
76 #include "eal_filesystem.h"
77 #include "eal_hugepages.h"
79 #define OPT_HUGE_DIR "huge-dir"
80 #define OPT_PROC_TYPE "proc-type"
81 #define OPT_NO_SHCONF "no-shconf"
82 #define OPT_NO_HPET "no-hpet"
83 #define OPT_VMWARE_TSC_MAP "vmware-tsc-map"
84 #define OPT_NO_PCI "no-pci"
85 #define OPT_NO_HUGE "no-huge"
86 #define OPT_FILE_PREFIX "file-prefix"
87 #define OPT_SOCKET_MEM "socket-mem"
88 #define OPT_SYSLOG "syslog"
90 #define RTE_EAL_BLACKLIST_SIZE 0x100
92 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
94 #define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 10)
96 #define GET_BLACKLIST_FIELD(in, fd, lim, dlm) \
101 val = strtoul((in), &end, 16); \
102 if (errno != 0 || end[0] != (dlm) || val > (lim)) \
104 (fd) = (typeof (fd))val; \
108 /* Allow the application to print its usage message too if set */
109 static rte_usage_hook_t rte_application_usage_hook = NULL;
110 /* early configuration structure, when memory config is not mmapped */
111 static struct rte_mem_config early_mem_config;
113 /* define fd variable here, because file needs to be kept open for the
114 * duration of the program, as we hold a write lock on it in the primary proc */
115 static int mem_cfg_fd = -1;
117 static struct flock wr_lock = {
119 .l_whence = SEEK_SET,
120 .l_start = offsetof(struct rte_mem_config, memseg),
121 .l_len = sizeof(early_mem_config.memseg),
124 /* Address of global and public configuration */
125 static struct rte_config rte_config = {
126 .mem_config = &early_mem_config,
129 static struct rte_pci_addr eal_dev_blacklist[RTE_EAL_BLACKLIST_SIZE];
131 /* internal configuration (per-core) */
132 struct lcore_config lcore_config[RTE_MAX_LCORE];
134 /* internal configuration */
135 struct internal_config internal_config;
137 /* used by rte_rdtsc() */
138 int rte_cycles_vmware_tsc_map;
140 /* Return a pointer to the configuration structure */
142 rte_eal_get_configuration(void)
147 /* parse a sysfs (or other) file containing one integer value */
149 eal_parse_sysfs_value(const char *filename, unsigned long *val)
155 if ((f = fopen(filename, "r")) == NULL) {
156 RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n",
161 if (fgets(buf, sizeof(buf), f) == NULL) {
162 RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n",
167 *val = strtoul(buf, &end, 0);
168 if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) {
169 RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n",
179 /* create memory configuration in shared/mmap memory. Take out
180 * a write lock on the memsegs, so we can auto-detect primary/secondary.
181 * This means we never close the file while running (auto-close on exit).
182 * We also don't lock the whole file, so that in future we can use read-locks
183 * on other parts, e.g. memzones, to detect if there are running secondary
186 rte_eal_config_create(void)
188 void *rte_mem_cfg_addr;
191 const char *pathname = eal_runtime_config_path();
193 if (internal_config.no_shconf)
197 mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
199 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
202 retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
205 rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
208 retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
211 rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
212 "process running?\n", pathname);
215 rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
216 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
218 if (rte_mem_cfg_addr == MAP_FAILED){
219 rte_panic("Cannot mmap memory for rte_config\n");
221 memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
222 rte_config.mem_config = (struct rte_mem_config *) rte_mem_cfg_addr;
225 /* attach to an existing shared memory config */
227 rte_eal_config_attach(void)
229 void *rte_mem_cfg_addr;
230 const char *pathname = eal_runtime_config_path();
232 if (internal_config.no_shconf)
236 mem_cfg_fd = open(pathname, O_RDWR);
238 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
241 rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
242 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
244 if (rte_mem_cfg_addr == MAP_FAILED)
245 rte_panic("Cannot mmap memory for rte_config\n");
247 rte_config.mem_config = (struct rte_mem_config *) rte_mem_cfg_addr;
250 /* Detect if we are a primary or a secondary process */
251 static enum rte_proc_type_t
252 eal_proc_type_detect(void)
254 enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
255 const char *pathname = eal_runtime_config_path();
257 /* if we can open the file but not get a write-lock we are a secondary
258 * process. NOTE: if we get a file handle back, we keep that open
259 * and don't close it to prevent a race condition between multiple opens */
260 if (((mem_cfg_fd = open(pathname, O_RDWR)) >= 0) &&
261 (fcntl(mem_cfg_fd, F_SETLK, &wr_lock) < 0))
262 ptype = RTE_PROC_SECONDARY;
264 RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
265 ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
270 /* Sets up rte_config structure with the pointer to shared memory config.*/
272 rte_config_init(void)
274 /* set the magic in configuration structure */
275 rte_config.magic = RTE_MAGIC;
276 rte_config.process_type = (internal_config.process_type == RTE_PROC_AUTO) ?
277 eal_proc_type_detect() : /* for auto, detect the type */
278 internal_config.process_type; /* otherwise use what's already set */
280 switch (rte_config.process_type){
281 case RTE_PROC_PRIMARY:
282 rte_eal_config_create();
284 case RTE_PROC_SECONDARY:
285 rte_eal_config_attach();
286 rte_eal_mcfg_wait_complete(rte_config.mem_config);
289 case RTE_PROC_INVALID:
290 rte_panic("Invalid process type\n");
294 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
296 eal_hugedirs_unlock(void)
300 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
302 /* skip uninitialized */
303 if (internal_config.hugepage_info[i].lock_descriptor == 0)
305 /* unlock hugepage file */
306 flock(internal_config.hugepage_info[i].lock_descriptor, LOCK_UN);
307 close(internal_config.hugepage_info[i].lock_descriptor);
308 /* reset the field */
309 internal_config.hugepage_info[i].lock_descriptor = 0;
315 eal_usage(const char *prgname)
317 printf("\nUsage: %s -c COREMASK -n NUM [-m NB] [-r NUM] [-b <domain:bus:devid.func>]"
318 "[--proc-type primary|secondary|auto] \n\n"
320 " -c COREMASK : A hexadecimal bitmask of cores to run on\n"
321 " -n NUM : Number of memory channels\n"
322 " -v : Display version information on startup\n"
323 " -b <domain:bus:devid.func>: to prevent EAL from using specified "
325 " (multiple -b options are allowed)\n"
326 " -m MB : memory to allocate (see also --"OPT_SOCKET_MEM")\n"
327 " -r NUM : force number of memory ranks (don't detect)\n"
328 " --"OPT_SYSLOG" : set syslog facility\n"
329 " --"OPT_SOCKET_MEM" : memory to allocate on specific \n"
330 " sockets (use comma separated values)\n"
331 " --"OPT_HUGE_DIR" : directory where hugetlbfs is mounted\n"
332 " --"OPT_PROC_TYPE" : type of this process\n"
333 " --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
334 " --"OPT_VMWARE_TSC_MAP": use VMware TSC map instead of "
336 "\nEAL options for DEBUG use only:\n"
337 " --"OPT_NO_HUGE" : use malloc instead of hugetlbfs\n"
338 " --"OPT_NO_PCI" : disable pci\n"
339 " --"OPT_NO_HPET" : disable hpet\n"
340 " --"OPT_NO_SHCONF": no shared config (mmap'd files)\n"
343 /* Allow the application to print its usage message too if hook is set */
344 if ( rte_application_usage_hook ) {
345 printf("===== Application Usage =====\n\n");
346 rte_application_usage_hook(prgname);
350 /* Set a per-application usage message */
352 rte_set_application_usage_hook( rte_usage_hook_t usage_func )
354 rte_usage_hook_t old_func;
356 /* Will be NULL on the first call to denote the last usage routine. */
357 old_func = rte_application_usage_hook;
358 rte_application_usage_hook = usage_func;
364 * Parse the coremask given as argument (hexadecimal string) and fill
365 * the global configuration (core role and core count) with the parsed
369 eal_parse_coremask(const char *coremask)
371 struct rte_config *cfg = rte_eal_get_configuration();
374 unsigned long long cm;
377 /* parse hexadecimal string */
378 cm = strtoull(coremask, &end, 16);
379 if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0') || (cm == 0))
382 RTE_LOG(DEBUG, EAL, "coremask set to %llx\n", cm);
383 /* set core role and core count */
384 for (i = 0; i < RTE_MAX_LCORE; i++) {
385 if ((1ULL << i) & cm) {
387 cfg->master_lcore = i;
388 cfg->lcore_role[i] = ROLE_RTE;
392 cfg->lcore_role[i] = ROLE_OFF;
399 eal_parse_syslog(const char *facility)
406 { "auth", LOG_AUTH },
407 { "cron", LOG_CRON },
408 { "daemon", LOG_DAEMON },
410 { "kern", LOG_KERN },
412 { "mail", LOG_MAIL },
413 { "news", LOG_NEWS },
414 { "syslog", LOG_SYSLOG },
415 { "user", LOG_USER },
416 { "uucp", LOG_UUCP },
417 { "local0", LOG_LOCAL0 },
418 { "local1", LOG_LOCAL1 },
419 { "local2", LOG_LOCAL2 },
420 { "local3", LOG_LOCAL3 },
421 { "local4", LOG_LOCAL4 },
422 { "local5", LOG_LOCAL5 },
423 { "local6", LOG_LOCAL6 },
424 { "local7", LOG_LOCAL7 },
428 for (i = 0; map[i].name; i++) {
429 if (!strcmp(facility, map[i].name)) {
430 internal_config.syslog_facility = map[i].value;
438 eal_parse_socket_mem(char *socket_mem)
440 char * arg[RTE_MAX_NUMA_NODES];
443 uint64_t total_mem = 0;
445 len = strnlen(socket_mem, SOCKET_MEM_STRLEN);
446 if (len == SOCKET_MEM_STRLEN) {
447 RTE_LOG(ERR, EAL, "--socket-mem is too long\n");
451 /* all other error cases will be caught later */
452 if (!isdigit(socket_mem[len-1]))
455 /* split the optarg into separate socket values */
456 arg_num = rte_strsplit(socket_mem, len,
457 arg, RTE_MAX_NUMA_NODES, ',');
459 /* if split failed, or 0 arguments */
463 internal_config.force_sockets = 1;
465 /* parse each defined socket option */
467 for (i = 0; i < arg_num; i++) {
469 internal_config.socket_mem[i] = strtoull(arg[i], &end, 10);
471 /* check for invalid input */
473 (arg[i][0] == '\0') || (end == NULL) || (*end != '\0'))
475 internal_config.socket_mem[i] *= 1024ULL;
476 internal_config.socket_mem[i] *= 1024ULL;
477 total_mem += internal_config.socket_mem[i];
480 /* check if we have a positive amount of total memory */
488 eal_get_hugepage_mem_size(void)
493 for (i = 0; i < internal_config.num_hugepage_sizes; i++) {
494 struct hugepage_info *hpi = &internal_config.hugepage_info[i];
495 if (hpi->hugedir != NULL) {
496 for (j = 0; j < RTE_MAX_NUMA_NODES; j++) {
497 size += hpi->hugepage_sz * hpi->num_pages[j];
502 return (size < SIZE_MAX) ? (size_t)(size) : SIZE_MAX;
505 static enum rte_proc_type_t
506 eal_parse_proc_type(const char *arg)
508 if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
509 return RTE_PROC_PRIMARY;
510 if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
511 return RTE_PROC_SECONDARY;
512 if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
513 return RTE_PROC_AUTO;
515 return RTE_PROC_INVALID;
519 eal_parse_blacklist(const char *input, struct rte_pci_addr *dev2bl)
521 GET_BLACKLIST_FIELD(input, dev2bl->domain, UINT16_MAX, ':');
522 GET_BLACKLIST_FIELD(input, dev2bl->bus, UINT8_MAX, ':');
523 GET_BLACKLIST_FIELD(input, dev2bl->devid, UINT8_MAX, '.');
524 GET_BLACKLIST_FIELD(input, dev2bl->function, UINT8_MAX, 0);
529 eal_parse_blacklist_opt(const char *optarg, size_t idx)
531 if (idx >= sizeof (eal_dev_blacklist) / sizeof (eal_dev_blacklist[0])) {
533 "%s - too many devices to blacklist...\n",
536 } else if (eal_parse_blacklist(optarg, eal_dev_blacklist + idx) != 0) {
538 "%s - invalid device to blacklist...\n",
547 /* Parse the argument given in the command line of the application */
549 eal_parse_args(int argc, char **argv)
555 ssize_t blacklist_index = 0;;
556 char *prgname = argv[0];
557 static struct option lgopts[] = {
558 {OPT_NO_HUGE, 0, 0, 0},
559 {OPT_NO_PCI, 0, 0, 0},
560 {OPT_NO_HPET, 0, 0, 0},
561 {OPT_VMWARE_TSC_MAP, 0, 0, 0},
562 {OPT_HUGE_DIR, 1, 0, 0},
563 {OPT_NO_SHCONF, 0, 0, 0},
564 {OPT_PROC_TYPE, 1, 0, 0},
565 {OPT_FILE_PREFIX, 1, 0, 0},
566 {OPT_SOCKET_MEM, 1, 0, 0},
567 {OPT_SYSLOG, 1, NULL, 0},
573 internal_config.memory = 0;
574 internal_config.force_nrank = 0;
575 internal_config.force_nchannel = 0;
576 internal_config.hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
577 internal_config.hugepage_dir = NULL;
578 internal_config.force_sockets = 0;
579 internal_config.syslog_facility = LOG_DAEMON;
580 #ifdef RTE_LIBEAL_USE_HPET
581 internal_config.no_hpet = 0;
583 internal_config.no_hpet = 1;
585 /* zero out the NUMA config */
586 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
587 internal_config.socket_mem[i] = 0;
589 /* zero out hugedir descriptors */
590 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
591 internal_config.hugepage_info[i].lock_descriptor = 0;
593 internal_config.vmware_tsc_map = 0;
595 while ((opt = getopt_long(argc, argvopt, "b:c:m:n:r:v",
596 lgopts, &option_index)) != EOF) {
601 if ((blacklist_index = eal_parse_blacklist_opt(optarg,
602 blacklist_index)) < 0) {
609 if (eal_parse_coremask(optarg) < 0) {
610 RTE_LOG(ERR, EAL, "invalid coremask\n");
618 internal_config.memory = atoi(optarg);
619 internal_config.memory *= 1024ULL;
620 internal_config.memory *= 1024ULL;
622 /* force number of channels */
624 internal_config.force_nchannel = atoi(optarg);
625 if (internal_config.force_nchannel == 0 ||
626 internal_config.force_nchannel > 4) {
627 RTE_LOG(ERR, EAL, "invalid channel number\n");
632 /* force number of ranks */
634 internal_config.force_nrank = atoi(optarg);
635 if (internal_config.force_nrank == 0 ||
636 internal_config.force_nrank > 16) {
637 RTE_LOG(ERR, EAL, "invalid rank number\n");
643 /* since message is explicitly requested by user, we
644 * write message at highest log level so it can always be seen
645 * even if info or warning messages are disabled */
646 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
651 if (!strcmp(lgopts[option_index].name, OPT_NO_HUGE)) {
652 internal_config.no_hugetlbfs = 1;
654 else if (!strcmp(lgopts[option_index].name, OPT_NO_PCI)) {
655 internal_config.no_pci = 1;
657 else if (!strcmp(lgopts[option_index].name, OPT_NO_HPET)) {
658 internal_config.no_hpet = 1;
660 else if (!strcmp(lgopts[option_index].name, OPT_VMWARE_TSC_MAP)) {
661 internal_config.vmware_tsc_map = 1;
663 else if (!strcmp(lgopts[option_index].name, OPT_NO_SHCONF)) {
664 internal_config.no_shconf = 1;
666 else if (!strcmp(lgopts[option_index].name, OPT_HUGE_DIR)) {
667 internal_config.hugepage_dir = optarg;
669 else if (!strcmp(lgopts[option_index].name, OPT_PROC_TYPE)) {
670 internal_config.process_type = eal_parse_proc_type(optarg);
672 else if (!strcmp(lgopts[option_index].name, OPT_FILE_PREFIX)) {
673 internal_config.hugefile_prefix = optarg;
675 else if (!strcmp(lgopts[option_index].name, OPT_SOCKET_MEM)) {
676 if (eal_parse_socket_mem(optarg) < 0) {
677 RTE_LOG(ERR, EAL, "invalid parameters for --"
678 OPT_SOCKET_MEM "\n");
683 else if (!strcmp(lgopts[option_index].name, OPT_SYSLOG)) {
684 if (eal_parse_syslog(optarg) < 0) {
685 RTE_LOG(ERR, EAL, "invalid parameters for --"
701 RTE_LOG(ERR, EAL, "coremask not specified\n");
705 if (internal_config.process_type == RTE_PROC_AUTO){
706 internal_config.process_type = eal_proc_type_detect();
708 if (internal_config.process_type == RTE_PROC_INVALID){
709 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
713 if (internal_config.process_type == RTE_PROC_PRIMARY &&
714 internal_config.force_nchannel == 0) {
715 RTE_LOG(ERR, EAL, "Number of memory channels (-n) not specified\n");
719 if (index(internal_config.hugefile_prefix,'%') != NULL){
720 RTE_LOG(ERR, EAL, "Invalid char, '%%', in '"OPT_FILE_PREFIX"' option\n");
724 if (internal_config.memory > 0 && internal_config.force_sockets == 1) {
725 RTE_LOG(ERR, EAL, "Options -m and --socket-mem cannot be specified "
726 "at the same time\n");
730 /* --no-huge doesn't make sense with either -m or --socket-mem */
731 if (internal_config.no_hugetlbfs &&
732 (internal_config.memory > 0 ||
733 internal_config.force_sockets == 1)) {
734 RTE_LOG(ERR, EAL, "Options -m or --socket-mem cannot be specified "
735 "together with --no-huge!\n");
740 if (blacklist_index > 0)
741 rte_eal_pci_set_blacklist(eal_dev_blacklist, blacklist_index);
744 argv[optind-1] = prgname;
746 /* if no memory amounts were requested, this will result in 0 and
747 * will be overriden later, right after eal_hugepage_info_init() */
748 for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
749 internal_config.memory += internal_config.socket_mem[i];
752 optind = 0; /* reset getopt lib */
757 eal_check_mem_on_local_socket(void)
759 const struct rte_memseg *ms;
762 socket_id = rte_lcore_to_socket_id(rte_config.master_lcore);
764 ms = rte_eal_get_physmem_layout();
766 for (i = 0; i < RTE_MAX_MEMSEG; i++)
767 if (ms[i].socket_id == socket_id &&
771 RTE_LOG(WARNING, EAL, "WARNING: Master core has no "
772 "memory on local socket!\n");
776 sync_func(__attribute__((unused)) void *arg)
782 rte_eal_mcfg_complete(void)
784 /* ALL shared mem_config related INIT DONE */
785 if (rte_config.process_type == RTE_PROC_PRIMARY)
786 rte_config.mem_config->magic = RTE_MAGIC;
789 /* Launch threads, called at application init(). */
791 rte_eal_init(int argc, char **argv)
795 static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
797 if (!rte_atomic32_test_and_set(&run_once))
800 thread_id = pthread_self();
802 if (rte_eal_log_early_init() < 0)
803 rte_panic("Cannot init early logs\n");
805 fctret = eal_parse_args(argc, argv);
809 if (internal_config.no_hugetlbfs == 0 &&
810 internal_config.process_type != RTE_PROC_SECONDARY &&
811 eal_hugepage_info_init() < 0)
812 rte_panic("Cannot get hugepage information\n");
814 if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
815 if (internal_config.no_hugetlbfs)
816 internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
818 internal_config.memory = eal_get_hugepage_mem_size();
821 if (internal_config.vmware_tsc_map == 1) {
822 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
823 rte_cycles_vmware_tsc_map = 1;
824 RTE_LOG (DEBUG, EAL, "Using VMWARE TSC MAP, "
825 "you must have monitor_control.pseudo_perfctr = TRUE\n");
827 RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
828 "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
832 rte_srand(rte_rdtsc());
836 if (rte_eal_cpu_init() < 0)
837 rte_panic("Cannot detect lcores\n");
839 if (rte_eal_memory_init() < 0)
840 rte_panic("Cannot init memory\n");
842 /* the directories are locked during eal_hugepage_info_init */
843 eal_hugedirs_unlock();
845 if (rte_eal_memzone_init() < 0)
846 rte_panic("Cannot init memzone\n");
848 if (rte_eal_tailqs_init() < 0)
849 rte_panic("Cannot init tail queues for objects\n");
851 if (rte_eal_log_init(argv[0], internal_config.syslog_facility) < 0)
852 rte_panic("Cannot init logs\n");
854 if (rte_eal_alarm_init() < 0)
855 rte_panic("Cannot init interrupt-handling thread\n");
857 if (rte_eal_intr_init() < 0)
858 rte_panic("Cannot init interrupt-handling thread\n");
860 if (rte_eal_timer_init() < 0)
861 rte_panic("Cannot init HPET or TSC timers\n");
863 if (rte_eal_pci_init() < 0)
864 rte_panic("Cannot init PCI\n");
866 RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n",
867 rte_config.master_lcore, (int)thread_id);
869 eal_check_mem_on_local_socket();
871 rte_eal_mcfg_complete();
873 RTE_LCORE_FOREACH_SLAVE(i) {
876 * create communication pipes between master thread
879 if (pipe(lcore_config[i].pipe_master2slave) < 0)
880 rte_panic("Cannot create pipe\n");
881 if (pipe(lcore_config[i].pipe_slave2master) < 0)
882 rte_panic("Cannot create pipe\n");
884 lcore_config[i].state = WAIT;
886 /* create a thread for each lcore */
887 ret = pthread_create(&lcore_config[i].thread_id, NULL,
888 eal_thread_loop, NULL);
890 rte_panic("Cannot create thread\n");
893 eal_thread_init_master(rte_config.master_lcore);
896 * Launch a dummy function on all slave lcores, so that master lcore
897 * knows they are all ready when this function returns.
899 rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
900 rte_eal_mp_wait_lcore();
906 enum rte_lcore_role_t
907 rte_eal_lcore_role(unsigned lcore_id)
909 return (rte_config.lcore_role[lcore_id]);
913 rte_eal_process_type(void)
915 return (rte_config.process_type);