diff mbox series

[dpdk-dev,13/20] eventdev: add default conf for event devs field in conf

Message ID 1528478659-15859-14-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
Generate a default conf for event devs, if it's not specified in the
conf. This routine will check the available event devices and it's
properties and sets the conf accordingly.

Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
---
 lib/librte_eventdev/rte_eventmode_helper.c | 67 ++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
diff mbox series

Patch

diff --git a/lib/librte_eventdev/rte_eventmode_helper.c b/lib/librte_eventdev/rte_eventmode_helper.c
index 8dbbd1a..4d6888c 100644
--- a/lib/librte_eventdev/rte_eventmode_helper.c
+++ b/lib/librte_eventdev/rte_eventmode_helper.c
@@ -196,6 +196,63 @@  rte_eventmode_validate_user_params(struct eventmode_conf *em_conf)
 }
 
 static int
+rte_eventmode_helper_set_default_conf_eventdev(struct eventmode_conf *em_conf)
+{
+	int i, ret;
+	int nb_eventdev;
+	struct eventdev_params *eventdev_config;
+	struct rte_event_dev_info dev_info;
+
+	/* Get the number of event devices */
+	nb_eventdev = rte_event_dev_count();
+
+	if (nb_eventdev == 0) {
+		RTE_EM_HLPR_LOG_ERR("No event devices detected");
+		return -1;
+	}
+
+	for (i = 0; i < nb_eventdev; i++) {
+
+		/* Get the event dev conf */
+		eventdev_config = &(em_conf->eventdev_config[i]);
+
+		/* Read event device info */
+		ret = rte_event_dev_info_get(i, &dev_info);
+
+		if (ret < 0) {
+			RTE_EM_HLPR_LOG_ERR(
+				"Failed reading event device info (err:%d)",
+				ret);
+			return ret;
+		}
+
+		/* Check if enough ports are available */
+		if (dev_info.max_event_ports < 2) {
+			RTE_EM_HLPR_LOG_ERR("Not enough ports available");
+			return -1;
+		}
+
+		/* Save number of queues & ports available */
+		eventdev_config->eventdev_id = i;
+		eventdev_config->nb_eventqueue = dev_info.max_event_queues;
+		eventdev_config->nb_eventport = dev_info.max_event_ports;
+		eventdev_config->ev_queue_mode =
+				RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
+
+		/* One port is required for eth_rx_adapter */
+		eventdev_config->nb_eventport -= 1;
+
+		/* One queue is reserved for the final ethernet tx stage */
+		eventdev_config->nb_eventqueue -= 1;
+
+		/* Update the number of eventdevs */
+		em_conf->nb_eventdev++;
+	}
+
+	return 0;
+}
+
+static int
 rte_eventmode_helper_validate_conf(struct eventmode_conf *em_conf)
 {
 	int ret;
@@ -205,6 +262,16 @@  rte_eventmode_helper_validate_conf(struct eventmode_conf *em_conf)
 	if (ret != 0)
 		return ret;
 
+	/*
+	 * See if event devs are specified. Else probe the event devices
+	 * and initialize the conf with all ports & queues available
+	 */
+	if (em_conf->nb_eventdev == 0) {
+		ret = rte_eventmode_helper_set_default_conf_eventdev(em_conf);
+		if (ret != 0)
+			return ret;
+	}
+
 	return 0;
 }