1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
5 #ifndef _TEST_PERF_COMMON_
6 #define _TEST_PERF_COMMON_
12 #include <rte_cycles.h>
13 #include <rte_ethdev.h>
14 #include <rte_eventdev.h>
15 #include <rte_lcore.h>
16 #include <rte_malloc.h>
17 #include <rte_mempool.h>
18 #include <rte_prefetch.h>
20 #include "evt_common.h"
21 #include "evt_options.h"
27 uint64_t processed_pkts;
32 } __rte_cache_aligned;
39 } __rte_cache_aligned;
42 /* Don't change the offset of "done". Signal handler use this memory
43 * to terminate all lcores work.
46 uint64_t outstand_pkts;
48 enum evt_test_result result;
51 struct rte_mempool *pool;
52 struct prod_data prod[EVT_MAX_PORTS];
53 struct worker_data worker[EVT_MAX_PORTS];
54 struct evt_options *opt;
55 uint8_t sched_type_list[EVT_MAX_STAGES] __rte_cache_aligned;
56 } __rte_cache_aligned;
60 } __rte_cache_aligned;
64 #define PERF_WORKER_INIT\
65 struct worker_data *w = arg;\
66 struct test_perf *t = w->t;\
67 struct evt_options *opt = t->opt;\
68 const uint8_t dev = w->dev_id;\
69 const uint8_t port = w->port_id;\
70 uint8_t *const sched_type_list = &t->sched_type_list[0];\
71 struct rte_mempool *const pool = t->pool;\
72 const uint8_t nb_stages = t->opt->nb_stages;\
73 const uint8_t laststage = nb_stages - 1;\
75 void *bufs[16] __rte_cache_aligned;\
76 int const sz = RTE_DIM(bufs);\
77 if (opt->verbose_level > 1)\
78 printf("%s(): lcore %d dev_id %d port=%d\n", __func__,\
79 rte_lcore_id(), dev, port)
81 static inline __attribute__((always_inline)) int
82 perf_process_last_stage(struct rte_mempool *const pool,
83 struct rte_event *const ev, struct worker_data *const w,
84 void *bufs[], int const buf_sz, uint8_t count)
86 bufs[count++] = ev->event_ptr;
90 if (unlikely(count == buf_sz)) {
92 rte_mempool_put_bulk(pool, bufs, buf_sz);
97 static inline __attribute__((always_inline)) uint8_t
98 perf_process_last_stage_latency(struct rte_mempool *const pool,
99 struct rte_event *const ev, struct worker_data *const w,
100 void *bufs[], int const buf_sz, uint8_t count)
103 struct perf_elt *const m = ev->event_ptr;
105 bufs[count++] = ev->event_ptr;
108 if (unlikely(count == buf_sz)) {
110 latency = rte_get_timer_cycles() - m->timestamp;
111 rte_mempool_put_bulk(pool, bufs, buf_sz);
113 latency = rte_get_timer_cycles() - m->timestamp;
116 w->latency += latency;
123 perf_nb_event_ports(struct evt_options *opt)
125 return evt_nr_active_lcores(opt->wlcores) +
126 evt_nr_active_lcores(opt->plcores);
129 int perf_test_result(struct evt_test *test, struct evt_options *opt);
130 int perf_opt_check(struct evt_options *opt, uint64_t nb_queues);
131 int perf_test_setup(struct evt_test *test, struct evt_options *opt);
132 int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt);
133 int perf_mempool_setup(struct evt_test *test, struct evt_options *opt);
134 int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt,
135 uint8_t stride, uint8_t nb_queues);
136 int perf_event_dev_service_setup(uint8_t dev_id);
137 int perf_launch_lcores(struct evt_test *test, struct evt_options *opt,
138 int (*worker)(void *));
139 void perf_opt_dump(struct evt_options *opt, uint8_t nb_queues);
140 void perf_test_destroy(struct evt_test *test, struct evt_options *opt);
141 void perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt);
142 void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt);
143 void perf_mempool_destroy(struct evt_test *test, struct evt_options *opt);
145 #endif /* _TEST_PERF_COMMON_ */