774d0303ba026ef1fcdc3ad10f47dd134503edf2
[dpdk.git] / test / test / test_eventdev_octeontx.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Cavium, Inc. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *       * Redistributions of source code must retain the above copyright
11  *         notice, this list of conditions and the following disclaimer.
12  *       * Redistributions in binary form must reproduce the above copyright
13  *         notice, this list of conditions and the following disclaimer in
14  *         the documentation and/or other materials provided with the
15  *         distribution.
16  *       * Neither the name of Cavium, 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.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #include <rte_atomic.h>
34 #include <rte_common.h>
35 #include <rte_cycles.h>
36 #include <rte_debug.h>
37 #include <rte_eal.h>
38 #include <rte_ethdev.h>
39 #include <rte_eventdev.h>
40 #include <rte_hexdump.h>
41 #include <rte_mbuf.h>
42 #include <rte_malloc.h>
43 #include <rte_memcpy.h>
44 #include <rte_launch.h>
45 #include <rte_lcore.h>
46 #include <rte_per_lcore.h>
47 #include <rte_random.h>
48
49 #include "test.h"
50
51 #define NUM_PACKETS (1 << 18)
52 #define MAX_EVENTS  (16 * 1024)
53
54 static int evdev;
55 static struct rte_mempool *eventdev_test_mempool;
56
57 struct event_attr {
58         uint32_t flow_id;
59         uint8_t event_type;
60         uint8_t sub_event_type;
61         uint8_t sched_type;
62         uint8_t queue;
63         uint8_t port;
64 };
65
66 static uint32_t seqn_list_index;
67 static int seqn_list[NUM_PACKETS];
68
69 static inline void
70 seqn_list_init(void)
71 {
72         RTE_BUILD_BUG_ON(NUM_PACKETS < MAX_EVENTS);
73         memset(seqn_list, 0, sizeof(seqn_list));
74         seqn_list_index = 0;
75 }
76
77 static inline int
78 seqn_list_update(int val)
79 {
80         if (seqn_list_index >= NUM_PACKETS)
81                 return TEST_FAILED;
82
83         seqn_list[seqn_list_index++] = val;
84         rte_smp_wmb();
85         return TEST_SUCCESS;
86 }
87
88 static inline int
89 seqn_list_check(int limit)
90 {
91         int i;
92
93         for (i = 0; i < limit; i++) {
94                 if (seqn_list[i] != i) {
95                         printf("Seqn mismatch %d %d\n", seqn_list[i], i);
96                         return TEST_FAILED;
97                 }
98         }
99         return TEST_SUCCESS;
100 }
101
102 struct test_core_param {
103         rte_atomic32_t *total_events;
104         uint64_t dequeue_tmo_ticks;
105         uint8_t port;
106         uint8_t sched_type;
107 };
108
109 static int
110 testsuite_setup(void)
111 {
112         const char *eventdev_name = "event_octeontx";
113
114         evdev = rte_event_dev_get_dev_id(eventdev_name);
115         if (evdev < 0) {
116                 printf("%d: Eventdev %s not found - creating.\n",
117                                 __LINE__, eventdev_name);
118                 if (rte_vdev_init(eventdev_name, NULL) < 0) {
119                         printf("Error creating eventdev %s\n", eventdev_name);
120                         return TEST_FAILED;
121                 }
122                 evdev = rte_event_dev_get_dev_id(eventdev_name);
123                 if (evdev < 0) {
124                         printf("Error finding newly created eventdev\n");
125                         return TEST_FAILED;
126                 }
127         }
128
129         return TEST_SUCCESS;
130 }
131
132 static void
133 testsuite_teardown(void)
134 {
135         rte_event_dev_close(evdev);
136 }
137
138 static inline void
139 devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf,
140                         struct rte_event_dev_info *info)
141 {
142         memset(dev_conf, 0, sizeof(struct rte_event_dev_config));
143         dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns;
144         dev_conf->nb_event_ports = info->max_event_ports;
145         dev_conf->nb_event_queues = info->max_event_queues;
146         dev_conf->nb_event_queue_flows = info->max_event_queue_flows;
147         dev_conf->nb_event_port_dequeue_depth =
148                         info->max_event_port_dequeue_depth;
149         dev_conf->nb_event_port_enqueue_depth =
150                         info->max_event_port_enqueue_depth;
151         dev_conf->nb_event_port_enqueue_depth =
152                         info->max_event_port_enqueue_depth;
153         dev_conf->nb_events_limit =
154                         info->max_num_events;
155 }
156
157 enum {
158         TEST_EVENTDEV_SETUP_DEFAULT,
159         TEST_EVENTDEV_SETUP_PRIORITY,
160         TEST_EVENTDEV_SETUP_DEQUEUE_TIMEOUT,
161 };
162
163 static inline int
164 _eventdev_setup(int mode)
165 {
166         int i, ret;
167         struct rte_event_dev_config dev_conf;
168         struct rte_event_dev_info info;
169         const char *pool_name = "evdev_octeontx_test_pool";
170
171         /* Create and destrory pool for each test case to make it standalone */
172         eventdev_test_mempool = rte_pktmbuf_pool_create(pool_name,
173                                         MAX_EVENTS,
174                                         0 /*MBUF_CACHE_SIZE*/,
175                                         0,
176                                         512, /* Use very small mbufs */
177                                         rte_socket_id());
178         if (!eventdev_test_mempool) {
179                 printf("ERROR creating mempool\n");
180                 return TEST_FAILED;
181         }
182
183         ret = rte_event_dev_info_get(evdev, &info);
184         TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
185         TEST_ASSERT(info.max_num_events >= (int32_t)MAX_EVENTS,
186                         "max_num_events=%d < max_events=%d",
187                         info.max_num_events, MAX_EVENTS);
188
189         devconf_set_default_sane_values(&dev_conf, &info);
190         if (mode == TEST_EVENTDEV_SETUP_DEQUEUE_TIMEOUT)
191                 dev_conf.event_dev_cfg |= RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
192
193         ret = rte_event_dev_configure(evdev, &dev_conf);
194         TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev");
195
196         if (mode == TEST_EVENTDEV_SETUP_PRIORITY) {
197                 if (rte_event_queue_count(evdev) > 8) {
198                         printf("test expects the unique priority per queue\n");
199                         return -ENOTSUP;
200                 }
201
202                 /* Configure event queues(0 to n) with
203                  * RTE_EVENT_DEV_PRIORITY_HIGHEST to
204                  * RTE_EVENT_DEV_PRIORITY_LOWEST
205                  */
206                 uint8_t step = (RTE_EVENT_DEV_PRIORITY_LOWEST + 1) /
207                                 rte_event_queue_count(evdev);
208                 for (i = 0; i < rte_event_queue_count(evdev); i++) {
209                         struct rte_event_queue_conf queue_conf;
210
211                         ret = rte_event_queue_default_conf_get(evdev, i,
212                                                 &queue_conf);
213                         TEST_ASSERT_SUCCESS(ret, "Failed to get def_conf%d", i);
214                         queue_conf.priority = i * step;
215                         ret = rte_event_queue_setup(evdev, i, &queue_conf);
216                         TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%d", i);
217                 }
218
219         } else {
220                 /* Configure event queues with default priority */
221                 for (i = 0; i < rte_event_queue_count(evdev); i++) {
222                         ret = rte_event_queue_setup(evdev, i, NULL);
223                         TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%d", i);
224                 }
225         }
226         /* Configure event ports */
227         for (i = 0; i < rte_event_port_count(evdev); i++) {
228                 ret = rte_event_port_setup(evdev, i, NULL);
229                 TEST_ASSERT_SUCCESS(ret, "Failed to setup port=%d", i);
230                 ret = rte_event_port_link(evdev, i, NULL, NULL, 0);
231                 TEST_ASSERT(ret >= 0, "Failed to link all queues port=%d", i);
232         }
233
234         ret = rte_event_dev_start(evdev);
235         TEST_ASSERT_SUCCESS(ret, "Failed to start device");
236
237         return TEST_SUCCESS;
238 }
239
240 static inline int
241 eventdev_setup(void)
242 {
243         return _eventdev_setup(TEST_EVENTDEV_SETUP_DEFAULT);
244 }
245
246 static inline int
247 eventdev_setup_priority(void)
248 {
249         return _eventdev_setup(TEST_EVENTDEV_SETUP_PRIORITY);
250 }
251
252 static inline int
253 eventdev_setup_dequeue_timeout(void)
254 {
255         return _eventdev_setup(TEST_EVENTDEV_SETUP_DEQUEUE_TIMEOUT);
256 }
257
258 static inline void
259 eventdev_teardown(void)
260 {
261         rte_event_dev_stop(evdev);
262         rte_mempool_free(eventdev_test_mempool);
263 }
264
265 static inline void
266 update_event_and_validation_attr(struct rte_mbuf *m, struct rte_event *ev,
267                         uint32_t flow_id, uint8_t event_type,
268                         uint8_t sub_event_type, uint8_t sched_type,
269                         uint8_t queue, uint8_t port)
270 {
271         struct event_attr *attr;
272
273         /* Store the event attributes in mbuf for future reference */
274         attr = rte_pktmbuf_mtod(m, struct event_attr *);
275         attr->flow_id = flow_id;
276         attr->event_type = event_type;
277         attr->sub_event_type = sub_event_type;
278         attr->sched_type = sched_type;
279         attr->queue = queue;
280         attr->port = port;
281
282         ev->flow_id = flow_id;
283         ev->sub_event_type = sub_event_type;
284         ev->event_type = event_type;
285         /* Inject the new event */
286         ev->op = RTE_EVENT_OP_NEW;
287         ev->sched_type = sched_type;
288         ev->queue_id = queue;
289         ev->mbuf = m;
290 }
291
292 static inline int
293 inject_events(uint32_t flow_id, uint8_t event_type, uint8_t sub_event_type,
294                 uint8_t sched_type, uint8_t queue, uint8_t port,
295                 unsigned int events)
296 {
297         struct rte_mbuf *m;
298         unsigned int i;
299
300         for (i = 0; i < events; i++) {
301                 struct rte_event ev = {.event = 0, .u64 = 0};
302
303                 m = rte_pktmbuf_alloc(eventdev_test_mempool);
304                 TEST_ASSERT_NOT_NULL(m, "mempool alloc failed");
305
306                 m->seqn = i;
307                 update_event_and_validation_attr(m, &ev, flow_id, event_type,
308                         sub_event_type, sched_type, queue, port);
309                 rte_event_enqueue_burst(evdev, port, &ev, 1);
310         }
311         return 0;
312 }
313
314 static inline int
315 check_excess_events(uint8_t port)
316 {
317         int i;
318         uint16_t valid_event;
319         struct rte_event ev;
320
321         /* Check for excess events, try for a few times and exit */
322         for (i = 0; i < 32; i++) {
323                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
324
325                 TEST_ASSERT_SUCCESS(valid_event, "Unexpected valid event=%d",
326                                         ev.mbuf->seqn);
327         }
328         return 0;
329 }
330
331 static inline int
332 generate_random_events(const unsigned int total_events)
333 {
334         struct rte_event_dev_info info;
335         unsigned int i;
336         int ret;
337
338         ret = rte_event_dev_info_get(evdev, &info);
339         TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
340         for (i = 0; i < total_events; i++) {
341                 ret = inject_events(
342                         rte_rand() % info.max_event_queue_flows /*flow_id */,
343                         rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */,
344                         rte_rand() % 256 /* sub_event_type */,
345                         rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1),
346                         rte_rand() % rte_event_queue_count(evdev) /* queue */,
347                         0 /* port */,
348                         1 /* events */);
349                 if (ret)
350                         return TEST_FAILED;
351         }
352         return ret;
353 }
354
355
356 static inline int
357 validate_event(struct rte_event *ev)
358 {
359         struct event_attr *attr;
360
361         attr = rte_pktmbuf_mtod(ev->mbuf, struct event_attr *);
362         TEST_ASSERT_EQUAL(attr->flow_id, ev->flow_id,
363                         "flow_id mismatch enq=%d deq =%d",
364                         attr->flow_id, ev->flow_id);
365         TEST_ASSERT_EQUAL(attr->event_type, ev->event_type,
366                         "event_type mismatch enq=%d deq =%d",
367                         attr->event_type, ev->event_type);
368         TEST_ASSERT_EQUAL(attr->sub_event_type, ev->sub_event_type,
369                         "sub_event_type mismatch enq=%d deq =%d",
370                         attr->sub_event_type, ev->sub_event_type);
371         TEST_ASSERT_EQUAL(attr->sched_type, ev->sched_type,
372                         "sched_type mismatch enq=%d deq =%d",
373                         attr->sched_type, ev->sched_type);
374         TEST_ASSERT_EQUAL(attr->queue, ev->queue_id,
375                         "queue mismatch enq=%d deq =%d",
376                         attr->queue, ev->queue_id);
377         return 0;
378 }
379
380 typedef int (*validate_event_cb)(uint32_t index, uint8_t port,
381                                  struct rte_event *ev);
382
383 static inline int
384 consume_events(uint8_t port, const uint32_t total_events, validate_event_cb fn)
385 {
386         int ret;
387         uint16_t valid_event;
388         uint32_t events = 0, forward_progress_cnt = 0, index = 0;
389         struct rte_event ev;
390
391         while (1) {
392                 if (++forward_progress_cnt > UINT16_MAX) {
393                         printf("Detected deadlock\n");
394                         return TEST_FAILED;
395                 }
396
397                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
398                 if (!valid_event)
399                         continue;
400
401                 forward_progress_cnt = 0;
402                 ret = validate_event(&ev);
403                 if (ret)
404                         return TEST_FAILED;
405
406                 if (fn != NULL) {
407                         ret = fn(index, port, &ev);
408                         TEST_ASSERT_SUCCESS(ret,
409                                 "Failed to validate test specific event");
410                 }
411
412                 ++index;
413
414                 rte_pktmbuf_free(ev.mbuf);
415                 if (++events >= total_events)
416                         break;
417         }
418
419         return check_excess_events(port);
420 }
421
422 static int
423 validate_simple_enqdeq(uint32_t index, uint8_t port, struct rte_event *ev)
424 {
425         RTE_SET_USED(port);
426         TEST_ASSERT_EQUAL(index, ev->mbuf->seqn, "index=%d != seqn=%d", index,
427                                         ev->mbuf->seqn);
428         return 0;
429 }
430
431 static inline int
432 test_simple_enqdeq(uint8_t sched_type)
433 {
434         int ret;
435
436         ret = inject_events(0 /*flow_id */,
437                                 RTE_EVENT_TYPE_CPU /* event_type */,
438                                 0 /* sub_event_type */,
439                                 sched_type,
440                                 0 /* queue */,
441                                 0 /* port */,
442                                 MAX_EVENTS);
443         if (ret)
444                 return TEST_FAILED;
445
446         return consume_events(0 /* port */, MAX_EVENTS, validate_simple_enqdeq);
447 }
448
449 static int
450 test_simple_enqdeq_ordered(void)
451 {
452         return test_simple_enqdeq(RTE_SCHED_TYPE_ORDERED);
453 }
454
455 static int
456 test_simple_enqdeq_atomic(void)
457 {
458         return test_simple_enqdeq(RTE_SCHED_TYPE_ATOMIC);
459 }
460
461 static int
462 test_simple_enqdeq_parallel(void)
463 {
464         return test_simple_enqdeq(RTE_SCHED_TYPE_PARALLEL);
465 }
466
467 /*
468  * Generate a prescribed number of events and spread them across available
469  * queues. On dequeue, using single event port(port 0) verify the enqueued
470  * event attributes
471  */
472 static int
473 test_multi_queue_enq_single_port_deq(void)
474 {
475         int ret;
476
477         ret = generate_random_events(MAX_EVENTS);
478         if (ret)
479                 return TEST_FAILED;
480
481         return consume_events(0 /* port */, MAX_EVENTS, NULL);
482 }
483
484 /*
485  * Inject 0..MAX_EVENTS events over 0..rte_event_queue_count() with modulus
486  * operation
487  *
488  * For example, Inject 32 events over 0..7 queues
489  * enqueue events 0, 8, 16, 24 in queue 0
490  * enqueue events 1, 9, 17, 25 in queue 1
491  * ..
492  * ..
493  * enqueue events 7, 15, 23, 31 in queue 7
494  *
495  * On dequeue, Validate the events comes in 0,8,16,24,1,9,17,25..,7,15,23,31
496  * order from queue0(highest priority) to queue7(lowest_priority)
497  */
498 static int
499 validate_queue_priority(uint32_t index, uint8_t port, struct rte_event *ev)
500 {
501         uint32_t range = MAX_EVENTS / rte_event_queue_count(evdev);
502         uint32_t expected_val = (index % range) * rte_event_queue_count(evdev);
503
504         expected_val += ev->queue_id;
505         RTE_SET_USED(port);
506         TEST_ASSERT_EQUAL(ev->mbuf->seqn, expected_val,
507         "seqn=%d index=%d expected=%d range=%d nb_queues=%d max_event=%d",
508                         ev->mbuf->seqn, index, expected_val, range,
509                         rte_event_queue_count(evdev), MAX_EVENTS);
510         return 0;
511 }
512
513 static int
514 test_multi_queue_priority(void)
515 {
516         uint8_t queue;
517         struct rte_mbuf *m;
518         int i, max_evts_roundoff;
519
520         /* See validate_queue_priority() comments for priority validate logic */
521         max_evts_roundoff  = MAX_EVENTS / rte_event_queue_count(evdev);
522         max_evts_roundoff *= rte_event_queue_count(evdev);
523
524         for (i = 0; i < max_evts_roundoff; i++) {
525                 struct rte_event ev = {.event = 0, .u64 = 0};
526
527                 m = rte_pktmbuf_alloc(eventdev_test_mempool);
528                 TEST_ASSERT_NOT_NULL(m, "mempool alloc failed");
529
530                 m->seqn = i;
531                 queue = i % rte_event_queue_count(evdev);
532                 update_event_and_validation_attr(m, &ev, 0, RTE_EVENT_TYPE_CPU,
533                         0, RTE_SCHED_TYPE_PARALLEL, queue, 0);
534                 rte_event_enqueue_burst(evdev, 0, &ev, 1);
535         }
536
537         return consume_events(0, max_evts_roundoff, validate_queue_priority);
538 }
539
540 static int
541 worker_multi_port_fn(void *arg)
542 {
543         struct test_core_param *param = arg;
544         struct rte_event ev;
545         uint16_t valid_event;
546         uint8_t port = param->port;
547         rte_atomic32_t *total_events = param->total_events;
548         int ret;
549
550         while (rte_atomic32_read(total_events) > 0) {
551                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
552                 if (!valid_event)
553                         continue;
554
555                 ret = validate_event(&ev);
556                 TEST_ASSERT_SUCCESS(ret, "Failed to validate event");
557                 rte_pktmbuf_free(ev.mbuf);
558                 rte_atomic32_sub(total_events, 1);
559         }
560         return 0;
561 }
562
563 static inline int
564 wait_workers_to_join(int lcore, const rte_atomic32_t *count)
565 {
566         uint64_t cycles, print_cycles;
567
568         print_cycles = cycles = rte_get_timer_cycles();
569         while (rte_eal_get_lcore_state(lcore) != FINISHED) {
570                 uint64_t new_cycles = rte_get_timer_cycles();
571
572                 if (new_cycles - print_cycles > rte_get_timer_hz()) {
573                         printf("\r%s: events %d\n", __func__,
574                                 rte_atomic32_read(count));
575                         print_cycles = new_cycles;
576                 }
577                 if (new_cycles - cycles > rte_get_timer_hz() * 10) {
578                         printf("%s: No schedules for seconds, deadlock (%d)\n",
579                                 __func__,
580                                 rte_atomic32_read(count));
581                         rte_event_dev_dump(evdev, stdout);
582                         cycles = new_cycles;
583                         return TEST_FAILED;
584                 }
585         }
586         rte_eal_mp_wait_lcore();
587         return TEST_SUCCESS;
588 }
589
590
591 static inline int
592 launch_workers_and_wait(int (*master_worker)(void *),
593                         int (*slave_workers)(void *), uint32_t total_events,
594                         uint8_t nb_workers, uint8_t sched_type)
595 {
596         uint8_t port = 0;
597         int w_lcore;
598         int ret;
599         struct test_core_param *param;
600         rte_atomic32_t atomic_total_events;
601         uint64_t dequeue_tmo_ticks;
602
603         if (!nb_workers)
604                 return 0;
605
606         rte_atomic32_set(&atomic_total_events, total_events);
607         seqn_list_init();
608
609         param = malloc(sizeof(struct test_core_param) * nb_workers);
610         if (!param)
611                 return TEST_FAILED;
612
613         ret = rte_event_dequeue_timeout_ticks(evdev,
614                 rte_rand() % 10000000/* 10ms */, &dequeue_tmo_ticks);
615         if (ret)
616                 return TEST_FAILED;
617
618         param[0].total_events = &atomic_total_events;
619         param[0].sched_type = sched_type;
620         param[0].port = 0;
621         param[0].dequeue_tmo_ticks = dequeue_tmo_ticks;
622         rte_smp_wmb();
623
624         w_lcore = rte_get_next_lcore(
625                         /* start core */ -1,
626                         /* skip master */ 1,
627                         /* wrap */ 0);
628         rte_eal_remote_launch(master_worker, &param[0], w_lcore);
629
630         for (port = 1; port < nb_workers; port++) {
631                 param[port].total_events = &atomic_total_events;
632                 param[port].sched_type = sched_type;
633                 param[port].port = port;
634                 param[port].dequeue_tmo_ticks = dequeue_tmo_ticks;
635                 rte_smp_wmb();
636                 w_lcore = rte_get_next_lcore(w_lcore, 1, 0);
637                 rte_eal_remote_launch(slave_workers, &param[port], w_lcore);
638         }
639
640         ret = wait_workers_to_join(w_lcore, &atomic_total_events);
641         free(param);
642         return ret;
643 }
644
645 /*
646  * Generate a prescribed number of events and spread them across available
647  * queues. Dequeue the events through multiple ports and verify the enqueued
648  * event attributes
649  */
650 static int
651 test_multi_queue_enq_multi_port_deq(void)
652 {
653         const unsigned int total_events = MAX_EVENTS;
654         uint8_t nr_ports;
655         int ret;
656
657         ret = generate_random_events(total_events);
658         if (ret)
659                 return TEST_FAILED;
660
661         nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1);
662
663         if (!nr_ports) {
664                 printf("%s: Not enough ports=%d or workers=%d\n", __func__,
665                         rte_event_port_count(evdev), rte_lcore_count() - 1);
666                 return TEST_SUCCESS;
667         }
668
669         return launch_workers_and_wait(worker_multi_port_fn,
670                                         worker_multi_port_fn, total_events,
671                                         nr_ports, 0xff /* invalid */);
672 }
673
674 static int
675 validate_queue_to_port_single_link(uint32_t index, uint8_t port,
676                         struct rte_event *ev)
677 {
678         RTE_SET_USED(index);
679         TEST_ASSERT_EQUAL(port, ev->queue_id,
680                                 "queue mismatch enq=%d deq =%d",
681                                 port, ev->queue_id);
682         return 0;
683 }
684
685 /*
686  * Link queue x to port x and check correctness of link by checking
687  * queue_id == x on dequeue on the specific port x
688  */
689 static int
690 test_queue_to_port_single_link(void)
691 {
692         int i, nr_links, ret;
693
694         /* Unlink all connections that created in eventdev_setup */
695         for (i = 0; i < rte_event_port_count(evdev); i++) {
696                 ret = rte_event_port_unlink(evdev, i, NULL, 0);
697                 TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d", i);
698         }
699
700         nr_links = RTE_MIN(rte_event_port_count(evdev),
701                                 rte_event_queue_count(evdev));
702         const unsigned int total_events = MAX_EVENTS / nr_links;
703
704         /* Link queue x to port x and inject events to queue x through port x */
705         for (i = 0; i < nr_links; i++) {
706                 uint8_t queue = (uint8_t)i;
707
708                 ret = rte_event_port_link(evdev, i, &queue, NULL, 1);
709                 TEST_ASSERT(ret == 1, "Failed to link queue to port %d", i);
710
711                 ret = inject_events(
712                         0x100 /*flow_id */,
713                         rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */,
714                         rte_rand() % 256 /* sub_event_type */,
715                         rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1),
716                         queue /* queue */,
717                         i /* port */,
718                         total_events /* events */);
719                 if (ret)
720                         return TEST_FAILED;
721         }
722
723         /* Verify the events generated from correct queue */
724         for (i = 0; i < nr_links; i++) {
725                 ret = consume_events(i /* port */, total_events,
726                                 validate_queue_to_port_single_link);
727                 if (ret)
728                         return TEST_FAILED;
729         }
730
731         return TEST_SUCCESS;
732 }
733
734 static int
735 validate_queue_to_port_multi_link(uint32_t index, uint8_t port,
736                         struct rte_event *ev)
737 {
738         RTE_SET_USED(index);
739         TEST_ASSERT_EQUAL(port, (ev->queue_id & 0x1),
740                                 "queue mismatch enq=%d deq =%d",
741                                 port, ev->queue_id);
742         return 0;
743 }
744
745 /*
746  * Link all even number of queues to port 0 and all odd number of queues to
747  * port 1 and verify the link connection on dequeue
748  */
749 static int
750 test_queue_to_port_multi_link(void)
751 {
752         int ret, port0_events = 0, port1_events = 0;
753         uint8_t nr_queues, nr_ports, queue, port;
754
755         nr_queues = rte_event_queue_count(evdev);
756         nr_ports = rte_event_port_count(evdev);
757
758         if (nr_ports < 2) {
759                 printf("%s: Not enough ports to test ports=%d\n",
760                                 __func__, nr_ports);
761                 return TEST_SUCCESS;
762         }
763
764         /* Unlink all connections that created in eventdev_setup */
765         for (port = 0; port < nr_ports; port++) {
766                 ret = rte_event_port_unlink(evdev, port, NULL, 0);
767                 TEST_ASSERT(ret >= 0, "Failed to unlink all queues port=%d",
768                                         port);
769         }
770
771         const unsigned int total_events = MAX_EVENTS / nr_queues;
772
773         /* Link all even number of queues to port0 and odd numbers to port 1*/
774         for (queue = 0; queue < nr_queues; queue++) {
775                 port = queue & 0x1;
776                 ret = rte_event_port_link(evdev, port, &queue, NULL, 1);
777                 TEST_ASSERT(ret == 1, "Failed to link queue=%d to port=%d",
778                                         queue, port);
779
780                 ret = inject_events(
781                         0x100 /*flow_id */,
782                         rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */,
783                         rte_rand() % 256 /* sub_event_type */,
784                         rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1),
785                         queue /* queue */,
786                         port /* port */,
787                         total_events /* events */);
788                 if (ret)
789                         return TEST_FAILED;
790
791                 if (port == 0)
792                         port0_events += total_events;
793                 else
794                         port1_events += total_events;
795         }
796
797         ret = consume_events(0 /* port */, port0_events,
798                                 validate_queue_to_port_multi_link);
799         if (ret)
800                 return TEST_FAILED;
801         ret = consume_events(1 /* port */, port1_events,
802                                 validate_queue_to_port_multi_link);
803         if (ret)
804                 return TEST_FAILED;
805
806         return TEST_SUCCESS;
807 }
808
809 static int
810 worker_flow_based_pipeline(void *arg)
811 {
812         struct test_core_param *param = arg;
813         struct rte_event ev;
814         uint16_t valid_event;
815         uint8_t port = param->port;
816         uint8_t new_sched_type = param->sched_type;
817         rte_atomic32_t *total_events = param->total_events;
818         uint64_t dequeue_tmo_ticks = param->dequeue_tmo_ticks;
819
820         while (rte_atomic32_read(total_events) > 0) {
821                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1,
822                                         dequeue_tmo_ticks);
823                 if (!valid_event)
824                         continue;
825
826                 /* Events from stage 0 */
827                 if (ev.sub_event_type == 0) {
828                         /* Move to atomic flow to maintain the ordering */
829                         ev.flow_id = 0x2;
830                         ev.event_type = RTE_EVENT_TYPE_CPU;
831                         ev.sub_event_type = 1; /* stage 1 */
832                         ev.sched_type = new_sched_type;
833                         ev.op = RTE_EVENT_OP_FORWARD;
834                         rte_event_enqueue_burst(evdev, port, &ev, 1);
835                 } else if (ev.sub_event_type == 1) { /* Events from stage 1*/
836                         if (seqn_list_update(ev.mbuf->seqn) == TEST_SUCCESS) {
837                                 rte_pktmbuf_free(ev.mbuf);
838                                 rte_atomic32_sub(total_events, 1);
839                         } else {
840                                 printf("Failed to update seqn_list\n");
841                                 return TEST_FAILED;
842                         }
843                 } else {
844                         printf("Invalid ev.sub_event_type = %d\n",
845                                         ev.sub_event_type);
846                         return TEST_FAILED;
847                 }
848         }
849         return 0;
850 }
851
852 static int
853 test_multiport_flow_sched_type_test(uint8_t in_sched_type,
854                         uint8_t out_sched_type)
855 {
856         const unsigned int total_events = MAX_EVENTS;
857         uint8_t nr_ports;
858         int ret;
859
860         nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1);
861
862         if (!nr_ports) {
863                 printf("%s: Not enough ports=%d or workers=%d\n", __func__,
864                         rte_event_port_count(evdev), rte_lcore_count() - 1);
865                 return TEST_SUCCESS;
866         }
867
868         /* Injects events with m->seqn=0 to total_events */
869         ret = inject_events(
870                 0x1 /*flow_id */,
871                 RTE_EVENT_TYPE_CPU /* event_type */,
872                 0 /* sub_event_type (stage 0) */,
873                 in_sched_type,
874                 0 /* queue */,
875                 0 /* port */,
876                 total_events /* events */);
877         if (ret)
878                 return TEST_FAILED;
879
880         ret = launch_workers_and_wait(worker_flow_based_pipeline,
881                                         worker_flow_based_pipeline,
882                                         total_events, nr_ports, out_sched_type);
883         if (ret)
884                 return TEST_FAILED;
885
886         if (in_sched_type != RTE_SCHED_TYPE_PARALLEL &&
887                         out_sched_type == RTE_SCHED_TYPE_ATOMIC) {
888                 /* Check the events order maintained or not */
889                 return seqn_list_check(total_events);
890         }
891         return TEST_SUCCESS;
892 }
893
894
895 /* Multi port ordered to atomic transaction */
896 static int
897 test_multi_port_flow_ordered_to_atomic(void)
898 {
899         /* Ingress event order test */
900         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_ORDERED,
901                                 RTE_SCHED_TYPE_ATOMIC);
902 }
903
904 static int
905 test_multi_port_flow_ordered_to_ordered(void)
906 {
907         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_ORDERED,
908                                 RTE_SCHED_TYPE_ORDERED);
909 }
910
911 static int
912 test_multi_port_flow_ordered_to_parallel(void)
913 {
914         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_ORDERED,
915                                 RTE_SCHED_TYPE_PARALLEL);
916 }
917
918 static int
919 test_multi_port_flow_atomic_to_atomic(void)
920 {
921         /* Ingress event order test */
922         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_ATOMIC,
923                                 RTE_SCHED_TYPE_ATOMIC);
924 }
925
926 static int
927 test_multi_port_flow_atomic_to_ordered(void)
928 {
929         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_ATOMIC,
930                                 RTE_SCHED_TYPE_ORDERED);
931 }
932
933 static int
934 test_multi_port_flow_atomic_to_parallel(void)
935 {
936         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_ATOMIC,
937                                 RTE_SCHED_TYPE_PARALLEL);
938 }
939
940 static int
941 test_multi_port_flow_parallel_to_atomic(void)
942 {
943         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_PARALLEL,
944                                 RTE_SCHED_TYPE_ATOMIC);
945 }
946
947 static int
948 test_multi_port_flow_parallel_to_ordered(void)
949 {
950         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_PARALLEL,
951                                 RTE_SCHED_TYPE_ORDERED);
952 }
953
954 static int
955 test_multi_port_flow_parallel_to_parallel(void)
956 {
957         return test_multiport_flow_sched_type_test(RTE_SCHED_TYPE_PARALLEL,
958                                 RTE_SCHED_TYPE_PARALLEL);
959 }
960
961 static int
962 worker_group_based_pipeline(void *arg)
963 {
964         struct test_core_param *param = arg;
965         struct rte_event ev;
966         uint16_t valid_event;
967         uint8_t port = param->port;
968         uint8_t new_sched_type = param->sched_type;
969         rte_atomic32_t *total_events = param->total_events;
970         uint64_t dequeue_tmo_ticks = param->dequeue_tmo_ticks;
971
972         while (rte_atomic32_read(total_events) > 0) {
973                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1,
974                                         dequeue_tmo_ticks);
975                 if (!valid_event)
976                         continue;
977
978                 /* Events from stage 0(group 0) */
979                 if (ev.queue_id == 0) {
980                         /* Move to atomic flow to maintain the ordering */
981                         ev.flow_id = 0x2;
982                         ev.event_type = RTE_EVENT_TYPE_CPU;
983                         ev.sched_type = new_sched_type;
984                         ev.queue_id = 1; /* Stage 1*/
985                         ev.op = RTE_EVENT_OP_FORWARD;
986                         rte_event_enqueue_burst(evdev, port, &ev, 1);
987                 } else if (ev.queue_id == 1) { /* Events from stage 1(group 1)*/
988                         if (seqn_list_update(ev.mbuf->seqn) == TEST_SUCCESS) {
989                                 rte_pktmbuf_free(ev.mbuf);
990                                 rte_atomic32_sub(total_events, 1);
991                         } else {
992                                 printf("Failed to update seqn_list\n");
993                                 return TEST_FAILED;
994                         }
995                 } else {
996                         printf("Invalid ev.queue_id = %d\n", ev.queue_id);
997                         return TEST_FAILED;
998                 }
999         }
1000
1001
1002         return 0;
1003 }
1004
1005 static int
1006 test_multiport_queue_sched_type_test(uint8_t in_sched_type,
1007                         uint8_t out_sched_type)
1008 {
1009         const unsigned int total_events = MAX_EVENTS;
1010         uint8_t nr_ports;
1011         int ret;
1012
1013         nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1);
1014
1015         if (rte_event_queue_count(evdev) < 2 ||  !nr_ports) {
1016                 printf("%s: Not enough queues=%d ports=%d or workers=%d\n",
1017                          __func__, rte_event_queue_count(evdev),
1018                         rte_event_port_count(evdev), rte_lcore_count() - 1);
1019                 return TEST_SUCCESS;
1020         }
1021
1022         /* Injects events with m->seqn=0 to total_events */
1023         ret = inject_events(
1024                 0x1 /*flow_id */,
1025                 RTE_EVENT_TYPE_CPU /* event_type */,
1026                 0 /* sub_event_type (stage 0) */,
1027                 in_sched_type,
1028                 0 /* queue */,
1029                 0 /* port */,
1030                 total_events /* events */);
1031         if (ret)
1032                 return TEST_FAILED;
1033
1034         ret = launch_workers_and_wait(worker_group_based_pipeline,
1035                                         worker_group_based_pipeline,
1036                                         total_events, nr_ports, out_sched_type);
1037         if (ret)
1038                 return TEST_FAILED;
1039
1040         if (in_sched_type != RTE_SCHED_TYPE_PARALLEL &&
1041                         out_sched_type == RTE_SCHED_TYPE_ATOMIC) {
1042                 /* Check the events order maintained or not */
1043                 return seqn_list_check(total_events);
1044         }
1045         return TEST_SUCCESS;
1046 }
1047
1048 static int
1049 test_multi_port_queue_ordered_to_atomic(void)
1050 {
1051         /* Ingress event order test */
1052         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_ORDERED,
1053                                 RTE_SCHED_TYPE_ATOMIC);
1054 }
1055
1056 static int
1057 test_multi_port_queue_ordered_to_ordered(void)
1058 {
1059         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_ORDERED,
1060                                 RTE_SCHED_TYPE_ORDERED);
1061 }
1062
1063 static int
1064 test_multi_port_queue_ordered_to_parallel(void)
1065 {
1066         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_ORDERED,
1067                                 RTE_SCHED_TYPE_PARALLEL);
1068 }
1069
1070 static int
1071 test_multi_port_queue_atomic_to_atomic(void)
1072 {
1073         /* Ingress event order test */
1074         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_ATOMIC,
1075                                 RTE_SCHED_TYPE_ATOMIC);
1076 }
1077
1078 static int
1079 test_multi_port_queue_atomic_to_ordered(void)
1080 {
1081         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_ATOMIC,
1082                                 RTE_SCHED_TYPE_ORDERED);
1083 }
1084
1085 static int
1086 test_multi_port_queue_atomic_to_parallel(void)
1087 {
1088         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_ATOMIC,
1089                                 RTE_SCHED_TYPE_PARALLEL);
1090 }
1091
1092 static int
1093 test_multi_port_queue_parallel_to_atomic(void)
1094 {
1095         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_PARALLEL,
1096                                 RTE_SCHED_TYPE_ATOMIC);
1097 }
1098
1099 static int
1100 test_multi_port_queue_parallel_to_ordered(void)
1101 {
1102         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_PARALLEL,
1103                                 RTE_SCHED_TYPE_ORDERED);
1104 }
1105
1106 static int
1107 test_multi_port_queue_parallel_to_parallel(void)
1108 {
1109         return test_multiport_queue_sched_type_test(RTE_SCHED_TYPE_PARALLEL,
1110                                 RTE_SCHED_TYPE_PARALLEL);
1111 }
1112
1113 static int
1114 worker_flow_based_pipeline_max_stages_rand_sched_type(void *arg)
1115 {
1116         struct test_core_param *param = arg;
1117         struct rte_event ev;
1118         uint16_t valid_event;
1119         uint8_t port = param->port;
1120         rte_atomic32_t *total_events = param->total_events;
1121
1122         while (rte_atomic32_read(total_events) > 0) {
1123                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
1124                 if (!valid_event)
1125                         continue;
1126
1127                 if (ev.sub_event_type == 255) { /* last stage */
1128                         rte_pktmbuf_free(ev.mbuf);
1129                         rte_atomic32_sub(total_events, 1);
1130                 } else {
1131                         ev.event_type = RTE_EVENT_TYPE_CPU;
1132                         ev.sub_event_type++;
1133                         ev.sched_type =
1134                                 rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1);
1135                         ev.op = RTE_EVENT_OP_FORWARD;
1136                         rte_event_enqueue_burst(evdev, port, &ev, 1);
1137                 }
1138         }
1139         return 0;
1140 }
1141
1142 static int
1143 launch_multi_port_max_stages_random_sched_type(int (*fn)(void *))
1144 {
1145         uint8_t nr_ports;
1146         int ret;
1147
1148         nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1);
1149
1150         if (!nr_ports) {
1151                 printf("%s: Not enough ports=%d or workers=%d\n", __func__,
1152                         rte_event_port_count(evdev), rte_lcore_count() - 1);
1153                 return TEST_SUCCESS;
1154         }
1155
1156         /* Injects events with m->seqn=0 to total_events */
1157         ret = inject_events(
1158                 0x1 /*flow_id */,
1159                 RTE_EVENT_TYPE_CPU /* event_type */,
1160                 0 /* sub_event_type (stage 0) */,
1161                 rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1) /* sched_type */,
1162                 0 /* queue */,
1163                 0 /* port */,
1164                 MAX_EVENTS /* events */);
1165         if (ret)
1166                 return TEST_FAILED;
1167
1168         return launch_workers_and_wait(fn, fn, MAX_EVENTS, nr_ports,
1169                                          0xff /* invalid */);
1170 }
1171
1172 /* Flow based pipeline with maximum stages with random sched type */
1173 static int
1174 test_multi_port_flow_max_stages_random_sched_type(void)
1175 {
1176         return launch_multi_port_max_stages_random_sched_type(
1177                 worker_flow_based_pipeline_max_stages_rand_sched_type);
1178 }
1179
1180 static int
1181 worker_queue_based_pipeline_max_stages_rand_sched_type(void *arg)
1182 {
1183         struct test_core_param *param = arg;
1184         struct rte_event ev;
1185         uint16_t valid_event;
1186         uint8_t port = param->port;
1187         uint8_t nr_queues = rte_event_queue_count(evdev);
1188         rte_atomic32_t *total_events = param->total_events;
1189
1190         while (rte_atomic32_read(total_events) > 0) {
1191                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
1192                 if (!valid_event)
1193                         continue;
1194
1195                 if (ev.queue_id == nr_queues - 1) { /* last stage */
1196                         rte_pktmbuf_free(ev.mbuf);
1197                         rte_atomic32_sub(total_events, 1);
1198                 } else {
1199                         ev.event_type = RTE_EVENT_TYPE_CPU;
1200                         ev.queue_id++;
1201                         ev.sched_type =
1202                                 rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1);
1203                         ev.op = RTE_EVENT_OP_FORWARD;
1204                         rte_event_enqueue_burst(evdev, port, &ev, 1);
1205                 }
1206         }
1207         return 0;
1208 }
1209
1210 /* Queue based pipeline with maximum stages with random sched type */
1211 static int
1212 test_multi_port_queue_max_stages_random_sched_type(void)
1213 {
1214         return launch_multi_port_max_stages_random_sched_type(
1215                 worker_queue_based_pipeline_max_stages_rand_sched_type);
1216 }
1217
1218 static int
1219 worker_mixed_pipeline_max_stages_rand_sched_type(void *arg)
1220 {
1221         struct test_core_param *param = arg;
1222         struct rte_event ev;
1223         uint16_t valid_event;
1224         uint8_t port = param->port;
1225         uint8_t nr_queues = rte_event_queue_count(evdev);
1226         rte_atomic32_t *total_events = param->total_events;
1227
1228         while (rte_atomic32_read(total_events) > 0) {
1229                 valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
1230                 if (!valid_event)
1231                         continue;
1232
1233                 if (ev.queue_id == nr_queues - 1) { /* Last stage */
1234                         rte_pktmbuf_free(ev.mbuf);
1235                         rte_atomic32_sub(total_events, 1);
1236                 } else {
1237                         ev.event_type = RTE_EVENT_TYPE_CPU;
1238                         ev.queue_id++;
1239                         ev.sub_event_type = rte_rand() % 256;
1240                         ev.sched_type =
1241                                 rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1);
1242                         ev.op = RTE_EVENT_OP_FORWARD;
1243                         rte_event_enqueue_burst(evdev, port, &ev, 1);
1244                 }
1245         }
1246         return 0;
1247 }
1248
1249 /* Queue and flow based pipeline with maximum stages with random sched type */
1250 static int
1251 test_multi_port_mixed_max_stages_random_sched_type(void)
1252 {
1253         return launch_multi_port_max_stages_random_sched_type(
1254                 worker_mixed_pipeline_max_stages_rand_sched_type);
1255 }
1256
1257 static int
1258 worker_ordered_flow_producer(void *arg)
1259 {
1260         struct test_core_param *param = arg;
1261         uint8_t port = param->port;
1262         struct rte_mbuf *m;
1263         int counter = 0;
1264
1265         while (counter < NUM_PACKETS) {
1266                 m = rte_pktmbuf_alloc(eventdev_test_mempool);
1267                 if (m == NULL)
1268                         continue;
1269
1270                 m->seqn = counter++;
1271
1272                 struct rte_event ev = {.event = 0, .u64 = 0};
1273
1274                 ev.flow_id = 0x1; /* Generate a fat flow */
1275                 ev.sub_event_type = 0;
1276                 /* Inject the new event */
1277                 ev.op = RTE_EVENT_OP_NEW;
1278                 ev.event_type = RTE_EVENT_TYPE_CPU;
1279                 ev.sched_type = RTE_SCHED_TYPE_ORDERED;
1280                 ev.queue_id = 0;
1281                 ev.mbuf = m;
1282                 rte_event_enqueue_burst(evdev, port, &ev, 1);
1283         }
1284
1285         return 0;
1286 }
1287
1288 static inline int
1289 test_producer_consumer_ingress_order_test(int (*fn)(void *))
1290 {
1291         uint8_t nr_ports;
1292
1293         nr_ports = RTE_MIN(rte_event_port_count(evdev), rte_lcore_count() - 1);
1294
1295         if (rte_lcore_count() < 3 || nr_ports < 2) {
1296                 printf("### Not enough cores for %s test.\n", __func__);
1297                 return TEST_SUCCESS;
1298         }
1299
1300         launch_workers_and_wait(worker_ordered_flow_producer, fn,
1301                                 NUM_PACKETS, nr_ports, RTE_SCHED_TYPE_ATOMIC);
1302         /* Check the events order maintained or not */
1303         return seqn_list_check(NUM_PACKETS);
1304 }
1305
1306 /* Flow based producer consumer ingress order test */
1307 static int
1308 test_flow_producer_consumer_ingress_order_test(void)
1309 {
1310         return test_producer_consumer_ingress_order_test(
1311                                 worker_flow_based_pipeline);
1312 }
1313
1314 /* Queue based producer consumer ingress order test */
1315 static int
1316 test_queue_producer_consumer_ingress_order_test(void)
1317 {
1318         return test_producer_consumer_ingress_order_test(
1319                                 worker_group_based_pipeline);
1320 }
1321
1322 static struct unit_test_suite eventdev_octeontx_testsuite  = {
1323         .suite_name = "eventdev octeontx unit test suite",
1324         .setup = testsuite_setup,
1325         .teardown = testsuite_teardown,
1326         .unit_test_cases = {
1327                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1328                         test_simple_enqdeq_ordered),
1329                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1330                         test_simple_enqdeq_atomic),
1331                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1332                         test_simple_enqdeq_parallel),
1333                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1334                         test_multi_queue_enq_single_port_deq),
1335                 TEST_CASE_ST(eventdev_setup_priority, eventdev_teardown,
1336                         test_multi_queue_priority),
1337                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1338                         test_multi_queue_enq_multi_port_deq),
1339                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1340                         test_queue_to_port_single_link),
1341                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1342                         test_queue_to_port_multi_link),
1343                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1344                         test_multi_port_flow_ordered_to_atomic),
1345                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1346                         test_multi_port_flow_ordered_to_ordered),
1347                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1348                         test_multi_port_flow_ordered_to_parallel),
1349                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1350                         test_multi_port_flow_atomic_to_atomic),
1351                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1352                         test_multi_port_flow_atomic_to_ordered),
1353                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1354                         test_multi_port_flow_atomic_to_parallel),
1355                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1356                         test_multi_port_flow_parallel_to_atomic),
1357                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1358                         test_multi_port_flow_parallel_to_ordered),
1359                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1360                         test_multi_port_flow_parallel_to_parallel),
1361                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1362                         test_multi_port_queue_ordered_to_atomic),
1363                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1364                         test_multi_port_queue_ordered_to_ordered),
1365                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1366                         test_multi_port_queue_ordered_to_parallel),
1367                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1368                         test_multi_port_queue_atomic_to_atomic),
1369                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1370                         test_multi_port_queue_atomic_to_ordered),
1371                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1372                         test_multi_port_queue_atomic_to_parallel),
1373                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1374                         test_multi_port_queue_parallel_to_atomic),
1375                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1376                         test_multi_port_queue_parallel_to_ordered),
1377                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1378                         test_multi_port_queue_parallel_to_parallel),
1379                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1380                         test_multi_port_flow_max_stages_random_sched_type),
1381                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1382                         test_multi_port_queue_max_stages_random_sched_type),
1383                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1384                         test_multi_port_mixed_max_stages_random_sched_type),
1385                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1386                         test_flow_producer_consumer_ingress_order_test),
1387                 TEST_CASE_ST(eventdev_setup, eventdev_teardown,
1388                         test_queue_producer_consumer_ingress_order_test),
1389                 /* Tests with dequeue timeout */
1390                 TEST_CASE_ST(eventdev_setup_dequeue_timeout, eventdev_teardown,
1391                         test_multi_port_flow_ordered_to_atomic),
1392                 TEST_CASE_ST(eventdev_setup_dequeue_timeout, eventdev_teardown,
1393                         test_multi_port_queue_ordered_to_atomic),
1394                 TEST_CASES_END() /**< NULL terminate unit test array */
1395         }
1396 };
1397
1398 static int
1399 test_eventdev_octeontx(void)
1400 {
1401         return unit_test_suite_runner(&eventdev_octeontx_testsuite);
1402 }
1403
1404 REGISTER_TEST_COMMAND(eventdev_octeontx_autotest, test_eventdev_octeontx);