use sizeof to avoid double use of a length define
[dpdk.git] / lib / librte_eal / bsdapp / eal / eal.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2018 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <stdint.h>
9 #include <string.h>
10 #include <stdarg.h>
11 #include <unistd.h>
12 #include <pthread.h>
13 #include <syslog.h>
14 #include <getopt.h>
15 #include <sys/file.h>
16 #include <stddef.h>
17 #include <errno.h>
18 #include <limits.h>
19 #include <sys/mman.h>
20 #include <sys/queue.h>
21
22 #include <rte_compat.h>
23 #include <rte_common.h>
24 #include <rte_debug.h>
25 #include <rte_memory.h>
26 #include <rte_launch.h>
27 #include <rte_eal.h>
28 #include <rte_eal_memconfig.h>
29 #include <rte_errno.h>
30 #include <rte_per_lcore.h>
31 #include <rte_lcore.h>
32 #include <rte_service_component.h>
33 #include <rte_log.h>
34 #include <rte_random.h>
35 #include <rte_cycles.h>
36 #include <rte_string_fns.h>
37 #include <rte_cpuflags.h>
38 #include <rte_interrupts.h>
39 #include <rte_bus.h>
40 #include <rte_dev.h>
41 #include <rte_devargs.h>
42 #include <rte_version.h>
43 #include <rte_vfio.h>
44 #include <rte_atomic.h>
45 #include <malloc_heap.h>
46
47 #include "eal_private.h"
48 #include "eal_thread.h"
49 #include "eal_internal_cfg.h"
50 #include "eal_filesystem.h"
51 #include "eal_hugepages.h"
52 #include "eal_options.h"
53
54 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
55
56 /* Allow the application to print its usage message too if set */
57 static rte_usage_hook_t rte_application_usage_hook = NULL;
58 /* early configuration structure, when memory config is not mmapped */
59 static struct rte_mem_config early_mem_config;
60
61 /* define fd variable here, because file needs to be kept open for the
62  * duration of the program, as we hold a write lock on it in the primary proc */
63 static int mem_cfg_fd = -1;
64
65 static struct flock wr_lock = {
66                 .l_type = F_WRLCK,
67                 .l_whence = SEEK_SET,
68                 .l_start = offsetof(struct rte_mem_config, memsegs),
69                 .l_len = sizeof(early_mem_config.memsegs),
70 };
71
72 /* Address of global and public configuration */
73 static struct rte_config rte_config = {
74                 .mem_config = &early_mem_config,
75 };
76
77 /* internal configuration (per-core) */
78 struct lcore_config lcore_config[RTE_MAX_LCORE];
79
80 /* internal configuration */
81 struct internal_config internal_config;
82
83 /* used by rte_rdtsc() */
84 int rte_cycles_vmware_tsc_map;
85
86 /* Return user provided mbuf pool ops name */
87 const char * __rte_experimental
88 rte_eal_mbuf_user_pool_ops(void)
89 {
90         return internal_config.user_mbuf_pool_ops_name;
91 }
92
93 /* Return mbuf pool ops name */
94 const char *
95 rte_eal_mbuf_default_mempool_ops(void)
96 {
97         if (internal_config.user_mbuf_pool_ops_name == NULL)
98                 return RTE_MBUF_DEFAULT_MEMPOOL_OPS;
99
100         return internal_config.user_mbuf_pool_ops_name;
101 }
102
103 /* Return a pointer to the configuration structure */
104 struct rte_config *
105 rte_eal_get_configuration(void)
106 {
107         return &rte_config;
108 }
109
110 enum rte_iova_mode
111 rte_eal_iova_mode(void)
112 {
113         return rte_eal_get_configuration()->iova_mode;
114 }
115
116 /* parse a sysfs (or other) file containing one integer value */
117 int
118 eal_parse_sysfs_value(const char *filename, unsigned long *val)
119 {
120         FILE *f;
121         char buf[BUFSIZ];
122         char *end = NULL;
123
124         if ((f = fopen(filename, "r")) == NULL) {
125                 RTE_LOG(ERR, EAL, "%s(): cannot open sysfs value %s\n",
126                         __func__, filename);
127                 return -1;
128         }
129
130         if (fgets(buf, sizeof(buf), f) == NULL) {
131                 RTE_LOG(ERR, EAL, "%s(): cannot read sysfs value %s\n",
132                         __func__, filename);
133                 fclose(f);
134                 return -1;
135         }
136         *val = strtoul(buf, &end, 0);
137         if ((buf[0] == '\0') || (end == NULL) || (*end != '\n')) {
138                 RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs value %s\n",
139                                 __func__, filename);
140                 fclose(f);
141                 return -1;
142         }
143         fclose(f);
144         return 0;
145 }
146
147
148 /* create memory configuration in shared/mmap memory. Take out
149  * a write lock on the memsegs, so we can auto-detect primary/secondary.
150  * This means we never close the file while running (auto-close on exit).
151  * We also don't lock the whole file, so that in future we can use read-locks
152  * on other parts, e.g. memzones, to detect if there are running secondary
153  * processes. */
154 static void
155 rte_eal_config_create(void)
156 {
157         void *rte_mem_cfg_addr;
158         int retval;
159
160         const char *pathname = eal_runtime_config_path();
161
162         if (internal_config.no_shconf)
163                 return;
164
165         if (mem_cfg_fd < 0){
166                 mem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);
167                 if (mem_cfg_fd < 0)
168                         rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
169         }
170
171         retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
172         if (retval < 0){
173                 close(mem_cfg_fd);
174                 rte_panic("Cannot resize '%s' for rte_mem_config\n", pathname);
175         }
176
177         retval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);
178         if (retval < 0){
179                 close(mem_cfg_fd);
180                 rte_exit(EXIT_FAILURE, "Cannot create lock on '%s'. Is another primary "
181                                 "process running?\n", pathname);
182         }
183
184         rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
185                                 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
186
187         if (rte_mem_cfg_addr == MAP_FAILED){
188                 rte_panic("Cannot mmap memory for rte_config\n");
189         }
190         memcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));
191         rte_config.mem_config = rte_mem_cfg_addr;
192 }
193
194 /* attach to an existing shared memory config */
195 static void
196 rte_eal_config_attach(void)
197 {
198         void *rte_mem_cfg_addr;
199         const char *pathname = eal_runtime_config_path();
200
201         if (internal_config.no_shconf)
202                 return;
203
204         if (mem_cfg_fd < 0){
205                 mem_cfg_fd = open(pathname, O_RDWR);
206                 if (mem_cfg_fd < 0)
207                         rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
208         }
209
210         rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
211                                 PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
212         close(mem_cfg_fd);
213         if (rte_mem_cfg_addr == MAP_FAILED)
214                 rte_panic("Cannot mmap memory for rte_config\n");
215
216         rte_config.mem_config = rte_mem_cfg_addr;
217 }
218
219 /* Detect if we are a primary or a secondary process */
220 enum rte_proc_type_t
221 eal_proc_type_detect(void)
222 {
223         enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
224         const char *pathname = eal_runtime_config_path();
225
226         /* if we can open the file but not get a write-lock we are a secondary
227          * process. NOTE: if we get a file handle back, we keep that open
228          * and don't close it to prevent a race condition between multiple opens */
229         if (((mem_cfg_fd = open(pathname, O_RDWR)) >= 0) &&
230                         (fcntl(mem_cfg_fd, F_SETLK, &wr_lock) < 0))
231                 ptype = RTE_PROC_SECONDARY;
232
233         RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
234                         ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
235
236         return ptype;
237 }
238
239 /* Sets up rte_config structure with the pointer to shared memory config.*/
240 static void
241 rte_config_init(void)
242 {
243         rte_config.process_type = internal_config.process_type;
244
245         switch (rte_config.process_type){
246         case RTE_PROC_PRIMARY:
247                 rte_eal_config_create();
248                 break;
249         case RTE_PROC_SECONDARY:
250                 rte_eal_config_attach();
251                 rte_eal_mcfg_wait_complete(rte_config.mem_config);
252                 break;
253         case RTE_PROC_AUTO:
254         case RTE_PROC_INVALID:
255                 rte_panic("Invalid process type\n");
256         }
257 }
258
259 /* display usage */
260 static void
261 eal_usage(const char *prgname)
262 {
263         printf("\nUsage: %s ", prgname);
264         eal_common_usage();
265         /* Allow the application to print its usage message too if hook is set */
266         if ( rte_application_usage_hook ) {
267                 printf("===== Application Usage =====\n\n");
268                 rte_application_usage_hook(prgname);
269         }
270 }
271
272 /* Set a per-application usage message */
273 rte_usage_hook_t
274 rte_set_application_usage_hook( rte_usage_hook_t usage_func )
275 {
276         rte_usage_hook_t        old_func;
277
278         /* Will be NULL on the first call to denote the last usage routine. */
279         old_func                                        = rte_application_usage_hook;
280         rte_application_usage_hook      = usage_func;
281
282         return old_func;
283 }
284
285 static inline size_t
286 eal_get_hugepage_mem_size(void)
287 {
288         uint64_t size = 0;
289         unsigned i, j;
290
291         for (i = 0; i < internal_config.num_hugepage_sizes; i++) {
292                 struct hugepage_info *hpi = &internal_config.hugepage_info[i];
293                 if (strnlen(hpi->hugedir, sizeof(hpi->hugedir)) != 0) {
294                         for (j = 0; j < RTE_MAX_NUMA_NODES; j++) {
295                                 size += hpi->hugepage_sz * hpi->num_pages[j];
296                         }
297                 }
298         }
299
300         return (size < SIZE_MAX) ? (size_t)(size) : SIZE_MAX;
301 }
302
303 /* Parse the arguments for --log-level only */
304 static void
305 eal_log_level_parse(int argc, char **argv)
306 {
307         int opt;
308         char **argvopt;
309         int option_index;
310         const int old_optind = optind;
311         const int old_optopt = optopt;
312         const int old_optreset = optreset;
313         char * const old_optarg = optarg;
314
315         argvopt = argv;
316         optind = 1;
317         optreset = 1;
318
319         while ((opt = getopt_long(argc, argvopt, eal_short_options,
320                                   eal_long_options, &option_index)) != EOF) {
321
322                 int ret;
323
324                 /* getopt is not happy, stop right now */
325                 if (opt == '?')
326                         break;
327
328                 ret = (opt == OPT_LOG_LEVEL_NUM) ?
329                         eal_parse_common_option(opt, optarg, &internal_config) : 0;
330
331                 /* common parser is not happy */
332                 if (ret < 0)
333                         break;
334         }
335
336         /* restore getopt lib */
337         optind = old_optind;
338         optopt = old_optopt;
339         optreset = old_optreset;
340         optarg = old_optarg;
341 }
342
343 /* Parse the argument given in the command line of the application */
344 static int
345 eal_parse_args(int argc, char **argv)
346 {
347         int opt, ret;
348         char **argvopt;
349         int option_index;
350         char *prgname = argv[0];
351         const int old_optind = optind;
352         const int old_optopt = optopt;
353         const int old_optreset = optreset;
354         char * const old_optarg = optarg;
355
356         argvopt = argv;
357         optind = 1;
358         optreset = 1;
359
360         while ((opt = getopt_long(argc, argvopt, eal_short_options,
361                                   eal_long_options, &option_index)) != EOF) {
362
363                 /* getopt is not happy, stop right now */
364                 if (opt == '?') {
365                         eal_usage(prgname);
366                         ret = -1;
367                         goto out;
368                 }
369
370                 ret = eal_parse_common_option(opt, optarg, &internal_config);
371                 /* common parser is not happy */
372                 if (ret < 0) {
373                         eal_usage(prgname);
374                         ret = -1;
375                         goto out;
376                 }
377                 /* common parser handled this option */
378                 if (ret == 0)
379                         continue;
380
381                 switch (opt) {
382                 case OPT_MBUF_POOL_OPS_NAME_NUM:
383                         internal_config.user_mbuf_pool_ops_name = optarg;
384                         break;
385                 case 'h':
386                         eal_usage(prgname);
387                         exit(EXIT_SUCCESS);
388                 default:
389                         if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
390                                 RTE_LOG(ERR, EAL, "Option %c is not supported "
391                                         "on FreeBSD\n", opt);
392                         } else if (opt >= OPT_LONG_MIN_NUM &&
393                                    opt < OPT_LONG_MAX_NUM) {
394                                 RTE_LOG(ERR, EAL, "Option %s is not supported "
395                                         "on FreeBSD\n",
396                                         eal_long_options[option_index].name);
397                         } else {
398                                 RTE_LOG(ERR, EAL, "Option %d is not supported "
399                                         "on FreeBSD\n", opt);
400                         }
401                         eal_usage(prgname);
402                         ret = -1;
403                         goto out;
404                 }
405         }
406
407         if (eal_adjust_config(&internal_config) != 0) {
408                 ret = -1;
409                 goto out;
410         }
411
412         /* sanity checks */
413         if (eal_check_common_options(&internal_config) != 0) {
414                 eal_usage(prgname);
415                 ret = -1;
416                 goto out;
417         }
418
419         if (optind >= 0)
420                 argv[optind-1] = prgname;
421         ret = optind-1;
422
423 out:
424         /* restore getopt lib */
425         optind = old_optind;
426         optopt = old_optopt;
427         optreset = old_optreset;
428         optarg = old_optarg;
429
430         return ret;
431 }
432
433 static int
434 check_socket(const struct rte_memseg_list *msl, void *arg)
435 {
436         int *socket_id = arg;
437
438         if (msl->socket_id == *socket_id && msl->memseg_arr.count != 0)
439                 return 1;
440
441         return 0;
442 }
443
444 static void
445 eal_check_mem_on_local_socket(void)
446 {
447         int socket_id;
448
449         socket_id = rte_lcore_to_socket_id(rte_config.master_lcore);
450
451         if (rte_memseg_list_walk(check_socket, &socket_id) == 0)
452                 RTE_LOG(WARNING, EAL, "WARNING: Master core has no memory on local socket!\n");
453 }
454
455
456 static int
457 sync_func(__attribute__((unused)) void *arg)
458 {
459         return 0;
460 }
461
462 inline static void
463 rte_eal_mcfg_complete(void)
464 {
465         /* ALL shared mem_config related INIT DONE */
466         if (rte_config.process_type == RTE_PROC_PRIMARY)
467                 rte_config.mem_config->magic = RTE_MAGIC;
468 }
469
470 /* return non-zero if hugepages are enabled. */
471 int rte_eal_has_hugepages(void)
472 {
473         return !internal_config.no_hugetlbfs;
474 }
475
476 /* Abstraction for port I/0 privilege */
477 int
478 rte_eal_iopl_init(void)
479 {
480         static int fd;
481
482         fd = open("/dev/io", O_RDWR);
483         if (fd < 0)
484                 return -1;
485         /* keep fd open for iopl */
486         return 0;
487 }
488
489 static void rte_eal_init_alert(const char *msg)
490 {
491         fprintf(stderr, "EAL: FATAL: %s\n", msg);
492         RTE_LOG(ERR, EAL, "%s\n", msg);
493 }
494
495 /* Launch threads, called at application init(). */
496 int
497 rte_eal_init(int argc, char **argv)
498 {
499         int i, fctret, ret;
500         pthread_t thread_id;
501         static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
502         char cpuset[RTE_CPU_AFFINITY_STR_LEN];
503         char thread_name[RTE_MAX_THREAD_NAME_LEN];
504
505         /* checks if the machine is adequate */
506         if (!rte_cpu_is_supported()) {
507                 rte_eal_init_alert("unsupported cpu type.");
508                 rte_errno = ENOTSUP;
509                 return -1;
510         }
511
512         if (!rte_atomic32_test_and_set(&run_once)) {
513                 rte_eal_init_alert("already called initialization.");
514                 rte_errno = EALREADY;
515                 return -1;
516         }
517
518         thread_id = pthread_self();
519
520         eal_reset_internal_config(&internal_config);
521
522         /* set log level as early as possible */
523         eal_log_level_parse(argc, argv);
524
525         if (rte_eal_cpu_init() < 0) {
526                 rte_eal_init_alert("Cannot detect lcores.");
527                 rte_errno = ENOTSUP;
528                 return -1;
529         }
530
531         fctret = eal_parse_args(argc, argv);
532         if (fctret < 0) {
533                 rte_eal_init_alert("Invalid 'command line' arguments.");
534                 rte_errno = EINVAL;
535                 rte_atomic32_clear(&run_once);
536                 return -1;
537         }
538
539         /* FreeBSD always uses legacy memory model */
540         internal_config.legacy_mem = true;
541
542         if (eal_plugins_init() < 0) {
543                 rte_eal_init_alert("Cannot init plugins\n");
544                 rte_errno = EINVAL;
545                 rte_atomic32_clear(&run_once);
546                 return -1;
547         }
548
549         if (eal_option_device_parse()) {
550                 rte_errno = ENODEV;
551                 rte_atomic32_clear(&run_once);
552                 return -1;
553         }
554
555         rte_config_init();
556
557         /* Put mp channel init before bus scan so that we can init the vdev
558          * bus through mp channel in the secondary process before the bus scan.
559          */
560         if (rte_mp_channel_init() < 0) {
561                 rte_eal_init_alert("failed to init mp channel\n");
562                 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
563                         rte_errno = EFAULT;
564                         return -1;
565                 }
566         }
567
568         if (rte_bus_scan()) {
569                 rte_eal_init_alert("Cannot scan the buses for devices\n");
570                 rte_errno = ENODEV;
571                 rte_atomic32_clear(&run_once);
572                 return -1;
573         }
574
575         /* autodetect the iova mapping mode (default is iova_pa) */
576         rte_eal_get_configuration()->iova_mode = rte_bus_get_iommu_class();
577
578         if (internal_config.no_hugetlbfs == 0) {
579                 /* rte_config isn't initialized yet */
580                 ret = internal_config.process_type == RTE_PROC_PRIMARY ?
581                         eal_hugepage_info_init() :
582                         eal_hugepage_info_read();
583                 if (ret < 0) {
584                         rte_eal_init_alert("Cannot get hugepage information.");
585                         rte_errno = EACCES;
586                         rte_atomic32_clear(&run_once);
587                         return -1;
588                 }
589         }
590
591         if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
592                 if (internal_config.no_hugetlbfs)
593                         internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
594                 else
595                         internal_config.memory = eal_get_hugepage_mem_size();
596         }
597
598         if (internal_config.vmware_tsc_map == 1) {
599 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
600                 rte_cycles_vmware_tsc_map = 1;
601                 RTE_LOG (DEBUG, EAL, "Using VMWARE TSC MAP, "
602                                 "you must have monitor_control.pseudo_perfctr = TRUE\n");
603 #else
604                 RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
605                                 "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
606 #endif
607         }
608
609         rte_srand(rte_rdtsc());
610
611         /* in secondary processes, memory init may allocate additional fbarrays
612          * not present in primary processes, so to avoid any potential issues,
613          * initialize memzones first.
614          */
615         if (rte_eal_memzone_init() < 0) {
616                 rte_eal_init_alert("Cannot init memzone\n");
617                 rte_errno = ENODEV;
618                 return -1;
619         }
620
621         if (rte_eal_memory_init() < 0) {
622                 rte_eal_init_alert("Cannot init memory\n");
623                 rte_errno = ENOMEM;
624                 return -1;
625         }
626
627         if (rte_eal_malloc_heap_init() < 0) {
628                 rte_eal_init_alert("Cannot init malloc heap\n");
629                 rte_errno = ENODEV;
630                 return -1;
631         }
632
633         if (rte_eal_tailqs_init() < 0) {
634                 rte_eal_init_alert("Cannot init tail queues for objects\n");
635                 rte_errno = EFAULT;
636                 return -1;
637         }
638
639         if (rte_eal_alarm_init() < 0) {
640                 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
641                 /* rte_eal_alarm_init sets rte_errno on failure. */
642                 return -1;
643         }
644
645         if (rte_eal_intr_init() < 0) {
646                 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
647                 return -1;
648         }
649
650         if (rte_eal_timer_init() < 0) {
651                 rte_eal_init_alert("Cannot init HPET or TSC timers\n");
652                 rte_errno = ENOTSUP;
653                 return -1;
654         }
655
656         eal_check_mem_on_local_socket();
657
658         eal_thread_init_master(rte_config.master_lcore);
659
660         ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
661
662         RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
663                 rte_config.master_lcore, thread_id, cpuset,
664                 ret == 0 ? "" : "...");
665
666         RTE_LCORE_FOREACH_SLAVE(i) {
667
668                 /*
669                  * create communication pipes between master thread
670                  * and children
671                  */
672                 if (pipe(lcore_config[i].pipe_master2slave) < 0)
673                         rte_panic("Cannot create pipe\n");
674                 if (pipe(lcore_config[i].pipe_slave2master) < 0)
675                         rte_panic("Cannot create pipe\n");
676
677                 lcore_config[i].state = WAIT;
678
679                 /* create a thread for each lcore */
680                 ret = pthread_create(&lcore_config[i].thread_id, NULL,
681                                      eal_thread_loop, NULL);
682                 if (ret != 0)
683                         rte_panic("Cannot create thread\n");
684
685                 /* Set thread_name for aid in debugging. */
686                 snprintf(thread_name, sizeof(thread_name),
687                                 "lcore-slave-%d", i);
688                 rte_thread_setname(lcore_config[i].thread_id, thread_name);
689         }
690
691         /*
692          * Launch a dummy function on all slave lcores, so that master lcore
693          * knows they are all ready when this function returns.
694          */
695         rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
696         rte_eal_mp_wait_lcore();
697
698         /* initialize services so vdevs register service during bus_probe. */
699         ret = rte_service_init();
700         if (ret) {
701                 rte_eal_init_alert("rte_service_init() failed\n");
702                 rte_errno = ENOEXEC;
703                 return -1;
704         }
705
706         /* Probe all the buses and devices/drivers on them */
707         if (rte_bus_probe()) {
708                 rte_eal_init_alert("Cannot probe devices\n");
709                 rte_errno = ENOTSUP;
710                 return -1;
711         }
712
713         /* initialize default service/lcore mappings and start running. Ignore
714          * -ENOTSUP, as it indicates no service coremask passed to EAL.
715          */
716         ret = rte_service_start_with_defaults();
717         if (ret < 0 && ret != -ENOTSUP) {
718                 rte_errno = ENOEXEC;
719                 return -1;
720         }
721
722         rte_eal_mcfg_complete();
723
724         return fctret;
725 }
726
727 int __rte_experimental
728 rte_eal_cleanup(void)
729 {
730         rte_service_finalize();
731         return 0;
732 }
733
734 /* get core role */
735 enum rte_lcore_role_t
736 rte_eal_lcore_role(unsigned lcore_id)
737 {
738         return rte_config.lcore_role[lcore_id];
739 }
740
741 enum rte_proc_type_t
742 rte_eal_process_type(void)
743 {
744         return rte_config.process_type;
745 }
746
747 int rte_eal_has_pci(void)
748 {
749         return !internal_config.no_pci;
750 }
751
752 int rte_eal_create_uio_dev(void)
753 {
754         return internal_config.create_uio_dev;
755 }
756
757 enum rte_intr_mode
758 rte_eal_vfio_intr_mode(void)
759 {
760         return RTE_INTR_MODE_NONE;
761 }
762
763 int rte_vfio_setup_device(__rte_unused const char *sysfs_base,
764                       __rte_unused const char *dev_addr,
765                       __rte_unused int *vfio_dev_fd,
766                       __rte_unused struct vfio_device_info *device_info)
767 {
768         return -1;
769 }
770
771 int rte_vfio_release_device(__rte_unused const char *sysfs_base,
772                         __rte_unused const char *dev_addr,
773                         __rte_unused int fd)
774 {
775         return -1;
776 }
777
778 int rte_vfio_enable(__rte_unused const char *modname)
779 {
780         return -1;
781 }
782
783 int rte_vfio_is_enabled(__rte_unused const char *modname)
784 {
785         return 0;
786 }
787
788 int rte_vfio_noiommu_is_enabled(void)
789 {
790         return 0;
791 }
792
793 int rte_vfio_clear_group(__rte_unused int vfio_group_fd)
794 {
795         return 0;
796 }
797
798 int __rte_experimental
799 rte_vfio_dma_map(uint64_t __rte_unused vaddr, __rte_unused uint64_t iova,
800                   __rte_unused uint64_t len)
801 {
802         return -1;
803 }
804
805 int __rte_experimental
806 rte_vfio_dma_unmap(uint64_t __rte_unused vaddr, uint64_t __rte_unused iova,
807                     __rte_unused uint64_t len)
808 {
809         return -1;
810 }
811
812 int __rte_experimental
813 rte_vfio_get_group_num(__rte_unused const char *sysfs_base,
814                        __rte_unused const char *dev_addr,
815                        __rte_unused int *iommu_group_num)
816 {
817         return -1;
818 }
819
820 int  __rte_experimental
821 rte_vfio_get_container_fd(void)
822 {
823         return -1;
824 }
825
826 int  __rte_experimental
827 rte_vfio_get_group_fd(__rte_unused int iommu_group_num)
828 {
829         return -1;
830 }