From: Keith Wiles <keith.wiles@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [RFC PATCH] eal:Add new API for parsing args at rte_eal_init time
Date: Wed, 3 Jun 2015 13:49:53 -0500 [thread overview]
Message-ID: <1433357393-54434-1-git-send-email-keith.wiles@intel.com> (raw)
Signed-off-by: Keith Wiles <keith.wiles@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
next reply other threads:[~2015-06-03 18:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 18:49 Keith Wiles [this message]
2015-06-03 19:24 ` Thomas Monjalon
2015-06-03 19:43 ` Wiles, Keith
2015-06-04 0:12 ` Stephen Hemminger
2015-06-04 11:50 ` Wiles, Keith
2015-06-04 13:55 ` Neil Horman
2015-06-04 14:27 ` Wiles, Keith
2015-06-04 14:43 ` David Marchand
2015-06-04 14:51 ` Wiles, Keith
2015-06-04 14:55 ` Wiles, Keith
2015-06-04 14:47 ` Stephen Hemminger
2015-06-04 16:51 ` Thomas F Herbert
2015-06-04 21:27 ` Chilikin, Andrey
2015-06-05 6:01 ` Simon Kågström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433357393-54434-1-git-send-email-keith.wiles@intel.com \
--to=keith.wiles@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).