xref: /dpdk/app/test/test_eventdev.c (revision d007a7f39de3f17071acdefcd48b49e07306040f)
1a9de470cSBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2a9de470cSBruce Richardson  * Copyright(c) 2016 Cavium, Inc
3a9de470cSBruce Richardson  */
4a9de470cSBruce Richardson 
53c60274cSJie Zhou #include "test.h"
63c60274cSJie Zhou 
7a9de470cSBruce Richardson #include <rte_common.h>
8a9de470cSBruce Richardson #include <rte_hexdump.h>
9a9de470cSBruce Richardson #include <rte_mbuf.h>
10a9de470cSBruce Richardson #include <rte_malloc.h>
11a9de470cSBruce Richardson #include <rte_memcpy.h>
123c60274cSJie Zhou 
133c60274cSJie Zhou #ifdef RTE_EXEC_ENV_WINDOWS
143c60274cSJie Zhou static int
153c60274cSJie Zhou test_eventdev_common(void)
163c60274cSJie Zhou {
173c60274cSJie Zhou 	printf("eventdev_common not supported on Windows, skipping test\n");
183c60274cSJie Zhou 	return TEST_SKIPPED;
193c60274cSJie Zhou }
203c60274cSJie Zhou 
213c60274cSJie Zhou #else
223c60274cSJie Zhou 
23a9de470cSBruce Richardson #include <rte_eventdev.h>
24a9de470cSBruce Richardson #include <rte_dev.h>
25a9de470cSBruce Richardson #include <rte_bus_vdev.h>
26a9de470cSBruce Richardson 
27a9de470cSBruce Richardson #define TEST_DEV_ID   0
28a9de470cSBruce Richardson 
29a9de470cSBruce Richardson static int
30a9de470cSBruce Richardson testsuite_setup(void)
31a9de470cSBruce Richardson {
32a9de470cSBruce Richardson 	RTE_BUILD_BUG_ON(sizeof(struct rte_event) != 16);
33a9de470cSBruce Richardson 	uint8_t count;
34a9de470cSBruce Richardson 	count = rte_event_dev_count();
35a9de470cSBruce Richardson 	if (!count) {
36a9de470cSBruce Richardson 		printf("Failed to find a valid event device,"
37a9de470cSBruce Richardson 			" testing with event_skeleton device\n");
38a9de470cSBruce Richardson 		return rte_vdev_init("event_skeleton", NULL);
39a9de470cSBruce Richardson 	}
40a9de470cSBruce Richardson 	return TEST_SUCCESS;
41a9de470cSBruce Richardson }
42a9de470cSBruce Richardson 
43a9de470cSBruce Richardson static void
44a9de470cSBruce Richardson testsuite_teardown(void)
45a9de470cSBruce Richardson {
46a9de470cSBruce Richardson }
47a9de470cSBruce Richardson 
48a9de470cSBruce Richardson static int
49a9de470cSBruce Richardson test_eventdev_count(void)
50a9de470cSBruce Richardson {
51a9de470cSBruce Richardson 	uint8_t count;
52a9de470cSBruce Richardson 	count = rte_event_dev_count();
53a9de470cSBruce Richardson 	TEST_ASSERT(count > 0, "Invalid eventdev count %" PRIu8, count);
54a9de470cSBruce Richardson 	return TEST_SUCCESS;
55a9de470cSBruce Richardson }
56a9de470cSBruce Richardson 
57a9de470cSBruce Richardson static int
58a9de470cSBruce Richardson test_eventdev_get_dev_id(void)
59a9de470cSBruce Richardson {
60a9de470cSBruce Richardson 	int ret;
61a9de470cSBruce Richardson 	ret = rte_event_dev_get_dev_id("not_a_valid_eventdev_driver");
62a9de470cSBruce Richardson 	TEST_ASSERT_FAIL(ret, "Expected <0 for invalid dev name ret=%d", ret);
63a9de470cSBruce Richardson 	return TEST_SUCCESS;
64a9de470cSBruce Richardson }
65a9de470cSBruce Richardson 
66a9de470cSBruce Richardson static int
67a9de470cSBruce Richardson test_eventdev_socket_id(void)
68a9de470cSBruce Richardson {
69a9de470cSBruce Richardson 	int socket_id;
70a9de470cSBruce Richardson 	socket_id = rte_event_dev_socket_id(TEST_DEV_ID);
71a9de470cSBruce Richardson 	TEST_ASSERT(socket_id != -EINVAL, "Failed to get socket_id %d",
72a9de470cSBruce Richardson 				socket_id);
73a9de470cSBruce Richardson 	socket_id = rte_event_dev_socket_id(RTE_EVENT_MAX_DEVS);
74a9de470cSBruce Richardson 	TEST_ASSERT(socket_id == -EINVAL, "Expected -EINVAL %d", socket_id);
75a9de470cSBruce Richardson 
76a9de470cSBruce Richardson 	return TEST_SUCCESS;
77a9de470cSBruce Richardson }
78a9de470cSBruce Richardson 
79a9de470cSBruce Richardson static int
80a9de470cSBruce Richardson test_eventdev_info_get(void)
81a9de470cSBruce Richardson {
82a9de470cSBruce Richardson 	int ret;
83a9de470cSBruce Richardson 	struct rte_event_dev_info info;
84a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, NULL);
85a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
86a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
87a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
88a9de470cSBruce Richardson 	TEST_ASSERT(info.max_event_ports > 0,
89a9de470cSBruce Richardson 			"Not enough event ports %d", info.max_event_ports);
90a9de470cSBruce Richardson 	TEST_ASSERT(info.max_event_queues > 0,
91a9de470cSBruce Richardson 			"Not enough event queues %d", info.max_event_queues);
92a9de470cSBruce Richardson 	return TEST_SUCCESS;
93a9de470cSBruce Richardson }
94a9de470cSBruce Richardson 
95a9de470cSBruce Richardson static inline void
96a9de470cSBruce Richardson devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf,
97a9de470cSBruce Richardson 			struct rte_event_dev_info *info)
98a9de470cSBruce Richardson {
99a9de470cSBruce Richardson 	memset(dev_conf, 0, sizeof(struct rte_event_dev_config));
100a9de470cSBruce Richardson 	dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns;
101a9de470cSBruce Richardson 	dev_conf->nb_event_ports = info->max_event_ports;
102a9de470cSBruce Richardson 	dev_conf->nb_event_queues = info->max_event_queues;
103a9de470cSBruce Richardson 	dev_conf->nb_event_queue_flows = info->max_event_queue_flows;
104a9de470cSBruce Richardson 	dev_conf->nb_event_port_dequeue_depth =
105a9de470cSBruce Richardson 			info->max_event_port_dequeue_depth;
106a9de470cSBruce Richardson 	dev_conf->nb_event_port_enqueue_depth =
107a9de470cSBruce Richardson 			info->max_event_port_enqueue_depth;
108a9de470cSBruce Richardson 	dev_conf->nb_event_port_enqueue_depth =
109a9de470cSBruce Richardson 			info->max_event_port_enqueue_depth;
110a9de470cSBruce Richardson 	dev_conf->nb_events_limit =
111a9de470cSBruce Richardson 			info->max_num_events;
112a9de470cSBruce Richardson }
113a9de470cSBruce Richardson 
114a9de470cSBruce Richardson static int
115a9de470cSBruce Richardson test_ethdev_config_run(struct rte_event_dev_config *dev_conf,
116a9de470cSBruce Richardson 		struct rte_event_dev_info *info,
117a9de470cSBruce Richardson 		void (*fn)(struct rte_event_dev_config *dev_conf,
118a9de470cSBruce Richardson 			struct rte_event_dev_info *info))
119a9de470cSBruce Richardson {
120a9de470cSBruce Richardson 	devconf_set_default_sane_values(dev_conf, info);
121a9de470cSBruce Richardson 	fn(dev_conf, info);
122a9de470cSBruce Richardson 	return rte_event_dev_configure(TEST_DEV_ID, dev_conf);
123a9de470cSBruce Richardson }
124a9de470cSBruce Richardson 
125a9de470cSBruce Richardson static void
126a9de470cSBruce Richardson max_dequeue_limit(struct rte_event_dev_config *dev_conf,
127a9de470cSBruce Richardson 		  struct rte_event_dev_info *info)
128a9de470cSBruce Richardson {
129a9de470cSBruce Richardson 	dev_conf->dequeue_timeout_ns = info->max_dequeue_timeout_ns + 1;
130a9de470cSBruce Richardson }
131a9de470cSBruce Richardson 
132a9de470cSBruce Richardson static void
133a9de470cSBruce Richardson max_events_limit(struct rte_event_dev_config *dev_conf,
134a9de470cSBruce Richardson 		  struct rte_event_dev_info *info)
135a9de470cSBruce Richardson {
136a9de470cSBruce Richardson 	dev_conf->nb_events_limit  = info->max_num_events + 1;
137a9de470cSBruce Richardson }
138a9de470cSBruce Richardson 
139a9de470cSBruce Richardson static void
140a9de470cSBruce Richardson max_event_ports(struct rte_event_dev_config *dev_conf,
141a9de470cSBruce Richardson 		  struct rte_event_dev_info *info)
142a9de470cSBruce Richardson {
143a9de470cSBruce Richardson 	dev_conf->nb_event_ports = info->max_event_ports + 1;
144a9de470cSBruce Richardson }
145a9de470cSBruce Richardson 
146a9de470cSBruce Richardson static void
147a9de470cSBruce Richardson max_event_queues(struct rte_event_dev_config *dev_conf,
148a9de470cSBruce Richardson 		  struct rte_event_dev_info *info)
149a9de470cSBruce Richardson {
150a9de470cSBruce Richardson 	dev_conf->nb_event_queues = info->max_event_queues + 1;
151a9de470cSBruce Richardson }
152a9de470cSBruce Richardson 
153a9de470cSBruce Richardson static void
154a9de470cSBruce Richardson max_event_queue_flows(struct rte_event_dev_config *dev_conf,
155a9de470cSBruce Richardson 		  struct rte_event_dev_info *info)
156a9de470cSBruce Richardson {
157a9de470cSBruce Richardson 	dev_conf->nb_event_queue_flows = info->max_event_queue_flows + 1;
158a9de470cSBruce Richardson }
159a9de470cSBruce Richardson 
160a9de470cSBruce Richardson static void
161a9de470cSBruce Richardson max_event_port_dequeue_depth(struct rte_event_dev_config *dev_conf,
162a9de470cSBruce Richardson 		  struct rte_event_dev_info *info)
163a9de470cSBruce Richardson {
164a9de470cSBruce Richardson 	dev_conf->nb_event_port_dequeue_depth =
165a9de470cSBruce Richardson 		info->max_event_port_dequeue_depth + 1;
166a9de470cSBruce Richardson }
167a9de470cSBruce Richardson 
168a9de470cSBruce Richardson static void
169a9de470cSBruce Richardson max_event_port_enqueue_depth(struct rte_event_dev_config *dev_conf,
170a9de470cSBruce Richardson 		  struct rte_event_dev_info *info)
171a9de470cSBruce Richardson {
172a9de470cSBruce Richardson 	dev_conf->nb_event_port_enqueue_depth =
173a9de470cSBruce Richardson 		info->max_event_port_enqueue_depth + 1;
174a9de470cSBruce Richardson }
175a9de470cSBruce Richardson 
176a9de470cSBruce Richardson 
177a9de470cSBruce Richardson static int
178a9de470cSBruce Richardson test_eventdev_configure(void)
179a9de470cSBruce Richardson {
180a9de470cSBruce Richardson 	int ret;
181a9de470cSBruce Richardson 	struct rte_event_dev_config dev_conf;
182a9de470cSBruce Richardson 	struct rte_event_dev_info info;
183a9de470cSBruce Richardson 	ret = rte_event_dev_configure(TEST_DEV_ID, NULL);
184a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
185a9de470cSBruce Richardson 
186a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
187a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
188a9de470cSBruce Richardson 
189a9de470cSBruce Richardson 	/* Check limits */
190a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(-EINVAL,
191a9de470cSBruce Richardson 		test_ethdev_config_run(&dev_conf, &info, max_dequeue_limit),
192a9de470cSBruce Richardson 		 "Config negative test failed");
193a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(-EINVAL,
194a9de470cSBruce Richardson 		test_ethdev_config_run(&dev_conf, &info, max_events_limit),
195a9de470cSBruce Richardson 		 "Config negative test failed");
196a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(-EINVAL,
197a9de470cSBruce Richardson 		test_ethdev_config_run(&dev_conf, &info, max_event_ports),
198a9de470cSBruce Richardson 		 "Config negative test failed");
199a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(-EINVAL,
200a9de470cSBruce Richardson 		test_ethdev_config_run(&dev_conf, &info, max_event_queues),
201a9de470cSBruce Richardson 		 "Config negative test failed");
202a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(-EINVAL,
203a9de470cSBruce Richardson 		test_ethdev_config_run(&dev_conf, &info, max_event_queue_flows),
204a9de470cSBruce Richardson 		"Config negative test failed");
205a9de470cSBruce Richardson 
206a9de470cSBruce Richardson 	if (info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) {
207a9de470cSBruce Richardson 		TEST_ASSERT_EQUAL(-EINVAL,
208a9de470cSBruce Richardson 				test_ethdev_config_run(&dev_conf, &info,
209a9de470cSBruce Richardson 					max_event_port_dequeue_depth),
210a9de470cSBruce Richardson 				"Config negative test failed");
211a9de470cSBruce Richardson 		TEST_ASSERT_EQUAL(-EINVAL,
212a9de470cSBruce Richardson 				test_ethdev_config_run(&dev_conf, &info,
213a9de470cSBruce Richardson 					max_event_port_enqueue_depth),
214a9de470cSBruce Richardson 				"Config negative test failed");
215a9de470cSBruce Richardson 	}
216a9de470cSBruce Richardson 
217a9de470cSBruce Richardson 	/* Positive case */
218a9de470cSBruce Richardson 	devconf_set_default_sane_values(&dev_conf, &info);
219a9de470cSBruce Richardson 	ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
220a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
221a9de470cSBruce Richardson 
222a9de470cSBruce Richardson 	/* re-configure */
223a9de470cSBruce Richardson 	devconf_set_default_sane_values(&dev_conf, &info);
224a9de470cSBruce Richardson 	dev_conf.nb_event_ports = RTE_MAX(info.max_event_ports/2, 1);
225a9de470cSBruce Richardson 	dev_conf.nb_event_queues = RTE_MAX(info.max_event_queues/2, 1);
226a9de470cSBruce Richardson 	ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
227a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to re configure eventdev");
228a9de470cSBruce Richardson 
229a9de470cSBruce Richardson 	/* re-configure back to max_event_queues and max_event_ports */
230a9de470cSBruce Richardson 	devconf_set_default_sane_values(&dev_conf, &info);
231a9de470cSBruce Richardson 	ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
232a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to re-configure eventdev");
233a9de470cSBruce Richardson 
234a9de470cSBruce Richardson 	return TEST_SUCCESS;
235a9de470cSBruce Richardson 
236a9de470cSBruce Richardson }
237a9de470cSBruce Richardson 
238a9de470cSBruce Richardson static int
239a9de470cSBruce Richardson eventdev_configure_setup(void)
240a9de470cSBruce Richardson {
241a9de470cSBruce Richardson 	int ret;
242a9de470cSBruce Richardson 	struct rte_event_dev_config dev_conf;
243a9de470cSBruce Richardson 	struct rte_event_dev_info info;
244a9de470cSBruce Richardson 
245a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
246a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
247a9de470cSBruce Richardson 	devconf_set_default_sane_values(&dev_conf, &info);
248a9de470cSBruce Richardson 	ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
249a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
250a9de470cSBruce Richardson 
251a9de470cSBruce Richardson 	return TEST_SUCCESS;
252a9de470cSBruce Richardson }
253a9de470cSBruce Richardson 
254a9de470cSBruce Richardson static int
255a9de470cSBruce Richardson test_eventdev_queue_default_conf_get(void)
256a9de470cSBruce Richardson {
257a9de470cSBruce Richardson 	int i, ret;
258a9de470cSBruce Richardson 	struct rte_event_queue_conf qconf;
259a9de470cSBruce Richardson 
260a9de470cSBruce Richardson 	ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, NULL);
261a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
262a9de470cSBruce Richardson 
263a9de470cSBruce Richardson 	uint32_t queue_count;
264a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
265a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
266a9de470cSBruce Richardson 			    "Queue count get failed");
267a9de470cSBruce Richardson 
268a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
269a9de470cSBruce Richardson 		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i,
270a9de470cSBruce Richardson 						 &qconf);
271a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d info", i);
272a9de470cSBruce Richardson 	}
273a9de470cSBruce Richardson 
274a9de470cSBruce Richardson 	return TEST_SUCCESS;
275a9de470cSBruce Richardson }
276a9de470cSBruce Richardson 
277a9de470cSBruce Richardson static int
278a9de470cSBruce Richardson test_eventdev_queue_setup(void)
279a9de470cSBruce Richardson {
280a9de470cSBruce Richardson 	int i, ret;
281a9de470cSBruce Richardson 	struct rte_event_dev_info info;
282a9de470cSBruce Richardson 	struct rte_event_queue_conf qconf;
283a9de470cSBruce Richardson 
284a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
285a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
286a9de470cSBruce Richardson 
287a9de470cSBruce Richardson 	/* Negative cases */
288a9de470cSBruce Richardson 	ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
289a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get queue0 info");
290a9de470cSBruce Richardson 	qconf.event_queue_cfg =	RTE_EVENT_QUEUE_CFG_ALL_TYPES;
291a9de470cSBruce Richardson 	qconf.nb_atomic_flows = info.max_event_queue_flows + 1;
292a9de470cSBruce Richardson 	ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf);
293a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
294a9de470cSBruce Richardson 
295a9de470cSBruce Richardson 	qconf.nb_atomic_flows = info.max_event_queue_flows;
296a9de470cSBruce Richardson 	qconf.schedule_type = RTE_SCHED_TYPE_ORDERED;
297a9de470cSBruce Richardson 	qconf.nb_atomic_order_sequences = info.max_event_queue_flows + 1;
298a9de470cSBruce Richardson 	ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf);
299a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
300a9de470cSBruce Richardson 
301a9de470cSBruce Richardson 	ret = rte_event_queue_setup(TEST_DEV_ID, info.max_event_queues,
302a9de470cSBruce Richardson 					&qconf);
303a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
304a9de470cSBruce Richardson 
305a9de470cSBruce Richardson 	/* Positive case */
306a9de470cSBruce Richardson 	ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
307a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get queue0 info");
308a9de470cSBruce Richardson 	ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf);
309a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to setup queue0");
310a9de470cSBruce Richardson 
311a9de470cSBruce Richardson 	uint32_t queue_count;
312a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
313a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
314a9de470cSBruce Richardson 			    "Queue count get failed");
315a9de470cSBruce Richardson 
316a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
317a9de470cSBruce Richardson 		ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL);
318a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
319a9de470cSBruce Richardson 	}
320a9de470cSBruce Richardson 
321a9de470cSBruce Richardson 	return TEST_SUCCESS;
322a9de470cSBruce Richardson }
323a9de470cSBruce Richardson 
324a9de470cSBruce Richardson static int
325a9de470cSBruce Richardson test_eventdev_queue_count(void)
326a9de470cSBruce Richardson {
327a9de470cSBruce Richardson 	int ret;
328a9de470cSBruce Richardson 	struct rte_event_dev_info info;
329a9de470cSBruce Richardson 
330a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
331a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
332a9de470cSBruce Richardson 
333a9de470cSBruce Richardson 	uint32_t queue_count;
334a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
335a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
336a9de470cSBruce Richardson 			    "Queue count get failed");
337a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(queue_count, info.max_event_queues,
338a9de470cSBruce Richardson 			  "Wrong queue count");
339a9de470cSBruce Richardson 
340a9de470cSBruce Richardson 	return TEST_SUCCESS;
341a9de470cSBruce Richardson }
342a9de470cSBruce Richardson 
343a9de470cSBruce Richardson static int
344a9de470cSBruce Richardson test_eventdev_queue_attr_priority(void)
345a9de470cSBruce Richardson {
346a9de470cSBruce Richardson 	int i, ret;
347a9de470cSBruce Richardson 	struct rte_event_dev_info info;
348a9de470cSBruce Richardson 	struct rte_event_queue_conf qconf;
349a9de470cSBruce Richardson 	uint8_t priority;
350a9de470cSBruce Richardson 
351a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
352a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
353a9de470cSBruce Richardson 
354a9de470cSBruce Richardson 	uint32_t queue_count;
355a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
356a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
357a9de470cSBruce Richardson 			    "Queue count get failed");
358a9de470cSBruce Richardson 
359a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
360a9de470cSBruce Richardson 		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i,
361a9de470cSBruce Richardson 					&qconf);
362a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
363a9de470cSBruce Richardson 		qconf.priority = i %  RTE_EVENT_DEV_PRIORITY_LOWEST;
364a9de470cSBruce Richardson 		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
365a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
366a9de470cSBruce Richardson 	}
367a9de470cSBruce Richardson 
368a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
369a9de470cSBruce Richardson 		uint32_t tmp;
370a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
371a9de470cSBruce Richardson 				    RTE_EVENT_QUEUE_ATTR_PRIORITY, &tmp),
372a9de470cSBruce Richardson 				    "Queue priority get failed");
373a9de470cSBruce Richardson 		priority = tmp;
374a9de470cSBruce Richardson 
375a9de470cSBruce Richardson 		if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
376a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(priority,
377a9de470cSBruce Richardson 			 i %  RTE_EVENT_DEV_PRIORITY_LOWEST,
378a9de470cSBruce Richardson 			 "Wrong priority value for queue%d", i);
379a9de470cSBruce Richardson 		else
380a9de470cSBruce Richardson 			TEST_ASSERT_EQUAL(priority,
381a9de470cSBruce Richardson 			 RTE_EVENT_DEV_PRIORITY_NORMAL,
382a9de470cSBruce Richardson 			 "Wrong priority value for queue%d", i);
383a9de470cSBruce Richardson 	}
384a9de470cSBruce Richardson 
385a9de470cSBruce Richardson 	return TEST_SUCCESS;
386a9de470cSBruce Richardson }
387a9de470cSBruce Richardson 
388a9de470cSBruce Richardson static int
389deb450c4SShijith Thotton test_eventdev_queue_attr_priority_runtime(void)
390deb450c4SShijith Thotton {
391deb450c4SShijith Thotton 	uint32_t queue_count, queue_req, prio, deq_cnt;
392deb450c4SShijith Thotton 	struct rte_event_queue_conf qconf;
393deb450c4SShijith Thotton 	struct rte_event_port_conf pconf;
394deb450c4SShijith Thotton 	struct rte_event_dev_info info;
395deb450c4SShijith Thotton 	struct rte_event event = {
396deb450c4SShijith Thotton 		.op = RTE_EVENT_OP_NEW,
397deb450c4SShijith Thotton 		.event_type = RTE_EVENT_TYPE_CPU,
398deb450c4SShijith Thotton 		.sched_type = RTE_SCHED_TYPE_ATOMIC,
399deb450c4SShijith Thotton 		.u64 = 0xbadbadba,
400deb450c4SShijith Thotton 	};
401deb450c4SShijith Thotton 	int i, ret;
402deb450c4SShijith Thotton 
403deb450c4SShijith Thotton 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
404deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
405deb450c4SShijith Thotton 
406deb450c4SShijith Thotton 	if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
407deb450c4SShijith Thotton 		return TEST_SKIPPED;
408deb450c4SShijith Thotton 
409deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(
410deb450c4SShijith Thotton 				    TEST_DEV_ID, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
411deb450c4SShijith Thotton 				    &queue_count),
412deb450c4SShijith Thotton 			    "Queue count get failed");
413deb450c4SShijith Thotton 
414deb450c4SShijith Thotton 	/* Need at least 2 queues to test LOW and HIGH priority. */
415deb450c4SShijith Thotton 	TEST_ASSERT(queue_count > 1, "Not enough event queues, needed 2");
416deb450c4SShijith Thotton 	queue_req = 2;
417deb450c4SShijith Thotton 
418deb450c4SShijith Thotton 	for (i = 0; i < (int)queue_count; i++) {
419deb450c4SShijith Thotton 		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf);
420deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
421deb450c4SShijith Thotton 		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
422deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
423deb450c4SShijith Thotton 	}
424deb450c4SShijith Thotton 
425deb450c4SShijith Thotton 	ret = rte_event_queue_attr_set(TEST_DEV_ID, 0,
426deb450c4SShijith Thotton 				       RTE_EVENT_QUEUE_ATTR_PRIORITY,
427deb450c4SShijith Thotton 				       RTE_EVENT_DEV_PRIORITY_LOWEST);
428deb450c4SShijith Thotton 	if (ret == -ENOTSUP)
429deb450c4SShijith Thotton 		return TEST_SKIPPED;
430deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Queue0 priority set failed");
431deb450c4SShijith Thotton 
432deb450c4SShijith Thotton 	ret = rte_event_queue_attr_set(TEST_DEV_ID, 1,
433deb450c4SShijith Thotton 				       RTE_EVENT_QUEUE_ATTR_PRIORITY,
434deb450c4SShijith Thotton 				       RTE_EVENT_DEV_PRIORITY_HIGHEST);
435deb450c4SShijith Thotton 	if (ret == -ENOTSUP)
436deb450c4SShijith Thotton 		return TEST_SKIPPED;
437deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Queue1 priority set failed");
438deb450c4SShijith Thotton 
439deb450c4SShijith Thotton 	/* Setup event port 0 */
440deb450c4SShijith Thotton 	ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
441deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
442deb450c4SShijith Thotton 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
443deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
444deb450c4SShijith Thotton 	ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
445deb450c4SShijith Thotton 	TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d",
446deb450c4SShijith Thotton 		    TEST_DEV_ID);
447deb450c4SShijith Thotton 
448deb450c4SShijith Thotton 	ret = rte_event_dev_start(TEST_DEV_ID);
449deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID);
450deb450c4SShijith Thotton 
451deb450c4SShijith Thotton 	for (i = 0; i < (int)queue_req; i++) {
452deb450c4SShijith Thotton 		event.queue_id = i;
453deb450c4SShijith Thotton 		while (rte_event_enqueue_burst(TEST_DEV_ID, 0, &event, 1) != 1)
454deb450c4SShijith Thotton 			rte_pause();
455deb450c4SShijith Thotton 	}
456deb450c4SShijith Thotton 
457deb450c4SShijith Thotton 	prio = RTE_EVENT_DEV_PRIORITY_HIGHEST;
458deb450c4SShijith Thotton 	deq_cnt = 0;
459deb450c4SShijith Thotton 	while (deq_cnt < queue_req) {
460deb450c4SShijith Thotton 		uint32_t queue_prio;
461deb450c4SShijith Thotton 
462deb450c4SShijith Thotton 		if (rte_event_dequeue_burst(TEST_DEV_ID, 0, &event, 1, 0) == 0)
463deb450c4SShijith Thotton 			continue;
464deb450c4SShijith Thotton 
465deb450c4SShijith Thotton 		ret = rte_event_queue_attr_get(TEST_DEV_ID, event.queue_id,
466deb450c4SShijith Thotton 					       RTE_EVENT_QUEUE_ATTR_PRIORITY,
467deb450c4SShijith Thotton 					       &queue_prio);
468deb450c4SShijith Thotton 		if (ret == -ENOTSUP)
469deb450c4SShijith Thotton 			return TEST_SKIPPED;
470deb450c4SShijith Thotton 
471deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Queue priority get failed");
472deb450c4SShijith Thotton 		TEST_ASSERT(queue_prio >= prio,
473deb450c4SShijith Thotton 			    "Received event from a lower priority queue first");
474deb450c4SShijith Thotton 		prio = queue_prio;
475deb450c4SShijith Thotton 		deq_cnt++;
476deb450c4SShijith Thotton 	}
477deb450c4SShijith Thotton 
478deb450c4SShijith Thotton 	return TEST_SUCCESS;
479deb450c4SShijith Thotton }
480deb450c4SShijith Thotton 
481deb450c4SShijith Thotton static int
482deb450c4SShijith Thotton test_eventdev_queue_attr_weight_runtime(void)
483deb450c4SShijith Thotton {
484deb450c4SShijith Thotton 	struct rte_event_queue_conf qconf;
485deb450c4SShijith Thotton 	struct rte_event_dev_info info;
486deb450c4SShijith Thotton 	uint32_t queue_count;
487deb450c4SShijith Thotton 	int i, ret;
488deb450c4SShijith Thotton 
489deb450c4SShijith Thotton 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
490deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
491deb450c4SShijith Thotton 
492deb450c4SShijith Thotton 	if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
493deb450c4SShijith Thotton 		return TEST_SKIPPED;
494deb450c4SShijith Thotton 
495deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(
496deb450c4SShijith Thotton 				    TEST_DEV_ID, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
497deb450c4SShijith Thotton 				    &queue_count),
498deb450c4SShijith Thotton 			    "Queue count get failed");
499deb450c4SShijith Thotton 
500deb450c4SShijith Thotton 	for (i = 0; i < (int)queue_count; i++) {
501deb450c4SShijith Thotton 		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf);
502deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
503deb450c4SShijith Thotton 		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
504deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
505deb450c4SShijith Thotton 	}
506deb450c4SShijith Thotton 
507deb450c4SShijith Thotton 	for (i = 0; i < (int)queue_count; i++) {
508deb450c4SShijith Thotton 		uint32_t get_val;
509deb450c4SShijith Thotton 		uint64_t set_val;
510deb450c4SShijith Thotton 
511deb450c4SShijith Thotton 		set_val = i % RTE_EVENT_QUEUE_WEIGHT_HIGHEST;
512deb450c4SShijith Thotton 		ret = rte_event_queue_attr_set(
513deb450c4SShijith Thotton 			TEST_DEV_ID, i, RTE_EVENT_QUEUE_ATTR_WEIGHT, set_val);
514deb450c4SShijith Thotton 		if (ret == -ENOTSUP)
515deb450c4SShijith Thotton 			return TEST_SKIPPED;
516deb450c4SShijith Thotton 
517deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Queue weight set failed");
518deb450c4SShijith Thotton 
519deb450c4SShijith Thotton 		ret = rte_event_queue_attr_get(
520deb450c4SShijith Thotton 			TEST_DEV_ID, i, RTE_EVENT_QUEUE_ATTR_WEIGHT, &get_val);
521deb450c4SShijith Thotton 		if (ret == -ENOTSUP)
522deb450c4SShijith Thotton 			return TEST_SKIPPED;
523deb450c4SShijith Thotton 
524deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Queue weight get failed");
525deb450c4SShijith Thotton 		TEST_ASSERT_EQUAL(get_val, set_val,
526deb450c4SShijith Thotton 				  "Wrong weight value for queue%d", i);
527deb450c4SShijith Thotton 	}
528deb450c4SShijith Thotton 
529deb450c4SShijith Thotton 	return TEST_SUCCESS;
530deb450c4SShijith Thotton }
531deb450c4SShijith Thotton 
532deb450c4SShijith Thotton static int
533deb450c4SShijith Thotton test_eventdev_queue_attr_affinity_runtime(void)
534deb450c4SShijith Thotton {
535deb450c4SShijith Thotton 	struct rte_event_queue_conf qconf;
536deb450c4SShijith Thotton 	struct rte_event_dev_info info;
537deb450c4SShijith Thotton 	uint32_t queue_count;
538deb450c4SShijith Thotton 	int i, ret;
539deb450c4SShijith Thotton 
540deb450c4SShijith Thotton 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
541deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
542deb450c4SShijith Thotton 
543deb450c4SShijith Thotton 	if (!(info.event_dev_cap & RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR))
544deb450c4SShijith Thotton 		return TEST_SKIPPED;
545deb450c4SShijith Thotton 
546deb450c4SShijith Thotton 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(
547deb450c4SShijith Thotton 				    TEST_DEV_ID, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
548deb450c4SShijith Thotton 				    &queue_count),
549deb450c4SShijith Thotton 			    "Queue count get failed");
550deb450c4SShijith Thotton 
551deb450c4SShijith Thotton 	for (i = 0; i < (int)queue_count; i++) {
552deb450c4SShijith Thotton 		ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i, &qconf);
553deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
554deb450c4SShijith Thotton 		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
555deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
556deb450c4SShijith Thotton 	}
557deb450c4SShijith Thotton 
558deb450c4SShijith Thotton 	for (i = 0; i < (int)queue_count; i++) {
559deb450c4SShijith Thotton 		uint32_t get_val;
560deb450c4SShijith Thotton 		uint64_t set_val;
561deb450c4SShijith Thotton 
562deb450c4SShijith Thotton 		set_val = i % RTE_EVENT_QUEUE_AFFINITY_HIGHEST;
563deb450c4SShijith Thotton 		ret = rte_event_queue_attr_set(
564deb450c4SShijith Thotton 			TEST_DEV_ID, i, RTE_EVENT_QUEUE_ATTR_AFFINITY, set_val);
565deb450c4SShijith Thotton 		if (ret == -ENOTSUP)
566deb450c4SShijith Thotton 			return TEST_SKIPPED;
567deb450c4SShijith Thotton 
568deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Queue affinity set failed");
569deb450c4SShijith Thotton 
570deb450c4SShijith Thotton 		ret = rte_event_queue_attr_get(
571deb450c4SShijith Thotton 			TEST_DEV_ID, i, RTE_EVENT_QUEUE_ATTR_AFFINITY, &get_val);
572deb450c4SShijith Thotton 		if (ret == -ENOTSUP)
573deb450c4SShijith Thotton 			return TEST_SKIPPED;
574deb450c4SShijith Thotton 
575deb450c4SShijith Thotton 		TEST_ASSERT_SUCCESS(ret, "Queue affinity get failed");
576deb450c4SShijith Thotton 		TEST_ASSERT_EQUAL(get_val, set_val,
577deb450c4SShijith Thotton 				  "Wrong affinity value for queue%d", i);
578deb450c4SShijith Thotton 	}
579deb450c4SShijith Thotton 
580deb450c4SShijith Thotton 	return TEST_SUCCESS;
581deb450c4SShijith Thotton }
582deb450c4SShijith Thotton 
583deb450c4SShijith Thotton static int
584a9de470cSBruce Richardson test_eventdev_queue_attr_nb_atomic_flows(void)
585a9de470cSBruce Richardson {
586a9de470cSBruce Richardson 	int i, ret;
587a9de470cSBruce Richardson 	struct rte_event_dev_info info;
588a9de470cSBruce Richardson 	struct rte_event_queue_conf qconf;
589a9de470cSBruce Richardson 	uint32_t nb_atomic_flows;
590a9de470cSBruce Richardson 
591a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
592a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
593a9de470cSBruce Richardson 
594a9de470cSBruce Richardson 	uint32_t queue_count;
595a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
596a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
597a9de470cSBruce Richardson 			    "Queue count get failed");
598a9de470cSBruce Richardson 
599a9de470cSBruce Richardson 	ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
600a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get queue 0's def conf");
601a9de470cSBruce Richardson 
602a9de470cSBruce Richardson 	if (qconf.nb_atomic_flows == 0)
603a9de470cSBruce Richardson 		/* Assume PMD doesn't support atomic flows, return early */
604a9de470cSBruce Richardson 		return -ENOTSUP;
605a9de470cSBruce Richardson 
606a9de470cSBruce Richardson 	qconf.schedule_type = RTE_SCHED_TYPE_ATOMIC;
607a9de470cSBruce Richardson 
608a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
609a9de470cSBruce Richardson 		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
610a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
611a9de470cSBruce Richardson 	}
612a9de470cSBruce Richardson 
613a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
614a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
615a9de470cSBruce Richardson 				    RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS,
616a9de470cSBruce Richardson 				    &nb_atomic_flows),
617a9de470cSBruce Richardson 				    "Queue nb_atomic_flows get failed");
618a9de470cSBruce Richardson 
619a9de470cSBruce Richardson 		TEST_ASSERT_EQUAL(nb_atomic_flows, qconf.nb_atomic_flows,
620a9de470cSBruce Richardson 				  "Wrong atomic flows value for queue%d", i);
621a9de470cSBruce Richardson 	}
622a9de470cSBruce Richardson 
623a9de470cSBruce Richardson 	return TEST_SUCCESS;
624a9de470cSBruce Richardson }
625a9de470cSBruce Richardson 
626a9de470cSBruce Richardson static int
627a9de470cSBruce Richardson test_eventdev_queue_attr_nb_atomic_order_sequences(void)
628a9de470cSBruce Richardson {
629a9de470cSBruce Richardson 	int i, ret;
630a9de470cSBruce Richardson 	struct rte_event_dev_info info;
631a9de470cSBruce Richardson 	struct rte_event_queue_conf qconf;
632a9de470cSBruce Richardson 	uint32_t nb_atomic_order_sequences;
633a9de470cSBruce Richardson 
634a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
635a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
636a9de470cSBruce Richardson 
637a9de470cSBruce Richardson 	uint32_t queue_count;
638a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
639a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
640a9de470cSBruce Richardson 			    "Queue count get failed");
641a9de470cSBruce Richardson 
642a9de470cSBruce Richardson 	ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
643a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get queue 0's def conf");
644a9de470cSBruce Richardson 
645a9de470cSBruce Richardson 	if (qconf.nb_atomic_order_sequences == 0)
646a9de470cSBruce Richardson 		/* Assume PMD doesn't support reordering */
647a9de470cSBruce Richardson 		return -ENOTSUP;
648a9de470cSBruce Richardson 
649a9de470cSBruce Richardson 	qconf.schedule_type = RTE_SCHED_TYPE_ORDERED;
650a9de470cSBruce Richardson 
651a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
652a9de470cSBruce Richardson 		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
653a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
654a9de470cSBruce Richardson 	}
655a9de470cSBruce Richardson 
656a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
657a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
658a9de470cSBruce Richardson 			    RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES,
659a9de470cSBruce Richardson 			    &nb_atomic_order_sequences),
660a9de470cSBruce Richardson 			    "Queue nb_atomic_order_sequencess get failed");
661a9de470cSBruce Richardson 
662a9de470cSBruce Richardson 		TEST_ASSERT_EQUAL(nb_atomic_order_sequences,
663a9de470cSBruce Richardson 				  qconf.nb_atomic_order_sequences,
664a9de470cSBruce Richardson 				  "Wrong atomic order sequences value for queue%d",
665a9de470cSBruce Richardson 				  i);
666a9de470cSBruce Richardson 	}
667a9de470cSBruce Richardson 
668a9de470cSBruce Richardson 	return TEST_SUCCESS;
669a9de470cSBruce Richardson }
670a9de470cSBruce Richardson 
671a9de470cSBruce Richardson static int
672a9de470cSBruce Richardson test_eventdev_queue_attr_event_queue_cfg(void)
673a9de470cSBruce Richardson {
674a9de470cSBruce Richardson 	int i, ret;
675a9de470cSBruce Richardson 	struct rte_event_dev_info info;
676a9de470cSBruce Richardson 	struct rte_event_queue_conf qconf;
677a9de470cSBruce Richardson 	uint32_t event_queue_cfg;
678a9de470cSBruce Richardson 
679a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
680a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
681a9de470cSBruce Richardson 
682a9de470cSBruce Richardson 	uint32_t queue_count;
683a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
684a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
685a9de470cSBruce Richardson 			    "Queue count get failed");
686a9de470cSBruce Richardson 
687a9de470cSBruce Richardson 	ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
688a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get queue0 def conf");
689a9de470cSBruce Richardson 
690a9de470cSBruce Richardson 	qconf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
691a9de470cSBruce Richardson 
692a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
693a9de470cSBruce Richardson 		ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
694a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
695a9de470cSBruce Richardson 	}
696a9de470cSBruce Richardson 
697a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
698a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
699a9de470cSBruce Richardson 				    RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG,
700a9de470cSBruce Richardson 				    &event_queue_cfg),
701a9de470cSBruce Richardson 				    "Queue event_queue_cfg get failed");
702a9de470cSBruce Richardson 
703a9de470cSBruce Richardson 		TEST_ASSERT_EQUAL(event_queue_cfg, qconf.event_queue_cfg,
704a9de470cSBruce Richardson 				  "Wrong event_queue_cfg value for queue%d",
705a9de470cSBruce Richardson 				  i);
706a9de470cSBruce Richardson 	}
707a9de470cSBruce Richardson 
708a9de470cSBruce Richardson 	return TEST_SUCCESS;
709a9de470cSBruce Richardson }
710a9de470cSBruce Richardson 
711a9de470cSBruce Richardson static int
712a9de470cSBruce Richardson test_eventdev_port_default_conf_get(void)
713a9de470cSBruce Richardson {
714a9de470cSBruce Richardson 	int i, ret;
715a9de470cSBruce Richardson 	struct rte_event_port_conf pconf;
716a9de470cSBruce Richardson 
717a9de470cSBruce Richardson 	ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, NULL);
718a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
719a9de470cSBruce Richardson 
720a9de470cSBruce Richardson 	uint32_t port_count;
721a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
722a9de470cSBruce Richardson 				RTE_EVENT_DEV_ATTR_PORT_COUNT,
723a9de470cSBruce Richardson 				&port_count), "Port count get failed");
724a9de470cSBruce Richardson 
725a9de470cSBruce Richardson 	ret = rte_event_port_default_conf_get(TEST_DEV_ID,
726a9de470cSBruce Richardson 			port_count + 1, NULL);
727a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
728a9de470cSBruce Richardson 
729a9de470cSBruce Richardson 	for (i = 0; i < (int)port_count; i++) {
730a9de470cSBruce Richardson 		ret = rte_event_port_default_conf_get(TEST_DEV_ID, i,
731a9de470cSBruce Richardson 							&pconf);
732a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to get port%d info", i);
733a9de470cSBruce Richardson 	}
734a9de470cSBruce Richardson 
735a9de470cSBruce Richardson 	return TEST_SUCCESS;
736a9de470cSBruce Richardson }
737a9de470cSBruce Richardson 
738a9de470cSBruce Richardson static int
739a9de470cSBruce Richardson test_eventdev_port_setup(void)
740a9de470cSBruce Richardson {
741a9de470cSBruce Richardson 	int i, ret;
742a9de470cSBruce Richardson 	struct rte_event_dev_info info;
743a9de470cSBruce Richardson 	struct rte_event_port_conf pconf;
744a9de470cSBruce Richardson 
745a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
746a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
747a9de470cSBruce Richardson 
748a9de470cSBruce Richardson 	/* Negative cases */
749a9de470cSBruce Richardson 	ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
750a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
751a9de470cSBruce Richardson 	pconf.new_event_threshold = info.max_num_events + 1;
752a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
753a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
754a9de470cSBruce Richardson 
755a9de470cSBruce Richardson 	pconf.new_event_threshold = info.max_num_events;
756a9de470cSBruce Richardson 	pconf.dequeue_depth = info.max_event_port_dequeue_depth + 1;
757a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
758a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
759a9de470cSBruce Richardson 
760a9de470cSBruce Richardson 	pconf.dequeue_depth = info.max_event_port_dequeue_depth;
761a9de470cSBruce Richardson 	pconf.enqueue_depth = info.max_event_port_enqueue_depth + 1;
762a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
763a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
764a9de470cSBruce Richardson 
765a9de470cSBruce Richardson 	if (!(info.event_dev_cap &
766a9de470cSBruce Richardson 	      RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE)) {
767a9de470cSBruce Richardson 		pconf.enqueue_depth = info.max_event_port_enqueue_depth;
76875d11313STimothy McDaniel 		pconf.event_port_cfg = RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL;
769a9de470cSBruce Richardson 		ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
770a9de470cSBruce Richardson 		TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
77175d11313STimothy McDaniel 		pconf.event_port_cfg = 0;
772a9de470cSBruce Richardson 	}
773a9de470cSBruce Richardson 
774a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, info.max_event_ports,
775a9de470cSBruce Richardson 					&pconf);
776a9de470cSBruce Richardson 	TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
777a9de470cSBruce Richardson 
778a9de470cSBruce Richardson 	/* Positive case */
779a9de470cSBruce Richardson 	ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
780a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
781a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
782a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
783a9de470cSBruce Richardson 
784a9de470cSBruce Richardson 	uint32_t port_count;
785a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
786a9de470cSBruce Richardson 				RTE_EVENT_DEV_ATTR_PORT_COUNT,
787a9de470cSBruce Richardson 				&port_count), "Port count get failed");
788a9de470cSBruce Richardson 
789a9de470cSBruce Richardson 	for (i = 0; i < (int)port_count; i++) {
790a9de470cSBruce Richardson 		ret = rte_event_port_setup(TEST_DEV_ID, i, NULL);
791a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i);
792a9de470cSBruce Richardson 	}
793a9de470cSBruce Richardson 
794a9de470cSBruce Richardson 	return TEST_SUCCESS;
795a9de470cSBruce Richardson }
796a9de470cSBruce Richardson 
797a9de470cSBruce Richardson static int
798a9de470cSBruce Richardson test_eventdev_port_attr_dequeue_depth(void)
799a9de470cSBruce Richardson {
800a9de470cSBruce Richardson 	int ret;
801a9de470cSBruce Richardson 	struct rte_event_dev_info info;
802a9de470cSBruce Richardson 	struct rte_event_port_conf pconf;
803a9de470cSBruce Richardson 
804a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
805a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
806a9de470cSBruce Richardson 
807a9de470cSBruce Richardson 	ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
808a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
809a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
810a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
811a9de470cSBruce Richardson 
812a9de470cSBruce Richardson 	uint32_t value;
813a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0,
814a9de470cSBruce Richardson 			RTE_EVENT_PORT_ATTR_DEQ_DEPTH, &value),
815a9de470cSBruce Richardson 			0, "Call to get port dequeue depth failed");
816a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(value, pconf.dequeue_depth,
817a9de470cSBruce Richardson 			"Wrong port dequeue depth");
818a9de470cSBruce Richardson 
819a9de470cSBruce Richardson 	return TEST_SUCCESS;
820a9de470cSBruce Richardson }
821a9de470cSBruce Richardson 
822a9de470cSBruce Richardson static int
823a9de470cSBruce Richardson test_eventdev_port_attr_enqueue_depth(void)
824a9de470cSBruce Richardson {
825a9de470cSBruce Richardson 	int ret;
826a9de470cSBruce Richardson 	struct rte_event_dev_info info;
827a9de470cSBruce Richardson 	struct rte_event_port_conf pconf;
828a9de470cSBruce Richardson 
829a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
830a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
831a9de470cSBruce Richardson 
832a9de470cSBruce Richardson 	ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
833a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
834a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
835a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
836a9de470cSBruce Richardson 
837a9de470cSBruce Richardson 	uint32_t value;
838a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0,
839a9de470cSBruce Richardson 			RTE_EVENT_PORT_ATTR_ENQ_DEPTH, &value),
840a9de470cSBruce Richardson 			0, "Call to get port enqueue depth failed");
841a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(value, pconf.enqueue_depth,
842a9de470cSBruce Richardson 			"Wrong port enqueue depth");
843a9de470cSBruce Richardson 
844a9de470cSBruce Richardson 	return TEST_SUCCESS;
845a9de470cSBruce Richardson }
846a9de470cSBruce Richardson 
847a9de470cSBruce Richardson static int
848a9de470cSBruce Richardson test_eventdev_port_attr_new_event_threshold(void)
849a9de470cSBruce Richardson {
850a9de470cSBruce Richardson 	int ret;
851a9de470cSBruce Richardson 	struct rte_event_dev_info info;
852a9de470cSBruce Richardson 	struct rte_event_port_conf pconf;
853a9de470cSBruce Richardson 
854a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
855a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
856a9de470cSBruce Richardson 
857a9de470cSBruce Richardson 	ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
858a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
859a9de470cSBruce Richardson 	ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
860a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
861a9de470cSBruce Richardson 
862a9de470cSBruce Richardson 	uint32_t value;
863a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0,
864a9de470cSBruce Richardson 			RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD, &value),
865a9de470cSBruce Richardson 			0, "Call to get port new event threshold failed");
866a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL((int32_t) value, pconf.new_event_threshold,
867a9de470cSBruce Richardson 			"Wrong port new event threshold");
868a9de470cSBruce Richardson 
869a9de470cSBruce Richardson 	return TEST_SUCCESS;
870a9de470cSBruce Richardson }
871a9de470cSBruce Richardson 
872a9de470cSBruce Richardson static int
873a9de470cSBruce Richardson test_eventdev_port_count(void)
874a9de470cSBruce Richardson {
875a9de470cSBruce Richardson 	int ret;
876a9de470cSBruce Richardson 	struct rte_event_dev_info info;
877a9de470cSBruce Richardson 
878a9de470cSBruce Richardson 	ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
879a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
880a9de470cSBruce Richardson 
881a9de470cSBruce Richardson 	uint32_t port_count;
882a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
883a9de470cSBruce Richardson 				RTE_EVENT_DEV_ATTR_PORT_COUNT,
884a9de470cSBruce Richardson 				&port_count), "Port count get failed");
885a9de470cSBruce Richardson 	TEST_ASSERT_EQUAL(port_count, info.max_event_ports, "Wrong port count");
886a9de470cSBruce Richardson 
887a9de470cSBruce Richardson 	return TEST_SUCCESS;
888a9de470cSBruce Richardson }
889a9de470cSBruce Richardson 
890a9de470cSBruce Richardson static int
891a9de470cSBruce Richardson test_eventdev_timeout_ticks(void)
892a9de470cSBruce Richardson {
893a9de470cSBruce Richardson 	int ret;
894a9de470cSBruce Richardson 	uint64_t timeout_ticks;
895a9de470cSBruce Richardson 
896a9de470cSBruce Richardson 	ret = rte_event_dequeue_timeout_ticks(TEST_DEV_ID, 100, &timeout_ticks);
897a9de470cSBruce Richardson 	if (ret != -ENOTSUP)
898a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Fail to get timeout_ticks");
899a9de470cSBruce Richardson 
900a9de470cSBruce Richardson 	return ret;
901a9de470cSBruce Richardson }
902a9de470cSBruce Richardson 
903a9de470cSBruce Richardson 
904a9de470cSBruce Richardson static int
905a9de470cSBruce Richardson test_eventdev_start_stop(void)
906a9de470cSBruce Richardson {
907a9de470cSBruce Richardson 	int i, ret;
908a9de470cSBruce Richardson 
909a9de470cSBruce Richardson 	ret = eventdev_configure_setup();
910a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
911a9de470cSBruce Richardson 
912a9de470cSBruce Richardson 	uint32_t queue_count;
913a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
914a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
915a9de470cSBruce Richardson 			    "Queue count get failed");
916a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
917a9de470cSBruce Richardson 		ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL);
918a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
919a9de470cSBruce Richardson 	}
920a9de470cSBruce Richardson 
921a9de470cSBruce Richardson 	uint32_t port_count;
922a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
923a9de470cSBruce Richardson 				RTE_EVENT_DEV_ATTR_PORT_COUNT,
924a9de470cSBruce Richardson 				&port_count), "Port count get failed");
925a9de470cSBruce Richardson 
926a9de470cSBruce Richardson 	for (i = 0; i < (int)port_count; i++) {
927a9de470cSBruce Richardson 		ret = rte_event_port_setup(TEST_DEV_ID, i, NULL);
928a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i);
929a9de470cSBruce Richardson 	}
930a9de470cSBruce Richardson 
931a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
932a9de470cSBruce Richardson 	TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d",
933a9de470cSBruce Richardson 		    TEST_DEV_ID);
934a9de470cSBruce Richardson 
935a9de470cSBruce Richardson 	ret = rte_event_dev_start(TEST_DEV_ID);
936a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID);
937a9de470cSBruce Richardson 
938a9de470cSBruce Richardson 	rte_event_dev_stop(TEST_DEV_ID);
939a9de470cSBruce Richardson 	return TEST_SUCCESS;
940a9de470cSBruce Richardson }
941a9de470cSBruce Richardson 
942a9de470cSBruce Richardson 
943a9de470cSBruce Richardson static int
944a9de470cSBruce Richardson eventdev_setup_device(void)
945a9de470cSBruce Richardson {
946a9de470cSBruce Richardson 	int i, ret;
947a9de470cSBruce Richardson 
948a9de470cSBruce Richardson 	ret = eventdev_configure_setup();
949a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
950a9de470cSBruce Richardson 
951a9de470cSBruce Richardson 	uint32_t queue_count;
952a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
953a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
954a9de470cSBruce Richardson 			    "Queue count get failed");
955a9de470cSBruce Richardson 	for (i = 0; i < (int)queue_count; i++) {
956a9de470cSBruce Richardson 		ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL);
957a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
958a9de470cSBruce Richardson 	}
959a9de470cSBruce Richardson 
960a9de470cSBruce Richardson 	uint32_t port_count;
961a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
962a9de470cSBruce Richardson 				RTE_EVENT_DEV_ATTR_PORT_COUNT,
963a9de470cSBruce Richardson 				&port_count), "Port count get failed");
964a9de470cSBruce Richardson 
965a9de470cSBruce Richardson 	for (i = 0; i < (int)port_count; i++) {
966a9de470cSBruce Richardson 		ret = rte_event_port_setup(TEST_DEV_ID, i, NULL);
967a9de470cSBruce Richardson 		TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i);
968a9de470cSBruce Richardson 	}
969a9de470cSBruce Richardson 
970a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
971a9de470cSBruce Richardson 	TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d",
972a9de470cSBruce Richardson 		    TEST_DEV_ID);
973a9de470cSBruce Richardson 
974a9de470cSBruce Richardson 	ret = rte_event_dev_start(TEST_DEV_ID);
975a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID);
976a9de470cSBruce Richardson 
977a9de470cSBruce Richardson 	return TEST_SUCCESS;
978a9de470cSBruce Richardson }
979a9de470cSBruce Richardson 
980a9de470cSBruce Richardson static void
981a9de470cSBruce Richardson eventdev_stop_device(void)
982a9de470cSBruce Richardson {
983a9de470cSBruce Richardson 	rte_event_dev_stop(TEST_DEV_ID);
984a9de470cSBruce Richardson }
985a9de470cSBruce Richardson 
986a9de470cSBruce Richardson static int
987a9de470cSBruce Richardson test_eventdev_link(void)
988a9de470cSBruce Richardson {
989a9de470cSBruce Richardson 	int ret, nb_queues, i;
990a9de470cSBruce Richardson 	uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
991a9de470cSBruce Richardson 	uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
992a9de470cSBruce Richardson 
993a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
994a9de470cSBruce Richardson 	TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d",
995a9de470cSBruce Richardson 				 TEST_DEV_ID);
996a9de470cSBruce Richardson 
997a9de470cSBruce Richardson 	uint32_t queue_count;
998a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
999a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
1000a9de470cSBruce Richardson 			    "Queue count get failed");
1001a9de470cSBruce Richardson 	nb_queues = queue_count;
1002a9de470cSBruce Richardson 	for (i = 0; i < nb_queues; i++) {
1003a9de470cSBruce Richardson 		queues[i] = i;
1004a9de470cSBruce Richardson 		priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL;
1005a9de470cSBruce Richardson 	}
1006a9de470cSBruce Richardson 
1007a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, queues,
1008a9de470cSBruce Richardson 					priorities, nb_queues);
1009a9de470cSBruce Richardson 	TEST_ASSERT(ret == nb_queues, "Failed to link(device%d) ret=%d",
1010a9de470cSBruce Richardson 				 TEST_DEV_ID, ret);
1011a9de470cSBruce Richardson 	return TEST_SUCCESS;
1012a9de470cSBruce Richardson }
1013a9de470cSBruce Richardson 
1014a9de470cSBruce Richardson static int
1015a9de470cSBruce Richardson test_eventdev_unlink(void)
1016a9de470cSBruce Richardson {
1017a9de470cSBruce Richardson 	int ret, nb_queues, i;
1018a9de470cSBruce Richardson 	uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
1019a9de470cSBruce Richardson 
1020a9de470cSBruce Richardson 	ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0);
1021a9de470cSBruce Richardson 	TEST_ASSERT(ret >= 0, "Failed to unlink with NULL device%d",
1022a9de470cSBruce Richardson 				 TEST_DEV_ID);
1023a9de470cSBruce Richardson 
1024a9de470cSBruce Richardson 	uint32_t queue_count;
1025a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
1026a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
1027a9de470cSBruce Richardson 			    "Queue count get failed");
1028a9de470cSBruce Richardson 	nb_queues = queue_count;
1029a9de470cSBruce Richardson 	for (i = 0; i < nb_queues; i++)
1030a9de470cSBruce Richardson 		queues[i] = i;
1031a9de470cSBruce Richardson 
1032a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
1033a9de470cSBruce Richardson 	TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d",
1034a9de470cSBruce Richardson 				 TEST_DEV_ID);
1035a9de470cSBruce Richardson 
1036a9de470cSBruce Richardson 	ret = rte_event_port_unlink(TEST_DEV_ID, 0, queues, nb_queues);
1037a9de470cSBruce Richardson 	TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d",
1038a9de470cSBruce Richardson 				 TEST_DEV_ID, ret);
1039a9de470cSBruce Richardson 	return TEST_SUCCESS;
1040a9de470cSBruce Richardson }
1041a9de470cSBruce Richardson 
1042a9de470cSBruce Richardson static int
1043a9de470cSBruce Richardson test_eventdev_link_get(void)
1044a9de470cSBruce Richardson {
1045a9de470cSBruce Richardson 	int ret, i;
1046a9de470cSBruce Richardson 	uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
1047a9de470cSBruce Richardson 	uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
1048a9de470cSBruce Richardson 
1049a9de470cSBruce Richardson 	/* link all queues */
1050a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
1051a9de470cSBruce Richardson 	TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d",
1052a9de470cSBruce Richardson 				 TEST_DEV_ID);
1053a9de470cSBruce Richardson 
1054a9de470cSBruce Richardson 	uint32_t queue_count;
1055a9de470cSBruce Richardson 	TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
1056a9de470cSBruce Richardson 			    RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
1057a9de470cSBruce Richardson 			    "Queue count get failed");
1058a9de470cSBruce Richardson 	const int nb_queues = queue_count;
1059a9de470cSBruce Richardson 	for (i = 0; i < nb_queues; i++)
1060a9de470cSBruce Richardson 		queues[i] = i;
1061a9de470cSBruce Richardson 
1062a9de470cSBruce Richardson 	ret = rte_event_port_unlink(TEST_DEV_ID, 0, queues, nb_queues);
1063a9de470cSBruce Richardson 	TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d",
1064a9de470cSBruce Richardson 				 TEST_DEV_ID, ret);
1065a9de470cSBruce Richardson 
1066a9de470cSBruce Richardson 	ret = rte_event_port_links_get(TEST_DEV_ID, 0, queues, priorities);
1067a9de470cSBruce Richardson 	TEST_ASSERT(ret == 0, "(%d)Wrong link get=%d", TEST_DEV_ID, ret);
1068a9de470cSBruce Richardson 
1069a9de470cSBruce Richardson 	/* link all queues and get the links */
1070a9de470cSBruce Richardson 	for (i = 0; i < nb_queues; i++) {
1071a9de470cSBruce Richardson 		queues[i] = i;
1072a9de470cSBruce Richardson 		priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL;
1073a9de470cSBruce Richardson 	}
1074a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, queues, priorities,
1075a9de470cSBruce Richardson 					 nb_queues);
1076a9de470cSBruce Richardson 	TEST_ASSERT(ret == nb_queues, "Failed to link(device%d) ret=%d",
1077a9de470cSBruce Richardson 				 TEST_DEV_ID, ret);
1078a9de470cSBruce Richardson 	ret = rte_event_port_links_get(TEST_DEV_ID, 0, queues, priorities);
1079a9de470cSBruce Richardson 	TEST_ASSERT(ret == nb_queues, "(%d)Wrong link get ret=%d expected=%d",
1080a9de470cSBruce Richardson 				 TEST_DEV_ID, ret, nb_queues);
1081a9de470cSBruce Richardson 	/* unlink all*/
1082a9de470cSBruce Richardson 	ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0);
1083a9de470cSBruce Richardson 	TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d",
1084a9de470cSBruce Richardson 				 TEST_DEV_ID, ret);
1085a9de470cSBruce Richardson 	/* link just one queue */
1086a9de470cSBruce Richardson 	queues[0] = 0;
1087a9de470cSBruce Richardson 	priorities[0] = RTE_EVENT_DEV_PRIORITY_NORMAL;
1088a9de470cSBruce Richardson 
1089a9de470cSBruce Richardson 	ret = rte_event_port_link(TEST_DEV_ID, 0, queues, priorities, 1);
1090a9de470cSBruce Richardson 	TEST_ASSERT(ret == 1, "Failed to link(device%d) ret=%d",
1091a9de470cSBruce Richardson 				 TEST_DEV_ID, ret);
1092a9de470cSBruce Richardson 	ret = rte_event_port_links_get(TEST_DEV_ID, 0, queues, priorities);
1093a9de470cSBruce Richardson 	TEST_ASSERT(ret == 1, "(%d)Wrong link get ret=%d expected=%d",
1094a9de470cSBruce Richardson 					TEST_DEV_ID, ret, 1);
1095a9de470cSBruce Richardson 	/* unlink the queue */
1096a9de470cSBruce Richardson 	ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0);
1097a9de470cSBruce Richardson 	TEST_ASSERT(ret == 1, "Failed to unlink(device%d) ret=%d",
1098a9de470cSBruce Richardson 				 TEST_DEV_ID, ret);
1099a9de470cSBruce Richardson 
1100a9de470cSBruce Richardson 	/* 4links and 2 unlinks */
1101a9de470cSBruce Richardson 	if (nb_queues >= 4) {
1102a9de470cSBruce Richardson 		for (i = 0; i < 4; i++) {
1103a9de470cSBruce Richardson 			queues[i] = i;
1104a9de470cSBruce Richardson 			priorities[i] = 0x40;
1105a9de470cSBruce Richardson 		}
1106a9de470cSBruce Richardson 		ret = rte_event_port_link(TEST_DEV_ID, 0, queues, priorities,
1107a9de470cSBruce Richardson 						4);
1108a9de470cSBruce Richardson 		TEST_ASSERT(ret == 4, "Failed to link(device%d) ret=%d",
1109a9de470cSBruce Richardson 					 TEST_DEV_ID, ret);
1110a9de470cSBruce Richardson 
1111a9de470cSBruce Richardson 		for (i = 0; i < 2; i++)
1112a9de470cSBruce Richardson 			queues[i] = i;
1113a9de470cSBruce Richardson 
1114a9de470cSBruce Richardson 		ret = rte_event_port_unlink(TEST_DEV_ID, 0, queues, 2);
1115a9de470cSBruce Richardson 		TEST_ASSERT(ret == 2, "Failed to unlink(device%d) ret=%d",
1116a9de470cSBruce Richardson 					 TEST_DEV_ID, ret);
1117a9de470cSBruce Richardson 		ret = rte_event_port_links_get(TEST_DEV_ID, 0,
1118a9de470cSBruce Richardson 						queues, priorities);
1119a9de470cSBruce Richardson 		TEST_ASSERT(ret == 2, "(%d)Wrong link get ret=%d expected=%d",
1120a9de470cSBruce Richardson 						TEST_DEV_ID, ret, 2);
1121a9de470cSBruce Richardson 		TEST_ASSERT(queues[0] == 2, "ret=%d expected=%d", ret, 2);
1122a9de470cSBruce Richardson 		TEST_ASSERT(priorities[0] == 0x40, "ret=%d expected=%d",
1123a9de470cSBruce Richardson 							ret, 0x40);
1124a9de470cSBruce Richardson 		TEST_ASSERT(queues[1] == 3, "ret=%d expected=%d", ret, 3);
1125a9de470cSBruce Richardson 		TEST_ASSERT(priorities[1] == 0x40, "ret=%d expected=%d",
1126a9de470cSBruce Richardson 					ret, 0x40);
1127a9de470cSBruce Richardson 	}
1128a9de470cSBruce Richardson 
1129a9de470cSBruce Richardson 	return TEST_SUCCESS;
1130a9de470cSBruce Richardson }
1131a9de470cSBruce Richardson 
1132a9de470cSBruce Richardson static int
1133*d007a7f3SPavan Nikhilesh test_eventdev_profile_switch(void)
1134*d007a7f3SPavan Nikhilesh {
1135*d007a7f3SPavan Nikhilesh #define MAX_RETRIES   4
1136*d007a7f3SPavan Nikhilesh 	uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
1137*d007a7f3SPavan Nikhilesh 	uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
1138*d007a7f3SPavan Nikhilesh 	struct rte_event_queue_conf qcfg;
1139*d007a7f3SPavan Nikhilesh 	struct rte_event_port_conf pcfg;
1140*d007a7f3SPavan Nikhilesh 	struct rte_event_dev_info info;
1141*d007a7f3SPavan Nikhilesh 	struct rte_event ev;
1142*d007a7f3SPavan Nikhilesh 	uint8_t q, re;
1143*d007a7f3SPavan Nikhilesh 	int rc;
1144*d007a7f3SPavan Nikhilesh 
1145*d007a7f3SPavan Nikhilesh 	rte_event_dev_info_get(TEST_DEV_ID, &info);
1146*d007a7f3SPavan Nikhilesh 
1147*d007a7f3SPavan Nikhilesh 	if (info.max_profiles_per_port <= 1)
1148*d007a7f3SPavan Nikhilesh 		return TEST_SKIPPED;
1149*d007a7f3SPavan Nikhilesh 
1150*d007a7f3SPavan Nikhilesh 	if (info.max_event_queues <= 1)
1151*d007a7f3SPavan Nikhilesh 		return TEST_SKIPPED;
1152*d007a7f3SPavan Nikhilesh 
1153*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pcfg);
1154*d007a7f3SPavan Nikhilesh 	TEST_ASSERT_SUCCESS(rc, "Failed to get port0 default config");
1155*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_setup(TEST_DEV_ID, 0, &pcfg);
1156*d007a7f3SPavan Nikhilesh 	TEST_ASSERT_SUCCESS(rc, "Failed to setup port0");
1157*d007a7f3SPavan Nikhilesh 
1158*d007a7f3SPavan Nikhilesh 	rc = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qcfg);
1159*d007a7f3SPavan Nikhilesh 	TEST_ASSERT_SUCCESS(rc, "Failed to get queue0 default config");
1160*d007a7f3SPavan Nikhilesh 	rc = rte_event_queue_setup(TEST_DEV_ID, 0, &qcfg);
1161*d007a7f3SPavan Nikhilesh 	TEST_ASSERT_SUCCESS(rc, "Failed to setup queue0");
1162*d007a7f3SPavan Nikhilesh 
1163*d007a7f3SPavan Nikhilesh 	q = 0;
1164*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_links_set(TEST_DEV_ID, 0, &q, NULL, 1, 0);
1165*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to link queue 0 to port 0 with profile 0");
1166*d007a7f3SPavan Nikhilesh 	q = 1;
1167*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_links_set(TEST_DEV_ID, 0, &q, NULL, 1, 1);
1168*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to link queue 1 to port 0 with profile 1");
1169*d007a7f3SPavan Nikhilesh 
1170*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_links_get(TEST_DEV_ID, 0, queues, priorities, 0);
1171*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to links");
1172*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(queues[0] == 0, "Invalid queue found in link");
1173*d007a7f3SPavan Nikhilesh 
1174*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_links_get(TEST_DEV_ID, 0, queues, priorities, 1);
1175*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to links");
1176*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(queues[0] == 1, "Invalid queue found in link");
1177*d007a7f3SPavan Nikhilesh 
1178*d007a7f3SPavan Nikhilesh 	rc = rte_event_dev_start(TEST_DEV_ID);
1179*d007a7f3SPavan Nikhilesh 	TEST_ASSERT_SUCCESS(rc, "Failed to start event device");
1180*d007a7f3SPavan Nikhilesh 
1181*d007a7f3SPavan Nikhilesh 	ev.event_type = RTE_EVENT_TYPE_CPU;
1182*d007a7f3SPavan Nikhilesh 	ev.queue_id = 0;
1183*d007a7f3SPavan Nikhilesh 	ev.op = RTE_EVENT_OP_NEW;
1184*d007a7f3SPavan Nikhilesh 	ev.flow_id = 0;
1185*d007a7f3SPavan Nikhilesh 	ev.u64 = 0xBADF00D0;
1186*d007a7f3SPavan Nikhilesh 	rc = rte_event_enqueue_burst(TEST_DEV_ID, 0, &ev, 1);
1187*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to enqueue event");
1188*d007a7f3SPavan Nikhilesh 	ev.queue_id = 1;
1189*d007a7f3SPavan Nikhilesh 	ev.flow_id = 1;
1190*d007a7f3SPavan Nikhilesh 	rc = rte_event_enqueue_burst(TEST_DEV_ID, 0, &ev, 1);
1191*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to enqueue event");
1192*d007a7f3SPavan Nikhilesh 
1193*d007a7f3SPavan Nikhilesh 	ev.event = 0;
1194*d007a7f3SPavan Nikhilesh 	ev.u64 = 0;
1195*d007a7f3SPavan Nikhilesh 
1196*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_switch(TEST_DEV_ID, 0, 1);
1197*d007a7f3SPavan Nikhilesh 	TEST_ASSERT_SUCCESS(rc, "Failed to change profile");
1198*d007a7f3SPavan Nikhilesh 
1199*d007a7f3SPavan Nikhilesh 	re = MAX_RETRIES;
1200*d007a7f3SPavan Nikhilesh 	while (re--) {
1201*d007a7f3SPavan Nikhilesh 		rc = rte_event_dequeue_burst(TEST_DEV_ID, 0, &ev, 1, 0);
1202*d007a7f3SPavan Nikhilesh 		printf("rc %d\n", rc);
1203*d007a7f3SPavan Nikhilesh 		if (rc)
1204*d007a7f3SPavan Nikhilesh 			break;
1205*d007a7f3SPavan Nikhilesh 	}
1206*d007a7f3SPavan Nikhilesh 
1207*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to dequeue event from profile 1");
1208*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(ev.flow_id == 1, "Incorrect flow identifier from profile 1");
1209*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(ev.queue_id == 1, "Incorrect queue identifier from profile 1");
1210*d007a7f3SPavan Nikhilesh 
1211*d007a7f3SPavan Nikhilesh 	re = MAX_RETRIES;
1212*d007a7f3SPavan Nikhilesh 	while (re--) {
1213*d007a7f3SPavan Nikhilesh 		rc = rte_event_dequeue_burst(TEST_DEV_ID, 0, &ev, 1, 0);
1214*d007a7f3SPavan Nikhilesh 		TEST_ASSERT(rc == 0, "Unexpected event dequeued from active profile");
1215*d007a7f3SPavan Nikhilesh 	}
1216*d007a7f3SPavan Nikhilesh 
1217*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_switch(TEST_DEV_ID, 0, 0);
1218*d007a7f3SPavan Nikhilesh 	TEST_ASSERT_SUCCESS(rc, "Failed to change profile");
1219*d007a7f3SPavan Nikhilesh 
1220*d007a7f3SPavan Nikhilesh 	re = MAX_RETRIES;
1221*d007a7f3SPavan Nikhilesh 	while (re--) {
1222*d007a7f3SPavan Nikhilesh 		rc = rte_event_dequeue_burst(TEST_DEV_ID, 0, &ev, 1, 0);
1223*d007a7f3SPavan Nikhilesh 		if (rc)
1224*d007a7f3SPavan Nikhilesh 			break;
1225*d007a7f3SPavan Nikhilesh 	}
1226*d007a7f3SPavan Nikhilesh 
1227*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to dequeue event from profile 1");
1228*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(ev.flow_id == 0, "Incorrect flow identifier from profile 0");
1229*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(ev.queue_id == 0, "Incorrect queue identifier from profile 0");
1230*d007a7f3SPavan Nikhilesh 
1231*d007a7f3SPavan Nikhilesh 	re = MAX_RETRIES;
1232*d007a7f3SPavan Nikhilesh 	while (re--) {
1233*d007a7f3SPavan Nikhilesh 		rc = rte_event_dequeue_burst(TEST_DEV_ID, 0, &ev, 1, 0);
1234*d007a7f3SPavan Nikhilesh 		TEST_ASSERT(rc == 0, "Unexpected event dequeued from active profile");
1235*d007a7f3SPavan Nikhilesh 	}
1236*d007a7f3SPavan Nikhilesh 
1237*d007a7f3SPavan Nikhilesh 	q = 0;
1238*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_unlink(TEST_DEV_ID, 0, &q, 1, 0);
1239*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to unlink queue 0 to port 0 with profile 0");
1240*d007a7f3SPavan Nikhilesh 	q = 1;
1241*d007a7f3SPavan Nikhilesh 	rc = rte_event_port_profile_unlink(TEST_DEV_ID, 0, &q, 1, 1);
1242*d007a7f3SPavan Nikhilesh 	TEST_ASSERT(rc == 1, "Failed to unlink queue 1 to port 0 with profile 1");
1243*d007a7f3SPavan Nikhilesh 
1244*d007a7f3SPavan Nikhilesh 	return TEST_SUCCESS;
1245*d007a7f3SPavan Nikhilesh }
1246*d007a7f3SPavan Nikhilesh 
1247*d007a7f3SPavan Nikhilesh static int
1248a9de470cSBruce Richardson test_eventdev_close(void)
1249a9de470cSBruce Richardson {
1250a9de470cSBruce Richardson 	rte_event_dev_stop(TEST_DEV_ID);
1251a9de470cSBruce Richardson 	return rte_event_dev_close(TEST_DEV_ID);
1252a9de470cSBruce Richardson }
1253a9de470cSBruce Richardson 
1254a9de470cSBruce Richardson static struct unit_test_suite eventdev_common_testsuite  = {
1255a9de470cSBruce Richardson 	.suite_name = "eventdev common code unit test suite",
1256a9de470cSBruce Richardson 	.setup = testsuite_setup,
1257a9de470cSBruce Richardson 	.teardown = testsuite_teardown,
1258a9de470cSBruce Richardson 	.unit_test_cases = {
1259a9de470cSBruce Richardson 		TEST_CASE_ST(NULL, NULL,
1260a9de470cSBruce Richardson 			test_eventdev_count),
1261a9de470cSBruce Richardson 		TEST_CASE_ST(NULL, NULL,
1262a9de470cSBruce Richardson 			test_eventdev_get_dev_id),
1263a9de470cSBruce Richardson 		TEST_CASE_ST(NULL, NULL,
1264a9de470cSBruce Richardson 			test_eventdev_socket_id),
1265a9de470cSBruce Richardson 		TEST_CASE_ST(NULL, NULL,
1266a9de470cSBruce Richardson 			test_eventdev_info_get),
1267a9de470cSBruce Richardson 		TEST_CASE_ST(NULL, NULL,
1268a9de470cSBruce Richardson 			test_eventdev_configure),
1269a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1270a9de470cSBruce Richardson 			test_eventdev_queue_default_conf_get),
1271a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1272a9de470cSBruce Richardson 			test_eventdev_queue_setup),
1273a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1274a9de470cSBruce Richardson 			test_eventdev_queue_count),
1275a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1276a9de470cSBruce Richardson 			test_eventdev_queue_attr_priority),
1277deb450c4SShijith Thotton 		TEST_CASE_ST(eventdev_configure_setup, eventdev_stop_device,
1278deb450c4SShijith Thotton 			test_eventdev_queue_attr_priority_runtime),
1279deb450c4SShijith Thotton 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1280deb450c4SShijith Thotton 			test_eventdev_queue_attr_weight_runtime),
1281deb450c4SShijith Thotton 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1282deb450c4SShijith Thotton 			test_eventdev_queue_attr_affinity_runtime),
1283a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1284a9de470cSBruce Richardson 			test_eventdev_queue_attr_nb_atomic_flows),
1285a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1286a9de470cSBruce Richardson 			test_eventdev_queue_attr_nb_atomic_order_sequences),
1287a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1288a9de470cSBruce Richardson 			test_eventdev_queue_attr_event_queue_cfg),
1289a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1290a9de470cSBruce Richardson 			test_eventdev_port_default_conf_get),
1291a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1292a9de470cSBruce Richardson 			test_eventdev_port_setup),
1293a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1294a9de470cSBruce Richardson 			test_eventdev_port_attr_dequeue_depth),
1295a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1296a9de470cSBruce Richardson 			test_eventdev_port_attr_enqueue_depth),
1297a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1298a9de470cSBruce Richardson 			test_eventdev_port_attr_new_event_threshold),
1299a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1300a9de470cSBruce Richardson 			test_eventdev_port_count),
1301a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_configure_setup, NULL,
1302a9de470cSBruce Richardson 			test_eventdev_timeout_ticks),
1303a9de470cSBruce Richardson 		TEST_CASE_ST(NULL, NULL,
1304a9de470cSBruce Richardson 			test_eventdev_start_stop),
1305*d007a7f3SPavan Nikhilesh 		TEST_CASE_ST(eventdev_configure_setup, eventdev_stop_device,
1306*d007a7f3SPavan Nikhilesh 			test_eventdev_profile_switch),
1307a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
1308a9de470cSBruce Richardson 			test_eventdev_link),
1309a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
1310a9de470cSBruce Richardson 			test_eventdev_unlink),
1311a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
1312a9de470cSBruce Richardson 			test_eventdev_link_get),
1313a9de470cSBruce Richardson 		TEST_CASE_ST(eventdev_setup_device, NULL,
1314a9de470cSBruce Richardson 			test_eventdev_close),
1315a9de470cSBruce Richardson 		TEST_CASES_END() /**< NULL terminate unit test array */
1316a9de470cSBruce Richardson 	}
1317a9de470cSBruce Richardson };
1318a9de470cSBruce Richardson 
1319a9de470cSBruce Richardson static int
1320a9de470cSBruce Richardson test_eventdev_common(void)
1321a9de470cSBruce Richardson {
1322a9de470cSBruce Richardson 	return unit_test_suite_runner(&eventdev_common_testsuite);
1323a9de470cSBruce Richardson }
1324a9de470cSBruce Richardson 
1325a9de470cSBruce Richardson static int
1326a9de470cSBruce Richardson test_eventdev_selftest_impl(const char *pmd, const char *opts)
1327a9de470cSBruce Richardson {
13282155b9caSPavan Nikhilesh 	int ret = 0;
13292155b9caSPavan Nikhilesh 
1330e0f4a0edSDavid Marchand 	if (rte_event_dev_get_dev_id(pmd) == -ENODEV)
13312155b9caSPavan Nikhilesh 		ret = rte_vdev_init(pmd, opts);
13322155b9caSPavan Nikhilesh 	if (ret)
1333e0f4a0edSDavid Marchand 		return TEST_SKIPPED;
13342155b9caSPavan Nikhilesh 
1335a9de470cSBruce Richardson 	return rte_event_dev_selftest(rte_event_dev_get_dev_id(pmd));
1336a9de470cSBruce Richardson }
1337a9de470cSBruce Richardson 
1338a9de470cSBruce Richardson static int
1339a9de470cSBruce Richardson test_eventdev_selftest_sw(void)
1340a9de470cSBruce Richardson {
1341a9de470cSBruce Richardson 	return test_eventdev_selftest_impl("event_sw", "");
1342a9de470cSBruce Richardson }
1343a9de470cSBruce Richardson 
1344a9de470cSBruce Richardson static int
1345a9de470cSBruce Richardson test_eventdev_selftest_octeontx(void)
1346a9de470cSBruce Richardson {
1347a9de470cSBruce Richardson 	return test_eventdev_selftest_impl("event_octeontx", "");
1348a9de470cSBruce Richardson }
1349a9de470cSBruce Richardson 
135062561532SPavan Nikhilesh static int
1351a439f622SHemant Agrawal test_eventdev_selftest_dpaa2(void)
1352a439f622SHemant Agrawal {
1353a439f622SHemant Agrawal 	return test_eventdev_selftest_impl("event_dpaa2", "");
1354a439f622SHemant Agrawal }
1355a439f622SHemant Agrawal 
13566f1b8288STimothy McDaniel static int
13576f1b8288STimothy McDaniel test_eventdev_selftest_dlb2(void)
13586f1b8288STimothy McDaniel {
13596f1b8288STimothy McDaniel 	return test_eventdev_selftest_impl("dlb2_event", "");
13606f1b8288STimothy McDaniel }
13616f1b8288STimothy McDaniel 
136223515064SPavan Nikhilesh static int
136323515064SPavan Nikhilesh test_eventdev_selftest_cn9k(void)
136423515064SPavan Nikhilesh {
136523515064SPavan Nikhilesh 	return test_eventdev_selftest_impl("event_cn9k", "");
136623515064SPavan Nikhilesh }
136723515064SPavan Nikhilesh 
136823515064SPavan Nikhilesh static int
136923515064SPavan Nikhilesh test_eventdev_selftest_cn10k(void)
137023515064SPavan Nikhilesh {
137123515064SPavan Nikhilesh 	return test_eventdev_selftest_impl("event_cn10k", "");
137223515064SPavan Nikhilesh }
137323515064SPavan Nikhilesh 
13743c60274cSJie Zhou #endif /* !RTE_EXEC_ENV_WINDOWS */
13753c60274cSJie Zhou 
1376e0a8442cSBruce Richardson REGISTER_FAST_TEST(eventdev_common_autotest, true, true, test_eventdev_common);
13773c60274cSJie Zhou 
13783c60274cSJie Zhou #ifndef RTE_EXEC_ENV_WINDOWS
1379aee48294SBruce Richardson REGISTER_FAST_TEST(eventdev_selftest_sw, true, true, test_eventdev_selftest_sw);
1380d83fb967SDavid Marchand REGISTER_DRIVER_TEST(eventdev_selftest_octeontx, test_eventdev_selftest_octeontx);
13813864b310SBruce Richardson REGISTER_DRIVER_TEST(eventdev_selftest_dpaa2, test_eventdev_selftest_dpaa2);
13823864b310SBruce Richardson REGISTER_DRIVER_TEST(eventdev_selftest_dlb2, test_eventdev_selftest_dlb2);
13833864b310SBruce Richardson REGISTER_DRIVER_TEST(eventdev_selftest_cn9k, test_eventdev_selftest_cn9k);
13843864b310SBruce Richardson REGISTER_DRIVER_TEST(eventdev_selftest_cn10k, test_eventdev_selftest_cn10k);
13853c60274cSJie Zhou 
13863c60274cSJie Zhou #endif /* !RTE_EXEC_ENV_WINDOWS */
1387