eal: fix mempool ops name parsing
[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 =
384                             strdup(optarg);
385                         break;
386                 case 'h':
387                         eal_usage(prgname);
388                         exit(EXIT_SUCCESS);
389                 default:
390                         if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
391                                 RTE_LOG(ERR, EAL, "Option %c is not supported "
392                                         "on FreeBSD\n", opt);
393                         } else if (opt >= OPT_LONG_MIN_NUM &&
394                                    opt < OPT_LONG_MAX_NUM) {
395                                 RTE_LOG(ERR, EAL, "Option %s is not supported "
396                                         "on FreeBSD\n",
397                                         eal_long_options[option_index].name);
398                         } else {
399                                 RTE_LOG(ERR, EAL, "Option %d is not supported "
400                                         "on FreeBSD\n", opt);
401                         }
402                         eal_usage(prgname);
403                         ret = -1;
404                         goto out;
405                 }
406         }
407
408         if (eal_adjust_config(&internal_config) != 0) {
409                 ret = -1;
410                 goto out;
411         }
412
413         /* sanity checks */
414         if (eal_check_common_options(&internal_config) != 0) {
415                 eal_usage(prgname);
416                 ret = -1;
417                 goto out;
418         }
419
420         if (optind >= 0)
421                 argv[optind-1] = prgname;
422         ret = optind-1;
423
424 out:
425         /* restore getopt lib */
426         optind = old_optind;
427         optopt = old_optopt;
428         optreset = old_optreset;
429         optarg = old_optarg;
430
431         return ret;
432 }
433
434 static int
435 check_socket(const struct rte_memseg_list *msl, void *arg)
436 {
437         int *socket_id = arg;
438
439         if (msl->socket_id == *socket_id && msl->memseg_arr.count != 0)
440                 return 1;
441
442         return 0;
443 }
444
445 static void
446 eal_check_mem_on_local_socket(void)
447 {
448         int socket_id;
449
450         socket_id = rte_lcore_to_socket_id(rte_config.master_lcore);
451
452         if (rte_memseg_list_walk(check_socket, &socket_id) == 0)
453                 RTE_LOG(WARNING, EAL, "WARNING: Master core has no memory on local socket!\n");
454 }
455
456
457 static int
458 sync_func(__attribute__((unused)) void *arg)
459 {
460         return 0;
461 }
462
463 inline static void
464 rte_eal_mcfg_complete(void)
465 {
466         /* ALL shared mem_config related INIT DONE */
467         if (rte_config.process_type == RTE_PROC_PRIMARY)
468                 rte_config.mem_config->magic = RTE_MAGIC;
469 }
470
471 /* return non-zero if hugepages are enabled. */
472 int rte_eal_has_hugepages(void)
473 {
474         return !internal_config.no_hugetlbfs;
475 }
476
477 /* Abstraction for port I/0 privilege */
478 int
479 rte_eal_iopl_init(void)
480 {
481         static int fd;
482
483         fd = open("/dev/io", O_RDWR);
484         if (fd < 0)
485                 return -1;
486         /* keep fd open for iopl */
487         return 0;
488 }
489
490 static void rte_eal_init_alert(const char *msg)
491 {
492         fprintf(stderr, "EAL: FATAL: %s\n", msg);
493         RTE_LOG(ERR, EAL, "%s\n", msg);
494 }
495
496 /* Launch threads, called at application init(). */
497 int
498 rte_eal_init(int argc, char **argv)
499 {
500         int i, fctret, ret;
501         pthread_t thread_id;
502         static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
503         char cpuset[RTE_CPU_AFFINITY_STR_LEN];
504         char thread_name[RTE_MAX_THREAD_NAME_LEN];
505
506         /* checks if the machine is adequate */
507         if (!rte_cpu_is_supported()) {
508                 rte_eal_init_alert("unsupported cpu type.");
509                 rte_errno = ENOTSUP;
510                 return -1;
511         }
512
513         if (!rte_atomic32_test_and_set(&run_once)) {
514                 rte_eal_init_alert("already called initialization.");
515                 rte_errno = EALREADY;
516                 return -1;
517         }
518
519         thread_id = pthread_self();
520
521         eal_reset_internal_config(&internal_config);
522
523         /* set log level as early as possible */
524         eal_log_level_parse(argc, argv);
525
526         if (rte_eal_cpu_init() < 0) {
527                 rte_eal_init_alert("Cannot detect lcores.");
528                 rte_errno = ENOTSUP;
529                 return -1;
530         }
531
532         fctret = eal_parse_args(argc, argv);
533         if (fctret < 0) {
534                 rte_eal_init_alert("Invalid 'command line' arguments.");
535                 rte_errno = EINVAL;
536                 rte_atomic32_clear(&run_once);
537                 return -1;
538         }
539
540         /* FreeBSD always uses legacy memory model */
541         internal_config.legacy_mem = true;
542
543         if (eal_plugins_init() < 0) {
544                 rte_eal_init_alert("Cannot init plugins\n");
545                 rte_errno = EINVAL;
546                 rte_atomic32_clear(&run_once);
547                 return -1;
548         }
549
550         if (eal_option_device_parse()) {
551                 rte_errno = ENODEV;
552                 rte_atomic32_clear(&run_once);
553                 return -1;
554         }
555
556         rte_config_init();
557
558         /* Put mp channel init before bus scan so that we can init the vdev
559          * bus through mp channel in the secondary process before the bus scan.
560          */
561         if (rte_mp_channel_init() < 0) {
562                 rte_eal_init_alert("failed to init mp channel\n");
563                 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
564                         rte_errno = EFAULT;
565                         return -1;
566                 }
567         }
568
569         if (rte_bus_scan()) {
570                 rte_eal_init_alert("Cannot scan the buses for devices\n");
571                 rte_errno = ENODEV;
572                 rte_atomic32_clear(&run_once);
573                 return -1;
574         }
575
576         /* autodetect the iova mapping mode (default is iova_pa) */
577         rte_eal_get_configuration()->iova_mode = rte_bus_get_iommu_class();
578
579         if (internal_config.no_hugetlbfs == 0) {
580                 /* rte_config isn't initialized yet */
581                 ret = internal_config.process_type == RTE_PROC_PRIMARY ?
582                         eal_hugepage_info_init() :
583                         eal_hugepage_info_read();
584                 if (ret < 0) {
585                         rte_eal_init_alert("Cannot get hugepage information.");
586                         rte_errno = EACCES;
587                         rte_atomic32_clear(&run_once);
588                         return -1;
589                 }
590         }
591
592         if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
593                 if (internal_config.no_hugetlbfs)
594                         internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
595                 else
596                         internal_config.memory = eal_get_hugepage_mem_size();
597         }
598
599         if (internal_config.vmware_tsc_map == 1) {
600 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
601                 rte_cycles_vmware_tsc_map = 1;
602                 RTE_LOG (DEBUG, EAL, "Using VMWARE TSC MAP, "
603                                 "you must have monitor_control.pseudo_perfctr = TRUE\n");
604 #else
605                 RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
606                                 "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
607 #endif
608         }
609
610         rte_srand(rte_rdtsc());
611
612         /* in secondary processes, memory init may allocate additional fbarrays
613          * not present in primary processes, so to avoid any potential issues,
614          * initialize memzones first.
615          */
616         if (rte_eal_memzone_init() < 0) {
617                 rte_eal_init_alert("Cannot init memzone\n");
618                 rte_errno = ENODEV;
619                 return -1;
620         }
621
622         if (rte_eal_memory_init() < 0) {
623                 rte_eal_init_alert("Cannot init memory\n");
624                 rte_errno = ENOMEM;
625                 return -1;
626         }
627
628         if (rte_eal_malloc_heap_init() < 0) {
629                 rte_eal_init_alert("Cannot init malloc heap\n");
630                 rte_errno = ENODEV;
631                 return -1;
632         }
633
634         if (rte_eal_tailqs_init() < 0) {
635                 rte_eal_init_alert("Cannot init tail queues for objects\n");
636                 rte_errno = EFAULT;
637                 return -1;
638         }
639
640         if (rte_eal_alarm_init() < 0) {
641                 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
642                 /* rte_eal_alarm_init sets rte_errno on failure. */
643                 return -1;
644         }
645
646         if (rte_eal_intr_init() < 0) {
647                 rte_eal_init_alert("Cannot init interrupt-handling thread\n");
648                 return -1;
649         }
650
651         if (rte_eal_timer_init() < 0) {
652                 rte_eal_init_alert("Cannot init HPET or TSC timers\n");
653                 rte_errno = ENOTSUP;
654                 return -1;
655         }
656
657         eal_check_mem_on_local_socket();
658
659         eal_thread_init_master(rte_config.master_lcore);
660
661         ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
662
663         RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
664                 rte_config.master_lcore, thread_id, cpuset,
665                 ret == 0 ? "" : "...");
666
667         RTE_LCORE_FOREACH_SLAVE(i) {
668
669                 /*
670                  * create communication pipes between master thread
671                  * and children
672                  */
673                 if (pipe(lcore_config[i].pipe_master2slave) < 0)
674                         rte_panic("Cannot create pipe\n");
675                 if (pipe(lcore_config[i].pipe_slave2master) < 0)
676                         rte_panic("Cannot create pipe\n");
677
678                 lcore_config[i].state = WAIT;
679
680                 /* create a thread for each lcore */
681                 ret = pthread_create(&lcore_config[i].thread_id, NULL,
682                                      eal_thread_loop, NULL);
683                 if (ret != 0)
684                         rte_panic("Cannot create thread\n");
685
686                 /* Set thread_name for aid in debugging. */
687                 snprintf(thread_name, sizeof(thread_name),
688                                 "lcore-slave-%d", i);
689                 rte_thread_setname(lcore_config[i].thread_id, thread_name);
690         }
691
692         /*
693          * Launch a dummy function on all slave lcores, so that master lcore
694          * knows they are all ready when this function returns.
695          */
696         rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
697         rte_eal_mp_wait_lcore();
698
699         /* initialize services so vdevs register service during bus_probe. */
700         ret = rte_service_init();
701         if (ret) {
702                 rte_eal_init_alert("rte_service_init() failed\n");
703                 rte_errno = ENOEXEC;
704                 return -1;
705         }
706
707         /* Probe all the buses and devices/drivers on them */
708         if (rte_bus_probe()) {
709                 rte_eal_init_alert("Cannot probe devices\n");
710                 rte_errno = ENOTSUP;
711                 return -1;
712         }
713
714         /* initialize default service/lcore mappings and start running. Ignore
715          * -ENOTSUP, as it indicates no service coremask passed to EAL.
716          */
717         ret = rte_service_start_with_defaults();
718         if (ret < 0 && ret != -ENOTSUP) {
719                 rte_errno = ENOEXEC;
720                 return -1;
721         }
722
723         rte_eal_mcfg_complete();
724
725         return fctret;
726 }
727
728 int __rte_experimental
729 rte_eal_cleanup(void)
730 {
731         rte_service_finalize();
732         return 0;
733 }
734
735 /* get core role */
736 enum rte_lcore_role_t
737 rte_eal_lcore_role(unsigned lcore_id)
738 {
739         return rte_config.lcore_role[lcore_id];
740 }
741
742 enum rte_proc_type_t
743 rte_eal_process_type(void)
744 {
745         return rte_config.process_type;
746 }
747
748 int rte_eal_has_pci(void)
749 {
750         return !internal_config.no_pci;
751 }
752
753 int rte_eal_create_uio_dev(void)
754 {
755         return internal_config.create_uio_dev;
756 }
757
758 enum rte_intr_mode
759 rte_eal_vfio_intr_mode(void)
760 {
761         return RTE_INTR_MODE_NONE;
762 }
763
764 int rte_vfio_setup_device(__rte_unused const char *sysfs_base,
765                       __rte_unused const char *dev_addr,
766                       __rte_unused int *vfio_dev_fd,
767                       __rte_unused struct vfio_device_info *device_info)
768 {
769         return -1;
770 }
771
772 int rte_vfio_release_device(__rte_unused const char *sysfs_base,
773                         __rte_unused const char *dev_addr,
774                         __rte_unused int fd)
775 {
776         return -1;
777 }
778
779 int rte_vfio_enable(__rte_unused const char *modname)
780 {
781         return -1;
782 }
783
784 int rte_vfio_is_enabled(__rte_unused const char *modname)
785 {
786         return 0;
787 }
788
789 int rte_vfio_noiommu_is_enabled(void)
790 {
791         return 0;
792 }
793
794 int rte_vfio_clear_group(__rte_unused int vfio_group_fd)
795 {
796         return 0;
797 }
798
799 int __rte_experimental
800 rte_vfio_dma_map(uint64_t __rte_unused vaddr, __rte_unused uint64_t iova,
801                   __rte_unused uint64_t len)
802 {
803         return -1;
804 }
805
806 int __rte_experimental
807 rte_vfio_dma_unmap(uint64_t __rte_unused vaddr, uint64_t __rte_unused iova,
808                     __rte_unused uint64_t len)
809 {
810         return -1;
811 }
812
813 int __rte_experimental
814 rte_vfio_get_group_num(__rte_unused const char *sysfs_base,
815                        __rte_unused const char *dev_addr,
816                        __rte_unused int *iommu_group_num)
817 {
818         return -1;
819 }
820
821 int  __rte_experimental
822 rte_vfio_get_container_fd(void)
823 {
824         return -1;
825 }
826
827 int  __rte_experimental
828 rte_vfio_get_group_fd(__rte_unused int iommu_group_num)
829 {
830         return -1;
831 }
832
833 int __rte_experimental
834 rte_vfio_container_create(void)
835 {
836         return -1;
837 }
838
839 int __rte_experimental
840 rte_vfio_container_destroy(__rte_unused int container_fd)
841 {
842         return -1;
843 }
844
845 int __rte_experimental
846 rte_vfio_container_group_bind(__rte_unused int container_fd,
847                 __rte_unused int iommu_group_num)
848 {
849         return -1;
850 }
851
852 int __rte_experimental
853 rte_vfio_container_group_unbind(__rte_unused int container_fd,
854                 __rte_unused int iommu_group_num)
855 {
856         return -1;
857 }
858
859 int __rte_experimental
860 rte_vfio_container_dma_map(__rte_unused int container_fd,
861                         __rte_unused uint64_t vaddr,
862                         __rte_unused uint64_t iova,
863                         __rte_unused uint64_t len)
864 {
865         return -1;
866 }
867
868 int __rte_experimental
869 rte_vfio_container_dma_unmap(__rte_unused int container_fd,
870                         __rte_unused uint64_t vaddr,
871                         __rte_unused uint64_t iova,
872                         __rte_unused uint64_t len)
873 {
874         return -1;
875 }