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_eventdev_destroy(struct evt_test *test, struct evt_options *opt)
49 rte_event_dev_stop(opt->dev_id);
50 rte_event_dev_close(opt->dev_id);
54 perf_elt_init(struct rte_mempool *mp, void *arg __rte_unused,
55 void *obj, unsigned i __rte_unused)
57 memset(obj, 0, mp->elt_size);
61 perf_mempool_setup(struct evt_test *test, struct evt_options *opt)
63 struct test_perf *t = evt_test_priv(test);
65 t->pool = rte_mempool_create(test->name, /* mempool name */
66 opt->pool_sz, /* number of elements*/
67 sizeof(struct perf_elt), /* element size*/
70 perf_elt_init, /* obj constructor */
71 NULL, opt->socket_id, 0); /* flags */
72 if (t->pool == NULL) {
73 evt_err("failed to create mempool");
81 perf_mempool_destroy(struct evt_test *test, struct evt_options *opt)
84 struct test_perf *t = evt_test_priv(test);
86 rte_mempool_free(t->pool);
90 perf_test_setup(struct evt_test *test, struct evt_options *opt)
94 test_perf = rte_zmalloc_socket(test->name, sizeof(struct test_perf),
95 RTE_CACHE_LINE_SIZE, opt->socket_id);
96 if (test_perf == NULL) {
97 evt_err("failed to allocate test_perf memory");
100 test->test_priv = test_perf;
102 struct test_perf *t = evt_test_priv(test);
104 t->outstand_pkts = opt->nb_pkts * evt_nr_active_lcores(opt->plcores);
105 t->nb_workers = evt_nr_active_lcores(opt->wlcores);
107 t->nb_pkts = opt->nb_pkts;
108 t->nb_flows = opt->nb_flows;
109 t->result = EVT_TEST_FAILED;
111 memcpy(t->sched_type_list, opt->sched_type_list,
112 sizeof(opt->sched_type_list));
119 perf_test_destroy(struct evt_test *test, struct evt_options *opt)
123 rte_free(test->test_priv);