eal: minor changes
[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 "
292            "PCI device\n"
293                "                 (multiple -b options are allowed)\n"
294                "  -m MB        : memory to allocate (see also --"OPT_SOCKET_MEM")\n"
295                "  -r NUM       : force number of memory ranks (don't detect)\n"
296                "  --"OPT_HUGE_DIR"   : directory where hugetlbfs is mounted\n"
297                "  --"OPT_PROC_TYPE"  : type of this process\n"
298                "  --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
299                "\nEAL options for DEBUG use only:\n"
300                "  --"OPT_NO_HUGE"  : use malloc instead of hugetlbfs\n"
301                "  --"OPT_NO_PCI"   : disable pci\n"
302                "  --"OPT_NO_HPET"  : disable hpet\n"
303                "  --"OPT_NO_SHCONF": no shared config (mmap'd files)\n\n",
304                prgname);
305 }
306
307 /*
308  * Parse the coremask given as argument (hexadecimal string) and fill
309  * the global configuration (core role and core count) with the parsed
310  * value.
311  */
312 static int
313 eal_parse_coremask(const char *coremask)
314 {
315         struct rte_config *cfg = rte_eal_get_configuration();
316         unsigned i;
317         char *end = NULL;
318         unsigned long long cm;
319         unsigned count = 0;
320
321         /* parse hexadecimal string */
322         cm = strtoull(coremask, &end, 16);
323         if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0') || (cm == 0))
324                 return -1;
325
326         RTE_LOG(DEBUG, EAL, "coremask set to %llx\n", cm);
327         /* set core role and core count */
328         for (i = 0; i < RTE_MAX_LCORE; i++) {
329                 if ((1ULL << i) & cm) {
330                         if (count == 0)
331                                 cfg->master_lcore = i;
332                         cfg->lcore_role[i] = ROLE_RTE;
333                         count++;
334                 }
335                 else {
336                         cfg->lcore_role[i] = ROLE_OFF;
337                 }
338         }
339         return 0;
340 }
341
342 static inline uint64_t
343 eal_get_hugepage_mem_size(void)
344 {
345         uint64_t size = 0;
346         unsigned i;
347
348         for (i = 0; i < internal_config.num_hugepage_sizes; i++){
349                 struct hugepage_info *hpi = &internal_config.hugepage_info[i];
350                 if (hpi->hugedir != NULL)
351                         size += hpi->hugepage_sz * hpi->num_pages;
352         }
353
354         return (size);
355 }
356
357 static enum rte_proc_type_t
358 eal_parse_proc_type(const char *arg)
359 {
360         if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
361                 return RTE_PROC_PRIMARY;
362         if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
363                 return RTE_PROC_SECONDARY;
364         if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
365                 return RTE_PROC_AUTO;
366
367         return RTE_PROC_INVALID;
368 }
369
370 static int
371 eal_parse_blacklist(const char *input,  struct rte_pci_addr *dev2bl)
372 {
373         GET_BLACKLIST_FIELD(input, dev2bl->domain, UINT16_MAX, ':');
374         GET_BLACKLIST_FIELD(input, dev2bl->bus, UINT8_MAX, ':');
375         GET_BLACKLIST_FIELD(input, dev2bl->devid, UINT8_MAX, '.');
376         GET_BLACKLIST_FIELD(input, dev2bl->function, UINT8_MAX, 0);
377         return (0);
378 }
379
380 static ssize_t
381 eal_parse_blacklist_opt(const char *optarg, size_t idx)
382 {
383         if (idx >= sizeof (eal_dev_blacklist) / sizeof (eal_dev_blacklist[0])) {
384                 RTE_LOG(ERR, EAL,
385                     "%s - too many devices to blacklist...\n",
386                     optarg);
387                 return (-EINVAL);
388         } else if (eal_parse_blacklist(optarg, eal_dev_blacklist + idx) != 0) {
389                 RTE_LOG(ERR, EAL,
390                     "%s - invalid device to blacklist...\n",
391                     optarg);
392                 return (-EINVAL);
393         }
394
395         idx += 1;
396         return (idx);
397 }
398
399
400 /* Parse the argument given in the command line of the application */
401 static int
402 eal_parse_args(int argc, char **argv)
403 {
404         int opt, ret;
405         char **argvopt;
406         int option_index;
407         int coremask_ok = 0;
408         ssize_t blacklist_index = 0;;
409         char *prgname = argv[0];
410         static struct option lgopts[] = {
411                 {OPT_NO_HUGE, 0, 0, 0},
412                 {OPT_NO_PCI, 0, 0, 0},
413                 {OPT_NO_HPET, 0, 0, 0},
414                 {OPT_HUGE_DIR, 1, 0, 0},
415                 {OPT_NO_SHCONF, 0, 0, 0},
416                 {OPT_PROC_TYPE, 1, 0, 0},
417                 {OPT_FILE_PREFIX, 1, 0, 0},
418                 {0, 0, 0, 0}
419         };
420
421         argvopt = argv;
422
423         internal_config.memory = 0;
424         internal_config.force_nrank = 0;
425         internal_config.force_nchannel = 0;
426         internal_config.hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
427         internal_config.hugepage_dir = NULL;
428 #ifdef RTE_LIBEAL_USE_HPET
429         internal_config.no_hpet = 0;
430 #else
431         internal_config.no_hpet = 1;
432 #endif
433
434         while ((opt = getopt_long(argc, argvopt, "b:c:m:n:r:v",
435                                   lgopts, &option_index)) != EOF) {
436
437                 switch (opt) {
438                 /* blacklist */
439                 case 'b':
440                         if ((blacklist_index = eal_parse_blacklist_opt(optarg,
441                             blacklist_index)) < 0) {
442                                 eal_usage(prgname);
443                                 return (-1);
444                         }
445                         break;
446                 /* coremask */
447                 case 'c':
448                         if (eal_parse_coremask(optarg) < 0) {
449                                 RTE_LOG(ERR, EAL, "invalid coremask\n");
450                                 eal_usage(prgname);
451                                 return -1;
452                         }
453                         coremask_ok = 1;
454                         break;
455                 /* size of memory */
456                 case 'm':
457                         internal_config.memory = atoi(optarg);
458                         internal_config.memory *= 1024ULL;
459                         internal_config.memory *= 1024ULL;
460                         break;
461                 /* force number of channels */
462                 case 'n':
463                         internal_config.force_nchannel = atoi(optarg);
464                         if (internal_config.force_nchannel == 0 ||
465                             internal_config.force_nchannel > 4) {
466                                 RTE_LOG(ERR, EAL, "invalid channel number\n");
467                                 eal_usage(prgname);
468                                 return -1;
469                         }
470                         break;
471                 /* force number of ranks */
472                 case 'r':
473                         internal_config.force_nrank = atoi(optarg);
474                         if (internal_config.force_nrank == 0 ||
475                             internal_config.force_nrank > 16) {
476                                 RTE_LOG(ERR, EAL, "invalid rank number\n");
477                                 eal_usage(prgname);
478                                 return -1;
479                         }
480                         break;
481                 case 'v':
482                         /* since message is explicitly requested by user, we
483                          * write message at highest log level so it can always be seen
484                          * even if info or warning messages are disabled */
485                         RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
486                         break;
487
488                 /* long options */
489                 case 0:
490                         if (!strcmp(lgopts[option_index].name, OPT_NO_HUGE)) {
491                                 internal_config.no_hugetlbfs = 1;
492                         }
493                         else if (!strcmp(lgopts[option_index].name, OPT_NO_PCI)) {
494                                 internal_config.no_pci = 1;
495                         }
496                         else if (!strcmp(lgopts[option_index].name, OPT_NO_HPET)) {
497                                 internal_config.no_hpet = 1;
498                         }
499                         else if (!strcmp(lgopts[option_index].name, OPT_NO_SHCONF)) {
500                                 internal_config.no_shconf = 1;
501                         }
502                         else if (!strcmp(lgopts[option_index].name, OPT_HUGE_DIR)) {
503                                 internal_config.hugepage_dir = optarg;
504                         }
505                         else if (!strcmp(lgopts[option_index].name, OPT_PROC_TYPE)) {
506                                 internal_config.process_type = eal_parse_proc_type(optarg);
507                         }
508                         else if (!strcmp(lgopts[option_index].name, OPT_FILE_PREFIX)) {
509                                 internal_config.hugefile_prefix = optarg;
510                         }
511                         break;
512
513                 default:
514                         eal_usage(prgname);
515                         return -1;
516                 }
517         }
518
519         /* sanity checks */
520         if (!coremask_ok) {
521                 RTE_LOG(ERR, EAL, "coremask not specified\n");
522                 eal_usage(prgname);
523                 return -1;
524         }
525         if (internal_config.process_type == RTE_PROC_AUTO){
526                 internal_config.process_type = eal_proc_type_detect();
527         }
528         if (internal_config.process_type == RTE_PROC_INVALID){
529                 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
530                 eal_usage(prgname);
531                 return -1;
532         }
533         if (internal_config.process_type == RTE_PROC_PRIMARY &&
534                         internal_config.force_nchannel == 0) {
535                 RTE_LOG(ERR, EAL, "Number of memory channels (-n) not specified\n");
536                 eal_usage(prgname);
537                 return -1;
538         }
539         if (index(internal_config.hugefile_prefix,'%') != NULL){
540                 RTE_LOG(ERR, EAL, "Invalid char, '%%', in '"OPT_FILE_PREFIX"' option\n");
541                 eal_usage(prgname);
542                 return -1;
543         }
544
545         if (blacklist_index > 0)
546                 rte_eal_pci_set_blacklist(eal_dev_blacklist, blacklist_index);
547
548         if (optind >= 0)
549                 argv[optind-1] = prgname;
550
551         ret = optind-1;
552         optind = 0; /* reset getopt lib */
553         return ret;
554 }
555
556 /* Launch threads, called at application init(). */
557 int
558 rte_eal_init(int argc, char **argv)
559 {
560         int i, fctret, ret;
561         pthread_t thread_id;
562
563         thread_id = pthread_self();
564
565         if (rte_eal_log_early_init() < 0)
566                 rte_panic("Cannot init early logs\n");
567
568         fctret = eal_parse_args(argc, argv);
569         if (fctret < 0)
570                 exit(1);
571
572         if (eal_hugepage_info_init() < 0)
573                 rte_panic("Cannot get hugepage information\n");
574
575         if (internal_config.memory == 0) {
576                 if (internal_config.no_hugetlbfs)
577                         internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
578                 else
579                         internal_config.memory = eal_get_hugepage_mem_size();
580         }
581
582         rte_srand(rte_rdtsc());
583         rte_config_init();
584
585         if (rte_eal_cpu_init() < 0)
586                 rte_panic("Cannot detect lcores\n");
587
588         if (rte_eal_memory_init() < 0)
589                 rte_panic("Cannot init memory\n");
590
591         if (rte_eal_memzone_init() < 0)
592                 rte_panic("Cannot init memzone\n");
593
594         if (rte_eal_tailqs_init() < 0)
595                 rte_panic("Cannot init tail queues for objects\n");
596
597         if (rte_eal_log_init() < 0)
598                 rte_panic("Cannot init logs\n");
599
600         if (rte_eal_alarm_init() < 0)
601                 rte_panic("Cannot init interrupt-handling thread\n");
602
603         if (rte_eal_intr_init() < 0)
604                 rte_panic("Cannot init interrupt-handling thread\n");
605
606         if (rte_eal_hpet_init() < 0)
607                 rte_panic("Cannot init HPET\n");
608
609         if (rte_eal_pci_init() < 0)
610                 rte_panic("Cannot init PCI\n");
611
612         RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n",
613                 rte_config.master_lcore, (int)thread_id);
614
615         RTE_LCORE_FOREACH_SLAVE(i) {
616
617                 /*
618                  * create communication pipes between master thread
619                  * and children
620                  */
621                 if (pipe(lcore_config[i].pipe_master2slave) < 0)
622                         rte_panic("Cannot create pipe\n");
623                 if (pipe(lcore_config[i].pipe_slave2master) < 0)
624                         rte_panic("Cannot create pipe\n");
625
626                 lcore_config[i].state = WAIT;
627
628                 /* create a thread for each lcore */
629                 ret = pthread_create(&lcore_config[i].thread_id, NULL,
630                                      eal_thread_loop, NULL);
631                 if (ret != 0)
632                         rte_panic("Cannot create thread\n");
633         }
634
635         eal_thread_init_master(rte_config.master_lcore);
636
637         return fctret;
638 }
639
640 /* get core role */
641 enum rte_lcore_role_t
642 rte_eal_lcore_role(unsigned lcore_id)
643 {
644         return (rte_config.lcore_role[lcore_id]);
645 }
646
647 enum rte_proc_type_t
648 rte_eal_process_type(void)
649 {
650         return (rte_config.process_type);
651 }
652