2 * SPDX-License-Identifier: BSD-3-Clause
3 * Copyright 2017 Cavium, Inc.
6 #include "test_pipeline_common.h"
8 /* See http://dpdk.org/doc/guides/tools/testeventdev.html for test details */
10 static __rte_always_inline int
11 pipeline_atq_nb_event_queues(struct evt_options *opt)
15 return rte_eth_dev_count();
19 worker_wrapper(void *arg)
22 rte_panic("invalid worker\n");
26 pipeline_atq_launch_lcores(struct evt_test *test, struct evt_options *opt)
28 struct test_pipeline *t = evt_test_priv(test);
31 rte_service_component_runstate_set(t->tx_service.service_id, 1);
32 return pipeline_launch_lcores(test, opt, worker_wrapper);
36 pipeline_atq_eventdev_setup(struct evt_test *test, struct evt_options *opt)
42 struct rte_event_dev_info info;
43 struct test_pipeline *t = evt_test_priv(test);
44 uint8_t tx_evqueue_id = 0;
45 uint8_t queue_arr[RTE_EVENT_MAX_QUEUES_PER_DEV];
46 uint8_t nb_worker_queues = 0;
48 nb_ports = evt_nr_active_lcores(opt->wlcores);
49 nb_queues = rte_eth_dev_count();
51 /* One extra port and queueu for Tx service */
53 tx_evqueue_id = nb_queues;
59 rte_event_dev_info_get(opt->dev_id, &info);
61 const struct rte_event_dev_config config = {
62 .nb_event_queues = nb_queues,
63 .nb_event_ports = nb_ports,
64 .nb_events_limit = info.max_num_events,
65 .nb_event_queue_flows = opt->nb_flows,
66 .nb_event_port_dequeue_depth =
67 info.max_event_port_dequeue_depth,
68 .nb_event_port_enqueue_depth =
69 info.max_event_port_enqueue_depth,
71 ret = rte_event_dev_configure(opt->dev_id, &config);
73 evt_err("failed to configure eventdev %d", opt->dev_id);
77 struct rte_event_queue_conf q_conf = {
78 .priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
79 .nb_atomic_flows = opt->nb_flows,
80 .nb_atomic_order_sequences = opt->nb_flows,
82 /* queue configurations */
83 for (queue = 0; queue < nb_queues; queue++) {
84 q_conf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_ALL_TYPES;
87 if (queue == tx_evqueue_id) {
88 q_conf.event_queue_cfg =
89 RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
91 queue_arr[nb_worker_queues] = queue;
96 ret = rte_event_queue_setup(opt->dev_id, queue, &q_conf);
98 evt_err("failed to setup queue=%d", queue);
103 /* port configuration */
104 const struct rte_event_port_conf p_conf = {
105 .dequeue_depth = opt->wkr_deq_dep,
106 .enqueue_depth = info.max_event_port_dequeue_depth,
107 .new_event_threshold = info.max_num_events,
111 ret = pipeline_event_port_setup(test, opt, queue_arr,
112 nb_worker_queues, p_conf);
116 ret = pipeline_event_tx_service_setup(test, opt, tx_evqueue_id,
117 nb_ports - 1, p_conf);
119 ret = pipeline_event_port_setup(test, opt, NULL, nb_queues,
126 * The pipelines are setup in the following manner:
128 * eth_dev_count = 2, nb_stages = 2, atq mode
130 * Multi thread safe :
134 * event queue pipelines:
138 * q0, q1 are configured as ATQ so, all the different stages can
139 * be enqueued on the same queue.
141 * Multi thread unsafe :
145 * event queue pipelines:
147 * } (q3->tx) Tx service
150 * q0,q1 are configured as stated above.
151 * q3 configured as SINGLE_LINK|ATOMIC.
153 ret = pipeline_event_rx_adapter_setup(opt, 1, p_conf);
157 if (!evt_has_distributed_sched(opt->dev_id)) {
159 rte_event_dev_service_id_get(opt->dev_id, &service_id);
160 ret = evt_service_setup(service_id);
162 evt_err("No service lcore found to run event dev.");
167 ret = rte_event_dev_start(opt->dev_id);
169 evt_err("failed to start eventdev %d", opt->dev_id);
177 pipeline_atq_opt_dump(struct evt_options *opt)
179 pipeline_opt_dump(opt, pipeline_atq_nb_event_queues(opt));
183 pipeline_atq_opt_check(struct evt_options *opt)
185 return pipeline_opt_check(opt, pipeline_atq_nb_event_queues(opt));
189 pipeline_atq_capability_check(struct evt_options *opt)
191 struct rte_event_dev_info dev_info;
193 rte_event_dev_info_get(opt->dev_id, &dev_info);
194 if (dev_info.max_event_queues < pipeline_atq_nb_event_queues(opt) ||
195 dev_info.max_event_ports <
196 evt_nr_active_lcores(opt->wlcores)) {
197 evt_err("not enough eventdev queues=%d/%d or ports=%d/%d",
198 pipeline_atq_nb_event_queues(opt),
199 dev_info.max_event_queues,
200 evt_nr_active_lcores(opt->wlcores),
201 dev_info.max_event_ports);
207 static const struct evt_test_ops pipeline_atq = {
208 .cap_check = pipeline_atq_capability_check,
209 .opt_check = pipeline_atq_opt_check,
210 .opt_dump = pipeline_atq_opt_dump,
211 .test_setup = pipeline_test_setup,
212 .mempool_setup = pipeline_mempool_setup,
213 .ethdev_setup = pipeline_ethdev_setup,
214 .eventdev_setup = pipeline_atq_eventdev_setup,
215 .launch_lcores = pipeline_atq_launch_lcores,
216 .eventdev_destroy = pipeline_eventdev_destroy,
217 .mempool_destroy = pipeline_mempool_destroy,
218 .ethdev_destroy = pipeline_ethdev_destroy,
219 .test_result = pipeline_test_result,
220 .test_destroy = pipeline_test_destroy,
223 EVT_TEST_REGISTER(pipeline_atq);