1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation.
3 * Copyright(c) 2012-2014 6WIND S.A.
21 #include <sys/queue.h>
23 #if defined(RTE_ARCH_X86)
27 #include <rte_compat.h>
28 #include <rte_common.h>
29 #include <rte_debug.h>
30 #include <rte_memory.h>
31 #include <rte_launch.h>
33 #include <rte_eal_memconfig.h>
34 #include <rte_errno.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_service_component.h>
39 #include <rte_random.h>
40 #include <rte_cycles.h>
41 #include <rte_string_fns.h>
42 #include <rte_cpuflags.h>
43 #include <rte_interrupts.h>
46 #include <rte_devargs.h>
47 #include <rte_version.h>
48 #include <rte_atomic.h>
49 #include <malloc_heap.h>
52 #include "eal_private.h"
53 #include "eal_thread.h"
54 #include "eal_internal_cfg.h"
55 #include "eal_filesystem.h"
56 #include "eal_hugepages.h"
57 #include "eal_options.h"
60 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
62 #define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 10)
64 /* Allow the application to print its usage message too if set */
65 static rte_usage_hook_t rte_application_usage_hook = NULL;
67 /* early configuration structure, when memory config is not mmapped */
68 static struct rte_mem_config early_mem_config;
70 /* define fd variable here, because file needs to be kept open for the
71 * duration of the program, as we hold a write lock on it in the primary proc */
72 static int mem_cfg_fd = -1;
74 static struct flock wr_lock = {
77 .l_start = offsetof(struct rte_mem_config, memsegs),
78 .l_len = sizeof(early_mem_config.memsegs),
81 /* Address of global and public configuration */
82 static struct rte_config rte_config = {
83 .mem_config = &early_mem_config,
86 /* internal configuration (per-core) */
87 struct lcore_config lcore_config[RTE_MAX_LCORE];
89 /* internal configuration */
90 struct internal_config internal_config;
92 /* used by rte_rdtsc() */
93 int rte_cycles_vmware_tsc_map;
95 /* Return user provided mbuf pool ops name */
96 const char * __rte_experimental
97 rte_eal_mbuf_user_pool_ops(void)
99 return internal_config.user_mbuf_pool_ops_name;
102 /* Return mbuf pool ops name */
104 rte_eal_mbuf_default_mempool_ops(void)
106 if (internal_config.user_mbuf_pool_ops_name == NULL)
107 return RTE_MBUF_DEFAULT_MEMPOOL_OPS;
109 return internal_config.user_mbuf_pool_ops_name;
112 /* Return a pointer to the configuration structure */
114 rte_eal_get_configuration(void)
120 rte_eal_iova_mode(void)
122 return rte_eal_get_configuration()->iova_mode;
125 /* parse a sysfs (or other) file containing one integer value */
127 eal_parse_sysfs_value(const char *filename, unsigned long *val)
133 if ((f = fopen(filename, "r")) == NULL) {
134 RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n",
139 if (fgets(buf, sizeof(buf), f) == NULL) {
140 RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n",
145 *val = strtoul(buf, &end, 0);
146 if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) {
147 RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n",
157 /* create memory configuration in shared/mmap memory. Take out
158 * a write lock on the memsegs, so we can auto-detect primary/secondary.
159 * This means we never close the file while running (auto-close on exit).
160 * We also don't lock the whole file, so that in future we can use read-locks
161 * on other parts, e.g. memzones, to detect if there are running secondary
164 rte_eal_config_create(void)
166 void *rte_mem_cfg_addr;
169 const char *pathname = eal_runtime_config_path();
171 if (internal_config.no_shconf)
174 /* map the config before hugepage address so that we don't waste a page */
175 if (internal_config.base_virtaddr != 0)
176 rte_mem_cfg_addr = (void *)
177 RTE_ALIGN_FLOOR(internal_config.base_virtaddr -
178 sizeof(struct rte_mem_config), sysconf(_SC_PAGE_SIZE));
180 rte_mem_cfg_addr = NULL;
183 mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
185 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
188 retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
191 rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
194 retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
197 rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
198 "process running?\n", pathname);
201 rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
202 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
204 if (rte_mem_cfg_addr == MAP_FAILED){
205 rte_panic("Cannot mmap memory for rte_config\n");
207 memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
208 rte_config.mem_config = rte_mem_cfg_addr;
210 /* store address of the config in the config itself so that secondary
211 * processes could later map the config into this exact location */
212 rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
216 /* attach to an existing shared memory config */
218 rte_eal_config_attach(void)
220 struct rte_mem_config *mem_config;
222 const char *pathname = eal_runtime_config_path();
224 if (internal_config.no_shconf)
228 mem_cfg_fd = open(pathname, O_RDWR);
230 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
233 /* map it as read-only first */
234 mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
235 PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
236 if (mem_config == MAP_FAILED)
237 rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
238 errno, strerror(errno));
240 rte_config.mem_config = mem_config;
243 /* reattach the shared config at exact memory location primary process has it */
245 rte_eal_config_reattach(void)
247 struct rte_mem_config *mem_config;
248 void *rte_mem_cfg_addr;
250 if (internal_config.no_shconf)
253 /* save the address primary process has mapped shared config to */
254 rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
256 /* unmap original config */
257 munmap(rte_config.mem_config, sizeof(struct rte_mem_config));
259 /* remap the config at proper address */
260 mem_config = (struct rte_mem_config *) mmap(rte_mem_cfg_addr,
261 sizeof(*mem_config), PROT_READ | PROT_WRITE, MAP_SHARED,
263 if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {
264 if (mem_config != MAP_FAILED)
265 /* errno is stale, don't use */
266 rte_panic("Cannot mmap memory for rte_config at [%p], got [%p]"
267 " - please use '--base-virtaddr' option\n",
268 rte_mem_cfg_addr, mem_config);
270 rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
271 errno, strerror(errno));
275 rte_config.mem_config = mem_config;
278 /* Detect if we are a primary or a secondary process */
280 eal_proc_type_detect(void)
282 enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
283 const char *pathname = eal_runtime_config_path();
285 /* if we can open the file but not get a write-lock we are a secondary
286 * process. NOTE: if we get a file handle back, we keep that open
287 * and don't close it to prevent a race condition between multiple opens */
288 if (((mem_cfg_fd = open(pathname, O_RDWR)) >= 0) &&
289 (fcntl(mem_cfg_fd, F_SETLK, &wr_lock) < 0))
290 ptype = RTE_PROC_SECONDARY;
292 RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
293 ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
298 /* Sets up rte_config structure with the pointer to shared memory config.*/
300 rte_config_init(void)
302 rte_config.process_type = internal_config.process_type;
304 switch (rte_config.process_type){
305 case RTE_PROC_PRIMARY:
306 rte_eal_config_create();
308 case RTE_PROC_SECONDARY:
309 rte_eal_config_attach();
310 rte_eal_mcfg_wait_complete(rte_config.mem_config);
311 rte_eal_config_reattach();
314 case RTE_PROC_INVALID:
315 rte_panic("Invalid process type\n");
319 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
321 eal_hugedirs_unlock(void)
325 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
327 /* skip uninitialized */
328 if (internal_config.hugepage_info[i].lock_descriptor < 0)
330 /* unlock hugepage file */
331 flock(internal_config.hugepage_info[i].lock_descriptor, LOCK_UN);
332 close(internal_config.hugepage_info[i].lock_descriptor);
333 /* reset the field */
334 internal_config.hugepage_info[i].lock_descriptor = -1;
340 eal_usage(const char *prgname)
342 printf("\nUsage: %s ", prgname);
344 printf("EAL Linux options:\n"
345 " --"OPT_SOCKET_MEM" Memory to allocate on sockets (comma separated values)\n"
346 " --"OPT_HUGE_DIR" Directory where hugetlbfs is mounted\n"
347 " --"OPT_FILE_PREFIX" Prefix for hugepage filenames\n"
348 " --"OPT_BASE_VIRTADDR" Base virtual address\n"
349 " --"OPT_CREATE_UIO_DEV" Create /dev/uioX (usually done by hotplug)\n"
350 " --"OPT_VFIO_INTR" Interrupt mode for VFIO (legacy|msi|msix)\n"
351 " --"OPT_LEGACY_MEM" Legacy memory mode (no dynamic allocation, contiguous segments)\n"
352 " --"OPT_SINGLE_FILE_SEGMENTS" Put all hugepage memory in single files\n"
354 /* Allow the application to print its usage message too if hook is set */
355 if ( rte_application_usage_hook ) {
356 printf("===== Application Usage =====\n\n");
357 rte_application_usage_hook(prgname);
361 /* Set a per-application usage message */
363 rte_set_application_usage_hook( rte_usage_hook_t usage_func )
365 rte_usage_hook_t old_func;
367 /* Will be NULL on the first call to denote the last usage routine. */
368 old_func = rte_application_usage_hook;
369 rte_application_usage_hook = usage_func;
375 eal_parse_socket_mem(char *socket_mem)
377 char * arg[RTE_MAX_NUMA_NODES];
380 uint64_t total_mem = 0;
382 len = strnlen(socket_mem, SOCKET_MEM_STRLEN);
383 if (len == SOCKET_MEM_STRLEN) {
384 RTE_LOG(ERR, EAL, "--socket-mem is too long\n");
388 /* all other error cases will be caught later */
389 if (!isdigit(socket_mem[len-1]))
392 /* split the optarg into separate socket values */
393 arg_num = rte_strsplit(socket_mem, len,
394 arg, RTE_MAX_NUMA_NODES, ',');
396 /* if split failed, or 0 arguments */
400 internal_config.force_sockets = 1;
402 /* parse each defined socket option */
404 for (i = 0; i < arg_num; i++) {
406 internal_config.socket_mem[i] = strtoull(arg[i], &end, 10);
408 /* check for invalid input */
410 (arg[i][0] == '\0') || (end == NULL) || (*end != '\0'))
412 internal_config.socket_mem[i] *= 1024ULL;
413 internal_config.socket_mem[i] *= 1024ULL;
414 total_mem += internal_config.socket_mem[i];
417 /* check if we have a positive amount of total memory */
425 eal_parse_base_virtaddr(const char *arg)
431 addr = strtoull(arg, &end, 16);
433 /* check for errors */
434 if ((errno != 0) || (arg[0] == '\0') || end == NULL || (*end != '\0'))
437 /* make sure we don't exceed 32-bit boundary on 32-bit target */
439 if (addr >= UINTPTR_MAX)
443 /* align the addr on 16M boundary, 16MB is the minimum huge page
444 * size on IBM Power architecture. If the addr is aligned to 16MB,
445 * it can align to 2MB for x86. So this alignment can also be used
447 internal_config.base_virtaddr =
448 RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M);
454 eal_parse_vfio_intr(const char *mode)
459 enum rte_intr_mode value;
461 { "legacy", RTE_INTR_MODE_LEGACY },
462 { "msi", RTE_INTR_MODE_MSI },
463 { "msix", RTE_INTR_MODE_MSIX },
466 for (i = 0; i < RTE_DIM(map); i++) {
467 if (!strcmp(mode, map[i].name)) {
468 internal_config.vfio_intr_mode = map[i].value;
475 /* Parse the arguments for --log-level only */
477 eal_log_level_parse(int argc, char **argv)
482 const int old_optind = optind;
483 const int old_optopt = optopt;
484 char * const old_optarg = optarg;
489 while ((opt = getopt_long(argc, argvopt, eal_short_options,
490 eal_long_options, &option_index)) != EOF) {
494 /* getopt is not happy, stop right now */
498 ret = (opt == OPT_LOG_LEVEL_NUM) ?
499 eal_parse_common_option(opt, optarg, &internal_config) : 0;
501 /* common parser is not happy */
506 /* restore getopt lib */
512 /* Parse the argument given in the command line of the application */
514 eal_parse_args(int argc, char **argv)
519 char *prgname = argv[0];
520 const int old_optind = optind;
521 const int old_optopt = optopt;
522 char * const old_optarg = optarg;
527 while ((opt = getopt_long(argc, argvopt, eal_short_options,
528 eal_long_options, &option_index)) != EOF) {
530 /* getopt is not happy, stop right now */
537 ret = eal_parse_common_option(opt, optarg, &internal_config);
538 /* common parser is not happy */
544 /* common parser handled this option */
553 case OPT_HUGE_DIR_NUM:
554 internal_config.hugepage_dir = strdup(optarg);
557 case OPT_FILE_PREFIX_NUM:
558 internal_config.hugefile_prefix = strdup(optarg);
561 case OPT_SOCKET_MEM_NUM:
562 if (eal_parse_socket_mem(optarg) < 0) {
563 RTE_LOG(ERR, EAL, "invalid parameters for --"
564 OPT_SOCKET_MEM "\n");
571 case OPT_BASE_VIRTADDR_NUM:
572 if (eal_parse_base_virtaddr(optarg) < 0) {
573 RTE_LOG(ERR, EAL, "invalid parameter for --"
574 OPT_BASE_VIRTADDR "\n");
581 case OPT_VFIO_INTR_NUM:
582 if (eal_parse_vfio_intr(optarg) < 0) {
583 RTE_LOG(ERR, EAL, "invalid parameters for --"
591 case OPT_CREATE_UIO_DEV_NUM:
592 internal_config.create_uio_dev = 1;
595 case OPT_MBUF_POOL_OPS_NAME_NUM:
596 internal_config.user_mbuf_pool_ops_name = optarg;
600 if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
601 RTE_LOG(ERR, EAL, "Option %c is not supported "
603 } else if (opt >= OPT_LONG_MIN_NUM &&
604 opt < OPT_LONG_MAX_NUM) {
605 RTE_LOG(ERR, EAL, "Option %s is not supported "
607 eal_long_options[option_index].name);
609 RTE_LOG(ERR, EAL, "Option %d is not supported "
618 if (eal_adjust_config(&internal_config) != 0) {
624 if (eal_check_common_options(&internal_config) != 0) {
631 argv[optind-1] = prgname;
635 /* restore getopt lib */
644 check_socket(const struct rte_memseg_list *msl, void *arg)
646 int *socket_id = arg;
648 if (msl->socket_id == *socket_id && msl->memseg_arr.count != 0)
655 eal_check_mem_on_local_socket(void)
659 socket_id = rte_lcore_to_socket_id(rte_config.master_lcore);
661 if (rte_memseg_list_walk(check_socket, &socket_id) == 0)
662 RTE_LOG(WARNING, EAL, "WARNING: Master core has no memory on local socket!\n");
666 sync_func(__attribute__((unused)) void *arg)
672 rte_eal_mcfg_complete(void)
674 /* ALL shared mem_config related INIT DONE */
675 if (rte_config.process_type == RTE_PROC_PRIMARY)
676 rte_config.mem_config->magic = RTE_MAGIC;
678 internal_config.init_complete = 1;
682 * Request iopl privilege for all RPL, returns 0 on success
683 * iopl() call is mostly for the i386 architecture. For other architectures,
684 * return -1 to indicate IO privilege can't be changed in this way.
687 rte_eal_iopl_init(void)
689 #if defined(RTE_ARCH_X86)
697 static int rte_eal_vfio_setup(void)
699 int vfio_enabled = 0;
701 if (rte_vfio_enable("vfio"))
703 vfio_enabled = rte_vfio_is_enabled("vfio");
707 /* if we are primary process, create a thread to communicate with
708 * secondary processes. the thread will use a socket to wait for
709 * requests from secondary process to send open file descriptors,
710 * because VFIO does not allow multiple open descriptors on a group or
713 if (internal_config.process_type == RTE_PROC_PRIMARY &&
714 vfio_mp_sync_setup() < 0)
722 static void rte_eal_init_alert(const char *msg)
724 fprintf(stderr, "EAL: FATAL: %s\n", msg);
725 RTE_LOG(ERR, EAL, "%s\n", msg);
728 /* Launch threads, called at application init(). */
730 rte_eal_init(int argc, char **argv)
734 static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
736 char cpuset[RTE_CPU_AFFINITY_STR_LEN];
737 char thread_name[RTE_MAX_THREAD_NAME_LEN];
739 /* checks if the machine is adequate */
740 if (!rte_cpu_is_supported()) {
741 rte_eal_init_alert("unsupported cpu type.");
746 if (!rte_atomic32_test_and_set(&run_once)) {
747 rte_eal_init_alert("already called initialization.");
748 rte_errno = EALREADY;
752 logid = strrchr(argv[0], '/');
753 logid = strdup(logid ? logid + 1: argv[0]);
755 thread_id = pthread_self();
757 eal_reset_internal_config(&internal_config);
759 /* set log level as early as possible */
760 eal_log_level_parse(argc, argv);
762 if (rte_eal_cpu_init() < 0) {
763 rte_eal_init_alert("Cannot detect lcores.");
768 fctret = eal_parse_args(argc, argv);
770 rte_eal_init_alert("Invalid 'command line' arguments.");
772 rte_atomic32_clear(&run_once);
776 if (eal_plugins_init() < 0) {
777 rte_eal_init_alert("Cannot init plugins\n");
779 rte_atomic32_clear(&run_once);
783 if (eal_option_device_parse()) {
785 rte_atomic32_clear(&run_once);
789 if (rte_bus_scan()) {
790 rte_eal_init_alert("Cannot scan the buses for devices\n");
792 rte_atomic32_clear(&run_once);
796 /* autodetect the iova mapping mode (default is iova_pa) */
797 rte_eal_get_configuration()->iova_mode = rte_bus_get_iommu_class();
799 /* Workaround for KNI which requires physical address to work */
800 if (rte_eal_get_configuration()->iova_mode == RTE_IOVA_VA &&
801 rte_eal_check_module("rte_kni") == 1) {
802 rte_eal_get_configuration()->iova_mode = RTE_IOVA_PA;
803 RTE_LOG(WARNING, EAL,
804 "Some devices want IOVA as VA but PA will be used because.. "
805 "KNI module inserted\n");
808 if (internal_config.no_hugetlbfs == 0) {
809 /* rte_config isn't initialized yet */
810 ret = internal_config.process_type == RTE_PROC_PRIMARY ?
811 eal_hugepage_info_init() :
812 eal_hugepage_info_read();
814 rte_eal_init_alert("Cannot get hugepage information.");
816 rte_atomic32_clear(&run_once);
821 if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
822 if (internal_config.no_hugetlbfs)
823 internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
826 if (internal_config.vmware_tsc_map == 1) {
827 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
828 rte_cycles_vmware_tsc_map = 1;
829 RTE_LOG (DEBUG, EAL, "Using VMWARE TSC MAP, "
830 "you must have monitor_control.pseudo_perfctr = TRUE\n");
832 RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
833 "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
837 rte_srand(rte_rdtsc());
841 if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
842 rte_eal_init_alert("Cannot init logging.");
844 rte_atomic32_clear(&run_once);
848 if (rte_mp_channel_init() < 0) {
849 rte_eal_init_alert("failed to init mp channel\n");
850 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
857 if (rte_eal_vfio_setup() < 0) {
858 rte_eal_init_alert("Cannot init VFIO\n");
860 rte_atomic32_clear(&run_once);
864 /* in secondary processes, memory init may allocate additional fbarrays
865 * not present in primary processes, so to avoid any potential issues,
866 * initialize memzones first.
868 if (rte_eal_memzone_init() < 0) {
869 rte_eal_init_alert("Cannot init memzone\n");
874 if (rte_eal_memory_init() < 0) {
875 rte_eal_init_alert("Cannot init memory\n");
880 /* the directories are locked during eal_hugepage_info_init */
881 eal_hugedirs_unlock();
883 if (rte_eal_malloc_heap_init() < 0) {
884 rte_eal_init_alert("Cannot init malloc heap\n");
889 if (rte_eal_tailqs_init() < 0) {
890 rte_eal_init_alert("Cannot init tail queues for objects\n");
895 if (rte_eal_alarm_init() < 0) {
896 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
897 /* rte_eal_alarm_init sets rte_errno on failure. */
901 if (rte_eal_timer_init() < 0) {
902 rte_eal_init_alert("Cannot init HPET or TSC timers\n");
907 eal_check_mem_on_local_socket();
909 eal_thread_init_master(rte_config.master_lcore);
911 ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
913 RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%x;cpuset=[%s%s])\n",
914 rte_config.master_lcore, (int)thread_id, cpuset,
915 ret == 0 ? "" : "...");
917 if (rte_eal_intr_init() < 0) {
918 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
922 RTE_LCORE_FOREACH_SLAVE(i) {
925 * create communication pipes between master thread
928 if (pipe(lcore_config[i].pipe_master2slave) < 0)
929 rte_panic("Cannot create pipe\n");
930 if (pipe(lcore_config[i].pipe_slave2master) < 0)
931 rte_panic("Cannot create pipe\n");
933 lcore_config[i].state = WAIT;
935 /* create a thread for each lcore */
936 ret = pthread_create(&lcore_config[i].thread_id, NULL,
937 eal_thread_loop, NULL);
939 rte_panic("Cannot create thread\n");
941 /* Set thread_name for aid in debugging. */
942 snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
943 "lcore-slave-%d", i);
944 ret = rte_thread_setname(lcore_config[i].thread_id,
948 "Cannot set name for lcore thread\n");
952 * Launch a dummy function on all slave lcores, so that master lcore
953 * knows they are all ready when this function returns.
955 rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
956 rte_eal_mp_wait_lcore();
958 /* initialize services so vdevs register service during bus_probe. */
959 ret = rte_service_init();
961 rte_eal_init_alert("rte_service_init() failed\n");
966 /* Probe all the buses and devices/drivers on them */
967 if (rte_bus_probe()) {
968 rte_eal_init_alert("Cannot probe devices\n");
973 /* initialize default service/lcore mappings and start running. Ignore
974 * -ENOTSUP, as it indicates no service coremask passed to EAL.
976 ret = rte_service_start_with_defaults();
977 if (ret < 0 && ret != -ENOTSUP) {
982 rte_eal_mcfg_complete();
987 int __rte_experimental
988 rte_eal_cleanup(void)
990 rte_service_finalize();
995 enum rte_lcore_role_t
996 rte_eal_lcore_role(unsigned lcore_id)
998 return rte_config.lcore_role[lcore_id];
1001 enum rte_proc_type_t
1002 rte_eal_process_type(void)
1004 return rte_config.process_type;
1007 int rte_eal_has_hugepages(void)
1009 return ! internal_config.no_hugetlbfs;
1012 int rte_eal_has_pci(void)
1014 return !internal_config.no_pci;
1017 int rte_eal_create_uio_dev(void)
1019 return internal_config.create_uio_dev;
1023 rte_eal_vfio_intr_mode(void)
1025 return internal_config.vfio_intr_mode;
1029 rte_eal_check_module(const char *module_name)
1031 char sysfs_mod_name[PATH_MAX];
1035 if (NULL == module_name)
1038 /* Check if there is sysfs mounted */
1039 if (stat("/sys/module", &st) != 0) {
1040 RTE_LOG(DEBUG, EAL, "sysfs is not mounted! error %i (%s)\n",
1041 errno, strerror(errno));
1045 /* A module might be built-in, therefore try sysfs */
1046 n = snprintf(sysfs_mod_name, PATH_MAX, "/sys/module/%s", module_name);
1047 if (n < 0 || n > PATH_MAX) {
1048 RTE_LOG(DEBUG, EAL, "Could not format module path\n");
1052 if (stat(sysfs_mod_name, &st) != 0) {
1053 RTE_LOG(DEBUG, EAL, "Module %s not found! error %i (%s)\n",
1054 sysfs_mod_name, errno, strerror(errno));
1058 /* Module has been found */