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