4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2012-2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 #include <sys/queue.h>
52 #if defined(RTE_ARCH_X86)
56 #include <rte_common.h>
57 #include <rte_debug.h>
58 #include <rte_memory.h>
59 #include <rte_memzone.h>
60 #include <rte_launch.h>
62 #include <rte_eal_memconfig.h>
63 #include <rte_errno.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_service_component.h>
68 #include <rte_random.h>
69 #include <rte_cycles.h>
70 #include <rte_string_fns.h>
71 #include <rte_cpuflags.h>
72 #include <rte_interrupts.h>
76 #include <rte_devargs.h>
77 #include <rte_version.h>
78 #include <rte_atomic.h>
79 #include <malloc_heap.h>
81 #include "eal_private.h"
82 #include "eal_thread.h"
83 #include "eal_internal_cfg.h"
84 #include "eal_filesystem.h"
85 #include "eal_hugepages.h"
86 #include "eal_options.h"
89 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
91 #define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 10)
93 /* Allow the application to print its usage message too if set */
94 static rte_usage_hook_t rte_application_usage_hook = NULL;
96 /* early configuration structure, when memory config is not mmapped */
97 static struct rte_mem_config early_mem_config;
99 /* define fd variable here, because file needs to be kept open for the
100 * duration of the program, as we hold a write lock on it in the primary proc */
101 static int mem_cfg_fd = -1;
103 static struct flock wr_lock = {
105 .l_whence = SEEK_SET,
106 .l_start = offsetof(struct rte_mem_config, memseg),
107 .l_len = sizeof(early_mem_config.memseg),
110 /* Address of global and public configuration */
111 static struct rte_config rte_config = {
112 .mem_config = &early_mem_config,
115 /* internal configuration (per-core) */
116 struct lcore_config lcore_config[RTE_MAX_LCORE];
118 /* internal configuration */
119 struct internal_config internal_config;
121 /* used by rte_rdtsc() */
122 int rte_cycles_vmware_tsc_map;
124 /* Return a pointer to the configuration structure */
126 rte_eal_get_configuration(void)
132 rte_eal_iova_mode(void)
134 return rte_eal_get_configuration()->iova_mode;
137 /* parse a sysfs (or other) file containing one integer value */
139 eal_parse_sysfs_value(const char *filename, unsigned long *val)
145 if ((f = fopen(filename, "r")) == NULL) {
146 RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n",
151 if (fgets(buf, sizeof(buf), f) == NULL) {
152 RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n",
157 *val = strtoul(buf, &end, 0);
158 if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) {
159 RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n",
169 /* create memory configuration in shared/mmap memory. Take out
170 * a write lock on the memsegs, so we can auto-detect primary/secondary.
171 * This means we never close the file while running (auto-close on exit).
172 * We also don't lock the whole file, so that in future we can use read-locks
173 * on other parts, e.g. memzones, to detect if there are running secondary
176 rte_eal_config_create(void)
178 void *rte_mem_cfg_addr;
181 const char *pathname = eal_runtime_config_path();
183 if (internal_config.no_shconf)
186 /* map the config before hugepage address so that we don't waste a page */
187 if (internal_config.base_virtaddr != 0)
188 rte_mem_cfg_addr = (void *)
189 RTE_ALIGN_FLOOR(internal_config.base_virtaddr -
190 sizeof(struct rte_mem_config), sysconf(_SC_PAGE_SIZE));
192 rte_mem_cfg_addr = NULL;
195 mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
197 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
200 retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
203 rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
206 retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
209 rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
210 "process running?\n", pathname);
213 rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
214 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
216 if (rte_mem_cfg_addr == MAP_FAILED){
217 rte_panic("Cannot mmap memory for rte_config\n");
219 memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
220 rte_config.mem_config = rte_mem_cfg_addr;
222 /* store address of the config in the config itself so that secondary
223 * processes could later map the config into this exact location */
224 rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
228 /* attach to an existing shared memory config */
230 rte_eal_config_attach(void)
232 struct rte_mem_config *mem_config;
234 const char *pathname = eal_runtime_config_path();
236 if (internal_config.no_shconf)
240 mem_cfg_fd = open(pathname, O_RDWR);
242 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
245 /* map it as read-only first */
246 mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
247 PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
248 if (mem_config == MAP_FAILED)
249 rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
250 errno, strerror(errno));
252 rte_config.mem_config = mem_config;
255 /* reattach the shared config at exact memory location primary process has it */
257 rte_eal_config_reattach(void)
259 struct rte_mem_config *mem_config;
260 void *rte_mem_cfg_addr;
262 if (internal_config.no_shconf)
265 /* save the address primary process has mapped shared config to */
266 rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
268 /* unmap original config */
269 munmap(rte_config.mem_config, sizeof(struct rte_mem_config));
271 /* remap the config at proper address */
272 mem_config = (struct rte_mem_config *) mmap(rte_mem_cfg_addr,
273 sizeof(*mem_config), PROT_READ | PROT_WRITE, MAP_SHARED,
275 if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {
276 if (mem_config != MAP_FAILED)
277 /* errno is stale, don't use */
278 rte_panic("Cannot mmap memory for rte_config at [%p], got [%p]"
279 " - please use '--base-virtaddr' option\n",
280 rte_mem_cfg_addr, mem_config);
282 rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
283 errno, strerror(errno));
287 rte_config.mem_config = mem_config;
290 /* Detect if we are a primary or a secondary process */
292 eal_proc_type_detect(void)
294 enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
295 const char *pathname = eal_runtime_config_path();
297 /* if we can open the file but not get a write-lock we are a secondary
298 * process. NOTE: if we get a file handle back, we keep that open
299 * and don't close it to prevent a race condition between multiple opens */
300 if (((mem_cfg_fd = open(pathname, O_RDWR)) >= 0) &&
301 (fcntl(mem_cfg_fd, F_SETLK, &wr_lock) < 0))
302 ptype = RTE_PROC_SECONDARY;
304 RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
305 ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
310 /* Sets up rte_config structure with the pointer to shared memory config.*/
312 rte_config_init(void)
314 rte_config.process_type = internal_config.process_type;
316 switch (rte_config.process_type){
317 case RTE_PROC_PRIMARY:
318 rte_eal_config_create();
320 case RTE_PROC_SECONDARY:
321 rte_eal_config_attach();
322 rte_eal_mcfg_wait_complete(rte_config.mem_config);
323 rte_eal_config_reattach();
326 case RTE_PROC_INVALID:
327 rte_panic("Invalid process type\n");
331 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
333 eal_hugedirs_unlock(void)
337 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
339 /* skip uninitialized */
340 if (internal_config.hugepage_info[i].lock_descriptor < 0)
342 /* unlock hugepage file */
343 flock(internal_config.hugepage_info[i].lock_descriptor, LOCK_UN);
344 close(internal_config.hugepage_info[i].lock_descriptor);
345 /* reset the field */
346 internal_config.hugepage_info[i].lock_descriptor = -1;
352 eal_usage(const char *prgname)
354 printf("\nUsage: %s ", prgname);
356 printf("EAL Linux options:\n"
357 " --"OPT_SOCKET_MEM" Memory to allocate on sockets (comma separated values)\n"
358 " --"OPT_HUGE_DIR" Directory where hugetlbfs is mounted\n"
359 " --"OPT_FILE_PREFIX" Prefix for hugepage filenames\n"
360 " --"OPT_BASE_VIRTADDR" Base virtual address\n"
361 " --"OPT_CREATE_UIO_DEV" Create /dev/uioX (usually done by hotplug)\n"
362 " --"OPT_VFIO_INTR" Interrupt mode for VFIO (legacy|msi|msix)\n"
363 " --"OPT_XEN_DOM0" Support running on Xen dom0 without hugetlbfs\n"
365 /* Allow the application to print its usage message too if hook is set */
366 if ( rte_application_usage_hook ) {
367 printf("===== Application Usage =====\n\n");
368 rte_application_usage_hook(prgname);
372 /* Set a per-application usage message */
374 rte_set_application_usage_hook( rte_usage_hook_t usage_func )
376 rte_usage_hook_t old_func;
378 /* Will be NULL on the first call to denote the last usage routine. */
379 old_func = rte_application_usage_hook;
380 rte_application_usage_hook = usage_func;
386 eal_parse_socket_mem(char *socket_mem)
388 char * arg[RTE_MAX_NUMA_NODES];
391 uint64_t total_mem = 0;
393 len = strnlen(socket_mem, SOCKET_MEM_STRLEN);
394 if (len == SOCKET_MEM_STRLEN) {
395 RTE_LOG(ERR, EAL, "--socket-mem is too long\n");
399 /* all other error cases will be caught later */
400 if (!isdigit(socket_mem[len-1]))
403 /* split the optarg into separate socket values */
404 arg_num = rte_strsplit(socket_mem, len,
405 arg, RTE_MAX_NUMA_NODES, ',');
407 /* if split failed, or 0 arguments */
411 internal_config.force_sockets = 1;
413 /* parse each defined socket option */
415 for (i = 0; i < arg_num; i++) {
417 internal_config.socket_mem[i] = strtoull(arg[i], &end, 10);
419 /* check for invalid input */
421 (arg[i][0] == '\0') || (end == NULL) || (*end != '\0'))
423 internal_config.socket_mem[i] *= 1024ULL;
424 internal_config.socket_mem[i] *= 1024ULL;
425 total_mem += internal_config.socket_mem[i];
428 /* check if we have a positive amount of total memory */
436 eal_parse_base_virtaddr(const char *arg)
442 addr = strtoull(arg, &end, 16);
444 /* check for errors */
445 if ((errno != 0) || (arg[0] == '\0') || end == NULL || (*end != '\0'))
448 /* make sure we don't exceed 32-bit boundary on 32-bit target */
450 if (addr >= UINTPTR_MAX)
454 /* align the addr on 16M boundary, 16MB is the minimum huge page
455 * size on IBM Power architecture. If the addr is aligned to 16MB,
456 * it can align to 2MB for x86. So this alignment can also be used
458 internal_config.base_virtaddr =
459 RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M);
465 eal_parse_vfio_intr(const char *mode)
470 enum rte_intr_mode value;
472 { "legacy", RTE_INTR_MODE_LEGACY },
473 { "msi", RTE_INTR_MODE_MSI },
474 { "msix", RTE_INTR_MODE_MSIX },
477 for (i = 0; i < RTE_DIM(map); i++) {
478 if (!strcmp(mode, map[i].name)) {
479 internal_config.vfio_intr_mode = map[i].value;
486 /* Parse the arguments for --log-level only */
488 eal_log_level_parse(int argc, char **argv)
493 const int old_optind = optind;
494 const int old_optopt = optopt;
495 char * const old_optarg = optarg;
500 while ((opt = getopt_long(argc, argvopt, eal_short_options,
501 eal_long_options, &option_index)) != EOF) {
505 /* getopt is not happy, stop right now */
509 ret = (opt == OPT_LOG_LEVEL_NUM) ?
510 eal_parse_common_option(opt, optarg, &internal_config) : 0;
512 /* common parser is not happy */
517 /* restore getopt lib */
523 /* Parse the argument given in the command line of the application */
525 eal_parse_args(int argc, char **argv)
530 char *prgname = argv[0];
531 const int old_optind = optind;
532 const int old_optopt = optopt;
533 char * const old_optarg = optarg;
538 while ((opt = getopt_long(argc, argvopt, eal_short_options,
539 eal_long_options, &option_index)) != EOF) {
541 /* getopt is not happy, stop right now */
548 ret = eal_parse_common_option(opt, optarg, &internal_config);
549 /* common parser is not happy */
555 /* common parser handled this option */
565 case OPT_XEN_DOM0_NUM:
566 #ifdef RTE_LIBRTE_XEN_DOM0
567 internal_config.xen_dom0_support = 1;
569 RTE_LOG(ERR, EAL, "Can't support DPDK app "
570 "running on Dom0, please configure"
571 " RTE_LIBRTE_XEN_DOM0=y\n");
577 case OPT_HUGE_DIR_NUM:
578 internal_config.hugepage_dir = optarg;
581 case OPT_FILE_PREFIX_NUM:
582 internal_config.hugefile_prefix = optarg;
585 case OPT_SOCKET_MEM_NUM:
586 if (eal_parse_socket_mem(optarg) < 0) {
587 RTE_LOG(ERR, EAL, "invalid parameters for --"
588 OPT_SOCKET_MEM "\n");
595 case OPT_BASE_VIRTADDR_NUM:
596 if (eal_parse_base_virtaddr(optarg) < 0) {
597 RTE_LOG(ERR, EAL, "invalid parameter for --"
598 OPT_BASE_VIRTADDR "\n");
605 case OPT_VFIO_INTR_NUM:
606 if (eal_parse_vfio_intr(optarg) < 0) {
607 RTE_LOG(ERR, EAL, "invalid parameters for --"
615 case OPT_CREATE_UIO_DEV_NUM:
616 internal_config.create_uio_dev = 1;
620 if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
621 RTE_LOG(ERR, EAL, "Option %c is not supported "
623 } else if (opt >= OPT_LONG_MIN_NUM &&
624 opt < OPT_LONG_MAX_NUM) {
625 RTE_LOG(ERR, EAL, "Option %s is not supported "
627 eal_long_options[option_index].name);
629 RTE_LOG(ERR, EAL, "Option %d is not supported "
638 if (eal_adjust_config(&internal_config) != 0) {
644 if (eal_check_common_options(&internal_config) != 0) {
650 /* --xen-dom0 doesn't make sense with --socket-mem */
651 if (internal_config.xen_dom0_support && internal_config.force_sockets == 1) {
652 RTE_LOG(ERR, EAL, "Options --"OPT_SOCKET_MEM" cannot be specified "
653 "together with --"OPT_XEN_DOM0"\n");
660 argv[optind-1] = prgname;
664 /* restore getopt lib */
673 eal_check_mem_on_local_socket(void)
675 const struct rte_memseg *ms;
678 socket_id = rte_lcore_to_socket_id(rte_config.master_lcore);
680 ms = rte_eal_get_physmem_layout();
682 for (i = 0; i < RTE_MAX_MEMSEG; i++)
683 if (ms[i].socket_id == socket_id &&
687 RTE_LOG(WARNING, EAL, "WARNING: Master core has no "
688 "memory on local socket!\n");
692 sync_func(__attribute__((unused)) void *arg)
698 rte_eal_mcfg_complete(void)
700 /* ALL shared mem_config related INIT DONE */
701 if (rte_config.process_type == RTE_PROC_PRIMARY)
702 rte_config.mem_config->magic = RTE_MAGIC;
706 * Request iopl privilege for all RPL, returns 0 on success
707 * iopl() call is mostly for the i386 architecture. For other architectures,
708 * return -1 to indicate IO privilege can't be changed in this way.
711 rte_eal_iopl_init(void)
713 #if defined(RTE_ARCH_X86)
721 static int rte_eal_vfio_setup(void)
723 int vfio_enabled = 0;
725 if (!internal_config.no_pci) {
727 vfio_enabled |= pci_vfio_is_enabled();
732 /* if we are primary process, create a thread to communicate with
733 * secondary processes. the thread will use a socket to wait for
734 * requests from secondary process to send open file descriptors,
735 * because VFIO does not allow multiple open descriptors on a group or
738 if (internal_config.process_type == RTE_PROC_PRIMARY &&
739 vfio_mp_sync_setup() < 0)
747 static void rte_eal_init_alert(const char *msg)
749 fprintf(stderr, "EAL: FATAL: %s\n", msg);
750 RTE_LOG(ERR, EAL, "%s\n", msg);
753 /* Launch threads, called at application init(). */
755 rte_eal_init(int argc, char **argv)
759 static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
761 char cpuset[RTE_CPU_AFFINITY_STR_LEN];
762 char thread_name[RTE_MAX_THREAD_NAME_LEN];
764 /* checks if the machine is adequate */
765 if (!rte_cpu_is_supported()) {
766 rte_eal_init_alert("unsupported cpu type.");
771 if (!rte_atomic32_test_and_set(&run_once)) {
772 rte_eal_init_alert("already called initialization.");
773 rte_errno = EALREADY;
777 logid = strrchr(argv[0], '/');
778 logid = strdup(logid ? logid + 1: argv[0]);
780 thread_id = pthread_self();
782 eal_reset_internal_config(&internal_config);
784 /* set log level as early as possible */
785 eal_log_level_parse(argc, argv);
787 if (rte_eal_cpu_init() < 0) {
788 rte_eal_init_alert("Cannot detect lcores.");
793 fctret = eal_parse_args(argc, argv);
795 rte_eal_init_alert("Invalid 'command line' arguments.");
797 rte_atomic32_clear(&run_once);
801 if (internal_config.no_hugetlbfs == 0 &&
802 internal_config.process_type != RTE_PROC_SECONDARY &&
803 internal_config.xen_dom0_support == 0 &&
804 eal_hugepage_info_init() < 0) {
805 rte_eal_init_alert("Cannot get hugepage information.");
807 rte_atomic32_clear(&run_once);
811 if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
812 if (internal_config.no_hugetlbfs)
813 internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
816 if (internal_config.vmware_tsc_map == 1) {
817 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
818 rte_cycles_vmware_tsc_map = 1;
819 RTE_LOG (DEBUG, EAL, "Using VMWARE TSC MAP, "
820 "you must have monitor_control.pseudo_perfctr = TRUE\n");
822 RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
823 "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
827 rte_srand(rte_rdtsc());
831 if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
832 rte_eal_init_alert("Cannot init logging.");
834 rte_atomic32_clear(&run_once);
839 if (rte_eal_vfio_setup() < 0) {
840 rte_eal_init_alert("Cannot init VFIO\n");
842 rte_atomic32_clear(&run_once);
847 if (rte_eal_memory_init() < 0) {
848 rte_eal_init_alert("Cannot init memory\n");
853 /* the directories are locked during eal_hugepage_info_init */
854 eal_hugedirs_unlock();
856 if (rte_eal_memzone_init() < 0) {
857 rte_eal_init_alert("Cannot init memzone\n");
862 if (rte_eal_tailqs_init() < 0) {
863 rte_eal_init_alert("Cannot init tail queues for objects\n");
868 if (rte_eal_alarm_init() < 0) {
869 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
870 /* rte_eal_alarm_init sets rte_errno on failure. */
874 if (rte_eal_timer_init() < 0) {
875 rte_eal_init_alert("Cannot init HPET or TSC timers\n");
880 eal_check_mem_on_local_socket();
882 if (eal_plugins_init() < 0)
883 rte_eal_init_alert("Cannot init plugins\n");
885 eal_thread_init_master(rte_config.master_lcore);
887 ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
889 RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%x;cpuset=[%s%s])\n",
890 rte_config.master_lcore, (int)thread_id, cpuset,
891 ret == 0 ? "" : "...");
893 if (rte_eal_intr_init() < 0) {
894 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
898 if (eal_option_device_parse()) {
903 if (rte_bus_scan()) {
904 rte_eal_init_alert("Cannot scan the buses for devices\n");
909 RTE_LCORE_FOREACH_SLAVE(i) {
912 * create communication pipes between master thread
915 if (pipe(lcore_config[i].pipe_master2slave) < 0)
916 rte_panic("Cannot create pipe\n");
917 if (pipe(lcore_config[i].pipe_slave2master) < 0)
918 rte_panic("Cannot create pipe\n");
920 lcore_config[i].state = WAIT;
922 /* create a thread for each lcore */
923 ret = pthread_create(&lcore_config[i].thread_id, NULL,
924 eal_thread_loop, NULL);
926 rte_panic("Cannot create thread\n");
928 /* Set thread_name for aid in debugging. */
929 snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
930 "lcore-slave-%d", i);
931 ret = rte_thread_setname(lcore_config[i].thread_id,
935 "Cannot set name for lcore thread\n");
939 * Launch a dummy function on all slave lcores, so that master lcore
940 * knows they are all ready when this function returns.
942 rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
943 rte_eal_mp_wait_lcore();
945 /* initialize services so vdevs register service during bus_probe. */
946 ret = rte_service_init();
948 rte_eal_init_alert("rte_service_init() failed\n");
953 /* Probe all the buses and devices/drivers on them */
954 if (rte_bus_probe()) {
955 rte_eal_init_alert("Cannot probe devices\n");
960 /* initialize default service/lcore mappings and start running. Ignore
961 * -ENOTSUP, as it indicates no service coremask passed to EAL.
963 ret = rte_service_start_with_defaults();
964 if (ret < 0 && ret != -ENOTSUP) {
969 rte_eal_mcfg_complete();
975 enum rte_lcore_role_t
976 rte_eal_lcore_role(unsigned lcore_id)
978 return rte_config.lcore_role[lcore_id];
982 rte_eal_process_type(void)
984 return rte_config.process_type;
987 int rte_eal_has_hugepages(void)
989 return ! internal_config.no_hugetlbfs;
993 rte_eal_check_module(const char *module_name)
995 char sysfs_mod_name[PATH_MAX];
999 if (NULL == module_name)
1002 /* Check if there is sysfs mounted */
1003 if (stat("/sys/module", &st) != 0) {
1004 RTE_LOG(DEBUG, EAL, "sysfs is not mounted! error %i (%s)\n",
1005 errno, strerror(errno));
1009 /* A module might be built-in, therefore try sysfs */
1010 n = snprintf(sysfs_mod_name, PATH_MAX, "/sys/module/%s", module_name);
1011 if (n < 0 || n > PATH_MAX) {
1012 RTE_LOG(DEBUG, EAL, "Could not format module path\n");
1016 if (stat(sysfs_mod_name, &st) != 0) {
1017 RTE_LOG(DEBUG, EAL, "Module %s not found! error %i (%s)\n",
1018 sysfs_mod_name, errno, strerror(errno));
1022 /* Module has been found */