xref: /dpdk/app/test-eventdev/test_perf_common.c (revision c1749bc5ee10ee1f13fcf084efffec585dc31d14)
153a3b7e8SJerin Jacob /* SPDX-License-Identifier: BSD-3-Clause
253a3b7e8SJerin Jacob  * Copyright(c) 2017 Cavium, Inc
3ffbae86fSJerin Jacob  */
4ffbae86fSJerin Jacob 
5626b12a8SPavan Nikhilesh #include <math.h>
6626b12a8SPavan Nikhilesh 
7ffbae86fSJerin Jacob #include "test_perf_common.h"
8ffbae86fSJerin Jacob 
9f3a67078SVolodymyr Fialko #define NB_CRYPTODEV_DESCRIPTORS 1024
108f5b5495SAkhil Goyal #define DATA_SIZE		512
118f5b5495SAkhil Goyal struct modex_test_data {
128f5b5495SAkhil Goyal 	enum rte_crypto_asym_xform_type xform_type;
138f5b5495SAkhil Goyal 	struct {
148f5b5495SAkhil Goyal 		uint8_t data[DATA_SIZE];
158f5b5495SAkhil Goyal 		uint16_t len;
168f5b5495SAkhil Goyal 	} base;
178f5b5495SAkhil Goyal 	struct {
188f5b5495SAkhil Goyal 		uint8_t data[DATA_SIZE];
198f5b5495SAkhil Goyal 		uint16_t len;
208f5b5495SAkhil Goyal 	} exponent;
218f5b5495SAkhil Goyal 	struct {
228f5b5495SAkhil Goyal 		uint8_t data[DATA_SIZE];
238f5b5495SAkhil Goyal 		uint16_t len;
248f5b5495SAkhil Goyal 	} modulus;
258f5b5495SAkhil Goyal 	struct {
268f5b5495SAkhil Goyal 		uint8_t data[DATA_SIZE];
278f5b5495SAkhil Goyal 		uint16_t len;
288f5b5495SAkhil Goyal 	} reminder;
298f5b5495SAkhil Goyal 	uint16_t result_len;
308f5b5495SAkhil Goyal };
318f5b5495SAkhil Goyal 
328f5b5495SAkhil Goyal static struct
338f5b5495SAkhil Goyal modex_test_data modex_test_case = {
348f5b5495SAkhil Goyal 	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
358f5b5495SAkhil Goyal 	.base = {
368f5b5495SAkhil Goyal 		.data = {
378f5b5495SAkhil Goyal 			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
388f5b5495SAkhil Goyal 			0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
398f5b5495SAkhil Goyal 			0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
408f5b5495SAkhil Goyal 		},
418f5b5495SAkhil Goyal 		.len = 20,
428f5b5495SAkhil Goyal 	},
438f5b5495SAkhil Goyal 	.exponent = {
448f5b5495SAkhil Goyal 		.data = {
458f5b5495SAkhil Goyal 			0x01, 0x00, 0x01
468f5b5495SAkhil Goyal 		},
478f5b5495SAkhil Goyal 		.len = 3,
488f5b5495SAkhil Goyal 	},
498f5b5495SAkhil Goyal 	.reminder = {
508f5b5495SAkhil Goyal 		.data = {
518f5b5495SAkhil Goyal 			0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
528f5b5495SAkhil Goyal 			0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
538f5b5495SAkhil Goyal 			0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
548f5b5495SAkhil Goyal 			0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
558f5b5495SAkhil Goyal 			0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
568f5b5495SAkhil Goyal 			0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
578f5b5495SAkhil Goyal 			0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
588f5b5495SAkhil Goyal 			0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
598f5b5495SAkhil Goyal 			0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
608f5b5495SAkhil Goyal 			0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
618f5b5495SAkhil Goyal 			0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
628f5b5495SAkhil Goyal 			0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
638f5b5495SAkhil Goyal 			0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
648f5b5495SAkhil Goyal 			0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
658f5b5495SAkhil Goyal 			0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
668f5b5495SAkhil Goyal 			0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
678f5b5495SAkhil Goyal 		},
688f5b5495SAkhil Goyal 		.len = 128,
698f5b5495SAkhil Goyal 	},
708f5b5495SAkhil Goyal 	.modulus = {
718f5b5495SAkhil Goyal 		.data = {
728f5b5495SAkhil Goyal 			0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
738f5b5495SAkhil Goyal 			0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
748f5b5495SAkhil Goyal 			0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
758f5b5495SAkhil Goyal 			0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
768f5b5495SAkhil Goyal 			0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
778f5b5495SAkhil Goyal 			0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
788f5b5495SAkhil Goyal 			0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
798f5b5495SAkhil Goyal 			0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
808f5b5495SAkhil Goyal 			0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
818f5b5495SAkhil Goyal 			0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
828f5b5495SAkhil Goyal 			0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
838f5b5495SAkhil Goyal 			0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
848f5b5495SAkhil Goyal 			0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
858f5b5495SAkhil Goyal 			0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
868f5b5495SAkhil Goyal 			0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
878f5b5495SAkhil Goyal 			0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
888f5b5495SAkhil Goyal 		},
898f5b5495SAkhil Goyal 		.len = 128,
908f5b5495SAkhil Goyal 	},
918f5b5495SAkhil Goyal 	.result_len = 128,
928f5b5495SAkhil Goyal };
93de2bc16eSShijith Thotton 
9441c219e6SJerin Jacob int
9541c219e6SJerin Jacob perf_test_result(struct evt_test *test, struct evt_options *opt)
9641c219e6SJerin Jacob {
9741c219e6SJerin Jacob 	RTE_SET_USED(opt);
986b1a14a8SPavan Nikhilesh 	int i;
996b1a14a8SPavan Nikhilesh 	uint64_t total = 0;
10041c219e6SJerin Jacob 	struct test_perf *t = evt_test_priv(test);
10141c219e6SJerin Jacob 
1026b1a14a8SPavan Nikhilesh 	printf("Packet distribution across worker cores :\n");
1036b1a14a8SPavan Nikhilesh 	for (i = 0; i < t->nb_workers; i++)
1046b1a14a8SPavan Nikhilesh 		total += t->worker[i].processed_pkts;
1056b1a14a8SPavan Nikhilesh 	for (i = 0; i < t->nb_workers; i++)
1066b1a14a8SPavan Nikhilesh 		printf("Worker %d packets: "CLGRN"%"PRIx64" "CLNRM"percentage:"
107c0900d33SHarry van Haaren 				CLGRN" %3.2f"CLNRM"\n", i,
1086b1a14a8SPavan Nikhilesh 				t->worker[i].processed_pkts,
1096b1a14a8SPavan Nikhilesh 				(((double)t->worker[i].processed_pkts)/total)
1106b1a14a8SPavan Nikhilesh 				* 100);
1116b1a14a8SPavan Nikhilesh 
11241c219e6SJerin Jacob 	return t->result;
11341c219e6SJerin Jacob }
11441c219e6SJerin Jacob 
1159d3aeb18SJerin Jacob static inline int
1169d3aeb18SJerin Jacob perf_producer(void *arg)
1179d3aeb18SJerin Jacob {
1189a618803SPavan Nikhilesh 	int i;
1199d3aeb18SJerin Jacob 	struct prod_data *p  = arg;
1209d3aeb18SJerin Jacob 	struct test_perf *t = p->t;
1219d3aeb18SJerin Jacob 	struct evt_options *opt = t->opt;
1229d3aeb18SJerin Jacob 	const uint8_t dev_id = p->dev_id;
1239d3aeb18SJerin Jacob 	const uint8_t port = p->port_id;
1249d3aeb18SJerin Jacob 	struct rte_mempool *pool = t->pool;
1259d3aeb18SJerin Jacob 	const uint64_t nb_pkts = t->nb_pkts;
1269d3aeb18SJerin Jacob 	const uint32_t nb_flows = t->nb_flows;
1279d3aeb18SJerin Jacob 	uint32_t flow_counter = 0;
1289d3aeb18SJerin Jacob 	uint64_t count = 0;
1299a618803SPavan Nikhilesh 	struct perf_elt *m[BURST_SIZE + 1] = {NULL};
1309d3aeb18SJerin Jacob 	struct rte_event ev;
1319d3aeb18SJerin Jacob 
1329d3aeb18SJerin Jacob 	if (opt->verbose_level > 1)
1339d3aeb18SJerin Jacob 		printf("%s(): lcore %d dev_id %d port=%d queue %d\n", __func__,
1349d3aeb18SJerin Jacob 				rte_lcore_id(), dev_id, port, p->queue_id);
1359d3aeb18SJerin Jacob 
1369d3aeb18SJerin Jacob 	ev.event = 0;
1379d3aeb18SJerin Jacob 	ev.op = RTE_EVENT_OP_NEW;
1389d3aeb18SJerin Jacob 	ev.queue_id = p->queue_id;
1399d3aeb18SJerin Jacob 	ev.sched_type = t->opt->sched_type_list[0];
1409d3aeb18SJerin Jacob 	ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
1419d3aeb18SJerin Jacob 	ev.event_type =  RTE_EVENT_TYPE_CPU;
1429d3aeb18SJerin Jacob 	ev.sub_event_type = 0; /* stage 0 */
1439d3aeb18SJerin Jacob 
1449d3aeb18SJerin Jacob 	while (count < nb_pkts && t->done == false) {
1459a618803SPavan Nikhilesh 		if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0)
1469d3aeb18SJerin Jacob 			continue;
1479a618803SPavan Nikhilesh 		for (i = 0; i < BURST_SIZE; i++) {
1489d3aeb18SJerin Jacob 			ev.flow_id = flow_counter++ % nb_flows;
1499a618803SPavan Nikhilesh 			ev.event_ptr = m[i];
1509a618803SPavan Nikhilesh 			m[i]->timestamp = rte_get_timer_cycles();
1519a618803SPavan Nikhilesh 			while (rte_event_enqueue_burst(dev_id,
1529a618803SPavan Nikhilesh 						       port, &ev, 1) != 1) {
1539d3aeb18SJerin Jacob 				if (t->done)
1549d3aeb18SJerin Jacob 					break;
1559d3aeb18SJerin Jacob 				rte_pause();
1569a618803SPavan Nikhilesh 				m[i]->timestamp = rte_get_timer_cycles();
1579d3aeb18SJerin Jacob 			}
1589a618803SPavan Nikhilesh 		}
1599a618803SPavan Nikhilesh 		count += BURST_SIZE;
1609d3aeb18SJerin Jacob 	}
1619d3aeb18SJerin Jacob 
1629d3aeb18SJerin Jacob 	return 0;
1639d3aeb18SJerin Jacob }
1649d3aeb18SJerin Jacob 
165d008f20bSPavan Nikhilesh static inline int
16620841a25SRashmi Shetty perf_producer_burst(void *arg)
16720841a25SRashmi Shetty {
16820841a25SRashmi Shetty 	uint32_t i;
16920841a25SRashmi Shetty 	uint64_t timestamp;
17020841a25SRashmi Shetty 	struct rte_event_dev_info dev_info;
17120841a25SRashmi Shetty 	struct prod_data *p  = arg;
17220841a25SRashmi Shetty 	struct test_perf *t = p->t;
17320841a25SRashmi Shetty 	struct evt_options *opt = t->opt;
17420841a25SRashmi Shetty 	const uint8_t dev_id = p->dev_id;
17520841a25SRashmi Shetty 	const uint8_t port = p->port_id;
17620841a25SRashmi Shetty 	struct rte_mempool *pool = t->pool;
17720841a25SRashmi Shetty 	const uint64_t nb_pkts = t->nb_pkts;
17820841a25SRashmi Shetty 	const uint32_t nb_flows = t->nb_flows;
17920841a25SRashmi Shetty 	uint32_t flow_counter = 0;
18020841a25SRashmi Shetty 	uint16_t enq = 0;
18120841a25SRashmi Shetty 	uint64_t count = 0;
18220841a25SRashmi Shetty 	struct perf_elt *m[MAX_PROD_ENQ_BURST_SIZE + 1];
18320841a25SRashmi Shetty 	struct rte_event ev[MAX_PROD_ENQ_BURST_SIZE + 1];
18420841a25SRashmi Shetty 	uint32_t burst_size = opt->prod_enq_burst_sz;
18520841a25SRashmi Shetty 
18620841a25SRashmi Shetty 	memset(m, 0, sizeof(*m) * (MAX_PROD_ENQ_BURST_SIZE + 1));
18720841a25SRashmi Shetty 	rte_event_dev_info_get(dev_id, &dev_info);
18820841a25SRashmi Shetty 	if (dev_info.max_event_port_enqueue_depth < burst_size)
18920841a25SRashmi Shetty 		burst_size = dev_info.max_event_port_enqueue_depth;
19020841a25SRashmi Shetty 
19120841a25SRashmi Shetty 	if (opt->verbose_level > 1)
19220841a25SRashmi Shetty 		printf("%s(): lcore %d dev_id %d port=%d queue %d\n", __func__,
19320841a25SRashmi Shetty 				rte_lcore_id(), dev_id, port, p->queue_id);
19420841a25SRashmi Shetty 
19520841a25SRashmi Shetty 	for (i = 0; i < burst_size; i++) {
19620841a25SRashmi Shetty 		ev[i].op = RTE_EVENT_OP_NEW;
19720841a25SRashmi Shetty 		ev[i].queue_id = p->queue_id;
19820841a25SRashmi Shetty 		ev[i].sched_type = t->opt->sched_type_list[0];
19920841a25SRashmi Shetty 		ev[i].priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
20020841a25SRashmi Shetty 		ev[i].event_type =  RTE_EVENT_TYPE_CPU;
20120841a25SRashmi Shetty 		ev[i].sub_event_type = 0; /* stage 0 */
20220841a25SRashmi Shetty 	}
20320841a25SRashmi Shetty 
20420841a25SRashmi Shetty 	while (count < nb_pkts && t->done == false) {
20520841a25SRashmi Shetty 		if (rte_mempool_get_bulk(pool, (void **)m, burst_size) < 0)
20620841a25SRashmi Shetty 			continue;
20720841a25SRashmi Shetty 		timestamp = rte_get_timer_cycles();
20820841a25SRashmi Shetty 		for (i = 0; i < burst_size; i++) {
20920841a25SRashmi Shetty 			ev[i].flow_id = flow_counter++ % nb_flows;
21020841a25SRashmi Shetty 			ev[i].event_ptr = m[i];
21120841a25SRashmi Shetty 			m[i]->timestamp = timestamp;
21220841a25SRashmi Shetty 		}
21320841a25SRashmi Shetty 		enq = rte_event_enqueue_burst(dev_id, port, ev, burst_size);
21420841a25SRashmi Shetty 		while (enq < burst_size) {
21520841a25SRashmi Shetty 			enq += rte_event_enqueue_burst(dev_id, port,
21620841a25SRashmi Shetty 							ev + enq,
21720841a25SRashmi Shetty 							burst_size - enq);
21820841a25SRashmi Shetty 			if (t->done)
21920841a25SRashmi Shetty 				break;
22020841a25SRashmi Shetty 			rte_pause();
22120841a25SRashmi Shetty 			timestamp = rte_get_timer_cycles();
22220841a25SRashmi Shetty 			for (i = enq; i < burst_size; i++)
22320841a25SRashmi Shetty 				m[i]->timestamp = timestamp;
22420841a25SRashmi Shetty 		}
22520841a25SRashmi Shetty 		count += burst_size;
22620841a25SRashmi Shetty 	}
22720841a25SRashmi Shetty 	return 0;
22820841a25SRashmi Shetty }
22920841a25SRashmi Shetty 
23020841a25SRashmi Shetty static inline int
231d008f20bSPavan Nikhilesh perf_event_timer_producer(void *arg)
232d008f20bSPavan Nikhilesh {
2339a618803SPavan Nikhilesh 	int i;
234d008f20bSPavan Nikhilesh 	struct prod_data *p  = arg;
235d008f20bSPavan Nikhilesh 	struct test_perf *t = p->t;
236d008f20bSPavan Nikhilesh 	struct evt_options *opt = t->opt;
237d008f20bSPavan Nikhilesh 	uint32_t flow_counter = 0;
238d008f20bSPavan Nikhilesh 	uint64_t count = 0;
239d008f20bSPavan Nikhilesh 	uint64_t arm_latency = 0;
240d008f20bSPavan Nikhilesh 	const uint8_t nb_timer_adptrs = opt->nb_timer_adptrs;
241d008f20bSPavan Nikhilesh 	const uint32_t nb_flows = t->nb_flows;
242d008f20bSPavan Nikhilesh 	const uint64_t nb_timers = opt->nb_timers;
243d008f20bSPavan Nikhilesh 	struct rte_mempool *pool = t->pool;
2449a618803SPavan Nikhilesh 	struct perf_elt *m[BURST_SIZE + 1] = {NULL};
245d008f20bSPavan Nikhilesh 	struct rte_event_timer_adapter **adptr = t->timer_adptr;
24652553263SPavan Nikhilesh 	struct rte_event_timer tim;
247d008f20bSPavan Nikhilesh 	uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec;
248d008f20bSPavan Nikhilesh 
24952553263SPavan Nikhilesh 	memset(&tim, 0, sizeof(struct rte_event_timer));
250626b12a8SPavan Nikhilesh 	timeout_ticks =
251626b12a8SPavan Nikhilesh 		opt->optm_timer_tick_nsec
252626b12a8SPavan Nikhilesh 			? ceil((double)(timeout_ticks * opt->timer_tick_nsec) /
253626b12a8SPavan Nikhilesh 			       opt->optm_timer_tick_nsec)
254626b12a8SPavan Nikhilesh 			: timeout_ticks;
255d008f20bSPavan Nikhilesh 	timeout_ticks += timeout_ticks ? 0 : 1;
25652553263SPavan Nikhilesh 	tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
25752553263SPavan Nikhilesh 	tim.ev.op = RTE_EVENT_OP_NEW;
25852553263SPavan Nikhilesh 	tim.ev.sched_type = t->opt->sched_type_list[0];
25952553263SPavan Nikhilesh 	tim.ev.queue_id = p->queue_id;
26052553263SPavan Nikhilesh 	tim.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
26152553263SPavan Nikhilesh 	tim.state = RTE_EVENT_TIMER_NOT_ARMED;
26252553263SPavan Nikhilesh 	tim.timeout_ticks = timeout_ticks;
263d008f20bSPavan Nikhilesh 
264d008f20bSPavan Nikhilesh 	if (opt->verbose_level > 1)
265d008f20bSPavan Nikhilesh 		printf("%s(): lcore %d\n", __func__, rte_lcore_id());
266d008f20bSPavan Nikhilesh 
267d008f20bSPavan Nikhilesh 	while (count < nb_timers && t->done == false) {
2689a618803SPavan Nikhilesh 		if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0)
269d008f20bSPavan Nikhilesh 			continue;
2709a618803SPavan Nikhilesh 		for (i = 0; i < BURST_SIZE; i++) {
2719a618803SPavan Nikhilesh 			rte_prefetch0(m[i + 1]);
2729a618803SPavan Nikhilesh 			m[i]->tim = tim;
2739a618803SPavan Nikhilesh 			m[i]->tim.ev.flow_id = flow_counter++ % nb_flows;
2749a618803SPavan Nikhilesh 			m[i]->tim.ev.event_ptr = m[i];
2759a618803SPavan Nikhilesh 			m[i]->timestamp = rte_get_timer_cycles();
276d008f20bSPavan Nikhilesh 			while (rte_event_timer_arm_burst(
277d008f20bSPavan Nikhilesh 			       adptr[flow_counter % nb_timer_adptrs],
2789a618803SPavan Nikhilesh 			       (struct rte_event_timer **)&m[i], 1) != 1) {
279d008f20bSPavan Nikhilesh 				if (t->done)
280d008f20bSPavan Nikhilesh 					break;
2819a618803SPavan Nikhilesh 				m[i]->timestamp = rte_get_timer_cycles();
282d008f20bSPavan Nikhilesh 			}
2839a618803SPavan Nikhilesh 			arm_latency += rte_get_timer_cycles() - m[i]->timestamp;
2849a618803SPavan Nikhilesh 		}
2859a618803SPavan Nikhilesh 		count += BURST_SIZE;
286d008f20bSPavan Nikhilesh 	}
287d008f20bSPavan Nikhilesh 	fflush(stdout);
288d008f20bSPavan Nikhilesh 	rte_delay_ms(1000);
289d008f20bSPavan Nikhilesh 	printf("%s(): lcore %d Average event timer arm latency = %.3f us\n",
29093b7794bSPavan Nikhilesh 			__func__, rte_lcore_id(),
29193b7794bSPavan Nikhilesh 			count ? (float)(arm_latency / count) /
29293b7794bSPavan Nikhilesh 			(rte_get_timer_hz() / 1000000) : 0);
293d008f20bSPavan Nikhilesh 	return 0;
294d008f20bSPavan Nikhilesh }
295d008f20bSPavan Nikhilesh 
29617b22d0bSPavan Nikhilesh static inline int
29717b22d0bSPavan Nikhilesh perf_event_timer_producer_burst(void *arg)
29817b22d0bSPavan Nikhilesh {
29917b22d0bSPavan Nikhilesh 	int i;
30017b22d0bSPavan Nikhilesh 	struct prod_data *p  = arg;
30117b22d0bSPavan Nikhilesh 	struct test_perf *t = p->t;
30217b22d0bSPavan Nikhilesh 	struct evt_options *opt = t->opt;
30317b22d0bSPavan Nikhilesh 	uint32_t flow_counter = 0;
30417b22d0bSPavan Nikhilesh 	uint64_t count = 0;
30517b22d0bSPavan Nikhilesh 	uint64_t arm_latency = 0;
30617b22d0bSPavan Nikhilesh 	const uint8_t nb_timer_adptrs = opt->nb_timer_adptrs;
30717b22d0bSPavan Nikhilesh 	const uint32_t nb_flows = t->nb_flows;
30817b22d0bSPavan Nikhilesh 	const uint64_t nb_timers = opt->nb_timers;
30917b22d0bSPavan Nikhilesh 	struct rte_mempool *pool = t->pool;
31017b22d0bSPavan Nikhilesh 	struct perf_elt *m[BURST_SIZE + 1] = {NULL};
31117b22d0bSPavan Nikhilesh 	struct rte_event_timer_adapter **adptr = t->timer_adptr;
31252553263SPavan Nikhilesh 	struct rte_event_timer tim;
31317b22d0bSPavan Nikhilesh 	uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec;
31417b22d0bSPavan Nikhilesh 
31552553263SPavan Nikhilesh 	memset(&tim, 0, sizeof(struct rte_event_timer));
316626b12a8SPavan Nikhilesh 	timeout_ticks =
317626b12a8SPavan Nikhilesh 		opt->optm_timer_tick_nsec
318626b12a8SPavan Nikhilesh 			? ceil((double)(timeout_ticks * opt->timer_tick_nsec) /
319626b12a8SPavan Nikhilesh 			       opt->optm_timer_tick_nsec)
320626b12a8SPavan Nikhilesh 			: timeout_ticks;
32117b22d0bSPavan Nikhilesh 	timeout_ticks += timeout_ticks ? 0 : 1;
32252553263SPavan Nikhilesh 	tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
32352553263SPavan Nikhilesh 	tim.ev.op = RTE_EVENT_OP_NEW;
32452553263SPavan Nikhilesh 	tim.ev.sched_type = t->opt->sched_type_list[0];
32552553263SPavan Nikhilesh 	tim.ev.queue_id = p->queue_id;
32652553263SPavan Nikhilesh 	tim.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
32752553263SPavan Nikhilesh 	tim.state = RTE_EVENT_TIMER_NOT_ARMED;
32852553263SPavan Nikhilesh 	tim.timeout_ticks = timeout_ticks;
32917b22d0bSPavan Nikhilesh 
33017b22d0bSPavan Nikhilesh 	if (opt->verbose_level > 1)
33117b22d0bSPavan Nikhilesh 		printf("%s(): lcore %d\n", __func__, rte_lcore_id());
33217b22d0bSPavan Nikhilesh 
33317b22d0bSPavan Nikhilesh 	while (count < nb_timers && t->done == false) {
33417b22d0bSPavan Nikhilesh 		if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0)
33517b22d0bSPavan Nikhilesh 			continue;
33617b22d0bSPavan Nikhilesh 		for (i = 0; i < BURST_SIZE; i++) {
33717b22d0bSPavan Nikhilesh 			rte_prefetch0(m[i + 1]);
33817b22d0bSPavan Nikhilesh 			m[i]->tim = tim;
33917b22d0bSPavan Nikhilesh 			m[i]->tim.ev.flow_id = flow_counter++ % nb_flows;
34017b22d0bSPavan Nikhilesh 			m[i]->tim.ev.event_ptr = m[i];
34117b22d0bSPavan Nikhilesh 			m[i]->timestamp = rte_get_timer_cycles();
34217b22d0bSPavan Nikhilesh 		}
34317b22d0bSPavan Nikhilesh 		rte_event_timer_arm_tmo_tick_burst(
34417b22d0bSPavan Nikhilesh 				adptr[flow_counter % nb_timer_adptrs],
34517b22d0bSPavan Nikhilesh 				(struct rte_event_timer **)m,
34617b22d0bSPavan Nikhilesh 				tim.timeout_ticks,
34717b22d0bSPavan Nikhilesh 				BURST_SIZE);
34817b22d0bSPavan Nikhilesh 		arm_latency += rte_get_timer_cycles() - m[i - 1]->timestamp;
34917b22d0bSPavan Nikhilesh 		count += BURST_SIZE;
35017b22d0bSPavan Nikhilesh 	}
35117b22d0bSPavan Nikhilesh 	fflush(stdout);
35217b22d0bSPavan Nikhilesh 	rte_delay_ms(1000);
35317b22d0bSPavan Nikhilesh 	printf("%s(): lcore %d Average event timer arm latency = %.3f us\n",
35493b7794bSPavan Nikhilesh 			__func__, rte_lcore_id(),
35593b7794bSPavan Nikhilesh 			count ? (float)(arm_latency / count) /
35693b7794bSPavan Nikhilesh 			(rte_get_timer_hz() / 1000000) : 0);
35717b22d0bSPavan Nikhilesh 	return 0;
35817b22d0bSPavan Nikhilesh }
35917b22d0bSPavan Nikhilesh 
360de2bc16eSShijith Thotton static inline void
361de2bc16eSShijith Thotton crypto_adapter_enq_op_new(struct prod_data *p)
362de2bc16eSShijith Thotton {
363de2bc16eSShijith Thotton 	struct test_perf *t = p->t;
364de2bc16eSShijith Thotton 	const uint32_t nb_flows = t->nb_flows;
365de2bc16eSShijith Thotton 	const uint64_t nb_pkts = t->nb_pkts;
366de2bc16eSShijith Thotton 	struct rte_mempool *pool = t->pool;
367de2bc16eSShijith Thotton 	struct evt_options *opt = t->opt;
368de2bc16eSShijith Thotton 	uint16_t qp_id = p->ca.cdev_qp_id;
369de2bc16eSShijith Thotton 	uint8_t cdev_id = p->ca.cdev_id;
3703158ec9fSVolodymyr Fialko 	uint64_t alloc_failures = 0;
371de2bc16eSShijith Thotton 	uint32_t flow_counter = 0;
372de2bc16eSShijith Thotton 	struct rte_crypto_op *op;
373de2bc16eSShijith Thotton 	struct rte_mbuf *m;
374de2bc16eSShijith Thotton 	uint64_t count = 0;
375de2bc16eSShijith Thotton 	uint16_t len;
376de2bc16eSShijith Thotton 
377de2bc16eSShijith Thotton 	if (opt->verbose_level > 1)
378de2bc16eSShijith Thotton 		printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
379de2bc16eSShijith Thotton 		       __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
380de2bc16eSShijith Thotton 		       p->ca.cdev_qp_id);
381de2bc16eSShijith Thotton 
382de2bc16eSShijith Thotton 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
383de2bc16eSShijith Thotton 
384de2bc16eSShijith Thotton 	while (count < nb_pkts && t->done == false) {
3858f5b5495SAkhil Goyal 		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
3868f5b5495SAkhil Goyal 			struct rte_crypto_sym_op *sym_op;
3878f5b5495SAkhil Goyal 
3888f5b5495SAkhil Goyal 			op = rte_crypto_op_alloc(t->ca_op_pool,
3898f5b5495SAkhil Goyal 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3903158ec9fSVolodymyr Fialko 			if (unlikely(op == NULL)) {
3913158ec9fSVolodymyr Fialko 				alloc_failures++;
392de2bc16eSShijith Thotton 				continue;
3933158ec9fSVolodymyr Fialko 			}
3943158ec9fSVolodymyr Fialko 
3953158ec9fSVolodymyr Fialko 			m = rte_pktmbuf_alloc(pool);
3963158ec9fSVolodymyr Fialko 			if (unlikely(m == NULL)) {
3973158ec9fSVolodymyr Fialko 				alloc_failures++;
3983158ec9fSVolodymyr Fialko 				rte_crypto_op_free(op);
3993158ec9fSVolodymyr Fialko 				continue;
4003158ec9fSVolodymyr Fialko 			}
401de2bc16eSShijith Thotton 
402de2bc16eSShijith Thotton 			rte_pktmbuf_append(m, len);
403de2bc16eSShijith Thotton 			sym_op = op->sym;
404de2bc16eSShijith Thotton 			sym_op->m_src = m;
405de2bc16eSShijith Thotton 			sym_op->cipher.data.offset = 0;
406de2bc16eSShijith Thotton 			sym_op->cipher.data.length = len;
407de2bc16eSShijith Thotton 			rte_crypto_op_attach_sym_session(
4088f5b5495SAkhil Goyal 				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
4098f5b5495SAkhil Goyal 		} else {
4108f5b5495SAkhil Goyal 			struct rte_crypto_asym_op *asym_op;
4118f5b5495SAkhil Goyal 			uint8_t *result = rte_zmalloc(NULL,
4128f5b5495SAkhil Goyal 					modex_test_case.result_len, 0);
413de2bc16eSShijith Thotton 
4148f5b5495SAkhil Goyal 			op = rte_crypto_op_alloc(t->ca_op_pool,
4158f5b5495SAkhil Goyal 					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
4163158ec9fSVolodymyr Fialko 			if (unlikely(op == NULL)) {
4173158ec9fSVolodymyr Fialko 				alloc_failures++;
4183158ec9fSVolodymyr Fialko 				continue;
4193158ec9fSVolodymyr Fialko 			}
4203158ec9fSVolodymyr Fialko 
4218f5b5495SAkhil Goyal 			asym_op = op->asym;
4228f5b5495SAkhil Goyal 			asym_op->modex.base.data = modex_test_case.base.data;
4238f5b5495SAkhil Goyal 			asym_op->modex.base.length = modex_test_case.base.len;
4248f5b5495SAkhil Goyal 			asym_op->modex.result.data = result;
4258f5b5495SAkhil Goyal 			asym_op->modex.result.length = modex_test_case.result_len;
4268f5b5495SAkhil Goyal 			rte_crypto_op_attach_asym_session(
4278f5b5495SAkhil Goyal 				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
4288f5b5495SAkhil Goyal 		}
429de2bc16eSShijith Thotton 		while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
430de2bc16eSShijith Thotton 				t->done == false)
431de2bc16eSShijith Thotton 			rte_pause();
432de2bc16eSShijith Thotton 
433de2bc16eSShijith Thotton 		count++;
434de2bc16eSShijith Thotton 	}
4353158ec9fSVolodymyr Fialko 
4363158ec9fSVolodymyr Fialko 	if (opt->verbose_level > 1 && alloc_failures)
4373158ec9fSVolodymyr Fialko 		printf("%s(): lcore %d allocation failures: %"PRIu64"\n",
4383158ec9fSVolodymyr Fialko 		       __func__, rte_lcore_id(), alloc_failures);
439de2bc16eSShijith Thotton }
440de2bc16eSShijith Thotton 
441de2bc16eSShijith Thotton static inline void
442de2bc16eSShijith Thotton crypto_adapter_enq_op_fwd(struct prod_data *p)
443de2bc16eSShijith Thotton {
444de2bc16eSShijith Thotton 	const uint8_t dev_id = p->dev_id;
445de2bc16eSShijith Thotton 	const uint8_t port = p->port_id;
446de2bc16eSShijith Thotton 	struct test_perf *t = p->t;
447de2bc16eSShijith Thotton 	const uint32_t nb_flows = t->nb_flows;
448de2bc16eSShijith Thotton 	const uint64_t nb_pkts = t->nb_pkts;
449de2bc16eSShijith Thotton 	struct rte_mempool *pool = t->pool;
450de2bc16eSShijith Thotton 	struct evt_options *opt = t->opt;
4513158ec9fSVolodymyr Fialko 	uint64_t alloc_failures = 0;
452de2bc16eSShijith Thotton 	uint32_t flow_counter = 0;
453de2bc16eSShijith Thotton 	struct rte_crypto_op *op;
454de2bc16eSShijith Thotton 	struct rte_event ev;
455de2bc16eSShijith Thotton 	struct rte_mbuf *m;
456de2bc16eSShijith Thotton 	uint64_t count = 0;
457de2bc16eSShijith Thotton 	uint16_t len;
458de2bc16eSShijith Thotton 
459de2bc16eSShijith Thotton 	if (opt->verbose_level > 1)
460de2bc16eSShijith Thotton 		printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
461de2bc16eSShijith Thotton 		       __func__, rte_lcore_id(), port, p->queue_id,
462de2bc16eSShijith Thotton 		       p->ca.cdev_id, p->ca.cdev_qp_id);
463de2bc16eSShijith Thotton 
464de2bc16eSShijith Thotton 	ev.event = 0;
465de2bc16eSShijith Thotton 	ev.op = RTE_EVENT_OP_NEW;
466de2bc16eSShijith Thotton 	ev.queue_id = p->queue_id;
467de2bc16eSShijith Thotton 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
468de2bc16eSShijith Thotton 	ev.event_type = RTE_EVENT_TYPE_CPU;
469de2bc16eSShijith Thotton 	len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
470de2bc16eSShijith Thotton 
471de2bc16eSShijith Thotton 	while (count < nb_pkts && t->done == false) {
4728f5b5495SAkhil Goyal 		if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
4738f5b5495SAkhil Goyal 			struct rte_crypto_sym_op *sym_op;
4748f5b5495SAkhil Goyal 
4758f5b5495SAkhil Goyal 			op = rte_crypto_op_alloc(t->ca_op_pool,
4768f5b5495SAkhil Goyal 					 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4773158ec9fSVolodymyr Fialko 			if (unlikely(op == NULL)) {
4783158ec9fSVolodymyr Fialko 				alloc_failures++;
479de2bc16eSShijith Thotton 				continue;
4803158ec9fSVolodymyr Fialko 			}
4813158ec9fSVolodymyr Fialko 
4823158ec9fSVolodymyr Fialko 			m = rte_pktmbuf_alloc(pool);
4833158ec9fSVolodymyr Fialko 			if (unlikely(m == NULL)) {
4843158ec9fSVolodymyr Fialko 				alloc_failures++;
4853158ec9fSVolodymyr Fialko 				rte_crypto_op_free(op);
4863158ec9fSVolodymyr Fialko 				continue;
4873158ec9fSVolodymyr Fialko 			}
488de2bc16eSShijith Thotton 
489de2bc16eSShijith Thotton 			rte_pktmbuf_append(m, len);
490de2bc16eSShijith Thotton 			sym_op = op->sym;
491de2bc16eSShijith Thotton 			sym_op->m_src = m;
492de2bc16eSShijith Thotton 			sym_op->cipher.data.offset = 0;
493de2bc16eSShijith Thotton 			sym_op->cipher.data.length = len;
494de2bc16eSShijith Thotton 			rte_crypto_op_attach_sym_session(
4958f5b5495SAkhil Goyal 				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
4968f5b5495SAkhil Goyal 		} else {
4978f5b5495SAkhil Goyal 			struct rte_crypto_asym_op *asym_op;
4988f5b5495SAkhil Goyal 			uint8_t *result = rte_zmalloc(NULL,
4998f5b5495SAkhil Goyal 					modex_test_case.result_len, 0);
5008f5b5495SAkhil Goyal 
5018f5b5495SAkhil Goyal 			op = rte_crypto_op_alloc(t->ca_op_pool,
5028f5b5495SAkhil Goyal 					 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
5033158ec9fSVolodymyr Fialko 			if (unlikely(op == NULL)) {
5043158ec9fSVolodymyr Fialko 				alloc_failures++;
5053158ec9fSVolodymyr Fialko 				continue;
5063158ec9fSVolodymyr Fialko 			}
5073158ec9fSVolodymyr Fialko 
5088f5b5495SAkhil Goyal 			asym_op = op->asym;
5098f5b5495SAkhil Goyal 			asym_op->modex.base.data = modex_test_case.base.data;
5108f5b5495SAkhil Goyal 			asym_op->modex.base.length = modex_test_case.base.len;
5118f5b5495SAkhil Goyal 			asym_op->modex.result.data = result;
5128f5b5495SAkhil Goyal 			asym_op->modex.result.length = modex_test_case.result_len;
5138f5b5495SAkhil Goyal 			rte_crypto_op_attach_asym_session(
5148f5b5495SAkhil Goyal 				op, p->ca.crypto_sess[flow_counter++ % nb_flows]);
5158f5b5495SAkhil Goyal 		}
516de2bc16eSShijith Thotton 		ev.event_ptr = op;
517de2bc16eSShijith Thotton 
518de2bc16eSShijith Thotton 		while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
519de2bc16eSShijith Thotton 		       t->done == false)
520de2bc16eSShijith Thotton 			rte_pause();
521de2bc16eSShijith Thotton 
522de2bc16eSShijith Thotton 		count++;
523de2bc16eSShijith Thotton 	}
5243158ec9fSVolodymyr Fialko 
5253158ec9fSVolodymyr Fialko 	if (opt->verbose_level > 1 && alloc_failures)
5263158ec9fSVolodymyr Fialko 		printf("%s(): lcore %d allocation failures: %"PRIu64"\n",
5273158ec9fSVolodymyr Fialko 		       __func__, rte_lcore_id(), alloc_failures);
528de2bc16eSShijith Thotton }
529de2bc16eSShijith Thotton 
530de2bc16eSShijith Thotton static inline int
531de2bc16eSShijith Thotton perf_event_crypto_producer(void *arg)
532de2bc16eSShijith Thotton {
533de2bc16eSShijith Thotton 	struct prod_data *p = arg;
534de2bc16eSShijith Thotton 	struct evt_options *opt = p->t->opt;
535de2bc16eSShijith Thotton 
536de2bc16eSShijith Thotton 	if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
537de2bc16eSShijith Thotton 		crypto_adapter_enq_op_new(p);
538de2bc16eSShijith Thotton 	else
539de2bc16eSShijith Thotton 		crypto_adapter_enq_op_fwd(p);
540de2bc16eSShijith Thotton 
541de2bc16eSShijith Thotton 	return 0;
542de2bc16eSShijith Thotton }
543de2bc16eSShijith Thotton 
54459f697e3SPavan Nikhilesh static int
54559f697e3SPavan Nikhilesh perf_producer_wrapper(void *arg)
54659f697e3SPavan Nikhilesh {
54759f697e3SPavan Nikhilesh 	struct prod_data *p  = arg;
54859f697e3SPavan Nikhilesh 	struct test_perf *t = p->t;
54920841a25SRashmi Shetty 	bool burst = evt_has_burst_mode(p->dev_id);
55020841a25SRashmi Shetty 
55120841a25SRashmi Shetty 	/* In case of synthetic producer, launch perf_producer or
55220841a25SRashmi Shetty 	 * perf_producer_burst depending on producer enqueue burst size
55320841a25SRashmi Shetty 	 */
55420841a25SRashmi Shetty 	if (t->opt->prod_type == EVT_PROD_TYPE_SYNT &&
55520841a25SRashmi Shetty 			t->opt->prod_enq_burst_sz == 1)
55659f697e3SPavan Nikhilesh 		return perf_producer(arg);
55720841a25SRashmi Shetty 	else if (t->opt->prod_type == EVT_PROD_TYPE_SYNT &&
55820841a25SRashmi Shetty 			t->opt->prod_enq_burst_sz > 1) {
55920841a25SRashmi Shetty 		if (!burst)
56020841a25SRashmi Shetty 			evt_err("This event device does not support burst mode");
56120841a25SRashmi Shetty 		else
56220841a25SRashmi Shetty 			return perf_producer_burst(arg);
56320841a25SRashmi Shetty 	}
56417b22d0bSPavan Nikhilesh 	else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
56517b22d0bSPavan Nikhilesh 			!t->opt->timdev_use_burst)
566d008f20bSPavan Nikhilesh 		return perf_event_timer_producer(arg);
56717b22d0bSPavan Nikhilesh 	else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
56817b22d0bSPavan Nikhilesh 			t->opt->timdev_use_burst)
56917b22d0bSPavan Nikhilesh 		return perf_event_timer_producer_burst(arg);
570de2bc16eSShijith Thotton 	else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
571de2bc16eSShijith Thotton 		return perf_event_crypto_producer(arg);
57259f697e3SPavan Nikhilesh 	return 0;
57359f697e3SPavan Nikhilesh }
57459f697e3SPavan Nikhilesh 
5759d3aeb18SJerin Jacob static inline uint64_t
5769d3aeb18SJerin Jacob processed_pkts(struct test_perf *t)
5779d3aeb18SJerin Jacob {
5789d3aeb18SJerin Jacob 	uint8_t i;
5799d3aeb18SJerin Jacob 	uint64_t total = 0;
5809d3aeb18SJerin Jacob 
5819d3aeb18SJerin Jacob 	for (i = 0; i < t->nb_workers; i++)
5829d3aeb18SJerin Jacob 		total += t->worker[i].processed_pkts;
5839d3aeb18SJerin Jacob 
5849d3aeb18SJerin Jacob 	return total;
5859d3aeb18SJerin Jacob }
5869d3aeb18SJerin Jacob 
5879d3aeb18SJerin Jacob static inline uint64_t
5889d3aeb18SJerin Jacob total_latency(struct test_perf *t)
5899d3aeb18SJerin Jacob {
5909d3aeb18SJerin Jacob 	uint8_t i;
5919d3aeb18SJerin Jacob 	uint64_t total = 0;
5929d3aeb18SJerin Jacob 
5939d3aeb18SJerin Jacob 	for (i = 0; i < t->nb_workers; i++)
5949d3aeb18SJerin Jacob 		total += t->worker[i].latency;
5959d3aeb18SJerin Jacob 
5969d3aeb18SJerin Jacob 	return total;
5979d3aeb18SJerin Jacob }
5989d3aeb18SJerin Jacob 
5999d3aeb18SJerin Jacob 
6009d3aeb18SJerin Jacob int
6019d3aeb18SJerin Jacob perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
6029d3aeb18SJerin Jacob 		int (*worker)(void *))
6039d3aeb18SJerin Jacob {
6049d3aeb18SJerin Jacob 	int ret, lcore_id;
6059d3aeb18SJerin Jacob 	struct test_perf *t = evt_test_priv(test);
6069d3aeb18SJerin Jacob 
6079d3aeb18SJerin Jacob 	int port_idx = 0;
6089d3aeb18SJerin Jacob 	/* launch workers */
609cb056611SStephen Hemminger 	RTE_LCORE_FOREACH_WORKER(lcore_id) {
6109d3aeb18SJerin Jacob 		if (!(opt->wlcores[lcore_id]))
6119d3aeb18SJerin Jacob 			continue;
6129d3aeb18SJerin Jacob 
6139d3aeb18SJerin Jacob 		ret = rte_eal_remote_launch(worker,
6149d3aeb18SJerin Jacob 				 &t->worker[port_idx], lcore_id);
6159d3aeb18SJerin Jacob 		if (ret) {
6169d3aeb18SJerin Jacob 			evt_err("failed to launch worker %d", lcore_id);
6179d3aeb18SJerin Jacob 			return ret;
6189d3aeb18SJerin Jacob 		}
6199d3aeb18SJerin Jacob 		port_idx++;
6209d3aeb18SJerin Jacob 	}
6219d3aeb18SJerin Jacob 
6229d3aeb18SJerin Jacob 	/* launch producers */
623cb056611SStephen Hemminger 	RTE_LCORE_FOREACH_WORKER(lcore_id) {
6249d3aeb18SJerin Jacob 		if (!(opt->plcores[lcore_id]))
6259d3aeb18SJerin Jacob 			continue;
6269d3aeb18SJerin Jacob 
62759f697e3SPavan Nikhilesh 		ret = rte_eal_remote_launch(perf_producer_wrapper,
62859f697e3SPavan Nikhilesh 				&t->prod[port_idx], lcore_id);
6299d3aeb18SJerin Jacob 		if (ret) {
6309d3aeb18SJerin Jacob 			evt_err("failed to launch perf_producer %d", lcore_id);
6319d3aeb18SJerin Jacob 			return ret;
6329d3aeb18SJerin Jacob 		}
6339d3aeb18SJerin Jacob 		port_idx++;
6349d3aeb18SJerin Jacob 	}
6359d3aeb18SJerin Jacob 
636d008f20bSPavan Nikhilesh 	const uint64_t total_pkts = t->outstand_pkts;
6379d3aeb18SJerin Jacob 
6389d3aeb18SJerin Jacob 	uint64_t dead_lock_cycles = rte_get_timer_cycles();
6399d3aeb18SJerin Jacob 	int64_t dead_lock_remaining  =  total_pkts;
6409d3aeb18SJerin Jacob 	const uint64_t dead_lock_sample = rte_get_timer_hz() * 5;
6419d3aeb18SJerin Jacob 
6429d3aeb18SJerin Jacob 	uint64_t perf_cycles = rte_get_timer_cycles();
6439d3aeb18SJerin Jacob 	int64_t perf_remaining  = total_pkts;
6449d3aeb18SJerin Jacob 	const uint64_t perf_sample = rte_get_timer_hz();
6459d3aeb18SJerin Jacob 
6469d3aeb18SJerin Jacob 	static float total_mpps;
6479d3aeb18SJerin Jacob 	static uint64_t samples;
6489d3aeb18SJerin Jacob 
6499d3aeb18SJerin Jacob 	const uint64_t freq_mhz = rte_get_timer_hz() / 1000000;
6509d3aeb18SJerin Jacob 	int64_t remaining = t->outstand_pkts - processed_pkts(t);
6519d3aeb18SJerin Jacob 
6529d3aeb18SJerin Jacob 	while (t->done == false) {
6539d3aeb18SJerin Jacob 		const uint64_t new_cycles = rte_get_timer_cycles();
6549d3aeb18SJerin Jacob 
6559d3aeb18SJerin Jacob 		if ((new_cycles - perf_cycles) > perf_sample) {
6569d3aeb18SJerin Jacob 			const uint64_t latency = total_latency(t);
6579d3aeb18SJerin Jacob 			const uint64_t pkts = processed_pkts(t);
6589d3aeb18SJerin Jacob 
6599d3aeb18SJerin Jacob 			remaining = t->outstand_pkts - pkts;
6609d3aeb18SJerin Jacob 			float mpps = (float)(perf_remaining-remaining)/1000000;
6619d3aeb18SJerin Jacob 
6629d3aeb18SJerin Jacob 			perf_remaining = remaining;
6639d3aeb18SJerin Jacob 			perf_cycles = new_cycles;
6649d3aeb18SJerin Jacob 			total_mpps += mpps;
6659d3aeb18SJerin Jacob 			++samples;
66604716352SJerin Jacob 			if (opt->fwd_latency && pkts > 0) {
6679d3aeb18SJerin Jacob 				printf(CLGRN"\r%.3f mpps avg %.3f mpps [avg fwd latency %.3f us] "CLNRM,
6689d3aeb18SJerin Jacob 					mpps, total_mpps/samples,
6699d3aeb18SJerin Jacob 					(float)(latency/pkts)/freq_mhz);
6709d3aeb18SJerin Jacob 			} else {
6719d3aeb18SJerin Jacob 				printf(CLGRN"\r%.3f mpps avg %.3f mpps"CLNRM,
6729d3aeb18SJerin Jacob 					mpps, total_mpps/samples);
6739d3aeb18SJerin Jacob 			}
6749d3aeb18SJerin Jacob 			fflush(stdout);
6759d3aeb18SJerin Jacob 
6769d3aeb18SJerin Jacob 			if (remaining <= 0) {
6779d3aeb18SJerin Jacob 				t->result = EVT_TEST_SUCCESS;
678d008f20bSPavan Nikhilesh 				if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
679d008f20bSPavan Nikhilesh 				    opt->prod_type ==
680de2bc16eSShijith Thotton 					    EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
681de2bc16eSShijith Thotton 				    opt->prod_type ==
682de2bc16eSShijith Thotton 					    EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
68359f697e3SPavan Nikhilesh 					t->done = true;
6849d3aeb18SJerin Jacob 					break;
6859d3aeb18SJerin Jacob 				}
6869d3aeb18SJerin Jacob 			}
68759f697e3SPavan Nikhilesh 		}
6889d3aeb18SJerin Jacob 
68959f697e3SPavan Nikhilesh 		if (new_cycles - dead_lock_cycles > dead_lock_sample &&
69047303784SErik Gabriel Carrillo 		    (opt->prod_type == EVT_PROD_TYPE_SYNT ||
691de2bc16eSShijith Thotton 		     opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
692de2bc16eSShijith Thotton 		     opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
6939d3aeb18SJerin Jacob 			remaining = t->outstand_pkts - processed_pkts(t);
6949d3aeb18SJerin Jacob 			if (dead_lock_remaining == remaining) {
6959d3aeb18SJerin Jacob 				rte_event_dev_dump(opt->dev_id, stdout);
6969d3aeb18SJerin Jacob 				evt_err("No schedules for seconds, deadlock");
6979d3aeb18SJerin Jacob 				t->done = true;
6989d3aeb18SJerin Jacob 				break;
6999d3aeb18SJerin Jacob 			}
7009d3aeb18SJerin Jacob 			dead_lock_remaining = remaining;
7019d3aeb18SJerin Jacob 			dead_lock_cycles = new_cycles;
7029d3aeb18SJerin Jacob 		}
7039d3aeb18SJerin Jacob 	}
7049d3aeb18SJerin Jacob 	printf("\n");
7059d3aeb18SJerin Jacob 	return 0;
7069d3aeb18SJerin Jacob }
7079d3aeb18SJerin Jacob 
7083617aae5SPavan Nikhilesh static int
7093617aae5SPavan Nikhilesh perf_event_rx_adapter_setup(struct evt_options *opt, uint8_t stride,
7103617aae5SPavan Nikhilesh 		struct rte_event_port_conf prod_conf)
7113617aae5SPavan Nikhilesh {
7123617aae5SPavan Nikhilesh 	int ret = 0;
7133617aae5SPavan Nikhilesh 	uint16_t prod;
7143617aae5SPavan Nikhilesh 	struct rte_event_eth_rx_adapter_queue_conf queue_conf;
7153617aae5SPavan Nikhilesh 
7163617aae5SPavan Nikhilesh 	memset(&queue_conf, 0,
7173617aae5SPavan Nikhilesh 			sizeof(struct rte_event_eth_rx_adapter_queue_conf));
7183617aae5SPavan Nikhilesh 	queue_conf.ev.sched_type = opt->sched_type_list[0];
7198728ccf3SThomas Monjalon 	RTE_ETH_FOREACH_DEV(prod) {
7203617aae5SPavan Nikhilesh 		uint32_t cap;
7213617aae5SPavan Nikhilesh 
7223617aae5SPavan Nikhilesh 		ret = rte_event_eth_rx_adapter_caps_get(opt->dev_id,
7233617aae5SPavan Nikhilesh 				prod, &cap);
7243617aae5SPavan Nikhilesh 		if (ret) {
7253617aae5SPavan Nikhilesh 			evt_err("failed to get event rx adapter[%d]"
7263617aae5SPavan Nikhilesh 					" capabilities",
7273617aae5SPavan Nikhilesh 					opt->dev_id);
7283617aae5SPavan Nikhilesh 			return ret;
7293617aae5SPavan Nikhilesh 		}
7303617aae5SPavan Nikhilesh 		queue_conf.ev.queue_id = prod * stride;
7313617aae5SPavan Nikhilesh 		ret = rte_event_eth_rx_adapter_create(prod, opt->dev_id,
7323617aae5SPavan Nikhilesh 				&prod_conf);
7333617aae5SPavan Nikhilesh 		if (ret) {
7343617aae5SPavan Nikhilesh 			evt_err("failed to create rx adapter[%d]", prod);
7353617aae5SPavan Nikhilesh 			return ret;
7363617aae5SPavan Nikhilesh 		}
7373617aae5SPavan Nikhilesh 		ret = rte_event_eth_rx_adapter_queue_add(prod, prod, -1,
7383617aae5SPavan Nikhilesh 				&queue_conf);
7393617aae5SPavan Nikhilesh 		if (ret) {
7403617aae5SPavan Nikhilesh 			evt_err("failed to add rx queues to adapter[%d]", prod);
7413617aae5SPavan Nikhilesh 			return ret;
7423617aae5SPavan Nikhilesh 		}
7433617aae5SPavan Nikhilesh 
744b0333c55SPavan Nikhilesh 		if (!(cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT)) {
745b0333c55SPavan Nikhilesh 			uint32_t service_id;
746b0333c55SPavan Nikhilesh 
747b0333c55SPavan Nikhilesh 			rte_event_eth_rx_adapter_service_id_get(prod,
748b0333c55SPavan Nikhilesh 					&service_id);
749b0333c55SPavan Nikhilesh 			ret = evt_service_setup(service_id);
750b0333c55SPavan Nikhilesh 			if (ret) {
751b0333c55SPavan Nikhilesh 				evt_err("Failed to setup service core"
752b0333c55SPavan Nikhilesh 						" for Rx adapter\n");
753b0333c55SPavan Nikhilesh 				return ret;
754b0333c55SPavan Nikhilesh 			}
755b0333c55SPavan Nikhilesh 		}
7563617aae5SPavan Nikhilesh 	}
7573617aae5SPavan Nikhilesh 
7583617aae5SPavan Nikhilesh 	return ret;
7593617aae5SPavan Nikhilesh }
7603617aae5SPavan Nikhilesh 
761d008f20bSPavan Nikhilesh static int
762d008f20bSPavan Nikhilesh perf_event_timer_adapter_setup(struct test_perf *t)
763d008f20bSPavan Nikhilesh {
764d008f20bSPavan Nikhilesh 	int i;
765d008f20bSPavan Nikhilesh 	int ret;
766d008f20bSPavan Nikhilesh 	struct rte_event_timer_adapter_info adapter_info;
767d008f20bSPavan Nikhilesh 	struct rte_event_timer_adapter *wl;
768d008f20bSPavan Nikhilesh 	uint8_t nb_producers = evt_nr_active_lcores(t->opt->plcores);
769d008f20bSPavan Nikhilesh 	uint8_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
770d008f20bSPavan Nikhilesh 
771d008f20bSPavan Nikhilesh 	if (nb_producers == 1)
772d008f20bSPavan Nikhilesh 		flags |= RTE_EVENT_TIMER_ADAPTER_F_SP_PUT;
773d008f20bSPavan Nikhilesh 
774d008f20bSPavan Nikhilesh 	for (i = 0; i < t->opt->nb_timer_adptrs; i++) {
775d008f20bSPavan Nikhilesh 		struct rte_event_timer_adapter_conf config = {
776d008f20bSPavan Nikhilesh 			.event_dev_id = t->opt->dev_id,
777d008f20bSPavan Nikhilesh 			.timer_adapter_id = i,
778d008f20bSPavan Nikhilesh 			.timer_tick_ns = t->opt->timer_tick_nsec,
779d008f20bSPavan Nikhilesh 			.max_tmo_ns = t->opt->max_tmo_nsec,
780c13b1ad7SPavan Nikhilesh 			.nb_timers = t->opt->pool_sz,
781d008f20bSPavan Nikhilesh 			.flags = flags,
782d008f20bSPavan Nikhilesh 		};
783d008f20bSPavan Nikhilesh 
784d008f20bSPavan Nikhilesh 		wl = rte_event_timer_adapter_create(&config);
785d008f20bSPavan Nikhilesh 		if (wl == NULL) {
786d008f20bSPavan Nikhilesh 			evt_err("failed to create event timer ring %d", i);
787d008f20bSPavan Nikhilesh 			return rte_errno;
788d008f20bSPavan Nikhilesh 		}
789d008f20bSPavan Nikhilesh 
790d008f20bSPavan Nikhilesh 		memset(&adapter_info, 0,
791d008f20bSPavan Nikhilesh 				sizeof(struct rte_event_timer_adapter_info));
792d008f20bSPavan Nikhilesh 		rte_event_timer_adapter_get_info(wl, &adapter_info);
793d008f20bSPavan Nikhilesh 		t->opt->optm_timer_tick_nsec = adapter_info.min_resolution_ns;
794d008f20bSPavan Nikhilesh 
795d008f20bSPavan Nikhilesh 		if (!(adapter_info.caps &
796d008f20bSPavan Nikhilesh 				RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) {
79799c25664SAndrzej Ostruszka 			uint32_t service_id = -1U;
798d008f20bSPavan Nikhilesh 
799d008f20bSPavan Nikhilesh 			rte_event_timer_adapter_service_id_get(wl,
800d008f20bSPavan Nikhilesh 					&service_id);
801d008f20bSPavan Nikhilesh 			ret = evt_service_setup(service_id);
802d008f20bSPavan Nikhilesh 			if (ret) {
803d008f20bSPavan Nikhilesh 				evt_err("Failed to setup service core"
804d008f20bSPavan Nikhilesh 						" for timer adapter\n");
805d008f20bSPavan Nikhilesh 				return ret;
806d008f20bSPavan Nikhilesh 			}
807d008f20bSPavan Nikhilesh 			rte_service_runstate_set(service_id, 1);
808d008f20bSPavan Nikhilesh 		}
809d008f20bSPavan Nikhilesh 		t->timer_adptr[i] = wl;
810d008f20bSPavan Nikhilesh 	}
811d008f20bSPavan Nikhilesh 	return 0;
812d008f20bSPavan Nikhilesh }
813d008f20bSPavan Nikhilesh 
814de2bc16eSShijith Thotton static int
815de2bc16eSShijith Thotton perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
816de2bc16eSShijith Thotton {
817de2bc16eSShijith Thotton 	struct evt_options *opt = t->opt;
818de2bc16eSShijith Thotton 	uint32_t cap;
819de2bc16eSShijith Thotton 	int ret;
820de2bc16eSShijith Thotton 
821de2bc16eSShijith Thotton 	ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id, &cap);
822de2bc16eSShijith Thotton 	if (ret) {
823de2bc16eSShijith Thotton 		evt_err("Failed to get crypto adapter capabilities");
824de2bc16eSShijith Thotton 		return ret;
825de2bc16eSShijith Thotton 	}
826de2bc16eSShijith Thotton 
827de2bc16eSShijith Thotton 	if (((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
828de2bc16eSShijith Thotton 	     !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
829de2bc16eSShijith Thotton 	    ((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
830de2bc16eSShijith Thotton 	     !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
831de2bc16eSShijith Thotton 		evt_err("crypto adapter %s mode unsupported\n",
832de2bc16eSShijith Thotton 			opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
833de2bc16eSShijith Thotton 		return -ENOTSUP;
834de2bc16eSShijith Thotton 	} else if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
835de2bc16eSShijith Thotton 		evt_err("Storing crypto session not supported");
836de2bc16eSShijith Thotton 		return -ENOTSUP;
837de2bc16eSShijith Thotton 	}
838de2bc16eSShijith Thotton 
839de2bc16eSShijith Thotton 	if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
840*c1749bc5SVolodymyr Fialko 		struct rte_event_crypto_adapter_queue_conf conf;
841de2bc16eSShijith Thotton 
842*c1749bc5SVolodymyr Fialko 		memset(&conf, 0, sizeof(conf));
843*c1749bc5SVolodymyr Fialko 		conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
844*c1749bc5SVolodymyr Fialko 		conf.ev.queue_id = p->queue_id;
845de2bc16eSShijith Thotton 		ret = rte_event_crypto_adapter_queue_pair_add(
846*c1749bc5SVolodymyr Fialko 			TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, &conf);
847de2bc16eSShijith Thotton 	} else {
848de2bc16eSShijith Thotton 		ret = rte_event_crypto_adapter_queue_pair_add(
849de2bc16eSShijith Thotton 			TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, NULL);
850de2bc16eSShijith Thotton 	}
851de2bc16eSShijith Thotton 
852de2bc16eSShijith Thotton 	return ret;
853de2bc16eSShijith Thotton }
854de2bc16eSShijith Thotton 
855de2bc16eSShijith Thotton static struct rte_cryptodev_sym_session *
856de2bc16eSShijith Thotton cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
857de2bc16eSShijith Thotton {
858de2bc16eSShijith Thotton 	struct rte_crypto_sym_xform cipher_xform;
859de2bc16eSShijith Thotton 	struct rte_cryptodev_sym_session *sess;
860de2bc16eSShijith Thotton 
861de2bc16eSShijith Thotton 	cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
862de2bc16eSShijith Thotton 	cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
863de2bc16eSShijith Thotton 	cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
864de2bc16eSShijith Thotton 	cipher_xform.next = NULL;
865de2bc16eSShijith Thotton 
866de2bc16eSShijith Thotton 	sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
867de2bc16eSShijith Thotton 	if (sess == NULL) {
868de2bc16eSShijith Thotton 		evt_err("Failed to create sym session");
869de2bc16eSShijith Thotton 		return NULL;
870de2bc16eSShijith Thotton 	}
871de2bc16eSShijith Thotton 
872de2bc16eSShijith Thotton 	if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
873de2bc16eSShijith Thotton 					   t->ca_sess_priv_pool)) {
874de2bc16eSShijith Thotton 		evt_err("Failed to init session");
875de2bc16eSShijith Thotton 		return NULL;
876de2bc16eSShijith Thotton 	}
877de2bc16eSShijith Thotton 
878de2bc16eSShijith Thotton 	return sess;
879de2bc16eSShijith Thotton }
880de2bc16eSShijith Thotton 
8818f5b5495SAkhil Goyal static void *
8828f5b5495SAkhil Goyal cryptodev_asym_sess_create(struct prod_data *p, struct test_perf *t)
8838f5b5495SAkhil Goyal {
8848f5b5495SAkhil Goyal 	const struct rte_cryptodev_asymmetric_xform_capability *capability;
8858f5b5495SAkhil Goyal 	struct rte_cryptodev_asym_capability_idx cap_idx;
8868f5b5495SAkhil Goyal 	struct rte_crypto_asym_xform xform;
8878f5b5495SAkhil Goyal 	void *sess;
8888f5b5495SAkhil Goyal 
8898f5b5495SAkhil Goyal 	xform.next = NULL;
8908f5b5495SAkhil Goyal 	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
8918f5b5495SAkhil Goyal 	cap_idx.type = xform.xform_type;
8928f5b5495SAkhil Goyal 	capability = rte_cryptodev_asym_capability_get(p->ca.cdev_id, &cap_idx);
8938f5b5495SAkhil Goyal 	if (capability == NULL) {
8948f5b5495SAkhil Goyal 		evt_err("Device doesn't support MODEX. Test Skipped\n");
8958f5b5495SAkhil Goyal 		return NULL;
8968f5b5495SAkhil Goyal 	}
8978f5b5495SAkhil Goyal 
8988f5b5495SAkhil Goyal 	xform.modex.modulus.data = modex_test_case.modulus.data;
8998f5b5495SAkhil Goyal 	xform.modex.modulus.length = modex_test_case.modulus.len;
9008f5b5495SAkhil Goyal 	xform.modex.exponent.data = modex_test_case.exponent.data;
9018f5b5495SAkhil Goyal 	xform.modex.exponent.length = modex_test_case.exponent.len;
9028f5b5495SAkhil Goyal 
9038f5b5495SAkhil Goyal 	if (rte_cryptodev_asym_session_create(p->ca.cdev_id, &xform,
9048f5b5495SAkhil Goyal 			t->ca_asym_sess_pool, &sess)) {
9058f5b5495SAkhil Goyal 		evt_err("Failed to create asym session");
9068f5b5495SAkhil Goyal 		return NULL;
9078f5b5495SAkhil Goyal 	}
9088f5b5495SAkhil Goyal 
9098f5b5495SAkhil Goyal 	return sess;
9108f5b5495SAkhil Goyal }
9118f5b5495SAkhil Goyal 
912272de067SJerin Jacob int
91384a7513dSJerin Jacob perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
914535c630cSPavan Nikhilesh 				uint8_t stride, uint8_t nb_queues,
915535c630cSPavan Nikhilesh 				const struct rte_event_port_conf *port_conf)
91684a7513dSJerin Jacob {
91784a7513dSJerin Jacob 	struct test_perf *t = evt_test_priv(test);
9183617aae5SPavan Nikhilesh 	uint16_t port, prod;
91984a7513dSJerin Jacob 	int ret = -1;
92084a7513dSJerin Jacob 
92184a7513dSJerin Jacob 	/* setup one port per worker, linking to all queues */
92284a7513dSJerin Jacob 	for (port = 0; port < evt_nr_active_lcores(opt->wlcores);
92384a7513dSJerin Jacob 				port++) {
92484a7513dSJerin Jacob 		struct worker_data *w = &t->worker[port];
92584a7513dSJerin Jacob 
92684a7513dSJerin Jacob 		w->dev_id = opt->dev_id;
92784a7513dSJerin Jacob 		w->port_id = port;
92884a7513dSJerin Jacob 		w->t = t;
92984a7513dSJerin Jacob 		w->processed_pkts = 0;
93084a7513dSJerin Jacob 		w->latency = 0;
93184a7513dSJerin Jacob 
9325f94d108SHarry van Haaren 		struct rte_event_port_conf conf = *port_conf;
9335f94d108SHarry van Haaren 		conf.event_port_cfg |= RTE_EVENT_PORT_CFG_HINT_WORKER;
9345f94d108SHarry van Haaren 
9355f94d108SHarry van Haaren 		ret = rte_event_port_setup(opt->dev_id, port, &conf);
93684a7513dSJerin Jacob 		if (ret) {
93784a7513dSJerin Jacob 			evt_err("failed to setup port %d", port);
93884a7513dSJerin Jacob 			return ret;
93984a7513dSJerin Jacob 		}
94084a7513dSJerin Jacob 
94184a7513dSJerin Jacob 		ret = rte_event_port_link(opt->dev_id, port, NULL, NULL, 0);
94284a7513dSJerin Jacob 		if (ret != nb_queues) {
94384a7513dSJerin Jacob 			evt_err("failed to link all queues to port %d", port);
94484a7513dSJerin Jacob 			return -EINVAL;
94584a7513dSJerin Jacob 		}
94684a7513dSJerin Jacob 	}
94784a7513dSJerin Jacob 
94884a7513dSJerin Jacob 	/* port for producers, no links */
9493617aae5SPavan Nikhilesh 	if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
9503617aae5SPavan Nikhilesh 		for ( ; port < perf_nb_event_ports(opt); port++) {
9513617aae5SPavan Nikhilesh 			struct prod_data *p = &t->prod[port];
9523617aae5SPavan Nikhilesh 			p->t = t;
9533617aae5SPavan Nikhilesh 		}
9543617aae5SPavan Nikhilesh 
9555f94d108SHarry van Haaren 		struct rte_event_port_conf conf = *port_conf;
9565f94d108SHarry van Haaren 		conf.event_port_cfg |= RTE_EVENT_PORT_CFG_HINT_PRODUCER;
9575f94d108SHarry van Haaren 
9585f94d108SHarry van Haaren 		ret = perf_event_rx_adapter_setup(opt, stride, conf);
9593617aae5SPavan Nikhilesh 		if (ret)
9603617aae5SPavan Nikhilesh 			return ret;
961d008f20bSPavan Nikhilesh 	} else if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
962d008f20bSPavan Nikhilesh 		prod = 0;
963d008f20bSPavan Nikhilesh 		for ( ; port < perf_nb_event_ports(opt); port++) {
964d008f20bSPavan Nikhilesh 			struct prod_data *p = &t->prod[port];
965d008f20bSPavan Nikhilesh 			p->queue_id = prod * stride;
966d008f20bSPavan Nikhilesh 			p->t = t;
967d008f20bSPavan Nikhilesh 			prod++;
968d008f20bSPavan Nikhilesh 		}
969d008f20bSPavan Nikhilesh 
970d008f20bSPavan Nikhilesh 		ret = perf_event_timer_adapter_setup(t);
971d008f20bSPavan Nikhilesh 		if (ret)
972d008f20bSPavan Nikhilesh 			return ret;
973de2bc16eSShijith Thotton 	} else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
974de2bc16eSShijith Thotton 		struct rte_event_port_conf conf = *port_conf;
975de2bc16eSShijith Thotton 		uint8_t cdev_id = 0;
976de2bc16eSShijith Thotton 		uint16_t qp_id = 0;
977de2bc16eSShijith Thotton 
978de2bc16eSShijith Thotton 		ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
979de2bc16eSShijith Thotton 						      opt->dev_id, &conf, 0);
980de2bc16eSShijith Thotton 		if (ret) {
981de2bc16eSShijith Thotton 			evt_err("Failed to create crypto adapter");
982de2bc16eSShijith Thotton 			return ret;
983de2bc16eSShijith Thotton 		}
984de2bc16eSShijith Thotton 
985de2bc16eSShijith Thotton 		prod = 0;
986de2bc16eSShijith Thotton 		for (; port < perf_nb_event_ports(opt); port++) {
987de2bc16eSShijith Thotton 			union rte_event_crypto_metadata m_data;
988de2bc16eSShijith Thotton 			struct prod_data *p = &t->prod[port];
989de2bc16eSShijith Thotton 			uint32_t flow_id;
990de2bc16eSShijith Thotton 
991de2bc16eSShijith Thotton 			if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
992de2bc16eSShijith Thotton 				cdev_id++;
993de2bc16eSShijith Thotton 				qp_id = 0;
994de2bc16eSShijith Thotton 			}
995de2bc16eSShijith Thotton 
996de2bc16eSShijith Thotton 			p->dev_id = opt->dev_id;
997de2bc16eSShijith Thotton 			p->port_id = port;
998de2bc16eSShijith Thotton 			p->queue_id = prod * stride;
999de2bc16eSShijith Thotton 			p->ca.cdev_id = cdev_id;
1000de2bc16eSShijith Thotton 			p->ca.cdev_qp_id = qp_id;
1001de2bc16eSShijith Thotton 			p->ca.crypto_sess = rte_zmalloc_socket(
10028f5b5495SAkhil Goyal 				NULL, sizeof(void *) * t->nb_flows,
1003de2bc16eSShijith Thotton 				RTE_CACHE_LINE_SIZE, opt->socket_id);
1004de2bc16eSShijith Thotton 			p->t = t;
1005de2bc16eSShijith Thotton 
1006de2bc16eSShijith Thotton 			m_data.request_info.cdev_id = p->ca.cdev_id;
1007de2bc16eSShijith Thotton 			m_data.request_info.queue_pair_id = p->ca.cdev_qp_id;
1008de2bc16eSShijith Thotton 			m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
1009de2bc16eSShijith Thotton 			m_data.response_info.queue_id = p->queue_id;
1010de2bc16eSShijith Thotton 
1011de2bc16eSShijith Thotton 			for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
10128f5b5495SAkhil Goyal 				m_data.response_info.flow_id = flow_id;
10138f5b5495SAkhil Goyal 				if (opt->crypto_op_type ==
10148f5b5495SAkhil Goyal 						RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
10158f5b5495SAkhil Goyal 					struct rte_cryptodev_sym_session *sess;
10168f5b5495SAkhil Goyal 
10178f5b5495SAkhil Goyal 					sess = cryptodev_sym_sess_create(p, t);
10188f5b5495SAkhil Goyal 					if (sess == NULL)
1019de2bc16eSShijith Thotton 						return -ENOMEM;
1020de2bc16eSShijith Thotton 
10218f5b5495SAkhil Goyal 					rte_cryptodev_session_event_mdata_set(
10228f5b5495SAkhil Goyal 						cdev_id,
10238f5b5495SAkhil Goyal 						sess,
10244c43055cSAkhil Goyal 						RTE_CRYPTO_OP_TYPE_SYMMETRIC,
10254c43055cSAkhil Goyal 						RTE_CRYPTO_OP_WITH_SESSION,
10264c43055cSAkhil Goyal 						&m_data, sizeof(m_data));
10278f5b5495SAkhil Goyal 					p->ca.crypto_sess[flow_id] = sess;
10288f5b5495SAkhil Goyal 				} else {
10298f5b5495SAkhil Goyal 					void *sess;
10304c43055cSAkhil Goyal 
10318f5b5495SAkhil Goyal 					sess = cryptodev_asym_sess_create(p, t);
10328f5b5495SAkhil Goyal 					if (sess == NULL)
10338f5b5495SAkhil Goyal 						return -ENOMEM;
10348f5b5495SAkhil Goyal 					rte_cryptodev_session_event_mdata_set(
10358f5b5495SAkhil Goyal 						cdev_id,
10368f5b5495SAkhil Goyal 						sess,
10378f5b5495SAkhil Goyal 						RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
10388f5b5495SAkhil Goyal 						RTE_CRYPTO_OP_WITH_SESSION,
10398f5b5495SAkhil Goyal 						&m_data, sizeof(m_data));
10408f5b5495SAkhil Goyal 					p->ca.crypto_sess[flow_id] = sess;
10418f5b5495SAkhil Goyal 				}
1042de2bc16eSShijith Thotton 			}
1043de2bc16eSShijith Thotton 
1044de2bc16eSShijith Thotton 			conf.event_port_cfg |=
1045de2bc16eSShijith Thotton 				RTE_EVENT_PORT_CFG_HINT_PRODUCER |
1046de2bc16eSShijith Thotton 				RTE_EVENT_PORT_CFG_HINT_CONSUMER;
1047de2bc16eSShijith Thotton 
1048de2bc16eSShijith Thotton 			ret = rte_event_port_setup(opt->dev_id, port, &conf);
1049de2bc16eSShijith Thotton 			if (ret) {
1050de2bc16eSShijith Thotton 				evt_err("failed to setup port %d", port);
1051de2bc16eSShijith Thotton 				return ret;
1052de2bc16eSShijith Thotton 			}
1053de2bc16eSShijith Thotton 
1054de2bc16eSShijith Thotton 			ret = perf_event_crypto_adapter_setup(t, p);
1055de2bc16eSShijith Thotton 			if (ret)
1056de2bc16eSShijith Thotton 				return ret;
1057de2bc16eSShijith Thotton 
1058de2bc16eSShijith Thotton 			qp_id++;
1059de2bc16eSShijith Thotton 			prod++;
1060de2bc16eSShijith Thotton 		}
10613617aae5SPavan Nikhilesh 	} else {
106284a7513dSJerin Jacob 		prod = 0;
106384a7513dSJerin Jacob 		for ( ; port < perf_nb_event_ports(opt); port++) {
106484a7513dSJerin Jacob 			struct prod_data *p = &t->prod[port];
106584a7513dSJerin Jacob 
106684a7513dSJerin Jacob 			p->dev_id = opt->dev_id;
106784a7513dSJerin Jacob 			p->port_id = port;
106884a7513dSJerin Jacob 			p->queue_id = prod * stride;
106984a7513dSJerin Jacob 			p->t = t;
107084a7513dSJerin Jacob 
10715f94d108SHarry van Haaren 			struct rte_event_port_conf conf = *port_conf;
10725f94d108SHarry van Haaren 			conf.event_port_cfg |=
10735f94d108SHarry van Haaren 				RTE_EVENT_PORT_CFG_HINT_PRODUCER |
10745f94d108SHarry van Haaren 				RTE_EVENT_PORT_CFG_HINT_CONSUMER;
10755f94d108SHarry van Haaren 
10765f94d108SHarry van Haaren 			ret = rte_event_port_setup(opt->dev_id, port, &conf);
107784a7513dSJerin Jacob 			if (ret) {
107884a7513dSJerin Jacob 				evt_err("failed to setup port %d", port);
107984a7513dSJerin Jacob 				return ret;
108084a7513dSJerin Jacob 			}
108184a7513dSJerin Jacob 			prod++;
108284a7513dSJerin Jacob 		}
10833617aae5SPavan Nikhilesh 	}
108484a7513dSJerin Jacob 
108584a7513dSJerin Jacob 	return ret;
108684a7513dSJerin Jacob }
108784a7513dSJerin Jacob 
108884a7513dSJerin Jacob int
1089272de067SJerin Jacob perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
1090272de067SJerin Jacob {
1091272de067SJerin Jacob 	unsigned int lcores;
1092272de067SJerin Jacob 
1093cb056611SStephen Hemminger 	/* N producer + N worker + main when producer cores are used
1094cb056611SStephen Hemminger 	 * Else N worker + main when Rx adapter is used
1095b01974daSPavan Nikhilesh 	 */
1096b01974daSPavan Nikhilesh 	lcores = opt->prod_type == EVT_PROD_TYPE_SYNT ? 3 : 2;
1097272de067SJerin Jacob 
1098272de067SJerin Jacob 	if (rte_lcore_count() < lcores) {
1099272de067SJerin Jacob 		evt_err("test need minimum %d lcores", lcores);
1100272de067SJerin Jacob 		return -1;
1101272de067SJerin Jacob 	}
1102272de067SJerin Jacob 
1103272de067SJerin Jacob 	/* Validate worker lcores */
1104cb056611SStephen Hemminger 	if (evt_lcores_has_overlap(opt->wlcores, rte_get_main_lcore())) {
1105cb056611SStephen Hemminger 		evt_err("worker lcores overlaps with main lcore");
1106272de067SJerin Jacob 		return -1;
1107272de067SJerin Jacob 	}
1108272de067SJerin Jacob 	if (evt_lcores_has_overlap_multi(opt->wlcores, opt->plcores)) {
1109272de067SJerin Jacob 		evt_err("worker lcores overlaps producer lcores");
1110272de067SJerin Jacob 		return -1;
1111272de067SJerin Jacob 	}
1112272de067SJerin Jacob 	if (evt_has_disabled_lcore(opt->wlcores)) {
1113272de067SJerin Jacob 		evt_err("one or more workers lcores are not enabled");
1114272de067SJerin Jacob 		return -1;
1115272de067SJerin Jacob 	}
1116272de067SJerin Jacob 	if (!evt_has_active_lcore(opt->wlcores)) {
1117272de067SJerin Jacob 		evt_err("minimum one worker is required");
1118272de067SJerin Jacob 		return -1;
1119272de067SJerin Jacob 	}
1120272de067SJerin Jacob 
1121902387eaSPavan Nikhilesh 	if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
1122de2bc16eSShijith Thotton 	    opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
1123de2bc16eSShijith Thotton 	    opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
1124272de067SJerin Jacob 		/* Validate producer lcores */
1125b01974daSPavan Nikhilesh 		if (evt_lcores_has_overlap(opt->plcores,
1126cb056611SStephen Hemminger 					rte_get_main_lcore())) {
1127cb056611SStephen Hemminger 			evt_err("producer lcores overlaps with main lcore");
1128272de067SJerin Jacob 			return -1;
1129272de067SJerin Jacob 		}
1130272de067SJerin Jacob 		if (evt_has_disabled_lcore(opt->plcores)) {
1131272de067SJerin Jacob 			evt_err("one or more producer lcores are not enabled");
1132272de067SJerin Jacob 			return -1;
1133272de067SJerin Jacob 		}
1134272de067SJerin Jacob 		if (!evt_has_active_lcore(opt->plcores)) {
1135272de067SJerin Jacob 			evt_err("minimum one producer is required");
1136272de067SJerin Jacob 			return -1;
1137272de067SJerin Jacob 		}
1138b01974daSPavan Nikhilesh 	}
1139272de067SJerin Jacob 
1140272de067SJerin Jacob 	if (evt_has_invalid_stage(opt))
1141272de067SJerin Jacob 		return -1;
1142272de067SJerin Jacob 
1143272de067SJerin Jacob 	if (evt_has_invalid_sched_type(opt))
1144272de067SJerin Jacob 		return -1;
1145272de067SJerin Jacob 
1146272de067SJerin Jacob 	if (nb_queues > EVT_MAX_QUEUES) {
1147272de067SJerin Jacob 		evt_err("number of queues exceeds %d", EVT_MAX_QUEUES);
1148272de067SJerin Jacob 		return -1;
1149272de067SJerin Jacob 	}
1150272de067SJerin Jacob 	if (perf_nb_event_ports(opt) > EVT_MAX_PORTS) {
1151272de067SJerin Jacob 		evt_err("number of ports exceeds %d", EVT_MAX_PORTS);
1152272de067SJerin Jacob 		return -1;
1153272de067SJerin Jacob 	}
1154272de067SJerin Jacob 
1155272de067SJerin Jacob 	/* Fixups */
1156d008f20bSPavan Nikhilesh 	if ((opt->nb_stages == 1 &&
1157d008f20bSPavan Nikhilesh 			opt->prod_type != EVT_PROD_TYPE_EVENT_TIMER_ADPTR) &&
1158d008f20bSPavan Nikhilesh 			opt->fwd_latency) {
1159272de067SJerin Jacob 		evt_info("fwd_latency is valid when nb_stages > 1, disabling");
1160272de067SJerin Jacob 		opt->fwd_latency = 0;
1161272de067SJerin Jacob 	}
1162d008f20bSPavan Nikhilesh 
1163272de067SJerin Jacob 	if (opt->fwd_latency && !opt->q_priority) {
1164272de067SJerin Jacob 		evt_info("enabled queue priority for latency measurement");
1165272de067SJerin Jacob 		opt->q_priority = 1;
1166272de067SJerin Jacob 	}
11679d3aeb18SJerin Jacob 	if (opt->nb_pkts == 0)
11689d3aeb18SJerin Jacob 		opt->nb_pkts = INT64_MAX/evt_nr_active_lcores(opt->plcores);
1169272de067SJerin Jacob 
1170272de067SJerin Jacob 	return 0;
1171272de067SJerin Jacob }
1172272de067SJerin Jacob 
1173272de067SJerin Jacob void
1174272de067SJerin Jacob perf_opt_dump(struct evt_options *opt, uint8_t nb_queues)
1175272de067SJerin Jacob {
1176272de067SJerin Jacob 	evt_dump("nb_prod_lcores", "%d", evt_nr_active_lcores(opt->plcores));
1177272de067SJerin Jacob 	evt_dump_producer_lcores(opt);
1178272de067SJerin Jacob 	evt_dump("nb_worker_lcores", "%d", evt_nr_active_lcores(opt->wlcores));
1179272de067SJerin Jacob 	evt_dump_worker_lcores(opt);
1180272de067SJerin Jacob 	evt_dump_nb_stages(opt);
1181272de067SJerin Jacob 	evt_dump("nb_evdev_ports", "%d", perf_nb_event_ports(opt));
1182272de067SJerin Jacob 	evt_dump("nb_evdev_queues", "%d", nb_queues);
1183272de067SJerin Jacob 	evt_dump_queue_priority(opt);
1184272de067SJerin Jacob 	evt_dump_sched_type_list(opt);
1185b01974daSPavan Nikhilesh 	evt_dump_producer_type(opt);
118620841a25SRashmi Shetty 	evt_dump("prod_enq_burst_sz", "%d", opt->prod_enq_burst_sz);
1187272de067SJerin Jacob }
1188272de067SJerin Jacob 
11897da008dfSPavan Nikhilesh static void
11907da008dfSPavan Nikhilesh perf_event_port_flush(uint8_t dev_id __rte_unused, struct rte_event ev,
11917da008dfSPavan Nikhilesh 		      void *args)
11927da008dfSPavan Nikhilesh {
11937da008dfSPavan Nikhilesh 	rte_mempool_put(args, ev.event_ptr);
11947da008dfSPavan Nikhilesh }
11957da008dfSPavan Nikhilesh 
119641c219e6SJerin Jacob void
1197f0b68c0bSPavan Nikhilesh perf_worker_cleanup(struct rte_mempool *const pool, uint8_t dev_id,
1198f0b68c0bSPavan Nikhilesh 		    uint8_t port_id, struct rte_event events[], uint16_t nb_enq,
1199f0b68c0bSPavan Nikhilesh 		    uint16_t nb_deq)
1200f0b68c0bSPavan Nikhilesh {
1201f0b68c0bSPavan Nikhilesh 	int i;
1202f0b68c0bSPavan Nikhilesh 
1203f0b68c0bSPavan Nikhilesh 	if (nb_deq) {
1204f0b68c0bSPavan Nikhilesh 		for (i = nb_enq; i < nb_deq; i++)
1205f0b68c0bSPavan Nikhilesh 			rte_mempool_put(pool, events[i].event_ptr);
1206f0b68c0bSPavan Nikhilesh 
1207f0b68c0bSPavan Nikhilesh 		for (i = 0; i < nb_deq; i++)
1208f0b68c0bSPavan Nikhilesh 			events[i].op = RTE_EVENT_OP_RELEASE;
1209f0b68c0bSPavan Nikhilesh 		rte_event_enqueue_burst(dev_id, port_id, events, nb_deq);
1210f0b68c0bSPavan Nikhilesh 	}
12117da008dfSPavan Nikhilesh 	rte_event_port_quiesce(dev_id, port_id, perf_event_port_flush, pool);
1212f0b68c0bSPavan Nikhilesh }
1213f0b68c0bSPavan Nikhilesh 
1214f0b68c0bSPavan Nikhilesh void
121541c219e6SJerin Jacob perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
121641c219e6SJerin Jacob {
1217d008f20bSPavan Nikhilesh 	int i;
1218d008f20bSPavan Nikhilesh 	struct test_perf *t = evt_test_priv(test);
121941c219e6SJerin Jacob 
1220d008f20bSPavan Nikhilesh 	if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
1221d008f20bSPavan Nikhilesh 		for (i = 0; i < opt->nb_timer_adptrs; i++)
1222d008f20bSPavan Nikhilesh 			rte_event_timer_adapter_stop(t->timer_adptr[i]);
1223d008f20bSPavan Nikhilesh 	}
122441c219e6SJerin Jacob 	rte_event_dev_stop(opt->dev_id);
122541c219e6SJerin Jacob 	rte_event_dev_close(opt->dev_id);
122641c219e6SJerin Jacob }
122741c219e6SJerin Jacob 
122841c219e6SJerin Jacob static inline void
122941c219e6SJerin Jacob perf_elt_init(struct rte_mempool *mp, void *arg __rte_unused,
123041c219e6SJerin Jacob 	    void *obj, unsigned i __rte_unused)
123141c219e6SJerin Jacob {
123241c219e6SJerin Jacob 	memset(obj, 0, mp->elt_size);
123341c219e6SJerin Jacob }
123441c219e6SJerin Jacob 
12353fc8de4fSPavan Nikhilesh #define NB_RX_DESC			128
12363fc8de4fSPavan Nikhilesh #define NB_TX_DESC			512
12373fc8de4fSPavan Nikhilesh int
12383fc8de4fSPavan Nikhilesh perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
12393fc8de4fSPavan Nikhilesh {
12408728ccf3SThomas Monjalon 	uint16_t i;
124177339255SIvan Ilchenko 	int ret;
12423fc8de4fSPavan Nikhilesh 	struct test_perf *t = evt_test_priv(test);
12433fc8de4fSPavan Nikhilesh 	struct rte_eth_conf port_conf = {
12443fc8de4fSPavan Nikhilesh 		.rxmode = {
1245295968d1SFerruh Yigit 			.mq_mode = RTE_ETH_MQ_RX_RSS,
12463fc8de4fSPavan Nikhilesh 			.split_hdr_size = 0,
12473fc8de4fSPavan Nikhilesh 		},
12483fc8de4fSPavan Nikhilesh 		.rx_adv_conf = {
12493fc8de4fSPavan Nikhilesh 			.rss_conf = {
12503fc8de4fSPavan Nikhilesh 				.rss_key = NULL,
1251295968d1SFerruh Yigit 				.rss_hf = RTE_ETH_RSS_IP,
12523fc8de4fSPavan Nikhilesh 			},
12533fc8de4fSPavan Nikhilesh 		},
12543fc8de4fSPavan Nikhilesh 	};
12553fc8de4fSPavan Nikhilesh 
1256de2bc16eSShijith Thotton 	if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
12573fc8de4fSPavan Nikhilesh 		return 0;
12583fc8de4fSPavan Nikhilesh 
1259d9a42a69SThomas Monjalon 	if (!rte_eth_dev_count_avail()) {
12603fc8de4fSPavan Nikhilesh 		evt_err("No ethernet ports found.");
12613fc8de4fSPavan Nikhilesh 		return -ENODEV;
12623fc8de4fSPavan Nikhilesh 	}
12633fc8de4fSPavan Nikhilesh 
12648728ccf3SThomas Monjalon 	RTE_ETH_FOREACH_DEV(i) {
12654f5701f2SFerruh Yigit 		struct rte_eth_dev_info dev_info;
12664f5701f2SFerruh Yigit 		struct rte_eth_conf local_port_conf = port_conf;
12673fc8de4fSPavan Nikhilesh 
126877339255SIvan Ilchenko 		ret = rte_eth_dev_info_get(i, &dev_info);
126977339255SIvan Ilchenko 		if (ret != 0) {
127077339255SIvan Ilchenko 			evt_err("Error during getting device (port %u) info: %s\n",
127177339255SIvan Ilchenko 					i, strerror(-ret));
127277339255SIvan Ilchenko 			return ret;
127377339255SIvan Ilchenko 		}
12744f5701f2SFerruh Yigit 
12754f5701f2SFerruh Yigit 		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
12764f5701f2SFerruh Yigit 			dev_info.flow_type_rss_offloads;
12774f5701f2SFerruh Yigit 		if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
12784f5701f2SFerruh Yigit 				port_conf.rx_adv_conf.rss_conf.rss_hf) {
12794f5701f2SFerruh Yigit 			evt_info("Port %u modified RSS hash function based on hardware support,"
12804f5701f2SFerruh Yigit 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
12814f5701f2SFerruh Yigit 				i,
12824f5701f2SFerruh Yigit 				port_conf.rx_adv_conf.rss_conf.rss_hf,
12834f5701f2SFerruh Yigit 				local_port_conf.rx_adv_conf.rss_conf.rss_hf);
12844f5701f2SFerruh Yigit 		}
12854f5701f2SFerruh Yigit 
12864f5701f2SFerruh Yigit 		if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
12873fc8de4fSPavan Nikhilesh 			evt_err("Failed to configure eth port [%d]", i);
12883fc8de4fSPavan Nikhilesh 			return -EINVAL;
12893fc8de4fSPavan Nikhilesh 		}
12903fc8de4fSPavan Nikhilesh 
12913fc8de4fSPavan Nikhilesh 		if (rte_eth_rx_queue_setup(i, 0, NB_RX_DESC,
12923fc8de4fSPavan Nikhilesh 				rte_socket_id(), NULL, t->pool) < 0) {
12933fc8de4fSPavan Nikhilesh 			evt_err("Failed to setup eth port [%d] rx_queue: %d.",
12943fc8de4fSPavan Nikhilesh 					i, 0);
12953fc8de4fSPavan Nikhilesh 			return -EINVAL;
12963fc8de4fSPavan Nikhilesh 		}
12973fc8de4fSPavan Nikhilesh 
12983fc8de4fSPavan Nikhilesh 		if (rte_eth_tx_queue_setup(i, 0, NB_TX_DESC,
12993fc8de4fSPavan Nikhilesh 					rte_socket_id(), NULL) < 0) {
13003fc8de4fSPavan Nikhilesh 			evt_err("Failed to setup eth port [%d] tx_queue: %d.",
13013fc8de4fSPavan Nikhilesh 					i, 0);
13023fc8de4fSPavan Nikhilesh 			return -EINVAL;
13033fc8de4fSPavan Nikhilesh 		}
13043fc8de4fSPavan Nikhilesh 
130570e51a0eSIvan Ilchenko 		ret = rte_eth_promiscuous_enable(i);
130670e51a0eSIvan Ilchenko 		if (ret != 0) {
130770e51a0eSIvan Ilchenko 			evt_err("Failed to enable promiscuous mode for eth port [%d]: %s",
130870e51a0eSIvan Ilchenko 				i, rte_strerror(-ret));
130970e51a0eSIvan Ilchenko 			return ret;
131070e51a0eSIvan Ilchenko 		}
13113fc8de4fSPavan Nikhilesh 	}
13123fc8de4fSPavan Nikhilesh 
13133fc8de4fSPavan Nikhilesh 	return 0;
13143fc8de4fSPavan Nikhilesh }
13153fc8de4fSPavan Nikhilesh 
1316a734e738SPavan Nikhilesh void
1317a734e738SPavan Nikhilesh perf_ethdev_rx_stop(struct evt_test *test, struct evt_options *opt)
13187f3daf34SPavan Nikhilesh {
13198728ccf3SThomas Monjalon 	uint16_t i;
13207f3daf34SPavan Nikhilesh 	RTE_SET_USED(test);
13217f3daf34SPavan Nikhilesh 
13227f3daf34SPavan Nikhilesh 	if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
13238728ccf3SThomas Monjalon 		RTE_ETH_FOREACH_DEV(i) {
13243617aae5SPavan Nikhilesh 			rte_event_eth_rx_adapter_stop(i);
1325a734e738SPavan Nikhilesh 			rte_event_eth_rx_adapter_queue_del(i, i, -1);
1326a734e738SPavan Nikhilesh 			rte_eth_dev_rx_queue_stop(i, 0);
1327a734e738SPavan Nikhilesh 		}
1328a734e738SPavan Nikhilesh 	}
1329a734e738SPavan Nikhilesh }
1330a734e738SPavan Nikhilesh 
1331a734e738SPavan Nikhilesh void
1332a734e738SPavan Nikhilesh perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
1333a734e738SPavan Nikhilesh {
1334a734e738SPavan Nikhilesh 	uint16_t i;
1335a734e738SPavan Nikhilesh 	RTE_SET_USED(test);
1336a734e738SPavan Nikhilesh 
1337a734e738SPavan Nikhilesh 	if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
1338a734e738SPavan Nikhilesh 		RTE_ETH_FOREACH_DEV(i) {
1339a734e738SPavan Nikhilesh 			rte_event_eth_tx_adapter_stop(i);
1340a734e738SPavan Nikhilesh 			rte_event_eth_tx_adapter_queue_del(i, i, -1);
1341a734e738SPavan Nikhilesh 			rte_eth_dev_tx_queue_stop(i, 0);
13427f3daf34SPavan Nikhilesh 			rte_eth_dev_stop(i);
13437f3daf34SPavan Nikhilesh 		}
13447f3daf34SPavan Nikhilesh 	}
13457f3daf34SPavan Nikhilesh }
13467f3daf34SPavan Nikhilesh 
134741c219e6SJerin Jacob int
1348de2bc16eSShijith Thotton perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
1349de2bc16eSShijith Thotton {
1350de2bc16eSShijith Thotton 	uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
1351de2bc16eSShijith Thotton 	struct test_perf *t = evt_test_priv(test);
1352de2bc16eSShijith Thotton 	unsigned int max_session_size;
1353de2bc16eSShijith Thotton 	uint32_t nb_sessions;
1354de2bc16eSShijith Thotton 	int ret;
1355de2bc16eSShijith Thotton 
1356de2bc16eSShijith Thotton 	if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
1357de2bc16eSShijith Thotton 		return 0;
1358de2bc16eSShijith Thotton 
1359de2bc16eSShijith Thotton 	cdev_count = rte_cryptodev_count();
1360de2bc16eSShijith Thotton 	if (cdev_count == 0) {
1361de2bc16eSShijith Thotton 		evt_err("No crypto devices available\n");
1362de2bc16eSShijith Thotton 		return -ENODEV;
1363de2bc16eSShijith Thotton 	}
1364de2bc16eSShijith Thotton 
1365de2bc16eSShijith Thotton 	t->ca_op_pool = rte_crypto_op_pool_create(
13668f5b5495SAkhil Goyal 		"crypto_op_pool", opt->crypto_op_type, opt->pool_sz,
13678f5b5495SAkhil Goyal 		128, sizeof(union rte_event_crypto_metadata),
13688f5b5495SAkhil Goyal 		rte_socket_id());
1369de2bc16eSShijith Thotton 	if (t->ca_op_pool == NULL) {
1370de2bc16eSShijith Thotton 		evt_err("Failed to create crypto op pool");
1371de2bc16eSShijith Thotton 		return -ENOMEM;
1372de2bc16eSShijith Thotton 	}
1373de2bc16eSShijith Thotton 
1374de2bc16eSShijith Thotton 	nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
13758f5b5495SAkhil Goyal 	t->ca_asym_sess_pool = rte_cryptodev_asym_session_pool_create(
13768f5b5495SAkhil Goyal 		"ca_asym_sess_pool", nb_sessions, 0,
13778f5b5495SAkhil Goyal 		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
13788f5b5495SAkhil Goyal 	if (t->ca_asym_sess_pool == NULL) {
13798f5b5495SAkhil Goyal 		evt_err("Failed to create sym session pool");
13808f5b5495SAkhil Goyal 		ret = -ENOMEM;
13818f5b5495SAkhil Goyal 		goto err;
13828f5b5495SAkhil Goyal 	}
13838f5b5495SAkhil Goyal 
1384de2bc16eSShijith Thotton 	t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
1385de2bc16eSShijith Thotton 		"ca_sess_pool", nb_sessions, 0, 0,
1386de2bc16eSShijith Thotton 		sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
1387de2bc16eSShijith Thotton 	if (t->ca_sess_pool == NULL) {
1388de2bc16eSShijith Thotton 		evt_err("Failed to create sym session pool");
1389de2bc16eSShijith Thotton 		ret = -ENOMEM;
1390de2bc16eSShijith Thotton 		goto err;
1391de2bc16eSShijith Thotton 	}
1392de2bc16eSShijith Thotton 
1393de2bc16eSShijith Thotton 	max_session_size = 0;
1394de2bc16eSShijith Thotton 	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
1395de2bc16eSShijith Thotton 		unsigned int session_size;
1396de2bc16eSShijith Thotton 
1397de2bc16eSShijith Thotton 		session_size =
1398de2bc16eSShijith Thotton 			rte_cryptodev_sym_get_private_session_size(cdev_id);
1399de2bc16eSShijith Thotton 		if (session_size > max_session_size)
1400de2bc16eSShijith Thotton 			max_session_size = session_size;
1401de2bc16eSShijith Thotton 	}
1402de2bc16eSShijith Thotton 
1403de2bc16eSShijith Thotton 	max_session_size += sizeof(union rte_event_crypto_metadata);
1404de2bc16eSShijith Thotton 	t->ca_sess_priv_pool = rte_mempool_create(
1405de2bc16eSShijith Thotton 		"ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
1406de2bc16eSShijith Thotton 		NULL, NULL, NULL, SOCKET_ID_ANY, 0);
1407de2bc16eSShijith Thotton 	if (t->ca_sess_priv_pool == NULL) {
1408de2bc16eSShijith Thotton 		evt_err("failed to create sym session private pool");
1409de2bc16eSShijith Thotton 		ret = -ENOMEM;
1410de2bc16eSShijith Thotton 		goto err;
1411de2bc16eSShijith Thotton 	}
1412de2bc16eSShijith Thotton 
1413de2bc16eSShijith Thotton 	/*
1414de2bc16eSShijith Thotton 	 * Calculate number of needed queue pairs, based on the amount of
1415de2bc16eSShijith Thotton 	 * available number of logical cores and crypto devices. For instance,
1416de2bc16eSShijith Thotton 	 * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
1417de2bc16eSShijith Thotton 	 * up per device.
1418de2bc16eSShijith Thotton 	 */
1419de2bc16eSShijith Thotton 	nb_plcores = evt_nr_active_lcores(opt->plcores);
1420de2bc16eSShijith Thotton 	nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
1421de2bc16eSShijith Thotton 					     nb_plcores / cdev_count;
1422de2bc16eSShijith Thotton 	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
1423de2bc16eSShijith Thotton 		struct rte_cryptodev_qp_conf qp_conf;
1424de2bc16eSShijith Thotton 		struct rte_cryptodev_config conf;
1425de2bc16eSShijith Thotton 		struct rte_cryptodev_info info;
1426de2bc16eSShijith Thotton 		int qp_id;
1427de2bc16eSShijith Thotton 
1428de2bc16eSShijith Thotton 		rte_cryptodev_info_get(cdev_id, &info);
1429de2bc16eSShijith Thotton 		if (nb_qps > info.max_nb_queue_pairs) {
1430de2bc16eSShijith Thotton 			evt_err("Not enough queue pairs per cryptodev (%u)",
1431de2bc16eSShijith Thotton 				nb_qps);
1432de2bc16eSShijith Thotton 			ret = -EINVAL;
1433de2bc16eSShijith Thotton 			goto err;
1434de2bc16eSShijith Thotton 		}
1435de2bc16eSShijith Thotton 
1436de2bc16eSShijith Thotton 		conf.nb_queue_pairs = nb_qps;
1437de2bc16eSShijith Thotton 		conf.socket_id = SOCKET_ID_ANY;
1438de2bc16eSShijith Thotton 		conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
1439de2bc16eSShijith Thotton 
1440de2bc16eSShijith Thotton 		ret = rte_cryptodev_configure(cdev_id, &conf);
1441de2bc16eSShijith Thotton 		if (ret) {
1442de2bc16eSShijith Thotton 			evt_err("Failed to configure cryptodev (%u)", cdev_id);
1443de2bc16eSShijith Thotton 			goto err;
1444de2bc16eSShijith Thotton 		}
1445de2bc16eSShijith Thotton 
1446de2bc16eSShijith Thotton 		qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
1447de2bc16eSShijith Thotton 		qp_conf.mp_session = t->ca_sess_pool;
1448de2bc16eSShijith Thotton 		qp_conf.mp_session_private = t->ca_sess_priv_pool;
1449de2bc16eSShijith Thotton 
1450de2bc16eSShijith Thotton 		for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
1451de2bc16eSShijith Thotton 			ret = rte_cryptodev_queue_pair_setup(
1452de2bc16eSShijith Thotton 				cdev_id, qp_id, &qp_conf,
1453de2bc16eSShijith Thotton 				rte_cryptodev_socket_id(cdev_id));
1454de2bc16eSShijith Thotton 			if (ret) {
1455de2bc16eSShijith Thotton 				evt_err("Failed to setup queue pairs on cryptodev %u\n",
1456de2bc16eSShijith Thotton 					cdev_id);
1457de2bc16eSShijith Thotton 				goto err;
1458de2bc16eSShijith Thotton 			}
1459de2bc16eSShijith Thotton 		}
1460de2bc16eSShijith Thotton 	}
1461de2bc16eSShijith Thotton 
1462de2bc16eSShijith Thotton 	return 0;
1463de2bc16eSShijith Thotton err:
1464de2bc16eSShijith Thotton 	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
1465de2bc16eSShijith Thotton 		rte_cryptodev_close(cdev_id);
1466de2bc16eSShijith Thotton 
1467de2bc16eSShijith Thotton 	rte_mempool_free(t->ca_op_pool);
1468de2bc16eSShijith Thotton 	rte_mempool_free(t->ca_sess_pool);
1469de2bc16eSShijith Thotton 	rte_mempool_free(t->ca_sess_priv_pool);
14708f5b5495SAkhil Goyal 	rte_mempool_free(t->ca_asym_sess_pool);
1471de2bc16eSShijith Thotton 
1472de2bc16eSShijith Thotton 	return ret;
1473de2bc16eSShijith Thotton }
1474de2bc16eSShijith Thotton 
1475de2bc16eSShijith Thotton void
1476de2bc16eSShijith Thotton perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
1477de2bc16eSShijith Thotton {
1478de2bc16eSShijith Thotton 	uint8_t cdev_id, cdev_count = rte_cryptodev_count();
1479de2bc16eSShijith Thotton 	struct test_perf *t = evt_test_priv(test);
1480de2bc16eSShijith Thotton 	uint16_t port;
1481de2bc16eSShijith Thotton 
1482de2bc16eSShijith Thotton 	if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
1483de2bc16eSShijith Thotton 		return;
1484de2bc16eSShijith Thotton 
1485de2bc16eSShijith Thotton 	for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
1486de2bc16eSShijith Thotton 		struct rte_cryptodev_sym_session *sess;
1487de2bc16eSShijith Thotton 		struct prod_data *p = &t->prod[port];
1488de2bc16eSShijith Thotton 		uint32_t flow_id;
1489de2bc16eSShijith Thotton 		uint8_t cdev_id;
1490de2bc16eSShijith Thotton 
1491de2bc16eSShijith Thotton 		for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
1492de2bc16eSShijith Thotton 			sess = p->ca.crypto_sess[flow_id];
1493de2bc16eSShijith Thotton 			cdev_id = p->ca.cdev_id;
1494de2bc16eSShijith Thotton 			rte_cryptodev_sym_session_clear(cdev_id, sess);
1495de2bc16eSShijith Thotton 			rte_cryptodev_sym_session_free(sess);
1496de2bc16eSShijith Thotton 		}
1497de2bc16eSShijith Thotton 
1498de2bc16eSShijith Thotton 		rte_event_crypto_adapter_queue_pair_del(
1499de2bc16eSShijith Thotton 			TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
1500de2bc16eSShijith Thotton 	}
1501de2bc16eSShijith Thotton 
1502de2bc16eSShijith Thotton 	rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
1503de2bc16eSShijith Thotton 
1504de2bc16eSShijith Thotton 	for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
1505de2bc16eSShijith Thotton 		rte_cryptodev_stop(cdev_id);
1506de2bc16eSShijith Thotton 		rte_cryptodev_close(cdev_id);
1507de2bc16eSShijith Thotton 	}
1508de2bc16eSShijith Thotton 
1509de2bc16eSShijith Thotton 	rte_mempool_free(t->ca_op_pool);
1510de2bc16eSShijith Thotton 	rte_mempool_free(t->ca_sess_pool);
1511de2bc16eSShijith Thotton 	rte_mempool_free(t->ca_sess_priv_pool);
15128f5b5495SAkhil Goyal 	rte_mempool_free(t->ca_asym_sess_pool);
1513de2bc16eSShijith Thotton }
1514de2bc16eSShijith Thotton 
1515de2bc16eSShijith Thotton int
151641c219e6SJerin Jacob perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
151741c219e6SJerin Jacob {
151841c219e6SJerin Jacob 	struct test_perf *t = evt_test_priv(test);
151941c219e6SJerin Jacob 
1520d008f20bSPavan Nikhilesh 	if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
1521d008f20bSPavan Nikhilesh 			opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
152241c219e6SJerin Jacob 		t->pool = rte_mempool_create(test->name, /* mempool name */
152341c219e6SJerin Jacob 				opt->pool_sz, /* number of elements*/
152441c219e6SJerin Jacob 				sizeof(struct perf_elt), /* element size*/
152541c219e6SJerin Jacob 				512, /* cache size*/
152641c219e6SJerin Jacob 				0, NULL, NULL,
152741c219e6SJerin Jacob 				perf_elt_init, /* obj constructor */
152841c219e6SJerin Jacob 				NULL, opt->socket_id, 0); /* flags */
15298577cc1aSPavan Nikhilesh 	} else {
15308577cc1aSPavan Nikhilesh 		t->pool = rte_pktmbuf_pool_create(test->name, /* mempool name */
15318577cc1aSPavan Nikhilesh 				opt->pool_sz, /* number of elements*/
15328577cc1aSPavan Nikhilesh 				512, /* cache size*/
15338577cc1aSPavan Nikhilesh 				0,
15348577cc1aSPavan Nikhilesh 				RTE_MBUF_DEFAULT_BUF_SIZE,
15358577cc1aSPavan Nikhilesh 				opt->socket_id); /* flags */
15368577cc1aSPavan Nikhilesh 
15378577cc1aSPavan Nikhilesh 	}
15388577cc1aSPavan Nikhilesh 
153941c219e6SJerin Jacob 	if (t->pool == NULL) {
154041c219e6SJerin Jacob 		evt_err("failed to create mempool");
154141c219e6SJerin Jacob 		return -ENOMEM;
154241c219e6SJerin Jacob 	}
154341c219e6SJerin Jacob 
154441c219e6SJerin Jacob 	return 0;
154541c219e6SJerin Jacob }
154641c219e6SJerin Jacob 
154741c219e6SJerin Jacob void
154841c219e6SJerin Jacob perf_mempool_destroy(struct evt_test *test, struct evt_options *opt)
154941c219e6SJerin Jacob {
155041c219e6SJerin Jacob 	RTE_SET_USED(opt);
155141c219e6SJerin Jacob 	struct test_perf *t = evt_test_priv(test);
155241c219e6SJerin Jacob 
155341c219e6SJerin Jacob 	rte_mempool_free(t->pool);
155441c219e6SJerin Jacob }
1555ffbae86fSJerin Jacob 
1556ffbae86fSJerin Jacob int
1557ffbae86fSJerin Jacob perf_test_setup(struct evt_test *test, struct evt_options *opt)
1558ffbae86fSJerin Jacob {
1559ffbae86fSJerin Jacob 	void *test_perf;
1560ffbae86fSJerin Jacob 
1561ffbae86fSJerin Jacob 	test_perf = rte_zmalloc_socket(test->name, sizeof(struct test_perf),
1562ffbae86fSJerin Jacob 				RTE_CACHE_LINE_SIZE, opt->socket_id);
1563ffbae86fSJerin Jacob 	if (test_perf  == NULL) {
1564ffbae86fSJerin Jacob 		evt_err("failed to allocate test_perf memory");
1565ffbae86fSJerin Jacob 		goto nomem;
1566ffbae86fSJerin Jacob 	}
1567ffbae86fSJerin Jacob 	test->test_priv = test_perf;
1568ffbae86fSJerin Jacob 
1569ffbae86fSJerin Jacob 	struct test_perf *t = evt_test_priv(test);
1570ffbae86fSJerin Jacob 
1571d008f20bSPavan Nikhilesh 	if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
1572d008f20bSPavan Nikhilesh 		t->outstand_pkts = opt->nb_timers *
1573d008f20bSPavan Nikhilesh 			evt_nr_active_lcores(opt->plcores);
1574d008f20bSPavan Nikhilesh 		t->nb_pkts = opt->nb_timers;
1575d008f20bSPavan Nikhilesh 	} else {
1576d008f20bSPavan Nikhilesh 		t->outstand_pkts = opt->nb_pkts *
1577d008f20bSPavan Nikhilesh 			evt_nr_active_lcores(opt->plcores);
1578d008f20bSPavan Nikhilesh 		t->nb_pkts = opt->nb_pkts;
1579d008f20bSPavan Nikhilesh 	}
1580d008f20bSPavan Nikhilesh 
1581ffbae86fSJerin Jacob 	t->nb_workers = evt_nr_active_lcores(opt->wlcores);
1582ffbae86fSJerin Jacob 	t->done = false;
1583ffbae86fSJerin Jacob 	t->nb_flows = opt->nb_flows;
1584ffbae86fSJerin Jacob 	t->result = EVT_TEST_FAILED;
1585ffbae86fSJerin Jacob 	t->opt = opt;
1586ffbae86fSJerin Jacob 	memcpy(t->sched_type_list, opt->sched_type_list,
1587ffbae86fSJerin Jacob 			sizeof(opt->sched_type_list));
1588ffbae86fSJerin Jacob 	return 0;
1589ffbae86fSJerin Jacob nomem:
1590ffbae86fSJerin Jacob 	return -ENOMEM;
1591ffbae86fSJerin Jacob }
1592ffbae86fSJerin Jacob 
1593ffbae86fSJerin Jacob void
1594ffbae86fSJerin Jacob perf_test_destroy(struct evt_test *test, struct evt_options *opt)
1595ffbae86fSJerin Jacob {
1596ffbae86fSJerin Jacob 	RTE_SET_USED(opt);
1597ffbae86fSJerin Jacob 
1598ffbae86fSJerin Jacob 	rte_free(test->test_priv);
1599ffbae86fSJerin Jacob }
1600