diff mbox series

[dpdk-dev,11/20] eventdev: add Rx adapter init in eventmode

Message ID 1528478659-15859-12-git-send-email-anoob.joseph@caviumnetworks.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers show
Series add eventmode helper functions | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Anoob Joseph June 8, 2018, 5:24 p.m. UTC
Adding rx adapter conf. The helper init routine would be initializing
the rx adapter according to the conf.

Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
---
 lib/librte_eventdev/rte_eventmode_helper.c         | 122 +++++++++++++++++++++
 .../rte_eventmode_helper_internal.h                |  27 +++++
 2 files changed, 149 insertions(+)
diff mbox series

Patch

diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c
index 9f2d6de..aade9e1 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.c
+++ b/lib/librte_eventdev/rte_eventmode_helper.c
@@ -6,6 +6,7 @@ 
 #include <rte_ethdev.h>
 #include <rte_eventdev.h>
 #include <rte_eventmode_helper.h>
+#include <rte_event_eth_rx_adapter.h>
 #include <rte_malloc.h>
 
 #include "rte_eventmode_helper_internal.h"
@@ -357,6 +358,122 @@  rte_eventmode_helper_initialize_ethdev(struct eventmode_conf *em_conf)
 	return 0;
 }
 
+static int
+rx_adapter_configure(struct eventmode_conf *em_conf,
+	struct rx_adapter_conf *adapter)
+{
+	int j;
+	int ret;
+	uint8_t eventdev_id;
+	uint32_t service_id;
+	struct adapter_connection_info *conn;
+	struct rte_event_port_conf port_conf = {0};
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+	struct rte_event_dev_info evdev_default_conf = {0};
+
+	/* Get event dev ID */
+	eventdev_id = adapter->eventdev_id;
+
+	/* Create rx_adapter */
+
+	/* Get default configuration of event dev */
+	ret = rte_event_dev_info_get(eventdev_id, &evdev_default_conf);
+	if (ret < 0) {
+		RTE_EM_HLPR_LOG_ERR(
+			"Error in getting event device info[devID:%d]",
+			eventdev_id);
+		return ret;
+	}
+
+	/* Setup port conf */
+	port_conf.new_event_threshold = 1200;
+	port_conf.dequeue_depth =
+			evdev_default_conf.max_event_port_dequeue_depth;
+	port_conf.enqueue_depth =
+			evdev_default_conf.max_event_port_enqueue_depth;
+
+	/* Create adapter */
+	ret = rte_event_eth_rx_adapter_create(adapter->adapter_id,
+			adapter->eventdev_id,
+			&port_conf);
+	if (ret < 0) {
+		RTE_EM_HLPR_LOG_ERR("Error in rx adapter creation");
+		return ret;
+	}
+
+	/* Setup various connections in the adapter */
+
+	queue_conf.rx_queue_flags =
+			RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
+
+	for (j = 0; j < adapter->nb_connections; j++) {
+		/* Get connection */
+		conn = &(adapter->conn[j]);
+
+		/* Setup queue conf */
+		queue_conf.ev.queue_id = conn->eventq_id;
+		queue_conf.ev.sched_type = em_conf->ext_params.s1_sched_type;
+
+		/* Set flow ID as ethdev ID */
+		queue_conf.ev.flow_id = conn->ethdev_id;
+
+		/* Add queue to the adapter */
+		ret = rte_event_eth_rx_adapter_queue_add(
+				adapter->adapter_id,
+				conn->ethdev_id,
+				conn->ethdev_rx_qid,
+				&queue_conf);
+		if (ret < 0) {
+			RTE_EM_HLPR_LOG_ERR(
+				"Error in adding eth queue in event adapter");
+			return ret;
+		}
+	}
+
+	/* Get the service ID used by rx adapter */
+	ret = rte_event_eth_rx_adapter_service_id_get(adapter->adapter_id,
+						      &service_id);
+	if (ret != -ESRCH && ret != 0) {
+		RTE_EM_HLPR_LOG_ERR(
+			"Error getting service ID used by adapter");
+		return ret;
+	}
+
+	/*
+	 * Rx core will invoke the service when required. The runstate check
+	 * is not required.
+	 *
+	 */
+	rte_service_set_runstate_mapped_check(service_id, 0);
+
+	/* Start adapter */
+	ret = rte_event_eth_rx_adapter_start(adapter->adapter_id);
+	if (ret) {
+		RTE_EM_HLPR_LOG_ERR("Error in starting rx adapter");
+		return ret;
+	}
+
+	return 0;
+}
+
+static int
+rte_eventmode_helper_initialize_rx_adapter(struct eventmode_conf *em_conf)
+{
+	int i, ret;
+	struct rx_adapter_conf *adapter;
+
+	/* Configure rx adapters */
+	for (i = 0; i < em_conf->nb_rx_adapter; i++) {
+		adapter = &(em_conf->adapter[i]);
+		ret = rx_adapter_configure(em_conf, adapter);
+		if (ret < 0) {
+			RTE_EM_HLPR_LOG_ERR("Rx adapter configuration failed");
+			return ret;
+		}
+	}
+	return 0;
+}
+
 int32_t
 rte_eventmode_helper_initialize_devs(
 		struct rte_eventmode_helper_conf *mode_conf)
