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_SCHED_LCORE ("slcore")
51 #define EVT_PROD_LCORES ("plcores")
52 #define EVT_WORK_LCORES ("wlcores")
53 #define EVT_NB_FLOWS ("nb_flows")
54 #define EVT_SOCKET_ID ("socket_id")
55 #define EVT_POOL_SZ ("pool_sz")
56 #define EVT_WKR_DEQ_DEP ("worker_deq_depth")
57 #define EVT_NB_PKTS ("nb_pkts")
58 #define EVT_NB_STAGES ("nb_stages")
59 #define EVT_SCHED_TYPE_LIST ("stlist")
60 #define EVT_FWD_LATENCY ("fwd_latency")
61 #define EVT_QUEUE_PRIORITY ("queue_priority")
62 #define EVT_HELP ("help")
65 #define EVT_TEST_NAME_MAX_LEN 32
66 char test_name[EVT_TEST_NAME_MAX_LEN];
67 bool plcores[RTE_MAX_LCORE];
68 bool wlcores[RTE_MAX_LCORE];
69 uint8_t sched_type_list[EVT_MAX_STAGES];
79 uint32_t fwd_latency:1;
80 uint32_t q_priority:1;
83 void evt_options_default(struct evt_options *opt);
84 int evt_options_parse(struct evt_options *opt, int argc, char **argv);
85 void evt_options_dump(struct evt_options *opt);
87 /* options check helpers */
89 evt_lcores_has_overlap(bool lcores[], int lcore)
91 if (lcores[lcore] == true) {
92 evt_err("lcore overlaps at %d", lcore);
100 evt_lcores_has_overlap_multi(bool lcoresx[], bool lcoresy[])
104 for (i = 0; i < RTE_MAX_LCORE; i++) {
105 if (lcoresx[i] && lcoresy[i]) {
106 evt_err("lcores overlaps at %d", i);
114 evt_has_active_lcore(bool lcores[])
118 for (i = 0; i < RTE_MAX_LCORE; i++)
125 evt_nr_active_lcores(bool lcores[])
130 for (i = 0; i < RTE_MAX_LCORE; i++)
137 evt_get_first_active_lcore(bool lcores[])
141 for (i = 0; i < RTE_MAX_LCORE; i++)
148 evt_has_disabled_lcore(bool lcores[])
152 for (i = 0; i < RTE_MAX_LCORE; i++)
153 if ((lcores[i] == true) && !(rte_lcore_is_enabled(i)))
159 evt_has_invalid_stage(struct evt_options *opt)
161 if (!opt->nb_stages) {
162 evt_err("need minimum one stage, check --stlist");
165 if (opt->nb_stages > EVT_MAX_STAGES) {
166 evt_err("requested changes are beyond EVT_MAX_STAGES=%d",
174 evt_has_invalid_sched_type(struct evt_options *opt)
178 for (i = 0; i < opt->nb_stages; i++) {
179 if (opt->sched_type_list[i] > RTE_SCHED_TYPE_PARALLEL) {
180 evt_err("invalid sched_type %d at %d",
181 opt->sched_type_list[i], i);
188 /* option dump helpers */
190 evt_dump_worker_lcores(struct evt_options *opt)
194 evt_dump_begin("worker lcores");
195 for (c = 0; c < RTE_MAX_LCORE; c++) {
203 evt_dump_producer_lcores(struct evt_options *opt)
207 evt_dump_begin("producer lcores");
208 for (c = 0; c < RTE_MAX_LCORE; c++) {
216 evt_dump_nb_flows(struct evt_options *opt)
218 evt_dump("nb_flows", "%d", opt->nb_flows);
222 evt_dump_scheduler_lcore(struct evt_options *opt)
224 evt_dump("scheduler lcore", "%d", opt->slcore);
228 evt_dump_worker_dequeue_depth(struct evt_options *opt)
230 evt_dump("worker deq depth", "%d", opt->wkr_deq_dep);
234 evt_dump_nb_stages(struct evt_options *opt)
236 evt_dump("nb_stages", "%d", opt->nb_stages);
240 evt_dump_fwd_latency(struct evt_options *opt)
242 evt_dump("fwd_latency", "%s", EVT_BOOL_FMT(opt->fwd_latency));
246 evt_dump_queue_priority(struct evt_options *opt)
248 evt_dump("queue_priority", "%s", EVT_BOOL_FMT(opt->q_priority));
251 static inline const char*
252 evt_sched_type_2_str(uint8_t sched_type)
255 if (sched_type == RTE_SCHED_TYPE_ORDERED)
257 else if (sched_type == RTE_SCHED_TYPE_ATOMIC)
259 else if (sched_type == RTE_SCHED_TYPE_PARALLEL)
266 evt_dump_sched_type_list(struct evt_options *opt)
270 evt_dump_begin("sched_type_list");
271 for (i = 0; i < opt->nb_stages; i++)
272 printf("%s ", evt_sched_type_2_str(opt->sched_type_list[i]));
277 #endif /* _EVT_OPTIONS_ */