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.
51 #include <sys/queue.h>
53 #if defined(RTE_ARCH_X86)
57 #include <rte_common.h>
58 #include <rte_debug.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_launch.h>
63 #include <rte_eal_memconfig.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
67 #include <rte_random.h>
68 #include <rte_cycles.h>
69 #include <rte_string_fns.h>
70 #include <rte_cpuflags.h>
71 #include <rte_interrupts.h>
74 #include <rte_devargs.h>
75 #include <rte_common.h>
76 #include <rte_version.h>
77 #include <rte_atomic.h>
78 #include <malloc_heap.h>
80 #include "eal_private.h"
81 #include "eal_thread.h"
82 #include "eal_internal_cfg.h"
83 #include "eal_filesystem.h"
84 #include "eal_hugepages.h"
85 #include "eal_options.h"
88 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
90 #define SOCKET_MEM_STRLEN (RTE_MAX_NUMA_NODES * 10)
92 /* Allow the application to print its usage message too if set */
93 static rte_usage_hook_t rte_application_usage_hook = NULL;
95 /* early configuration structure, when memory config is not mmapped */
96 static struct rte_mem_config early_mem_config;
98 /* define fd variable here, because file needs to be kept open for the
99 * duration of the program, as we hold a write lock on it in the primary proc */
100 static int mem_cfg_fd = -1;
102 static struct flock wr_lock = {
104 .l_whence = SEEK_SET,
105 .l_start = offsetof(struct rte_mem_config, memseg),
106 .l_len = sizeof(early_mem_config.memseg),
109 /* Address of global and public configuration */
110 static struct rte_config rte_config = {
111 .mem_config = &early_mem_config,
114 /* internal configuration (per-core) */
115 struct lcore_config lcore_config[RTE_MAX_LCORE];
117 /* internal configuration */
118 struct internal_config internal_config;
120 /* used by rte_rdtsc() */
121 int rte_cycles_vmware_tsc_map;
123 /* Return a pointer to the configuration structure */
125 rte_eal_get_configuration(void)
130 /* parse a sysfs (or other) file containing one integer value */
132 eal_parse_sysfs_value(const char *filename, unsigned long *val)
138 if ((f = fopen(filename, "r")) == NULL) {
139 RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n",
144 if (fgets(buf, sizeof(buf), f) == NULL) {
145 RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n",
150 *val = strtoul(buf, &end, 0);
151 if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) {
152 RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n",
162 /* create memory configuration in shared/mmap memory. Take out
163 * a write lock on the memsegs, so we can auto-detect primary/secondary.
164 * This means we never close the file while running (auto-close on exit).
165 * We also don't lock the whole file, so that in future we can use read-locks
166 * on other parts, e.g. memzones, to detect if there are running secondary
169 rte_eal_config_create(void)
171 void *rte_mem_cfg_addr;
174 const char *pathname = eal_runtime_config_path();
176 if (internal_config.no_shconf)
179 /* map the config before hugepage address so that we don't waste a page */
180 if (internal_config.base_virtaddr != 0)
181 rte_mem_cfg_addr = (void *)
182 RTE_ALIGN_FLOOR(internal_config.base_virtaddr -
183 sizeof(struct rte_mem_config), sysconf(_SC_PAGE_SIZE));
185 rte_mem_cfg_addr = NULL;
188 mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
190 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
193 retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
196 rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
199 retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
202 rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
203 "process running?\n", pathname);
206 rte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),
207 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
209 if (rte_mem_cfg_addr == MAP_FAILED){
210 rte_panic("Cannot mmap memory for rte_config\n");
212 memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
213 rte_config.mem_config = (struct rte_mem_config *) rte_mem_cfg_addr;
215 /* store address of the config in the config itself so that secondary
216 * processes could later map the config into this exact location */
217 rte_config.mem_config->mem_cfg_addr = (uintptr_t) rte_mem_cfg_addr;
221 /* attach to an existing shared memory config */
223 rte_eal_config_attach(void)
225 struct rte_mem_config *mem_config;
227 const char *pathname = eal_runtime_config_path();
229 if (internal_config.no_shconf)
233 mem_cfg_fd = open(pathname, O_RDWR);
235 rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
238 /* map it as read-only first */
239 mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),
240 PROT_READ, MAP_SHARED, mem_cfg_fd, 0);
241 if (mem_config == MAP_FAILED)
242 rte_panic("Cannot mmap memory for rte_config\n");
244 rte_config.mem_config = mem_config;
247 /* reattach the shared config at exact memory location primary process has it */
249 rte_eal_config_reattach(void)
251 struct rte_mem_config *mem_config;
252 void *rte_mem_cfg_addr;
254 if (internal_config.no_shconf)
257 /* save the address primary process has mapped shared config to */
258 rte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;
260 /* unmap original config */
261 munmap(rte_config.mem_config, sizeof(struct rte_mem_config));
263 /* remap the config at proper address */
264 mem_config = (struct rte_mem_config *) mmap(rte_mem_cfg_addr,
265 sizeof(*mem_config), PROT_READ | PROT_WRITE, MAP_SHARED,
268 if (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr)
269 rte_panic("Cannot mmap memory for rte_config\n");
271 rte_config.mem_config = mem_config;
274 /* Detect if we are a primary or a secondary process */
276 eal_proc_type_detect(void)
278 enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
279 const char *pathname = eal_runtime_config_path();
281 /* if we can open the file but not get a write-lock we are a secondary
282 * process. NOTE: if we get a file handle back, we keep that open
283 * and don't close it to prevent a race condition between multiple opens */
284 if (((mem_cfg_fd = open(pathname, O_RDWR)) >= 0) &&
285 (fcntl(mem_cfg_fd, F_SETLK, &wr_lock) < 0))
286 ptype = RTE_PROC_SECONDARY;
288 RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
289 ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
294 /* Sets up rte_config structure with the pointer to shared memory config.*/
296 rte_config_init(void)
298 rte_config.process_type = internal_config.process_type;
300 switch (rte_config.process_type){
301 case RTE_PROC_PRIMARY:
302 rte_eal_config_create();
304 case RTE_PROC_SECONDARY:
305 rte_eal_config_attach();
306 rte_eal_mcfg_wait_complete(rte_config.mem_config);
307 rte_eal_config_reattach();
310 case RTE_PROC_INVALID:
311 rte_panic("Invalid process type\n");
315 /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */
317 eal_hugedirs_unlock(void)
321 for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
323 /* skip uninitialized */
324 if (internal_config.hugepage_info[i].lock_descriptor < 0)
326 /* unlock hugepage file */
327 flock(internal_config.hugepage_info[i].lock_descriptor, LOCK_UN);
328 close(internal_config.hugepage_info[i].lock_descriptor);
329 /* reset the field */
330 internal_config.hugepage_info[i].lock_descriptor = -1;
336 eal_usage(const char *prgname)
338 printf("\nUsage: %s ", prgname);
340 printf("EAL Linux options:\n"
341 " --"OPT_SOCKET_MEM" Memory to allocate on sockets (comma separated values)\n"
342 " --"OPT_HUGE_DIR" Directory where hugetlbfs is mounted\n"
343 " --"OPT_FILE_PREFIX" Prefix for hugepage filenames\n"
344 " --"OPT_BASE_VIRTADDR" Base virtual address\n"
345 " --"OPT_CREATE_UIO_DEV" Create /dev/uioX (usually done by hotplug)\n"
346 " --"OPT_VFIO_INTR" Interrupt mode for VFIO (legacy|msi|msix)\n"
347 " --"OPT_XEN_DOM0" Support running on Xen dom0 without hugetlbfs\n"
349 /* Allow the application to print its usage message too if hook is set */
350 if ( rte_application_usage_hook ) {
351 printf("===== Application Usage =====\n\n");
352 rte_application_usage_hook(prgname);
356 /* Set a per-application usage message */
358 rte_set_application_usage_hook( rte_usage_hook_t usage_func )
360 rte_usage_hook_t old_func;
362 /* Will be NULL on the first call to denote the last usage routine. */
363 old_func = rte_application_usage_hook;
364 rte_application_usage_hook = usage_func;
370 eal_parse_socket_mem(char *socket_mem)
372 char * arg[RTE_MAX_NUMA_NODES];
375 uint64_t total_mem = 0;
377 len = strnlen(socket_mem, SOCKET_MEM_STRLEN);
378 if (len == SOCKET_MEM_STRLEN) {
379 RTE_LOG(ERR, EAL, "--socket-mem is too long\n");
383 /* all other error cases will be caught later */
384 if (!isdigit(socket_mem[len-1]))
387 /* split the optarg into separate socket values */
388 arg_num = rte_strsplit(socket_mem, len,
389 arg, RTE_MAX_NUMA_NODES, ',');
391 /* if split failed, or 0 arguments */
395 internal_config.force_sockets = 1;
397 /* parse each defined socket option */
399 for (i = 0; i < arg_num; i++) {
401 internal_config.socket_mem[i] = strtoull(arg[i], &end, 10);
403 /* check for invalid input */
405 (arg[i][0] == '\0') || (end == NULL) || (*end != '\0'))
407 internal_config.socket_mem[i] *= 1024ULL;
408 internal_config.socket_mem[i] *= 1024ULL;
409 total_mem += internal_config.socket_mem[i];
412 /* check if we have a positive amount of total memory */
420 eal_parse_base_virtaddr(const char *arg)
426 addr = strtoull(arg, &end, 16);
428 /* check for errors */
429 if ((errno != 0) || (arg[0] == '\0') || end == NULL || (*end != '\0'))
432 /* make sure we don't exceed 32-bit boundary on 32-bit target */
434 if (addr >= UINTPTR_MAX)
438 /* align the addr on 16M boundary, 16MB is the minimum huge page
439 * size on IBM Power architecture. If the addr is aligned to 16MB,
440 * it can align to 2MB for x86. So this alignment can also be used
442 internal_config.base_virtaddr =
443 RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M);
449 eal_parse_vfio_intr(const char *mode)
454 enum rte_intr_mode value;
456 { "legacy", RTE_INTR_MODE_LEGACY },
457 { "msi", RTE_INTR_MODE_MSI },
458 { "msix", RTE_INTR_MODE_MSIX },
461 for (i = 0; i < RTE_DIM(map); i++) {
462 if (!strcmp(mode, map[i].name)) {
463 internal_config.vfio_intr_mode = map[i].value;
470 /* Parse the arguments for --log-level only */
472 eal_log_level_parse(int argc, char **argv)
477 const int old_optind = optind;
478 const int old_optopt = optopt;
479 char * const old_optarg = optarg;
484 eal_reset_internal_config(&internal_config);
486 while ((opt = getopt_long(argc, argvopt, eal_short_options,
487 eal_long_options, &option_index)) != EOF) {
491 /* getopt is not happy, stop right now */
495 ret = (opt == OPT_LOG_LEVEL_NUM) ?
496 eal_parse_common_option(opt, optarg, &internal_config) : 0;
498 /* common parser is not happy */
503 /* restore getopt lib */
509 /* Parse the argument given in the command line of the application */
511 eal_parse_args(int argc, char **argv)
516 char *prgname = argv[0];
517 const int old_optind = optind;
518 const int old_optopt = optopt;
519 char * const old_optarg = optarg;
524 while ((opt = getopt_long(argc, argvopt, eal_short_options,
525 eal_long_options, &option_index)) != EOF) {
527 /* getopt is not happy, stop right now */
534 ret = eal_parse_common_option(opt, optarg, &internal_config);
535 /* common parser is not happy */
541 /* common parser handled this option */
551 case OPT_XEN_DOM0_NUM:
552 #ifdef RTE_LIBRTE_XEN_DOM0
553 internal_config.xen_dom0_support = 1;
555 RTE_LOG(ERR, EAL, "Can't support DPDK app "
556 "running on Dom0, please configure"
557 " RTE_LIBRTE_XEN_DOM0=y\n");
563 case OPT_HUGE_DIR_NUM:
564 internal_config.hugepage_dir = optarg;
567 case OPT_FILE_PREFIX_NUM:
568 internal_config.hugefile_prefix = optarg;
571 case OPT_SOCKET_MEM_NUM:
572 if (eal_parse_socket_mem(optarg) < 0) {
573 RTE_LOG(ERR, EAL, "invalid parameters for --"
574 OPT_SOCKET_MEM "\n");
581 case OPT_BASE_VIRTADDR_NUM:
582 if (eal_parse_base_virtaddr(optarg) < 0) {
583 RTE_LOG(ERR, EAL, "invalid parameter for --"
584 OPT_BASE_VIRTADDR "\n");
591 case OPT_VFIO_INTR_NUM:
592 if (eal_parse_vfio_intr(optarg) < 0) {
593 RTE_LOG(ERR, EAL, "invalid parameters for --"
601 case OPT_CREATE_UIO_DEV_NUM:
602 internal_config.create_uio_dev = 1;
606 if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
607 RTE_LOG(ERR, EAL, "Option %c is not supported "
609 } else if (opt >= OPT_LONG_MIN_NUM &&
610 opt < OPT_LONG_MAX_NUM) {
611 RTE_LOG(ERR, EAL, "Option %s is not supported "
613 eal_long_options[option_index].name);
615 RTE_LOG(ERR, EAL, "Option %d is not supported "
624 if (eal_adjust_config(&internal_config) != 0) {
630 if (eal_check_common_options(&internal_config) != 0) {
636 /* --xen-dom0 doesn't make sense with --socket-mem */
637 if (internal_config.xen_dom0_support && internal_config.force_sockets == 1) {
638 RTE_LOG(ERR, EAL, "Options --"OPT_SOCKET_MEM" cannot be specified "
639 "together with --"OPT_XEN_DOM0"\n");
646 argv[optind-1] = prgname;
650 /* restore getopt lib */
659 eal_check_mem_on_local_socket(void)
661 const struct rte_memseg *ms;
664 socket_id = rte_lcore_to_socket_id(rte_config.master_lcore);
666 ms = rte_eal_get_physmem_layout();
668 for (i = 0; i < RTE_MAX_MEMSEG; i++)
669 if (ms[i].socket_id == socket_id &&
673 RTE_LOG(WARNING, EAL, "WARNING: Master core has no "
674 "memory on local socket!\n");
678 sync_func(__attribute__((unused)) void *arg)
684 rte_eal_mcfg_complete(void)
686 /* ALL shared mem_config related INIT DONE */
687 if (rte_config.process_type == RTE_PROC_PRIMARY)
688 rte_config.mem_config->magic = RTE_MAGIC;
692 * Request iopl privilege for all RPL, returns 0 on success
693 * iopl() call is mostly for the i386 architecture. For other architectures,
694 * return -1 to indicate IO privilege can't be changed in this way.
697 rte_eal_iopl_init(void)
699 #if defined(RTE_ARCH_X86)
707 static int rte_eal_vfio_setup(void)
709 int vfio_enabled = 0;
711 if (!internal_config.no_pci) {
713 vfio_enabled |= pci_vfio_is_enabled();
718 /* if we are primary process, create a thread to communicate with
719 * secondary processes. the thread will use a socket to wait for
720 * requests from secondary process to send open file descriptors,
721 * because VFIO does not allow multiple open descriptors on a group or
724 if (internal_config.process_type == RTE_PROC_PRIMARY &&
725 vfio_mp_sync_setup() < 0)
733 /* Launch threads, called at application init(). */
735 rte_eal_init(int argc, char **argv)
739 static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
741 char cpuset[RTE_CPU_AFFINITY_STR_LEN];
742 char thread_name[RTE_MAX_THREAD_NAME_LEN];
744 /* checks if the machine is adequate */
745 rte_cpu_check_supported();
747 if (!rte_atomic32_test_and_set(&run_once))
750 logid = strrchr(argv[0], '/');
751 logid = strdup(logid ? logid + 1: argv[0]);
753 thread_id = pthread_self();
755 if (rte_eal_log_early_init() < 0)
756 rte_panic("Cannot init early logs\n");
758 eal_log_level_parse(argc, argv);
760 /* set log level as early as possible */
761 rte_set_log_level(internal_config.log_level);
763 if (rte_eal_cpu_init() < 0)
764 rte_panic("Cannot detect lcores\n");
766 fctret = eal_parse_args(argc, argv);
770 if (internal_config.no_hugetlbfs == 0 &&
771 internal_config.process_type != RTE_PROC_SECONDARY &&
772 internal_config.xen_dom0_support == 0 &&
773 eal_hugepage_info_init() < 0)
774 rte_panic("Cannot get hugepage information\n");
776 if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
777 if (internal_config.no_hugetlbfs)
778 internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
781 if (internal_config.vmware_tsc_map == 1) {
782 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
783 rte_cycles_vmware_tsc_map = 1;
784 RTE_LOG (DEBUG, EAL, "Using VMWARE TSC MAP, "
785 "you must have monitor_control.pseudo_perfctr = TRUE\n");
787 RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
788 "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
792 rte_srand(rte_rdtsc());
796 if (rte_eal_pci_init() < 0)
797 rte_panic("Cannot init PCI\n");
800 if (rte_eal_vfio_setup() < 0)
801 rte_panic("Cannot init VFIO\n");
804 if (rte_eal_memory_init() < 0)
805 rte_panic("Cannot init memory\n");
807 /* the directories are locked during eal_hugepage_info_init */
808 eal_hugedirs_unlock();
810 if (rte_eal_memzone_init() < 0)
811 rte_panic("Cannot init memzone\n");
813 if (rte_eal_tailqs_init() < 0)
814 rte_panic("Cannot init tail queues for objects\n");
816 if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)
817 rte_panic("Cannot init logs\n");
819 if (rte_eal_alarm_init() < 0)
820 rte_panic("Cannot init interrupt-handling thread\n");
822 if (rte_eal_timer_init() < 0)
823 rte_panic("Cannot init HPET or TSC timers\n");
825 eal_check_mem_on_local_socket();
827 if (eal_plugins_init() < 0)
828 rte_panic("Cannot init plugins\n");
830 eal_thread_init_master(rte_config.master_lcore);
832 ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
834 RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%x;cpuset=[%s%s])\n",
835 rte_config.master_lcore, (int)thread_id, cpuset,
836 ret == 0 ? "" : "...");
838 if (rte_eal_dev_init() < 0)
839 rte_panic("Cannot init pmd devices\n");
841 if (rte_eal_intr_init() < 0)
842 rte_panic("Cannot init interrupt-handling thread\n");
844 RTE_LCORE_FOREACH_SLAVE(i) {
847 * create communication pipes between master thread
850 if (pipe(lcore_config[i].pipe_master2slave) < 0)
851 rte_panic("Cannot create pipe\n");
852 if (pipe(lcore_config[i].pipe_slave2master) < 0)
853 rte_panic("Cannot create pipe\n");
855 lcore_config[i].state = WAIT;
857 /* create a thread for each lcore */
858 ret = pthread_create(&lcore_config[i].thread_id, NULL,
859 eal_thread_loop, NULL);
861 rte_panic("Cannot create thread\n");
863 /* Set thread_name for aid in debugging. */
864 snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
865 "lcore-slave-%d", i);
866 ret = rte_thread_setname(lcore_config[i].thread_id,
870 "Cannot set name for lcore thread\n");
874 * Launch a dummy function on all slave lcores, so that master lcore
875 * knows they are all ready when this function returns.
877 rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
878 rte_eal_mp_wait_lcore();
880 /* Probe & Initialize PCI devices */
881 if (rte_eal_pci_probe())
882 rte_panic("Cannot probe PCI\n");
884 rte_eal_mcfg_complete();
890 enum rte_lcore_role_t
891 rte_eal_lcore_role(unsigned lcore_id)
893 return rte_config.lcore_role[lcore_id];
897 rte_eal_process_type(void)
899 return rte_config.process_type;
902 int rte_eal_has_hugepages(void)
904 return ! internal_config.no_hugetlbfs;
908 rte_eal_check_module(const char *module_name)
910 char sysfs_mod_name[PATH_MAX];
914 if (NULL == module_name)
917 /* Check if there is sysfs mounted */
918 if (stat("/sys/module", &st) != 0) {
919 RTE_LOG(DEBUG, EAL, "sysfs is not mounted! error %i (%s)\n",
920 errno, strerror(errno));
924 /* A module might be built-in, therefore try sysfs */
925 n = snprintf(sysfs_mod_name, PATH_MAX, "/sys/module/%s", module_name);
926 if (n < 0 || n > PATH_MAX) {
927 RTE_LOG(DEBUG, EAL, "Could not format module path\n");
931 if (stat(sysfs_mod_name, &st) != 0) {
932 RTE_LOG(DEBUG, EAL, "Module %s not found! error %i (%s)\n",
933 sysfs_mod_name, errno, strerror(errno));
937 /* Module has been found */