From patchwork Wed Jun 3 18:49:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wiles, Keith" X-Patchwork-Id: 5107 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 0C7FABDC2; Wed, 3 Jun 2015 20:50:05 +0200 (CEST) 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. *