4 * Copyright(c) 2016 Cavium, Inc. All rights reserved.
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, Inc 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 <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 #include <rte_eventdev.h>
40 #include <rte_bus_vdev.h>
49 RTE_BUILD_BUG_ON(sizeof(struct rte_event) != 16);
51 count = rte_event_dev_count();
53 printf("Failed to find a valid event device,"
54 " testing with event_skeleton device\n");
55 return rte_vdev_init("event_skeleton", NULL);
61 testsuite_teardown(void)
66 test_eventdev_count(void)
69 count = rte_event_dev_count();
70 TEST_ASSERT(count > 0, "Invalid eventdev count %" PRIu8, count);
75 test_eventdev_get_dev_id(void)
78 ret = rte_event_dev_get_dev_id("not_a_valid_eventdev_driver");
79 TEST_ASSERT_FAIL(ret, "Expected <0 for invalid dev name ret=%d", ret);
84 test_eventdev_socket_id(void)
87 socket_id = rte_event_dev_socket_id(TEST_DEV_ID);
88 TEST_ASSERT(socket_id != -EINVAL, "Failed to get socket_id %d",
90 socket_id = rte_event_dev_socket_id(RTE_EVENT_MAX_DEVS);
91 TEST_ASSERT(socket_id == -EINVAL, "Expected -EINVAL %d", socket_id);
97 test_eventdev_info_get(void)
100 struct rte_event_dev_info info;
101 ret = rte_event_dev_info_get(TEST_DEV_ID, NULL);
102 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
103 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
104 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
105 TEST_ASSERT(info.max_event_ports > 0,
106 "Not enough event ports %d", info.max_event_ports);
107 TEST_ASSERT(info.max_event_queues > 0,
108 "Not enough event queues %d", info.max_event_queues);
113 devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf,
114 struct rte_event_dev_info *info)
116 memset(dev_conf, 0, sizeof(struct rte_event_dev_config));
117 dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns;
118 dev_conf->nb_event_ports = info->max_event_ports;
119 dev_conf->nb_event_queues = info->max_event_queues;
120 dev_conf->nb_event_queue_flows = info->max_event_queue_flows;
121 dev_conf->nb_event_port_dequeue_depth =
122 info->max_event_port_dequeue_depth;
123 dev_conf->nb_event_port_enqueue_depth =
124 info->max_event_port_enqueue_depth;
125 dev_conf->nb_event_port_enqueue_depth =
126 info->max_event_port_enqueue_depth;
127 dev_conf->nb_events_limit =
128 info->max_num_events;
132 test_ethdev_config_run(struct rte_event_dev_config *dev_conf,
133 struct rte_event_dev_info *info,
134 void (*fn)(struct rte_event_dev_config *dev_conf,
135 struct rte_event_dev_info *info))
137 devconf_set_default_sane_values(dev_conf, info);
139 return rte_event_dev_configure(TEST_DEV_ID, dev_conf);
143 max_dequeue_limit(struct rte_event_dev_config *dev_conf,
144 struct rte_event_dev_info *info)
146 dev_conf->dequeue_timeout_ns = info->max_dequeue_timeout_ns + 1;
150 max_events_limit(struct rte_event_dev_config *dev_conf,
151 struct rte_event_dev_info *info)
153 dev_conf->nb_events_limit = info->max_num_events + 1;
157 max_event_ports(struct rte_event_dev_config *dev_conf,
158 struct rte_event_dev_info *info)
160 dev_conf->nb_event_ports = info->max_event_ports + 1;
164 max_event_queues(struct rte_event_dev_config *dev_conf,
165 struct rte_event_dev_info *info)
167 dev_conf->nb_event_queues = info->max_event_queues + 1;
171 max_event_queue_flows(struct rte_event_dev_config *dev_conf,
172 struct rte_event_dev_info *info)
174 dev_conf->nb_event_queue_flows = info->max_event_queue_flows + 1;
178 max_event_port_dequeue_depth(struct rte_event_dev_config *dev_conf,
179 struct rte_event_dev_info *info)
181 dev_conf->nb_event_port_dequeue_depth =
182 info->max_event_port_dequeue_depth + 1;
186 max_event_port_enqueue_depth(struct rte_event_dev_config *dev_conf,
187 struct rte_event_dev_info *info)
189 dev_conf->nb_event_port_enqueue_depth =
190 info->max_event_port_enqueue_depth + 1;
195 test_eventdev_configure(void)
198 struct rte_event_dev_config dev_conf;
199 struct rte_event_dev_info info;
200 ret = rte_event_dev_configure(TEST_DEV_ID, NULL);
201 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
203 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
204 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
207 TEST_ASSERT_EQUAL(-EINVAL,
208 test_ethdev_config_run(&dev_conf, &info, max_dequeue_limit),
209 "Config negative test failed");
210 TEST_ASSERT_EQUAL(-EINVAL,
211 test_ethdev_config_run(&dev_conf, &info, max_events_limit),
212 "Config negative test failed");
213 TEST_ASSERT_EQUAL(-EINVAL,
214 test_ethdev_config_run(&dev_conf, &info, max_event_ports),
215 "Config negative test failed");
216 TEST_ASSERT_EQUAL(-EINVAL,
217 test_ethdev_config_run(&dev_conf, &info, max_event_queues),
218 "Config negative test failed");
219 TEST_ASSERT_EQUAL(-EINVAL,
220 test_ethdev_config_run(&dev_conf, &info, max_event_queue_flows),
221 "Config negative test failed");
222 TEST_ASSERT_EQUAL(-EINVAL,
223 test_ethdev_config_run(&dev_conf, &info,
224 max_event_port_dequeue_depth),
225 "Config negative test failed");
226 TEST_ASSERT_EQUAL(-EINVAL,
227 test_ethdev_config_run(&dev_conf, &info,
228 max_event_port_enqueue_depth),
229 "Config negative test failed");
232 devconf_set_default_sane_values(&dev_conf, &info);
233 ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
234 TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
237 devconf_set_default_sane_values(&dev_conf, &info);
238 dev_conf.nb_event_ports = RTE_MAX(info.max_event_ports/2, 1);
239 dev_conf.nb_event_queues = RTE_MAX(info.max_event_queues/2, 1);
240 ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
241 TEST_ASSERT_SUCCESS(ret, "Failed to re configure eventdev");
243 /* re-configure back to max_event_queues and max_event_ports */
244 devconf_set_default_sane_values(&dev_conf, &info);
245 ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
246 TEST_ASSERT_SUCCESS(ret, "Failed to re-configure eventdev");
253 eventdev_configure_setup(void)
256 struct rte_event_dev_config dev_conf;
257 struct rte_event_dev_info info;
259 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
260 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
261 devconf_set_default_sane_values(&dev_conf, &info);
262 ret = rte_event_dev_configure(TEST_DEV_ID, &dev_conf);
263 TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
269 test_eventdev_queue_default_conf_get(void)
272 struct rte_event_queue_conf qconf;
274 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, NULL);
275 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
277 uint32_t queue_count;
278 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
279 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
280 "Queue count get failed");
282 for (i = 0; i < (int)queue_count; i++) {
283 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i,
285 TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d info", i);
292 test_eventdev_queue_setup(void)
295 struct rte_event_dev_info info;
296 struct rte_event_queue_conf qconf;
298 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
299 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
302 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
303 TEST_ASSERT_SUCCESS(ret, "Failed to get queue0 info");
304 qconf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_ALL_TYPES;
305 qconf.nb_atomic_flows = info.max_event_queue_flows + 1;
306 ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf);
307 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
309 qconf.nb_atomic_flows = info.max_event_queue_flows;
310 qconf.schedule_type = RTE_SCHED_TYPE_ORDERED;
311 qconf.nb_atomic_order_sequences = info.max_event_queue_flows + 1;
312 ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf);
313 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
315 ret = rte_event_queue_setup(TEST_DEV_ID, info.max_event_queues,
317 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
320 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
321 TEST_ASSERT_SUCCESS(ret, "Failed to get queue0 info");
322 ret = rte_event_queue_setup(TEST_DEV_ID, 0, &qconf);
323 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue0");
325 uint32_t queue_count;
326 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
327 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
328 "Queue count get failed");
330 for (i = 0; i < (int)queue_count; i++) {
331 ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL);
332 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
339 test_eventdev_queue_count(void)
342 struct rte_event_dev_info info;
344 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
345 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
347 uint32_t queue_count;
348 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
349 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
350 "Queue count get failed");
351 TEST_ASSERT_EQUAL(queue_count, info.max_event_queues,
352 "Wrong queue count");
358 test_eventdev_queue_attr_priority(void)
361 struct rte_event_dev_info info;
362 struct rte_event_queue_conf qconf;
365 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
366 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
368 uint32_t queue_count;
369 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
370 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
371 "Queue count get failed");
373 for (i = 0; i < (int)queue_count; i++) {
374 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, i,
376 TEST_ASSERT_SUCCESS(ret, "Failed to get queue%d def conf", i);
377 qconf.priority = i % RTE_EVENT_DEV_PRIORITY_LOWEST;
378 ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
379 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
382 for (i = 0; i < (int)queue_count; i++) {
384 TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
385 RTE_EVENT_QUEUE_ATTR_PRIORITY, &tmp),
386 "Queue priority get failed");
389 if (info.event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
390 TEST_ASSERT_EQUAL(priority,
391 i % RTE_EVENT_DEV_PRIORITY_LOWEST,
392 "Wrong priority value for queue%d", i);
394 TEST_ASSERT_EQUAL(priority,
395 RTE_EVENT_DEV_PRIORITY_NORMAL,
396 "Wrong priority value for queue%d", i);
403 test_eventdev_queue_attr_nb_atomic_flows(void)
406 struct rte_event_dev_info info;
407 struct rte_event_queue_conf qconf;
408 uint32_t nb_atomic_flows;
410 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
411 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
413 uint32_t queue_count;
414 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
415 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
416 "Queue count get failed");
418 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
419 TEST_ASSERT_SUCCESS(ret, "Failed to get queue 0's def conf");
421 if (qconf.nb_atomic_flows == 0)
422 /* Assume PMD doesn't support atomic flows, return early */
425 qconf.schedule_type = RTE_SCHED_TYPE_ATOMIC;
427 for (i = 0; i < (int)queue_count; i++) {
428 ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
429 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
432 for (i = 0; i < (int)queue_count; i++) {
433 TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
434 RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS,
436 "Queue nb_atomic_flows get failed");
438 TEST_ASSERT_EQUAL(nb_atomic_flows, qconf.nb_atomic_flows,
439 "Wrong atomic flows value for queue%d", i);
446 test_eventdev_queue_attr_nb_atomic_order_sequences(void)
449 struct rte_event_dev_info info;
450 struct rte_event_queue_conf qconf;
451 uint32_t nb_atomic_order_sequences;
453 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
454 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
456 uint32_t queue_count;
457 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
458 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
459 "Queue count get failed");
461 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
462 TEST_ASSERT_SUCCESS(ret, "Failed to get queue 0's def conf");
464 if (qconf.nb_atomic_order_sequences == 0)
465 /* Assume PMD doesn't support reordering */
468 qconf.schedule_type = RTE_SCHED_TYPE_ORDERED;
470 for (i = 0; i < (int)queue_count; i++) {
471 ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
472 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
475 for (i = 0; i < (int)queue_count; i++) {
476 TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
477 RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES,
478 &nb_atomic_order_sequences),
479 "Queue nb_atomic_order_sequencess get failed");
481 TEST_ASSERT_EQUAL(nb_atomic_order_sequences,
482 qconf.nb_atomic_order_sequences,
483 "Wrong atomic order sequences value for queue%d",
491 test_eventdev_queue_attr_event_queue_cfg(void)
494 struct rte_event_dev_info info;
495 struct rte_event_queue_conf qconf;
496 uint32_t event_queue_cfg;
498 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
499 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
501 uint32_t queue_count;
502 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
503 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
504 "Queue count get failed");
506 ret = rte_event_queue_default_conf_get(TEST_DEV_ID, 0, &qconf);
507 TEST_ASSERT_SUCCESS(ret, "Failed to get queue0 def conf");
509 qconf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
511 for (i = 0; i < (int)queue_count; i++) {
512 ret = rte_event_queue_setup(TEST_DEV_ID, i, &qconf);
513 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
516 for (i = 0; i < (int)queue_count; i++) {
517 TEST_ASSERT_SUCCESS(rte_event_queue_attr_get(TEST_DEV_ID, i,
518 RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG,
520 "Queue event_queue_cfg get failed");
522 TEST_ASSERT_EQUAL(event_queue_cfg, qconf.event_queue_cfg,
523 "Wrong event_queue_cfg value for queue%d",
531 test_eventdev_port_default_conf_get(void)
534 struct rte_event_port_conf pconf;
536 ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, NULL);
537 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
540 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
541 RTE_EVENT_DEV_ATTR_PORT_COUNT,
542 &port_count), "Port count get failed");
544 ret = rte_event_port_default_conf_get(TEST_DEV_ID,
545 port_count + 1, NULL);
546 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
548 for (i = 0; i < (int)port_count; i++) {
549 ret = rte_event_port_default_conf_get(TEST_DEV_ID, i,
551 TEST_ASSERT_SUCCESS(ret, "Failed to get port%d info", i);
558 test_eventdev_port_setup(void)
561 struct rte_event_dev_info info;
562 struct rte_event_port_conf pconf;
564 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
565 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
568 ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
569 TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
570 pconf.new_event_threshold = info.max_num_events + 1;
571 ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
572 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
574 pconf.new_event_threshold = info.max_num_events;
575 pconf.dequeue_depth = info.max_event_port_dequeue_depth + 1;
576 ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
577 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
579 pconf.dequeue_depth = info.max_event_port_dequeue_depth;
580 pconf.enqueue_depth = info.max_event_port_enqueue_depth + 1;
581 ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
582 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
584 ret = rte_event_port_setup(TEST_DEV_ID, info.max_event_ports,
586 TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret);
589 ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
590 TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
591 ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
592 TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
595 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
596 RTE_EVENT_DEV_ATTR_PORT_COUNT,
597 &port_count), "Port count get failed");
599 for (i = 0; i < (int)port_count; i++) {
600 ret = rte_event_port_setup(TEST_DEV_ID, i, NULL);
601 TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i);
608 test_eventdev_port_attr_dequeue_depth(void)
611 struct rte_event_dev_info info;
612 struct rte_event_port_conf pconf;
614 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
615 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
617 ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
618 TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
619 ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
620 TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
623 TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0,
624 RTE_EVENT_PORT_ATTR_DEQ_DEPTH, &value),
625 0, "Call to get port dequeue depth failed");
626 TEST_ASSERT_EQUAL(value, pconf.dequeue_depth,
627 "Wrong port dequeue depth");
633 test_eventdev_port_attr_enqueue_depth(void)
636 struct rte_event_dev_info info;
637 struct rte_event_port_conf pconf;
639 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
640 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
642 ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
643 TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
644 ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
645 TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
648 TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0,
649 RTE_EVENT_PORT_ATTR_ENQ_DEPTH, &value),
650 0, "Call to get port enqueue depth failed");
651 TEST_ASSERT_EQUAL(value, pconf.enqueue_depth,
652 "Wrong port enqueue depth");
658 test_eventdev_port_attr_new_event_threshold(void)
661 struct rte_event_dev_info info;
662 struct rte_event_port_conf pconf;
664 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
665 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
667 ret = rte_event_port_default_conf_get(TEST_DEV_ID, 0, &pconf);
668 TEST_ASSERT_SUCCESS(ret, "Failed to get port0 info");
669 ret = rte_event_port_setup(TEST_DEV_ID, 0, &pconf);
670 TEST_ASSERT_SUCCESS(ret, "Failed to setup port0");
673 TEST_ASSERT_EQUAL(rte_event_port_attr_get(TEST_DEV_ID, 0,
674 RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD, &value),
675 0, "Call to get port new event threshold failed");
676 TEST_ASSERT_EQUAL((int32_t) value, pconf.new_event_threshold,
677 "Wrong port new event threshold");
683 test_eventdev_port_count(void)
686 struct rte_event_dev_info info;
688 ret = rte_event_dev_info_get(TEST_DEV_ID, &info);
689 TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
692 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
693 RTE_EVENT_DEV_ATTR_PORT_COUNT,
694 &port_count), "Port count get failed");
695 TEST_ASSERT_EQUAL(port_count, info.max_event_ports, "Wrong port count");
701 test_eventdev_timeout_ticks(void)
704 uint64_t timeout_ticks;
706 ret = rte_event_dequeue_timeout_ticks(TEST_DEV_ID, 100, &timeout_ticks);
708 TEST_ASSERT_SUCCESS(ret, "Fail to get timeout_ticks");
715 test_eventdev_start_stop(void)
719 ret = eventdev_configure_setup();
720 TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
722 uint32_t queue_count;
723 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
724 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
725 "Queue count get failed");
726 for (i = 0; i < (int)queue_count; i++) {
727 ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL);
728 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
732 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
733 RTE_EVENT_DEV_ATTR_PORT_COUNT,
734 &port_count), "Port count get failed");
736 for (i = 0; i < (int)port_count; i++) {
737 ret = rte_event_port_setup(TEST_DEV_ID, i, NULL);
738 TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i);
741 ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
742 TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d",
745 ret = rte_event_dev_start(TEST_DEV_ID);
746 TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID);
748 rte_event_dev_stop(TEST_DEV_ID);
754 eventdev_setup_device(void)
758 ret = eventdev_configure_setup();
759 TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
761 uint32_t queue_count;
762 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
763 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
764 "Queue count get failed");
765 for (i = 0; i < (int)queue_count; i++) {
766 ret = rte_event_queue_setup(TEST_DEV_ID, i, NULL);
767 TEST_ASSERT_SUCCESS(ret, "Failed to setup queue%d", i);
771 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
772 RTE_EVENT_DEV_ATTR_PORT_COUNT,
773 &port_count), "Port count get failed");
775 for (i = 0; i < (int)port_count; i++) {
776 ret = rte_event_port_setup(TEST_DEV_ID, i, NULL);
777 TEST_ASSERT_SUCCESS(ret, "Failed to setup port%d", i);
780 ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
781 TEST_ASSERT(ret == (int)queue_count, "Failed to link port, device %d",
784 ret = rte_event_dev_start(TEST_DEV_ID);
785 TEST_ASSERT_SUCCESS(ret, "Failed to start device%d", TEST_DEV_ID);
791 eventdev_stop_device(void)
793 rte_event_dev_stop(TEST_DEV_ID);
797 test_eventdev_link(void)
799 int ret, nb_queues, i;
800 uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
801 uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
803 ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
804 TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d",
807 uint32_t queue_count;
808 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
809 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
810 "Queue count get failed");
811 nb_queues = queue_count;
812 for (i = 0; i < nb_queues; i++) {
814 priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL;
817 ret = rte_event_port_link(TEST_DEV_ID, 0, queues,
818 priorities, nb_queues);
819 TEST_ASSERT(ret == nb_queues, "Failed to link(device%d) ret=%d",
825 test_eventdev_unlink(void)
827 int ret, nb_queues, i;
828 uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
830 ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0);
831 TEST_ASSERT(ret >= 0, "Failed to unlink with NULL device%d",
834 uint32_t queue_count;
835 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
836 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
837 "Queue count get failed");
838 nb_queues = queue_count;
839 for (i = 0; i < nb_queues; i++)
843 ret = rte_event_port_unlink(TEST_DEV_ID, 0, queues, nb_queues);
844 TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d",
850 test_eventdev_link_get(void)
853 uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
854 uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
856 /* link all queues */
857 ret = rte_event_port_link(TEST_DEV_ID, 0, NULL, NULL, 0);
858 TEST_ASSERT(ret >= 0, "Failed to link with NULL device%d",
861 uint32_t queue_count;
862 TEST_ASSERT_SUCCESS(rte_event_dev_attr_get(TEST_DEV_ID,
863 RTE_EVENT_DEV_ATTR_QUEUE_COUNT, &queue_count),
864 "Queue count get failed");
865 const int nb_queues = queue_count;
866 for (i = 0; i < nb_queues; i++)
869 ret = rte_event_port_unlink(TEST_DEV_ID, 0, queues, nb_queues);
870 TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d",
873 ret = rte_event_port_links_get(TEST_DEV_ID, 0, queues, priorities);
874 TEST_ASSERT(ret == 0, "(%d)Wrong link get=%d", TEST_DEV_ID, ret);
876 /* link all queues and get the links */
877 for (i = 0; i < nb_queues; i++) {
879 priorities[i] = RTE_EVENT_DEV_PRIORITY_NORMAL;
881 ret = rte_event_port_link(TEST_DEV_ID, 0, queues, priorities,
883 TEST_ASSERT(ret == nb_queues, "Failed to link(device%d) ret=%d",
885 ret = rte_event_port_links_get(TEST_DEV_ID, 0, queues, priorities);
886 TEST_ASSERT(ret == nb_queues, "(%d)Wrong link get ret=%d expected=%d",
887 TEST_DEV_ID, ret, nb_queues);
889 ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0);
890 TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d",
892 /* link just one queue */
894 priorities[0] = RTE_EVENT_DEV_PRIORITY_NORMAL;
896 ret = rte_event_port_link(TEST_DEV_ID, 0, queues, priorities, 1);
897 TEST_ASSERT(ret == 1, "Failed to link(device%d) ret=%d",
899 ret = rte_event_port_links_get(TEST_DEV_ID, 0, queues, priorities);
900 TEST_ASSERT(ret == 1, "(%d)Wrong link get ret=%d expected=%d",
901 TEST_DEV_ID, ret, 1);
903 ret = rte_event_port_unlink(TEST_DEV_ID, 0, NULL, 0);
904 TEST_ASSERT(ret == nb_queues, "Failed to unlink(device%d) ret=%d",
907 /* 4links and 2 unlinks */
908 if (nb_queues >= 4) {
909 for (i = 0; i < 4; i++) {
911 priorities[i] = 0x40;
913 ret = rte_event_port_link(TEST_DEV_ID, 0, queues, priorities,
915 TEST_ASSERT(ret == 4, "Failed to link(device%d) ret=%d",
918 for (i = 0; i < 2; i++)
921 ret = rte_event_port_unlink(TEST_DEV_ID, 0, queues, 2);
922 TEST_ASSERT(ret == 2, "Failed to unlink(device%d) ret=%d",
924 ret = rte_event_port_links_get(TEST_DEV_ID, 0,
926 TEST_ASSERT(ret == 2, "(%d)Wrong link get ret=%d expected=%d",
927 TEST_DEV_ID, ret, 2);
928 TEST_ASSERT(queues[0] == 2, "ret=%d expected=%d", ret, 2);
929 TEST_ASSERT(priorities[0] == 0x40, "ret=%d expected=%d",
931 TEST_ASSERT(queues[1] == 3, "ret=%d expected=%d", ret, 3);
932 TEST_ASSERT(priorities[1] == 0x40, "ret=%d expected=%d",
940 test_eventdev_close(void)
942 rte_event_dev_stop(TEST_DEV_ID);
943 return rte_event_dev_close(TEST_DEV_ID);
946 static struct unit_test_suite eventdev_common_testsuite = {
947 .suite_name = "eventdev common code unit test suite",
948 .setup = testsuite_setup,
949 .teardown = testsuite_teardown,
951 TEST_CASE_ST(NULL, NULL,
952 test_eventdev_count),
953 TEST_CASE_ST(NULL, NULL,
954 test_eventdev_get_dev_id),
955 TEST_CASE_ST(NULL, NULL,
956 test_eventdev_socket_id),
957 TEST_CASE_ST(NULL, NULL,
958 test_eventdev_info_get),
959 TEST_CASE_ST(NULL, NULL,
960 test_eventdev_configure),
961 TEST_CASE_ST(eventdev_configure_setup, NULL,
962 test_eventdev_queue_default_conf_get),
963 TEST_CASE_ST(eventdev_configure_setup, NULL,
964 test_eventdev_queue_setup),
965 TEST_CASE_ST(eventdev_configure_setup, NULL,
966 test_eventdev_queue_count),
967 TEST_CASE_ST(eventdev_configure_setup, NULL,
968 test_eventdev_queue_attr_priority),
969 TEST_CASE_ST(eventdev_configure_setup, NULL,
970 test_eventdev_queue_attr_nb_atomic_flows),
971 TEST_CASE_ST(eventdev_configure_setup, NULL,
972 test_eventdev_queue_attr_nb_atomic_order_sequences),
973 TEST_CASE_ST(eventdev_configure_setup, NULL,
974 test_eventdev_queue_attr_event_queue_cfg),
975 TEST_CASE_ST(eventdev_configure_setup, NULL,
976 test_eventdev_port_default_conf_get),
977 TEST_CASE_ST(eventdev_configure_setup, NULL,
978 test_eventdev_port_setup),
979 TEST_CASE_ST(eventdev_configure_setup, NULL,
980 test_eventdev_port_attr_dequeue_depth),
981 TEST_CASE_ST(eventdev_configure_setup, NULL,
982 test_eventdev_port_attr_enqueue_depth),
983 TEST_CASE_ST(eventdev_configure_setup, NULL,
984 test_eventdev_port_attr_new_event_threshold),
985 TEST_CASE_ST(eventdev_configure_setup, NULL,
986 test_eventdev_port_count),
987 TEST_CASE_ST(eventdev_configure_setup, NULL,
988 test_eventdev_timeout_ticks),
989 TEST_CASE_ST(NULL, NULL,
990 test_eventdev_start_stop),
991 TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
993 TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
994 test_eventdev_unlink),
995 TEST_CASE_ST(eventdev_setup_device, eventdev_stop_device,
996 test_eventdev_link_get),
997 TEST_CASE_ST(eventdev_setup_device, NULL,
998 test_eventdev_close),
999 TEST_CASES_END() /**< NULL terminate unit test array */
1004 test_eventdev_common(void)
1006 return unit_test_suite_runner(&eventdev_common_testsuite);
1009 REGISTER_TEST_COMMAND(eventdev_common_autotest, test_eventdev_common);