[dpdk-dev] [PATCH 06/20] eventdev: add common initialize routine for eventmode devs

Anoob Joseph anoob.joseph at caviumnetworks.com
Fri Jun 8 19:24:05 CEST 2018


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 <anoob.joseph at caviumnetworks.com>
---
 lib/librte_eventdev/rte_eventmode_helper.c | 49 ++++++++++++++++++++++++++++++
 lib/librte_eventdev/rte_eventmode_helper.h | 25 +++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c
index ec014a6..f2c2b78 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>
 
@@ -152,3 +153,51 @@ rte_eventmode_helper_parse_args(int argc, char **argv)
 
 	return NULL;
 }
+
+int32_t
+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 7500f0c..e1e8a3b 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.h
+++ b/lib/librte_eventdev/rte_eventmode_helper.h
@@ -60,4 +60,29 @@ rte_eventmode_helper_print_options_description(void);
 struct rte_eventmode_helper_conf *
 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_eventmode_helper_initialize_devs(
+		struct rte_eventmode_helper_conf *mode_conf);
+
+
 #endif /* _RTE_EVENTMODE_HELPER_H_ */
-- 
2.7.4



More information about the dev mailing list