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