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, memseg),
78 .l_len = sizeof(early_mem_config.memseg),
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 mbuf pool ops name */
97 rte_eal_mbuf_default_mempool_ops(void)
99 if (internal_config.user_mbuf_pool_ops_name == NULL)
100 return RTE_MBUF_DEFAULT_MEMPOOL_OPS;
102 return internal_config.user_mbuf_pool_ops_name;
105 /* Return a pointer to the configuration structure */
107 rte_eal_get_configuration(void)
113 rte_eal_iova_mode(void)
115 return rte_eal_get_configuration()->iova_mode;
118 /* parse a sysfs (or other) file containing one integer value */
120 eal_parse_sysfs_value(const char *filename, unsigned long *val)
126 if ((f = fopen(filename, "r")) == NULL) {
127 RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n",
132 if (fgets(buf, sizeof(buf), f) == NULL) {
133 RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n",
138 *val = strtoul(buf, &end, 0);
139 if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) {
140 RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n",
150 /* create memory configuration in shared/mmap memory. Take out
151 * a write lock on the memsegs, so we can auto-detect primary/secondary.
152 * This means we never close the file while running (auto-close on exit).
153 * We also don't lock the whole file, so that in future we can use read-locks
154 * on other parts, e.g. memzones, to detect if there are running secondary
157 rte_eal_config_create(void)
159 void *rte_mem_cfg_addr;
162 const char *pathname = eal_runtime_config_path();
164 if (internal_config.no_shconf)
167 /* map the config before hugepage address so that we don't waste a page */
168 if (internal_config.base_virtaddr != 0)
169 rte_mem_cfg_addr = (void *)
170 RTE_ALIGN_FLOOR(internal_config.base_virtaddr -
171 sizeof(struct rte_mem_config), sysconf(_SC_PAGE_SIZE));
173 rte_mem_cfg_addr = NULL;
176 mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
178 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
181 retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
184 rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
187 retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
190 rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
191 "process running?\n", pathname);
194 rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
195 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
197 if (rte_mem_cfg_addr == MAP_FAILED){
198 rte_panic("Cannot mmap memory for rte_config\n");
200 memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
201 rte_config.mem_config = rte_mem_cfg_addr;
203 /* store address of the config in the config itself so that secondary
204 * processes could later map the config into this exact location */
205 rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
209 /* attach to an existing shared memory config */
211 rte_eal_config_attach(void)
213 struct rte_mem_config *mem_config;
215 const char *pathname = eal_runtime_config_path();
217 if (internal_config.no_shconf)
221 mem_cfg_fd = open(pathname, O_RDWR);
223 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
226 /* map it as read-only first */
227 mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
228 PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
229 if (mem_config == MAP_FAILED)
230 rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
231 errno, strerror(errno));
233 rte_config.mem_config = mem_config;
236 /* reattach the shared config at exact memory location primary process has it */
238 rte_eal_config_reattach(void)
240 struct rte_mem_config *mem_config;
241 void *rte_mem_cfg_addr;
243 if (internal_config.no_shconf)
246 /* save the address primary process has mapped shared config to */
247 rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
249 /* unmap original config */
250 munmap(rte_config.mem_config, sizeof(struct rte_mem_config));
252 /* remap the config at proper address */
253 mem_config = (struct rte_mem_config *) mmap(rte_mem_cfg_addr,
254 sizeof(*mem_config), PROT_READ | PROT_WRITE, MAP_SHARED,
256 if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {
257 if (mem_config != MAP_FAILED)
258 /* errno is stale, don't use */
259 rte_panic("Cannot mmap memory for rte_config at [%p], got [%p]"
260 " - please use '--base-virtaddr' option\n",
261 rte_mem_cfg_addr, mem_config);
263 rte_panic("Cannot mmap memory for rte_config! error %i (%s)\n",
264 errno, strerror(errno));
268 rte_config.mem_config = mem_config;
271 /* Detect if we are a primary or a secondary process */
273 eal_proc_type_detect(void)
275 enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
276 const char *pathname = eal_runtime_config_path();
278 /* if we can open the file but not get a write-lock we are a secondary
279 * process. NOTE: if we get a file handle back, we keep that open
280 * and don't close it to prevent a race condition between multiple opens */
281 if (((mem_cfg_fd = open(pathname, O_RDWR)) >= 0) &&
282 (fcntl(mem_cfg_fd, F_SETLK, &wr_lock) < 0))
283 ptype = RTE_PROC_SECONDARY;
285 RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
286 ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
291 /* Sets up rte_config structure with the pointer to shared memory config.*/
293 rte_config_init(void)
295 rte_config.process_type = internal_config.process_type;
297 switch (rte_config.process_type){
298 case RTE_PROC_PRIMARY:
299 rte_eal_config_create();
301 case RTE_PROC_SECONDARY:
302 rte_eal_config_attach();
303 rte_eal_mcfg_wait_complete(rte_config.mem_config);
304 rte_eal_config_reattach();
307 case RTE_PROC_INVALID:
308 rte_panic("Invalid process type\n");
312 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
314 eal_hugedirs_unlock(void)
318 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
320 /* skip uninitialized */
321 if (internal_config.hugepage_info[i].lock_descriptor < 0)
323 /* unlock hugepage file */
324 flock(internal_config.hugepage_info[i].lock_descriptor, LOCK_UN);
325 close(internal_config.hugepage_info[i].lock_descriptor);
326 /* reset the field */
327 internal_config.hugepage_info[i].lock_descriptor = -1;
333 eal_usage(const char *prgname)
335 printf("\nUsage: %s ", prgname);
337 printf("EAL Linux options:\n"
338 " --"OPT_SOCKET_MEM" Memory to allocate on sockets (comma separated values)\n"
339 " --"OPT_HUGE_DIR" Directory where hugetlbfs is mounted\n"
340 " --"OPT_FILE_PREFIX" Prefix for hugepage filenames\n"
341 " --"OPT_BASE_VIRTADDR" Base virtual address\n"
342 " --"OPT_CREATE_UIO_DEV" Create /dev/uioX (usually done by hotplug)\n"
343 " --"OPT_VFIO_INTR" Interrupt mode for VFIO (legacy|msi|msix)\n"
345 /* Allow the application to print its usage message too if hook is set */
346 if ( rte_application_usage_hook ) {
347 printf("===== Application Usage =====\n\n");
348 rte_application_usage_hook(prgname);
352 /* Set a per-application usage message */
354 rte_set_application_usage_hook( rte_usage_hook_t usage_func )
356 rte_usage_hook_t old_func;
358 /* Will be NULL on the first call to denote the last usage routine. */
359 old_func = rte_application_usage_hook;
360 rte_application_usage_hook = usage_func;
366 eal_parse_socket_mem(char *socket_mem)
368 char * arg[RTE_MAX_NUMA_NODES];
371 uint64_t total_mem = 0;
373 len = strnlen(socket_mem, SOCKET_MEM_STRLEN);
374 if (len == SOCKET_MEM_STRLEN) {
375 RTE_LOG(ERR, EAL, "--socket-mem is too long\n");
379 /* all other error cases will be caught later */
380 if (!isdigit(socket_mem[len-1]))
383 /* split the optarg into separate socket values */
384 arg_num = rte_strsplit(socket_mem, len,
385 arg, RTE_MAX_NUMA_NODES, ',');
387 /* if split failed, or 0 arguments */
391 internal_config.force_sockets = 1;
393 /* parse each defined socket option */
395 for (i = 0; i < arg_num; i++) {
397 internal_config.socket_mem[i] = strtoull(arg[i], &end, 10);
399 /* check for invalid input */
401 (arg[i][0] == '\0') || (end == NULL) || (*end != '\0'))
403 internal_config.socket_mem[i] *= 1024ULL;
404 internal_config.socket_mem[i] *= 1024ULL;
405 total_mem += internal_config.socket_mem[i];
408 /* check if we have a positive amount of total memory */
416 eal_parse_base_virtaddr(const char *arg)
422 addr = strtoull(arg, &end, 16);
424 /* check for errors */
425 if ((errno != 0) || (arg[0] == '\0') || end == NULL || (*end != '\0'))
428 /* make sure we don't exceed 32-bit boundary on 32-bit target */
430 if (addr >= UINTPTR_MAX)
434 /* align the addr on 16M boundary, 16MB is the minimum huge page
435 * size on IBM Power architecture. If the addr is aligned to 16MB,
436 * it can align to 2MB for x86. So this alignment can also be used
438 internal_config.base_virtaddr =
439 RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M);
445 eal_parse_vfio_intr(const char *mode)
450 enum rte_intr_mode value;
452 { "legacy", RTE_INTR_MODE_LEGACY },
453 { "msi", RTE_INTR_MODE_MSI },
454 { "msix", RTE_INTR_MODE_MSIX },
457 for (i = 0; i < RTE_DIM(map); i++) {
458 if (!strcmp(mode, map[i].name)) {
459 internal_config.vfio_intr_mode = map[i].value;
466 /* Parse the arguments for --log-level only */
468 eal_log_level_parse(int argc, char **argv)
473 const int old_optind = optind;
474 const int old_optopt = optopt;
475 char * const old_optarg = optarg;
480 while ((opt = getopt_long(argc, argvopt, eal_short_options,
481 eal_long_options, &option_index)) != EOF) {
485 /* getopt is not happy, stop right now */
489 ret = (opt == OPT_LOG_LEVEL_NUM) ?
490 eal_parse_common_option(opt, optarg, &internal_config) : 0;
492 /* common parser is not happy */
497 /* restore getopt lib */
503 /* Parse the argument given in the command line of the application */
505 eal_parse_args(int argc, char **argv)
510 char *prgname = argv[0];
511 const int old_optind = optind;
512 const int old_optopt = optopt;
513 char * const old_optarg = optarg;
518 while ((opt = getopt_long(argc, argvopt, eal_short_options,
519 eal_long_options, &option_index)) != EOF) {
521 /* getopt is not happy, stop right now */
528 ret = eal_parse_common_option(opt, optarg, &internal_config);
529 /* common parser is not happy */
535 /* common parser handled this option */
544 case OPT_HUGE_DIR_NUM:
545 internal_config.hugepage_dir = strdup(optarg);
548 case OPT_FILE_PREFIX_NUM:
549 internal_config.hugefile_prefix = strdup(optarg);
552 case OPT_SOCKET_MEM_NUM:
553 if (eal_parse_socket_mem(optarg) < 0) {
554 RTE_LOG(ERR, EAL, "invalid parameters for --"
555 OPT_SOCKET_MEM "\n");
562 case OPT_BASE_VIRTADDR_NUM:
563 if (eal_parse_base_virtaddr(optarg) < 0) {
564 RTE_LOG(ERR, EAL, "invalid parameter for --"
565 OPT_BASE_VIRTADDR "\n");
572 case OPT_VFIO_INTR_NUM:
573 if (eal_parse_vfio_intr(optarg) < 0) {
574 RTE_LOG(ERR, EAL, "invalid parameters for --"
582 case OPT_CREATE_UIO_DEV_NUM:
583 internal_config.create_uio_dev = 1;
586 case OPT_MBUF_POOL_OPS_NAME_NUM:
587 internal_config.user_mbuf_pool_ops_name = optarg;
591 if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
592 RTE_LOG(ERR, EAL, "Option %c is not supported "
594 } else if (opt >= OPT_LONG_MIN_NUM &&
595 opt < OPT_LONG_MAX_NUM) {
596 RTE_LOG(ERR, EAL, "Option %s is not supported "
598 eal_long_options[option_index].name);
600 RTE_LOG(ERR, EAL, "Option %d is not supported "
609 if (eal_adjust_config(&internal_config) != 0) {
615 if (eal_check_common_options(&internal_config) != 0) {
622 argv[optind-1] = prgname;
626 /* restore getopt lib */
635 eal_check_mem_on_local_socket(void)
637 const struct rte_memseg *ms;
640 socket_id = rte_lcore_to_socket_id(rte_config.master_lcore);
642 ms = rte_eal_get_physmem_layout();
644 for (i = 0; i < RTE_MAX_MEMSEG; i++)
645 if (ms[i].socket_id == socket_id &&
649 RTE_LOG(WARNING, EAL, "WARNING: Master core has no "
650 "memory on local socket!\n");
654 sync_func(__attribute__((unused)) void *arg)
660 rte_eal_mcfg_complete(void)
662 /* ALL shared mem_config related INIT DONE */
663 if (rte_config.process_type == RTE_PROC_PRIMARY)
664 rte_config.mem_config->magic = RTE_MAGIC;
668 * Request iopl privilege for all RPL, returns 0 on success
669 * iopl() call is mostly for the i386 architecture. For other architectures,
670 * return -1 to indicate IO privilege can't be changed in this way.
673 rte_eal_iopl_init(void)
675 #if defined(RTE_ARCH_X86)
683 static int rte_eal_vfio_setup(void)
685 int vfio_enabled = 0;
687 if (rte_vfio_enable("vfio"))
689 vfio_enabled = rte_vfio_is_enabled("vfio");
693 /* if we are primary process, create a thread to communicate with
694 * secondary processes. the thread will use a socket to wait for
695 * requests from secondary process to send open file descriptors,
696 * because VFIO does not allow multiple open descriptors on a group or
699 if (internal_config.process_type == RTE_PROC_PRIMARY &&
700 vfio_mp_sync_setup() < 0)
708 static void rte_eal_init_alert(const char *msg)
710 fprintf(stderr, "EAL: FATAL: %s\n", msg);
711 RTE_LOG(ERR, EAL, "%s\n", msg);
714 /* Launch threads, called at application init(). */
716 rte_eal_init(int argc, char **argv)
720 static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
722 char cpuset[RTE_CPU_AFFINITY_STR_LEN];
723 char thread_name[RTE_MAX_THREAD_NAME_LEN];
725 /* checks if the machine is adequate */
726 if (!rte_cpu_is_supported()) {
727 rte_eal_init_alert("unsupported cpu type.");
732 if (!rte_atomic32_test_and_set(&run_once)) {
733 rte_eal_init_alert("already called initialization.");
734 rte_errno = EALREADY;
738 logid = strrchr(argv[0], '/');
739 logid = strdup(logid ? logid + 1: argv[0]);
741 thread_id = pthread_self();
743 eal_reset_internal_config(&internal_config);
745 /* set log level as early as possible */
746 eal_log_level_parse(argc, argv);
748 if (rte_eal_cpu_init() < 0) {
749 rte_eal_init_alert("Cannot detect lcores.");
754 fctret = eal_parse_args(argc, argv);
756 rte_eal_init_alert("Invalid 'command line' arguments.");
758 rte_atomic32_clear(&run_once);
762 if (eal_plugins_init() < 0) {
763 rte_eal_init_alert("Cannot init plugins\n");
765 rte_atomic32_clear(&run_once);
769 if (eal_option_device_parse()) {
771 rte_atomic32_clear(&run_once);
775 if (rte_bus_scan()) {
776 rte_eal_init_alert("Cannot scan the buses for devices\n");
778 rte_atomic32_clear(&run_once);
782 /* autodetect the iova mapping mode (default is iova_pa) */
783 rte_eal_get_configuration()->iova_mode = rte_bus_get_iommu_class();
785 /* Workaround for KNI which requires physical address to work */
786 if (rte_eal_get_configuration()->iova_mode == RTE_IOVA_VA &&
787 rte_eal_check_module("rte_kni") == 1) {
788 rte_eal_get_configuration()->iova_mode = RTE_IOVA_PA;
789 RTE_LOG(WARNING, EAL,
790 "Some devices want IOVA as VA but PA will be used because.. "
791 "KNI module inserted\n");
794 if (internal_config.no_hugetlbfs == 0 &&
795 internal_config.process_type != RTE_PROC_SECONDARY &&
796 eal_hugepage_info_init() < 0) {
797 rte_eal_init_alert("Cannot get hugepage information.");
799 rte_atomic32_clear(&run_once);
803 if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
804 if (internal_config.no_hugetlbfs)
805 internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
808 if (internal_config.vmware_tsc_map == 1) {
809 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
810 rte_cycles_vmware_tsc_map = 1;
811 RTE_LOG (DEBUG, EAL, "Using VMWARE TSC MAP, "
812 "you must have monitor_control.pseudo_perfctr = TRUE\n");
814 RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
815 "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
819 rte_srand(rte_rdtsc());
823 if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
824 rte_eal_init_alert("Cannot init logging.");
826 rte_atomic32_clear(&run_once);
830 if (rte_mp_channel_init() < 0) {
831 rte_eal_init_alert("failed to init mp channel\n");
832 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
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 eal_thread_init_master(rte_config.master_lcore);
884 ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
886 RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%x;cpuset=[%s%s])\n",
887 rte_config.master_lcore, (int)thread_id, cpuset,
888 ret == 0 ? "" : "...");
890 if (rte_eal_intr_init() < 0) {
891 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
895 RTE_LCORE_FOREACH_SLAVE(i) {
898 * create communication pipes between master thread
901 if (pipe(lcore_config[i].pipe_master2slave) < 0)
902 rte_panic("Cannot create pipe\n");
903 if (pipe(lcore_config[i].pipe_slave2master) < 0)
904 rte_panic("Cannot create pipe\n");
906 lcore_config[i].state = WAIT;
908 /* create a thread for each lcore */
909 ret = pthread_create(&lcore_config[i].thread_id, NULL,
910 eal_thread_loop, NULL);
912 rte_panic("Cannot create thread\n");
914 /* Set thread_name for aid in debugging. */
915 snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
916 "lcore-slave-%d", i);
917 ret = rte_thread_setname(lcore_config[i].thread_id,
921 "Cannot set name for lcore thread\n");
925 * Launch a dummy function on all slave lcores, so that master lcore
926 * knows they are all ready when this function returns.
928 rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
929 rte_eal_mp_wait_lcore();
931 /* initialize services so vdevs register service during bus_probe. */
932 ret = rte_service_init();
934 rte_eal_init_alert("rte_service_init() failed\n");
939 /* Probe all the buses and devices/drivers on them */
940 if (rte_bus_probe()) {
941 rte_eal_init_alert("Cannot probe devices\n");
946 /* initialize default service/lcore mappings and start running. Ignore
947 * -ENOTSUP, as it indicates no service coremask passed to EAL.
949 ret = rte_service_start_with_defaults();
950 if (ret < 0 && ret != -ENOTSUP) {
955 rte_eal_mcfg_complete();
960 int __rte_experimental
961 rte_eal_cleanup(void)
963 rte_service_finalize();
968 enum rte_lcore_role_t
969 rte_eal_lcore_role(unsigned lcore_id)
971 return rte_config.lcore_role[lcore_id];
975 rte_eal_process_type(void)
977 return rte_config.process_type;
980 int rte_eal_has_hugepages(void)
982 return ! internal_config.no_hugetlbfs;
985 int rte_eal_has_pci(void)
987 return !internal_config.no_pci;
990 int rte_eal_create_uio_dev(void)
992 return internal_config.create_uio_dev;
996 rte_eal_vfio_intr_mode(void)
998 return internal_config.vfio_intr_mode;
1002 rte_eal_check_module(const char *module_name)
1004 char sysfs_mod_name[PATH_MAX];
1008 if (NULL == module_name)
1011 /* Check if there is sysfs mounted */
1012 if (stat("/sys/module", &st) != 0) {
1013 RTE_LOG(DEBUG, EAL, "sysfs is not mounted! error %i (%s)\n",
1014 errno, strerror(errno));
1018 /* A module might be built-in, therefore try sysfs */
1019 n = snprintf(sysfs_mod_name, PATH_MAX, "/sys/module/%s", module_name);
1020 if (n < 0 || n > PATH_MAX) {
1021 RTE_LOG(DEBUG, EAL, "Could not format module path\n");
1025 if (stat(sysfs_mod_name, &st) != 0) {
1026 RTE_LOG(DEBUG, EAL, "Module %s not found! error %i (%s)\n",
1027 sysfs_mod_name, errno, strerror(errno));
1031 /* Module has been found */