xref: /dpdk/app/test-eventdev/test_perf_atq.c (revision e6050243553aa2c1016aaeeb5723d75d4da6d3ad)
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright (C) Cavium 2017.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
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
15  *       distribution.
16  *     * Neither the name of Cavium 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.
19  *
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.
31  */
32 
33 #include "test_perf_common.h"
34 
35 /* See http://dpdk.org/doc/guides/tools/testeventdev.html for test details */
36 
37 static inline int
38 atq_nb_event_queues(struct evt_options *opt)
39 {
40 	/* nb_queues = number of producers */
41 	return evt_nr_active_lcores(opt->plcores);
42 }
43 
44 static int
45 perf_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
46 {
47 	int ret;
48 	uint8_t queue;
49 
50 	const struct rte_event_dev_config config = {
51 			.nb_event_queues = atq_nb_event_queues(opt),
52 			.nb_event_ports = perf_nb_event_ports(opt),
53 			.nb_events_limit  = 4096,
54 			.nb_event_queue_flows = opt->nb_flows,
55 			.nb_event_port_dequeue_depth = 128,
56 			.nb_event_port_enqueue_depth = 128,
57 	};
58 
59 	ret = rte_event_dev_configure(opt->dev_id, &config);
60 	if (ret) {
61 		evt_err("failed to configure eventdev %d", opt->dev_id);
62 		return ret;
63 	}
64 
65 	struct rte_event_queue_conf q_conf = {
66 			.priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
67 			.event_queue_cfg = RTE_EVENT_QUEUE_CFG_ALL_TYPES,
68 			.nb_atomic_flows = opt->nb_flows,
69 			.nb_atomic_order_sequences = opt->nb_flows,
70 	};
71 	/* queue configurations */
72 	for (queue = 0; queue < atq_nb_event_queues(opt); queue++) {
73 		ret = rte_event_queue_setup(opt->dev_id, queue, &q_conf);
74 		if (ret) {
75 			evt_err("failed to setup queue=%d", queue);
76 			return ret;
77 		}
78 	}
79 
80 	ret = perf_event_dev_port_setup(test, opt, 1 /* stride */,
81 					atq_nb_event_queues(opt));
82 	if (ret)
83 		return ret;
84 
85 	ret = rte_event_dev_start(opt->dev_id);
86 	if (ret) {
87 		evt_err("failed to start eventdev %d", opt->dev_id);
88 		return ret;
89 	}
90 
91 	return 0;
92 }
93 
94 static void
95 perf_atq_opt_dump(struct evt_options *opt)
96 {
97 	perf_opt_dump(opt, atq_nb_event_queues(opt));
98 }
99 
100 static int
101 perf_atq_opt_check(struct evt_options *opt)
102 {
103 	return perf_opt_check(opt, atq_nb_event_queues(opt));
104 }
105 
106 static bool
107 perf_atq_capability_check(struct evt_options *opt)
108 {
109 	struct rte_event_dev_info dev_info;
110 
111 	rte_event_dev_info_get(opt->dev_id, &dev_info);
112 	if (dev_info.max_event_queues < atq_nb_event_queues(opt) ||
113 			dev_info.max_event_ports < perf_nb_event_ports(opt)) {
114 		evt_err("not enough eventdev queues=%d/%d or ports=%d/%d",
115 			atq_nb_event_queues(opt), dev_info.max_event_queues,
116 			perf_nb_event_ports(opt), dev_info.max_event_ports);
117 	}
118 	if (!evt_has_all_types_queue(opt->dev_id))
119 		return false;
120 
121 	return true;
122 }
123 
124 static const struct evt_test_ops perf_atq =  {
125 	.cap_check          = perf_atq_capability_check,
126 	.opt_check          = perf_atq_opt_check,
127 	.opt_dump           = perf_atq_opt_dump,
128 	.test_setup         = perf_test_setup,
129 	.mempool_setup      = perf_mempool_setup,
130 	.eventdev_setup     = perf_atq_eventdev_setup,
131 	.eventdev_destroy   = perf_eventdev_destroy,
132 	.mempool_destroy    = perf_mempool_destroy,
133 	.test_result        = perf_test_result,
134 	.test_destroy       = perf_test_destroy,
135 };
136 
137 EVT_TEST_REGISTER(perf_atq);
138