From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id D0B09B3D6 for ; Wed, 3 Jun 2015 20:50:02 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 03 Jun 2015 11:50:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,548,1427785200"; d="scan'208";a="736535177" Received: from psriniv1-mobl3.amr.corp.intel.com ([10.252.134.161]) by fmsmga002.fm.intel.com with ESMTP; 03 Jun 2015 11:50:01 -0700 From: Keith Wiles To: dev@dpdk.org Date: Wed, 3 Jun 2015 13:49:53 -0500 Message-Id: <1433357393-54434-1-git-send-email-keith.wiles@intel.com> X-Mailer: git-send-email 2.3.0 Subject: [dpdk-dev] [RFC PATCH] eal:Add new API for parsing args at rte_eal_init time X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2015 18:50:03 -0000 Signed-off-by: Keith Wiles --- 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