1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
11 #include <rte_common.h>
12 #include <rte_eventdev.h>
13 #include <rte_lcore.h>
15 #include "evt_common.h"
17 #define EVT_BOOL_FMT(x) ((x) ? "true" : "false")
19 #define EVT_VERBOSE ("verbose")
20 #define EVT_DEVICE ("dev")
21 #define EVT_TEST ("test")
22 #define EVT_PROD_LCORES ("plcores")
23 #define EVT_WORK_LCORES ("wlcores")
24 #define EVT_NB_FLOWS ("nb_flows")
25 #define EVT_SOCKET_ID ("socket_id")
26 #define EVT_POOL_SZ ("pool_sz")
27 #define EVT_WKR_DEQ_DEP ("worker_deq_depth")
28 #define EVT_NB_PKTS ("nb_pkts")
29 #define EVT_NB_STAGES ("nb_stages")
30 #define EVT_SCHED_TYPE_LIST ("stlist")
31 #define EVT_FWD_LATENCY ("fwd_latency")
32 #define EVT_QUEUE_PRIORITY ("queue_priority")
33 #define EVT_PROD_ETHDEV ("prod_type_ethdev")
34 #define EVT_HELP ("help")
38 EVT_PROD_TYPE_SYNT, /* Producer type Synthetic i.e. CPU. */
39 EVT_PROD_TYPE_ETH_RX_ADPTR, /* Producer type Eth Rx Adapter. */
44 #define EVT_TEST_NAME_MAX_LEN 32
45 char test_name[EVT_TEST_NAME_MAX_LEN];
46 bool plcores[RTE_MAX_LCORE];
47 bool wlcores[RTE_MAX_LCORE];
48 uint8_t sched_type_list[EVT_MAX_STAGES];
57 uint32_t fwd_latency:1;
58 uint32_t q_priority:1;
59 enum evt_prod_type prod_type;
62 void evt_options_default(struct evt_options *opt);
63 int evt_options_parse(struct evt_options *opt, int argc, char **argv);
64 void evt_options_dump(struct evt_options *opt);
66 /* options check helpers */
68 evt_lcores_has_overlap(bool lcores[], int lcore)
70 if (lcores[lcore] == true) {
71 evt_err("lcore overlaps at %d", lcore);
79 evt_lcores_has_overlap_multi(bool lcoresx[], bool lcoresy[])
83 for (i = 0; i < RTE_MAX_LCORE; i++) {
84 if (lcoresx[i] && lcoresy[i]) {
85 evt_err("lcores overlaps at %d", i);
93 evt_has_active_lcore(bool lcores[])
97 for (i = 0; i < RTE_MAX_LCORE; i++)
104 evt_nr_active_lcores(bool lcores[])
109 for (i = 0; i < RTE_MAX_LCORE; i++)
116 evt_get_first_active_lcore(bool lcores[])
120 for (i = 0; i < RTE_MAX_LCORE; i++)
127 evt_has_disabled_lcore(bool lcores[])
131 for (i = 0; i < RTE_MAX_LCORE; i++)
132 if ((lcores[i] == true) && !(rte_lcore_is_enabled(i)))
138 evt_has_invalid_stage(struct evt_options *opt)
140 if (!opt->nb_stages) {
141 evt_err("need minimum one stage, check --stlist");
144 if (opt->nb_stages > EVT_MAX_STAGES) {
145 evt_err("requested changes are beyond EVT_MAX_STAGES=%d",
153 evt_has_invalid_sched_type(struct evt_options *opt)
157 for (i = 0; i < opt->nb_stages; i++) {
158 if (opt->sched_type_list[i] > RTE_SCHED_TYPE_PARALLEL) {
159 evt_err("invalid sched_type %d at %d",
160 opt->sched_type_list[i], i);
167 /* option dump helpers */
169 evt_dump_worker_lcores(struct evt_options *opt)
173 evt_dump_begin("worker lcores");
174 for (c = 0; c < RTE_MAX_LCORE; c++) {
182 evt_dump_producer_lcores(struct evt_options *opt)
186 evt_dump_begin("producer lcores");
187 for (c = 0; c < RTE_MAX_LCORE; c++) {
195 evt_dump_nb_flows(struct evt_options *opt)
197 evt_dump("nb_flows", "%d", opt->nb_flows);
201 evt_dump_worker_dequeue_depth(struct evt_options *opt)
203 evt_dump("worker deq depth", "%d", opt->wkr_deq_dep);
207 evt_dump_nb_stages(struct evt_options *opt)
209 evt_dump("nb_stages", "%d", opt->nb_stages);
213 evt_dump_fwd_latency(struct evt_options *opt)
215 evt_dump("fwd_latency", "%s", EVT_BOOL_FMT(opt->fwd_latency));
219 evt_dump_queue_priority(struct evt_options *opt)
221 evt_dump("queue_priority", "%s", EVT_BOOL_FMT(opt->q_priority));
224 static inline const char*
225 evt_sched_type_2_str(uint8_t sched_type)
228 if (sched_type == RTE_SCHED_TYPE_ORDERED)
230 else if (sched_type == RTE_SCHED_TYPE_ATOMIC)
232 else if (sched_type == RTE_SCHED_TYPE_PARALLEL)
239 evt_dump_sched_type_list(struct evt_options *opt)
243 evt_dump_begin("sched_type_list");
244 for (i = 0; i < opt->nb_stages; i++)
245 printf("%s ", evt_sched_type_2_str(opt->sched_type_list[i]));
250 #define EVT_PROD_MAX_NAME_LEN 50
252 evt_dump_producer_type(struct evt_options *opt)
254 char name[EVT_PROD_MAX_NAME_LEN];
256 switch (opt->prod_type) {
258 case EVT_PROD_TYPE_SYNT:
259 snprintf(name, EVT_PROD_MAX_NAME_LEN,
260 "Synthetic producer lcores");
262 case EVT_PROD_TYPE_ETH_RX_ADPTR:
263 snprintf(name, EVT_PROD_MAX_NAME_LEN,
264 "Ethdev Rx Adapter producers");
267 evt_dump("prod_type", "%s", name);
270 #endif /* _EVT_OPTIONS_ */