DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC PATCH] eal:Add new API for parsing args at rte_eal_init time
@ 2015-06-03 18:49 Keith Wiles
  2015-06-03 19:24 ` Thomas Monjalon
  2015-06-04  0:12 ` Stephen Hemminger
  0 siblings, 2 replies; 14+ messages in thread
From: Keith Wiles @ 2015-06-03 18:49 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-06-05  6:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 18:49 [dpdk-dev] [RFC PATCH] eal:Add new API for parsing args at rte_eal_init time Keith Wiles
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

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).