New upstream version 18.08
[deb_dpdk.git] / lib / librte_eal / common / eal_common_options.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <string.h>
9 #include <syslog.h>
10 #include <ctype.h>
11 #include <limits.h>
12 #include <errno.h>
13 #include <getopt.h>
14 #include <dlfcn.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <dirent.h>
18
19 #include <rte_eal.h>
20 #include <rte_log.h>
21 #include <rte_lcore.h>
22 #include <rte_tailq.h>
23 #include <rte_version.h>
24 #include <rte_devargs.h>
25 #include <rte_memcpy.h>
26
27 #include "eal_internal_cfg.h"
28 #include "eal_options.h"
29 #include "eal_filesystem.h"
30 #include "eal_private.h"
31
32 #define BITS_PER_HEX 4
33 #define LCORE_OPT_LST 1
34 #define LCORE_OPT_MSK 2
35 #define LCORE_OPT_MAP 3
36
37 const char
38 eal_short_options[] =
39         "b:" /* pci-blacklist */
40         "c:" /* coremask */
41         "s:" /* service coremask */
42         "d:" /* driver */
43         "h"  /* help */
44         "l:" /* corelist */
45         "S:" /* service corelist */
46         "m:" /* memory size */
47         "n:" /* memory channels */
48         "r:" /* memory ranks */
49         "v"  /* version */
50         "w:" /* pci-whitelist */
51         ;
52
53 const struct option
54 eal_long_options[] = {
55         {OPT_BASE_VIRTADDR,     1, NULL, OPT_BASE_VIRTADDR_NUM    },
56         {OPT_CREATE_UIO_DEV,    0, NULL, OPT_CREATE_UIO_DEV_NUM   },
57         {OPT_FILE_PREFIX,       1, NULL, OPT_FILE_PREFIX_NUM      },
58         {OPT_HELP,              0, NULL, OPT_HELP_NUM             },
59         {OPT_HUGE_DIR,          1, NULL, OPT_HUGE_DIR_NUM         },
60         {OPT_HUGE_UNLINK,       0, NULL, OPT_HUGE_UNLINK_NUM      },
61         {OPT_LCORES,            1, NULL, OPT_LCORES_NUM           },
62         {OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },
63         {OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
64         {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
65         {OPT_NO_HPET,           0, NULL, OPT_NO_HPET_NUM          },
66         {OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
67         {OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
68         {OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
69         {OPT_IN_MEMORY,         0, NULL, OPT_IN_MEMORY_NUM        },
70         {OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
71         {OPT_PCI_WHITELIST,     1, NULL, OPT_PCI_WHITELIST_NUM    },
72         {OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },
73         {OPT_SOCKET_MEM,        1, NULL, OPT_SOCKET_MEM_NUM       },
74         {OPT_SOCKET_LIMIT,      1, NULL, OPT_SOCKET_LIMIT_NUM     },
75         {OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },
76         {OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },
77         {OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },
78         {OPT_VMWARE_TSC_MAP,    0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
79         {OPT_LEGACY_MEM,        0, NULL, OPT_LEGACY_MEM_NUM       },
80         {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
81         {0,                     0, NULL, 0                        }
82 };
83
84 TAILQ_HEAD(shared_driver_list, shared_driver);
85
86 /* Definition for shared object drivers. */
87 struct shared_driver {
88         TAILQ_ENTRY(shared_driver) next;
89
90         char    name[PATH_MAX];
91         void*   lib_handle;
92 };
93
94 /* List of external loadable drivers */
95 static struct shared_driver_list solib_list =
96 TAILQ_HEAD_INITIALIZER(solib_list);
97
98 /* Default path of external loadable drivers */
99 static const char *default_solib_dir = RTE_EAL_PMD_PATH;
100
101 /*
102  * Stringified version of solib path used by dpdk-pmdinfo.py
103  * Note: PLEASE DO NOT ALTER THIS without making a corresponding
104  * change to usertools/dpdk-pmdinfo.py
105  */
106 static const char dpdk_solib_path[] __attribute__((used)) =
107 "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
108
109 TAILQ_HEAD(device_option_list, device_option);
110
111 struct device_option {
112         TAILQ_ENTRY(device_option) next;
113
114         enum rte_devtype type;
115         char arg[];
116 };
117
118 static struct device_option_list devopt_list =
119 TAILQ_HEAD_INITIALIZER(devopt_list);
120
121 static int master_lcore_parsed;
122 static int mem_parsed;
123 static int core_parsed;
124
125 static int
126 eal_option_device_add(enum rte_devtype type, const char *optarg)
127 {
128         struct device_option *devopt;
129         size_t optlen;
130         int ret;
131
132         optlen = strlen(optarg) + 1;
133         devopt = calloc(1, sizeof(*devopt) + optlen);
134         if (devopt == NULL) {
135                 RTE_LOG(ERR, EAL, "Unable to allocate device option\n");
136                 return -ENOMEM;
137         }
138
139         devopt->type = type;
140         ret = snprintf(devopt->arg, optlen, "%s", optarg);
141         if (ret < 0) {
142                 RTE_LOG(ERR, EAL, "Unable to copy device option\n");
143                 free(devopt);
144                 return -EINVAL;
145         }
146         TAILQ_INSERT_TAIL(&devopt_list, devopt, next);
147         return 0;
148 }
149
150 int
151 eal_option_device_parse(void)
152 {
153         struct device_option *devopt;
154         void *tmp;
155         int ret = 0;
156
157         TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
158                 if (ret == 0) {
159                         ret = rte_devargs_add(devopt->type, devopt->arg);
160                         if (ret)
161                                 RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n",
162                                         devopt->arg);
163                 }
164                 TAILQ_REMOVE(&devopt_list, devopt, next);
165                 free(devopt);
166         }
167         return ret;
168 }
169
170 void
171 eal_reset_internal_config(struct internal_config *internal_cfg)
172 {
173         int i;
174
175         internal_cfg->memory = 0;
176         internal_cfg->force_nrank = 0;
177         internal_cfg->force_nchannel = 0;
178         internal_cfg->hugefile_prefix = HUGEFILE_PREFIX_DEFAULT;
179         internal_cfg->hugepage_dir = NULL;
180         internal_cfg->force_sockets = 0;
181         /* zero out the NUMA config */
182         for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
183                 internal_cfg->socket_mem[i] = 0;
184         internal_cfg->force_socket_limits = 0;
185         /* zero out the NUMA limits config */
186         for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
187                 internal_cfg->socket_limit[i] = 0;
188         /* zero out hugedir descriptors */
189         for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) {
190                 memset(&internal_cfg->hugepage_info[i], 0,
191                                 sizeof(internal_cfg->hugepage_info[0]));
192                 internal_cfg->hugepage_info[i].lock_descriptor = -1;
193         }
194         internal_cfg->base_virtaddr = 0;
195
196         internal_cfg->syslog_facility = LOG_DAEMON;
197
198         /* if set to NONE, interrupt mode is determined automatically */
199         internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
200
201 #ifdef RTE_LIBEAL_USE_HPET
202         internal_cfg->no_hpet = 0;
203 #else
204         internal_cfg->no_hpet = 1;
205 #endif
206         internal_cfg->vmware_tsc_map = 0;
207         internal_cfg->create_uio_dev = 0;
208         internal_cfg->user_mbuf_pool_ops_name = NULL;
209         internal_cfg->init_complete = 0;
210 }
211
212 static int
213 eal_plugin_add(const char *path)
214 {
215         struct shared_driver *solib;
216
217         solib = malloc(sizeof(*solib));
218         if (solib == NULL) {
219                 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
220                 return -1;
221         }
222         memset(solib, 0, sizeof(*solib));
223         strncpy(solib->name, path, PATH_MAX-1);
224         solib->name[PATH_MAX-1] = 0;
225         TAILQ_INSERT_TAIL(&solib_list, solib, next);
226
227         return 0;
228 }
229
230 static int
231 eal_plugindir_init(const char *path)
232 {
233         DIR *d = NULL;
234         struct dirent *dent = NULL;
235         char sopath[PATH_MAX];
236
237         if (path == NULL || *path == '\0')
238                 return 0;
239
240         d = opendir(path);
241         if (d == NULL) {
242                 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
243                         path, strerror(errno));
244                 return -1;
245         }
246
247         while ((dent = readdir(d)) != NULL) {
248                 struct stat sb;
249
250                 snprintf(sopath, PATH_MAX-1, "%s/%s", path, dent->d_name);
251                 sopath[PATH_MAX-1] = 0;
252
253                 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
254                         continue;
255
256                 if (eal_plugin_add(sopath) == -1)
257                         break;
258         }
259
260         closedir(d);
261         /* XXX this ignores failures from readdir() itself */
262         return (dent == NULL) ? 0 : -1;
263 }
264
265 int
266 eal_plugins_init(void)
267 {
268         struct shared_driver *solib = NULL;
269         struct stat sb;
270
271         if (*default_solib_dir != '\0' && stat(default_solib_dir, &sb) == 0 &&
272                                 S_ISDIR(sb.st_mode))
273                 eal_plugin_add(default_solib_dir);
274
275         TAILQ_FOREACH(solib, &solib_list, next) {
276
277                 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
278                         if (eal_plugindir_init(solib->name) == -1) {
279                                 RTE_LOG(ERR, EAL,
280                                         "Cannot init plugin directory %s\n",
281                                         solib->name);
282                                 return -1;
283                         }
284                 } else {
285                         RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
286                                 solib->name);
287                         solib->lib_handle = dlopen(solib->name, RTLD_NOW);
288                         if (solib->lib_handle == NULL) {
289                                 RTE_LOG(ERR, EAL, "%s\n", dlerror());
290                                 return -1;
291                         }
292                 }
293
294         }
295         return 0;
296 }
297
298 /*
299  * Parse the coremask given as argument (hexadecimal string) and fill
300  * the global configuration (core role and core count) with the parsed
301  * value.
302  */
303 static int xdigit2val(unsigned char c)
304 {
305         int val;
306
307         if (isdigit(c))
308                 val = c - '0';
309         else if (isupper(c))
310                 val = c - 'A' + 10;
311         else
312                 val = c - 'a' + 10;
313         return val;
314 }
315
316 static int
317 eal_parse_service_coremask(const char *coremask)
318 {
319         struct rte_config *cfg = rte_eal_get_configuration();
320         int i, j, idx = 0;
321         unsigned int count = 0;
322         char c;
323         int val;
324         uint32_t taken_lcore_count = 0;
325
326         if (coremask == NULL)
327                 return -1;
328         /* Remove all blank characters ahead and after .
329          * Remove 0x/0X if exists.
330          */
331         while (isblank(*coremask))
332                 coremask++;
333         if (coremask[0] == '0' && ((coremask[1] == 'x')
334                 || (coremask[1] == 'X')))
335                 coremask += 2;
336         i = strlen(coremask);
337         while ((i > 0) && isblank(coremask[i - 1]))
338                 i--;
339
340         if (i == 0)
341                 return -1;
342
343         for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
344                 c = coremask[i];
345                 if (isxdigit(c) == 0) {
346                         /* invalid characters */
347                         return -1;
348                 }
349                 val = xdigit2val(c);
350                 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
351                                 j++, idx++) {
352                         if ((1 << j) & val) {
353                                 /* handle master lcore already parsed */
354                                 uint32_t lcore = idx;
355                                 if (master_lcore_parsed &&
356                                                 cfg->master_lcore == lcore) {
357                                         RTE_LOG(ERR, EAL,
358                                                 "lcore %u is master lcore, cannot use as service core\n",
359                                                 idx);
360                                         return -1;
361                                 }
362
363                                 if (!lcore_config[idx].detected) {
364                                         RTE_LOG(ERR, EAL,
365                                                 "lcore %u unavailable\n", idx);
366                                         return -1;
367                                 }
368
369                                 if (cfg->lcore_role[idx] == ROLE_RTE)
370                                         taken_lcore_count++;
371
372                                 lcore_config[idx].core_role = ROLE_SERVICE;
373                                 count++;
374                         }
375                 }
376         }
377
378         for (; i >= 0; i--)
379                 if (coremask[i] != '0')
380                         return -1;
381
382         for (; idx < RTE_MAX_LCORE; idx++)
383                 lcore_config[idx].core_index = -1;
384
385         if (count == 0)
386                 return -1;
387
388         if (core_parsed && taken_lcore_count != count) {
389                 RTE_LOG(WARNING, EAL,
390                         "Not all service cores are in the coremask. "
391                         "Please ensure -c or -l includes service cores\n");
392         }
393
394         cfg->service_lcore_count = count;
395         return 0;
396 }
397
398 static int
399 eal_service_cores_parsed(void)
400 {
401         int idx;
402         for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
403                 if (lcore_config[idx].core_role == ROLE_SERVICE)
404                         return 1;
405         }
406         return 0;
407 }
408
409 static int
410 eal_parse_coremask(const char *coremask)
411 {
412         struct rte_config *cfg = rte_eal_get_configuration();
413         int i, j, idx = 0;
414         unsigned count = 0;
415         char c;
416         int val;
417
418         if (eal_service_cores_parsed())
419                 RTE_LOG(WARNING, EAL,
420                         "Service cores parsed before dataplane cores. "
421                         "Please ensure -c is before -s or -S\n");
422
423         if (coremask == NULL)
424                 return -1;
425         /* Remove all blank characters ahead and after .
426          * Remove 0x/0X if exists.
427          */
428         while (isblank(*coremask))
429                 coremask++;
430         if (coremask[0] == '0' && ((coremask[1] == 'x')
431                 || (coremask[1] == 'X')))
432                 coremask += 2;
433         i = strlen(coremask);
434         while ((i > 0) && isblank(coremask[i - 1]))
435                 i--;
436         if (i == 0)
437                 return -1;
438
439         for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
440                 c = coremask[i];
441                 if (isxdigit(c) == 0) {
442                         /* invalid characters */
443                         return -1;
444                 }
445                 val = xdigit2val(c);
446                 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
447                 {
448                         if ((1 << j) & val) {
449                                 if (!lcore_config[idx].detected) {
450                                         RTE_LOG(ERR, EAL, "lcore %u "
451                                                 "unavailable\n", idx);
452                                         return -1;
453                                 }
454
455                                 cfg->lcore_role[idx] = ROLE_RTE;
456                                 lcore_config[idx].core_index = count;
457                                 count++;
458                         } else {
459                                 cfg->lcore_role[idx] = ROLE_OFF;
460                                 lcore_config[idx].core_index = -1;
461                         }
462                 }
463         }
464         for (; i >= 0; i--)
465                 if (coremask[i] != '0')
466                         return -1;
467         for (; idx < RTE_MAX_LCORE; idx++) {
468                 cfg->lcore_role[idx] = ROLE_OFF;
469                 lcore_config[idx].core_index = -1;
470         }
471         if (count == 0)
472                 return -1;
473         /* Update the count of enabled logical cores of the EAL configuration */
474         cfg->lcore_count = count;
475         return 0;
476 }
477
478 static int
479 eal_parse_service_corelist(const char *corelist)
480 {
481         struct rte_config *cfg = rte_eal_get_configuration();
482         int i, idx = 0;
483         unsigned count = 0;
484         char *end = NULL;
485         int min, max;
486         uint32_t taken_lcore_count = 0;
487
488         if (corelist == NULL)
489                 return -1;
490
491         /* Remove all blank characters ahead and after */
492         while (isblank(*corelist))
493                 corelist++;
494         i = strlen(corelist);
495         while ((i > 0) && isblank(corelist[i - 1]))
496                 i--;
497
498         /* Get list of cores */
499         min = RTE_MAX_LCORE;
500         do {
501                 while (isblank(*corelist))
502                         corelist++;
503                 if (*corelist == '\0')
504                         return -1;
505                 errno = 0;
506                 idx = strtoul(corelist, &end, 10);
507                 if (errno || end == NULL)
508                         return -1;
509                 while (isblank(*end))
510                         end++;
511                 if (*end == '-') {
512                         min = idx;
513                 } else if ((*end == ',') || (*end == '\0')) {
514                         max = idx;
515                         if (min == RTE_MAX_LCORE)
516                                 min = idx;
517                         for (idx = min; idx <= max; idx++) {
518                                 if (cfg->lcore_role[idx] != ROLE_SERVICE) {
519                                         /* handle master lcore already parsed */
520                                         uint32_t lcore = idx;
521                                         if (cfg->master_lcore == lcore &&
522                                                         master_lcore_parsed) {
523                                                 RTE_LOG(ERR, EAL,
524                                                         "Error: lcore %u is master lcore, cannot use as service core\n",
525                                                         idx);
526                                                 return -1;
527                                         }
528                                         if (cfg->lcore_role[idx] == ROLE_RTE)
529                                                 taken_lcore_count++;
530
531                                         lcore_config[idx].core_role =
532                                                         ROLE_SERVICE;
533                                         count++;
534                                 }
535                         }
536                         min = RTE_MAX_LCORE;
537                 } else
538                         return -1;
539                 corelist = end + 1;
540         } while (*end != '\0');
541
542         if (count == 0)
543                 return -1;
544
545         if (core_parsed && taken_lcore_count != count) {
546                 RTE_LOG(WARNING, EAL,
547                         "Not all service cores were in the coremask. "
548                         "Please ensure -c or -l includes service cores\n");
549         }
550
551         return 0;
552 }
553
554 static int
555 eal_parse_corelist(const char *corelist)
556 {
557         struct rte_config *cfg = rte_eal_get_configuration();
558         int i, idx = 0;
559         unsigned count = 0;
560         char *end = NULL;
561         int min, max;
562
563         if (eal_service_cores_parsed())
564                 RTE_LOG(WARNING, EAL,
565                         "Service cores parsed before dataplane cores. "
566                         "Please ensure -l is before -s or -S\n");
567
568         if (corelist == NULL)
569                 return -1;
570
571         /* Remove all blank characters ahead and after */
572         while (isblank(*corelist))
573                 corelist++;
574         i = strlen(corelist);
575         while ((i > 0) && isblank(corelist[i - 1]))
576                 i--;
577
578         /* Reset config */
579         for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
580                 cfg->lcore_role[idx] = ROLE_OFF;
581                 lcore_config[idx].core_index = -1;
582         }
583
584         /* Get list of cores */
585         min = RTE_MAX_LCORE;
586         do {
587                 while (isblank(*corelist))
588                         corelist++;
589                 if (*corelist == '\0')
590                         return -1;
591                 errno = 0;
592                 idx = strtoul(corelist, &end, 10);
593                 if (errno || end == NULL)
594                         return -1;
595                 while (isblank(*end))
596                         end++;
597                 if (*end == '-') {
598                         min = idx;
599                 } else if ((*end == ',') || (*end == '\0')) {
600                         max = idx;
601                         if (min == RTE_MAX_LCORE)
602                                 min = idx;
603                         for (idx = min; idx <= max; idx++) {
604                                 if (cfg->lcore_role[idx] != ROLE_RTE) {
605                                         cfg->lcore_role[idx] = ROLE_RTE;
606                                         lcore_config[idx].core_index = count;
607                                         count++;
608                                 }
609                         }
610                         min = RTE_MAX_LCORE;
611                 } else
612                         return -1;
613                 corelist = end + 1;
614         } while (*end != '\0');
615
616         if (count == 0)
617                 return -1;
618
619         /* Update the count of enabled logical cores of the EAL configuration */
620         cfg->lcore_count = count;
621
622         return 0;
623 }
624
625 /* Changes the lcore id of the master thread */
626 static int
627 eal_parse_master_lcore(const char *arg)
628 {
629         char *parsing_end;
630         struct rte_config *cfg = rte_eal_get_configuration();
631
632         errno = 0;
633         cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
634         if (errno || parsing_end[0] != 0)
635                 return -1;
636         if (cfg->master_lcore >= RTE_MAX_LCORE)
637                 return -1;
638         master_lcore_parsed = 1;
639
640         /* ensure master core is not used as service core */
641         if (lcore_config[cfg->master_lcore].core_role == ROLE_SERVICE) {
642                 RTE_LOG(ERR, EAL,
643                         "Error: Master lcore is used as a service core\n");
644                 return -1;
645         }
646
647         return 0;
648 }
649
650 /*
651  * Parse elem, the elem could be single number/range or '(' ')' group
652  * 1) A single number elem, it's just a simple digit. e.g. 9
653  * 2) A single range elem, two digits with a '-' between. e.g. 2-6
654  * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
655  *    Within group elem, '-' used for a range separator;
656  *                       ',' used for a single number.
657  */
658 static int
659 eal_parse_set(const char *input, uint16_t set[], unsigned num)
660 {
661         unsigned idx;
662         const char *str = input;
663         char *end = NULL;
664         unsigned min, max;
665
666         memset(set, 0, num * sizeof(uint16_t));
667
668         while (isblank(*str))
669                 str++;
670
671         /* only digit or left bracket is qualify for start point */
672         if ((!isdigit(*str) && *str != '(') || *str == '\0')
673                 return -1;
674
675         /* process single number or single range of number */
676         if (*str != '(') {
677                 errno = 0;
678                 idx = strtoul(str, &end, 10);
679                 if (errno || end == NULL || idx >= num)
680                         return -1;
681                 else {
682                         while (isblank(*end))
683                                 end++;
684
685                         min = idx;
686                         max = idx;
687                         if (*end == '-') {
688                                 /* process single <number>-<number> */
689                                 end++;
690                                 while (isblank(*end))
691                                         end++;
692                                 if (!isdigit(*end))
693                                         return -1;
694
695                                 errno = 0;
696                                 idx = strtoul(end, &end, 10);
697                                 if (errno || end == NULL || idx >= num)
698                                         return -1;
699                                 max = idx;
700                                 while (isblank(*end))
701                                         end++;
702                                 if (*end != ',' && *end != '\0')
703                                         return -1;
704                         }
705
706                         if (*end != ',' && *end != '\0' &&
707                             *end != '@')
708                                 return -1;
709
710                         for (idx = RTE_MIN(min, max);
711                              idx <= RTE_MAX(min, max); idx++)
712                                 set[idx] = 1;
713
714                         return end - input;
715                 }
716         }
717
718         /* process set within bracket */
719         str++;
720         while (isblank(*str))
721                 str++;
722         if (*str == '\0')
723                 return -1;
724
725         min = RTE_MAX_LCORE;
726         do {
727
728                 /* go ahead to the first digit */
729                 while (isblank(*str))
730                         str++;
731                 if (!isdigit(*str))
732                         return -1;
733
734                 /* get the digit value */
735                 errno = 0;
736                 idx = strtoul(str, &end, 10);
737                 if (errno || end == NULL || idx >= num)
738                         return -1;
739
740                 /* go ahead to separator '-',',' and ')' */
741                 while (isblank(*end))
742                         end++;
743                 if (*end == '-') {
744                         if (min == RTE_MAX_LCORE)
745                                 min = idx;
746                         else /* avoid continuous '-' */
747                                 return -1;
748                 } else if ((*end == ',') || (*end == ')')) {
749                         max = idx;
750                         if (min == RTE_MAX_LCORE)
751                                 min = idx;
752                         for (idx = RTE_MIN(min, max);
753                              idx <= RTE_MAX(min, max); idx++)
754                                 set[idx] = 1;
755
756                         min = RTE_MAX_LCORE;
757                 } else
758                         return -1;
759
760                 str = end + 1;
761         } while (*end != '\0' && *end != ')');
762
763         /*
764          * to avoid failure that tail blank makes end character check fail
765          * in eal_parse_lcores( )
766          */
767         while (isblank(*str))
768                 str++;
769
770         return str - input;
771 }
772
773 /* convert from set array to cpuset bitmap */
774 static int
775 convert_to_cpuset(rte_cpuset_t *cpusetp,
776               uint16_t *set, unsigned num)
777 {
778         unsigned idx;
779
780         CPU_ZERO(cpusetp);
781
782         for (idx = 0; idx < num; idx++) {
783                 if (!set[idx])
784                         continue;
785
786                 if (!lcore_config[idx].detected) {
787                         RTE_LOG(ERR, EAL, "core %u "
788                                 "unavailable\n", idx);
789                         return -1;
790                 }
791
792                 CPU_SET(idx, cpusetp);
793         }
794
795         return 0;
796 }
797
798 /*
799  * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
800  * lcores, cpus could be a single digit/range or a group.
801  * '(' and ')' are necessary if it's a group.
802  * If not supply '@cpus', the value of cpus uses the same as lcores.
803  * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
804  *   lcore 0 runs on cpuset 0x41 (cpu 0,6)
805  *   lcore 1 runs on cpuset 0x2 (cpu 1)
806  *   lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
807  *   lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
808  *   lcore 6 runs on cpuset 0x41 (cpu 0,6)
809  *   lcore 7 runs on cpuset 0x80 (cpu 7)
810  *   lcore 8 runs on cpuset 0x100 (cpu 8)
811  */
812 static int
813 eal_parse_lcores(const char *lcores)
814 {
815         struct rte_config *cfg = rte_eal_get_configuration();
816         static uint16_t set[RTE_MAX_LCORE];
817         unsigned idx = 0;
818         unsigned count = 0;
819         const char *lcore_start = NULL;
820         const char *end = NULL;
821         int offset;
822         rte_cpuset_t cpuset;
823         int lflags;
824         int ret = -1;
825
826         if (lcores == NULL)
827                 return -1;
828
829         /* Remove all blank characters ahead and after */
830         while (isblank(*lcores))
831                 lcores++;
832
833         CPU_ZERO(&cpuset);
834
835         /* Reset lcore config */
836         for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
837                 cfg->lcore_role[idx] = ROLE_OFF;
838                 lcore_config[idx].core_index = -1;
839                 CPU_ZERO(&lcore_config[idx].cpuset);
840         }
841
842         /* Get list of cores */
843         do {
844                 while (isblank(*lcores))
845                         lcores++;
846                 if (*lcores == '\0')
847                         goto err;
848
849                 lflags = 0;
850
851                 /* record lcore_set start point */
852                 lcore_start = lcores;
853
854                 /* go across a complete bracket */
855                 if (*lcore_start == '(') {
856                         lcores += strcspn(lcores, ")");
857                         if (*lcores++ == '\0')
858                                 goto err;
859                 }
860
861                 /* scan the separator '@', ','(next) or '\0'(finish) */
862                 lcores += strcspn(lcores, "@,");
863
864                 if (*lcores == '@') {
865                         /* explicit assign cpu_set */
866                         offset = eal_parse_set(lcores + 1, set, RTE_DIM(set));
867                         if (offset < 0)
868                                 goto err;
869
870                         /* prepare cpu_set and update the end cursor */
871                         if (0 > convert_to_cpuset(&cpuset,
872                                                   set, RTE_DIM(set)))
873                                 goto err;
874                         end = lcores + 1 + offset;
875                 } else { /* ',' or '\0' */
876                         /* haven't given cpu_set, current loop done */
877                         end = lcores;
878
879                         /* go back to check <number>-<number> */
880                         offset = strcspn(lcore_start, "(-");
881                         if (offset < (end - lcore_start) &&
882                             *(lcore_start + offset) != '(')
883                                 lflags = 1;
884                 }
885
886                 if (*end != ',' && *end != '\0')
887                         goto err;
888
889                 /* parse lcore_set from start point */
890                 if (0 > eal_parse_set(lcore_start, set, RTE_DIM(set)))
891                         goto err;
892
893                 /* without '@', by default using lcore_set as cpu_set */
894                 if (*lcores != '@' &&
895                     0 > convert_to_cpuset(&cpuset, set, RTE_DIM(set)))
896                         goto err;
897
898                 /* start to update lcore_set */
899                 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
900                         if (!set[idx])
901                                 continue;
902
903                         if (cfg->lcore_role[idx] != ROLE_RTE) {
904                                 lcore_config[idx].core_index = count;
905                                 cfg->lcore_role[idx] = ROLE_RTE;
906                                 count++;
907                         }
908
909                         if (lflags) {
910                                 CPU_ZERO(&cpuset);
911                                 CPU_SET(idx, &cpuset);
912                         }
913                         rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
914                                    sizeof(rte_cpuset_t));
915                 }
916
917                 lcores = end + 1;
918         } while (*end != '\0');
919
920         if (count == 0)
921                 goto err;
922
923         cfg->lcore_count = count;
924         ret = 0;
925
926 err:
927
928         return ret;
929 }
930
931 static int
932 eal_parse_syslog(const char *facility, struct internal_config *conf)
933 {
934         int i;
935         static const struct {
936                 const char *name;
937                 int value;
938         } map[] = {
939                 { "auth", LOG_AUTH },
940                 { "cron", LOG_CRON },
941                 { "daemon", LOG_DAEMON },
942                 { "ftp", LOG_FTP },
943                 { "kern", LOG_KERN },
944                 { "lpr", LOG_LPR },
945                 { "mail", LOG_MAIL },
946                 { "news", LOG_NEWS },
947                 { "syslog", LOG_SYSLOG },
948                 { "user", LOG_USER },
949                 { "uucp", LOG_UUCP },
950                 { "local0", LOG_LOCAL0 },
951                 { "local1", LOG_LOCAL1 },
952                 { "local2", LOG_LOCAL2 },
953                 { "local3", LOG_LOCAL3 },
954                 { "local4", LOG_LOCAL4 },
955                 { "local5", LOG_LOCAL5 },
956                 { "local6", LOG_LOCAL6 },
957                 { "local7", LOG_LOCAL7 },
958                 { NULL, 0 }
959         };
960
961         for (i = 0; map[i].name; i++) {
962                 if (!strcmp(facility, map[i].name)) {
963                         conf->syslog_facility = map[i].value;
964                         return 0;
965                 }
966         }
967         return -1;
968 }
969
970 static int
971 eal_parse_log_priority(const char *level)
972 {
973         static const char * const levels[] = {
974                 [RTE_LOG_EMERG]   = "emergency",
975                 [RTE_LOG_ALERT]   = "alert",
976                 [RTE_LOG_CRIT]    = "critical",
977                 [RTE_LOG_ERR]     = "error",
978                 [RTE_LOG_WARNING] = "warning",
979                 [RTE_LOG_NOTICE]  = "notice",
980                 [RTE_LOG_INFO]    = "info",
981                 [RTE_LOG_DEBUG]   = "debug",
982         };
983         size_t len = strlen(level);
984         unsigned long tmp;
985         char *end;
986         unsigned int i;
987
988         if (len == 0)
989                 return -1;
990
991         /* look for named values, skip 0 which is not a valid level */
992         for (i = 1; i < RTE_DIM(levels); i++) {
993                 if (strncmp(levels[i], level, len) == 0)
994                         return i;
995         }
996
997         /* not a string, maybe it is numeric */
998         errno = 0;
999         tmp = strtoul(level, &end, 0);
1000
1001         /* check for errors */
1002         if (errno != 0 || end == NULL || *end != '\0' ||
1003             tmp >= UINT32_MAX)
1004                 return -1;
1005
1006         return tmp;
1007 }
1008
1009 static int
1010 eal_parse_log_level(const char *arg)
1011 {
1012         const char *pattern = NULL;
1013         const char *regex = NULL;
1014         char *str, *level;
1015         int priority;
1016
1017         str = strdup(arg);
1018         if (str == NULL)
1019                 return -1;
1020
1021         if ((level = strchr(str, ','))) {
1022                 regex = str;
1023                 *level++ = '\0';
1024         } else if ((level = strchr(str, ':'))) {
1025                 pattern = str;
1026                 *level++ = '\0';
1027         } else {
1028                 level = str;
1029         }
1030
1031         priority = eal_parse_log_priority(level);
1032         if (priority < 0) {
1033                 fprintf(stderr, "invalid log priority: %s\n", level);
1034                 goto fail;
1035         }
1036
1037         if (regex) {
1038                 if (rte_log_set_level_regexp(regex, priority) < 0) {
1039                         fprintf(stderr, "cannot set log level %s,%d\n",
1040                                 pattern, priority);
1041                         goto fail;
1042                 }
1043                 if (rte_log_save_regexp(regex, priority) < 0)
1044                         goto fail;
1045         } else if (pattern) {
1046                 if (rte_log_set_level_pattern(pattern, priority) < 0) {
1047                         fprintf(stderr, "cannot set log level %s:%d\n",
1048                                 pattern, priority);
1049                         goto fail;
1050                 }
1051                 if (rte_log_save_pattern(pattern, priority) < 0)
1052                         goto fail;
1053         } else {
1054                 rte_log_set_global_level(priority);
1055         }
1056
1057         free(str);
1058         return 0;
1059
1060 fail:
1061         free(str);
1062         return -1;
1063 }
1064
1065 static enum rte_proc_type_t
1066 eal_parse_proc_type(const char *arg)
1067 {
1068         if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
1069                 return RTE_PROC_PRIMARY;
1070         if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
1071                 return RTE_PROC_SECONDARY;
1072         if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
1073                 return RTE_PROC_AUTO;
1074
1075         return RTE_PROC_INVALID;
1076 }
1077
1078 int
1079 eal_parse_common_option(int opt, const char *optarg,
1080                         struct internal_config *conf)
1081 {
1082         static int b_used;
1083         static int w_used;
1084
1085         switch (opt) {
1086         /* blacklist */
1087         case 'b':
1088                 if (w_used)
1089                         goto bw_used;
1090                 if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI,
1091                                 optarg) < 0) {
1092                         return -1;
1093                 }
1094                 b_used = 1;
1095                 break;
1096         /* whitelist */
1097         case 'w':
1098                 if (b_used)
1099                         goto bw_used;
1100                 if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI,
1101                                 optarg) < 0) {
1102                         return -1;
1103                 }
1104                 w_used = 1;
1105                 break;
1106         /* coremask */
1107         case 'c':
1108                 if (eal_parse_coremask(optarg) < 0) {
1109                         RTE_LOG(ERR, EAL, "invalid coremask\n");
1110                         return -1;
1111                 }
1112
1113                 if (core_parsed) {
1114                         RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s) is set!\n",
1115                                 (core_parsed == LCORE_OPT_LST) ? "-l" :
1116                                 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1117                                 "-c");
1118                         return -1;
1119                 }
1120
1121                 core_parsed = LCORE_OPT_MSK;
1122                 break;
1123         /* corelist */
1124         case 'l':
1125                 if (eal_parse_corelist(optarg) < 0) {
1126                         RTE_LOG(ERR, EAL, "invalid core list\n");
1127                         return -1;
1128                 }
1129
1130                 if (core_parsed) {
1131                         RTE_LOG(ERR, EAL, "Option -l is ignored, because (%s) is set!\n",
1132                                 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1133                                 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1134                                 "-l");
1135                         return -1;
1136                 }
1137
1138                 core_parsed = LCORE_OPT_LST;
1139                 break;
1140         /* service coremask */
1141         case 's':
1142                 if (eal_parse_service_coremask(optarg) < 0) {
1143                         RTE_LOG(ERR, EAL, "invalid service coremask\n");
1144                         return -1;
1145                 }
1146                 break;
1147         /* service corelist */
1148         case 'S':
1149                 if (eal_parse_service_corelist(optarg) < 0) {
1150                         RTE_LOG(ERR, EAL, "invalid service core list\n");
1151                         return -1;
1152                 }
1153                 break;
1154         /* size of memory */
1155         case 'm':
1156                 conf->memory = atoi(optarg);
1157                 conf->memory *= 1024ULL;
1158                 conf->memory *= 1024ULL;
1159                 mem_parsed = 1;
1160                 break;
1161         /* force number of channels */
1162         case 'n':
1163                 conf->force_nchannel = atoi(optarg);
1164                 if (conf->force_nchannel == 0) {
1165                         RTE_LOG(ERR, EAL, "invalid channel number\n");
1166                         return -1;
1167                 }
1168                 break;
1169         /* force number of ranks */
1170         case 'r':
1171                 conf->force_nrank = atoi(optarg);
1172                 if (conf->force_nrank == 0 ||
1173                     conf->force_nrank > 16) {
1174                         RTE_LOG(ERR, EAL, "invalid rank number\n");
1175                         return -1;
1176                 }
1177                 break;
1178         /* force loading of external driver */
1179         case 'd':
1180                 if (eal_plugin_add(optarg) == -1)
1181                         return -1;
1182                 break;
1183         case 'v':
1184                 /* since message is explicitly requested by user, we
1185                  * write message at highest log level so it can always
1186                  * be seen
1187                  * even if info or warning messages are disabled */
1188                 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
1189                 break;
1190
1191         /* long options */
1192         case OPT_HUGE_UNLINK_NUM:
1193                 conf->hugepage_unlink = 1;
1194                 break;
1195
1196         case OPT_NO_HUGE_NUM:
1197                 conf->no_hugetlbfs = 1;
1198                 /* no-huge is legacy mem */
1199                 conf->legacy_mem = 1;
1200                 break;
1201
1202         case OPT_NO_PCI_NUM:
1203                 conf->no_pci = 1;
1204                 break;
1205
1206         case OPT_NO_HPET_NUM:
1207                 conf->no_hpet = 1;
1208                 break;
1209
1210         case OPT_VMWARE_TSC_MAP_NUM:
1211                 conf->vmware_tsc_map = 1;
1212                 break;
1213
1214         case OPT_NO_SHCONF_NUM:
1215                 conf->no_shconf = 1;
1216                 break;
1217
1218         case OPT_IN_MEMORY_NUM:
1219                 conf->in_memory = 1;
1220                 /* in-memory is a superset of noshconf and huge-unlink */
1221                 conf->no_shconf = 1;
1222                 conf->hugepage_unlink = 1;
1223                 break;
1224
1225         case OPT_PROC_TYPE_NUM:
1226                 conf->process_type = eal_parse_proc_type(optarg);
1227                 break;
1228
1229         case OPT_MASTER_LCORE_NUM:
1230                 if (eal_parse_master_lcore(optarg) < 0) {
1231                         RTE_LOG(ERR, EAL, "invalid parameter for --"
1232                                         OPT_MASTER_LCORE "\n");
1233                         return -1;
1234                 }
1235                 break;
1236
1237         case OPT_VDEV_NUM:
1238                 if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1239                                 optarg) < 0) {
1240                         return -1;
1241                 }
1242                 break;
1243
1244         case OPT_SYSLOG_NUM:
1245                 if (eal_parse_syslog(optarg, conf) < 0) {
1246                         RTE_LOG(ERR, EAL, "invalid parameters for --"
1247                                         OPT_SYSLOG "\n");
1248                         return -1;
1249                 }
1250                 break;
1251
1252         case OPT_LOG_LEVEL_NUM: {
1253                 if (eal_parse_log_level(optarg) < 0) {
1254                         RTE_LOG(ERR, EAL,
1255                                 "invalid parameters for --"
1256                                 OPT_LOG_LEVEL "\n");
1257                         return -1;
1258                 }
1259                 break;
1260         }
1261         case OPT_LCORES_NUM:
1262                 if (eal_parse_lcores(optarg) < 0) {
1263                         RTE_LOG(ERR, EAL, "invalid parameter for --"
1264                                 OPT_LCORES "\n");
1265                         return -1;
1266                 }
1267
1268                 if (core_parsed) {
1269                         RTE_LOG(ERR, EAL, "Option --lcore is ignored, because (%s) is set!\n",
1270                                 (core_parsed == LCORE_OPT_LST) ? "-l" :
1271                                 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1272                                 "--lcore");
1273                         return -1;
1274                 }
1275
1276                 core_parsed = LCORE_OPT_MAP;
1277                 break;
1278         case OPT_LEGACY_MEM_NUM:
1279                 conf->legacy_mem = 1;
1280                 break;
1281         case OPT_SINGLE_FILE_SEGMENTS_NUM:
1282                 conf->single_file_segments = 1;
1283                 break;
1284
1285         /* don't know what to do, leave this to caller */
1286         default:
1287                 return 1;
1288
1289         }
1290
1291         return 0;
1292 bw_used:
1293         RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
1294                 "cannot be used at the same time\n");
1295         return -1;
1296 }
1297
1298 static void
1299 eal_auto_detect_cores(struct rte_config *cfg)
1300 {
1301         unsigned int lcore_id;
1302         unsigned int removed = 0;
1303         rte_cpuset_t affinity_set;
1304         pthread_t tid = pthread_self();
1305
1306         if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t),
1307                                 &affinity_set) < 0)
1308                 CPU_ZERO(&affinity_set);
1309
1310         for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1311                 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1312                     !CPU_ISSET(lcore_id, &affinity_set)) {
1313                         cfg->lcore_role[lcore_id] = ROLE_OFF;
1314                         removed++;
1315                 }
1316         }
1317
1318         cfg->lcore_count -= removed;
1319 }
1320
1321 int
1322 eal_adjust_config(struct internal_config *internal_cfg)
1323 {
1324         int i;
1325         struct rte_config *cfg = rte_eal_get_configuration();
1326
1327         if (!core_parsed)
1328                 eal_auto_detect_cores(cfg);
1329
1330         if (internal_config.process_type == RTE_PROC_AUTO)
1331                 internal_config.process_type = eal_proc_type_detect();
1332
1333         /* default master lcore is the first one */
1334         if (!master_lcore_parsed) {
1335                 cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
1336                 lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
1337         }
1338
1339         /* if no memory amounts were requested, this will result in 0 and
1340          * will be overridden later, right after eal_hugepage_info_init() */
1341         for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1342                 internal_cfg->memory += internal_cfg->socket_mem[i];
1343
1344         return 0;
1345 }
1346
1347 int
1348 eal_check_common_options(struct internal_config *internal_cfg)
1349 {
1350         struct rte_config *cfg = rte_eal_get_configuration();
1351
1352         if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
1353                 RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
1354                 return -1;
1355         }
1356
1357         if (internal_cfg->process_type == RTE_PROC_INVALID) {
1358                 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1359                 return -1;
1360         }
1361         if (index(internal_cfg->hugefile_prefix, '%') != NULL) {
1362                 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1363                         "option\n");
1364                 return -1;
1365         }
1366         if (mem_parsed && internal_cfg->force_sockets == 1) {
1367                 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1368                         "be specified at the same time\n");
1369                 return -1;
1370         }
1371         if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1372                 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1373                         "be specified together with --"OPT_NO_HUGE"\n");
1374                 return -1;
1375         }
1376         if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink &&
1377                         !internal_cfg->in_memory) {
1378                 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1379                         "be specified together with --"OPT_NO_HUGE"\n");
1380                 return -1;
1381         }
1382         if (internal_config.force_socket_limits && internal_config.legacy_mem) {
1383                 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_LIMIT
1384                         " is only supported in non-legacy memory mode\n");
1385         }
1386         if (internal_cfg->single_file_segments &&
1387                         internal_cfg->hugepage_unlink) {
1388                 RTE_LOG(ERR, EAL, "Option --"OPT_SINGLE_FILE_SEGMENTS" is "
1389                         "not compatible with neither --"OPT_IN_MEMORY" nor "
1390                         "--"OPT_HUGE_UNLINK"\n");
1391                 return -1;
1392         }
1393
1394         return 0;
1395 }
1396
1397 void
1398 eal_common_usage(void)
1399 {
1400         printf("[options]\n\n"
1401                "EAL common options:\n"
1402                "  -c COREMASK         Hexadecimal bitmask of cores to run on\n"
1403                "  -l CORELIST         List of cores to run on\n"
1404                "                      The argument format is <c1>[-c2][,c3[-c4],...]\n"
1405                "                      where c1, c2, etc are core indexes between 0 and %d\n"
1406                "  --"OPT_LCORES" COREMAP    Map lcore set to physical cpu set\n"
1407                "                      The argument format is\n"
1408                "                            '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
1409                "                      lcores and cpus list are grouped by '(' and ')'\n"
1410                "                      Within the group, '-' is used for range separator,\n"
1411                "                      ',' is used for single number separator.\n"
1412                "                      '( )' can be omitted for single element group,\n"
1413                "                      '@' can be omitted if cpus and lcores have the same value\n"
1414                "  -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
1415                "  --"OPT_MASTER_LCORE" ID   Core ID that is used as master\n"
1416                "  --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
1417                "  -n CHANNELS         Number of memory channels\n"
1418                "  -m MB               Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
1419                "  -r RANKS            Force number of memory ranks (don't detect)\n"
1420                "  -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
1421                "                      Prevent EAL from using this PCI device. The argument\n"
1422                "                      format is <domain:bus:devid.func>.\n"
1423                "  -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
1424                "                      Only use the specified PCI devices. The argument format\n"
1425                "                      is <[domain:]bus:devid.func>. This option can be present\n"
1426                "                      several times (once per device).\n"
1427                "                      [NOTE: PCI whitelist cannot be used with -b option]\n"
1428                "  --"OPT_VDEV"              Add a virtual device.\n"
1429                "                      The argument format is <driver><id>[,key=val,...]\n"
1430                "                      (ex: --vdev=net_pcap0,iface=eth2).\n"
1431                "  -d LIB.so|DIR       Add a driver or driver directory\n"
1432                "                      (can be used multiple times)\n"
1433                "  --"OPT_VMWARE_TSC_MAP"    Use VMware TSC map instead of native RDTSC\n"
1434                "  --"OPT_PROC_TYPE"         Type of this process (primary|secondary|auto)\n"
1435                "  --"OPT_SYSLOG"            Set syslog facility\n"
1436                "  --"OPT_LOG_LEVEL"=<int>   Set global log level\n"
1437                "  --"OPT_LOG_LEVEL"=<type-match>:<int>\n"
1438                "                      Set specific log level\n"
1439                "  -v                  Display version information on startup\n"
1440                "  -h, --help          This help\n"
1441                "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
1442                "                      disable secondary process support\n"
1443                "\nEAL options for DEBUG use only:\n"
1444                "  --"OPT_HUGE_UNLINK"       Unlink hugepage files after init\n"
1445                "  --"OPT_NO_HUGE"           Use malloc instead of hugetlbfs\n"
1446                "  --"OPT_NO_PCI"            Disable PCI\n"
1447                "  --"OPT_NO_HPET"           Disable HPET\n"
1448                "  --"OPT_NO_SHCONF"         No shared config (mmap'd files)\n"
1449                "\n", RTE_MAX_LCORE);
1450 }