@@ -401,6 +518,11 @@  rte_eventmode_helper_initialize_devs(
 	if (ret != 0)
 		return ret;
 
+	/* Setup rx adapter */
+	ret = rte_eventmode_helper_initialize_rx_adapter(em_conf);
+	if (ret != 0)
+		return ret;
+
 	/* Start eth devices after setting up adapter */
 	RTE_ETH_FOREACH_DEV(portid) {
 
diff --git a/lib/librte_eventdev/rte_eventmode_helper_internal.h b/lib/librte_eventdev/rte_eventmode_helper_internal.h
index e9c1b4f..63b2fb5 100644
--- a/lib/librte_eventdev/rte_eventmode_helper_internal.h
+++ b/lib/librte_eventdev/rte_eventmode_helper_internal.h
@@ -30,6 +30,12 @@ 
 /* Max event devices supported */
 #define EVENT_MODE_MAX_EVENT_DEVS RTE_EVENT_MAX_DEVS
 
+/* Max rx adapters supported */
+#define EVENT_MODE_MAX_RX_ADAPTERS RTE_EVENT_MAX_DEVS
+
+/* Max rx adapter connections */
+#define EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER 16
+
 /* Max event queues supported per event device */
 #define EVENT_MODE_MAX_EVENT_QUEUES_PER_DEV RTE_EVENT_MAX_QUEUES_PER_DEV
 
@@ -45,12 +51,33 @@  struct eventdev_params {
 	uint8_t ev_queue_mode;
 };
 
+/* Rx adapter connection info */
+struct adapter_connection_info {
+	uint8_t ethdev_id;
+	uint8_t eventq_id;
+	int32_t ethdev_rx_qid;
+};
+
+/* Rx adapter conf */
+struct rx_adapter_conf {
+	int32_t eventdev_id;
+	int32_t adapter_id;
+	uint32_t rx_core_id;
+	uint8_t nb_connections;
+	struct adapter_connection_info
+			conn[EVENT_MODE_MAX_CONNECTIONS_PER_ADAPTER];
+};
+
 /* Eventmode conf data */
 struct eventmode_conf {
 	int nb_eventdev;
 		/**< No of event devs */
 	struct eventdev_params eventdev_config[EVENT_MODE_MAX_EVENT_DEVS];
 		/**< Per event dev conf */
+	uint8_t nb_rx_adapter;
+		/**< No of adapters */
+	struct rx_adapter_conf adapter[EVENT_MODE_MAX_RX_ADAPTERS];
+		/**< Adapter conf */
 	uint8_t nb_link;
 		/**< No of links */
 	struct rte_eventmode_helper_event_link_info