xref: /dpdk/examples/l2fwd-event/l2fwd_event_internal_port.c (revision 6cf329f9d8c2eb97c8f39becd514c14b25251ac1)
169de9488SSunil Kumar Kori /* SPDX-License-Identifier: BSD-3-Clause
269de9488SSunil Kumar Kori  * Copyright(C) 2019 Marvell International Ltd.
369de9488SSunil Kumar Kori  */
469de9488SSunil Kumar Kori 
569de9488SSunil Kumar Kori #include <stdbool.h>
669de9488SSunil Kumar Kori #include <getopt.h>
769de9488SSunil Kumar Kori 
869de9488SSunil Kumar Kori #include <rte_cycles.h>
969de9488SSunil Kumar Kori #include <rte_ethdev.h>
1069de9488SSunil Kumar Kori #include <rte_eventdev.h>
1169de9488SSunil Kumar Kori #include <rte_event_eth_rx_adapter.h>
1269de9488SSunil Kumar Kori #include <rte_event_eth_tx_adapter.h>
1369de9488SSunil Kumar Kori #include <rte_lcore.h>
1469de9488SSunil Kumar Kori #include <rte_spinlock.h>
1569de9488SSunil Kumar Kori 
1669de9488SSunil Kumar Kori #include "l2fwd_common.h"
1769de9488SSunil Kumar Kori #include "l2fwd_event.h"
1869de9488SSunil Kumar Kori 
196ab87600SSunil Kumar Kori static uint32_t
206ab87600SSunil Kumar Kori l2fwd_event_device_setup_internal_port(struct l2fwd_resources *rsrc)
216ab87600SSunil Kumar Kori {
226ab87600SSunil Kumar Kori 	struct l2fwd_event_resources *evt_rsrc = rsrc->evt_rsrc;
236ab87600SSunil Kumar Kori 	struct rte_event_dev_config event_d_conf = {
246ab87600SSunil Kumar Kori 		.nb_events_limit  = 4096,
256ab87600SSunil Kumar Kori 		.nb_event_queue_flows = 1024,
266ab87600SSunil Kumar Kori 		.nb_event_port_dequeue_depth = 128,
276ab87600SSunil Kumar Kori 		.nb_event_port_enqueue_depth = 128
286ab87600SSunil Kumar Kori 	};
296ab87600SSunil Kumar Kori 	struct rte_event_dev_info dev_info;
306ab87600SSunil Kumar Kori 	const uint8_t event_d_id = 0; /* Always use first event device only */
316ab87600SSunil Kumar Kori 	uint32_t event_queue_cfg = 0;
326ab87600SSunil Kumar Kori 	uint16_t ethdev_count = 0;
336ab87600SSunil Kumar Kori 	uint16_t num_workers = 0;
346ab87600SSunil Kumar Kori 	uint16_t port_id;
356ab87600SSunil Kumar Kori 	int ret;
366ab87600SSunil Kumar Kori 
376ab87600SSunil Kumar Kori 	RTE_ETH_FOREACH_DEV(port_id) {
386ab87600SSunil Kumar Kori 		if ((rsrc->enabled_port_mask & (1 << port_id)) == 0)
396ab87600SSunil Kumar Kori 			continue;
406ab87600SSunil Kumar Kori 		ethdev_count++;
416ab87600SSunil Kumar Kori 	}
426ab87600SSunil Kumar Kori 
437be78d02SJosh Soref 	/* Event device configuration */
446ab87600SSunil Kumar Kori 	rte_event_dev_info_get(event_d_id, &dev_info);
456ab87600SSunil Kumar Kori 
46345a22d5SPavan Nikhilesh 	/* Enable implicit release */
47345a22d5SPavan Nikhilesh 	if (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE)
48345a22d5SPavan Nikhilesh 		evt_rsrc->disable_implicit_release = 0;
496ab87600SSunil Kumar Kori 
506ab87600SSunil Kumar Kori 	if (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES)
516ab87600SSunil Kumar Kori 		event_queue_cfg |= RTE_EVENT_QUEUE_CFG_ALL_TYPES;
526ab87600SSunil Kumar Kori 
536ab87600SSunil Kumar Kori 	event_d_conf.nb_event_queues = ethdev_count;
546ab87600SSunil Kumar Kori 	if (dev_info.max_event_queues < event_d_conf.nb_event_queues)
556ab87600SSunil Kumar Kori 		event_d_conf.nb_event_queues = dev_info.max_event_queues;
566ab87600SSunil Kumar Kori 
576ab87600SSunil Kumar Kori 	if (dev_info.max_num_events < event_d_conf.nb_events_limit)
586ab87600SSunil Kumar Kori 		event_d_conf.nb_events_limit = dev_info.max_num_events;
596ab87600SSunil Kumar Kori 
606ab87600SSunil Kumar Kori 	if (dev_info.max_event_queue_flows < event_d_conf.nb_event_queue_flows)
616ab87600SSunil Kumar Kori 		event_d_conf.nb_event_queue_flows =
626ab87600SSunil Kumar Kori 						dev_info.max_event_queue_flows;
636ab87600SSunil Kumar Kori 
646ab87600SSunil Kumar Kori 	if (dev_info.max_event_port_dequeue_depth <
656ab87600SSunil Kumar Kori 				event_d_conf.nb_event_port_dequeue_depth)
666ab87600SSunil Kumar Kori 		event_d_conf.nb_event_port_dequeue_depth =
676ab87600SSunil Kumar Kori 				dev_info.max_event_port_dequeue_depth;
686ab87600SSunil Kumar Kori 
696ab87600SSunil Kumar Kori 	if (dev_info.max_event_port_enqueue_depth <
706ab87600SSunil Kumar Kori 				event_d_conf.nb_event_port_enqueue_depth)
716ab87600SSunil Kumar Kori 		event_d_conf.nb_event_port_enqueue_depth =
726ab87600SSunil Kumar Kori 				dev_info.max_event_port_enqueue_depth;
736ab87600SSunil Kumar Kori 
74cb056611SStephen Hemminger 	/* Ignore Main core. */
75345a22d5SPavan Nikhilesh 	num_workers = rte_lcore_count() - 1;
766ab87600SSunil Kumar Kori 	if (dev_info.max_event_ports < num_workers)
776ab87600SSunil Kumar Kori 		num_workers = dev_info.max_event_ports;
786ab87600SSunil Kumar Kori 
796ab87600SSunil Kumar Kori 	event_d_conf.nb_event_ports = num_workers;
806ab87600SSunil Kumar Kori 	evt_rsrc->evp.nb_ports = num_workers;
816ab87600SSunil Kumar Kori 	evt_rsrc->evq.nb_queues = event_d_conf.nb_event_queues;
826ab87600SSunil Kumar Kori 	evt_rsrc->has_burst = !!(dev_info.event_dev_cap &
836ab87600SSunil Kumar Kori 				    RTE_EVENT_DEV_CAP_BURST_MODE);
846ab87600SSunil Kumar Kori 
85*6cf329f9SPavan Nikhilesh 	if (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE)
86*6cf329f9SPavan Nikhilesh 		event_d_conf.preschedule_type = RTE_EVENT_PRESCHEDULE;
87*6cf329f9SPavan Nikhilesh 
88*6cf329f9SPavan Nikhilesh 	if (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_EVENT_PRESCHEDULE_ADAPTIVE)
89*6cf329f9SPavan Nikhilesh 		event_d_conf.preschedule_type = RTE_EVENT_PRESCHEDULE_ADAPTIVE;
90*6cf329f9SPavan Nikhilesh 
916ab87600SSunil Kumar Kori 	ret = rte_event_dev_configure(event_d_id, &event_d_conf);
926ab87600SSunil Kumar Kori 	if (ret < 0)
936ab87600SSunil Kumar Kori 		rte_panic("Error in configuring event device\n");
946ab87600SSunil Kumar Kori 
956ab87600SSunil Kumar Kori 	evt_rsrc->event_d_id = event_d_id;
966ab87600SSunil Kumar Kori 	return event_queue_cfg;
976ab87600SSunil Kumar Kori }
986ab87600SSunil Kumar Kori 
993b5476dbSSunil Kumar Kori static void
1003b5476dbSSunil Kumar Kori l2fwd_event_port_setup_internal_port(struct l2fwd_resources *rsrc)
1013b5476dbSSunil Kumar Kori {
1023b5476dbSSunil Kumar Kori 	struct l2fwd_event_resources *evt_rsrc = rsrc->evt_rsrc;
1033b5476dbSSunil Kumar Kori 	uint8_t event_d_id = evt_rsrc->event_d_id;
1043b5476dbSSunil Kumar Kori 	struct rte_event_port_conf event_p_conf = {
1053b5476dbSSunil Kumar Kori 		.dequeue_depth = 32,
1063b5476dbSSunil Kumar Kori 		.enqueue_depth = 32,
1073b5476dbSSunil Kumar Kori 		.new_event_threshold = 4096
1083b5476dbSSunil Kumar Kori 	};
1093b5476dbSSunil Kumar Kori 	struct rte_event_port_conf def_p_conf;
1103b5476dbSSunil Kumar Kori 	uint8_t event_p_id;
1113b5476dbSSunil Kumar Kori 	int32_t ret;
1123b5476dbSSunil Kumar Kori 
1133b5476dbSSunil Kumar Kori 	evt_rsrc->evp.event_p_id = (uint8_t *)malloc(sizeof(uint8_t) *
1143b5476dbSSunil Kumar Kori 					evt_rsrc->evp.nb_ports);
1153b5476dbSSunil Kumar Kori 	if (!evt_rsrc->evp.event_p_id)
1163b5476dbSSunil Kumar Kori 		rte_panic("Failed to allocate memory for Event Ports\n");
1173b5476dbSSunil Kumar Kori 
1188cecdc7eSSunil Kumar Kori 	ret = rte_event_port_default_conf_get(event_d_id, 0, &def_p_conf);
1198cecdc7eSSunil Kumar Kori 	if (ret < 0)
1208cecdc7eSSunil Kumar Kori 		rte_panic("Error to get default configuration of event port\n");
1218cecdc7eSSunil Kumar Kori 
1223b5476dbSSunil Kumar Kori 	if (def_p_conf.new_event_threshold < event_p_conf.new_event_threshold)
1233b5476dbSSunil Kumar Kori 		event_p_conf.new_event_threshold =
1243b5476dbSSunil Kumar Kori 						def_p_conf.new_event_threshold;
1253b5476dbSSunil Kumar Kori 
1263b5476dbSSunil Kumar Kori 	if (def_p_conf.dequeue_depth < event_p_conf.dequeue_depth)
1273b5476dbSSunil Kumar Kori 		event_p_conf.dequeue_depth = def_p_conf.dequeue_depth;
1283b5476dbSSunil Kumar Kori 
1293b5476dbSSunil Kumar Kori 	if (def_p_conf.enqueue_depth < event_p_conf.enqueue_depth)
1303b5476dbSSunil Kumar Kori 		event_p_conf.enqueue_depth = def_p_conf.enqueue_depth;
1313b5476dbSSunil Kumar Kori 
13275d11313STimothy McDaniel 	event_p_conf.event_port_cfg = 0;
13375d11313STimothy McDaniel 	if (evt_rsrc->disable_implicit_release)
13475d11313STimothy McDaniel 		event_p_conf.event_port_cfg |=
13575d11313STimothy McDaniel 			RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL;
1363b5476dbSSunil Kumar Kori 
1373b5476dbSSunil Kumar Kori 	for (event_p_id = 0; event_p_id < evt_rsrc->evp.nb_ports;
1383b5476dbSSunil Kumar Kori 								event_p_id++) {
1393b5476dbSSunil Kumar Kori 		ret = rte_event_port_setup(event_d_id, event_p_id,
1403b5476dbSSunil Kumar Kori 					   &event_p_conf);
1413b5476dbSSunil Kumar Kori 		if (ret < 0)
1423b5476dbSSunil Kumar Kori 			rte_panic("Error in configuring event port %d\n",
1433b5476dbSSunil Kumar Kori 				  event_p_id);
1443b5476dbSSunil Kumar Kori 
1453b5476dbSSunil Kumar Kori 		ret = rte_event_port_link(event_d_id, event_p_id, NULL,
1463b5476dbSSunil Kumar Kori 					  NULL, 0);
1473b5476dbSSunil Kumar Kori 		if (ret < 0)
1483b5476dbSSunil Kumar Kori 			rte_panic("Error in linking event port %d to queue\n",
1493b5476dbSSunil Kumar Kori 				  event_p_id);
1503b5476dbSSunil Kumar Kori 		evt_rsrc->evp.event_p_id[event_p_id] = event_p_id;
1513b5476dbSSunil Kumar Kori 
1523b5476dbSSunil Kumar Kori 		/* init spinlock */
1533b5476dbSSunil Kumar Kori 		rte_spinlock_init(&evt_rsrc->evp.lock);
1543b5476dbSSunil Kumar Kori 	}
1553b5476dbSSunil Kumar Kori 
1563b5476dbSSunil Kumar Kori 	evt_rsrc->def_p_conf = event_p_conf;
1573b5476dbSSunil Kumar Kori }
1583b5476dbSSunil Kumar Kori 
1593b5476dbSSunil Kumar Kori static void
1603b5476dbSSunil Kumar Kori l2fwd_event_queue_setup_internal_port(struct l2fwd_resources *rsrc,
1613b5476dbSSunil Kumar Kori 				uint32_t event_queue_cfg)
1623b5476dbSSunil Kumar Kori {
1633b5476dbSSunil Kumar Kori 	struct l2fwd_event_resources *evt_rsrc = rsrc->evt_rsrc;
1643b5476dbSSunil Kumar Kori 	uint8_t event_d_id = evt_rsrc->event_d_id;
1653b5476dbSSunil Kumar Kori 	struct rte_event_queue_conf event_q_conf = {
1663b5476dbSSunil Kumar Kori 		.nb_atomic_flows = 1024,
1673b5476dbSSunil Kumar Kori 		.nb_atomic_order_sequences = 1024,
1683b5476dbSSunil Kumar Kori 		.event_queue_cfg = event_queue_cfg,
1693b5476dbSSunil Kumar Kori 		.priority = RTE_EVENT_DEV_PRIORITY_NORMAL
1703b5476dbSSunil Kumar Kori 	};
1713b5476dbSSunil Kumar Kori 	struct rte_event_queue_conf def_q_conf;
1723b5476dbSSunil Kumar Kori 	uint8_t event_q_id = 0;
1733b5476dbSSunil Kumar Kori 	int32_t ret;
1743b5476dbSSunil Kumar Kori 
1758cecdc7eSSunil Kumar Kori 	ret = rte_event_queue_default_conf_get(event_d_id, event_q_id,
1768cecdc7eSSunil Kumar Kori 					       &def_q_conf);
1778cecdc7eSSunil Kumar Kori 	if (ret < 0)
1788cecdc7eSSunil Kumar Kori 		rte_panic("Error to get default config of event queue\n");
1793b5476dbSSunil Kumar Kori 
1803b5476dbSSunil Kumar Kori 	if (def_q_conf.nb_atomic_flows < event_q_conf.nb_atomic_flows)
1813b5476dbSSunil Kumar Kori 		event_q_conf.nb_atomic_flows = def_q_conf.nb_atomic_flows;
1823b5476dbSSunil Kumar Kori 
1833b5476dbSSunil Kumar Kori 	if (def_q_conf.nb_atomic_order_sequences <
1843b5476dbSSunil Kumar Kori 					event_q_conf.nb_atomic_order_sequences)
1853b5476dbSSunil Kumar Kori 		event_q_conf.nb_atomic_order_sequences =
1863b5476dbSSunil Kumar Kori 					def_q_conf.nb_atomic_order_sequences;
1873b5476dbSSunil Kumar Kori 
1883b5476dbSSunil Kumar Kori 	event_q_conf.event_queue_cfg = event_queue_cfg;
1893b5476dbSSunil Kumar Kori 	event_q_conf.schedule_type = rsrc->sched_type;
1903b5476dbSSunil Kumar Kori 	evt_rsrc->evq.event_q_id = (uint8_t *)malloc(sizeof(uint8_t) *
1913b5476dbSSunil Kumar Kori 					evt_rsrc->evq.nb_queues);
1923b5476dbSSunil Kumar Kori 	if (!evt_rsrc->evq.event_q_id)
1933b5476dbSSunil Kumar Kori 		rte_panic("Memory allocation failure\n");
1943b5476dbSSunil Kumar Kori 
1953b5476dbSSunil Kumar Kori 	for (event_q_id = 0; event_q_id < evt_rsrc->evq.nb_queues;
1963b5476dbSSunil Kumar Kori 								event_q_id++) {
1973b5476dbSSunil Kumar Kori 		ret = rte_event_queue_setup(event_d_id, event_q_id,
1983b5476dbSSunil Kumar Kori 					    &event_q_conf);
1993b5476dbSSunil Kumar Kori 		if (ret < 0)
2003b5476dbSSunil Kumar Kori 			rte_panic("Error in configuring event queue\n");
2013b5476dbSSunil Kumar Kori 		evt_rsrc->evq.event_q_id[event_q_id] = event_q_id;
2023b5476dbSSunil Kumar Kori 	}
2033b5476dbSSunil Kumar Kori }
2043b5476dbSSunil Kumar Kori 
20550f05aa6SSunil Kumar Kori static void
20650f05aa6SSunil Kumar Kori l2fwd_rx_tx_adapter_setup_internal_port(struct l2fwd_resources *rsrc)
20750f05aa6SSunil Kumar Kori {
20850f05aa6SSunil Kumar Kori 	struct l2fwd_event_resources *evt_rsrc = rsrc->evt_rsrc;
209ab1488a3SDavid Marchand 	struct rte_event_eth_rx_adapter_queue_conf eth_q_conf;
21050f05aa6SSunil Kumar Kori 	uint8_t event_d_id = evt_rsrc->event_d_id;
21150f05aa6SSunil Kumar Kori 	uint16_t adapter_id = 0;
21250f05aa6SSunil Kumar Kori 	uint16_t nb_adapter = 0;
21350f05aa6SSunil Kumar Kori 	uint16_t port_id;
21450f05aa6SSunil Kumar Kori 	uint8_t q_id = 0;
21550f05aa6SSunil Kumar Kori 	int ret;
21650f05aa6SSunil Kumar Kori 
217ab1488a3SDavid Marchand 	memset(&eth_q_conf, 0, sizeof(eth_q_conf));
218ab1488a3SDavid Marchand 	eth_q_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
219ab1488a3SDavid Marchand 
22050f05aa6SSunil Kumar Kori 	RTE_ETH_FOREACH_DEV(port_id) {
22150f05aa6SSunil Kumar Kori 		if ((rsrc->enabled_port_mask & (1 << port_id)) == 0)
22250f05aa6SSunil Kumar Kori 			continue;
22350f05aa6SSunil Kumar Kori 		nb_adapter++;
22450f05aa6SSunil Kumar Kori 	}
22550f05aa6SSunil Kumar Kori 
22650f05aa6SSunil Kumar Kori 	evt_rsrc->rx_adptr.nb_rx_adptr = nb_adapter;
22750f05aa6SSunil Kumar Kori 	evt_rsrc->rx_adptr.rx_adptr = (uint8_t *)malloc(sizeof(uint8_t) *
22850f05aa6SSunil Kumar Kori 					evt_rsrc->rx_adptr.nb_rx_adptr);
22950f05aa6SSunil Kumar Kori 	if (!evt_rsrc->rx_adptr.rx_adptr) {
23050f05aa6SSunil Kumar Kori 		free(evt_rsrc->evp.event_p_id);
23150f05aa6SSunil Kumar Kori 		free(evt_rsrc->evq.event_q_id);
23250f05aa6SSunil Kumar Kori 		rte_panic("Failed to allocate memery for Rx adapter\n");
23350f05aa6SSunil Kumar Kori 	}
23450f05aa6SSunil Kumar Kori 
2359a212dc0SConor Fogarty 	/* Assigned ethernet port. 8< */
23650f05aa6SSunil Kumar Kori 	RTE_ETH_FOREACH_DEV(port_id) {
23750f05aa6SSunil Kumar Kori 		if ((rsrc->enabled_port_mask & (1 << port_id)) == 0)
23850f05aa6SSunil Kumar Kori 			continue;
239796b07e9SShijith Thotton 
240796b07e9SShijith Thotton 		if (rsrc->evt_vec.enabled) {
241796b07e9SShijith Thotton 			uint32_t cap;
242796b07e9SShijith Thotton 
243796b07e9SShijith Thotton 			if (rte_event_eth_rx_adapter_caps_get(event_d_id,
244796b07e9SShijith Thotton 							      port_id, &cap))
245796b07e9SShijith Thotton 				rte_panic(
246796b07e9SShijith Thotton 					"Failed to get event rx adapter capability");
247796b07e9SShijith Thotton 
248796b07e9SShijith Thotton 			if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR) {
249796b07e9SShijith Thotton 				eth_q_conf.vector_sz = rsrc->evt_vec.size;
250796b07e9SShijith Thotton 				eth_q_conf.vector_timeout_ns =
251796b07e9SShijith Thotton 					rsrc->evt_vec.timeout_ns;
252796b07e9SShijith Thotton 				eth_q_conf.vector_mp = rsrc->evt_vec_pool;
253796b07e9SShijith Thotton 				eth_q_conf.rx_queue_flags |=
254796b07e9SShijith Thotton 				RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR;
255796b07e9SShijith Thotton 			} else {
256796b07e9SShijith Thotton 				rte_panic(
257796b07e9SShijith Thotton 					"Rx adapter doesn't support event vector");
258796b07e9SShijith Thotton 			}
259796b07e9SShijith Thotton 		}
260796b07e9SShijith Thotton 
26150f05aa6SSunil Kumar Kori 		ret = rte_event_eth_rx_adapter_create(adapter_id, event_d_id,
26250f05aa6SSunil Kumar Kori 						&evt_rsrc->def_p_conf);
26350f05aa6SSunil Kumar Kori 		if (ret)
26450f05aa6SSunil Kumar Kori 			rte_panic("Failed to create rx adapter[%d]\n",
26550f05aa6SSunil Kumar Kori 				  adapter_id);
26650f05aa6SSunil Kumar Kori 
26750f05aa6SSunil Kumar Kori 		/* Configure user requested sched type*/
26850f05aa6SSunil Kumar Kori 		eth_q_conf.ev.sched_type = rsrc->sched_type;
26950f05aa6SSunil Kumar Kori 		eth_q_conf.ev.queue_id = evt_rsrc->evq.event_q_id[q_id];
27050f05aa6SSunil Kumar Kori 		ret = rte_event_eth_rx_adapter_queue_add(adapter_id, port_id,
27150f05aa6SSunil Kumar Kori 							 -1, &eth_q_conf);
27250f05aa6SSunil Kumar Kori 		if (ret)
27350f05aa6SSunil Kumar Kori 			rte_panic("Failed to add queues to Rx adapter\n");
27450f05aa6SSunil Kumar Kori 
27550f05aa6SSunil Kumar Kori 		ret = rte_event_eth_rx_adapter_start(adapter_id);
27650f05aa6SSunil Kumar Kori 		if (ret)
27750f05aa6SSunil Kumar Kori 			rte_panic("Rx adapter[%d] start Failed\n", adapter_id);
27850f05aa6SSunil Kumar Kori 
27950f05aa6SSunil Kumar Kori 		evt_rsrc->rx_adptr.rx_adptr[adapter_id] = adapter_id;
28050f05aa6SSunil Kumar Kori 		adapter_id++;
28150f05aa6SSunil Kumar Kori 		if (q_id < evt_rsrc->evq.nb_queues)
28250f05aa6SSunil Kumar Kori 			q_id++;
28350f05aa6SSunil Kumar Kori 	}
28450f05aa6SSunil Kumar Kori 
28550f05aa6SSunil Kumar Kori 	evt_rsrc->tx_adptr.nb_tx_adptr = nb_adapter;
28650f05aa6SSunil Kumar Kori 	evt_rsrc->tx_adptr.tx_adptr = (uint8_t *)malloc(sizeof(uint8_t) *
28750f05aa6SSunil Kumar Kori 					evt_rsrc->tx_adptr.nb_tx_adptr);
28850f05aa6SSunil Kumar Kori 	if (!evt_rsrc->tx_adptr.tx_adptr) {
28950f05aa6SSunil Kumar Kori 		free(evt_rsrc->rx_adptr.rx_adptr);
29050f05aa6SSunil Kumar Kori 		free(evt_rsrc->evp.event_p_id);
29150f05aa6SSunil Kumar Kori 		free(evt_rsrc->evq.event_q_id);
29250f05aa6SSunil Kumar Kori 		rte_panic("Failed to allocate memery for Rx adapter\n");
29350f05aa6SSunil Kumar Kori 	}
29450f05aa6SSunil Kumar Kori 
29550f05aa6SSunil Kumar Kori 	adapter_id = 0;
29650f05aa6SSunil Kumar Kori 	RTE_ETH_FOREACH_DEV(port_id) {
29750f05aa6SSunil Kumar Kori 		if ((rsrc->enabled_port_mask & (1 << port_id)) == 0)
29850f05aa6SSunil Kumar Kori 			continue;
29950f05aa6SSunil Kumar Kori 		ret = rte_event_eth_tx_adapter_create(adapter_id, event_d_id,
30050f05aa6SSunil Kumar Kori 						&evt_rsrc->def_p_conf);
30150f05aa6SSunil Kumar Kori 		if (ret)
30250f05aa6SSunil Kumar Kori 			rte_panic("Failed to create tx adapter[%d]\n",
30350f05aa6SSunil Kumar Kori 				  adapter_id);
30450f05aa6SSunil Kumar Kori 
30550f05aa6SSunil Kumar Kori 		ret = rte_event_eth_tx_adapter_queue_add(adapter_id, port_id,
30650f05aa6SSunil Kumar Kori 							 -1);
30750f05aa6SSunil Kumar Kori 		if (ret)
30850f05aa6SSunil Kumar Kori 			rte_panic("Failed to add queues to Tx adapter\n");
30950f05aa6SSunil Kumar Kori 
31050f05aa6SSunil Kumar Kori 		ret = rte_event_eth_tx_adapter_start(adapter_id);
31150f05aa6SSunil Kumar Kori 		if (ret)
31250f05aa6SSunil Kumar Kori 			rte_panic("Tx adapter[%d] start Failed\n", adapter_id);
31350f05aa6SSunil Kumar Kori 
31450f05aa6SSunil Kumar Kori 		evt_rsrc->tx_adptr.tx_adptr[adapter_id] = adapter_id;
31550f05aa6SSunil Kumar Kori 		adapter_id++;
31650f05aa6SSunil Kumar Kori 	}
3179a212dc0SConor Fogarty 	/* >8 End of assigned ethernet port. */
31850f05aa6SSunil Kumar Kori }
31950f05aa6SSunil Kumar Kori 
32069de9488SSunil Kumar Kori void
32169de9488SSunil Kumar Kori l2fwd_event_set_internal_port_ops(struct event_setup_ops *ops)
32269de9488SSunil Kumar Kori {
3236ab87600SSunil Kumar Kori 	ops->event_device_setup = l2fwd_event_device_setup_internal_port;
3243b5476dbSSunil Kumar Kori 	ops->event_queue_setup = l2fwd_event_queue_setup_internal_port;
3253b5476dbSSunil Kumar Kori 	ops->event_port_setup = l2fwd_event_port_setup_internal_port;
32650f05aa6SSunil Kumar Kori 	ops->adapter_setup = l2fwd_rx_tx_adapter_setup_internal_port;
32769de9488SSunil Kumar Kori }
328