60f0e4c69b550ed389282d703249b91d407586c4
[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 #ifndef RTE_EXEC_ENV_WINDOWS
10 #include <syslog.h>
11 #endif
12 #include <ctype.h>
13 #include <limits.h>
14 #include <errno.h>
15 #include <getopt.h>
16 #ifndef RTE_EXEC_ENV_WINDOWS
17 #include <dlfcn.h>
18 #include <libgen.h>
19 #endif
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #ifndef RTE_EXEC_ENV_WINDOWS
23 #include <dirent.h>
24 #endif
25
26 #include <rte_string_fns.h>
27 #include <rte_eal.h>
28 #include <rte_log.h>
29 #include <rte_lcore.h>
30 #include <rte_memory.h>
31 #include <rte_tailq.h>
32 #include <rte_version.h>
33 #include <rte_devargs.h>
34 #include <rte_memcpy.h>
35 #ifndef RTE_EXEC_ENV_WINDOWS
36 #include <rte_telemetry.h>
37 #endif
38 #include <rte_vect.h>
39
40 #include "eal_internal_cfg.h"
41 #include "eal_options.h"
42 #include "eal_filesystem.h"
43 #include "eal_private.h"
44 #ifndef RTE_EXEC_ENV_WINDOWS
45 #include "eal_trace.h"
46 #endif
47
48 #define BITS_PER_HEX 4
49 #define LCORE_OPT_LST 1
50 #define LCORE_OPT_MSK 2
51 #define LCORE_OPT_MAP 3
52
53 const char
54 eal_short_options[] =
55         "b:" /* pci-blacklist */
56         "c:" /* coremask */
57         "s:" /* service coremask */
58         "d:" /* driver */
59         "h"  /* help */
60         "l:" /* corelist */
61         "S:" /* service corelist */
62         "m:" /* memory size */
63         "n:" /* memory channels */
64         "r:" /* memory ranks */
65         "v"  /* version */
66         "w:" /* pci-whitelist */
67         ;
68
69 const struct option
70 eal_long_options[] = {
71         {OPT_BASE_VIRTADDR,     1, NULL, OPT_BASE_VIRTADDR_NUM    },
72         {OPT_CREATE_UIO_DEV,    0, NULL, OPT_CREATE_UIO_DEV_NUM   },
73         {OPT_FILE_PREFIX,       1, NULL, OPT_FILE_PREFIX_NUM      },
74         {OPT_HELP,              0, NULL, OPT_HELP_NUM             },
75         {OPT_HUGE_DIR,          1, NULL, OPT_HUGE_DIR_NUM         },
76         {OPT_HUGE_UNLINK,       0, NULL, OPT_HUGE_UNLINK_NUM      },
77         {OPT_IOVA_MODE,         1, NULL, OPT_IOVA_MODE_NUM        },
78         {OPT_LCORES,            1, NULL, OPT_LCORES_NUM           },
79         {OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },
80         {OPT_TRACE,             1, NULL, OPT_TRACE_NUM            },
81         {OPT_TRACE_DIR,         1, NULL, OPT_TRACE_DIR_NUM        },
82         {OPT_TRACE_BUF_SIZE,    1, NULL, OPT_TRACE_BUF_SIZE_NUM   },
83         {OPT_TRACE_MODE,        1, NULL, OPT_TRACE_MODE_NUM       },
84         {OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
85         {OPT_MBUF_POOL_OPS_NAME, 1, NULL, OPT_MBUF_POOL_OPS_NAME_NUM},
86         {OPT_NO_HPET,           0, NULL, OPT_NO_HPET_NUM          },
87         {OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
88         {OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
89         {OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
90         {OPT_IN_MEMORY,         0, NULL, OPT_IN_MEMORY_NUM        },
91         {OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
92         {OPT_PCI_WHITELIST,     1, NULL, OPT_PCI_WHITELIST_NUM    },
93         {OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },
94         {OPT_SOCKET_MEM,        1, NULL, OPT_SOCKET_MEM_NUM       },
95         {OPT_SOCKET_LIMIT,      1, NULL, OPT_SOCKET_LIMIT_NUM     },
96         {OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },
97         {OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },
98         {OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },
99         {OPT_VFIO_VF_TOKEN,     1, NULL, OPT_VFIO_VF_TOKEN_NUM    },
100         {OPT_VMWARE_TSC_MAP,    0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
101         {OPT_LEGACY_MEM,        0, NULL, OPT_LEGACY_MEM_NUM       },
102         {OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
103         {OPT_MATCH_ALLOCATIONS, 0, NULL, OPT_MATCH_ALLOCATIONS_NUM},
104         {OPT_TELEMETRY,         0, NULL, OPT_TELEMETRY_NUM        },
105         {OPT_NO_TELEMETRY,      0, NULL, OPT_NO_TELEMETRY_NUM     },
106         {OPT_FORCE_MAX_SIMD_BITWIDTH, 1, NULL, OPT_FORCE_MAX_SIMD_BITWIDTH_NUM},
107         {0,                     0, NULL, 0                        }
108 };
109
110 TAILQ_HEAD(shared_driver_list, shared_driver);
111
112 /* Definition for shared object drivers. */
113 struct shared_driver {
114         TAILQ_ENTRY(shared_driver) next;
115
116         char    name[PATH_MAX];
117         void*   lib_handle;
118 };
119
120 /* List of external loadable drivers */
121 static struct shared_driver_list solib_list =
122 TAILQ_HEAD_INITIALIZER(solib_list);
123
124 #ifndef RTE_EXEC_ENV_WINDOWS
125 /* Default path of external loadable drivers */
126 static const char *default_solib_dir = RTE_EAL_PMD_PATH;
127 #endif
128
129 /*
130  * Stringified version of solib path used by dpdk-pmdinfo.py
131  * Note: PLEASE DO NOT ALTER THIS without making a corresponding
132  * change to usertools/dpdk-pmdinfo.py
133  */
134 static const char dpdk_solib_path[] __rte_used =
135 "DPDK_PLUGIN_PATH=" RTE_EAL_PMD_PATH;
136
137 TAILQ_HEAD(device_option_list, device_option);
138
139 struct device_option {
140         TAILQ_ENTRY(device_option) next;
141
142         enum rte_devtype type;
143         char arg[];
144 };
145
146 static struct device_option_list devopt_list =
147 TAILQ_HEAD_INITIALIZER(devopt_list);
148
149 static int master_lcore_parsed;
150 static int mem_parsed;
151 static int core_parsed;
152
153 /* Allow the application to print its usage message too if set */
154 static rte_usage_hook_t rte_application_usage_hook;
155
156 /* Returns rte_usage_hook_t */
157 rte_usage_hook_t
158 eal_get_application_usage_hook(void)
159 {
160         return rte_application_usage_hook;
161 }
162
163 /* Set a per-application usage message */
164 rte_usage_hook_t
165 rte_set_application_usage_hook(rte_usage_hook_t usage_func)
166 {
167         rte_usage_hook_t old_func;
168
169         /* Will be NULL on the first call to denote the last usage routine. */
170         old_func = rte_application_usage_hook;
171         rte_application_usage_hook = usage_func;
172
173         return old_func;
174 }
175
176 #ifndef RTE_EXEC_ENV_WINDOWS
177 static char **eal_args;
178 static char **eal_app_args;
179
180 #define EAL_PARAM_REQ "/eal/params"
181 #define EAL_APP_PARAM_REQ "/eal/app_params"
182
183 /* callback handler for telemetry library to report out EAL flags */
184 int
185 handle_eal_info_request(const char *cmd, const char *params __rte_unused,
186                 struct rte_tel_data *d)
187 {
188         char **args;
189         int used = 0;
190         int i = 0;
191
192         if (strcmp(cmd, EAL_PARAM_REQ) == 0)
193                 args = eal_args;
194         else
195                 args = eal_app_args;
196
197         rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
198         if (args == NULL || args[0] == NULL)
199                 return 0;
200
201         for ( ; args[i] != NULL; i++)
202                 used = rte_tel_data_add_array_string(d, args[i]);
203         return used;
204 }
205
206 int
207 eal_save_args(int argc, char **argv)
208 {
209         int i, j;
210
211         rte_telemetry_register_cmd(EAL_PARAM_REQ, handle_eal_info_request,
212                         "Returns EAL commandline parameters used. Takes no parameters");
213         rte_telemetry_register_cmd(EAL_APP_PARAM_REQ, handle_eal_info_request,
214                         "Returns app commandline parameters used. Takes no parameters");
215
216         /* clone argv to report out later. We overprovision, but
217          * this does not waste huge amounts of memory
218          */
219         eal_args = calloc(argc + 1, sizeof(*eal_args));
220         if (eal_args == NULL)
221                 return -1;
222
223         for (i = 0; i < argc; i++) {
224                 eal_args[i] = strdup(argv[i]);
225                 if (strcmp(argv[i], "--") == 0)
226                         break;
227         }
228         eal_args[i++] = NULL; /* always finish with NULL */
229
230         /* allow reporting of any app args we know about too */
231         if (i >= argc)
232                 return 0;
233
234         eal_app_args = calloc(argc - i + 1, sizeof(*eal_args));
235         if (eal_app_args == NULL)
236                 return -1;
237
238         for (j = 0; i < argc; j++, i++)
239                 eal_app_args[j] = strdup(argv[i]);
240         eal_app_args[j] = NULL;
241
242         return 0;
243 }
244 #endif
245
246 static int
247 eal_option_device_add(enum rte_devtype type, const char *optarg)
248 {
249         struct device_option *devopt;
250         size_t optlen;
251         int ret;
252
253         optlen = strlen(optarg) + 1;
254         devopt = calloc(1, sizeof(*devopt) + optlen);
255         if (devopt == NULL) {
256                 RTE_LOG(ERR, EAL, "Unable to allocate device option\n");
257                 return -ENOMEM;
258         }
259
260         devopt->type = type;
261         ret = strlcpy(devopt->arg, optarg, optlen);
262         if (ret < 0) {
263                 RTE_LOG(ERR, EAL, "Unable to copy device option\n");
264                 free(devopt);
265                 return -EINVAL;
266         }
267         TAILQ_INSERT_TAIL(&devopt_list, devopt, next);
268         return 0;
269 }
270
271 int
272 eal_option_device_parse(void)
273 {
274         struct device_option *devopt;
275         void *tmp;
276         int ret = 0;
277
278         TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) {
279                 if (ret == 0) {
280                         ret = rte_devargs_add(devopt->type, devopt->arg);
281                         if (ret)
282                                 RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n",
283                                         devopt->arg);
284                 }
285                 TAILQ_REMOVE(&devopt_list, devopt, next);
286                 free(devopt);
287         }
288         return ret;
289 }
290
291 const char *
292 eal_get_hugefile_prefix(void)
293 {
294         const struct internal_config *internal_conf =
295                 eal_get_internal_configuration();
296
297         if (internal_conf->hugefile_prefix != NULL)
298                 return internal_conf->hugefile_prefix;
299         return HUGEFILE_PREFIX_DEFAULT;
300 }
301
302 void
303 eal_reset_internal_config(struct internal_config *internal_cfg)
304 {
305         int i;
306
307         internal_cfg->memory = 0;
308         internal_cfg->force_nrank = 0;
309         internal_cfg->force_nchannel = 0;
310         internal_cfg->hugefile_prefix = NULL;
311         internal_cfg->hugepage_dir = NULL;
312         internal_cfg->force_sockets = 0;
313         /* zero out the NUMA config */
314         for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
315                 internal_cfg->socket_mem[i] = 0;
316         internal_cfg->force_socket_limits = 0;
317         /* zero out the NUMA limits config */
318         for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
319                 internal_cfg->socket_limit[i] = 0;
320         /* zero out hugedir descriptors */
321         for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) {
322                 memset(&internal_cfg->hugepage_info[i], 0,
323                                 sizeof(internal_cfg->hugepage_info[0]));
324                 internal_cfg->hugepage_info[i].lock_descriptor = -1;
325         }
326         internal_cfg->base_virtaddr = 0;
327
328 #ifdef LOG_DAEMON
329         internal_cfg->syslog_facility = LOG_DAEMON;
330 #endif
331
332         /* if set to NONE, interrupt mode is determined automatically */
333         internal_cfg->vfio_intr_mode = RTE_INTR_MODE_NONE;
334         memset(internal_cfg->vfio_vf_token, 0,
335                         sizeof(internal_cfg->vfio_vf_token));
336
337 #ifdef RTE_LIBEAL_USE_HPET
338         internal_cfg->no_hpet = 0;
339 #else
340         internal_cfg->no_hpet = 1;
341 #endif
342         internal_cfg->vmware_tsc_map = 0;
343         internal_cfg->create_uio_dev = 0;
344         internal_cfg->iova_mode = RTE_IOVA_DC;
345         internal_cfg->user_mbuf_pool_ops_name = NULL;
346         CPU_ZERO(&internal_cfg->ctrl_cpuset);
347         internal_cfg->init_complete = 0;
348         internal_cfg->max_simd_bitwidth.bitwidth = RTE_VECT_DEFAULT_SIMD_BITWIDTH;
349         internal_cfg->max_simd_bitwidth.forced = 0;
350 }
351
352 static int
353 eal_plugin_add(const char *path)
354 {
355         struct shared_driver *solib;
356
357         solib = malloc(sizeof(*solib));
358         if (solib == NULL) {
359                 RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
360                 return -1;
361         }
362         memset(solib, 0, sizeof(*solib));
363         strlcpy(solib->name, path, PATH_MAX);
364         TAILQ_INSERT_TAIL(&solib_list, solib, next);
365
366         return 0;
367 }
368
369 #ifdef RTE_EXEC_ENV_WINDOWS
370 int
371 eal_plugins_init(void)
372 {
373         return 0;
374 }
375 #else
376
377 static int
378 eal_plugindir_init(const char *path)
379 {
380         DIR *d = NULL;
381         struct dirent *dent = NULL;
382         char sopath[PATH_MAX];
383
384         if (path == NULL || *path == '\0')
385                 return 0;
386
387         d = opendir(path);
388         if (d == NULL) {
389                 RTE_LOG(ERR, EAL, "failed to open directory %s: %s\n",
390                         path, strerror(errno));
391                 return -1;
392         }
393
394         while ((dent = readdir(d)) != NULL) {
395                 struct stat sb;
396                 int nlen = strnlen(dent->d_name, sizeof(dent->d_name));
397
398                 /* check if name ends in .so */
399                 if (strcmp(&dent->d_name[nlen - 3], ".so") != 0)
400                         continue;
401
402                 snprintf(sopath, sizeof(sopath), "%s/%s", path, dent->d_name);
403
404                 /* if a regular file, add to list to load */
405                 if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
406                         continue;
407
408                 if (eal_plugin_add(sopath) == -1)
409                         break;
410         }
411
412         closedir(d);
413         /* XXX this ignores failures from readdir() itself */
414         return (dent == NULL) ? 0 : -1;
415 }
416
417 static int
418 verify_perms(const char *dirpath)
419 {
420         struct stat st;
421
422         /* if not root, check down one level first */
423         if (strcmp(dirpath, "/") != 0) {
424                 static __thread char last_dir_checked[PATH_MAX];
425                 char copy[PATH_MAX];
426                 const char *dir;
427
428                 strlcpy(copy, dirpath, PATH_MAX);
429                 dir = dirname(copy);
430                 if (strncmp(dir, last_dir_checked, PATH_MAX) != 0) {
431                         if (verify_perms(dir) != 0)
432                                 return -1;
433                         strlcpy(last_dir_checked, dir, PATH_MAX);
434                 }
435         }
436
437         /* call stat to check for permissions and ensure not world writable */
438         if (stat(dirpath, &st) != 0) {
439                 RTE_LOG(ERR, EAL, "Error with stat on %s, %s\n",
440                                 dirpath, strerror(errno));
441                 return -1;
442         }
443         if (st.st_mode & S_IWOTH) {
444                 RTE_LOG(ERR, EAL,
445                                 "Error, directory path %s is world-writable and insecure\n",
446                                 dirpath);
447                 return -1;
448         }
449
450         return 0;
451 }
452
453 static void *
454 eal_dlopen(const char *pathname)
455 {
456         void *retval = NULL;
457         char *realp = realpath(pathname, NULL);
458
459         if (realp == NULL && errno == ENOENT) {
460                 /* not a full or relative path, try a load from system dirs */
461                 retval = dlopen(pathname, RTLD_NOW);
462                 if (retval == NULL)
463                         RTE_LOG(ERR, EAL, "%s\n", dlerror());
464                 return retval;
465         }
466         if (realp == NULL) {
467                 RTE_LOG(ERR, EAL, "Error with realpath for %s, %s\n",
468                                 pathname, strerror(errno));
469                 goto out;
470         }
471         if (strnlen(realp, PATH_MAX) == PATH_MAX) {
472                 RTE_LOG(ERR, EAL, "Error, driver path greater than PATH_MAX\n");
473                 goto out;
474         }
475
476         /* do permissions checks */
477         if (verify_perms(realp) != 0)
478                 goto out;
479
480         retval = dlopen(realp, RTLD_NOW);
481         if (retval == NULL)
482                 RTE_LOG(ERR, EAL, "%s\n", dlerror());
483 out:
484         free(realp);
485         return retval;
486 }
487
488 int
489 eal_plugins_init(void)
490 {
491         struct shared_driver *solib = NULL;
492         struct stat sb;
493
494         /* If we are not statically linked, add default driver loading
495          * path if it exists as a directory.
496          * (Using dlopen with NOLOAD flag on EAL, will return NULL if the EAL
497          * shared library is not already loaded i.e. it's statically linked.)
498          */
499         if (dlopen("librte_eal.so", RTLD_LAZY | RTLD_NOLOAD) != NULL &&
500                         *default_solib_dir != '\0' &&
501                         stat(default_solib_dir, &sb) == 0 &&
502                         S_ISDIR(sb.st_mode))
503                 eal_plugin_add(default_solib_dir);
504
505         TAILQ_FOREACH(solib, &solib_list, next) {
506
507                 if (stat(solib->name, &sb) == 0 && S_ISDIR(sb.st_mode)) {
508                         if (eal_plugindir_init(solib->name) == -1) {
509                                 RTE_LOG(ERR, EAL,
510                                         "Cannot init plugin directory %s\n",
511                                         solib->name);
512                                 return -1;
513                         }
514                 } else {
515                         RTE_LOG(DEBUG, EAL, "open shared lib %s\n",
516                                 solib->name);
517                         solib->lib_handle = eal_dlopen(solib->name);
518                         if (solib->lib_handle == NULL)
519                                 return -1;
520                 }
521
522         }
523         return 0;
524 }
525 #endif
526
527 /*
528  * Parse the coremask given as argument (hexadecimal string) and fill
529  * the global configuration (core role and core count) with the parsed
530  * value.
531  */
532 static int xdigit2val(unsigned char c)
533 {
534         int val;
535
536         if (isdigit(c))
537                 val = c - '0';
538         else if (isupper(c))
539                 val = c - 'A' + 10;
540         else
541                 val = c - 'a' + 10;
542         return val;
543 }
544
545 static int
546 eal_parse_service_coremask(const char *coremask)
547 {
548         struct rte_config *cfg = rte_eal_get_configuration();
549         int i, j, idx = 0;
550         unsigned int count = 0;
551         char c;
552         int val;
553         uint32_t taken_lcore_count = 0;
554
555         if (coremask == NULL)
556                 return -1;
557         /* Remove all blank characters ahead and after .
558          * Remove 0x/0X if exists.
559          */
560         while (isblank(*coremask))
561                 coremask++;
562         if (coremask[0] == '0' && ((coremask[1] == 'x')
563                 || (coremask[1] == 'X')))
564                 coremask += 2;
565         i = strlen(coremask);
566         while ((i > 0) && isblank(coremask[i - 1]))
567                 i--;
568
569         if (i == 0)
570                 return -1;
571
572         for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
573                 c = coremask[i];
574                 if (isxdigit(c) == 0) {
575                         /* invalid characters */
576                         return -1;
577                 }
578                 val = xdigit2val(c);
579                 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
580                                 j++, idx++) {
581                         if ((1 << j) & val) {
582                                 /* handle master lcore already parsed */
583                                 uint32_t lcore = idx;
584                                 if (master_lcore_parsed &&
585                                                 cfg->master_lcore == lcore) {
586                                         RTE_LOG(ERR, EAL,
587                                                 "lcore %u is master lcore, cannot use as service core\n",
588                                                 idx);
589                                         return -1;
590                                 }
591
592                                 if (eal_cpu_detected(idx) == 0) {
593                                         RTE_LOG(ERR, EAL,
594                                                 "lcore %u unavailable\n", idx);
595                                         return -1;
596                                 }
597
598                                 if (cfg->lcore_role[idx] == ROLE_RTE)
599                                         taken_lcore_count++;
600
601                                 lcore_config[idx].core_role = ROLE_SERVICE;
602                                 count++;
603                         }
604                 }
605         }
606
607         for (; i >= 0; i--)
608                 if (coremask[i] != '0')
609                         return -1;
610
611         for (; idx < RTE_MAX_LCORE; idx++)
612                 lcore_config[idx].core_index = -1;
613
614         if (count == 0)
615                 return -1;
616
617         if (core_parsed && taken_lcore_count != count) {
618                 RTE_LOG(WARNING, EAL,
619                         "Not all service cores are in the coremask. "
620                         "Please ensure -c or -l includes service cores\n");
621         }
622
623         cfg->service_lcore_count = count;
624         return 0;
625 }
626
627 static int
628 eal_service_cores_parsed(void)
629 {
630         int idx;
631         for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
632                 if (lcore_config[idx].core_role == ROLE_SERVICE)
633                         return 1;
634         }
635         return 0;
636 }
637
638 static int
639 update_lcore_config(int *cores)
640 {
641         struct rte_config *cfg = rte_eal_get_configuration();
642         unsigned int count = 0;
643         unsigned int i;
644         int ret = 0;
645
646         for (i = 0; i < RTE_MAX_LCORE; i++) {
647                 if (cores[i] != -1) {
648                         if (eal_cpu_detected(i) == 0) {
649                                 RTE_LOG(ERR, EAL, "lcore %u unavailable\n", i);
650                                 ret = -1;
651                                 continue;
652                         }
653                         cfg->lcore_role[i] = ROLE_RTE;
654                         count++;
655                 } else {
656                         cfg->lcore_role[i] = ROLE_OFF;
657                 }
658                 lcore_config[i].core_index = cores[i];
659         }
660         if (!ret)
661                 cfg->lcore_count = count;
662         return ret;
663 }
664
665 static int
666 eal_parse_coremask(const char *coremask, int *cores)
667 {
668         unsigned count = 0;
669         int i, j, idx;
670         int val;
671         char c;
672
673         for (idx = 0; idx < RTE_MAX_LCORE; idx++)
674                 cores[idx] = -1;
675         idx = 0;
676
677         /* Remove all blank characters ahead and after .
678          * Remove 0x/0X if exists.
679          */
680         while (isblank(*coremask))
681                 coremask++;
682         if (coremask[0] == '0' && ((coremask[1] == 'x')
683                 || (coremask[1] == 'X')))
684                 coremask += 2;
685         i = strlen(coremask);
686         while ((i > 0) && isblank(coremask[i - 1]))
687                 i--;
688         if (i == 0)
689                 return -1;
690
691         for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
692                 c = coremask[i];
693                 if (isxdigit(c) == 0) {
694                         /* invalid characters */
695                         return -1;
696                 }
697                 val = xdigit2val(c);
698                 for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++)
699                 {
700                         if ((1 << j) & val) {
701                                 cores[idx] = count;
702                                 count++;
703                         }
704                 }
705         }
706         for (; i >= 0; i--)
707                 if (coremask[i] != '0')
708                         return -1;
709         if (count == 0)
710                 return -1;
711         return 0;
712 }
713
714 static int
715 eal_parse_service_corelist(const char *corelist)
716 {
717         struct rte_config *cfg = rte_eal_get_configuration();
718         int i, idx = 0;
719         unsigned count = 0;
720         char *end = NULL;
721         int min, max;
722         uint32_t taken_lcore_count = 0;
723
724         if (corelist == NULL)
725                 return -1;
726
727         /* Remove all blank characters ahead and after */
728         while (isblank(*corelist))
729                 corelist++;
730         i = strlen(corelist);
731         while ((i > 0) && isblank(corelist[i - 1]))
732                 i--;
733
734         /* Get list of cores */
735         min = RTE_MAX_LCORE;
736         do {
737                 while (isblank(*corelist))
738                         corelist++;
739                 if (*corelist == '\0')
740                         return -1;
741                 errno = 0;
742                 idx = strtoul(corelist, &end, 10);
743                 if (errno || end == NULL)
744                         return -1;
745                 while (isblank(*end))
746                         end++;
747                 if (*end == '-') {
748                         min = idx;
749                 } else if ((*end == ',') || (*end == '\0')) {
750                         max = idx;
751                         if (min == RTE_MAX_LCORE)
752                                 min = idx;
753                         for (idx = min; idx <= max; idx++) {
754                                 if (cfg->lcore_role[idx] != ROLE_SERVICE) {
755                                         /* handle master lcore already parsed */
756                                         uint32_t lcore = idx;
757                                         if (cfg->master_lcore == lcore &&
758                                                         master_lcore_parsed) {
759                                                 RTE_LOG(ERR, EAL,
760                                                         "Error: lcore %u is master lcore, cannot use as service core\n",
761                                                         idx);
762                                                 return -1;
763                                         }
764                                         if (cfg->lcore_role[idx] == ROLE_RTE)
765                                                 taken_lcore_count++;
766
767                                         lcore_config[idx].core_role =
768                                                         ROLE_SERVICE;
769                                         count++;
770                                 }
771                         }
772                         min = RTE_MAX_LCORE;
773                 } else
774                         return -1;
775                 corelist = end + 1;
776         } while (*end != '\0');
777
778         if (count == 0)
779                 return -1;
780
781         if (core_parsed && taken_lcore_count != count) {
782                 RTE_LOG(WARNING, EAL,
783                         "Not all service cores were in the coremask. "
784                         "Please ensure -c or -l includes service cores\n");
785         }
786
787         return 0;
788 }
789
790 static int
791 eal_parse_corelist(const char *corelist, int *cores)
792 {
793         unsigned count = 0;
794         char *end = NULL;
795         int min, max;
796         int idx;
797
798         for (idx = 0; idx < RTE_MAX_LCORE; idx++)
799                 cores[idx] = -1;
800
801         /* Remove all blank characters ahead */
802         while (isblank(*corelist))
803                 corelist++;
804
805         /* Get list of cores */
806         min = RTE_MAX_LCORE;
807         do {
808                 while (isblank(*corelist))
809                         corelist++;
810                 if (*corelist == '\0')
811                         return -1;
812                 errno = 0;
813                 idx = strtol(corelist, &end, 10);
814                 if (errno || end == NULL)
815                         return -1;
816                 if (idx < 0 || idx >= RTE_MAX_LCORE)
817                         return -1;
818                 while (isblank(*end))
819                         end++;
820                 if (*end == '-') {
821                         min = idx;
822                 } else if ((*end == ',') || (*end == '\0')) {
823                         max = idx;
824                         if (min == RTE_MAX_LCORE)
825                                 min = idx;
826                         for (idx = min; idx <= max; idx++) {
827                                 if (cores[idx] == -1) {
828                                         cores[idx] = count;
829                                         count++;
830                                 }
831                         }
832                         min = RTE_MAX_LCORE;
833                 } else
834                         return -1;
835                 corelist = end + 1;
836         } while (*end != '\0');
837
838         if (count == 0)
839                 return -1;
840         return 0;
841 }
842
843 /* Changes the lcore id of the master thread */
844 static int
845 eal_parse_master_lcore(const char *arg)
846 {
847         char *parsing_end;
848         struct rte_config *cfg = rte_eal_get_configuration();
849
850         errno = 0;
851         cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
852         if (errno || parsing_end[0] != 0)
853                 return -1;
854         if (cfg->master_lcore >= RTE_MAX_LCORE)
855                 return -1;
856         master_lcore_parsed = 1;
857
858         /* ensure master core is not used as service core */
859         if (lcore_config[cfg->master_lcore].core_role == ROLE_SERVICE) {
860                 RTE_LOG(ERR, EAL,
861                         "Error: Master lcore is used as a service core\n");
862                 return -1;
863         }
864
865         return 0;
866 }
867
868 /*
869  * Parse elem, the elem could be single number/range or '(' ')' group
870  * 1) A single number elem, it's just a simple digit. e.g. 9
871  * 2) A single range elem, two digits with a '-' between. e.g. 2-6
872  * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
873  *    Within group elem, '-' used for a range separator;
874  *                       ',' used for a single number.
875  */
876 static int
877 eal_parse_set(const char *input, rte_cpuset_t *set)
878 {
879         unsigned idx;
880         const char *str = input;
881         char *end = NULL;
882         unsigned min, max;
883
884         CPU_ZERO(set);
885
886         while (isblank(*str))
887                 str++;
888
889         /* only digit or left bracket is qualify for start point */
890         if ((!isdigit(*str) && *str != '(') || *str == '\0')
891                 return -1;
892
893         /* process single number or single range of number */
894         if (*str != '(') {
895                 errno = 0;
896                 idx = strtoul(str, &end, 10);
897                 if (errno || end == NULL || idx >= CPU_SETSIZE)
898                         return -1;
899                 else {
900                         while (isblank(*end))
901                                 end++;
902
903                         min = idx;
904                         max = idx;
905                         if (*end == '-') {
906                                 /* process single <number>-<number> */
907                                 end++;
908                                 while (isblank(*end))
909                                         end++;
910                                 if (!isdigit(*end))
911                                         return -1;
912
913                                 errno = 0;
914                                 idx = strtoul(end, &end, 10);
915                                 if (errno || end == NULL || idx >= CPU_SETSIZE)
916                                         return -1;
917                                 max = idx;
918                                 while (isblank(*end))
919                                         end++;
920                                 if (*end != ',' && *end != '\0')
921                                         return -1;
922                         }
923
924                         if (*end != ',' && *end != '\0' &&
925                             *end != '@')
926                                 return -1;
927
928                         for (idx = RTE_MIN(min, max);
929                              idx <= RTE_MAX(min, max); idx++)
930                                 CPU_SET(idx, set);
931
932                         return end - input;
933                 }
934         }
935
936         /* process set within bracket */
937         str++;
938         while (isblank(*str))
939                 str++;
940         if (*str == '\0')
941                 return -1;
942
943         min = RTE_MAX_LCORE;
944         do {
945
946                 /* go ahead to the first digit */
947                 while (isblank(*str))
948                         str++;
949                 if (!isdigit(*str))
950                         return -1;
951
952                 /* get the digit value */
953                 errno = 0;
954                 idx = strtoul(str, &end, 10);
955                 if (errno || end == NULL || idx >= CPU_SETSIZE)
956                         return -1;
957
958                 /* go ahead to separator '-',',' and ')' */
959                 while (isblank(*end))
960                         end++;
961                 if (*end == '-') {
962                         if (min == RTE_MAX_LCORE)
963                                 min = idx;
964                         else /* avoid continuous '-' */
965                                 return -1;
966                 } else if ((*end == ',') || (*end == ')')) {
967                         max = idx;
968                         if (min == RTE_MAX_LCORE)
969                                 min = idx;
970                         for (idx = RTE_MIN(min, max);
971                              idx <= RTE_MAX(min, max); idx++)
972                                 CPU_SET(idx, set);
973
974                         min = RTE_MAX_LCORE;
975                 } else
976                         return -1;
977
978                 str = end + 1;
979         } while (*end != '\0' && *end != ')');
980
981         /*
982          * to avoid failure that tail blank makes end character check fail
983          * in eal_parse_lcores( )
984          */
985         while (isblank(*str))
986                 str++;
987
988         return str - input;
989 }
990
991 static int
992 check_cpuset(rte_cpuset_t *set)
993 {
994         unsigned int idx;
995
996         for (idx = 0; idx < CPU_SETSIZE; idx++) {
997                 if (!CPU_ISSET(idx, set))
998                         continue;
999
1000                 if (eal_cpu_detected(idx) == 0) {
1001                         RTE_LOG(ERR, EAL, "core %u "
1002                                 "unavailable\n", idx);
1003                         return -1;
1004                 }
1005         }
1006         return 0;
1007 }
1008
1009 /*
1010  * The format pattern: --lcores='<lcores[@cpus]>[<,lcores[@cpus]>...]'
1011  * lcores, cpus could be a single digit/range or a group.
1012  * '(' and ')' are necessary if it's a group.
1013  * If not supply '@cpus', the value of cpus uses the same as lcores.
1014  * e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means start 9 EAL thread as below
1015  *   lcore 0 runs on cpuset 0x41 (cpu 0,6)
1016  *   lcore 1 runs on cpuset 0x2 (cpu 1)
1017  *   lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
1018  *   lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
1019  *   lcore 6 runs on cpuset 0x41 (cpu 0,6)
1020  *   lcore 7 runs on cpuset 0x80 (cpu 7)
1021  *   lcore 8 runs on cpuset 0x100 (cpu 8)
1022  */
1023 static int
1024 eal_parse_lcores(const char *lcores)
1025 {
1026         struct rte_config *cfg = rte_eal_get_configuration();
1027         rte_cpuset_t lcore_set;
1028         unsigned int set_count;
1029         unsigned idx = 0;
1030         unsigned count = 0;
1031         const char *lcore_start = NULL;
1032         const char *end = NULL;
1033         int offset;
1034         rte_cpuset_t cpuset;
1035         int lflags;
1036         int ret = -1;
1037
1038         if (lcores == NULL)
1039                 return -1;
1040
1041         /* Remove all blank characters ahead and after */
1042         while (isblank(*lcores))
1043                 lcores++;
1044
1045         CPU_ZERO(&cpuset);
1046
1047         /* Reset lcore config */
1048         for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1049                 cfg->lcore_role[idx] = ROLE_OFF;
1050                 lcore_config[idx].core_index = -1;
1051                 CPU_ZERO(&lcore_config[idx].cpuset);
1052         }
1053
1054         /* Get list of cores */
1055         do {
1056                 while (isblank(*lcores))
1057                         lcores++;
1058                 if (*lcores == '\0')
1059                         goto err;
1060
1061                 lflags = 0;
1062
1063                 /* record lcore_set start point */
1064                 lcore_start = lcores;
1065
1066                 /* go across a complete bracket */
1067                 if (*lcore_start == '(') {
1068                         lcores += strcspn(lcores, ")");
1069                         if (*lcores++ == '\0')
1070                                 goto err;
1071                 }
1072
1073                 /* scan the separator '@', ','(next) or '\0'(finish) */
1074                 lcores += strcspn(lcores, "@,");
1075
1076                 if (*lcores == '@') {
1077                         /* explicit assign cpuset and update the end cursor */
1078                         offset = eal_parse_set(lcores + 1, &cpuset);
1079                         if (offset < 0)
1080                                 goto err;
1081                         end = lcores + 1 + offset;
1082                 } else { /* ',' or '\0' */
1083                         /* haven't given cpuset, current loop done */
1084                         end = lcores;
1085
1086                         /* go back to check <number>-<number> */
1087                         offset = strcspn(lcore_start, "(-");
1088                         if (offset < (end - lcore_start) &&
1089                             *(lcore_start + offset) != '(')
1090                                 lflags = 1;
1091                 }
1092
1093                 if (*end != ',' && *end != '\0')
1094                         goto err;
1095
1096                 /* parse lcore_set from start point */
1097                 if (eal_parse_set(lcore_start, &lcore_set) < 0)
1098                         goto err;
1099
1100                 /* without '@', by default using lcore_set as cpuset */
1101                 if (*lcores != '@')
1102                         rte_memcpy(&cpuset, &lcore_set, sizeof(cpuset));
1103
1104                 set_count = CPU_COUNT(&lcore_set);
1105                 /* start to update lcore_set */
1106                 for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1107                         if (!CPU_ISSET(idx, &lcore_set))
1108                                 continue;
1109                         set_count--;
1110
1111                         if (cfg->lcore_role[idx] != ROLE_RTE) {
1112                                 lcore_config[idx].core_index = count;
1113                                 cfg->lcore_role[idx] = ROLE_RTE;
1114                                 count++;
1115                         }
1116
1117                         if (lflags) {
1118                                 CPU_ZERO(&cpuset);
1119                                 CPU_SET(idx, &cpuset);
1120                         }
1121
1122                         if (check_cpuset(&cpuset) < 0)
1123                                 goto err;
1124                         rte_memcpy(&lcore_config[idx].cpuset, &cpuset,
1125                                    sizeof(rte_cpuset_t));
1126                 }
1127
1128                 /* some cores from the lcore_set can't be handled by EAL */
1129                 if (set_count != 0)
1130                         goto err;
1131
1132                 lcores = end + 1;
1133         } while (*end != '\0');
1134
1135         if (count == 0)
1136                 goto err;
1137
1138         cfg->lcore_count = count;
1139         ret = 0;
1140
1141 err:
1142
1143         return ret;
1144 }
1145
1146 #ifndef RTE_EXEC_ENV_WINDOWS
1147 static int
1148 eal_parse_syslog(const char *facility, struct internal_config *conf)
1149 {
1150         int i;
1151         static const struct {
1152                 const char *name;
1153                 int value;
1154         } map[] = {
1155                 { "auth", LOG_AUTH },
1156                 { "cron", LOG_CRON },
1157                 { "daemon", LOG_DAEMON },
1158                 { "ftp", LOG_FTP },
1159                 { "kern", LOG_KERN },
1160                 { "lpr", LOG_LPR },
1161                 { "mail", LOG_MAIL },
1162                 { "news", LOG_NEWS },
1163                 { "syslog", LOG_SYSLOG },
1164                 { "user", LOG_USER },
1165                 { "uucp", LOG_UUCP },
1166                 { "local0", LOG_LOCAL0 },
1167                 { "local1", LOG_LOCAL1 },
1168                 { "local2", LOG_LOCAL2 },
1169                 { "local3", LOG_LOCAL3 },
1170                 { "local4", LOG_LOCAL4 },
1171                 { "local5", LOG_LOCAL5 },
1172                 { "local6", LOG_LOCAL6 },
1173                 { "local7", LOG_LOCAL7 },
1174                 { NULL, 0 }
1175         };
1176
1177         for (i = 0; map[i].name; i++) {
1178                 if (!strcmp(facility, map[i].name)) {
1179                         conf->syslog_facility = map[i].value;
1180                         return 0;
1181                 }
1182         }
1183         return -1;
1184 }
1185 #endif
1186
1187 static int
1188 eal_parse_log_priority(const char *level)
1189 {
1190         static const char * const levels[] = {
1191                 [RTE_LOG_EMERG]   = "emergency",
1192                 [RTE_LOG_ALERT]   = "alert",
1193                 [RTE_LOG_CRIT]    = "critical",
1194                 [RTE_LOG_ERR]     = "error",
1195                 [RTE_LOG_WARNING] = "warning",
1196                 [RTE_LOG_NOTICE]  = "notice",
1197                 [RTE_LOG_INFO]    = "info",
1198                 [RTE_LOG_DEBUG]   = "debug",
1199         };
1200         size_t len = strlen(level);
1201         unsigned long tmp;
1202         char *end;
1203         unsigned int i;
1204
1205         if (len == 0)
1206                 return -1;
1207
1208         /* look for named values, skip 0 which is not a valid level */
1209         for (i = 1; i < RTE_DIM(levels); i++) {
1210                 if (strncmp(levels[i], level, len) == 0)
1211                         return i;
1212         }
1213
1214         /* not a string, maybe it is numeric */
1215         errno = 0;
1216         tmp = strtoul(level, &end, 0);
1217
1218         /* check for errors */
1219         if (errno != 0 || end == NULL || *end != '\0' ||
1220             tmp >= UINT32_MAX)
1221                 return -1;
1222
1223         return tmp;
1224 }
1225
1226 static int
1227 eal_parse_log_level(const char *arg)
1228 {
1229         const char *pattern = NULL;
1230         const char *regex = NULL;
1231         char *str, *level;
1232         int priority;
1233
1234         str = strdup(arg);
1235         if (str == NULL)
1236                 return -1;
1237
1238         if ((level = strchr(str, ','))) {
1239                 regex = str;
1240                 *level++ = '\0';
1241         } else if ((level = strchr(str, ':'))) {
1242                 pattern = str;
1243                 *level++ = '\0';
1244         } else {
1245                 level = str;
1246         }
1247
1248         priority = eal_parse_log_priority(level);
1249         if (priority < 0) {
1250                 fprintf(stderr, "invalid log priority: %s\n", level);
1251                 goto fail;
1252         }
1253
1254         if (regex) {
1255                 if (rte_log_set_level_regexp(regex, priority) < 0) {
1256                         fprintf(stderr, "cannot set log level %s,%d\n",
1257                                 regex, priority);
1258                         goto fail;
1259                 }
1260                 if (rte_log_save_regexp(regex, priority) < 0)
1261                         goto fail;
1262         } else if (pattern) {
1263                 if (rte_log_set_level_pattern(pattern, priority) < 0) {
1264                         fprintf(stderr, "cannot set log level %s:%d\n",
1265                                 pattern, priority);
1266                         goto fail;
1267                 }
1268                 if (rte_log_save_pattern(pattern, priority) < 0)
1269                         goto fail;
1270         } else {
1271                 rte_log_set_global_level(priority);
1272         }
1273
1274         free(str);
1275         return 0;
1276
1277 fail:
1278         free(str);
1279         return -1;
1280 }
1281
1282 static enum rte_proc_type_t
1283 eal_parse_proc_type(const char *arg)
1284 {
1285         if (strncasecmp(arg, "primary", sizeof("primary")) == 0)
1286                 return RTE_PROC_PRIMARY;
1287         if (strncasecmp(arg, "secondary", sizeof("secondary")) == 0)
1288                 return RTE_PROC_SECONDARY;
1289         if (strncasecmp(arg, "auto", sizeof("auto")) == 0)
1290                 return RTE_PROC_AUTO;
1291
1292         return RTE_PROC_INVALID;
1293 }
1294
1295 static int
1296 eal_parse_iova_mode(const char *name)
1297 {
1298         int mode;
1299         struct internal_config *internal_conf =
1300                 eal_get_internal_configuration();
1301
1302         if (name == NULL)
1303                 return -1;
1304
1305         if (!strcmp("pa", name))
1306                 mode = RTE_IOVA_PA;
1307         else if (!strcmp("va", name))
1308                 mode = RTE_IOVA_VA;
1309         else
1310                 return -1;
1311
1312         internal_conf->iova_mode = mode;
1313         return 0;
1314 }
1315
1316 static int
1317 eal_parse_simd_bitwidth(const char *arg)
1318 {
1319         char *end;
1320         unsigned long bitwidth;
1321         int ret;
1322         struct internal_config *internal_conf =
1323                 eal_get_internal_configuration();
1324
1325         if (arg == NULL || arg[0] == '\0')
1326                 return -1;
1327
1328         errno = 0;
1329         bitwidth = strtoul(arg, &end, 0);
1330
1331         /* check for errors */
1332         if (errno != 0 || end == NULL || *end != '\0' || bitwidth > RTE_VECT_SIMD_MAX)
1333                 return -1;
1334
1335         if (bitwidth == 0)
1336                 bitwidth = (unsigned long) RTE_VECT_SIMD_MAX;
1337         ret = rte_vect_set_max_simd_bitwidth(bitwidth);
1338         if (ret < 0)
1339                 return -1;
1340         internal_conf->max_simd_bitwidth.forced = 1;
1341         return 0;
1342 }
1343
1344 static int
1345 eal_parse_base_virtaddr(const char *arg)
1346 {
1347         char *end;
1348         uint64_t addr;
1349         struct internal_config *internal_conf =
1350                 eal_get_internal_configuration();
1351
1352         errno = 0;
1353         addr = strtoull(arg, &end, 16);
1354
1355         /* check for errors */
1356         if ((errno != 0) || (arg[0] == '\0') || end == NULL || (*end != '\0'))
1357                 return -1;
1358
1359         /* make sure we don't exceed 32-bit boundary on 32-bit target */
1360 #ifndef RTE_ARCH_64
1361         if (addr >= UINTPTR_MAX)
1362                 return -1;
1363 #endif
1364
1365         /* align the addr on 16M boundary, 16MB is the minimum huge page
1366          * size on IBM Power architecture. If the addr is aligned to 16MB,
1367          * it can align to 2MB for x86. So this alignment can also be used
1368          * on x86 and other architectures.
1369          */
1370         internal_conf->base_virtaddr =
1371                 RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16M);
1372
1373         return 0;
1374 }
1375
1376 /* caller is responsible for freeing the returned string */
1377 static char *
1378 available_cores(void)
1379 {
1380         char *str = NULL;
1381         int previous;
1382         int sequence;
1383         char *tmp;
1384         int idx;
1385
1386         /* find the first available cpu */
1387         for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
1388                 if (eal_cpu_detected(idx) == 0)
1389                         continue;
1390                 break;
1391         }
1392         if (idx >= RTE_MAX_LCORE)
1393                 return NULL;
1394
1395         /* first sequence */
1396         if (asprintf(&str, "%d", idx) < 0)
1397                 return NULL;
1398         previous = idx;
1399         sequence = 0;
1400
1401         for (idx++ ; idx < RTE_MAX_LCORE; idx++) {
1402                 if (eal_cpu_detected(idx) == 0)
1403                         continue;
1404
1405                 if (idx == previous + 1) {
1406                         previous = idx;
1407                         sequence = 1;
1408                         continue;
1409                 }
1410
1411                 /* finish current sequence */
1412                 if (sequence) {
1413                         if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
1414                                 free(str);
1415                                 return NULL;
1416                         }
1417                         free(str);
1418                         str = tmp;
1419                 }
1420
1421                 /* new sequence */
1422                 if (asprintf(&tmp, "%s,%d", str, idx) < 0) {
1423                         free(str);
1424                         return NULL;
1425                 }
1426                 free(str);
1427                 str = tmp;
1428                 previous = idx;
1429                 sequence = 0;
1430         }
1431
1432         /* finish last sequence */
1433         if (sequence) {
1434                 if (asprintf(&tmp, "%s-%d", str, previous) < 0) {
1435                         free(str);
1436                         return NULL;
1437                 }
1438                 free(str);
1439                 str = tmp;
1440         }
1441
1442         return str;
1443 }
1444
1445 int
1446 eal_parse_common_option(int opt, const char *optarg,
1447                         struct internal_config *conf)
1448 {
1449         static int b_used;
1450         static int w_used;
1451
1452         switch (opt) {
1453         /* blacklist */
1454         case 'b':
1455                 if (w_used)
1456                         goto bw_used;
1457                 if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI,
1458                                 optarg) < 0) {
1459                         return -1;
1460                 }
1461                 b_used = 1;
1462                 break;
1463         /* whitelist */
1464         case 'w':
1465                 if (b_used)
1466                         goto bw_used;
1467                 if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI,
1468                                 optarg) < 0) {
1469                         return -1;
1470                 }
1471                 w_used = 1;
1472                 break;
1473         /* coremask */
1474         case 'c': {
1475                 int lcore_indexes[RTE_MAX_LCORE];
1476
1477                 if (eal_service_cores_parsed())
1478                         RTE_LOG(WARNING, EAL,
1479                                 "Service cores parsed before dataplane cores. Please ensure -c is before -s or -S\n");
1480                 if (eal_parse_coremask(optarg, lcore_indexes) < 0) {
1481                         RTE_LOG(ERR, EAL, "invalid coremask syntax\n");
1482                         return -1;
1483                 }
1484                 if (update_lcore_config(lcore_indexes) < 0) {
1485                         char *available = available_cores();
1486
1487                         RTE_LOG(ERR, EAL,
1488                                 "invalid coremask, please check specified cores are part of %s\n",
1489                                 available);
1490                         free(available);
1491                         return -1;
1492                 }
1493
1494                 if (core_parsed) {
1495                         RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s) is set!\n",
1496                                 (core_parsed == LCORE_OPT_LST) ? "-l" :
1497                                 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1498                                 "-c");
1499                         return -1;
1500                 }
1501
1502                 core_parsed = LCORE_OPT_MSK;
1503                 break;
1504         }
1505         /* corelist */
1506         case 'l': {
1507                 int lcore_indexes[RTE_MAX_LCORE];
1508
1509                 if (eal_service_cores_parsed())
1510                         RTE_LOG(WARNING, EAL,
1511                                 "Service cores parsed before dataplane cores. Please ensure -l is before -s or -S\n");
1512
1513                 if (eal_parse_corelist(optarg, lcore_indexes) < 0) {
1514                         RTE_LOG(ERR, EAL, "invalid core list syntax\n");
1515                         return -1;
1516                 }
1517                 if (update_lcore_config(lcore_indexes) < 0) {
1518                         char *available = available_cores();
1519
1520                         RTE_LOG(ERR, EAL,
1521                                 "invalid core list, please check specified cores are part of %s\n",
1522                                 available);
1523                         free(available);
1524                         return -1;
1525                 }
1526
1527                 if (core_parsed) {
1528                         RTE_LOG(ERR, EAL, "Option -l is ignored, because (%s) is set!\n",
1529                                 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1530                                 (core_parsed == LCORE_OPT_MAP) ? "--lcore" :
1531                                 "-l");
1532                         return -1;
1533                 }
1534
1535                 core_parsed = LCORE_OPT_LST;
1536                 break;
1537         }
1538         /* service coremask */
1539         case 's':
1540                 if (eal_parse_service_coremask(optarg) < 0) {
1541                         RTE_LOG(ERR, EAL, "invalid service coremask\n");
1542                         return -1;
1543                 }
1544                 break;
1545         /* service corelist */
1546         case 'S':
1547                 if (eal_parse_service_corelist(optarg) < 0) {
1548                         RTE_LOG(ERR, EAL, "invalid service core list\n");
1549                         return -1;
1550                 }
1551                 break;
1552         /* size of memory */
1553         case 'm':
1554                 conf->memory = atoi(optarg);
1555                 conf->memory *= 1024ULL;
1556                 conf->memory *= 1024ULL;
1557                 mem_parsed = 1;
1558                 break;
1559         /* force number of channels */
1560         case 'n':
1561                 conf->force_nchannel = atoi(optarg);
1562                 if (conf->force_nchannel == 0) {
1563                         RTE_LOG(ERR, EAL, "invalid channel number\n");
1564                         return -1;
1565                 }
1566                 break;
1567         /* force number of ranks */
1568         case 'r':
1569                 conf->force_nrank = atoi(optarg);
1570                 if (conf->force_nrank == 0 ||
1571                     conf->force_nrank > 16) {
1572                         RTE_LOG(ERR, EAL, "invalid rank number\n");
1573                         return -1;
1574                 }
1575                 break;
1576         /* force loading of external driver */
1577         case 'd':
1578                 if (eal_plugin_add(optarg) == -1)
1579                         return -1;
1580                 break;
1581         case 'v':
1582                 /* since message is explicitly requested by user, we
1583                  * write message at highest log level so it can always
1584                  * be seen
1585                  * even if info or warning messages are disabled */
1586                 RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version());
1587                 break;
1588
1589         /* long options */
1590         case OPT_HUGE_UNLINK_NUM:
1591                 conf->hugepage_unlink = 1;
1592                 break;
1593
1594         case OPT_NO_HUGE_NUM:
1595                 conf->no_hugetlbfs = 1;
1596                 /* no-huge is legacy mem */
1597                 conf->legacy_mem = 1;
1598                 break;
1599
1600         case OPT_NO_PCI_NUM:
1601                 conf->no_pci = 1;
1602                 break;
1603
1604         case OPT_NO_HPET_NUM:
1605                 conf->no_hpet = 1;
1606                 break;
1607
1608         case OPT_VMWARE_TSC_MAP_NUM:
1609                 conf->vmware_tsc_map = 1;
1610                 break;
1611
1612         case OPT_NO_SHCONF_NUM:
1613                 conf->no_shconf = 1;
1614                 break;
1615
1616         case OPT_IN_MEMORY_NUM:
1617                 conf->in_memory = 1;
1618                 /* in-memory is a superset of noshconf and huge-unlink */
1619                 conf->no_shconf = 1;
1620                 conf->hugepage_unlink = 1;
1621                 break;
1622
1623         case OPT_PROC_TYPE_NUM:
1624                 conf->process_type = eal_parse_proc_type(optarg);
1625                 break;
1626
1627         case OPT_MASTER_LCORE_NUM:
1628                 if (eal_parse_master_lcore(optarg) < 0) {
1629                         RTE_LOG(ERR, EAL, "invalid parameter for --"
1630                                         OPT_MASTER_LCORE "\n");
1631                         return -1;
1632                 }
1633                 break;
1634
1635         case OPT_VDEV_NUM:
1636                 if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
1637                                 optarg) < 0) {
1638                         return -1;
1639                 }
1640                 break;
1641
1642 #ifndef RTE_EXEC_ENV_WINDOWS
1643         case OPT_SYSLOG_NUM:
1644                 if (eal_parse_syslog(optarg, conf) < 0) {
1645                         RTE_LOG(ERR, EAL, "invalid parameters for --"
1646                                         OPT_SYSLOG "\n");
1647                         return -1;
1648                 }
1649                 break;
1650 #endif
1651
1652         case OPT_LOG_LEVEL_NUM: {
1653                 if (eal_parse_log_level(optarg) < 0) {
1654                         RTE_LOG(ERR, EAL,
1655                                 "invalid parameters for --"
1656                                 OPT_LOG_LEVEL "\n");
1657                         return -1;
1658                 }
1659                 break;
1660         }
1661
1662 #ifndef RTE_EXEC_ENV_WINDOWS
1663         case OPT_TRACE_NUM: {
1664                 if (eal_trace_args_save(optarg) < 0) {
1665                         RTE_LOG(ERR, EAL, "invalid parameters for --"
1666                                 OPT_TRACE "\n");
1667                         return -1;
1668                 }
1669                 break;
1670         }
1671
1672         case OPT_TRACE_DIR_NUM: {
1673                 if (eal_trace_dir_args_save(optarg) < 0) {
1674                         RTE_LOG(ERR, EAL, "invalid parameters for --"
1675                                 OPT_TRACE_DIR "\n");
1676                         return -1;
1677                 }
1678                 break;
1679         }
1680
1681         case OPT_TRACE_BUF_SIZE_NUM: {
1682                 if (eal_trace_bufsz_args_save(optarg) < 0) {
1683                         RTE_LOG(ERR, EAL, "invalid parameters for --"
1684                                 OPT_TRACE_BUF_SIZE "\n");
1685                         return -1;
1686                 }
1687                 break;
1688         }
1689
1690         case OPT_TRACE_MODE_NUM: {
1691                 if (eal_trace_mode_args_save(optarg) < 0) {
1692                         RTE_LOG(ERR, EAL, "invalid parameters for --"
1693                                 OPT_TRACE_MODE "\n");
1694                         return -1;
1695                 }
1696                 break;
1697         }
1698 #endif /* !RTE_EXEC_ENV_WINDOWS */
1699
1700         case OPT_LCORES_NUM:
1701                 if (eal_parse_lcores(optarg) < 0) {
1702                         RTE_LOG(ERR, EAL, "invalid parameter for --"
1703                                 OPT_LCORES "\n");
1704                         return -1;
1705                 }
1706
1707                 if (core_parsed) {
1708                         RTE_LOG(ERR, EAL, "Option --lcore is ignored, because (%s) is set!\n",
1709                                 (core_parsed == LCORE_OPT_LST) ? "-l" :
1710                                 (core_parsed == LCORE_OPT_MSK) ? "-c" :
1711                                 "--lcore");
1712                         return -1;
1713                 }
1714
1715                 core_parsed = LCORE_OPT_MAP;
1716                 break;
1717         case OPT_LEGACY_MEM_NUM:
1718                 conf->legacy_mem = 1;
1719                 break;
1720         case OPT_SINGLE_FILE_SEGMENTS_NUM:
1721                 conf->single_file_segments = 1;
1722                 break;
1723         case OPT_IOVA_MODE_NUM:
1724                 if (eal_parse_iova_mode(optarg) < 0) {
1725                         RTE_LOG(ERR, EAL, "invalid parameters for --"
1726                                 OPT_IOVA_MODE "\n");
1727                         return -1;
1728                 }
1729                 break;
1730         case OPT_BASE_VIRTADDR_NUM:
1731                 if (eal_parse_base_virtaddr(optarg) < 0) {
1732                         RTE_LOG(ERR, EAL, "invalid parameter for --"
1733                                         OPT_BASE_VIRTADDR "\n");
1734                         return -1;
1735                 }
1736                 break;
1737         case OPT_TELEMETRY_NUM:
1738                 break;
1739         case OPT_NO_TELEMETRY_NUM:
1740                 conf->no_telemetry = 1;
1741                 break;
1742         case OPT_FORCE_MAX_SIMD_BITWIDTH_NUM:
1743                 if (eal_parse_simd_bitwidth(optarg) < 0) {
1744                         RTE_LOG(ERR, EAL, "invalid parameter for --"
1745                                         OPT_FORCE_MAX_SIMD_BITWIDTH "\n");
1746                         return -1;
1747                 }
1748                 break;
1749
1750         /* don't know what to do, leave this to caller */
1751         default:
1752                 return 1;
1753
1754         }
1755
1756         return 0;
1757 bw_used:
1758         RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
1759                 "cannot be used at the same time\n");
1760         return -1;
1761 }
1762
1763 static void
1764 eal_auto_detect_cores(struct rte_config *cfg)
1765 {
1766         unsigned int lcore_id;
1767         unsigned int removed = 0;
1768         rte_cpuset_t affinity_set;
1769
1770         if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
1771                                 &affinity_set))
1772                 CPU_ZERO(&affinity_set);
1773
1774         for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1775                 if (cfg->lcore_role[lcore_id] == ROLE_RTE &&
1776                     !CPU_ISSET(lcore_id, &affinity_set)) {
1777                         cfg->lcore_role[lcore_id] = ROLE_OFF;
1778                         removed++;
1779                 }
1780         }
1781
1782         cfg->lcore_count -= removed;
1783 }
1784
1785 static void
1786 compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
1787 {
1788         rte_cpuset_t *cpuset = &internal_cfg->ctrl_cpuset;
1789         rte_cpuset_t default_set;
1790         unsigned int lcore_id;
1791
1792         for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
1793                 if (rte_lcore_has_role(lcore_id, ROLE_OFF))
1794                         continue;
1795                 RTE_CPU_OR(cpuset, cpuset, &lcore_config[lcore_id].cpuset);
1796         }
1797         RTE_CPU_NOT(cpuset, cpuset);
1798
1799         if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
1800                                 &default_set))
1801                 CPU_ZERO(&default_set);
1802
1803         RTE_CPU_AND(cpuset, cpuset, &default_set);
1804
1805         /* if no remaining cpu, use master lcore cpu affinity */
1806         if (!CPU_COUNT(cpuset)) {
1807                 memcpy(cpuset, &lcore_config[rte_get_master_lcore()].cpuset,
1808                         sizeof(*cpuset));
1809         }
1810 }
1811
1812 int
1813 eal_cleanup_config(struct internal_config *internal_cfg)
1814 {
1815         if (internal_cfg->hugefile_prefix != NULL)
1816                 free(internal_cfg->hugefile_prefix);
1817         if (internal_cfg->hugepage_dir != NULL)
1818                 free(internal_cfg->hugepage_dir);
1819         if (internal_cfg->user_mbuf_pool_ops_name != NULL)
1820                 free(internal_cfg->user_mbuf_pool_ops_name);
1821
1822         return 0;
1823 }
1824
1825 int
1826 eal_adjust_config(struct internal_config *internal_cfg)
1827 {
1828         int i;
1829         struct rte_config *cfg = rte_eal_get_configuration();
1830         struct internal_config *internal_conf =
1831                 eal_get_internal_configuration();
1832
1833         if (!core_parsed)
1834                 eal_auto_detect_cores(cfg);
1835
1836         if (internal_conf->process_type == RTE_PROC_AUTO)
1837                 internal_conf->process_type = eal_proc_type_detect();
1838
1839         /* default master lcore is the first one */
1840         if (!master_lcore_parsed) {
1841                 cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
1842                 if (cfg->master_lcore >= RTE_MAX_LCORE)
1843                         return -1;
1844                 lcore_config[cfg->master_lcore].core_role = ROLE_RTE;
1845         }
1846
1847         compute_ctrl_threads_cpuset(internal_cfg);
1848
1849         /* if no memory amounts were requested, this will result in 0 and
1850          * will be overridden later, right after eal_hugepage_info_init() */
1851         for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
1852                 internal_cfg->memory += internal_cfg->socket_mem[i];
1853
1854         return 0;
1855 }
1856
1857 int
1858 eal_check_common_options(struct internal_config *internal_cfg)
1859 {
1860         struct rte_config *cfg = rte_eal_get_configuration();
1861         const struct internal_config *internal_conf =
1862                 eal_get_internal_configuration();
1863
1864         if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
1865                 RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
1866                 return -1;
1867         }
1868
1869         if (internal_cfg->process_type == RTE_PROC_INVALID) {
1870                 RTE_LOG(ERR, EAL, "Invalid process type specified\n");
1871                 return -1;
1872         }
1873         if (internal_cfg->hugefile_prefix != NULL &&
1874                         strlen(internal_cfg->hugefile_prefix) < 1) {
1875                 RTE_LOG(ERR, EAL, "Invalid length of --" OPT_FILE_PREFIX " option\n");
1876                 return -1;
1877         }
1878         if (internal_cfg->hugepage_dir != NULL &&
1879                         strlen(internal_cfg->hugepage_dir) < 1) {
1880                 RTE_LOG(ERR, EAL, "Invalid length of --" OPT_HUGE_DIR" option\n");
1881                 return -1;
1882         }
1883         if (internal_cfg->user_mbuf_pool_ops_name != NULL &&
1884                         strlen(internal_cfg->user_mbuf_pool_ops_name) < 1) {
1885                 RTE_LOG(ERR, EAL, "Invalid length of --" OPT_MBUF_POOL_OPS_NAME" option\n");
1886                 return -1;
1887         }
1888         if (index(eal_get_hugefile_prefix(), '%') != NULL) {
1889                 RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" "
1890                         "option\n");
1891                 return -1;
1892         }
1893         if (mem_parsed && internal_cfg->force_sockets == 1) {
1894                 RTE_LOG(ERR, EAL, "Options -m and --"OPT_SOCKET_MEM" cannot "
1895                         "be specified at the same time\n");
1896                 return -1;
1897         }
1898         if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) {
1899                 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_MEM" cannot "
1900                         "be specified together with --"OPT_NO_HUGE"\n");
1901                 return -1;
1902         }
1903         if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink &&
1904                         !internal_cfg->in_memory) {
1905                 RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
1906                         "be specified together with --"OPT_NO_HUGE"\n");
1907                 return -1;
1908         }
1909         if (internal_conf->force_socket_limits && internal_conf->legacy_mem) {
1910                 RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_LIMIT
1911                         " is only supported in non-legacy memory mode\n");
1912         }
1913         if (internal_cfg->single_file_segments &&
1914                         internal_cfg->hugepage_unlink &&
1915                         !internal_cfg->in_memory) {
1916                 RTE_LOG(ERR, EAL, "Option --"OPT_SINGLE_FILE_SEGMENTS" is "
1917                         "not compatible with --"OPT_HUGE_UNLINK"\n");
1918                 return -1;
1919         }
1920         if (internal_cfg->legacy_mem &&
1921                         internal_cfg->in_memory) {
1922                 RTE_LOG(ERR, EAL, "Option --"OPT_LEGACY_MEM" is not compatible "
1923                                 "with --"OPT_IN_MEMORY"\n");
1924                 return -1;
1925         }
1926         if (internal_cfg->legacy_mem && internal_cfg->match_allocations) {
1927                 RTE_LOG(ERR, EAL, "Option --"OPT_LEGACY_MEM" is not compatible "
1928                                 "with --"OPT_MATCH_ALLOCATIONS"\n");
1929                 return -1;
1930         }
1931         if (internal_cfg->no_hugetlbfs && internal_cfg->match_allocations) {
1932                 RTE_LOG(ERR, EAL, "Option --"OPT_NO_HUGE" is not compatible "
1933                                 "with --"OPT_MATCH_ALLOCATIONS"\n");
1934                 return -1;
1935         }
1936         if (internal_cfg->legacy_mem && internal_cfg->memory == 0) {
1937                 RTE_LOG(NOTICE, EAL, "Static memory layout is selected, "
1938                         "amount of reserved memory can be adjusted with "
1939                         "-m or --"OPT_SOCKET_MEM"\n");
1940         }
1941
1942         return 0;
1943 }
1944
1945 uint16_t
1946 rte_vect_get_max_simd_bitwidth(void)
1947 {
1948         const struct internal_config *internal_conf =
1949                 eal_get_internal_configuration();
1950         return internal_conf->max_simd_bitwidth.bitwidth;
1951 }
1952
1953 int
1954 rte_vect_set_max_simd_bitwidth(uint16_t bitwidth)
1955 {
1956         struct internal_config *internal_conf =
1957                 eal_get_internal_configuration();
1958         if (internal_conf->max_simd_bitwidth.forced) {
1959                 RTE_LOG(NOTICE, EAL, "Cannot set max SIMD bitwidth - user runtime override enabled");
1960                 return -EPERM;
1961         }
1962
1963         if (bitwidth < RTE_VECT_SIMD_DISABLED || !rte_is_power_of_2(bitwidth)) {
1964                 RTE_LOG(ERR, EAL, "Invalid bitwidth value!\n");
1965                 return -EINVAL;
1966         }
1967         internal_conf->max_simd_bitwidth.bitwidth = bitwidth;
1968         return 0;
1969 }
1970
1971 void
1972 eal_common_usage(void)
1973 {
1974         printf("[options]\n\n"
1975                "EAL common options:\n"
1976                "  -c COREMASK         Hexadecimal bitmask of cores to run on\n"
1977                "  -l CORELIST         List of cores to run on\n"
1978                "                      The argument format is <c1>[-c2][,c3[-c4],...]\n"
1979                "                      where c1, c2, etc are core indexes between 0 and %d\n"
1980                "  --"OPT_LCORES" COREMAP    Map lcore set to physical cpu set\n"
1981                "                      The argument format is\n"
1982                "                            '<lcores[@cpus]>[<,lcores[@cpus]>...]'\n"
1983                "                      lcores and cpus list are grouped by '(' and ')'\n"
1984                "                      Within the group, '-' is used for range separator,\n"
1985                "                      ',' is used for single number separator.\n"
1986                "                      '( )' can be omitted for single element group,\n"
1987                "                      '@' can be omitted if cpus and lcores have the same value\n"
1988                "  -s SERVICE COREMASK Hexadecimal bitmask of cores to be used as service cores\n"
1989                "  --"OPT_MASTER_LCORE" ID   Core ID that is used as master\n"
1990                "  --"OPT_MBUF_POOL_OPS_NAME" Pool ops name for mbuf to use\n"
1991                "  -n CHANNELS         Number of memory channels\n"
1992                "  -m MB               Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
1993                "  -r RANKS            Force number of memory ranks (don't detect)\n"
1994                "  -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
1995                "                      Prevent EAL from using this PCI device. The argument\n"
1996                "                      format is <domain:bus:devid.func>.\n"
1997                "  -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
1998                "                      Only use the specified PCI devices. The argument format\n"
1999                "                      is <[domain:]bus:devid.func>. This option can be present\n"
2000                "                      several times (once per device).\n"
2001                "                      [NOTE: PCI whitelist cannot be used with -b option]\n"
2002                "  --"OPT_VDEV"              Add a virtual device.\n"
2003                "                      The argument format is <driver><id>[,key=val,...]\n"
2004                "                      (ex: --vdev=net_pcap0,iface=eth2).\n"
2005                "  --"OPT_IOVA_MODE"   Set IOVA mode. 'pa' for IOVA_PA\n"
2006                "                      'va' for IOVA_VA\n"
2007                "  -d LIB.so|DIR       Add a driver or driver directory\n"
2008                "                      (can be used multiple times)\n"
2009                "  --"OPT_VMWARE_TSC_MAP"    Use VMware TSC map instead of native RDTSC\n"
2010                "  --"OPT_PROC_TYPE"         Type of this process (primary|secondary|auto)\n"
2011 #ifndef RTE_EXEC_ENV_WINDOWS
2012                "  --"OPT_SYSLOG"            Set syslog facility\n"
2013 #endif
2014                "  --"OPT_LOG_LEVEL"=<int>   Set global log level\n"
2015                "  --"OPT_LOG_LEVEL"=<type-match>:<int>\n"
2016                "                      Set specific log level\n"
2017 #ifndef RTE_EXEC_ENV_WINDOWS
2018                "  --"OPT_TRACE"=<regex-match>\n"
2019                "                      Enable trace based on regular expression trace name.\n"
2020                "                      By default, the trace is disabled.\n"
2021                "                      User must specify this option to enable trace.\n"
2022                "  --"OPT_TRACE_DIR"=<directory path>\n"
2023                "                      Specify trace directory for trace output.\n"
2024                "                      By default, trace output will created at\n"
2025                "                      $HOME directory and parameter must be\n"
2026                "                      specified once only.\n"
2027                "  --"OPT_TRACE_BUF_SIZE"=<int>\n"
2028                "                      Specify maximum size of allocated memory\n"
2029                "                      for trace output for each thread. Valid\n"
2030                "                      unit can be either 'B|K|M' for 'Bytes',\n"
2031                "                      'KBytes' and 'MBytes' respectively.\n"
2032                "                      Default is 1MB and parameter must be\n"
2033                "                      specified once only.\n"
2034                "  --"OPT_TRACE_MODE"=<o[verwrite] | d[iscard]>\n"
2035                "                      Specify the mode of update of trace\n"
2036                "                      output file. Either update on a file can\n"
2037                "                      be wrapped or discarded when file size\n"
2038                "                      reaches its maximum limit.\n"
2039                "                      Default mode is 'overwrite' and parameter\n"
2040                "                      must be specified once only.\n"
2041 #endif /* !RTE_EXEC_ENV_WINDOWS */
2042                "  -v                  Display version information on startup\n"
2043                "  -h, --help          This help\n"
2044                "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
2045                "                      disable secondary process support\n"
2046                "  --"OPT_BASE_VIRTADDR"     Base virtual address\n"
2047                "  --"OPT_TELEMETRY"   Enable telemetry support (on by default)\n"
2048                "  --"OPT_NO_TELEMETRY"   Disable telemetry support\n"
2049                "  --"OPT_FORCE_MAX_SIMD_BITWIDTH" Force the max SIMD bitwidth\n"
2050                "\nEAL options for DEBUG use only:\n"
2051                "  --"OPT_HUGE_UNLINK"       Unlink hugepage files after init\n"
2052                "  --"OPT_NO_HUGE"           Use malloc instead of hugetlbfs\n"
2053                "  --"OPT_NO_PCI"            Disable PCI\n"
2054                "  --"OPT_NO_HPET"           Disable HPET\n"
2055                "  --"OPT_NO_SHCONF"         No shared config (mmap'd files)\n"
2056                "\n", RTE_MAX_LCORE);
2057 }