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_order_common.h"
36 order_test_result(struct evt_test *test, struct evt_options *opt)
39 struct test_order *t = evt_test_priv(test);
45 order_opt_check(struct evt_options *opt)
47 /* 1 producer + N workers + 1 master */
48 if (rte_lcore_count() < 3) {
49 evt_err("test need minimum 3 lcores");
53 /* Validate worker lcores */
54 if (evt_lcores_has_overlap(opt->wlcores, rte_get_master_lcore())) {
55 evt_err("worker lcores overlaps with master lcore");
59 if (evt_nr_active_lcores(opt->plcores) == 0) {
60 evt_err("missing the producer lcore");
64 if (evt_nr_active_lcores(opt->plcores) != 1) {
65 evt_err("only one producer lcore must be selected");
69 int plcore = evt_get_first_active_lcore(opt->plcores);
72 evt_err("failed to find active producer");
76 if (evt_lcores_has_overlap(opt->wlcores, plcore)) {
77 evt_err("worker lcores overlaps producer lcore");
80 if (evt_has_disabled_lcore(opt->wlcores)) {
81 evt_err("one or more workers lcores are not enabled");
84 if (!evt_has_active_lcore(opt->wlcores)) {
85 evt_err("minimum one worker is required");
89 /* Validate producer lcore */
90 if (plcore == (int)rte_get_master_lcore()) {
91 evt_err("producer lcore and master lcore should be different");
94 if (!rte_lcore_is_enabled(plcore)) {
95 evt_err("producer lcore is not enabled");
100 if (opt->nb_pkts == 0)
101 opt->nb_pkts = INT64_MAX;
107 order_test_setup(struct evt_test *test, struct evt_options *opt)
111 test_order = rte_zmalloc_socket(test->name, sizeof(struct test_order),
112 RTE_CACHE_LINE_SIZE, opt->socket_id);
113 if (test_order == NULL) {
114 evt_err("failed to allocate test_order memory");
117 test->test_priv = test_order;
119 struct test_order *t = evt_test_priv(test);
121 t->producer_flow_seq = rte_zmalloc_socket("test_producer_flow_seq",
122 sizeof(*t->producer_flow_seq) * opt->nb_flows,
123 RTE_CACHE_LINE_SIZE, opt->socket_id);
125 if (t->producer_flow_seq == NULL) {
126 evt_err("failed to allocate t->producer_flow_seq memory");
130 t->expected_flow_seq = rte_zmalloc_socket("test_expected_flow_seq",
131 sizeof(*t->expected_flow_seq) * opt->nb_flows,
132 RTE_CACHE_LINE_SIZE, opt->socket_id);
134 if (t->expected_flow_seq == NULL) {
135 evt_err("failed to allocate t->expected_flow_seq memory");
138 rte_atomic64_set(&t->outstand_pkts, opt->nb_pkts);
140 t->nb_pkts = opt->nb_pkts;
141 t->nb_flows = opt->nb_flows;
142 t->result = EVT_TEST_FAILED;
147 rte_free(t->producer_flow_seq);
149 rte_free(test->test_priv);
155 order_test_destroy(struct evt_test *test, struct evt_options *opt)
158 struct test_order *t = evt_test_priv(test);
160 rte_free(t->expected_flow_seq);
161 rte_free(t->producer_flow_seq);
162 rte_free(test->test_priv);
166 order_mempool_setup(struct evt_test *test, struct evt_options *opt)
168 struct test_order *t = evt_test_priv(test);
170 t->pool = rte_pktmbuf_pool_create(test->name, opt->pool_sz,
172 512, /* Use very small mbufs */
174 if (t->pool == NULL) {
175 evt_err("failed to create mempool");
183 order_mempool_destroy(struct evt_test *test, struct evt_options *opt)
186 struct test_order *t = evt_test_priv(test);
188 rte_mempool_free(t->pool);
192 order_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
196 rte_event_dev_stop(opt->dev_id);
197 rte_event_dev_close(opt->dev_id);
201 order_opt_dump(struct evt_options *opt)
203 evt_dump_producer_lcores(opt);
204 evt_dump("nb_wrker_lcores", "%d", evt_nr_active_lcores(opt->wlcores));
205 evt_dump_worker_lcores(opt);
206 evt_dump("nb_evdev_ports", "%d", order_nb_event_ports(opt));