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
9de2bc16eSShijith Thotton #define NB_CRYPTODEV_DESCRIPTORS 128
10de2bc16eSShijith Thotton
1141c219e6SJerin Jacob int
perf_test_result(struct evt_test * test,struct evt_options * opt)1241c219e6SJerin Jacob perf_test_result(struct evt_test *test, struct evt_options *opt)
1341c219e6SJerin Jacob {
1441c219e6SJerin Jacob RTE_SET_USED(opt);
156b1a14a8SPavan Nikhilesh int i;
166b1a14a8SPavan Nikhilesh uint64_t total = 0;
1741c219e6SJerin Jacob struct test_perf *t = evt_test_priv(test);
1841c219e6SJerin Jacob
196b1a14a8SPavan Nikhilesh printf("Packet distribution across worker cores :\n");
206b1a14a8SPavan Nikhilesh for (i = 0; i < t->nb_workers; i++)
216b1a14a8SPavan Nikhilesh total += t->worker[i].processed_pkts;
226b1a14a8SPavan Nikhilesh for (i = 0; i < t->nb_workers; i++)
236b1a14a8SPavan Nikhilesh printf("Worker %d packets: "CLGRN"%"PRIx64" "CLNRM"percentage:"
24c0900d33SHarry van Haaren CLGRN" %3.2f"CLNRM"\n", i,
256b1a14a8SPavan Nikhilesh t->worker[i].processed_pkts,
266b1a14a8SPavan Nikhilesh (((double)t->worker[i].processed_pkts)/total)
276b1a14a8SPavan Nikhilesh * 100);
286b1a14a8SPavan Nikhilesh
2941c219e6SJerin Jacob return t->result;
3041c219e6SJerin Jacob }
3141c219e6SJerin Jacob
329d3aeb18SJerin Jacob static inline int
perf_producer(void * arg)339d3aeb18SJerin Jacob perf_producer(void *arg)
349d3aeb18SJerin Jacob {
359a618803SPavan Nikhilesh int i;
369d3aeb18SJerin Jacob struct prod_data *p = arg;
379d3aeb18SJerin Jacob struct test_perf *t = p->t;
389d3aeb18SJerin Jacob struct evt_options *opt = t->opt;
399d3aeb18SJerin Jacob const uint8_t dev_id = p->dev_id;
409d3aeb18SJerin Jacob const uint8_t port = p->port_id;
419d3aeb18SJerin Jacob struct rte_mempool *pool = t->pool;
429d3aeb18SJerin Jacob const uint64_t nb_pkts = t->nb_pkts;
439d3aeb18SJerin Jacob const uint32_t nb_flows = t->nb_flows;
449d3aeb18SJerin Jacob uint32_t flow_counter = 0;
459d3aeb18SJerin Jacob uint64_t count = 0;
469a618803SPavan Nikhilesh struct perf_elt *m[BURST_SIZE + 1] = {NULL};
479d3aeb18SJerin Jacob struct rte_event ev;
489d3aeb18SJerin Jacob
499d3aeb18SJerin Jacob if (opt->verbose_level > 1)
509d3aeb18SJerin Jacob printf("%s(): lcore %d dev_id %d port=%d queue %d\n", __func__,
519d3aeb18SJerin Jacob rte_lcore_id(), dev_id, port, p->queue_id);
529d3aeb18SJerin Jacob
539d3aeb18SJerin Jacob ev.event = 0;
549d3aeb18SJerin Jacob ev.op = RTE_EVENT_OP_NEW;
559d3aeb18SJerin Jacob ev.queue_id = p->queue_id;
569d3aeb18SJerin Jacob ev.sched_type = t->opt->sched_type_list[0];
579d3aeb18SJerin Jacob ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
589d3aeb18SJerin Jacob ev.event_type = RTE_EVENT_TYPE_CPU;
599d3aeb18SJerin Jacob ev.sub_event_type = 0; /* stage 0 */
609d3aeb18SJerin Jacob
619d3aeb18SJerin Jacob while (count < nb_pkts && t->done == false) {
629a618803SPavan Nikhilesh if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0)
639d3aeb18SJerin Jacob continue;
649a618803SPavan Nikhilesh for (i = 0; i < BURST_SIZE; i++) {
659d3aeb18SJerin Jacob ev.flow_id = flow_counter++ % nb_flows;
669a618803SPavan Nikhilesh ev.event_ptr = m[i];
679a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles();
689a618803SPavan Nikhilesh while (rte_event_enqueue_burst(dev_id,
699a618803SPavan Nikhilesh port, &ev, 1) != 1) {
709d3aeb18SJerin Jacob if (t->done)
719d3aeb18SJerin Jacob break;
729d3aeb18SJerin Jacob rte_pause();
739a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles();
749d3aeb18SJerin Jacob }
759a618803SPavan Nikhilesh }
769a618803SPavan Nikhilesh count += BURST_SIZE;
779d3aeb18SJerin Jacob }
789d3aeb18SJerin Jacob
799d3aeb18SJerin Jacob return 0;
809d3aeb18SJerin Jacob }
819d3aeb18SJerin Jacob
82d008f20bSPavan Nikhilesh static inline int
perf_producer_burst(void * arg)8320841a25SRashmi Shetty perf_producer_burst(void *arg)
8420841a25SRashmi Shetty {
8520841a25SRashmi Shetty uint32_t i;
8620841a25SRashmi Shetty uint64_t timestamp;
8720841a25SRashmi Shetty struct rte_event_dev_info dev_info;
8820841a25SRashmi Shetty struct prod_data *p = arg;
8920841a25SRashmi Shetty struct test_perf *t = p->t;
9020841a25SRashmi Shetty struct evt_options *opt = t->opt;
9120841a25SRashmi Shetty const uint8_t dev_id = p->dev_id;
9220841a25SRashmi Shetty const uint8_t port = p->port_id;
9320841a25SRashmi Shetty struct rte_mempool *pool = t->pool;
9420841a25SRashmi Shetty const uint64_t nb_pkts = t->nb_pkts;
9520841a25SRashmi Shetty const uint32_t nb_flows = t->nb_flows;
9620841a25SRashmi Shetty uint32_t flow_counter = 0;
9720841a25SRashmi Shetty uint16_t enq = 0;
9820841a25SRashmi Shetty uint64_t count = 0;
9920841a25SRashmi Shetty struct perf_elt *m[MAX_PROD_ENQ_BURST_SIZE + 1];
10020841a25SRashmi Shetty struct rte_event ev[MAX_PROD_ENQ_BURST_SIZE + 1];
10120841a25SRashmi Shetty uint32_t burst_size = opt->prod_enq_burst_sz;
10220841a25SRashmi Shetty
10320841a25SRashmi Shetty memset(m, 0, sizeof(*m) * (MAX_PROD_ENQ_BURST_SIZE + 1));
10420841a25SRashmi Shetty rte_event_dev_info_get(dev_id, &dev_info);
10520841a25SRashmi Shetty if (dev_info.max_event_port_enqueue_depth < burst_size)
10620841a25SRashmi Shetty burst_size = dev_info.max_event_port_enqueue_depth;
10720841a25SRashmi Shetty
10820841a25SRashmi Shetty if (opt->verbose_level > 1)
10920841a25SRashmi Shetty printf("%s(): lcore %d dev_id %d port=%d queue %d\n", __func__,
11020841a25SRashmi Shetty rte_lcore_id(), dev_id, port, p->queue_id);
11120841a25SRashmi Shetty
11220841a25SRashmi Shetty for (i = 0; i < burst_size; i++) {
11320841a25SRashmi Shetty ev[i].op = RTE_EVENT_OP_NEW;
11420841a25SRashmi Shetty ev[i].queue_id = p->queue_id;
11520841a25SRashmi Shetty ev[i].sched_type = t->opt->sched_type_list[0];
11620841a25SRashmi Shetty ev[i].priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
11720841a25SRashmi Shetty ev[i].event_type = RTE_EVENT_TYPE_CPU;
11820841a25SRashmi Shetty ev[i].sub_event_type = 0; /* stage 0 */
11920841a25SRashmi Shetty }
12020841a25SRashmi Shetty
12120841a25SRashmi Shetty while (count < nb_pkts && t->done == false) {
12220841a25SRashmi Shetty if (rte_mempool_get_bulk(pool, (void **)m, burst_size) < 0)
12320841a25SRashmi Shetty continue;
12420841a25SRashmi Shetty timestamp = rte_get_timer_cycles();
12520841a25SRashmi Shetty for (i = 0; i < burst_size; i++) {
12620841a25SRashmi Shetty ev[i].flow_id = flow_counter++ % nb_flows;
12720841a25SRashmi Shetty ev[i].event_ptr = m[i];
12820841a25SRashmi Shetty m[i]->timestamp = timestamp;
12920841a25SRashmi Shetty }
13020841a25SRashmi Shetty enq = rte_event_enqueue_burst(dev_id, port, ev, burst_size);
13120841a25SRashmi Shetty while (enq < burst_size) {
13220841a25SRashmi Shetty enq += rte_event_enqueue_burst(dev_id, port,
13320841a25SRashmi Shetty ev + enq,
13420841a25SRashmi Shetty burst_size - enq);
13520841a25SRashmi Shetty if (t->done)
13620841a25SRashmi Shetty break;
13720841a25SRashmi Shetty rte_pause();
13820841a25SRashmi Shetty timestamp = rte_get_timer_cycles();
13920841a25SRashmi Shetty for (i = enq; i < burst_size; i++)
14020841a25SRashmi Shetty m[i]->timestamp = timestamp;
14120841a25SRashmi Shetty }
14220841a25SRashmi Shetty count += burst_size;
14320841a25SRashmi Shetty }
14420841a25SRashmi Shetty return 0;
14520841a25SRashmi Shetty }
14620841a25SRashmi Shetty
14720841a25SRashmi Shetty static inline int
perf_event_timer_producer(void * arg)148d008f20bSPavan Nikhilesh perf_event_timer_producer(void *arg)
149d008f20bSPavan Nikhilesh {
1509a618803SPavan Nikhilesh int i;
151d008f20bSPavan Nikhilesh struct prod_data *p = arg;
152d008f20bSPavan Nikhilesh struct test_perf *t = p->t;
153d008f20bSPavan Nikhilesh struct evt_options *opt = t->opt;
154d008f20bSPavan Nikhilesh uint32_t flow_counter = 0;
155d008f20bSPavan Nikhilesh uint64_t count = 0;
156d008f20bSPavan Nikhilesh uint64_t arm_latency = 0;
157d008f20bSPavan Nikhilesh const uint8_t nb_timer_adptrs = opt->nb_timer_adptrs;
158d008f20bSPavan Nikhilesh const uint32_t nb_flows = t->nb_flows;
159d008f20bSPavan Nikhilesh const uint64_t nb_timers = opt->nb_timers;
160d008f20bSPavan Nikhilesh struct rte_mempool *pool = t->pool;
1619a618803SPavan Nikhilesh struct perf_elt *m[BURST_SIZE + 1] = {NULL};
162d008f20bSPavan Nikhilesh struct rte_event_timer_adapter **adptr = t->timer_adptr;
16352553263SPavan Nikhilesh struct rte_event_timer tim;
164d008f20bSPavan Nikhilesh uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec;
165d008f20bSPavan Nikhilesh
16652553263SPavan Nikhilesh memset(&tim, 0, sizeof(struct rte_event_timer));
167626b12a8SPavan Nikhilesh timeout_ticks =
168626b12a8SPavan Nikhilesh opt->optm_timer_tick_nsec
169626b12a8SPavan Nikhilesh ? ceil((double)(timeout_ticks * opt->timer_tick_nsec) /
170626b12a8SPavan Nikhilesh opt->optm_timer_tick_nsec)
171626b12a8SPavan Nikhilesh : timeout_ticks;
172d008f20bSPavan Nikhilesh timeout_ticks += timeout_ticks ? 0 : 1;
17352553263SPavan Nikhilesh tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
17452553263SPavan Nikhilesh tim.ev.op = RTE_EVENT_OP_NEW;
17552553263SPavan Nikhilesh tim.ev.sched_type = t->opt->sched_type_list[0];
17652553263SPavan Nikhilesh tim.ev.queue_id = p->queue_id;
17752553263SPavan Nikhilesh tim.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
17852553263SPavan Nikhilesh tim.state = RTE_EVENT_TIMER_NOT_ARMED;
17952553263SPavan Nikhilesh tim.timeout_ticks = timeout_ticks;
180d008f20bSPavan Nikhilesh
181d008f20bSPavan Nikhilesh if (opt->verbose_level > 1)
182d008f20bSPavan Nikhilesh printf("%s(): lcore %d\n", __func__, rte_lcore_id());
183d008f20bSPavan Nikhilesh
184d008f20bSPavan Nikhilesh while (count < nb_timers && t->done == false) {
1859a618803SPavan Nikhilesh if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0)
186d008f20bSPavan Nikhilesh continue;
1879a618803SPavan Nikhilesh for (i = 0; i < BURST_SIZE; i++) {
1889a618803SPavan Nikhilesh rte_prefetch0(m[i + 1]);
1899a618803SPavan Nikhilesh m[i]->tim = tim;
1909a618803SPavan Nikhilesh m[i]->tim.ev.flow_id = flow_counter++ % nb_flows;
1919a618803SPavan Nikhilesh m[i]->tim.ev.event_ptr = m[i];
1929a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles();
193d008f20bSPavan Nikhilesh while (rte_event_timer_arm_burst(
194d008f20bSPavan Nikhilesh adptr[flow_counter % nb_timer_adptrs],
1959a618803SPavan Nikhilesh (struct rte_event_timer **)&m[i], 1) != 1) {
196d008f20bSPavan Nikhilesh if (t->done)
197d008f20bSPavan Nikhilesh break;
1989a618803SPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles();
199d008f20bSPavan Nikhilesh }
2009a618803SPavan Nikhilesh arm_latency += rte_get_timer_cycles() - m[i]->timestamp;
2019a618803SPavan Nikhilesh }
2029a618803SPavan Nikhilesh count += BURST_SIZE;
203d008f20bSPavan Nikhilesh }
204d008f20bSPavan Nikhilesh fflush(stdout);
205d008f20bSPavan Nikhilesh rte_delay_ms(1000);
206d008f20bSPavan Nikhilesh printf("%s(): lcore %d Average event timer arm latency = %.3f us\n",
20793b7794bSPavan Nikhilesh __func__, rte_lcore_id(),
20893b7794bSPavan Nikhilesh count ? (float)(arm_latency / count) /
20993b7794bSPavan Nikhilesh (rte_get_timer_hz() / 1000000) : 0);
210d008f20bSPavan Nikhilesh return 0;
211d008f20bSPavan Nikhilesh }
212d008f20bSPavan Nikhilesh
21317b22d0bSPavan Nikhilesh static inline int
perf_event_timer_producer_burst(void * arg)21417b22d0bSPavan Nikhilesh perf_event_timer_producer_burst(void *arg)
21517b22d0bSPavan Nikhilesh {
21617b22d0bSPavan Nikhilesh int i;
21717b22d0bSPavan Nikhilesh struct prod_data *p = arg;
21817b22d0bSPavan Nikhilesh struct test_perf *t = p->t;
21917b22d0bSPavan Nikhilesh struct evt_options *opt = t->opt;
22017b22d0bSPavan Nikhilesh uint32_t flow_counter = 0;
22117b22d0bSPavan Nikhilesh uint64_t count = 0;
22217b22d0bSPavan Nikhilesh uint64_t arm_latency = 0;
22317b22d0bSPavan Nikhilesh const uint8_t nb_timer_adptrs = opt->nb_timer_adptrs;
22417b22d0bSPavan Nikhilesh const uint32_t nb_flows = t->nb_flows;
22517b22d0bSPavan Nikhilesh const uint64_t nb_timers = opt->nb_timers;
22617b22d0bSPavan Nikhilesh struct rte_mempool *pool = t->pool;
22717b22d0bSPavan Nikhilesh struct perf_elt *m[BURST_SIZE + 1] = {NULL};
22817b22d0bSPavan Nikhilesh struct rte_event_timer_adapter **adptr = t->timer_adptr;
22952553263SPavan Nikhilesh struct rte_event_timer tim;
23017b22d0bSPavan Nikhilesh uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec;
23117b22d0bSPavan Nikhilesh
23252553263SPavan Nikhilesh memset(&tim, 0, sizeof(struct rte_event_timer));
233626b12a8SPavan Nikhilesh timeout_ticks =
234626b12a8SPavan Nikhilesh opt->optm_timer_tick_nsec
235626b12a8SPavan Nikhilesh ? ceil((double)(timeout_ticks * opt->timer_tick_nsec) /
236626b12a8SPavan Nikhilesh opt->optm_timer_tick_nsec)
237626b12a8SPavan Nikhilesh : timeout_ticks;
23817b22d0bSPavan Nikhilesh timeout_ticks += timeout_ticks ? 0 : 1;
23952553263SPavan Nikhilesh tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
24052553263SPavan Nikhilesh tim.ev.op = RTE_EVENT_OP_NEW;
24152553263SPavan Nikhilesh tim.ev.sched_type = t->opt->sched_type_list[0];
24252553263SPavan Nikhilesh tim.ev.queue_id = p->queue_id;
24352553263SPavan Nikhilesh tim.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
24452553263SPavan Nikhilesh tim.state = RTE_EVENT_TIMER_NOT_ARMED;
24552553263SPavan Nikhilesh tim.timeout_ticks = timeout_ticks;
24617b22d0bSPavan Nikhilesh
24717b22d0bSPavan Nikhilesh if (opt->verbose_level > 1)
24817b22d0bSPavan Nikhilesh printf("%s(): lcore %d\n", __func__, rte_lcore_id());
24917b22d0bSPavan Nikhilesh
25017b22d0bSPavan Nikhilesh while (count < nb_timers && t->done == false) {
25117b22d0bSPavan Nikhilesh if (rte_mempool_get_bulk(pool, (void **)m, BURST_SIZE) < 0)
25217b22d0bSPavan Nikhilesh continue;
25317b22d0bSPavan Nikhilesh for (i = 0; i < BURST_SIZE; i++) {
25417b22d0bSPavan Nikhilesh rte_prefetch0(m[i + 1]);
25517b22d0bSPavan Nikhilesh m[i]->tim = tim;
25617b22d0bSPavan Nikhilesh m[i]->tim.ev.flow_id = flow_counter++ % nb_flows;
25717b22d0bSPavan Nikhilesh m[i]->tim.ev.event_ptr = m[i];
25817b22d0bSPavan Nikhilesh m[i]->timestamp = rte_get_timer_cycles();
25917b22d0bSPavan Nikhilesh }
26017b22d0bSPavan Nikhilesh rte_event_timer_arm_tmo_tick_burst(
26117b22d0bSPavan Nikhilesh adptr[flow_counter % nb_timer_adptrs],
26217b22d0bSPavan Nikhilesh (struct rte_event_timer **)m,
26317b22d0bSPavan Nikhilesh tim.timeout_ticks,
26417b22d0bSPavan Nikhilesh BURST_SIZE);
26517b22d0bSPavan Nikhilesh arm_latency += rte_get_timer_cycles() - m[i - 1]->timestamp;
26617b22d0bSPavan Nikhilesh count += BURST_SIZE;
26717b22d0bSPavan Nikhilesh }
26817b22d0bSPavan Nikhilesh fflush(stdout);
26917b22d0bSPavan Nikhilesh rte_delay_ms(1000);
27017b22d0bSPavan Nikhilesh printf("%s(): lcore %d Average event timer arm latency = %.3f us\n",
27193b7794bSPavan Nikhilesh __func__, rte_lcore_id(),
27293b7794bSPavan Nikhilesh count ? (float)(arm_latency / count) /
27393b7794bSPavan Nikhilesh (rte_get_timer_hz() / 1000000) : 0);
27417b22d0bSPavan Nikhilesh return 0;
27517b22d0bSPavan Nikhilesh }
27617b22d0bSPavan Nikhilesh
277de2bc16eSShijith Thotton static inline void
crypto_adapter_enq_op_new(struct prod_data * p)278de2bc16eSShijith Thotton crypto_adapter_enq_op_new(struct prod_data *p)
279de2bc16eSShijith Thotton {
280de2bc16eSShijith Thotton struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
281de2bc16eSShijith Thotton struct test_perf *t = p->t;
282de2bc16eSShijith Thotton const uint32_t nb_flows = t->nb_flows;
283de2bc16eSShijith Thotton const uint64_t nb_pkts = t->nb_pkts;
284de2bc16eSShijith Thotton struct rte_mempool *pool = t->pool;
285de2bc16eSShijith Thotton struct rte_crypto_sym_op *sym_op;
286de2bc16eSShijith Thotton struct evt_options *opt = t->opt;
287de2bc16eSShijith Thotton uint16_t qp_id = p->ca.cdev_qp_id;
288de2bc16eSShijith Thotton uint8_t cdev_id = p->ca.cdev_id;
289de2bc16eSShijith Thotton uint32_t flow_counter = 0;
290de2bc16eSShijith Thotton struct rte_crypto_op *op;
291de2bc16eSShijith Thotton struct rte_mbuf *m;
292de2bc16eSShijith Thotton uint64_t count = 0;
293de2bc16eSShijith Thotton uint16_t len;
294de2bc16eSShijith Thotton
295de2bc16eSShijith Thotton if (opt->verbose_level > 1)
296de2bc16eSShijith Thotton printf("%s(): lcore %d queue %d cdev_id %u cdev_qp_id %u\n",
297de2bc16eSShijith Thotton __func__, rte_lcore_id(), p->queue_id, p->ca.cdev_id,
298de2bc16eSShijith Thotton p->ca.cdev_qp_id);
299de2bc16eSShijith Thotton
300de2bc16eSShijith Thotton len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
301de2bc16eSShijith Thotton
302de2bc16eSShijith Thotton while (count < nb_pkts && t->done == false) {
303de2bc16eSShijith Thotton m = rte_pktmbuf_alloc(pool);
304de2bc16eSShijith Thotton if (m == NULL)
305de2bc16eSShijith Thotton continue;
306de2bc16eSShijith Thotton
307de2bc16eSShijith Thotton rte_pktmbuf_append(m, len);
308de2bc16eSShijith Thotton op = rte_crypto_op_alloc(t->ca_op_pool,
309de2bc16eSShijith Thotton RTE_CRYPTO_OP_TYPE_SYMMETRIC);
310de2bc16eSShijith Thotton sym_op = op->sym;
311de2bc16eSShijith Thotton sym_op->m_src = m;
312de2bc16eSShijith Thotton sym_op->cipher.data.offset = 0;
313de2bc16eSShijith Thotton sym_op->cipher.data.length = len;
314de2bc16eSShijith Thotton rte_crypto_op_attach_sym_session(
315de2bc16eSShijith Thotton op, crypto_sess[flow_counter++ % nb_flows]);
316de2bc16eSShijith Thotton
317de2bc16eSShijith Thotton while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 &&
318de2bc16eSShijith Thotton t->done == false)
319de2bc16eSShijith Thotton rte_pause();
320de2bc16eSShijith Thotton
321de2bc16eSShijith Thotton count++;
322de2bc16eSShijith Thotton }
323de2bc16eSShijith Thotton }
324de2bc16eSShijith Thotton
325de2bc16eSShijith Thotton static inline void
crypto_adapter_enq_op_fwd(struct prod_data * p)326de2bc16eSShijith Thotton crypto_adapter_enq_op_fwd(struct prod_data *p)
327de2bc16eSShijith Thotton {
328de2bc16eSShijith Thotton struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess;
329de2bc16eSShijith Thotton const uint8_t dev_id = p->dev_id;
330de2bc16eSShijith Thotton const uint8_t port = p->port_id;
331de2bc16eSShijith Thotton struct test_perf *t = p->t;
332de2bc16eSShijith Thotton const uint32_t nb_flows = t->nb_flows;
333de2bc16eSShijith Thotton const uint64_t nb_pkts = t->nb_pkts;
334de2bc16eSShijith Thotton struct rte_mempool *pool = t->pool;
335de2bc16eSShijith Thotton struct evt_options *opt = t->opt;
336de2bc16eSShijith Thotton struct rte_crypto_sym_op *sym_op;
337de2bc16eSShijith Thotton uint32_t flow_counter = 0;
338de2bc16eSShijith Thotton struct rte_crypto_op *op;
339de2bc16eSShijith Thotton struct rte_event ev;
340de2bc16eSShijith Thotton struct rte_mbuf *m;
341de2bc16eSShijith Thotton uint64_t count = 0;
342de2bc16eSShijith Thotton uint16_t len;
343de2bc16eSShijith Thotton
344de2bc16eSShijith Thotton if (opt->verbose_level > 1)
345de2bc16eSShijith Thotton printf("%s(): lcore %d port %d queue %d cdev_id %u cdev_qp_id %u\n",
346de2bc16eSShijith Thotton __func__, rte_lcore_id(), port, p->queue_id,
347de2bc16eSShijith Thotton p->ca.cdev_id, p->ca.cdev_qp_id);
348de2bc16eSShijith Thotton
349de2bc16eSShijith Thotton ev.event = 0;
350de2bc16eSShijith Thotton ev.op = RTE_EVENT_OP_NEW;
351de2bc16eSShijith Thotton ev.queue_id = p->queue_id;
352de2bc16eSShijith Thotton ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
353de2bc16eSShijith Thotton ev.event_type = RTE_EVENT_TYPE_CPU;
354de2bc16eSShijith Thotton len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN;
355de2bc16eSShijith Thotton
356de2bc16eSShijith Thotton while (count < nb_pkts && t->done == false) {
357de2bc16eSShijith Thotton m = rte_pktmbuf_alloc(pool);
358de2bc16eSShijith Thotton if (m == NULL)
359de2bc16eSShijith Thotton continue;
360de2bc16eSShijith Thotton
361de2bc16eSShijith Thotton rte_pktmbuf_append(m, len);
362de2bc16eSShijith Thotton op = rte_crypto_op_alloc(t->ca_op_pool,
363de2bc16eSShijith Thotton RTE_CRYPTO_OP_TYPE_SYMMETRIC);
364de2bc16eSShijith Thotton sym_op = op->sym;
365de2bc16eSShijith Thotton sym_op->m_src = m;
366de2bc16eSShijith Thotton sym_op->cipher.data.offset = 0;
367de2bc16eSShijith Thotton sym_op->cipher.data.length = len;
368de2bc16eSShijith Thotton rte_crypto_op_attach_sym_session(
369de2bc16eSShijith Thotton op, crypto_sess[flow_counter++ % nb_flows]);
370de2bc16eSShijith Thotton ev.event_ptr = op;
371de2bc16eSShijith Thotton
372de2bc16eSShijith Thotton while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 &&
373de2bc16eSShijith Thotton t->done == false)
374de2bc16eSShijith Thotton rte_pause();
375de2bc16eSShijith Thotton
376de2bc16eSShijith Thotton count++;
377de2bc16eSShijith Thotton }
378de2bc16eSShijith Thotton }
379de2bc16eSShijith Thotton
380de2bc16eSShijith Thotton static inline int
perf_event_crypto_producer(void * arg)381de2bc16eSShijith Thotton perf_event_crypto_producer(void *arg)
382de2bc16eSShijith Thotton {
383de2bc16eSShijith Thotton struct prod_data *p = arg;
384de2bc16eSShijith Thotton struct evt_options *opt = p->t->opt;
385de2bc16eSShijith Thotton
386de2bc16eSShijith Thotton if (opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
387de2bc16eSShijith Thotton crypto_adapter_enq_op_new(p);
388de2bc16eSShijith Thotton else
389de2bc16eSShijith Thotton crypto_adapter_enq_op_fwd(p);
390de2bc16eSShijith Thotton
391de2bc16eSShijith Thotton return 0;
392de2bc16eSShijith Thotton }
393de2bc16eSShijith Thotton
39459f697e3SPavan Nikhilesh static int
perf_producer_wrapper(void * arg)39559f697e3SPavan Nikhilesh perf_producer_wrapper(void *arg)
39659f697e3SPavan Nikhilesh {
39759f697e3SPavan Nikhilesh struct prod_data *p = arg;
39859f697e3SPavan Nikhilesh struct test_perf *t = p->t;
39920841a25SRashmi Shetty bool burst = evt_has_burst_mode(p->dev_id);
40020841a25SRashmi Shetty
40120841a25SRashmi Shetty /* In case of synthetic producer, launch perf_producer or
40220841a25SRashmi Shetty * perf_producer_burst depending on producer enqueue burst size
40320841a25SRashmi Shetty */
40420841a25SRashmi Shetty if (t->opt->prod_type == EVT_PROD_TYPE_SYNT &&
40520841a25SRashmi Shetty t->opt->prod_enq_burst_sz == 1)
40659f697e3SPavan Nikhilesh return perf_producer(arg);
40720841a25SRashmi Shetty else if (t->opt->prod_type == EVT_PROD_TYPE_SYNT &&
40820841a25SRashmi Shetty t->opt->prod_enq_burst_sz > 1) {
40920841a25SRashmi Shetty if (!burst)
41020841a25SRashmi Shetty evt_err("This event device does not support burst mode");
41120841a25SRashmi Shetty else
41220841a25SRashmi Shetty return perf_producer_burst(arg);
41320841a25SRashmi Shetty }
41417b22d0bSPavan Nikhilesh else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
41517b22d0bSPavan Nikhilesh !t->opt->timdev_use_burst)
416d008f20bSPavan Nikhilesh return perf_event_timer_producer(arg);
41717b22d0bSPavan Nikhilesh else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR &&
41817b22d0bSPavan Nikhilesh t->opt->timdev_use_burst)
41917b22d0bSPavan Nikhilesh return perf_event_timer_producer_burst(arg);
420de2bc16eSShijith Thotton else if (t->opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
421de2bc16eSShijith Thotton return perf_event_crypto_producer(arg);
42259f697e3SPavan Nikhilesh return 0;
42359f697e3SPavan Nikhilesh }
42459f697e3SPavan Nikhilesh
4259d3aeb18SJerin Jacob static inline uint64_t
processed_pkts(struct test_perf * t)4269d3aeb18SJerin Jacob processed_pkts(struct test_perf *t)
4279d3aeb18SJerin Jacob {
4289d3aeb18SJerin Jacob uint8_t i;
4299d3aeb18SJerin Jacob uint64_t total = 0;
4309d3aeb18SJerin Jacob
4319d3aeb18SJerin Jacob for (i = 0; i < t->nb_workers; i++)
4329d3aeb18SJerin Jacob total += t->worker[i].processed_pkts;
4339d3aeb18SJerin Jacob
4349d3aeb18SJerin Jacob return total;
4359d3aeb18SJerin Jacob }
4369d3aeb18SJerin Jacob
4379d3aeb18SJerin Jacob static inline uint64_t
total_latency(struct test_perf * t)4389d3aeb18SJerin Jacob total_latency(struct test_perf *t)
4399d3aeb18SJerin Jacob {
4409d3aeb18SJerin Jacob uint8_t i;
4419d3aeb18SJerin Jacob uint64_t total = 0;
4429d3aeb18SJerin Jacob
4439d3aeb18SJerin Jacob for (i = 0; i < t->nb_workers; i++)
4449d3aeb18SJerin Jacob total += t->worker[i].latency;
4459d3aeb18SJerin Jacob
4469d3aeb18SJerin Jacob return total;
4479d3aeb18SJerin Jacob }
4489d3aeb18SJerin Jacob
4499d3aeb18SJerin Jacob
4509d3aeb18SJerin Jacob int
perf_launch_lcores(struct evt_test * test,struct evt_options * opt,int (* worker)(void *))4519d3aeb18SJerin Jacob perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
4529d3aeb18SJerin Jacob int (*worker)(void *))
4539d3aeb18SJerin Jacob {
4549d3aeb18SJerin Jacob int ret, lcore_id;
4559d3aeb18SJerin Jacob struct test_perf *t = evt_test_priv(test);
4569d3aeb18SJerin Jacob
4579d3aeb18SJerin Jacob int port_idx = 0;
4589d3aeb18SJerin Jacob /* launch workers */
459cb056611SStephen Hemminger RTE_LCORE_FOREACH_WORKER(lcore_id) {
4609d3aeb18SJerin Jacob if (!(opt->wlcores[lcore_id]))
4619d3aeb18SJerin Jacob continue;
4629d3aeb18SJerin Jacob
4639d3aeb18SJerin Jacob ret = rte_eal_remote_launch(worker,
4649d3aeb18SJerin Jacob &t->worker[port_idx], lcore_id);
4659d3aeb18SJerin Jacob if (ret) {
4669d3aeb18SJerin Jacob evt_err("failed to launch worker %d", lcore_id);
4679d3aeb18SJerin Jacob return ret;
4689d3aeb18SJerin Jacob }
4699d3aeb18SJerin Jacob port_idx++;
4709d3aeb18SJerin Jacob }
4719d3aeb18SJerin Jacob
4729d3aeb18SJerin Jacob /* launch producers */
473cb056611SStephen Hemminger RTE_LCORE_FOREACH_WORKER(lcore_id) {
4749d3aeb18SJerin Jacob if (!(opt->plcores[lcore_id]))
4759d3aeb18SJerin Jacob continue;
4769d3aeb18SJerin Jacob
47759f697e3SPavan Nikhilesh ret = rte_eal_remote_launch(perf_producer_wrapper,
47859f697e3SPavan Nikhilesh &t->prod[port_idx], lcore_id);
4799d3aeb18SJerin Jacob if (ret) {
4809d3aeb18SJerin Jacob evt_err("failed to launch perf_producer %d", lcore_id);
4819d3aeb18SJerin Jacob return ret;
4829d3aeb18SJerin Jacob }
4839d3aeb18SJerin Jacob port_idx++;
4849d3aeb18SJerin Jacob }
4859d3aeb18SJerin Jacob
486d008f20bSPavan Nikhilesh const uint64_t total_pkts = t->outstand_pkts;
4879d3aeb18SJerin Jacob
4889d3aeb18SJerin Jacob uint64_t dead_lock_cycles = rte_get_timer_cycles();
4899d3aeb18SJerin Jacob int64_t dead_lock_remaining = total_pkts;
4909d3aeb18SJerin Jacob const uint64_t dead_lock_sample = rte_get_timer_hz() * 5;
4919d3aeb18SJerin Jacob
4929d3aeb18SJerin Jacob uint64_t perf_cycles = rte_get_timer_cycles();
4939d3aeb18SJerin Jacob int64_t perf_remaining = total_pkts;
4949d3aeb18SJerin Jacob const uint64_t perf_sample = rte_get_timer_hz();
4959d3aeb18SJerin Jacob
4969d3aeb18SJerin Jacob static float total_mpps;
4979d3aeb18SJerin Jacob static uint64_t samples;
4989d3aeb18SJerin Jacob
4999d3aeb18SJerin Jacob const uint64_t freq_mhz = rte_get_timer_hz() / 1000000;
5009d3aeb18SJerin Jacob int64_t remaining = t->outstand_pkts - processed_pkts(t);
5019d3aeb18SJerin Jacob
5029d3aeb18SJerin Jacob while (t->done == false) {
5039d3aeb18SJerin Jacob const uint64_t new_cycles = rte_get_timer_cycles();
5049d3aeb18SJerin Jacob
5059d3aeb18SJerin Jacob if ((new_cycles - perf_cycles) > perf_sample) {
5069d3aeb18SJerin Jacob const uint64_t latency = total_latency(t);
5079d3aeb18SJerin Jacob const uint64_t pkts = processed_pkts(t);
5089d3aeb18SJerin Jacob
5099d3aeb18SJerin Jacob remaining = t->outstand_pkts - pkts;
5109d3aeb18SJerin Jacob float mpps = (float)(perf_remaining-remaining)/1000000;
5119d3aeb18SJerin Jacob
5129d3aeb18SJerin Jacob perf_remaining = remaining;
5139d3aeb18SJerin Jacob perf_cycles = new_cycles;
5149d3aeb18SJerin Jacob total_mpps += mpps;
5159d3aeb18SJerin Jacob ++samples;
51604716352SJerin Jacob if (opt->fwd_latency && pkts > 0) {
5179d3aeb18SJerin Jacob printf(CLGRN"\r%.3f mpps avg %.3f mpps [avg fwd latency %.3f us] "CLNRM,
5189d3aeb18SJerin Jacob mpps, total_mpps/samples,
5199d3aeb18SJerin Jacob (float)(latency/pkts)/freq_mhz);
5209d3aeb18SJerin Jacob } else {
5219d3aeb18SJerin Jacob printf(CLGRN"\r%.3f mpps avg %.3f mpps"CLNRM,
5229d3aeb18SJerin Jacob mpps, total_mpps/samples);
5239d3aeb18SJerin Jacob }
5249d3aeb18SJerin Jacob fflush(stdout);
5259d3aeb18SJerin Jacob
5269d3aeb18SJerin Jacob if (remaining <= 0) {
5279d3aeb18SJerin Jacob t->result = EVT_TEST_SUCCESS;
528d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
529d008f20bSPavan Nikhilesh opt->prod_type ==
530de2bc16eSShijith Thotton EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
531de2bc16eSShijith Thotton opt->prod_type ==
532de2bc16eSShijith Thotton EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
53359f697e3SPavan Nikhilesh t->done = true;
5349d3aeb18SJerin Jacob break;
5359d3aeb18SJerin Jacob }
5369d3aeb18SJerin Jacob }
53759f697e3SPavan Nikhilesh }
5389d3aeb18SJerin Jacob
53959f697e3SPavan Nikhilesh if (new_cycles - dead_lock_cycles > dead_lock_sample &&
54047303784SErik Gabriel Carrillo (opt->prod_type == EVT_PROD_TYPE_SYNT ||
541de2bc16eSShijith Thotton opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
542de2bc16eSShijith Thotton opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)) {
5439d3aeb18SJerin Jacob remaining = t->outstand_pkts - processed_pkts(t);
5449d3aeb18SJerin Jacob if (dead_lock_remaining == remaining) {
5459d3aeb18SJerin Jacob rte_event_dev_dump(opt->dev_id, stdout);
5469d3aeb18SJerin Jacob evt_err("No schedules for seconds, deadlock");
5479d3aeb18SJerin Jacob t->done = true;
5489d3aeb18SJerin Jacob break;
5499d3aeb18SJerin Jacob }
5509d3aeb18SJerin Jacob dead_lock_remaining = remaining;
5519d3aeb18SJerin Jacob dead_lock_cycles = new_cycles;
5529d3aeb18SJerin Jacob }
5539d3aeb18SJerin Jacob }
5549d3aeb18SJerin Jacob printf("\n");
5559d3aeb18SJerin Jacob return 0;
5569d3aeb18SJerin Jacob }
5579d3aeb18SJerin Jacob
5583617aae5SPavan Nikhilesh static int
perf_event_rx_adapter_setup(struct evt_options * opt,uint8_t stride,struct rte_event_port_conf prod_conf)5593617aae5SPavan Nikhilesh perf_event_rx_adapter_setup(struct evt_options *opt, uint8_t stride,
5603617aae5SPavan Nikhilesh struct rte_event_port_conf prod_conf)
5613617aae5SPavan Nikhilesh {
5623617aae5SPavan Nikhilesh int ret = 0;
5633617aae5SPavan Nikhilesh uint16_t prod;
5643617aae5SPavan Nikhilesh struct rte_event_eth_rx_adapter_queue_conf queue_conf;
5653617aae5SPavan Nikhilesh
5663617aae5SPavan Nikhilesh memset(&queue_conf, 0,
5673617aae5SPavan Nikhilesh sizeof(struct rte_event_eth_rx_adapter_queue_conf));
5683617aae5SPavan Nikhilesh queue_conf.ev.sched_type = opt->sched_type_list[0];
5698728ccf3SThomas Monjalon RTE_ETH_FOREACH_DEV(prod) {
5703617aae5SPavan Nikhilesh uint32_t cap;
5713617aae5SPavan Nikhilesh
5723617aae5SPavan Nikhilesh ret = rte_event_eth_rx_adapter_caps_get(opt->dev_id,
5733617aae5SPavan Nikhilesh prod, &cap);
5743617aae5SPavan Nikhilesh if (ret) {
5753617aae5SPavan Nikhilesh evt_err("failed to get event rx adapter[%d]"
5763617aae5SPavan Nikhilesh " capabilities",
5773617aae5SPavan Nikhilesh opt->dev_id);
5783617aae5SPavan Nikhilesh return ret;
5793617aae5SPavan Nikhilesh }
5803617aae5SPavan Nikhilesh queue_conf.ev.queue_id = prod * stride;
5813617aae5SPavan Nikhilesh ret = rte_event_eth_rx_adapter_create(prod, opt->dev_id,
5823617aae5SPavan Nikhilesh &prod_conf);
5833617aae5SPavan Nikhilesh if (ret) {
5843617aae5SPavan Nikhilesh evt_err("failed to create rx adapter[%d]", prod);
5853617aae5SPavan Nikhilesh return ret;
5863617aae5SPavan Nikhilesh }
5873617aae5SPavan Nikhilesh ret = rte_event_eth_rx_adapter_queue_add(prod, prod, -1,
5883617aae5SPavan Nikhilesh &queue_conf);
5893617aae5SPavan Nikhilesh if (ret) {
5903617aae5SPavan Nikhilesh evt_err("failed to add rx queues to adapter[%d]", prod);
5913617aae5SPavan Nikhilesh return ret;
5923617aae5SPavan Nikhilesh }
5933617aae5SPavan Nikhilesh
594b0333c55SPavan Nikhilesh if (!(cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT)) {
595b0333c55SPavan Nikhilesh uint32_t service_id;
596b0333c55SPavan Nikhilesh
597b0333c55SPavan Nikhilesh rte_event_eth_rx_adapter_service_id_get(prod,
598b0333c55SPavan Nikhilesh &service_id);
599b0333c55SPavan Nikhilesh ret = evt_service_setup(service_id);
600b0333c55SPavan Nikhilesh if (ret) {
601b0333c55SPavan Nikhilesh evt_err("Failed to setup service core"
602b0333c55SPavan Nikhilesh " for Rx adapter\n");
603b0333c55SPavan Nikhilesh return ret;
604b0333c55SPavan Nikhilesh }
605b0333c55SPavan Nikhilesh }
6063617aae5SPavan Nikhilesh }
6073617aae5SPavan Nikhilesh
6083617aae5SPavan Nikhilesh return ret;
6093617aae5SPavan Nikhilesh }
6103617aae5SPavan Nikhilesh
611d008f20bSPavan Nikhilesh static int
perf_event_timer_adapter_setup(struct test_perf * t)612d008f20bSPavan Nikhilesh perf_event_timer_adapter_setup(struct test_perf *t)
613d008f20bSPavan Nikhilesh {
614d008f20bSPavan Nikhilesh int i;
615d008f20bSPavan Nikhilesh int ret;
616d008f20bSPavan Nikhilesh struct rte_event_timer_adapter_info adapter_info;
617d008f20bSPavan Nikhilesh struct rte_event_timer_adapter *wl;
618d008f20bSPavan Nikhilesh uint8_t nb_producers = evt_nr_active_lcores(t->opt->plcores);
619d008f20bSPavan Nikhilesh uint8_t flags = RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES;
620d008f20bSPavan Nikhilesh
621d008f20bSPavan Nikhilesh if (nb_producers == 1)
622d008f20bSPavan Nikhilesh flags |= RTE_EVENT_TIMER_ADAPTER_F_SP_PUT;
623d008f20bSPavan Nikhilesh
624d008f20bSPavan Nikhilesh for (i = 0; i < t->opt->nb_timer_adptrs; i++) {
625d008f20bSPavan Nikhilesh struct rte_event_timer_adapter_conf config = {
626d008f20bSPavan Nikhilesh .event_dev_id = t->opt->dev_id,
627d008f20bSPavan Nikhilesh .timer_adapter_id = i,
628d008f20bSPavan Nikhilesh .timer_tick_ns = t->opt->timer_tick_nsec,
629d008f20bSPavan Nikhilesh .max_tmo_ns = t->opt->max_tmo_nsec,
630c13b1ad7SPavan Nikhilesh .nb_timers = t->opt->pool_sz,
631d008f20bSPavan Nikhilesh .flags = flags,
632d008f20bSPavan Nikhilesh };
633d008f20bSPavan Nikhilesh
634d008f20bSPavan Nikhilesh wl = rte_event_timer_adapter_create(&config);
635d008f20bSPavan Nikhilesh if (wl == NULL) {
636d008f20bSPavan Nikhilesh evt_err("failed to create event timer ring %d", i);
637d008f20bSPavan Nikhilesh return rte_errno;
638d008f20bSPavan Nikhilesh }
639d008f20bSPavan Nikhilesh
640d008f20bSPavan Nikhilesh memset(&adapter_info, 0,
641d008f20bSPavan Nikhilesh sizeof(struct rte_event_timer_adapter_info));
642d008f20bSPavan Nikhilesh rte_event_timer_adapter_get_info(wl, &adapter_info);
643d008f20bSPavan Nikhilesh t->opt->optm_timer_tick_nsec = adapter_info.min_resolution_ns;
644d008f20bSPavan Nikhilesh
645d008f20bSPavan Nikhilesh if (!(adapter_info.caps &
646d008f20bSPavan Nikhilesh RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) {
64799c25664SAndrzej Ostruszka uint32_t service_id = -1U;
648d008f20bSPavan Nikhilesh
649d008f20bSPavan Nikhilesh rte_event_timer_adapter_service_id_get(wl,
650d008f20bSPavan Nikhilesh &service_id);
651d008f20bSPavan Nikhilesh ret = evt_service_setup(service_id);
652d008f20bSPavan Nikhilesh if (ret) {
653d008f20bSPavan Nikhilesh evt_err("Failed to setup service core"
654d008f20bSPavan Nikhilesh " for timer adapter\n");
655d008f20bSPavan Nikhilesh return ret;
656d008f20bSPavan Nikhilesh }
657d008f20bSPavan Nikhilesh rte_service_runstate_set(service_id, 1);
658d008f20bSPavan Nikhilesh }
659d008f20bSPavan Nikhilesh t->timer_adptr[i] = wl;
660d008f20bSPavan Nikhilesh }
661d008f20bSPavan Nikhilesh return 0;
662d008f20bSPavan Nikhilesh }
663d008f20bSPavan Nikhilesh
664de2bc16eSShijith Thotton static int
perf_event_crypto_adapter_setup(struct test_perf * t,struct prod_data * p)665de2bc16eSShijith Thotton perf_event_crypto_adapter_setup(struct test_perf *t, struct prod_data *p)
666de2bc16eSShijith Thotton {
667de2bc16eSShijith Thotton struct evt_options *opt = t->opt;
668de2bc16eSShijith Thotton uint32_t cap;
669de2bc16eSShijith Thotton int ret;
670de2bc16eSShijith Thotton
671de2bc16eSShijith Thotton ret = rte_event_crypto_adapter_caps_get(p->dev_id, p->ca.cdev_id, &cap);
672de2bc16eSShijith Thotton if (ret) {
673de2bc16eSShijith Thotton evt_err("Failed to get crypto adapter capabilities");
674de2bc16eSShijith Thotton return ret;
675de2bc16eSShijith Thotton }
676de2bc16eSShijith Thotton
677de2bc16eSShijith Thotton if (((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
678de2bc16eSShijith Thotton !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) ||
679de2bc16eSShijith Thotton ((opt->crypto_adptr_mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
680de2bc16eSShijith Thotton !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))) {
681de2bc16eSShijith Thotton evt_err("crypto adapter %s mode unsupported\n",
682de2bc16eSShijith Thotton opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW");
683de2bc16eSShijith Thotton return -ENOTSUP;
684de2bc16eSShijith Thotton } else if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA)) {
685de2bc16eSShijith Thotton evt_err("Storing crypto session not supported");
686de2bc16eSShijith Thotton return -ENOTSUP;
687de2bc16eSShijith Thotton }
688de2bc16eSShijith Thotton
689de2bc16eSShijith Thotton if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
690de2bc16eSShijith Thotton struct rte_event response_info;
691de2bc16eSShijith Thotton
692de2bc16eSShijith Thotton response_info.event = 0;
693de2bc16eSShijith Thotton response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
694de2bc16eSShijith Thotton response_info.queue_id = p->queue_id;
695de2bc16eSShijith Thotton ret = rte_event_crypto_adapter_queue_pair_add(
696de2bc16eSShijith Thotton TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id,
697de2bc16eSShijith Thotton &response_info);
698de2bc16eSShijith Thotton } else {
699de2bc16eSShijith Thotton ret = rte_event_crypto_adapter_queue_pair_add(
700de2bc16eSShijith Thotton TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id, NULL);
701de2bc16eSShijith Thotton }
702de2bc16eSShijith Thotton
703de2bc16eSShijith Thotton return ret;
704de2bc16eSShijith Thotton }
705de2bc16eSShijith Thotton
706de2bc16eSShijith Thotton static struct rte_cryptodev_sym_session *
cryptodev_sym_sess_create(struct prod_data * p,struct test_perf * t)707de2bc16eSShijith Thotton cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t)
708de2bc16eSShijith Thotton {
709de2bc16eSShijith Thotton struct rte_crypto_sym_xform cipher_xform;
710de2bc16eSShijith Thotton struct rte_cryptodev_sym_session *sess;
711de2bc16eSShijith Thotton
712de2bc16eSShijith Thotton cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
713de2bc16eSShijith Thotton cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
714de2bc16eSShijith Thotton cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
715de2bc16eSShijith Thotton cipher_xform.next = NULL;
716de2bc16eSShijith Thotton
717de2bc16eSShijith Thotton sess = rte_cryptodev_sym_session_create(t->ca_sess_pool);
718de2bc16eSShijith Thotton if (sess == NULL) {
719de2bc16eSShijith Thotton evt_err("Failed to create sym session");
720de2bc16eSShijith Thotton return NULL;
721de2bc16eSShijith Thotton }
722de2bc16eSShijith Thotton
723de2bc16eSShijith Thotton if (rte_cryptodev_sym_session_init(p->ca.cdev_id, sess, &cipher_xform,
724de2bc16eSShijith Thotton t->ca_sess_priv_pool)) {
725de2bc16eSShijith Thotton evt_err("Failed to init session");
726de2bc16eSShijith Thotton return NULL;
727de2bc16eSShijith Thotton }
728de2bc16eSShijith Thotton
729de2bc16eSShijith Thotton return sess;
730de2bc16eSShijith Thotton }
731de2bc16eSShijith Thotton
732272de067SJerin Jacob int
perf_event_dev_port_setup(struct evt_test * test,struct evt_options * opt,uint8_t stride,uint8_t nb_queues,const struct rte_event_port_conf * port_conf)73384a7513dSJerin Jacob perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
734535c630cSPavan Nikhilesh uint8_t stride, uint8_t nb_queues,
735535c630cSPavan Nikhilesh const struct rte_event_port_conf *port_conf)
73684a7513dSJerin Jacob {
73784a7513dSJerin Jacob struct test_perf *t = evt_test_priv(test);
7383617aae5SPavan Nikhilesh uint16_t port, prod;
73984a7513dSJerin Jacob int ret = -1;
74084a7513dSJerin Jacob
74184a7513dSJerin Jacob /* setup one port per worker, linking to all queues */
74284a7513dSJerin Jacob for (port = 0; port < evt_nr_active_lcores(opt->wlcores);
74384a7513dSJerin Jacob port++) {
74484a7513dSJerin Jacob struct worker_data *w = &t->worker[port];
74584a7513dSJerin Jacob
74684a7513dSJerin Jacob w->dev_id = opt->dev_id;
74784a7513dSJerin Jacob w->port_id = port;
74884a7513dSJerin Jacob w->t = t;
74984a7513dSJerin Jacob w->processed_pkts = 0;
75084a7513dSJerin Jacob w->latency = 0;
75184a7513dSJerin Jacob
7525f94d108SHarry van Haaren struct rte_event_port_conf conf = *port_conf;
7535f94d108SHarry van Haaren conf.event_port_cfg |= RTE_EVENT_PORT_CFG_HINT_WORKER;
7545f94d108SHarry van Haaren
7555f94d108SHarry van Haaren ret = rte_event_port_setup(opt->dev_id, port, &conf);
75684a7513dSJerin Jacob if (ret) {
75784a7513dSJerin Jacob evt_err("failed to setup port %d", port);
75884a7513dSJerin Jacob return ret;
75984a7513dSJerin Jacob }
76084a7513dSJerin Jacob
76184a7513dSJerin Jacob ret = rte_event_port_link(opt->dev_id, port, NULL, NULL, 0);
76284a7513dSJerin Jacob if (ret != nb_queues) {
76384a7513dSJerin Jacob evt_err("failed to link all queues to port %d", port);
76484a7513dSJerin Jacob return -EINVAL;
76584a7513dSJerin Jacob }
76684a7513dSJerin Jacob }
76784a7513dSJerin Jacob
76884a7513dSJerin Jacob /* port for producers, no links */
7693617aae5SPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
7703617aae5SPavan Nikhilesh for ( ; port < perf_nb_event_ports(opt); port++) {
7713617aae5SPavan Nikhilesh struct prod_data *p = &t->prod[port];
7723617aae5SPavan Nikhilesh p->t = t;
7733617aae5SPavan Nikhilesh }
7743617aae5SPavan Nikhilesh
7755f94d108SHarry van Haaren struct rte_event_port_conf conf = *port_conf;
7765f94d108SHarry van Haaren conf.event_port_cfg |= RTE_EVENT_PORT_CFG_HINT_PRODUCER;
7775f94d108SHarry van Haaren
7785f94d108SHarry van Haaren ret = perf_event_rx_adapter_setup(opt, stride, conf);
7793617aae5SPavan Nikhilesh if (ret)
7803617aae5SPavan Nikhilesh return ret;
781d008f20bSPavan Nikhilesh } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
782d008f20bSPavan Nikhilesh prod = 0;
783d008f20bSPavan Nikhilesh for ( ; port < perf_nb_event_ports(opt); port++) {
784d008f20bSPavan Nikhilesh struct prod_data *p = &t->prod[port];
785d008f20bSPavan Nikhilesh p->queue_id = prod * stride;
786d008f20bSPavan Nikhilesh p->t = t;
787d008f20bSPavan Nikhilesh prod++;
788d008f20bSPavan Nikhilesh }
789d008f20bSPavan Nikhilesh
790d008f20bSPavan Nikhilesh ret = perf_event_timer_adapter_setup(t);
791d008f20bSPavan Nikhilesh if (ret)
792d008f20bSPavan Nikhilesh return ret;
793de2bc16eSShijith Thotton } else if (opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
794de2bc16eSShijith Thotton struct rte_event_port_conf conf = *port_conf;
795de2bc16eSShijith Thotton uint8_t cdev_id = 0;
796de2bc16eSShijith Thotton uint16_t qp_id = 0;
797de2bc16eSShijith Thotton
798de2bc16eSShijith Thotton ret = rte_event_crypto_adapter_create(TEST_PERF_CA_ID,
799de2bc16eSShijith Thotton opt->dev_id, &conf, 0);
800de2bc16eSShijith Thotton if (ret) {
801de2bc16eSShijith Thotton evt_err("Failed to create crypto adapter");
802de2bc16eSShijith Thotton return ret;
803de2bc16eSShijith Thotton }
804de2bc16eSShijith Thotton
805de2bc16eSShijith Thotton prod = 0;
806de2bc16eSShijith Thotton for (; port < perf_nb_event_ports(opt); port++) {
807de2bc16eSShijith Thotton struct rte_cryptodev_sym_session *crypto_sess;
808de2bc16eSShijith Thotton union rte_event_crypto_metadata m_data;
809de2bc16eSShijith Thotton struct prod_data *p = &t->prod[port];
810de2bc16eSShijith Thotton uint32_t flow_id;
811de2bc16eSShijith Thotton
812de2bc16eSShijith Thotton if (qp_id == rte_cryptodev_queue_pair_count(cdev_id)) {
813de2bc16eSShijith Thotton cdev_id++;
814de2bc16eSShijith Thotton qp_id = 0;
815de2bc16eSShijith Thotton }
816de2bc16eSShijith Thotton
817de2bc16eSShijith Thotton p->dev_id = opt->dev_id;
818de2bc16eSShijith Thotton p->port_id = port;
819de2bc16eSShijith Thotton p->queue_id = prod * stride;
820de2bc16eSShijith Thotton p->ca.cdev_id = cdev_id;
821de2bc16eSShijith Thotton p->ca.cdev_qp_id = qp_id;
822de2bc16eSShijith Thotton p->ca.crypto_sess = rte_zmalloc_socket(
823de2bc16eSShijith Thotton NULL, sizeof(crypto_sess) * t->nb_flows,
824de2bc16eSShijith Thotton RTE_CACHE_LINE_SIZE, opt->socket_id);
825de2bc16eSShijith Thotton p->t = t;
826de2bc16eSShijith Thotton
827de2bc16eSShijith Thotton m_data.request_info.cdev_id = p->ca.cdev_id;
828de2bc16eSShijith Thotton m_data.request_info.queue_pair_id = p->ca.cdev_qp_id;
829de2bc16eSShijith Thotton m_data.response_info.sched_type = RTE_SCHED_TYPE_ATOMIC;
830de2bc16eSShijith Thotton m_data.response_info.queue_id = p->queue_id;
831de2bc16eSShijith Thotton
832de2bc16eSShijith Thotton for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
833de2bc16eSShijith Thotton crypto_sess = cryptodev_sym_sess_create(p, t);
834de2bc16eSShijith Thotton if (crypto_sess == NULL)
835de2bc16eSShijith Thotton return -ENOMEM;
836de2bc16eSShijith Thotton
837de2bc16eSShijith Thotton m_data.response_info.flow_id = flow_id;
838de2bc16eSShijith Thotton rte_cryptodev_sym_session_set_user_data(
839de2bc16eSShijith Thotton crypto_sess, &m_data, sizeof(m_data));
840de2bc16eSShijith Thotton p->ca.crypto_sess[flow_id] = crypto_sess;
841de2bc16eSShijith Thotton }
842de2bc16eSShijith Thotton
843de2bc16eSShijith Thotton conf.event_port_cfg |=
844de2bc16eSShijith Thotton RTE_EVENT_PORT_CFG_HINT_PRODUCER |
845de2bc16eSShijith Thotton RTE_EVENT_PORT_CFG_HINT_CONSUMER;
846de2bc16eSShijith Thotton
847de2bc16eSShijith Thotton ret = rte_event_port_setup(opt->dev_id, port, &conf);
848de2bc16eSShijith Thotton if (ret) {
849de2bc16eSShijith Thotton evt_err("failed to setup port %d", port);
850de2bc16eSShijith Thotton return ret;
851de2bc16eSShijith Thotton }
852de2bc16eSShijith Thotton
853de2bc16eSShijith Thotton ret = perf_event_crypto_adapter_setup(t, p);
854de2bc16eSShijith Thotton if (ret)
855de2bc16eSShijith Thotton return ret;
856de2bc16eSShijith Thotton
857de2bc16eSShijith Thotton qp_id++;
858de2bc16eSShijith Thotton prod++;
859de2bc16eSShijith Thotton }
8603617aae5SPavan Nikhilesh } else {
86184a7513dSJerin Jacob prod = 0;
86284a7513dSJerin Jacob for ( ; port < perf_nb_event_ports(opt); port++) {
86384a7513dSJerin Jacob struct prod_data *p = &t->prod[port];
86484a7513dSJerin Jacob
86584a7513dSJerin Jacob p->dev_id = opt->dev_id;
86684a7513dSJerin Jacob p->port_id = port;
86784a7513dSJerin Jacob p->queue_id = prod * stride;
86884a7513dSJerin Jacob p->t = t;
86984a7513dSJerin Jacob
8705f94d108SHarry van Haaren struct rte_event_port_conf conf = *port_conf;
8715f94d108SHarry van Haaren conf.event_port_cfg |=
8725f94d108SHarry van Haaren RTE_EVENT_PORT_CFG_HINT_PRODUCER |
8735f94d108SHarry van Haaren RTE_EVENT_PORT_CFG_HINT_CONSUMER;
8745f94d108SHarry van Haaren
8755f94d108SHarry van Haaren ret = rte_event_port_setup(opt->dev_id, port, &conf);
87684a7513dSJerin Jacob if (ret) {
87784a7513dSJerin Jacob evt_err("failed to setup port %d", port);
87884a7513dSJerin Jacob return ret;
87984a7513dSJerin Jacob }
88084a7513dSJerin Jacob prod++;
88184a7513dSJerin Jacob }
8823617aae5SPavan Nikhilesh }
88384a7513dSJerin Jacob
88484a7513dSJerin Jacob return ret;
88584a7513dSJerin Jacob }
88684a7513dSJerin Jacob
88784a7513dSJerin Jacob int
perf_opt_check(struct evt_options * opt,uint64_t nb_queues)888272de067SJerin Jacob perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
889272de067SJerin Jacob {
890272de067SJerin Jacob unsigned int lcores;
891272de067SJerin Jacob
892cb056611SStephen Hemminger /* N producer + N worker + main when producer cores are used
893cb056611SStephen Hemminger * Else N worker + main when Rx adapter is used
894b01974daSPavan Nikhilesh */
895b01974daSPavan Nikhilesh lcores = opt->prod_type == EVT_PROD_TYPE_SYNT ? 3 : 2;
896272de067SJerin Jacob
897272de067SJerin Jacob if (rte_lcore_count() < lcores) {
898272de067SJerin Jacob evt_err("test need minimum %d lcores", lcores);
899272de067SJerin Jacob return -1;
900272de067SJerin Jacob }
901272de067SJerin Jacob
902272de067SJerin Jacob /* Validate worker lcores */
903cb056611SStephen Hemminger if (evt_lcores_has_overlap(opt->wlcores, rte_get_main_lcore())) {
904cb056611SStephen Hemminger evt_err("worker lcores overlaps with main lcore");
905272de067SJerin Jacob return -1;
906272de067SJerin Jacob }
907272de067SJerin Jacob if (evt_lcores_has_overlap_multi(opt->wlcores, opt->plcores)) {
908272de067SJerin Jacob evt_err("worker lcores overlaps producer lcores");
909272de067SJerin Jacob return -1;
910272de067SJerin Jacob }
911272de067SJerin Jacob if (evt_has_disabled_lcore(opt->wlcores)) {
912272de067SJerin Jacob evt_err("one or more workers lcores are not enabled");
913272de067SJerin Jacob return -1;
914272de067SJerin Jacob }
915272de067SJerin Jacob if (!evt_has_active_lcore(opt->wlcores)) {
916272de067SJerin Jacob evt_err("minimum one worker is required");
917272de067SJerin Jacob return -1;
918272de067SJerin Jacob }
919272de067SJerin Jacob
920902387eaSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
921de2bc16eSShijith Thotton opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR ||
922de2bc16eSShijith Thotton opt->prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
923272de067SJerin Jacob /* Validate producer lcores */
924b01974daSPavan Nikhilesh if (evt_lcores_has_overlap(opt->plcores,
925cb056611SStephen Hemminger rte_get_main_lcore())) {
926cb056611SStephen Hemminger evt_err("producer lcores overlaps with main lcore");
927272de067SJerin Jacob return -1;
928272de067SJerin Jacob }
929272de067SJerin Jacob if (evt_has_disabled_lcore(opt->plcores)) {
930272de067SJerin Jacob evt_err("one or more producer lcores are not enabled");
931272de067SJerin Jacob return -1;
932272de067SJerin Jacob }
933272de067SJerin Jacob if (!evt_has_active_lcore(opt->plcores)) {
934272de067SJerin Jacob evt_err("minimum one producer is required");
935272de067SJerin Jacob return -1;
936272de067SJerin Jacob }
937b01974daSPavan Nikhilesh }
938272de067SJerin Jacob
939272de067SJerin Jacob if (evt_has_invalid_stage(opt))
940272de067SJerin Jacob return -1;
941272de067SJerin Jacob
942272de067SJerin Jacob if (evt_has_invalid_sched_type(opt))
943272de067SJerin Jacob return -1;
944272de067SJerin Jacob
945272de067SJerin Jacob if (nb_queues > EVT_MAX_QUEUES) {
946272de067SJerin Jacob evt_err("number of queues exceeds %d", EVT_MAX_QUEUES);
947272de067SJerin Jacob return -1;
948272de067SJerin Jacob }
949272de067SJerin Jacob if (perf_nb_event_ports(opt) > EVT_MAX_PORTS) {
950272de067SJerin Jacob evt_err("number of ports exceeds %d", EVT_MAX_PORTS);
951272de067SJerin Jacob return -1;
952272de067SJerin Jacob }
953272de067SJerin Jacob
954272de067SJerin Jacob /* Fixups */
955d008f20bSPavan Nikhilesh if ((opt->nb_stages == 1 &&
956d008f20bSPavan Nikhilesh opt->prod_type != EVT_PROD_TYPE_EVENT_TIMER_ADPTR) &&
957d008f20bSPavan Nikhilesh opt->fwd_latency) {
958272de067SJerin Jacob evt_info("fwd_latency is valid when nb_stages > 1, disabling");
959272de067SJerin Jacob opt->fwd_latency = 0;
960272de067SJerin Jacob }
961d008f20bSPavan Nikhilesh
962272de067SJerin Jacob if (opt->fwd_latency && !opt->q_priority) {
963272de067SJerin Jacob evt_info("enabled queue priority for latency measurement");
964272de067SJerin Jacob opt->q_priority = 1;
965272de067SJerin Jacob }
9669d3aeb18SJerin Jacob if (opt->nb_pkts == 0)
9679d3aeb18SJerin Jacob opt->nb_pkts = INT64_MAX/evt_nr_active_lcores(opt->plcores);
968272de067SJerin Jacob
969272de067SJerin Jacob return 0;
970272de067SJerin Jacob }
971272de067SJerin Jacob
972272de067SJerin Jacob void
perf_opt_dump(struct evt_options * opt,uint8_t nb_queues)973272de067SJerin Jacob perf_opt_dump(struct evt_options *opt, uint8_t nb_queues)
974272de067SJerin Jacob {
975272de067SJerin Jacob evt_dump("nb_prod_lcores", "%d", evt_nr_active_lcores(opt->plcores));
976272de067SJerin Jacob evt_dump_producer_lcores(opt);
977272de067SJerin Jacob evt_dump("nb_worker_lcores", "%d", evt_nr_active_lcores(opt->wlcores));
978272de067SJerin Jacob evt_dump_worker_lcores(opt);
979272de067SJerin Jacob evt_dump_nb_stages(opt);
980272de067SJerin Jacob evt_dump("nb_evdev_ports", "%d", perf_nb_event_ports(opt));
981272de067SJerin Jacob evt_dump("nb_evdev_queues", "%d", nb_queues);
982272de067SJerin Jacob evt_dump_queue_priority(opt);
983272de067SJerin Jacob evt_dump_sched_type_list(opt);
984b01974daSPavan Nikhilesh evt_dump_producer_type(opt);
98520841a25SRashmi Shetty evt_dump("prod_enq_burst_sz", "%d", opt->prod_enq_burst_sz);
986272de067SJerin Jacob }
987272de067SJerin Jacob
988*7da008dfSPavan Nikhilesh static void
perf_event_port_flush(uint8_t dev_id __rte_unused,struct rte_event ev,void * args)989*7da008dfSPavan Nikhilesh perf_event_port_flush(uint8_t dev_id __rte_unused, struct rte_event ev,
990*7da008dfSPavan Nikhilesh void *args)
991*7da008dfSPavan Nikhilesh {
992*7da008dfSPavan Nikhilesh rte_mempool_put(args, ev.event_ptr);
993*7da008dfSPavan Nikhilesh }
994*7da008dfSPavan Nikhilesh
99541c219e6SJerin Jacob void
perf_worker_cleanup(struct rte_mempool * const pool,uint8_t dev_id,uint8_t port_id,struct rte_event events[],uint16_t nb_enq,uint16_t nb_deq)996f0b68c0bSPavan Nikhilesh perf_worker_cleanup(struct rte_mempool *const pool, uint8_t dev_id,
997f0b68c0bSPavan Nikhilesh uint8_t port_id, struct rte_event events[], uint16_t nb_enq,
998f0b68c0bSPavan Nikhilesh uint16_t nb_deq)
999f0b68c0bSPavan Nikhilesh {
1000f0b68c0bSPavan Nikhilesh int i;
1001f0b68c0bSPavan Nikhilesh
1002f0b68c0bSPavan Nikhilesh if (nb_deq) {
1003f0b68c0bSPavan Nikhilesh for (i = nb_enq; i < nb_deq; i++)
1004f0b68c0bSPavan Nikhilesh rte_mempool_put(pool, events[i].event_ptr);
1005f0b68c0bSPavan Nikhilesh
1006f0b68c0bSPavan Nikhilesh for (i = 0; i < nb_deq; i++)
1007f0b68c0bSPavan Nikhilesh events[i].op = RTE_EVENT_OP_RELEASE;
1008f0b68c0bSPavan Nikhilesh rte_event_enqueue_burst(dev_id, port_id, events, nb_deq);
1009f0b68c0bSPavan Nikhilesh }
1010*7da008dfSPavan Nikhilesh rte_event_port_quiesce(dev_id, port_id, perf_event_port_flush, pool);
1011f0b68c0bSPavan Nikhilesh }
1012f0b68c0bSPavan Nikhilesh
1013f0b68c0bSPavan Nikhilesh void
perf_eventdev_destroy(struct evt_test * test,struct evt_options * opt)101441c219e6SJerin Jacob perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
101541c219e6SJerin Jacob {
1016d008f20bSPavan Nikhilesh int i;
1017d008f20bSPavan Nikhilesh struct test_perf *t = evt_test_priv(test);
101841c219e6SJerin Jacob
1019d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
1020d008f20bSPavan Nikhilesh for (i = 0; i < opt->nb_timer_adptrs; i++)
1021d008f20bSPavan Nikhilesh rte_event_timer_adapter_stop(t->timer_adptr[i]);
1022d008f20bSPavan Nikhilesh }
102341c219e6SJerin Jacob rte_event_dev_stop(opt->dev_id);
102441c219e6SJerin Jacob rte_event_dev_close(opt->dev_id);
102541c219e6SJerin Jacob }
102641c219e6SJerin Jacob
102741c219e6SJerin Jacob static inline void
perf_elt_init(struct rte_mempool * mp,void * arg __rte_unused,void * obj,unsigned i __rte_unused)102841c219e6SJerin Jacob perf_elt_init(struct rte_mempool *mp, void *arg __rte_unused,
102941c219e6SJerin Jacob void *obj, unsigned i __rte_unused)
103041c219e6SJerin Jacob {
103141c219e6SJerin Jacob memset(obj, 0, mp->elt_size);
103241c219e6SJerin Jacob }
103341c219e6SJerin Jacob
10343fc8de4fSPavan Nikhilesh #define NB_RX_DESC 128
10353fc8de4fSPavan Nikhilesh #define NB_TX_DESC 512
10363fc8de4fSPavan Nikhilesh int
perf_ethdev_setup(struct evt_test * test,struct evt_options * opt)10373fc8de4fSPavan Nikhilesh perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
10383fc8de4fSPavan Nikhilesh {
10398728ccf3SThomas Monjalon uint16_t i;
104077339255SIvan Ilchenko int ret;
10413fc8de4fSPavan Nikhilesh struct test_perf *t = evt_test_priv(test);
10423fc8de4fSPavan Nikhilesh struct rte_eth_conf port_conf = {
10433fc8de4fSPavan Nikhilesh .rxmode = {
1044295968d1SFerruh Yigit .mq_mode = RTE_ETH_MQ_RX_RSS,
10453fc8de4fSPavan Nikhilesh .split_hdr_size = 0,
10463fc8de4fSPavan Nikhilesh },
10473fc8de4fSPavan Nikhilesh .rx_adv_conf = {
10483fc8de4fSPavan Nikhilesh .rss_conf = {
10493fc8de4fSPavan Nikhilesh .rss_key = NULL,
1050295968d1SFerruh Yigit .rss_hf = RTE_ETH_RSS_IP,
10513fc8de4fSPavan Nikhilesh },
10523fc8de4fSPavan Nikhilesh },
10533fc8de4fSPavan Nikhilesh };
10543fc8de4fSPavan Nikhilesh
1055de2bc16eSShijith Thotton if (opt->prod_type != EVT_PROD_TYPE_ETH_RX_ADPTR)
10563fc8de4fSPavan Nikhilesh return 0;
10573fc8de4fSPavan Nikhilesh
1058d9a42a69SThomas Monjalon if (!rte_eth_dev_count_avail()) {
10593fc8de4fSPavan Nikhilesh evt_err("No ethernet ports found.");
10603fc8de4fSPavan Nikhilesh return -ENODEV;
10613fc8de4fSPavan Nikhilesh }
10623fc8de4fSPavan Nikhilesh
10638728ccf3SThomas Monjalon RTE_ETH_FOREACH_DEV(i) {
10644f5701f2SFerruh Yigit struct rte_eth_dev_info dev_info;
10654f5701f2SFerruh Yigit struct rte_eth_conf local_port_conf = port_conf;
10663fc8de4fSPavan Nikhilesh
106777339255SIvan Ilchenko ret = rte_eth_dev_info_get(i, &dev_info);
106877339255SIvan Ilchenko if (ret != 0) {
106977339255SIvan Ilchenko evt_err("Error during getting device (port %u) info: %s\n",
107077339255SIvan Ilchenko i, strerror(-ret));
107177339255SIvan Ilchenko return ret;
107277339255SIvan Ilchenko }
10734f5701f2SFerruh Yigit
10744f5701f2SFerruh Yigit local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
10754f5701f2SFerruh Yigit dev_info.flow_type_rss_offloads;
10764f5701f2SFerruh Yigit if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
10774f5701f2SFerruh Yigit port_conf.rx_adv_conf.rss_conf.rss_hf) {
10784f5701f2SFerruh Yigit evt_info("Port %u modified RSS hash function based on hardware support,"
10794f5701f2SFerruh Yigit "requested:%#"PRIx64" configured:%#"PRIx64"\n",
10804f5701f2SFerruh Yigit i,
10814f5701f2SFerruh Yigit port_conf.rx_adv_conf.rss_conf.rss_hf,
10824f5701f2SFerruh Yigit local_port_conf.rx_adv_conf.rss_conf.rss_hf);
10834f5701f2SFerruh Yigit }
10844f5701f2SFerruh Yigit
10854f5701f2SFerruh Yigit if (rte_eth_dev_configure(i, 1, 1, &local_port_conf) < 0) {
10863fc8de4fSPavan Nikhilesh evt_err("Failed to configure eth port [%d]", i);
10873fc8de4fSPavan Nikhilesh return -EINVAL;
10883fc8de4fSPavan Nikhilesh }
10893fc8de4fSPavan Nikhilesh
10903fc8de4fSPavan Nikhilesh if (rte_eth_rx_queue_setup(i, 0, NB_RX_DESC,
10913fc8de4fSPavan Nikhilesh rte_socket_id(), NULL, t->pool) < 0) {
10923fc8de4fSPavan Nikhilesh evt_err("Failed to setup eth port [%d] rx_queue: %d.",
10933fc8de4fSPavan Nikhilesh i, 0);
10943fc8de4fSPavan Nikhilesh return -EINVAL;
10953fc8de4fSPavan Nikhilesh }
10963fc8de4fSPavan Nikhilesh
10973fc8de4fSPavan Nikhilesh if (rte_eth_tx_queue_setup(i, 0, NB_TX_DESC,
10983fc8de4fSPavan Nikhilesh rte_socket_id(), NULL) < 0) {
10993fc8de4fSPavan Nikhilesh evt_err("Failed to setup eth port [%d] tx_queue: %d.",
11003fc8de4fSPavan Nikhilesh i, 0);
11013fc8de4fSPavan Nikhilesh return -EINVAL;
11023fc8de4fSPavan Nikhilesh }
11033fc8de4fSPavan Nikhilesh
110470e51a0eSIvan Ilchenko ret = rte_eth_promiscuous_enable(i);
110570e51a0eSIvan Ilchenko if (ret != 0) {
110670e51a0eSIvan Ilchenko evt_err("Failed to enable promiscuous mode for eth port [%d]: %s",
110770e51a0eSIvan Ilchenko i, rte_strerror(-ret));
110870e51a0eSIvan Ilchenko return ret;
110970e51a0eSIvan Ilchenko }
11103fc8de4fSPavan Nikhilesh }
11113fc8de4fSPavan Nikhilesh
11123fc8de4fSPavan Nikhilesh return 0;
11133fc8de4fSPavan Nikhilesh }
11143fc8de4fSPavan Nikhilesh
1115a734e738SPavan Nikhilesh void
perf_ethdev_rx_stop(struct evt_test * test,struct evt_options * opt)1116a734e738SPavan Nikhilesh perf_ethdev_rx_stop(struct evt_test *test, struct evt_options *opt)
11177f3daf34SPavan Nikhilesh {
11188728ccf3SThomas Monjalon uint16_t i;
11197f3daf34SPavan Nikhilesh RTE_SET_USED(test);
11207f3daf34SPavan Nikhilesh
11217f3daf34SPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
11228728ccf3SThomas Monjalon RTE_ETH_FOREACH_DEV(i) {
11233617aae5SPavan Nikhilesh rte_event_eth_rx_adapter_stop(i);
1124a734e738SPavan Nikhilesh rte_event_eth_rx_adapter_queue_del(i, i, -1);
1125a734e738SPavan Nikhilesh rte_eth_dev_rx_queue_stop(i, 0);
1126a734e738SPavan Nikhilesh }
1127a734e738SPavan Nikhilesh }
1128a734e738SPavan Nikhilesh }
1129a734e738SPavan Nikhilesh
1130a734e738SPavan Nikhilesh void
perf_ethdev_destroy(struct evt_test * test,struct evt_options * opt)1131a734e738SPavan Nikhilesh perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
1132a734e738SPavan Nikhilesh {
1133a734e738SPavan Nikhilesh uint16_t i;
1134a734e738SPavan Nikhilesh RTE_SET_USED(test);
1135a734e738SPavan Nikhilesh
1136a734e738SPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
1137a734e738SPavan Nikhilesh RTE_ETH_FOREACH_DEV(i) {
1138a734e738SPavan Nikhilesh rte_event_eth_tx_adapter_stop(i);
1139a734e738SPavan Nikhilesh rte_event_eth_tx_adapter_queue_del(i, i, -1);
1140a734e738SPavan Nikhilesh rte_eth_dev_tx_queue_stop(i, 0);
11417f3daf34SPavan Nikhilesh rte_eth_dev_stop(i);
11427f3daf34SPavan Nikhilesh }
11437f3daf34SPavan Nikhilesh }
11447f3daf34SPavan Nikhilesh }
11457f3daf34SPavan Nikhilesh
114641c219e6SJerin Jacob int
perf_cryptodev_setup(struct evt_test * test,struct evt_options * opt)1147de2bc16eSShijith Thotton perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt)
1148de2bc16eSShijith Thotton {
1149de2bc16eSShijith Thotton uint8_t cdev_count, cdev_id, nb_plcores, nb_qps;
1150de2bc16eSShijith Thotton struct test_perf *t = evt_test_priv(test);
1151de2bc16eSShijith Thotton unsigned int max_session_size;
1152de2bc16eSShijith Thotton uint32_t nb_sessions;
1153de2bc16eSShijith Thotton int ret;
1154de2bc16eSShijith Thotton
1155de2bc16eSShijith Thotton if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
1156de2bc16eSShijith Thotton return 0;
1157de2bc16eSShijith Thotton
1158de2bc16eSShijith Thotton cdev_count = rte_cryptodev_count();
1159de2bc16eSShijith Thotton if (cdev_count == 0) {
1160de2bc16eSShijith Thotton evt_err("No crypto devices available\n");
1161de2bc16eSShijith Thotton return -ENODEV;
1162de2bc16eSShijith Thotton }
1163de2bc16eSShijith Thotton
1164de2bc16eSShijith Thotton t->ca_op_pool = rte_crypto_op_pool_create(
1165de2bc16eSShijith Thotton "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz,
1166de2bc16eSShijith Thotton 128, 0, rte_socket_id());
1167de2bc16eSShijith Thotton if (t->ca_op_pool == NULL) {
1168de2bc16eSShijith Thotton evt_err("Failed to create crypto op pool");
1169de2bc16eSShijith Thotton return -ENOMEM;
1170de2bc16eSShijith Thotton }
1171de2bc16eSShijith Thotton
1172de2bc16eSShijith Thotton nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows;
1173de2bc16eSShijith Thotton t->ca_sess_pool = rte_cryptodev_sym_session_pool_create(
1174de2bc16eSShijith Thotton "ca_sess_pool", nb_sessions, 0, 0,
1175de2bc16eSShijith Thotton sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY);
1176de2bc16eSShijith Thotton if (t->ca_sess_pool == NULL) {
1177de2bc16eSShijith Thotton evt_err("Failed to create sym session pool");
1178de2bc16eSShijith Thotton ret = -ENOMEM;
1179de2bc16eSShijith Thotton goto err;
1180de2bc16eSShijith Thotton }
1181de2bc16eSShijith Thotton
1182de2bc16eSShijith Thotton max_session_size = 0;
1183de2bc16eSShijith Thotton for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
1184de2bc16eSShijith Thotton unsigned int session_size;
1185de2bc16eSShijith Thotton
1186de2bc16eSShijith Thotton session_size =
1187de2bc16eSShijith Thotton rte_cryptodev_sym_get_private_session_size(cdev_id);
1188de2bc16eSShijith Thotton if (session_size > max_session_size)
1189de2bc16eSShijith Thotton max_session_size = session_size;
1190de2bc16eSShijith Thotton }
1191de2bc16eSShijith Thotton
1192de2bc16eSShijith Thotton max_session_size += sizeof(union rte_event_crypto_metadata);
1193de2bc16eSShijith Thotton t->ca_sess_priv_pool = rte_mempool_create(
1194de2bc16eSShijith Thotton "ca_sess_priv_pool", nb_sessions, max_session_size, 0, 0, NULL,
1195de2bc16eSShijith Thotton NULL, NULL, NULL, SOCKET_ID_ANY, 0);
1196de2bc16eSShijith Thotton if (t->ca_sess_priv_pool == NULL) {
1197de2bc16eSShijith Thotton evt_err("failed to create sym session private pool");
1198de2bc16eSShijith Thotton ret = -ENOMEM;
1199de2bc16eSShijith Thotton goto err;
1200de2bc16eSShijith Thotton }
1201de2bc16eSShijith Thotton
1202de2bc16eSShijith Thotton /*
1203de2bc16eSShijith Thotton * Calculate number of needed queue pairs, based on the amount of
1204de2bc16eSShijith Thotton * available number of logical cores and crypto devices. For instance,
1205de2bc16eSShijith Thotton * if there are 4 cores and 2 crypto devices, 2 queue pairs will be set
1206de2bc16eSShijith Thotton * up per device.
1207de2bc16eSShijith Thotton */
1208de2bc16eSShijith Thotton nb_plcores = evt_nr_active_lcores(opt->plcores);
1209de2bc16eSShijith Thotton nb_qps = (nb_plcores % cdev_count) ? (nb_plcores / cdev_count) + 1 :
1210de2bc16eSShijith Thotton nb_plcores / cdev_count;
1211de2bc16eSShijith Thotton for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
1212de2bc16eSShijith Thotton struct rte_cryptodev_qp_conf qp_conf;
1213de2bc16eSShijith Thotton struct rte_cryptodev_config conf;
1214de2bc16eSShijith Thotton struct rte_cryptodev_info info;
1215de2bc16eSShijith Thotton int qp_id;
1216de2bc16eSShijith Thotton
1217de2bc16eSShijith Thotton rte_cryptodev_info_get(cdev_id, &info);
1218de2bc16eSShijith Thotton if (nb_qps > info.max_nb_queue_pairs) {
1219de2bc16eSShijith Thotton evt_err("Not enough queue pairs per cryptodev (%u)",
1220de2bc16eSShijith Thotton nb_qps);
1221de2bc16eSShijith Thotton ret = -EINVAL;
1222de2bc16eSShijith Thotton goto err;
1223de2bc16eSShijith Thotton }
1224de2bc16eSShijith Thotton
1225de2bc16eSShijith Thotton conf.nb_queue_pairs = nb_qps;
1226de2bc16eSShijith Thotton conf.socket_id = SOCKET_ID_ANY;
1227de2bc16eSShijith Thotton conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
1228de2bc16eSShijith Thotton
1229de2bc16eSShijith Thotton ret = rte_cryptodev_configure(cdev_id, &conf);
1230de2bc16eSShijith Thotton if (ret) {
1231de2bc16eSShijith Thotton evt_err("Failed to configure cryptodev (%u)", cdev_id);
1232de2bc16eSShijith Thotton goto err;
1233de2bc16eSShijith Thotton }
1234de2bc16eSShijith Thotton
1235de2bc16eSShijith Thotton qp_conf.nb_descriptors = NB_CRYPTODEV_DESCRIPTORS;
1236de2bc16eSShijith Thotton qp_conf.mp_session = t->ca_sess_pool;
1237de2bc16eSShijith Thotton qp_conf.mp_session_private = t->ca_sess_priv_pool;
1238de2bc16eSShijith Thotton
1239de2bc16eSShijith Thotton for (qp_id = 0; qp_id < conf.nb_queue_pairs; qp_id++) {
1240de2bc16eSShijith Thotton ret = rte_cryptodev_queue_pair_setup(
1241de2bc16eSShijith Thotton cdev_id, qp_id, &qp_conf,
1242de2bc16eSShijith Thotton rte_cryptodev_socket_id(cdev_id));
1243de2bc16eSShijith Thotton if (ret) {
1244de2bc16eSShijith Thotton evt_err("Failed to setup queue pairs on cryptodev %u\n",
1245de2bc16eSShijith Thotton cdev_id);
1246de2bc16eSShijith Thotton goto err;
1247de2bc16eSShijith Thotton }
1248de2bc16eSShijith Thotton }
1249de2bc16eSShijith Thotton }
1250de2bc16eSShijith Thotton
1251de2bc16eSShijith Thotton return 0;
1252de2bc16eSShijith Thotton err:
1253de2bc16eSShijith Thotton for (cdev_id = 0; cdev_id < cdev_count; cdev_id++)
1254de2bc16eSShijith Thotton rte_cryptodev_close(cdev_id);
1255de2bc16eSShijith Thotton
1256de2bc16eSShijith Thotton rte_mempool_free(t->ca_op_pool);
1257de2bc16eSShijith Thotton rte_mempool_free(t->ca_sess_pool);
1258de2bc16eSShijith Thotton rte_mempool_free(t->ca_sess_priv_pool);
1259de2bc16eSShijith Thotton
1260de2bc16eSShijith Thotton return ret;
1261de2bc16eSShijith Thotton }
1262de2bc16eSShijith Thotton
1263de2bc16eSShijith Thotton void
perf_cryptodev_destroy(struct evt_test * test,struct evt_options * opt)1264de2bc16eSShijith Thotton perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt)
1265de2bc16eSShijith Thotton {
1266de2bc16eSShijith Thotton uint8_t cdev_id, cdev_count = rte_cryptodev_count();
1267de2bc16eSShijith Thotton struct test_perf *t = evt_test_priv(test);
1268de2bc16eSShijith Thotton uint16_t port;
1269de2bc16eSShijith Thotton
1270de2bc16eSShijith Thotton if (opt->prod_type != EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR)
1271de2bc16eSShijith Thotton return;
1272de2bc16eSShijith Thotton
1273de2bc16eSShijith Thotton for (port = t->nb_workers; port < perf_nb_event_ports(opt); port++) {
1274de2bc16eSShijith Thotton struct rte_cryptodev_sym_session *sess;
1275de2bc16eSShijith Thotton struct prod_data *p = &t->prod[port];
1276de2bc16eSShijith Thotton uint32_t flow_id;
1277de2bc16eSShijith Thotton uint8_t cdev_id;
1278de2bc16eSShijith Thotton
1279de2bc16eSShijith Thotton for (flow_id = 0; flow_id < t->nb_flows; flow_id++) {
1280de2bc16eSShijith Thotton sess = p->ca.crypto_sess[flow_id];
1281de2bc16eSShijith Thotton cdev_id = p->ca.cdev_id;
1282de2bc16eSShijith Thotton rte_cryptodev_sym_session_clear(cdev_id, sess);
1283de2bc16eSShijith Thotton rte_cryptodev_sym_session_free(sess);
1284de2bc16eSShijith Thotton }
1285de2bc16eSShijith Thotton
1286de2bc16eSShijith Thotton rte_event_crypto_adapter_queue_pair_del(
1287de2bc16eSShijith Thotton TEST_PERF_CA_ID, p->ca.cdev_id, p->ca.cdev_qp_id);
1288de2bc16eSShijith Thotton }
1289de2bc16eSShijith Thotton
1290de2bc16eSShijith Thotton rte_event_crypto_adapter_free(TEST_PERF_CA_ID);
1291de2bc16eSShijith Thotton
1292de2bc16eSShijith Thotton for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
1293de2bc16eSShijith Thotton rte_cryptodev_stop(cdev_id);
1294de2bc16eSShijith Thotton rte_cryptodev_close(cdev_id);
1295de2bc16eSShijith Thotton }
1296de2bc16eSShijith Thotton
1297de2bc16eSShijith Thotton rte_mempool_free(t->ca_op_pool);
1298de2bc16eSShijith Thotton rte_mempool_free(t->ca_sess_pool);
1299de2bc16eSShijith Thotton rte_mempool_free(t->ca_sess_priv_pool);
1300de2bc16eSShijith Thotton }
1301de2bc16eSShijith Thotton
1302de2bc16eSShijith Thotton int
perf_mempool_setup(struct evt_test * test,struct evt_options * opt)130341c219e6SJerin Jacob perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
130441c219e6SJerin Jacob {
130541c219e6SJerin Jacob struct test_perf *t = evt_test_priv(test);
130641c219e6SJerin Jacob
1307d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_SYNT ||
1308d008f20bSPavan Nikhilesh opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
130941c219e6SJerin Jacob t->pool = rte_mempool_create(test->name, /* mempool name */
131041c219e6SJerin Jacob opt->pool_sz, /* number of elements*/
131141c219e6SJerin Jacob sizeof(struct perf_elt), /* element size*/
131241c219e6SJerin Jacob 512, /* cache size*/
131341c219e6SJerin Jacob 0, NULL, NULL,
131441c219e6SJerin Jacob perf_elt_init, /* obj constructor */
131541c219e6SJerin Jacob NULL, opt->socket_id, 0); /* flags */
13168577cc1aSPavan Nikhilesh } else {
13178577cc1aSPavan Nikhilesh t->pool = rte_pktmbuf_pool_create(test->name, /* mempool name */
13188577cc1aSPavan Nikhilesh opt->pool_sz, /* number of elements*/
13198577cc1aSPavan Nikhilesh 512, /* cache size*/
13208577cc1aSPavan Nikhilesh 0,
13218577cc1aSPavan Nikhilesh RTE_MBUF_DEFAULT_BUF_SIZE,
13228577cc1aSPavan Nikhilesh opt->socket_id); /* flags */
13238577cc1aSPavan Nikhilesh
13248577cc1aSPavan Nikhilesh }
13258577cc1aSPavan Nikhilesh
132641c219e6SJerin Jacob if (t->pool == NULL) {
132741c219e6SJerin Jacob evt_err("failed to create mempool");
132841c219e6SJerin Jacob return -ENOMEM;
132941c219e6SJerin Jacob }
133041c219e6SJerin Jacob
133141c219e6SJerin Jacob return 0;
133241c219e6SJerin Jacob }
133341c219e6SJerin Jacob
133441c219e6SJerin Jacob void
perf_mempool_destroy(struct evt_test * test,struct evt_options * opt)133541c219e6SJerin Jacob perf_mempool_destroy(struct evt_test *test, struct evt_options *opt)
133641c219e6SJerin Jacob {
133741c219e6SJerin Jacob RTE_SET_USED(opt);
133841c219e6SJerin Jacob struct test_perf *t = evt_test_priv(test);
133941c219e6SJerin Jacob
134041c219e6SJerin Jacob rte_mempool_free(t->pool);
134141c219e6SJerin Jacob }
1342ffbae86fSJerin Jacob
1343ffbae86fSJerin Jacob int
perf_test_setup(struct evt_test * test,struct evt_options * opt)1344ffbae86fSJerin Jacob perf_test_setup(struct evt_test *test, struct evt_options *opt)
1345ffbae86fSJerin Jacob {
1346ffbae86fSJerin Jacob void *test_perf;
1347ffbae86fSJerin Jacob
1348ffbae86fSJerin Jacob test_perf = rte_zmalloc_socket(test->name, sizeof(struct test_perf),
1349ffbae86fSJerin Jacob RTE_CACHE_LINE_SIZE, opt->socket_id);
1350ffbae86fSJerin Jacob if (test_perf == NULL) {
1351ffbae86fSJerin Jacob evt_err("failed to allocate test_perf memory");
1352ffbae86fSJerin Jacob goto nomem;
1353ffbae86fSJerin Jacob }
1354ffbae86fSJerin Jacob test->test_priv = test_perf;
1355ffbae86fSJerin Jacob
1356ffbae86fSJerin Jacob struct test_perf *t = evt_test_priv(test);
1357ffbae86fSJerin Jacob
1358d008f20bSPavan Nikhilesh if (opt->prod_type == EVT_PROD_TYPE_EVENT_TIMER_ADPTR) {
1359d008f20bSPavan Nikhilesh t->outstand_pkts = opt->nb_timers *
1360d008f20bSPavan Nikhilesh evt_nr_active_lcores(opt->plcores);
1361d008f20bSPavan Nikhilesh t->nb_pkts = opt->nb_timers;
1362d008f20bSPavan Nikhilesh } else {
1363d008f20bSPavan Nikhilesh t->outstand_pkts = opt->nb_pkts *
1364d008f20bSPavan Nikhilesh evt_nr_active_lcores(opt->plcores);
1365d008f20bSPavan Nikhilesh t->nb_pkts = opt->nb_pkts;
1366d008f20bSPavan Nikhilesh }
1367d008f20bSPavan Nikhilesh
1368ffbae86fSJerin Jacob t->nb_workers = evt_nr_active_lcores(opt->wlcores);
1369ffbae86fSJerin Jacob t->done = false;
1370ffbae86fSJerin Jacob t->nb_flows = opt->nb_flows;
1371ffbae86fSJerin Jacob t->result = EVT_TEST_FAILED;
1372ffbae86fSJerin Jacob t->opt = opt;
1373ffbae86fSJerin Jacob memcpy(t->sched_type_list, opt->sched_type_list,
1374ffbae86fSJerin Jacob sizeof(opt->sched_type_list));
1375ffbae86fSJerin Jacob return 0;
1376ffbae86fSJerin Jacob nomem:
1377ffbae86fSJerin Jacob return -ENOMEM;
1378ffbae86fSJerin Jacob }
1379ffbae86fSJerin Jacob
1380ffbae86fSJerin Jacob void
perf_test_destroy(struct evt_test * test,struct evt_options * opt)1381ffbae86fSJerin Jacob perf_test_destroy(struct evt_test *test, struct evt_options *opt)
1382ffbae86fSJerin Jacob {
1383ffbae86fSJerin Jacob RTE_SET_USED(opt);
1384ffbae86fSJerin Jacob
1385ffbae86fSJerin Jacob rte_free(test->test_priv);
1386ffbae86fSJerin Jacob }
1387