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