4 * Copyright (C) Cavium 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 networks 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.
33 #include "test_perf_common.h"
36 perf_test_result(struct evt_test *test, struct evt_options *opt)
39 struct test_perf *t = evt_test_priv(test);
45 perf_opt_check(struct evt_options *opt, uint64_t nb_queues)
48 bool need_slcore = !evt_has_distributed_sched(opt->dev_id);
50 /* N producer + N worker + 1 scheduler(based on dev capa) + 1 master */
51 lcores = need_slcore ? 4 : 3;
53 if (rte_lcore_count() < lcores) {
54 evt_err("test need minimum %d lcores", lcores);
58 /* Validate worker lcores */
59 if (evt_lcores_has_overlap(opt->wlcores, rte_get_master_lcore())) {
60 evt_err("worker lcores overlaps with master lcore");
63 if (need_slcore && evt_lcores_has_overlap(opt->wlcores, opt->slcore)) {
64 evt_err("worker lcores overlaps with scheduler lcore");
67 if (evt_lcores_has_overlap_multi(opt->wlcores, opt->plcores)) {
68 evt_err("worker lcores overlaps producer lcores");
71 if (evt_has_disabled_lcore(opt->wlcores)) {
72 evt_err("one or more workers lcores are not enabled");
75 if (!evt_has_active_lcore(opt->wlcores)) {
76 evt_err("minimum one worker is required");
80 /* Validate producer lcores */
81 if (evt_lcores_has_overlap(opt->plcores, rte_get_master_lcore())) {
82 evt_err("producer lcores overlaps with master lcore");
85 if (need_slcore && evt_lcores_has_overlap(opt->plcores, opt->slcore)) {
86 evt_err("producer lcores overlaps with scheduler lcore");
89 if (evt_has_disabled_lcore(opt->plcores)) {
90 evt_err("one or more producer lcores are not enabled");
93 if (!evt_has_active_lcore(opt->plcores)) {
94 evt_err("minimum one producer is required");
98 /* Validate scheduler lcore */
99 if (!evt_has_distributed_sched(opt->dev_id) &&
100 opt->slcore == (int)rte_get_master_lcore()) {
101 evt_err("scheduler lcore and master lcore should be different");
104 if (need_slcore && !rte_lcore_is_enabled(opt->slcore)) {
105 evt_err("scheduler lcore is not enabled");
109 if (evt_has_invalid_stage(opt))
112 if (evt_has_invalid_sched_type(opt))
115 if (nb_queues > EVT_MAX_QUEUES) {
116 evt_err("number of queues exceeds %d", EVT_MAX_QUEUES);
119 if (perf_nb_event_ports(opt) > EVT_MAX_PORTS) {
120 evt_err("number of ports exceeds %d", EVT_MAX_PORTS);
125 if (opt->nb_stages == 1 && opt->fwd_latency) {
126 evt_info("fwd_latency is valid when nb_stages > 1, disabling");
127 opt->fwd_latency = 0;
129 if (opt->fwd_latency && !opt->q_priority) {
130 evt_info("enabled queue priority for latency measurement");
138 perf_opt_dump(struct evt_options *opt, uint8_t nb_queues)
140 evt_dump("nb_prod_lcores", "%d", evt_nr_active_lcores(opt->plcores));
141 evt_dump_producer_lcores(opt);
142 evt_dump("nb_worker_lcores", "%d", evt_nr_active_lcores(opt->wlcores));
143 evt_dump_worker_lcores(opt);
144 if (!evt_has_distributed_sched(opt->dev_id))
145 evt_dump_scheduler_lcore(opt);
146 evt_dump_nb_stages(opt);
147 evt_dump("nb_evdev_ports", "%d", perf_nb_event_ports(opt));
148 evt_dump("nb_evdev_queues", "%d", nb_queues);
149 evt_dump_queue_priority(opt);
150 evt_dump_sched_type_list(opt);
154 perf_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
158 rte_event_dev_stop(opt->dev_id);
159 rte_event_dev_close(opt->dev_id);
163 perf_elt_init(struct rte_mempool *mp, void *arg __rte_unused,
164 void *obj, unsigned i __rte_unused)
166 memset(obj, 0, mp->elt_size);
170 perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
172 struct test_perf *t = evt_test_priv(test);
174 t->pool = rte_mempool_create(test->name, /* mempool name */
175 opt->pool_sz, /* number of elements*/
176 sizeof(struct perf_elt), /* element size*/
179 perf_elt_init, /* obj constructor */
180 NULL, opt->socket_id, 0); /* flags */
181 if (t->pool == NULL) {
182 evt_err("failed to create mempool");
190 perf_mempool_destroy(struct evt_test *test, struct evt_options *opt)
193 struct test_perf *t = evt_test_priv(test);
195 rte_mempool_free(t->pool);
199 perf_test_setup(struct evt_test *test, struct evt_options *opt)
203 test_perf = rte_zmalloc_socket(test->name, sizeof(struct test_perf),
204 RTE_CACHE_LINE_SIZE, opt->socket_id);
205 if (test_perf == NULL) {
206 evt_err("failed to allocate test_perf memory");
209 test->test_priv = test_perf;
211 struct test_perf *t = evt_test_priv(test);
213 t->outstand_pkts = opt->nb_pkts * evt_nr_active_lcores(opt->plcores);
214 t->nb_workers = evt_nr_active_lcores(opt->wlcores);
216 t->nb_pkts = opt->nb_pkts;
217 t->nb_flows = opt->nb_flows;
218 t->result = EVT_TEST_FAILED;
220 memcpy(t->sched_type_list, opt->sched_type_list,
221 sizeof(opt->sched_type_list));
228 perf_test_destroy(struct evt_test *test, struct evt_options *opt)
232 rte_free(test->test_priv);