[19/39] eventdev: add common initialize routine for eventmode devs

Message ID 1559580584-5728-20-git-send-email-anoobj@marvell.com (mailing list archive)
State Superseded, archived
Headers
Series None |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Anoob Joseph June 3, 2019, 4:49 p.m. UTC
  Adding framework for common initialization routine for event mode.
Event mode would involve initialization of multiple devices, like
eventdev, ethdev etc and this routine would be the placeholder for all
initialization to come in.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Lukasz Bartosik <lbartosik@marvell.com>
---
 lib/librte_eventdev/rte_eventdev_version.map |  2 ++
 lib/librte_eventdev/rte_eventmode_helper.c   | 51 +++++++++++++++++++++++++++-
 lib/librte_eventdev/rte_eventmode_helper.h   | 26 +++++++++++++-
 3 files changed, 77 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map
index 1199064..e156fa0 100644
--- a/lib/librte_eventdev/rte_eventdev_version.map
+++ b/lib/librte_eventdev/rte_eventdev_version.map
@@ -130,4 +130,6 @@  EXPERIMENTAL {
 	rte_event_eth_rx_adapter_stats_get;
 	rte_eventmode_helper_print_options_list;
 	rte_eventmode_helper_print_options_description;
+	rte_eventmode_helper_parse_args;
+	rte_eventmode_helper_initialize_devs;
 };
diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c
index 38f1a2b..d1a569b 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.c
+++ b/lib/librte_eventdev/rte_eventmode_helper.c
@@ -3,6 +3,7 @@ 
  */
 #include <getopt.h>
 
+#include <rte_ethdev.h>
 #include <rte_eventmode_helper.h>
 #include <rte_malloc.h>
 
@@ -92,7 +93,7 @@  em_initialize_helper_conf(struct rte_eventmode_helper_conf *conf)
 	conf->eth_portmask = -1;
 }
 
-struct rte_eventmode_helper_conf *
+struct rte_eventmode_helper_conf * __rte_experimental
 rte_eventmode_helper_parse_args(int argc, char **argv)
 {
 	int32_t opt, ret;
@@ -152,3 +153,51 @@  rte_eventmode_helper_parse_args(int argc, char **argv)
 
 	return NULL;
 }
+
+int32_t __rte_experimental
+rte_eventmode_helper_initialize_devs(
+		struct rte_eventmode_helper_conf *mode_conf)
+{
+	int ret;
+	uint16_t portid;
+
+	if (mode_conf == NULL) {
+		RTE_EM_HLPR_LOG_ERR("Invalid conf");
+		return -1;
+	}
+
+	if (mode_conf->mode != RTE_EVENTMODE_HELPER_PKT_TRANSFER_MODE_EVENT)
+		return 0;
+
+	if (mode_conf->mode_params == NULL) {
+		RTE_EM_HLPR_LOG_ERR("Invalid mode params");
+		return -1;
+	}
+
+	/* Stop eth devices before setting up adapter */
+	RTE_ETH_FOREACH_DEV(portid) {
+
+		/* Use only the ports enabled */
+		if ((mode_conf->eth_portmask & (1 << portid)) == 0)
+			continue;
+
+		rte_eth_dev_stop(portid);
+	}
+
+	/* Start eth devices after setting up adapter */
+	RTE_ETH_FOREACH_DEV(portid) {
+
+		/* Use only the ports enabled */
+		if ((mode_conf->eth_portmask & (1 << portid)) == 0)
+			continue;
+
+		ret = rte_eth_dev_start(portid);
+		if (ret < 0) {
+			RTE_EM_HLPR_LOG_ERR(
+				"Error starting eth dev %d", portid);
+			return -1;
+		}
+	}
+
+	return 0;
+}
diff --git a/lib/librte_eventdev/rte_eventmode_helper.h b/lib/librte_eventdev/rte_eventmode_helper.h
index 77e69d0..0eafed3 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.h
+++ b/lib/librte_eventdev/rte_eventmode_helper.h
@@ -62,9 +62,33 @@  rte_eventmode_helper_print_options_description(void);
  * @return
  *   Configuration generated by parsing the event mode args.
  */
-struct rte_eventmode_helper_conf *
+struct rte_eventmode_helper_conf * __rte_experimental
 rte_eventmode_helper_parse_args(int argc, char **argv);
 
+/* Helper functions for initialization, & launching workers */
+
+/**
+ * Initialize event mode devices
+ *
+ * Application could call this function to get the event device, eth device
+ * and eth rx adapter initialized according to the conf populated using the
+ * command line args.
+ *
+ * Application is expected to initialize the eth device and then the eventmode
+ * helper subsystem will stop & start eth device according to it's requirement.
+ * So call to this function should be done after the eth device is successfully
+ * initialized.
+ *
+ * @param mode_conf
+ *   Configuration of the mode in which app is doing packet handling
+ * @return
+ *  - 0 on success.
+ *  - (<0) on failure.
+ */
+int32_t __rte_experimental
+rte_eventmode_helper_initialize_devs(
+		struct rte_eventmode_helper_conf *mode_conf);
+
 #ifdef __cplusplus
 }
 #endif