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