xref: /dpdk/app/test-eventdev/test_order_common.c (revision b6a7e6852e9ab82ae0e05e2d2a0b83abca17de3b)
153a3b7e8SJerin Jacob /* SPDX-License-Identifier: BSD-3-Clause
253a3b7e8SJerin Jacob  * Copyright(c) 2017 Cavium, Inc
3d1f59fb7SJerin Jacob  */
4d1f59fb7SJerin Jacob 
508966fe7STyler Retzlaff #include <stdalign.h>
608966fe7STyler Retzlaff 
7d1f59fb7SJerin Jacob #include "test_order_common.h"
8d1f59fb7SJerin Jacob 
9d1f59fb7SJerin Jacob int
order_test_result(struct evt_test * test,struct evt_options * opt)10ba11ebf1SJerin Jacob order_test_result(struct evt_test *test, struct evt_options *opt)
11ba11ebf1SJerin Jacob {
12ba11ebf1SJerin Jacob 	RTE_SET_USED(opt);
13ba11ebf1SJerin Jacob 	struct test_order *t = evt_test_priv(test);
14ba11ebf1SJerin Jacob 
15ba11ebf1SJerin Jacob 	return t->result;
16ba11ebf1SJerin Jacob }
17ba11ebf1SJerin Jacob 
1833b7483dSJerin Jacob static inline int
order_producer(void * arg)1933b7483dSJerin Jacob order_producer(void *arg)
2033b7483dSJerin Jacob {
2133b7483dSJerin Jacob 	struct prod_data *p  = arg;
2233b7483dSJerin Jacob 	struct test_order *t = p->t;
2333b7483dSJerin Jacob 	struct evt_options *opt = t->opt;
2433b7483dSJerin Jacob 	const uint8_t dev_id = p->dev_id;
2533b7483dSJerin Jacob 	const uint8_t port = p->port_id;
2633b7483dSJerin Jacob 	struct rte_mempool *pool = t->pool;
2733b7483dSJerin Jacob 	const uint64_t nb_pkts = t->nb_pkts;
2833b7483dSJerin Jacob 	uint32_t *producer_flow_seq = t->producer_flow_seq;
2933b7483dSJerin Jacob 	const uint32_t nb_flows = t->nb_flows;
3033b7483dSJerin Jacob 	uint64_t count = 0;
3133b7483dSJerin Jacob 	struct rte_mbuf *m;
3233b7483dSJerin Jacob 	struct rte_event ev;
3333b7483dSJerin Jacob 
3433b7483dSJerin Jacob 	if (opt->verbose_level > 1)
3533b7483dSJerin Jacob 		printf("%s(): lcore %d dev_id %d port=%d queue=%d\n",
3633b7483dSJerin Jacob 			 __func__, rte_lcore_id(), dev_id, port, p->queue_id);
3733b7483dSJerin Jacob 
3833b7483dSJerin Jacob 	ev.event = 0;
3933b7483dSJerin Jacob 	ev.op = RTE_EVENT_OP_NEW;
4033b7483dSJerin Jacob 	ev.queue_id = p->queue_id;
4133b7483dSJerin Jacob 	ev.sched_type = RTE_SCHED_TYPE_ORDERED;
4233b7483dSJerin Jacob 	ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
4333b7483dSJerin Jacob 	ev.event_type =  RTE_EVENT_TYPE_CPU;
4433b7483dSJerin Jacob 	ev.sub_event_type = 0; /* stage 0 */
4533b7483dSJerin Jacob 
4633b7483dSJerin Jacob 	while (count < nb_pkts && t->err == false) {
4733b7483dSJerin Jacob 		m = rte_pktmbuf_alloc(pool);
4833b7483dSJerin Jacob 		if (m == NULL)
4933b7483dSJerin Jacob 			continue;
5033b7483dSJerin Jacob 
51a4931d5bSThomas Monjalon 		const flow_id_t flow = (uintptr_t)m % nb_flows;
5233b7483dSJerin Jacob 		/* Maintain seq number per flow */
5345a059b0SDavid Marchand 		*order_mbuf_seqn(t, m) = producer_flow_seq[flow]++;
54a4931d5bSThomas Monjalon 		order_flow_id_save(t, flow, m, &ev);
5533b7483dSJerin Jacob 
5633b7483dSJerin Jacob 		while (rte_event_enqueue_burst(dev_id, port, &ev, 1) != 1) {
5733b7483dSJerin Jacob 			if (t->err)
5833b7483dSJerin Jacob 				break;
5933b7483dSJerin Jacob 			rte_pause();
6033b7483dSJerin Jacob 		}
6133b7483dSJerin Jacob 
6233b7483dSJerin Jacob 		count++;
6333b7483dSJerin Jacob 	}
6433b7483dSJerin Jacob 	return 0;
6533b7483dSJerin Jacob }
6633b7483dSJerin Jacob 
67ba11ebf1SJerin Jacob int
order_opt_check(struct evt_options * opt)68ba11ebf1SJerin Jacob order_opt_check(struct evt_options *opt)
69ba11ebf1SJerin Jacob {
70f77f8c9fSPavan Nikhilesh 	if (opt->prod_type != EVT_PROD_TYPE_SYNT) {
719fdc9986SPavan Nikhilesh 		evt_err("Invalid producer type '%s' valid producer '%s'",
729fdc9986SPavan Nikhilesh 			evt_prod_id_to_name(opt->prod_type),
739fdc9986SPavan Nikhilesh 			evt_prod_id_to_name(EVT_PROD_TYPE_SYNT));
749fdc9986SPavan Nikhilesh 		return -1;
75f77f8c9fSPavan Nikhilesh 	}
76f77f8c9fSPavan Nikhilesh 
77cb056611SStephen Hemminger 	/* 1 producer + N workers + main */
78ba11ebf1SJerin Jacob 	if (rte_lcore_count() < 3) {
79ba11ebf1SJerin Jacob 		evt_err("test need minimum 3 lcores");
80ba11ebf1SJerin Jacob 		return -1;
81ba11ebf1SJerin Jacob 	}
82ba11ebf1SJerin Jacob 
83ba11ebf1SJerin Jacob 	/* Validate worker lcores */
84cb056611SStephen Hemminger 	if (evt_lcores_has_overlap(opt->wlcores, rte_get_main_lcore())) {
85cb056611SStephen Hemminger 		evt_err("worker lcores overlaps with main lcore");
86ba11ebf1SJerin Jacob 		return -1;
87ba11ebf1SJerin Jacob 	}
88ba11ebf1SJerin Jacob 
89ba11ebf1SJerin Jacob 	if (evt_nr_active_lcores(opt->plcores) == 0) {
90ba11ebf1SJerin Jacob 		evt_err("missing the producer lcore");
91ba11ebf1SJerin Jacob 		return -1;
92ba11ebf1SJerin Jacob 	}
93ba11ebf1SJerin Jacob 
94ba11ebf1SJerin Jacob 	if (evt_nr_active_lcores(opt->plcores) != 1) {
95ba11ebf1SJerin Jacob 		evt_err("only one producer lcore must be selected");
96ba11ebf1SJerin Jacob 		return -1;
97ba11ebf1SJerin Jacob 	}
98ba11ebf1SJerin Jacob 
99ba11ebf1SJerin Jacob 	int plcore = evt_get_first_active_lcore(opt->plcores);
100ba11ebf1SJerin Jacob 
101ba11ebf1SJerin Jacob 	if (plcore < 0) {
102ba11ebf1SJerin Jacob 		evt_err("failed to find active producer");
103ba11ebf1SJerin Jacob 		return plcore;
104ba11ebf1SJerin Jacob 	}
105ba11ebf1SJerin Jacob 
106ba11ebf1SJerin Jacob 	if (evt_lcores_has_overlap(opt->wlcores, plcore)) {
107ba11ebf1SJerin Jacob 		evt_err("worker lcores overlaps producer lcore");
108ba11ebf1SJerin Jacob 		return -1;
109ba11ebf1SJerin Jacob 	}
110ba11ebf1SJerin Jacob 	if (evt_has_disabled_lcore(opt->wlcores)) {
111ba11ebf1SJerin Jacob 		evt_err("one or more workers lcores are not enabled");
112ba11ebf1SJerin Jacob 		return -1;
113ba11ebf1SJerin Jacob 	}
114ba11ebf1SJerin Jacob 	if (!evt_has_active_lcore(opt->wlcores)) {
115ba11ebf1SJerin Jacob 		evt_err("minimum one worker is required");
116ba11ebf1SJerin Jacob 		return -1;
117ba11ebf1SJerin Jacob 	}
118ba11ebf1SJerin Jacob 
119ba11ebf1SJerin Jacob 	/* Validate producer lcore */
120cb056611SStephen Hemminger 	if (plcore == (int)rte_get_main_lcore()) {
121cb056611SStephen Hemminger 		evt_err("producer lcore and main lcore should be different");
122ba11ebf1SJerin Jacob 		return -1;
123ba11ebf1SJerin Jacob 	}
124ba11ebf1SJerin Jacob 	if (!rte_lcore_is_enabled(plcore)) {
125ba11ebf1SJerin Jacob 		evt_err("producer lcore is not enabled");
126ba11ebf1SJerin Jacob 		return -1;
127ba11ebf1SJerin Jacob 	}
128ba11ebf1SJerin Jacob 
129ba11ebf1SJerin Jacob 	/* Fixups */
130ba11ebf1SJerin Jacob 	if (opt->nb_pkts == 0)
131ba11ebf1SJerin Jacob 		opt->nb_pkts = INT64_MAX;
132ba11ebf1SJerin Jacob 
133ba11ebf1SJerin Jacob 	return 0;
134ba11ebf1SJerin Jacob }
135ba11ebf1SJerin Jacob 
136ba11ebf1SJerin Jacob int
order_test_setup(struct evt_test * test,struct evt_options * opt)137d1f59fb7SJerin Jacob order_test_setup(struct evt_test *test, struct evt_options *opt)
138d1f59fb7SJerin Jacob {
139d1f59fb7SJerin Jacob 	void *test_order;
140a4931d5bSThomas Monjalon 	struct test_order *t;
141a4931d5bSThomas Monjalon 	static const struct rte_mbuf_dynfield flow_id_dynfield_desc = {
142a4931d5bSThomas Monjalon 		.name = "test_event_dynfield_flow_id",
143a4931d5bSThomas Monjalon 		.size = sizeof(flow_id_t),
14408966fe7STyler Retzlaff 		.align = alignof(flow_id_t),
145a4931d5bSThomas Monjalon 	};
14645a059b0SDavid Marchand 	static const struct rte_mbuf_dynfield seqn_dynfield_desc = {
14745a059b0SDavid Marchand 		.name = "test_event_dynfield_seqn",
14845a059b0SDavid Marchand 		.size = sizeof(seqn_t),
14908966fe7STyler Retzlaff 		.align = alignof(seqn_t),
15045a059b0SDavid Marchand 	};
151d1f59fb7SJerin Jacob 
152d1f59fb7SJerin Jacob 	test_order = rte_zmalloc_socket(test->name, sizeof(struct test_order),
153d1f59fb7SJerin Jacob 				RTE_CACHE_LINE_SIZE, opt->socket_id);
154d1f59fb7SJerin Jacob 	if (test_order  == NULL) {
155d1f59fb7SJerin Jacob 		evt_err("failed to allocate test_order memory");
156d1f59fb7SJerin Jacob 		goto nomem;
157d1f59fb7SJerin Jacob 	}
158d1f59fb7SJerin Jacob 	test->test_priv = test_order;
159a4931d5bSThomas Monjalon 	t = evt_test_priv(test);
160d1f59fb7SJerin Jacob 
161a4931d5bSThomas Monjalon 	t->flow_id_dynfield_offset =
162a4931d5bSThomas Monjalon 		rte_mbuf_dynfield_register(&flow_id_dynfield_desc);
163a4931d5bSThomas Monjalon 	if (t->flow_id_dynfield_offset < 0) {
164a4931d5bSThomas Monjalon 		evt_err("failed to register mbuf field");
165a4931d5bSThomas Monjalon 		return -rte_errno;
166a4931d5bSThomas Monjalon 	}
167d1f59fb7SJerin Jacob 
16845a059b0SDavid Marchand 	t->seqn_dynfield_offset =
16945a059b0SDavid Marchand 		rte_mbuf_dynfield_register(&seqn_dynfield_desc);
17045a059b0SDavid Marchand 	if (t->seqn_dynfield_offset < 0) {
17145a059b0SDavid Marchand 		evt_err("failed to register mbuf field");
17245a059b0SDavid Marchand 		return -rte_errno;
17345a059b0SDavid Marchand 	}
17445a059b0SDavid Marchand 
175d1f59fb7SJerin Jacob 	t->producer_flow_seq = rte_zmalloc_socket("test_producer_flow_seq",
176d1f59fb7SJerin Jacob 				 sizeof(*t->producer_flow_seq) * opt->nb_flows,
177d1f59fb7SJerin Jacob 				RTE_CACHE_LINE_SIZE, opt->socket_id);
178d1f59fb7SJerin Jacob 
179d1f59fb7SJerin Jacob 	if (t->producer_flow_seq  == NULL) {
180d1f59fb7SJerin Jacob 		evt_err("failed to allocate t->producer_flow_seq memory");
181d1f59fb7SJerin Jacob 		goto prod_nomem;
182d1f59fb7SJerin Jacob 	}
183d1f59fb7SJerin Jacob 
184d1f59fb7SJerin Jacob 	t->expected_flow_seq = rte_zmalloc_socket("test_expected_flow_seq",
185d1f59fb7SJerin Jacob 				 sizeof(*t->expected_flow_seq) * opt->nb_flows,
186d1f59fb7SJerin Jacob 				RTE_CACHE_LINE_SIZE, opt->socket_id);
187d1f59fb7SJerin Jacob 
188d1f59fb7SJerin Jacob 	if (t->expected_flow_seq  == NULL) {
189d1f59fb7SJerin Jacob 		evt_err("failed to allocate t->expected_flow_seq memory");
190d1f59fb7SJerin Jacob 		goto exp_nomem;
191d1f59fb7SJerin Jacob 	}
192*b6a7e685STyler Retzlaff 	rte_atomic_store_explicit(&t->outstand_pkts, opt->nb_pkts, rte_memory_order_relaxed);
193d1f59fb7SJerin Jacob 	t->err = false;
194d1f59fb7SJerin Jacob 	t->nb_pkts = opt->nb_pkts;
195d1f59fb7SJerin Jacob 	t->nb_flows = opt->nb_flows;
196d1f59fb7SJerin Jacob 	t->result = EVT_TEST_FAILED;
197d1f59fb7SJerin Jacob 	t->opt = opt;
198d1f59fb7SJerin Jacob 	return 0;
199d1f59fb7SJerin Jacob 
200d1f59fb7SJerin Jacob exp_nomem:
201d1f59fb7SJerin Jacob 	rte_free(t->producer_flow_seq);
202d1f59fb7SJerin Jacob prod_nomem:
203d1f59fb7SJerin Jacob 	rte_free(test->test_priv);
204d1f59fb7SJerin Jacob nomem:
205d1f59fb7SJerin Jacob 	return -ENOMEM;
206d1f59fb7SJerin Jacob }
207d1f59fb7SJerin Jacob 
208d1f59fb7SJerin Jacob void
order_test_destroy(struct evt_test * test,struct evt_options * opt)209d1f59fb7SJerin Jacob order_test_destroy(struct evt_test *test, struct evt_options *opt)
210d1f59fb7SJerin Jacob {
211d1f59fb7SJerin Jacob 	RTE_SET_USED(opt);
212d1f59fb7SJerin Jacob 	struct test_order *t = evt_test_priv(test);
213d1f59fb7SJerin Jacob 
214d1f59fb7SJerin Jacob 	rte_free(t->expected_flow_seq);
215d1f59fb7SJerin Jacob 	rte_free(t->producer_flow_seq);
216d1f59fb7SJerin Jacob 	rte_free(test->test_priv);
217d1f59fb7SJerin Jacob }
218ba11ebf1SJerin Jacob 
219ba11ebf1SJerin Jacob int
order_mempool_setup(struct evt_test * test,struct evt_options * opt)220ba11ebf1SJerin Jacob order_mempool_setup(struct evt_test *test, struct evt_options *opt)
221ba11ebf1SJerin Jacob {
222ba11ebf1SJerin Jacob 	struct test_order *t = evt_test_priv(test);
223ba11ebf1SJerin Jacob 
224ba11ebf1SJerin Jacob 	t->pool  = rte_pktmbuf_pool_create(test->name, opt->pool_sz,
225ba11ebf1SJerin Jacob 					256 /* Cache */, 0,
226ba11ebf1SJerin Jacob 					512, /* Use very small mbufs */
227ba11ebf1SJerin Jacob 					opt->socket_id);
228ba11ebf1SJerin Jacob 	if (t->pool == NULL) {
229ba11ebf1SJerin Jacob 		evt_err("failed to create mempool");
230ba11ebf1SJerin Jacob 		return -ENOMEM;
231ba11ebf1SJerin Jacob 	}
232ba11ebf1SJerin Jacob 
233ba11ebf1SJerin Jacob 	return 0;
234ba11ebf1SJerin Jacob }
235ba11ebf1SJerin Jacob 
236ba11ebf1SJerin Jacob void
order_mempool_destroy(struct evt_test * test,struct evt_options * opt)237ba11ebf1SJerin Jacob order_mempool_destroy(struct evt_test *test, struct evt_options *opt)
238ba11ebf1SJerin Jacob {
239ba11ebf1SJerin Jacob 	RTE_SET_USED(opt);
240ba11ebf1SJerin Jacob 	struct test_order *t = evt_test_priv(test);
241ba11ebf1SJerin Jacob 
242ba11ebf1SJerin Jacob 	rte_mempool_free(t->pool);
243ba11ebf1SJerin Jacob }
244ba11ebf1SJerin Jacob 
245ba11ebf1SJerin Jacob void
order_eventdev_destroy(struct evt_test * test,struct evt_options * opt)246ba11ebf1SJerin Jacob order_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
247ba11ebf1SJerin Jacob {
248ba11ebf1SJerin Jacob 	RTE_SET_USED(test);
249ba11ebf1SJerin Jacob 
250ba11ebf1SJerin Jacob 	rte_event_dev_stop(opt->dev_id);
251ba11ebf1SJerin Jacob 	rte_event_dev_close(opt->dev_id);
252ba11ebf1SJerin Jacob }
253ba11ebf1SJerin Jacob 
254ba11ebf1SJerin Jacob void
order_opt_dump(struct evt_options * opt)255ba11ebf1SJerin Jacob order_opt_dump(struct evt_options *opt)
256ba11ebf1SJerin Jacob {
257ba11ebf1SJerin Jacob 	evt_dump_producer_lcores(opt);
2587be78d02SJosh Soref 	evt_dump("nb_worker_lcores", "%d", evt_nr_active_lcores(opt->wlcores));
259ba11ebf1SJerin Jacob 	evt_dump_worker_lcores(opt);
260ba11ebf1SJerin Jacob 	evt_dump("nb_evdev_ports", "%d", order_nb_event_ports(opt));
261ba11ebf1SJerin Jacob }
262ba11ebf1SJerin Jacob 
2635710e751SJerin Jacob int
order_launch_lcores(struct evt_test * test,struct evt_options * opt,int (* worker)(void *))26433b7483dSJerin Jacob order_launch_lcores(struct evt_test *test, struct evt_options *opt,
26533b7483dSJerin Jacob 			int (*worker)(void *))
26633b7483dSJerin Jacob {
26733b7483dSJerin Jacob 	int ret, lcore_id;
26833b7483dSJerin Jacob 	struct test_order *t = evt_test_priv(test);
26933b7483dSJerin Jacob 
27033b7483dSJerin Jacob 	int wkr_idx = 0;
27133b7483dSJerin Jacob 	/* launch workers */
272cb056611SStephen Hemminger 	RTE_LCORE_FOREACH_WORKER(lcore_id) {
27333b7483dSJerin Jacob 		if (!(opt->wlcores[lcore_id]))
27433b7483dSJerin Jacob 			continue;
27533b7483dSJerin Jacob 
27633b7483dSJerin Jacob 		ret = rte_eal_remote_launch(worker, &t->worker[wkr_idx],
27733b7483dSJerin Jacob 					 lcore_id);
27833b7483dSJerin Jacob 		if (ret) {
27933b7483dSJerin Jacob 			evt_err("failed to launch worker %d", lcore_id);
28033b7483dSJerin Jacob 			return ret;
28133b7483dSJerin Jacob 		}
28233b7483dSJerin Jacob 		wkr_idx++;
28333b7483dSJerin Jacob 	}
28433b7483dSJerin Jacob 
28533b7483dSJerin Jacob 	/* launch producer */
28633b7483dSJerin Jacob 	int plcore = evt_get_first_active_lcore(opt->plcores);
28733b7483dSJerin Jacob 
28833b7483dSJerin Jacob 	ret = rte_eal_remote_launch(order_producer, &t->prod, plcore);
28933b7483dSJerin Jacob 	if (ret) {
29033b7483dSJerin Jacob 		evt_err("failed to launch order_producer %d", plcore);
29133b7483dSJerin Jacob 		return ret;
29233b7483dSJerin Jacob 	}
29333b7483dSJerin Jacob 
29433b7483dSJerin Jacob 	uint64_t cycles = rte_get_timer_cycles();
29533b7483dSJerin Jacob 	int64_t old_remaining  = -1;
29633b7483dSJerin Jacob 
29733b7483dSJerin Jacob 	while (t->err == false) {
29833b7483dSJerin Jacob 		uint64_t new_cycles = rte_get_timer_cycles();
299*b6a7e685STyler Retzlaff 		int64_t remaining = rte_atomic_load_explicit(&t->outstand_pkts,
300*b6a7e685STyler Retzlaff 				rte_memory_order_relaxed);
30133b7483dSJerin Jacob 
30233b7483dSJerin Jacob 		if (remaining <= 0) {
30333b7483dSJerin Jacob 			t->result = EVT_TEST_SUCCESS;
30433b7483dSJerin Jacob 			break;
30533b7483dSJerin Jacob 		}
30633b7483dSJerin Jacob 
30733b7483dSJerin Jacob 		if (new_cycles - cycles > rte_get_timer_hz() * 1) {
30833b7483dSJerin Jacob 			printf(CLGRN"\r%"PRId64""CLNRM, remaining);
30933b7483dSJerin Jacob 			fflush(stdout);
31033b7483dSJerin Jacob 			if (old_remaining == remaining) {
31133b7483dSJerin Jacob 				rte_event_dev_dump(opt->dev_id, stdout);
31233b7483dSJerin Jacob 				evt_err("No schedules for seconds, deadlock");
31333b7483dSJerin Jacob 				t->err = true;
31433b7483dSJerin Jacob 				break;
31533b7483dSJerin Jacob 			}
31633b7483dSJerin Jacob 			old_remaining = remaining;
31733b7483dSJerin Jacob 			cycles = new_cycles;
31833b7483dSJerin Jacob 		}
31933b7483dSJerin Jacob 	}
32033b7483dSJerin Jacob 	printf("\r");
32133b7483dSJerin Jacob 
32233b7483dSJerin Jacob 	return 0;
32333b7483dSJerin Jacob }
32433b7483dSJerin Jacob 
32533b7483dSJerin Jacob int
order_event_dev_port_setup(struct evt_test * test,struct evt_options * opt,uint8_t nb_workers,uint8_t nb_queues)3265710e751SJerin Jacob order_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
3275710e751SJerin Jacob 				uint8_t nb_workers, uint8_t nb_queues)
3285710e751SJerin Jacob {
3295710e751SJerin Jacob 	int ret;
3305710e751SJerin Jacob 	uint8_t port;
3315710e751SJerin Jacob 	struct test_order *t = evt_test_priv(test);
332f77f8c9fSPavan Nikhilesh 	struct rte_event_dev_info dev_info;
333f77f8c9fSPavan Nikhilesh 
334f77f8c9fSPavan Nikhilesh 	ret = rte_event_dev_info_get(opt->dev_id, &dev_info);
335f77f8c9fSPavan Nikhilesh 	if (ret) {
336f77f8c9fSPavan Nikhilesh 		evt_err("failed to get eventdev info %d", opt->dev_id);
337f77f8c9fSPavan Nikhilesh 		return ret;
338f77f8c9fSPavan Nikhilesh 	}
339f77f8c9fSPavan Nikhilesh 
340f77f8c9fSPavan Nikhilesh 	if (opt->wkr_deq_dep > dev_info.max_event_port_dequeue_depth)
341f77f8c9fSPavan Nikhilesh 		opt->wkr_deq_dep = dev_info.max_event_port_dequeue_depth;
342ba11ebf1SJerin Jacob 
3435710e751SJerin Jacob 	/* port configuration */
344f77f8c9fSPavan Nikhilesh 	const struct rte_event_port_conf p_conf = {
3455710e751SJerin Jacob 			.dequeue_depth = opt->wkr_deq_dep,
346f77f8c9fSPavan Nikhilesh 			.enqueue_depth = dev_info.max_event_port_dequeue_depth,
347f77f8c9fSPavan Nikhilesh 			.new_event_threshold = dev_info.max_num_events,
3485710e751SJerin Jacob 	};
3495710e751SJerin Jacob 
3505710e751SJerin Jacob 	/* setup one port per worker, linking to all queues */
3515710e751SJerin Jacob 	for (port = 0; port < nb_workers; port++) {
3525710e751SJerin Jacob 		struct worker_data *w = &t->worker[port];
3535710e751SJerin Jacob 
3545710e751SJerin Jacob 		w->dev_id = opt->dev_id;
3555710e751SJerin Jacob 		w->port_id = port;
3565710e751SJerin Jacob 		w->t = t;
3575710e751SJerin Jacob 
358f77f8c9fSPavan Nikhilesh 		ret = rte_event_port_setup(opt->dev_id, port, &p_conf);
3595710e751SJerin Jacob 		if (ret) {
3605710e751SJerin Jacob 			evt_err("failed to setup port %d", port);
3615710e751SJerin Jacob 			return ret;
3625710e751SJerin Jacob 		}
3635710e751SJerin Jacob 
3645710e751SJerin Jacob 		ret = rte_event_port_link(opt->dev_id, port, NULL, NULL, 0);
3655710e751SJerin Jacob 		if (ret != nb_queues) {
3665710e751SJerin Jacob 			evt_err("failed to link all queues to port %d", port);
3675710e751SJerin Jacob 			return -EINVAL;
3685710e751SJerin Jacob 		}
3695710e751SJerin Jacob 	}
3705710e751SJerin Jacob 	struct prod_data *p = &t->prod;
3715710e751SJerin Jacob 
3725710e751SJerin Jacob 	p->dev_id = opt->dev_id;
3735710e751SJerin Jacob 	p->port_id = port; /* last port */
3745710e751SJerin Jacob 	p->queue_id = 0;
3755710e751SJerin Jacob 	p->t = t;
3765710e751SJerin Jacob 
377f77f8c9fSPavan Nikhilesh 	ret = rte_event_port_setup(opt->dev_id, port, &p_conf);
3785710e751SJerin Jacob 	if (ret) {
3795710e751SJerin Jacob 		evt_err("failed to setup producer port %d", port);
3805710e751SJerin Jacob 		return ret;
3815710e751SJerin Jacob 	}
3825710e751SJerin Jacob 
3835710e751SJerin Jacob 	return ret;
3845710e751SJerin Jacob }
385