lib: sysfs parsing
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal.c
1 /*-
2  *   BSD LICENSE
3  * 
4  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  * 
7  *   Redistribution and use in source and binary forms, with or without 
8  *   modification, are permitted provided that the following conditions 
9  *   are met:
10  * 
11  *     * Redistributions of source code must retain the above copyright 
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright 
14  *       notice, this list of conditions and the following disclaimer in 
15  *       the documentation and/or other materials provided with the 
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its 
18  *       contributors may be used to endorse or promote products derived 
19  *       from this software without specific prior written permission.
20  * 
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  * 
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 <getopt.h>
43 #include <fcntl.h>
44 #include <stddef.h>
45 #include <errno.h>
46 #include <limits.h>
47 #include <errno.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_tailq.h>
57 #include <rte_eal.h>
58 #include <rte_per_lcore.h>
59 #include <rte_lcore.h>
60 #include <rte_log.h>
61 #include <rte_random.h>
62 #include <rte_cycles.h>
63 #include <rte_string_fns.h>
64 #include <rte_cpuflags.h>
65 #include <rte_interrupts.h>
66 #include <rte_pci.h>
67 #include <rte_common.h>
68 #include <rte_version.h>
69
70 #include "eal_private.h"
71 #include "eal_thread.h"
72 #include "eal_internal_cfg.h"
73 #include "eal_filesystem.h"
74 #include "eal_hugepages.h"
75
76 #define OPT_HUGE_DIR    "huge-dir"
77 #define OPT_PROC_TYPE   "proc-type"
78 #define OPT_NO_SHCONF   "no-shconf"
79 #define OPT_NO_HPET     "no-hpet"
80 #define OPT_NO_PCI      "no-pci"
81 #define OPT_NO_HUGE     "no-huge"
82 #define OPT_FILE_PREFIX "file-prefix"
83
84 #define RTE_EAL_BLACKLIST_SIZE  0x100
85
86 #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
87
88 #define GET_BLACKLIST_FIELD(in, fd, lim, dlm)                   \
89 {                                                               \
90         unsigned long val;                                      \
91         char *end;                                              \
92         errno = 0;                                              \
93         val = strtoul((in), &end, 16);                          \
94         if (errno != 0 || end[0] != (dlm) || val > (lim))       \
95                 return (-EINVAL);                               \
96         (fd) = (typeof (fd))val;                                \
97         (in) = end + 1;                                         \
98 }
99
100 /* early configuration structure, when memory config is not mmapped */
101 static struct rte_mem_config early_mem_config;
102
103 /* define fd variable here, because file needs to be kept open for the
104  * duration of the program, as we hold a write lock on it in the primary proc */
105 static int mem_cfg_fd = -1;
106
107 static struct flock wr_lock = {
108                 .l_type = F_WRLCK,
109                 .l_whence = SEEK_SET,
110                 .l_start = offsetof(struct rte_mem_config, memseg),
111                 .l_len = sizeof(early_mem_config.memseg),
112 };
113
114 /* Address of global and public configuration */
115 static struct rte_config rte_config = {
116                 .mem_config = &early_mem_config,
117 };
118
119 static struct rte_pci_addr eal_dev_blacklist[RTE_EAL_BLACKLIST_SIZE];
120
121 /* internal configuration (per-core) */
122 struct lcore_config lcore_config[RTE_MAX_LCORE];
123
124 /* internal configuration */
125 struct internal_config internal_config;
126
127 /* Return a pointer to the configuration structure */
128 struct rte_config *
129 rte_eal_get_configuration(void)
130 {
131         return &rte_config;
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         rte_config.mem_config = (struct rte_mem_config *) rte_mem_cfg_addr;
209         memcpy(rte_config.mem_config, &early_mem_config,
210                         sizeof(early_mem_config));
211 }
212
213 /* attach to an existing shared memory config */
214 static void
215 rte_eal_config_attach(void)
216 {
217         void *rte_mem_cfg_addr;
218         const char *pathname = eal_runtime_config_path();
219
220         if (internal_config.no_shconf)
221                 return;
222
223         if (mem_cfg_fd < 0){
224                 mem_cfg_fd = open(pathname, O_RDONLY);
225                 if (mem_cfg_fd < 0)
226                         rte_panic("Cannot open '%s' for rte_mem_config\n", pathname);
227         }
228
229         rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config), PROT_READ,
230                         MAP_SHARED, mem_cfg_fd, 0);
231         close(mem_cfg_fd);
232         if (rte_mem_cfg_addr == MAP_FAILED)
233                 rte_panic("Cannot mmap memory for rte_config\n");
234
235         rte_config.mem_config = (struct rte_mem_config *) rte_mem_cfg_addr;
236 }
237
238 /* Detect if we are a primary or a secondary process */
239 static enum rte_proc_type_t
240 eal_proc_type_detect(void)
241 {
242         enum rte_proc_type_t ptype = RTE_PROC_PRIMARY;
243         const char *pathname = eal_runtime_config_path();
244
245         /* if we can open the file but not get a write-lock we are a secondary
246          * process. NOTE: if we get a file handle back, we keep that open
247          * and don't close it to prevent a race condition between multiple opens */
248         if (((mem_cfg_fd = open(pathname, O_RDWR)) >= 0) &&
249                         (fcntl(mem_cfg_fd, F_SETLK, &wr_lock) < 0))
250                 ptype = RTE_PROC_SECONDARY;
251
252         RTE_LOG(INFO, EAL, "Auto-detected process type: %s\n",
253                         ptype == RTE_PROC_PRIMARY ? "PRIMARY" : "SECONDARY");
254
255         return ptype;
256 }
257
258 /* Sets up rte_config structure with the pointer to shared memory config.*/
259 static void
260 rte_config_init(void)
261 {
262         /* set the magic in configuration structure */
263         rte_config.magic = RTE_MAGIC;
264         rte_config.process_type = (internal_config.process_type == RTE_PROC_AUTO) ?
265                         eal_proc_type_detect() : /* for auto, detect the type */
266                         internal_config.process_type; /* otherwise use what's already set */
267
268         switch (rte_config.process_type){
269         case RTE_PROC_PRIMARY:
270                 rte_eal_config_create();
271                 break;
272         case RTE_PROC_SECONDARY:
273                 rte_eal_config_attach();
274                 break;
275         case RTE_PROC_AUTO:
276         case RTE_PROC_INVALID:
277                 rte_panic("Invalid process type\n");
278         }
279 }
280
281 /* display usage */
282 static void
283 eal_usage(const char *prgname)
284 {
285         printf("\nUsage: %s -c COREMASK -n NUM [-m NB] [-r NUM] [-b <domain:bus:devid.func>]"
286                "[--proc-type primary|secondary|auto] \n\n"
287                "EAL options:\n"
288                "  -c COREMASK: A hexadecimal bitmask of cores to run on\n"
289                "  -n NUM     : Number of memory channels\n"
290                    "  -v         : Display version information on startup\n"
291                "  -b <domain:bus:devid.func>: to prevent EAL from using specified PCI device\n"
292                "               (multiple -b options are alowed)\n"
293                "  -m MB      : memory to allocate (default = size of hugemem)\n"
294                "  -r NUM     : force number of memory ranks (don't detect)\n"
295                "  --"OPT_HUGE_DIR" : directory where hugetlbfs is mounted\n"
296                "  --"OPT_PROC_TYPE": type of this process\n"
297                "  --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
298                "\nEAL options for DEBUG use only:\n"
299                "  --"OPT_NO_HUGE"  : use malloc instead of hugetlbfs\n"
300                "  --"OPT_NO_PCI"   : disable pci\n"
301                "  --"OPT_NO_HPET"  : disable hpet\n"
302                "  --"OPT_NO_SHCONF": no shared config (mmap'd files)\n\n",
303                prgname);
304 }
305
306 /*
307  * Parse the coremask given as argument (hexadecimal string) and fill
308  * the global configuration (core role and core count) with the parsed
309  * value.
310  */
311 static int
312 eal_parse_coremask(const char *coremask)
313 {
314         struct rte_config *cfg = rte_eal_get_configuration();
315         unsigned i;
316         char *end = NULL;
317         unsigned long long cm;
318         unsigned count = 0;
319
320         /* parse hexadecimal string */
321         cm = strtoull(coremask, &end, 16);
322         if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0') || (cm == 0))
323                 return -1;
324
325         RTE_LOG(DEBUG, EAL, "coremask set to %llx\n", cm);
326         /* set core role and core count */
327         for (i = 0; i < RTE_MAX_LCORE; i++) {
328                 if ((1ULL << i) & cm) {
329                         if (count == 0)
330                                 cfg->master_lcore = i;
331                         cfg->lcore_role[i] = ROLE_RTE;
332                         count++;
333                 }
334                 else {
335                         cfg->lcore_role[i] = ROLE_OFF;
336                 }
337         }
338         return 0;
339 }
340
341 static inline uint64_t
342 eal_get_hugepage_mem_size(void)
343 {
344         uint64_t size = 0;
345         unsigned i;
346
347         for (i = 0; i < internal_config.num_hugepage_sizes; i++){
348                 struct hugepage_info *hpi = &internal_config.hugepage_info[i];
349                 if (hpi->hugedir != NULL)
350                         size += hpi->hugepage_sz * hpi->num_pages;
351         }
352
353         return (size);
354 }
355
356 static enum rte_proc_type_t
357 eal_parse_proc_type(const char *arg)
358 {
359         if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
360                 return RTE_PROC_PRIMARY;
361         if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
362                 return RTE_PROC_SECONDARY;
363         if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
364                 return RTE_PROC_AUTO;
365
366         return RTE_PROC_INVALID;
367 }
368
369 static int
370 eal_parse_blacklist(const char *input,  struct rte_pci_addr *dev2bl)
371 {
372         GET_BLACKLIST_FIELD(input, dev2bl->domain, UINT16_MAX, ':');
373         GET_BLACKLIST_FIELD(input, dev2bl->bus, UINT8_MAX, ':');
374         GET_BLACKLIST_FIELD(input, dev2bl->devid, UINT8_MAX, '.');
375         GET_BLACKLIST_FIELD(input, dev2bl->function, UINT8_MAX, 0);
376         return (0);
377 }
378
379 static ssize_t
380 eal_parse_blacklist_opt(const char *optarg, size_t idx)
381 {
382         if (idx >= sizeof (eal_dev_blacklist) / sizeof (eal_dev_blacklist[0])) {
383                 RTE_LOG(ERR, EAL,
384                     "%s - too many devices to blacklist...\n",
385                     optarg);
386                 return (-EINVAL);
387         } else if (eal_parse_blacklist(optarg, eal_dev_blacklist + idx) != 0) {
388                 RTE_LOG(ERR, EAL,
389                     "%s - invalid device to blacklist...\n",
390                     optarg);
391                 return (-EINVAL);
392         }
393
394         idx += 1;
395         return (idx);
396 }
397
398
399 /* Parse the argument given in the command line of the application */
400 static int
401 eal_parse_args(int argc, char **argv)
402 {
403         int opt, ret;
404         char **argvopt;
405         int option_index;
406         int coremask_ok = 0;
407         ssize_t blacklist_index = 0;;
408         char *prgname = argv[0];
409         static struct option lgopts[] = {
410                 {OPT_NO_HUGE, 0, 0, 0},
411                 {OPT_NO_PCI, 0, 0, 0},
412                 {OPT_NO_HPET, 0, 0, 0},
413                 {OPT_HUGE_DIR, 1, 0, 0},
414                 {OPT_NO_SHCONF, 0, 0, 0},
415                 {OPT_PROC_TYPE, 1, 0, 0},
416                 {OPT_FILE_PREFIX, 1, 0, 0},
417                 {0, 0, 0, 0}
418         };
419
420         argvopt = argv;
421
422         internal_config.memory = 0;
423         internal_config.force_nrank = 0;
424         internal_config.force_nchannel = 0;
425         internal_config.hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
426         internal_config.hugepage_dir = NULL;
427 #ifdef RTE_LIBEAL_USE_HPET
428         internal_config.no_hpet = 0;
429 #else
430         internal_config.no_hpet = 1;
431 #endif
432
433         while ((opt = getopt_long(argc, argvopt, "b:c:m:n:r:v",
434                                   lgopts, &option_index)) != EOF) {
435
436                 switch (opt) {
437                 /* blacklist */
438                 case 'b':
439                         if ((blacklist_index = eal_parse_blacklist_opt(optarg,
440                             blacklist_index)) < 0) {
441                                 eal_usage(prgname);
442                                 return (-1);
443                         }
444                         break;
445                 /* coremask */
446                 case 'c':
447                         if (eal_parse_coremask(optarg) < 0) {
448                                 RTE_LOG(ERR, EAL, "invalid coremask\n");
449                                 eal_usage(prgname);
450                                 return -1;
451                         }
452                         coremask_ok = 1;
453                         break;
454                 /* size of memory */
455                 case 'm':
456                         internal_config.memory = atoi(optarg);
457                         internal_config.memory *= 1024ULL;
458                         internal_config.memory *= 1024ULL;
459                         break;
460                 /* force number of channels */
461                 case 'n':
462                         internal_config.force_nchannel = atoi(optarg);
463                         if (internal_config.force_nchannel == 0 ||
464                             internal_config.force_nchannel > 4) {
465                                 RTE_LOG(ERR, EAL, "invalid channel number\n");
466                                 eal_usage(prgname);
467                                 return -1;
468                         }
469                         break;
470                 /* force number of ranks */
471                 case 'r':
472                         internal_config.force_nrank = atoi(optarg);
473                         if (internal_config.force_nrank == 0 ||
474                             internal_config.force_nrank > 16) {
475                                 RTE_LOG(ERR, EAL, "invalid rank number\n");
476                                 eal_usage(prgname);
477                                 return -1;
478                         }
479                         break;
480                 case 'v':
481                         /* since message is explicitly requested by user, we
482                          * write message at highest log level so it can always be seen
483                          * even if info or warning messages are disabled */
484                         RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
485                         break;
486
487                 /* long options */
488                 case 0:
489                         if (!strcmp(lgopts[option_index].name, OPT_NO_HUGE)) {
490                                 internal_config.no_hugetlbfs = 1;
491                         }
492                         else if (!strcmp(lgopts[option_index].name, OPT_NO_PCI)) {
493                                 internal_config.no_pci = 1;
494                         }
495                         else if (!strcmp(lgopts[option_index].name, OPT_NO_HPET)) {
496                                 internal_config.no_hpet = 1;
497                         }
498                         else if (!strcmp(lgopts[option_index].name, OPT_NO_SHCONF)) {
499                                 internal_config.no_shconf = 1;
500                         }
501                         else if (!strcmp(lgopts[option_index].name, OPT_HUGE_DIR)) {
502                                 internal_config.hugepage_dir = optarg;
503                         }
504                         else if (!strcmp(lgopts[option_index].name, OPT_PROC_TYPE)) {
505                                 internal_config.process_type = eal_parse_proc_type(optarg);
506                         }
507                         else if (!strcmp(lgopts[option_index].name, OPT_FILE_PREFIX)) {
508                                 internal_config.hugefile_prefix = optarg;
509                         }
510                         break;
511
512                 default:
513                         eal_usage(prgname);
514                         return -1;
515                 }
516         }
517
518         /* sanity checks */
519         if (!coremask_ok) {
520                 RTE_LOG(ERR, EAL, "coremask not specified\n");
521                 eal_usage(prgname);
522                 return -1;
523         }
524         if (internal_config.process_type == RTE_PROC_AUTO){
525                 internal_config.process_type = eal_proc_type_detect();
526         }
527         if (internal_config.process_type == RTE_PROC_INVALID){
528                 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
529                 eal_usage(prgname);
530                 return -1;
531         }
532         if (internal_config.process_type == RTE_PROC_PRIMARY &&
533                         internal_config.force_nchannel == 0) {
534                 RTE_LOG(ERR, EAL, "Number of memory channels (-n) not specified\n");
535                 eal_usage(prgname);
536                 return -1;
537         }
538         if (index(internal_config.hugefile_prefix,'%') != NULL){
539                 RTE_LOG(ERR, EAL, "Invalid char, '%%', in '"OPT_FILE_PREFIX"' option\n");
540                 eal_usage(prgname);
541                 return -1;
542         }
543
544         if (blacklist_index > 0)
545                 rte_eal_pci_set_blacklist(eal_dev_blacklist, blacklist_index);
546
547         if (optind >= 0)
548                 argv[optind-1] = prgname;
549
550         ret = optind-1;
551         optind = 0; /* reset getopt lib */
552         return ret;
553 }
554
555 /* Launch threads, called at application init(). */
556 int
557 rte_eal_init(int argc, char **argv)
558 {
559         int i, fctret, ret;
560         pthread_t thread_id;
561
562         thread_id = pthread_self();
563
564         if (rte_eal_log_early_init() < 0)
565                 rte_panic("Cannot init early logs\n");
566
567         fctret = eal_parse_args(argc, argv);
568         if (fctret < 0)
569                 exit(1);
570
571         if (eal_hugepage_info_init() < 0)
572                 rte_panic("Cannot get hugepage information\n");
573
574         if (internal_config.memory == 0) {
575                 if (internal_config.no_hugetlbfs)
576                         internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
577                 else
578                         internal_config.memory = eal_get_hugepage_mem_size();
579         }
580
581         rte_srand(rte_rdtsc());
582         rte_config_init();
583
584         if (rte_eal_cpu_init() < 0)
585                 rte_panic("Cannot detect lcores\n");
586
587         if (rte_eal_memory_init() < 0)
588                 rte_panic("Cannot init memory\n");
589
590         if (rte_eal_memzone_init() < 0)
591                 rte_panic("Cannot init memzone\n");
592
593         if (rte_eal_tailqs_init() < 0)
594                 rte_panic("Cannot init tail queues for objects\n");
595
596         if (rte_eal_log_init() < 0)
597                 rte_panic("Cannot init logs\n");
598
599         if (rte_eal_alarm_init() < 0)
600                 rte_panic("Cannot init interrupt-handling thread\n");
601
602         if (rte_eal_intr_init() < 0)
603                 rte_panic("Cannot init interrupt-handling thread\n");
604
605         if (rte_eal_hpet_init() < 0)
606                 rte_panic("Cannot init HPET\n");
607
608         if (rte_eal_pci_init() < 0)
609                 rte_panic("Cannot init PCI\n");
610
611         RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n",
612                 rte_config.master_lcore, (int)thread_id);
613
614         RTE_LCORE_FOREACH_SLAVE(i) {
615
616                 /*
617                  * create communication pipes between master thread
618                  * and children
619                  */
620                 if (pipe(lcore_config[i].pipe_master2slave) < 0)
621                         rte_panic("Cannot create pipe\n");
622                 if (pipe(lcore_config[i].pipe_slave2master) < 0)
623                         rte_panic("Cannot create pipe\n");
624
625                 lcore_config[i].state = WAIT;
626
627                 /* create a thread for each lcore */
628                 ret = pthread_create(&lcore_config[i].thread_id, NULL,
629                                      eal_thread_loop, NULL);
630                 if (ret != 0)
631                         rte_panic("Cannot create thread\n");
632         }
633
634         eal_thread_init_master(rte_config.master_lcore);
635
636         return fctret;
637 }
638
639 /* get core role */
640 enum rte_lcore_role_t
641 rte_eal_lcore_role(unsigned lcore_id)
642 {
643         return (rte_config.lcore_role[lcore_id]);
644 }
645
646 enum rte_proc_type_t
647 rte_eal_process_type(void)
648 {
649         return (rte_config.process_type);
650 }
651