4 * Copyright (C) Cavium, Inc 2017.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Cavium, Inc nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #include <rte_common.h>
40 #include <rte_eventdev.h>
41 #include <rte_lcore.h>
43 #include "evt_common.h"
45 #define EVT_BOOL_FMT(x) ((x) ? "true" : "false")
47 #define EVT_VERBOSE ("verbose")
48 #define EVT_DEVICE ("dev")
49 #define EVT_TEST ("test")
50 #define EVT_PROD_LCORES ("plcores")
51 #define EVT_WORK_LCORES ("wlcores")
52 #define EVT_NB_FLOWS ("nb_flows")
53 #define EVT_SOCKET_ID ("socket_id")
54 #define EVT_POOL_SZ ("pool_sz")
55 #define EVT_WKR_DEQ_DEP ("worker_deq_depth")
56 #define EVT_NB_PKTS ("nb_pkts")
57 #define EVT_NB_STAGES ("nb_stages")
58 #define EVT_SCHED_TYPE_LIST ("stlist")
59 #define EVT_FWD_LATENCY ("fwd_latency")
60 #define EVT_QUEUE_PRIORITY ("queue_priority")
61 #define EVT_HELP ("help")
64 #define EVT_TEST_NAME_MAX_LEN 32
65 char test_name[EVT_TEST_NAME_MAX_LEN];
66 bool plcores[RTE_MAX_LCORE];
67 bool wlcores[RTE_MAX_LCORE];
68 uint8_t sched_type_list[EVT_MAX_STAGES];
77 uint32_t fwd_latency:1;
78 uint32_t q_priority:1;
81 void evt_options_default(struct evt_options *opt);
82 int evt_options_parse(struct evt_options *opt, int argc, char **argv);
83 void evt_options_dump(struct evt_options *opt);
85 /* options check helpers */
87 evt_lcores_has_overlap(bool lcores[], int lcore)
89 if (lcores[lcore] == true) {
90 evt_err("lcore overlaps at %d", lcore);
98 evt_lcores_has_overlap_multi(bool lcoresx[], bool lcoresy[])
102 for (i = 0; i < RTE_MAX_LCORE; i++) {
103 if (lcoresx[i] && lcoresy[i]) {
104 evt_err("lcores overlaps at %d", i);
112 evt_has_active_lcore(bool lcores[])
116 for (i = 0; i < RTE_MAX_LCORE; i++)
123 evt_nr_active_lcores(bool lcores[])
128 for (i = 0; i < RTE_MAX_LCORE; i++)
135 evt_get_first_active_lcore(bool lcores[])
139 for (i = 0; i < RTE_MAX_LCORE; i++)
146 evt_has_disabled_lcore(bool lcores[])
150 for (i = 0; i < RTE_MAX_LCORE; i++)
151 if ((lcores[i] == true) && !(rte_lcore_is_enabled(i)))
157 evt_has_invalid_stage(struct evt_options *opt)
159 if (!opt->nb_stages) {
160 evt_err("need minimum one stage, check --stlist");
163 if (opt->nb_stages > EVT_MAX_STAGES) {
164 evt_err("requested changes are beyond EVT_MAX_STAGES=%d",
172 evt_has_invalid_sched_type(struct evt_options *opt)
176 for (i = 0; i < opt->nb_stages; i++) {
177 if (opt->sched_type_list[i] > RTE_SCHED_TYPE_PARALLEL) {
178 evt_err("invalid sched_type %d at %d",
179 opt->sched_type_list[i], i);
186 /* option dump helpers */
188 evt_dump_worker_lcores(struct evt_options *opt)
192 evt_dump_begin("worker lcores");
193 for (c = 0; c < RTE_MAX_LCORE; c++) {
201 evt_dump_producer_lcores(struct evt_options *opt)
205 evt_dump_begin("producer lcores");
206 for (c = 0; c < RTE_MAX_LCORE; c++) {
214 evt_dump_nb_flows(struct evt_options *opt)
216 evt_dump("nb_flows", "%d", opt->nb_flows);
220 evt_dump_worker_dequeue_depth(struct evt_options *opt)
222 evt_dump("worker deq depth", "%d", opt->wkr_deq_dep);
226 evt_dump_nb_stages(struct evt_options *opt)
228 evt_dump("nb_stages", "%d", opt->nb_stages);
232 evt_dump_fwd_latency(struct evt_options *opt)
234 evt_dump("fwd_latency", "%s", EVT_BOOL_FMT(opt->fwd_latency));
238 evt_dump_queue_priority(struct evt_options *opt)
240 evt_dump("queue_priority", "%s", EVT_BOOL_FMT(opt->q_priority));
243 static inline const char*
244 evt_sched_type_2_str(uint8_t sched_type)
247 if (sched_type == RTE_SCHED_TYPE_ORDERED)
249 else if (sched_type == RTE_SCHED_TYPE_ATOMIC)
251 else if (sched_type == RTE_SCHED_TYPE_PARALLEL)
258 evt_dump_sched_type_list(struct evt_options *opt)
262 evt_dump_begin("sched_type_list");
263 for (i = 0; i < opt->nb_stages; i++)
264 printf("%s ", evt_sched_type_2_str(opt->sched_type_list[i]));
269 #endif /* _EVT_OPTIONS_ */