a93e36e342746ba97bb022822fd0eeb41adaa573
[dpdk.git] / test / test / test_eventdev_octeontx.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Cavium networks. 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 networks 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
56 static int
57 testsuite_setup(void)
58 {
59         const char *eventdev_name = "event_octeontx";
60
61         evdev = rte_event_dev_get_dev_id(eventdev_name);
62         if (evdev < 0) {
63                 printf("%d: Eventdev %s not found - creating.\n",
64                                 __LINE__, eventdev_name);
65                 if (rte_eal_vdev_init(eventdev_name, NULL) < 0) {
66                         printf("Error creating eventdev %s\n", eventdev_name);
67                         return TEST_FAILED;
68                 }
69                 evdev = rte_event_dev_get_dev_id(eventdev_name);
70                 if (evdev < 0) {
71                         printf("Error finding newly created eventdev\n");
72                         return TEST_FAILED;
73                 }
74         }
75
76         return TEST_SUCCESS;
77 }
78
79 static void
80 testsuite_teardown(void)
81 {
82         rte_event_dev_close(evdev);
83 }
84
85
86 static struct unit_test_suite eventdev_octeontx_testsuite  = {
87         .suite_name = "eventdev octeontx unit test suite",
88         .setup = testsuite_setup,
89         .teardown = testsuite_teardown,
90 };
91
92 static int
93 test_eventdev_octeontx(void)
94 {
95         return unit_test_suite_runner(&eventdev_octeontx_testsuite);
96 }
97
98 REGISTER_TEST_COMMAND(eventdev_octeontx_autotest, test_eventdev_octeontx);