[03/11] examples/l3fwd: add event device configuration
diff mbox series

Message ID 20190926100558.24348-4-pbhagavatula@marvell.com
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • example/l3fwd: introduce event device support
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula Sept. 26, 2019, 10:05 a.m. UTC
From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Add event device configuration based on the capabilities of the
probed event device.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 examples/l3fwd/l3fwd_eventdev.c               | 67 +++++++++++++++++++
 examples/l3fwd/l3fwd_eventdev.h               |  4 ++
 examples/l3fwd/l3fwd_eventdev_internal_port.c |  1 +
 3 files changed, 72 insertions(+)

Patch
diff mbox series

diff --git a/examples/l3fwd/l3fwd_eventdev.c b/examples/l3fwd/l3fwd_eventdev.c
index fa464626d..7e2c4c66b 100644
--- a/examples/l3fwd/l3fwd_eventdev.c
+++ b/examples/l3fwd/l3fwd_eventdev.c
@@ -91,10 +91,74 @@  l3fwd_eventdev_capability_setup(void)
 		l3fwd_eventdev_set_internal_port_ops(&evdev_rsrc->ops);
 }
 
+
+static uint32_t
+l3fwd_eventdev_setup(uint16_t ethdev_count)
+{
+	struct l3fwd_eventdev_resources *evdev_rsrc = l3fwd_get_eventdev_rsrc();
+	struct rte_event_dev_config event_d_conf = {
+		.nb_events_limit  = 4096,
+		.nb_event_queue_flows = 1024,
+		.nb_event_port_dequeue_depth = 128,
+		.nb_event_port_enqueue_depth = 128
+	};
+	struct rte_event_dev_info dev_info;
+	const uint8_t event_d_id = 0; /* Always use first event device only */
+	uint32_t event_queue_cfg = 0;
+	uint16_t num_workers = 0;
+	int ret;
+
+	/* Event device configurtion */
+	rte_event_dev_info_get(event_d_id, &dev_info);
+	evdev_rsrc->disable_implicit_release = !!(dev_info.event_dev_cap &
+				    RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE);
+
+	if (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES)
+		event_queue_cfg |= RTE_EVENT_QUEUE_CFG_ALL_TYPES;
+
+	event_d_conf.nb_event_queues = ethdev_count +
+			(evdev_rsrc->tx_mode_q ? 1 : 0);
+	if (dev_info.max_event_queues < event_d_conf.nb_event_queues)
+		event_d_conf.nb_event_queues = dev_info.max_event_queues;
+
+	if (dev_info.max_num_events < event_d_conf.nb_events_limit)
+		event_d_conf.nb_events_limit = dev_info.max_num_events;
+
+	if (dev_info.max_event_queue_flows < event_d_conf.nb_event_queue_flows)
+		event_d_conf.nb_event_queue_flows =
+						dev_info.max_event_queue_flows;
+
+	if (dev_info.max_event_port_dequeue_depth <
+				event_d_conf.nb_event_port_dequeue_depth)
+		event_d_conf.nb_event_port_dequeue_depth =
+				dev_info.max_event_port_dequeue_depth;
+
+	if (dev_info.max_event_port_enqueue_depth <
+				event_d_conf.nb_event_port_enqueue_depth)
+		event_d_conf.nb_event_port_enqueue_depth =
+				dev_info.max_event_port_enqueue_depth;
+
+	num_workers = rte_lcore_count() - rte_service_lcore_count();
+	if (dev_info.max_event_ports < num_workers)
+		num_workers = dev_info.max_event_ports;
+
+	event_d_conf.nb_event_ports = num_workers;
+	evdev_rsrc->has_burst = !!(dev_info.event_dev_cap &
+				    RTE_EVENT_DEV_CAP_BURST_MODE);
+
+	ret = rte_event_dev_configure(event_d_id, &event_d_conf);
+	if (ret < 0)
+		rte_exit(EXIT_FAILURE, "Error in configuring event device");
+
+	evdev_rsrc->event_d_id = event_d_id;
+	return event_queue_cfg;
+}
+
 void
 l3fwd_eventdev_resource_setup(void)
 {
 	struct l3fwd_eventdev_resources *evdev_rsrc = l3fwd_get_eventdev_rsrc();
+	uint16_t ethdev_count = rte_eth_dev_count_avail();
 	int32_t ret;
 
 	/* Parse eventdev command line options */
@@ -107,4 +171,7 @@  l3fwd_eventdev_resource_setup(void)
 
 	/* Setup eventdev capability callbacks */
 	l3fwd_eventdev_capability_setup();
+
+	/* Event device configuration */
+	l3fwd_eventdev_setup(ethdev_count);
 }
diff --git a/examples/l3fwd/l3fwd_eventdev.h b/examples/l3fwd/l3fwd_eventdev.h
index 61a537864..ce4e35443 100644
--- a/examples/l3fwd/l3fwd_eventdev.h
+++ b/examples/l3fwd/l3fwd_eventdev.h
@@ -8,6 +8,7 @@ 
 #include <rte_common.h>
 #include <rte_eventdev.h>
 #include <rte_event_eth_tx_adapter.h>
+#include <rte_service.h>
 #include <rte_spinlock.h>
 
 #include "l3fwd.h"
@@ -37,9 +38,12 @@  struct l3fwd_eventdev_setup_ops {
 };
 
 struct l3fwd_eventdev_resources {
+	uint8_t disable_implicit_release;
 	struct l3fwd_eventdev_setup_ops ops;
+	uint8_t event_d_id;
 	uint8_t sync_mode;
 	uint8_t tx_mode_q;
+	uint8_t has_burst;
 	uint8_t enabled;
 	uint8_t nb_args;
 	char **args;
diff --git a/examples/l3fwd/l3fwd_eventdev_internal_port.c b/examples/l3fwd/l3fwd_eventdev_internal_port.c
index f698a0ce1..d40185862 100644
--- a/examples/l3fwd/l3fwd_eventdev_internal_port.c
+++ b/examples/l3fwd/l3fwd_eventdev_internal_port.c
@@ -5,6 +5,7 @@ 
 #include "l3fwd.h"
 #include "l3fwd_eventdev.h"
 
+
 void
 l3fwd_eventdev_set_internal_port_ops(struct l3fwd_eventdev_setup_ops *ops)
 {