Signed-off-by: Keith Wiles <keith.wiles at intel.com> --- lib/librte_eal/bsdapp/eal/eal.c | 20 ++++++++++++++++++++ lib/librte_eal/common/include/rte_eal.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 43e8a47..a228576 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -557,6 +557,26 @@ rte_eal_init(int argc, char **argv) return fctret; } +/* Launch threads, called at application init() and parse app args. */ +int +rte_eal_init_parse(int argc, char **argv, + int (*parse)(int, char **)) +{ + int ret; + + ret = rte_eal_init(argc, argv); + if ((ret >= 0) && (parse != NULL)) { + argc -= ret; + argv += ret; + + int rval = parse(argc, argv); + if (rval < 0) + return rval; + ret += rval; /* Return the total args parsed */ + } + return ret; +} + /* get core role */ enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id) diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index 1385a73..c04f295 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -153,6 +153,38 @@ int rte_eal_iopl_init(void); * - On failure, a negative error value. */ int rte_eal_init(int argc, char **argv); + +/** + * Initialize the Environment Abstraction Layer (EAL) and parse local args. + * + * This function is to be executed on the MASTER lcore only, as soon + * as possible in the application's main() function. + * + * The function finishes the initialization process before main() is called. + * It puts the SLAVE lcores in the WAIT state. + * + * When the multi-partition feature is supported, depending on the + * configuration (if CONFIG_RTE_EAL_MAIN_PARTITION is disabled), this + * function waits to ensure that the magic number is set before + * returning. See also the rte_eal_get_configuration() function. Note: + * This behavior may change in the future. + * + * @param argc + * The argc argument that was given to the main() function. + * @param argv + * The argv argument that was given to the main() function. + * @param parse + * The parse function pointer from user int (*parse)(int, char **); + * @return + * - On success, the number of parsed arguments, which is greater or + * equal to zero. After the call to rte_eal_init(), + * all arguments argv[x] with x < ret may be modified and should + * not be accessed by the application. + * - On failure, a negative error value. + */ +int rte_eal_init_parse(int argc, char **argv, + int (*parse)(int, char **)); + /** * Usage function typedef used by the application usage function. * -- 2.3.0