1f714a188SAmr Mokhtar /* SPDX-License-Identifier: BSD-3-Clause
2f714a188SAmr Mokhtar * Copyright(c) 2017 Intel Corporation
3f714a188SAmr Mokhtar */
4f714a188SAmr Mokhtar
5f714a188SAmr Mokhtar #include <rte_common.h>
6f714a188SAmr Mokhtar #include <rte_hexdump.h>
7f714a188SAmr Mokhtar #include <rte_mbuf.h>
8f714a188SAmr Mokhtar #include <rte_malloc.h>
9f714a188SAmr Mokhtar #include <rte_memcpy.h>
10f714a188SAmr Mokhtar #include <rte_cycles.h>
11f714a188SAmr Mokhtar
12f714a188SAmr Mokhtar #include <rte_bus_vdev.h>
13f714a188SAmr Mokhtar
14f714a188SAmr Mokhtar #include <rte_bbdev.h>
15f714a188SAmr Mokhtar #include <rte_bbdev_op.h>
16f714a188SAmr Mokhtar #include <rte_bbdev_pmd.h>
17f714a188SAmr Mokhtar
18f714a188SAmr Mokhtar #include "main.h"
19f714a188SAmr Mokhtar
20f714a188SAmr Mokhtar
21f714a188SAmr Mokhtar #define BBDEV_NAME_NULL ("bbdev_null")
22f714a188SAmr Mokhtar
23f714a188SAmr Mokhtar struct bbdev_testsuite_params {
24f714a188SAmr Mokhtar struct rte_bbdev_queue_conf qconf;
25f714a188SAmr Mokhtar };
26f714a188SAmr Mokhtar
27f714a188SAmr Mokhtar static struct bbdev_testsuite_params testsuite_params;
28f714a188SAmr Mokhtar
29f714a188SAmr Mokhtar static uint8_t null_dev_id;
30f714a188SAmr Mokhtar
31f714a188SAmr Mokhtar static int
testsuite_setup(void)32f714a188SAmr Mokhtar testsuite_setup(void)
33f714a188SAmr Mokhtar {
34f714a188SAmr Mokhtar uint8_t nb_devs;
35f714a188SAmr Mokhtar int ret;
36f714a188SAmr Mokhtar char buf[RTE_BBDEV_NAME_MAX_LEN];
37f714a188SAmr Mokhtar
38f714a188SAmr Mokhtar /* Create test device */
39f714a188SAmr Mokhtar snprintf(buf, sizeof(buf), "%s_unittest", BBDEV_NAME_NULL);
40f714a188SAmr Mokhtar ret = rte_vdev_init(buf, NULL);
41f714a188SAmr Mokhtar TEST_ASSERT(ret == 0, "Failed to create instance of pmd: %s", buf);
42f714a188SAmr Mokhtar
43f714a188SAmr Mokhtar nb_devs = rte_bbdev_count();
44f714a188SAmr Mokhtar TEST_ASSERT(nb_devs != 0, "No devices found");
45f714a188SAmr Mokhtar
46f714a188SAmr Mokhtar /* Most recently created device is our device */
47f714a188SAmr Mokhtar null_dev_id = nb_devs - 1;
48f714a188SAmr Mokhtar
49f714a188SAmr Mokhtar return TEST_SUCCESS;
50f714a188SAmr Mokhtar }
51f714a188SAmr Mokhtar
52f714a188SAmr Mokhtar static void
testsuite_teardown(void)53f714a188SAmr Mokhtar testsuite_teardown(void)
54f714a188SAmr Mokhtar {
55f714a188SAmr Mokhtar char buf[RTE_BBDEV_NAME_MAX_LEN];
56f714a188SAmr Mokhtar
57f714a188SAmr Mokhtar snprintf(buf, sizeof(buf), "%s_unittest", BBDEV_NAME_NULL);
58f714a188SAmr Mokhtar rte_vdev_uninit(buf);
59f714a188SAmr Mokhtar }
60f714a188SAmr Mokhtar
61f714a188SAmr Mokhtar static int
ut_setup(void)62f714a188SAmr Mokhtar ut_setup(void)
63f714a188SAmr Mokhtar {
64f714a188SAmr Mokhtar struct bbdev_testsuite_params *ts_params = &testsuite_params;
65f714a188SAmr Mokhtar uint8_t num_queues;
66f714a188SAmr Mokhtar
67f714a188SAmr Mokhtar /* Valid queue configuration */
68f714a188SAmr Mokhtar ts_params->qconf.priority = 0;
69f714a188SAmr Mokhtar ts_params->qconf.socket = SOCKET_ID_ANY;
70f714a188SAmr Mokhtar ts_params->qconf.deferred_start = 1;
71f714a188SAmr Mokhtar
72f714a188SAmr Mokhtar num_queues = 1;
73f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_setup_queues(null_dev_id, num_queues,
74f714a188SAmr Mokhtar SOCKET_ID_ANY), "Failed to setup queues for bbdev %u",
75f714a188SAmr Mokhtar 0);
76f714a188SAmr Mokhtar
77f714a188SAmr Mokhtar /* Start the device */
78f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_start(null_dev_id),
79f714a188SAmr Mokhtar "Failed to start bbdev %u", 0);
80f714a188SAmr Mokhtar
81f714a188SAmr Mokhtar return TEST_SUCCESS;
82f714a188SAmr Mokhtar }
83f714a188SAmr Mokhtar
84f714a188SAmr Mokhtar static void
ut_teardown(void)85f714a188SAmr Mokhtar ut_teardown(void)
86f714a188SAmr Mokhtar {
87f714a188SAmr Mokhtar rte_bbdev_close(null_dev_id);
88f714a188SAmr Mokhtar }
89f714a188SAmr Mokhtar
90f714a188SAmr Mokhtar static int
test_bbdev_configure_invalid_dev_id(void)91f714a188SAmr Mokhtar test_bbdev_configure_invalid_dev_id(void)
92f714a188SAmr Mokhtar {
93f714a188SAmr Mokhtar uint8_t dev_id;
94f714a188SAmr Mokhtar uint8_t num_queues;
95f714a188SAmr Mokhtar
96f714a188SAmr Mokhtar num_queues = 1;
97f714a188SAmr Mokhtar for (dev_id = 0; dev_id < RTE_BBDEV_MAX_DEVS; dev_id++) {
98f714a188SAmr Mokhtar if (!rte_bbdev_is_valid(dev_id)) {
99f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_setup_queues(dev_id,
100f714a188SAmr Mokhtar num_queues, SOCKET_ID_ANY),
101f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
102f714a188SAmr Mokhtar "invalid dev_num %u", dev_id);
103f714a188SAmr Mokhtar TEST_ASSERT(rte_bbdev_intr_enable(dev_id) == -ENODEV,
104f714a188SAmr Mokhtar "Failed test for rte_bbdev_intr_enable: "
105f714a188SAmr Mokhtar "invalid dev_num %u", dev_id);
106f714a188SAmr Mokhtar break;
107f714a188SAmr Mokhtar }
108f714a188SAmr Mokhtar }
109f714a188SAmr Mokhtar
110f714a188SAmr Mokhtar return TEST_SUCCESS;
111f714a188SAmr Mokhtar }
112f714a188SAmr Mokhtar
113f714a188SAmr Mokhtar static int
test_bbdev_configure_invalid_num_queues(void)114f714a188SAmr Mokhtar test_bbdev_configure_invalid_num_queues(void)
115f714a188SAmr Mokhtar {
116f714a188SAmr Mokhtar struct rte_bbdev_info info;
117f714a188SAmr Mokhtar uint8_t dev_id, num_devs;
118f714a188SAmr Mokhtar uint8_t num_queues;
119f714a188SAmr Mokhtar int return_value;
120f714a188SAmr Mokhtar
121f714a188SAmr Mokhtar TEST_ASSERT((num_devs = rte_bbdev_count()) >= 1,
122f714a188SAmr Mokhtar "Need at least %d devices for test", 1);
123f714a188SAmr Mokhtar
124f714a188SAmr Mokhtar /* valid num_queues values */
125f714a188SAmr Mokhtar num_queues = 8;
126f714a188SAmr Mokhtar
127f714a188SAmr Mokhtar /* valid dev_id values */
128f714a188SAmr Mokhtar dev_id = null_dev_id;
129f714a188SAmr Mokhtar
130f714a188SAmr Mokhtar /* Stop the device in case it's started so it can be configured */
131f714a188SAmr Mokhtar rte_bbdev_stop(dev_id);
132f714a188SAmr Mokhtar
133f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_setup_queues(dev_id, 0, SOCKET_ID_ANY),
134f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
135f714a188SAmr Mokhtar "invalid num_queues %d", 0);
136f714a188SAmr Mokhtar
137f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_setup_queues(dev_id, num_queues,
138f714a188SAmr Mokhtar SOCKET_ID_ANY),
139f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
140f714a188SAmr Mokhtar "invalid dev_num %u", dev_id);
141f714a188SAmr Mokhtar
142f714a188SAmr Mokhtar TEST_ASSERT_FAIL(return_value = rte_bbdev_info_get(dev_id, NULL),
143f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
144f714a188SAmr Mokhtar "returned value:%i", return_value);
145f714a188SAmr Mokhtar
146f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_info_get(dev_id, &info),
147f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
148f714a188SAmr Mokhtar "invalid return value:%i", return_value);
149f714a188SAmr Mokhtar
150f714a188SAmr Mokhtar TEST_ASSERT(info.num_queues == num_queues,
151f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
152f714a188SAmr Mokhtar "invalid num_queues:%u", info.num_queues);
153f714a188SAmr Mokhtar
154f714a188SAmr Mokhtar num_queues = info.drv.max_num_queues;
155f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_setup_queues(dev_id, num_queues,
156f714a188SAmr Mokhtar SOCKET_ID_ANY),
157f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
158f714a188SAmr Mokhtar "invalid num_queues: %u", num_queues);
159f714a188SAmr Mokhtar
160f714a188SAmr Mokhtar num_queues++;
161f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_setup_queues(dev_id, num_queues,
162f714a188SAmr Mokhtar SOCKET_ID_ANY),
163f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
164f714a188SAmr Mokhtar "invalid num_queues: %u", num_queues);
165f714a188SAmr Mokhtar
166f714a188SAmr Mokhtar return TEST_SUCCESS;
167f714a188SAmr Mokhtar }
168f714a188SAmr Mokhtar
169f714a188SAmr Mokhtar static int
test_bbdev_configure_stop_device(void)170f714a188SAmr Mokhtar test_bbdev_configure_stop_device(void)
171f714a188SAmr Mokhtar {
172f714a188SAmr Mokhtar struct rte_bbdev_info info;
173f714a188SAmr Mokhtar uint8_t dev_id;
174f714a188SAmr Mokhtar int return_value;
175f714a188SAmr Mokhtar
176f714a188SAmr Mokhtar /* valid dev_id values */
177f714a188SAmr Mokhtar dev_id = null_dev_id;
178f714a188SAmr Mokhtar
179f714a188SAmr Mokhtar /* Stop the device so it can be configured */
180f714a188SAmr Mokhtar rte_bbdev_stop(dev_id);
181f714a188SAmr Mokhtar
182f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_info_get(dev_id, &info),
183f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
184f714a188SAmr Mokhtar "invalid return value from "
185f714a188SAmr Mokhtar "rte_bbdev_info_get function: %i", return_value);
186f714a188SAmr Mokhtar
187f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(info.started, "Failed test for rte_bbdev_info_get: "
188f714a188SAmr Mokhtar "started value: %u", info.started);
189f714a188SAmr Mokhtar
190f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_setup_queues(dev_id,
191f714a188SAmr Mokhtar info.drv.max_num_queues, SOCKET_ID_ANY),
192f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
193f714a188SAmr Mokhtar "device should be stopped, dev_id: %u", dev_id);
194f714a188SAmr Mokhtar
195f714a188SAmr Mokhtar return_value = rte_bbdev_intr_enable(dev_id);
196f714a188SAmr Mokhtar TEST_ASSERT(return_value != -EBUSY,
197f714a188SAmr Mokhtar "Failed test for rte_bbdev_intr_enable: device should be stopped, dev_id: %u",
198f714a188SAmr Mokhtar dev_id);
199f714a188SAmr Mokhtar
200f714a188SAmr Mokhtar /* Start the device so it cannot be configured */
201f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_start(RTE_BBDEV_MAX_DEVS),
202f714a188SAmr Mokhtar "Failed to start bbdev %u", dev_id);
203f714a188SAmr Mokhtar
204f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_start(dev_id),
205f714a188SAmr Mokhtar "Failed to start bbdev %u", dev_id);
206f714a188SAmr Mokhtar
207f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_info_get(dev_id, &info),
208f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
209f714a188SAmr Mokhtar "invalid return value from "
210f714a188SAmr Mokhtar "rte_bbdev_info_get function: %i", return_value);
211f714a188SAmr Mokhtar
212f714a188SAmr Mokhtar TEST_ASSERT_FAIL(info.started, "Failed test for rte_bbdev_info_get: "
213f714a188SAmr Mokhtar "started value: %u", info.started);
214f714a188SAmr Mokhtar
215f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_setup_queues(dev_id,
216f714a188SAmr Mokhtar info.drv.max_num_queues, SOCKET_ID_ANY),
217f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
218f714a188SAmr Mokhtar "device should be started, dev_id: %u", dev_id);
219f714a188SAmr Mokhtar
220f714a188SAmr Mokhtar return_value = rte_bbdev_intr_enable(dev_id);
221f714a188SAmr Mokhtar TEST_ASSERT(return_value == -EBUSY,
222f714a188SAmr Mokhtar "Failed test for rte_bbdev_intr_enable: device should be started, dev_id: %u",
223f714a188SAmr Mokhtar dev_id);
224f714a188SAmr Mokhtar
225f714a188SAmr Mokhtar /* Stop again the device so it can be once again configured */
226f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_stop(RTE_BBDEV_MAX_DEVS),
227f714a188SAmr Mokhtar "Failed to start bbdev %u", dev_id);
228f714a188SAmr Mokhtar
229f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stop(dev_id), "Failed to stop bbdev %u",
230f714a188SAmr Mokhtar dev_id);
231f714a188SAmr Mokhtar
232f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_info_get(dev_id, &info),
233f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
234f714a188SAmr Mokhtar "invalid return value from "
235f714a188SAmr Mokhtar "rte_bbdev_info_get function: %i", return_value);
236f714a188SAmr Mokhtar
237f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(info.started, "Failed test for rte_bbdev_info_get: "
238f714a188SAmr Mokhtar "started value: %u", info.started);
239f714a188SAmr Mokhtar
240f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_setup_queues(dev_id,
241f714a188SAmr Mokhtar info.drv.max_num_queues, SOCKET_ID_ANY),
242f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
243f714a188SAmr Mokhtar "device should be stopped, dev_id: %u", dev_id);
244f714a188SAmr Mokhtar
245f714a188SAmr Mokhtar return_value = rte_bbdev_intr_enable(dev_id);
246f714a188SAmr Mokhtar TEST_ASSERT(return_value != -EBUSY,
247f714a188SAmr Mokhtar "Failed test for rte_bbdev_intr_enable: device should be stopped, dev_id: %u",
248f714a188SAmr Mokhtar dev_id);
249f714a188SAmr Mokhtar
250f714a188SAmr Mokhtar return TEST_SUCCESS;
251f714a188SAmr Mokhtar }
252f714a188SAmr Mokhtar
253f714a188SAmr Mokhtar static int
test_bbdev_configure_stop_queue(void)254f714a188SAmr Mokhtar test_bbdev_configure_stop_queue(void)
255f714a188SAmr Mokhtar {
256f714a188SAmr Mokhtar struct bbdev_testsuite_params *ts_params = &testsuite_params;
257f714a188SAmr Mokhtar struct rte_bbdev_info info;
258f714a188SAmr Mokhtar struct rte_bbdev_queue_info qinfo;
259f714a188SAmr Mokhtar uint8_t dev_id;
260f714a188SAmr Mokhtar uint16_t queue_id;
261f714a188SAmr Mokhtar int return_value;
262f714a188SAmr Mokhtar
263f714a188SAmr Mokhtar /* Valid dev_id values */
264f714a188SAmr Mokhtar dev_id = null_dev_id;
265f714a188SAmr Mokhtar
266f714a188SAmr Mokhtar /* Valid queue_id values */
267f714a188SAmr Mokhtar queue_id = 0;
268f714a188SAmr Mokhtar
269f714a188SAmr Mokhtar rte_bbdev_stop(dev_id);
270f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_info_get(dev_id, &info),
271f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
272f714a188SAmr Mokhtar "invalid return value:%i", return_value);
273f714a188SAmr Mokhtar
274f714a188SAmr Mokhtar /* Valid queue configuration */
275f714a188SAmr Mokhtar ts_params->qconf.queue_size = info.drv.queue_size_lim;
27658a695c6SKamil Chalupnik ts_params->qconf.priority = info.drv.max_ul_queue_priority;
277f714a188SAmr Mokhtar
278f714a188SAmr Mokhtar /* Device - started; queue - started */
279f714a188SAmr Mokhtar rte_bbdev_start(dev_id);
280f714a188SAmr Mokhtar
281f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
282f714a188SAmr Mokhtar &ts_params->qconf),
283f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
284f714a188SAmr Mokhtar "queue:%u on device:%u should be stopped",
285f714a188SAmr Mokhtar queue_id, dev_id);
286f714a188SAmr Mokhtar
287f714a188SAmr Mokhtar /* Device - stopped; queue - started */
288f714a188SAmr Mokhtar rte_bbdev_stop(dev_id);
289f714a188SAmr Mokhtar
290f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
291f714a188SAmr Mokhtar &ts_params->qconf),
292f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
293f714a188SAmr Mokhtar "queue:%u on device:%u should be stopped",
294f714a188SAmr Mokhtar queue_id, dev_id);
295f714a188SAmr Mokhtar
296f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_stop(RTE_BBDEV_MAX_DEVS, queue_id),
297f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_stop "
298f714a188SAmr Mokhtar "invalid dev_id ");
299f714a188SAmr Mokhtar
300f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_stop(dev_id, RTE_MAX_QUEUES_PER_PORT),
301f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_stop "
302f714a188SAmr Mokhtar "invalid queue_id ");
303f714a188SAmr Mokhtar
304f714a188SAmr Mokhtar /* Device - stopped; queue - stopped */
305f714a188SAmr Mokhtar rte_bbdev_queue_stop(dev_id, queue_id);
306f714a188SAmr Mokhtar
307f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_configure(dev_id, queue_id,
308f714a188SAmr Mokhtar &ts_params->qconf),
309f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
310f714a188SAmr Mokhtar "queue:%u on device:%u should be stopped", queue_id,
311f714a188SAmr Mokhtar dev_id);
312f714a188SAmr Mokhtar
313f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_queue_info_get(dev_id,
314f714a188SAmr Mokhtar queue_id, &qinfo),
315f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
316f714a188SAmr Mokhtar "invalid return value from "
317f714a188SAmr Mokhtar "rte_bbdev_queue_info_get function: %i", return_value);
318f714a188SAmr Mokhtar
319f714a188SAmr Mokhtar TEST_ASSERT(qinfo.conf.socket == ts_params->qconf.socket,
320f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_info_get: "
321f714a188SAmr Mokhtar "invalid queue_size:%u", qinfo.conf.socket);
322f714a188SAmr Mokhtar
323f714a188SAmr Mokhtar TEST_ASSERT(qinfo.conf.queue_size == ts_params->qconf.queue_size,
324f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_info_get: "
325f714a188SAmr Mokhtar "invalid queue_size:%u", qinfo.conf.queue_size);
326f714a188SAmr Mokhtar
327f714a188SAmr Mokhtar TEST_ASSERT(qinfo.conf.priority == ts_params->qconf.priority,
328f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_info_get: "
329f714a188SAmr Mokhtar "invalid queue_size:%u", qinfo.conf.priority);
330f714a188SAmr Mokhtar
331f714a188SAmr Mokhtar TEST_ASSERT(qinfo.conf.deferred_start ==
332f714a188SAmr Mokhtar ts_params->qconf.deferred_start,
333f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_info_get: "
334f714a188SAmr Mokhtar "invalid queue_size:%u", qinfo.conf.deferred_start);
335f714a188SAmr Mokhtar
336f714a188SAmr Mokhtar /* Device - started; queue - stopped */
337f714a188SAmr Mokhtar rte_bbdev_start(dev_id);
338f714a188SAmr Mokhtar rte_bbdev_queue_stop(dev_id, queue_id);
339f714a188SAmr Mokhtar
340f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
341f714a188SAmr Mokhtar &ts_params->qconf),
342f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
343f714a188SAmr Mokhtar "queue:%u on device:%u should be stopped", queue_id,
344f714a188SAmr Mokhtar dev_id);
345f714a188SAmr Mokhtar
346f714a188SAmr Mokhtar rte_bbdev_stop(dev_id);
347f714a188SAmr Mokhtar
348f714a188SAmr Mokhtar /* After rte_bbdev_start(dev_id):
349f714a188SAmr Mokhtar * - queue should be still stopped if deferred_start ==
350f714a188SAmr Mokhtar */
351f714a188SAmr Mokhtar rte_bbdev_start(dev_id);
352f714a188SAmr Mokhtar
353f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_queue_info_get(dev_id,
354f714a188SAmr Mokhtar queue_id, &qinfo),
355f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
356f714a188SAmr Mokhtar "invalid return value from "
357f714a188SAmr Mokhtar "rte_bbdev_queue_info_get function: %i", return_value);
358f714a188SAmr Mokhtar
359f714a188SAmr Mokhtar TEST_ASSERT(qinfo.started == 0,
360f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_info_get: "
361f714a188SAmr Mokhtar "invalid value for qinfo.started:%u", qinfo.started);
362f714a188SAmr Mokhtar
363f714a188SAmr Mokhtar rte_bbdev_stop(dev_id);
364f714a188SAmr Mokhtar
365f714a188SAmr Mokhtar /* After rte_bbdev_start(dev_id):
366f714a188SAmr Mokhtar * - queue should be started if deferred_start ==
367f714a188SAmr Mokhtar */
368f714a188SAmr Mokhtar ts_params->qconf.deferred_start = 0;
369*1ee65919SHernan Vargas TEST_ASSERT_SUCCESS(rte_bbdev_queue_configure(dev_id, queue_id, &ts_params->qconf),
370*1ee65919SHernan Vargas "Failed test for rte_bbdev_queue_configure");
371f714a188SAmr Mokhtar rte_bbdev_start(dev_id);
372f714a188SAmr Mokhtar
373f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_queue_info_get(dev_id,
374f714a188SAmr Mokhtar queue_id, &qinfo),
375f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
376f714a188SAmr Mokhtar "invalid return value from "
377f714a188SAmr Mokhtar "rte_bbdev_queue_info_get function: %i", return_value);
378f714a188SAmr Mokhtar
379f714a188SAmr Mokhtar TEST_ASSERT(qinfo.started == 1,
380f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_info_get: "
381f714a188SAmr Mokhtar "invalid value for qinfo.started:%u", qinfo.started);
382f714a188SAmr Mokhtar
383f714a188SAmr Mokhtar return TEST_SUCCESS;
384f714a188SAmr Mokhtar }
385f714a188SAmr Mokhtar
386f714a188SAmr Mokhtar static int
test_bbdev_configure_invalid_queue_configure(void)387f714a188SAmr Mokhtar test_bbdev_configure_invalid_queue_configure(void)
388f714a188SAmr Mokhtar {
389f714a188SAmr Mokhtar struct bbdev_testsuite_params *ts_params = &testsuite_params;
390f714a188SAmr Mokhtar int return_value;
391f714a188SAmr Mokhtar struct rte_bbdev_info info;
392f714a188SAmr Mokhtar uint8_t dev_id;
393f714a188SAmr Mokhtar uint16_t queue_id;
394f714a188SAmr Mokhtar
395f714a188SAmr Mokhtar /* Valid dev_id values */
396f714a188SAmr Mokhtar dev_id = null_dev_id;
397f714a188SAmr Mokhtar
398f714a188SAmr Mokhtar /* Valid queue_id values */
399f714a188SAmr Mokhtar queue_id = 0;
400f714a188SAmr Mokhtar
401f714a188SAmr Mokhtar rte_bbdev_stop(dev_id);
402f714a188SAmr Mokhtar
403f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(return_value = rte_bbdev_info_get(dev_id, &info),
404f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
405f714a188SAmr Mokhtar "invalid return value:%i", return_value);
406f714a188SAmr Mokhtar
407f714a188SAmr Mokhtar rte_bbdev_queue_stop(dev_id, queue_id);
408f714a188SAmr Mokhtar
409f714a188SAmr Mokhtar ts_params->qconf.queue_size = info.drv.queue_size_lim + 1;
410f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
411f714a188SAmr Mokhtar &ts_params->qconf),
412f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
413f714a188SAmr Mokhtar "invalid value qconf.queue_size: %u",
414f714a188SAmr Mokhtar ts_params->qconf.queue_size);
415f714a188SAmr Mokhtar
416f714a188SAmr Mokhtar ts_params->qconf.queue_size = info.drv.queue_size_lim;
41758a695c6SKamil Chalupnik ts_params->qconf.priority = info.drv.max_ul_queue_priority;
418f714a188SAmr Mokhtar queue_id = info.num_queues;
419f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
420f714a188SAmr Mokhtar &ts_params->qconf),
421f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
422f714a188SAmr Mokhtar "invalid value queue_id: %u", queue_id);
423f714a188SAmr Mokhtar
424f714a188SAmr Mokhtar queue_id = 0;
425f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_configure(dev_id, queue_id, NULL),
426f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
427f714a188SAmr Mokhtar "NULL qconf structure ");
428f714a188SAmr Mokhtar
429f714a188SAmr Mokhtar ts_params->qconf.socket = RTE_MAX_NUMA_NODES;
430f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
431f714a188SAmr Mokhtar &ts_params->qconf),
432f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
433f714a188SAmr Mokhtar "invalid socket number ");
434f714a188SAmr Mokhtar
435f714a188SAmr Mokhtar ts_params->qconf.socket = SOCKET_ID_ANY;
436f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_configure(dev_id, queue_id,
437f714a188SAmr Mokhtar &ts_params->qconf),
438f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
439f714a188SAmr Mokhtar "invalid value qconf.queue_size: %u",
440f714a188SAmr Mokhtar ts_params->qconf.queue_size);
441f714a188SAmr Mokhtar
442f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(RTE_BBDEV_MAX_DEVS, queue_id,
443f714a188SAmr Mokhtar &ts_params->qconf),
444f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
445f714a188SAmr Mokhtar "invalid dev_id");
446f714a188SAmr Mokhtar
447f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_configure(dev_id, queue_id, NULL),
448f714a188SAmr Mokhtar "Failed test for rte_bbdev_queue_configure: "
449f714a188SAmr Mokhtar "invalid value qconf.queue_size: %u",
450f714a188SAmr Mokhtar ts_params->qconf.queue_size);
451f714a188SAmr Mokhtar
452f714a188SAmr Mokhtar return TEST_SUCCESS;
453f714a188SAmr Mokhtar }
454f714a188SAmr Mokhtar
455f714a188SAmr Mokhtar static int
test_bbdev_op_pool(void)456f714a188SAmr Mokhtar test_bbdev_op_pool(void)
457f714a188SAmr Mokhtar {
458f714a188SAmr Mokhtar struct rte_mempool *mp;
459f714a188SAmr Mokhtar
460f714a188SAmr Mokhtar unsigned int dec_size = sizeof(struct rte_bbdev_dec_op);
461f714a188SAmr Mokhtar unsigned int enc_size = sizeof(struct rte_bbdev_enc_op);
462f714a188SAmr Mokhtar
463f714a188SAmr Mokhtar const char *pool_dec = "Test_DEC";
464f714a188SAmr Mokhtar const char *pool_enc = "Test_ENC";
465f714a188SAmr Mokhtar
466f714a188SAmr Mokhtar /* Valid pool configuration */
467f714a188SAmr Mokhtar uint32_t size = 256;
468f714a188SAmr Mokhtar uint32_t cache_size = 128;
469f714a188SAmr Mokhtar
470f714a188SAmr Mokhtar TEST_ASSERT(rte_bbdev_op_pool_create(NULL,
471f714a188SAmr Mokhtar RTE_BBDEV_OP_TURBO_DEC, size, cache_size, 0) == NULL,
472f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
473f714a188SAmr Mokhtar "NULL name parameter");
474f714a188SAmr Mokhtar
475f714a188SAmr Mokhtar TEST_ASSERT((mp = rte_bbdev_op_pool_create(pool_dec,
476f714a188SAmr Mokhtar RTE_BBDEV_OP_TURBO_DEC, size, cache_size, 0)) != NULL,
477f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
478f714a188SAmr Mokhtar "returned value is empty");
479f714a188SAmr Mokhtar
480f714a188SAmr Mokhtar TEST_ASSERT(mp->size == size,
481f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
482f714a188SAmr Mokhtar "invalid size of the mempool, mp->size: %u", mp->size);
483f714a188SAmr Mokhtar
484f714a188SAmr Mokhtar TEST_ASSERT(mp->cache_size == cache_size,
485f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
486f714a188SAmr Mokhtar "invalid size of the mempool, mp->size: %u",
487f714a188SAmr Mokhtar mp->cache_size);
488f714a188SAmr Mokhtar
489f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(strcmp(mp->name, pool_dec),
490f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
491f714a188SAmr Mokhtar "invalid name of mempool, mp->name: %s", mp->name);
492f714a188SAmr Mokhtar
493f714a188SAmr Mokhtar TEST_ASSERT(mp->elt_size == dec_size,
494f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
495f714a188SAmr Mokhtar "invalid element size for RTE_BBDEV_OP_TURBO_DEC, "
496f714a188SAmr Mokhtar "mp->elt_size: %u", mp->elt_size);
497f714a188SAmr Mokhtar
498f714a188SAmr Mokhtar rte_mempool_free(mp);
499f714a188SAmr Mokhtar
500f714a188SAmr Mokhtar TEST_ASSERT((mp = rte_bbdev_op_pool_create(pool_enc,
501f714a188SAmr Mokhtar RTE_BBDEV_OP_TURBO_ENC, size, cache_size, 0)) != NULL,
502f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
503f714a188SAmr Mokhtar "returned value is empty");
504f714a188SAmr Mokhtar
505f714a188SAmr Mokhtar TEST_ASSERT(mp->elt_size == enc_size,
506f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
507f714a188SAmr Mokhtar "invalid element size for RTE_BBDEV_OP_TURBO_ENC, "
508f714a188SAmr Mokhtar "mp->elt_size: %u", mp->elt_size);
509f714a188SAmr Mokhtar
510f714a188SAmr Mokhtar rte_mempool_free(mp);
511f714a188SAmr Mokhtar
512f714a188SAmr Mokhtar TEST_ASSERT((mp = rte_bbdev_op_pool_create("Test_NONE",
513f714a188SAmr Mokhtar RTE_BBDEV_OP_NONE, size, cache_size, 0)) != NULL,
514f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
515f714a188SAmr Mokhtar "returned value is empty for RTE_BBDEV_OP_NONE");
516f714a188SAmr Mokhtar
517f714a188SAmr Mokhtar TEST_ASSERT(mp->elt_size == (enc_size > dec_size ? enc_size : dec_size),
518f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
519f714a188SAmr Mokhtar "invalid size for RTE_BBDEV_OP_NONE, mp->elt_size: %u",
520f714a188SAmr Mokhtar mp->elt_size);
521f714a188SAmr Mokhtar
522f714a188SAmr Mokhtar rte_mempool_free(mp);
523f714a188SAmr Mokhtar
524f714a188SAmr Mokhtar TEST_ASSERT((mp = rte_bbdev_op_pool_create("Test_INV",
525e70212ccSNicolas Chautru RTE_BBDEV_OP_TYPE_SIZE_MAX, size, cache_size, 0)) == NULL,
526f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
527f714a188SAmr Mokhtar "returned value is not NULL for invalid type");
528f714a188SAmr Mokhtar
529f714a188SAmr Mokhtar /* Invalid pool configuration */
530f714a188SAmr Mokhtar size = 128;
531f714a188SAmr Mokhtar cache_size = 256;
532f714a188SAmr Mokhtar
533f714a188SAmr Mokhtar TEST_ASSERT((mp = rte_bbdev_op_pool_create("Test_InvSize",
534f714a188SAmr Mokhtar RTE_BBDEV_OP_NONE, size, cache_size, 0)) == NULL,
535f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_pool_create: "
536f714a188SAmr Mokhtar "returned value should be empty "
537f714a188SAmr Mokhtar "because size of per-lcore local cache "
538f714a188SAmr Mokhtar "is greater than size of the mempool.");
539f714a188SAmr Mokhtar
540f714a188SAmr Mokhtar return TEST_SUCCESS;
541f714a188SAmr Mokhtar }
542f714a188SAmr Mokhtar
543f714a188SAmr Mokhtar /**
544f714a188SAmr Mokhtar * Create pool of OP types RTE_BBDEV_OP_NONE, RTE_BBDEV_OP_TURBO_DEC and
545f714a188SAmr Mokhtar * RTE_BBDEV_OP_TURBO_ENC and check that only ops of that type can be
546f714a188SAmr Mokhtar * allocated
547f714a188SAmr Mokhtar */
548f714a188SAmr Mokhtar static int
test_bbdev_op_type(void)549f714a188SAmr Mokhtar test_bbdev_op_type(void)
550f714a188SAmr Mokhtar {
551f714a188SAmr Mokhtar struct rte_mempool *mp_dec;
552f714a188SAmr Mokhtar
553f714a188SAmr Mokhtar const unsigned int OPS_COUNT = 32;
554f714a188SAmr Mokhtar struct rte_bbdev_dec_op *dec_ops_arr[OPS_COUNT];
555f714a188SAmr Mokhtar struct rte_bbdev_enc_op *enc_ops_arr[OPS_COUNT];
556f714a188SAmr Mokhtar
557f714a188SAmr Mokhtar const char *pool_dec = "Test_op_dec";
558f714a188SAmr Mokhtar
559f714a188SAmr Mokhtar /* Valid pool configuration */
560f714a188SAmr Mokhtar uint32_t num_elements = 256;
561f714a188SAmr Mokhtar uint32_t cache_size = 128;
562f714a188SAmr Mokhtar
563f714a188SAmr Mokhtar /* mempool type : RTE_BBDEV_OP_TURBO_DEC */
564f714a188SAmr Mokhtar mp_dec = rte_bbdev_op_pool_create(pool_dec,
565f714a188SAmr Mokhtar RTE_BBDEV_OP_TURBO_DEC, num_elements, cache_size, 0);
566f714a188SAmr Mokhtar TEST_ASSERT(mp_dec != NULL, "Failed to create %s mempool", pool_dec);
567f714a188SAmr Mokhtar
568f714a188SAmr Mokhtar TEST_ASSERT(rte_bbdev_dec_op_alloc_bulk(mp_dec, dec_ops_arr, 1) == 0,
569f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_alloc_bulk TURBO_DEC: "
570f714a188SAmr Mokhtar "OPs type: RTE_BBDEV_OP_TURBO_DEC");
571f714a188SAmr Mokhtar
572f714a188SAmr Mokhtar TEST_ASSERT(rte_bbdev_enc_op_alloc_bulk(mp_dec, enc_ops_arr, 1) != 0,
573f714a188SAmr Mokhtar "Failed test for rte_bbdev_op_alloc_bulk TURBO_DEC: "
574f714a188SAmr Mokhtar "OPs type: RTE_BBDEV_OP_TURBO_ENC");
575f714a188SAmr Mokhtar
576f714a188SAmr Mokhtar rte_mempool_free(mp_dec);
577f714a188SAmr Mokhtar
578f714a188SAmr Mokhtar return TEST_SUCCESS;
579f714a188SAmr Mokhtar }
580f714a188SAmr Mokhtar
581f714a188SAmr Mokhtar static int
test_bbdev_op_pool_size(void)582f714a188SAmr Mokhtar test_bbdev_op_pool_size(void)
583f714a188SAmr Mokhtar {
584f714a188SAmr Mokhtar struct rte_mempool *mp_none;
585f714a188SAmr Mokhtar
586f714a188SAmr Mokhtar const unsigned int OPS_COUNT = 128;
587f714a188SAmr Mokhtar struct rte_bbdev_enc_op *ops_enc_arr[OPS_COUNT];
588f714a188SAmr Mokhtar struct rte_bbdev_enc_op *ops_ext_arr[OPS_COUNT];
589f714a188SAmr Mokhtar struct rte_bbdev_enc_op *ops_ext2_arr[OPS_COUNT];
590f714a188SAmr Mokhtar
591f714a188SAmr Mokhtar const char *pool_none = "Test_pool_size";
592f714a188SAmr Mokhtar
593f714a188SAmr Mokhtar /* Valid pool configuration */
594f714a188SAmr Mokhtar uint32_t num_elements = 256;
595f714a188SAmr Mokhtar uint32_t cache_size = 0;
596f714a188SAmr Mokhtar
597f714a188SAmr Mokhtar /* Create mempool type : RTE_BBDEV_OP_TURBO_ENC, size : 256 */
598f714a188SAmr Mokhtar mp_none = rte_bbdev_op_pool_create(pool_none, RTE_BBDEV_OP_TURBO_ENC,
599f714a188SAmr Mokhtar num_elements, cache_size, 0);
600f714a188SAmr Mokhtar TEST_ASSERT(mp_none != NULL, "Failed to create %s mempool", pool_none);
601f714a188SAmr Mokhtar
602f714a188SAmr Mokhtar /* Add 128 RTE_BBDEV_OP_TURBO_ENC ops */
603f714a188SAmr Mokhtar rte_bbdev_enc_op_alloc_bulk(mp_none, ops_enc_arr, OPS_COUNT);
604f714a188SAmr Mokhtar
605f714a188SAmr Mokhtar /* Add 128 RTE_BBDEV_OP_TURBO_ENC ops */
606f714a188SAmr Mokhtar TEST_ASSERT(rte_bbdev_enc_op_alloc_bulk(mp_none, ops_ext_arr,
607f714a188SAmr Mokhtar OPS_COUNT) == 0,
608f714a188SAmr Mokhtar "Failed test for allocating bbdev ops: "
609f714a188SAmr Mokhtar "Mempool size: 256, Free : 128, Attempted to add: 128");
610f714a188SAmr Mokhtar
611f714a188SAmr Mokhtar /* Try adding 128 more RTE_BBDEV_OP_TURBO_ENC ops, this should fail */
612f714a188SAmr Mokhtar TEST_ASSERT(rte_bbdev_enc_op_alloc_bulk(mp_none, ops_ext2_arr,
613f714a188SAmr Mokhtar OPS_COUNT) != 0,
614f714a188SAmr Mokhtar "Failed test for allocating bbdev ops: "
615f714a188SAmr Mokhtar "Mempool size: 256, Free : 0, Attempted to add: 128");
616f714a188SAmr Mokhtar
617f714a188SAmr Mokhtar /* Free-up 128 RTE_BBDEV_OP_TURBO_ENC ops */
618f714a188SAmr Mokhtar rte_bbdev_enc_op_free_bulk(ops_enc_arr, OPS_COUNT);
619f714a188SAmr Mokhtar
620f714a188SAmr Mokhtar /* Try adding 128 RTE_BBDEV_OP_TURBO_DEC ops, this should succeed */
621f714a188SAmr Mokhtar /* Cache size > 0 causes reallocation of ops size > 127 fail */
622f714a188SAmr Mokhtar TEST_ASSERT(rte_bbdev_enc_op_alloc_bulk(mp_none, ops_ext2_arr,
623f714a188SAmr Mokhtar OPS_COUNT) == 0,
624f714a188SAmr Mokhtar "Failed test for allocating ops after mempool freed: "
625f714a188SAmr Mokhtar "Mempool size: 256, Free : 128, Attempted to add: 128");
626f714a188SAmr Mokhtar
627f714a188SAmr Mokhtar rte_mempool_free(mp_none);
628f714a188SAmr Mokhtar
629f714a188SAmr Mokhtar return TEST_SUCCESS;
630f714a188SAmr Mokhtar }
631f714a188SAmr Mokhtar
632f714a188SAmr Mokhtar static int
test_bbdev_count(void)633f714a188SAmr Mokhtar test_bbdev_count(void)
634f714a188SAmr Mokhtar {
635f714a188SAmr Mokhtar uint8_t num_devs, num_valid_devs = 0;
636f714a188SAmr Mokhtar
637f714a188SAmr Mokhtar for (num_devs = 0; num_devs < RTE_BBDEV_MAX_DEVS; num_devs++) {
638f714a188SAmr Mokhtar if (rte_bbdev_is_valid(num_devs))
639f714a188SAmr Mokhtar num_valid_devs++;
640f714a188SAmr Mokhtar }
641f714a188SAmr Mokhtar
642f714a188SAmr Mokhtar num_devs = rte_bbdev_count();
643f714a188SAmr Mokhtar TEST_ASSERT(num_valid_devs == num_devs,
644f714a188SAmr Mokhtar "Failed test for rte_bbdev_is_valid: "
645f714a188SAmr Mokhtar "invalid num_devs %u ", num_devs);
646f714a188SAmr Mokhtar
647f714a188SAmr Mokhtar return TEST_SUCCESS;
648f714a188SAmr Mokhtar }
649f714a188SAmr Mokhtar
650f714a188SAmr Mokhtar static int
test_bbdev_stats(void)651f714a188SAmr Mokhtar test_bbdev_stats(void)
652f714a188SAmr Mokhtar {
653f714a188SAmr Mokhtar uint8_t dev_id = null_dev_id;
654f714a188SAmr Mokhtar uint16_t queue_id = 0;
655f714a188SAmr Mokhtar struct rte_bbdev_dec_op *dec_ops[4096] = { 0 };
656f714a188SAmr Mokhtar struct rte_bbdev_dec_op *dec_proc_ops[4096] = { 0 };
657f714a188SAmr Mokhtar struct rte_bbdev_enc_op *enc_ops[4096] = { 0 };
658f714a188SAmr Mokhtar struct rte_bbdev_enc_op *enc_proc_ops[4096] = { 0 };
659f714a188SAmr Mokhtar uint16_t num_ops = 236;
660f714a188SAmr Mokhtar struct rte_bbdev_stats stats;
661f714a188SAmr Mokhtar struct bbdev_testsuite_params *ts_params = &testsuite_params;
662f714a188SAmr Mokhtar
663f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_stop(dev_id, queue_id),
664f714a188SAmr Mokhtar "Failed to stop queue %u on device %u ", queue_id,
665f714a188SAmr Mokhtar dev_id);
666f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stop(dev_id),
667f714a188SAmr Mokhtar "Failed to stop bbdev %u ", dev_id);
668f714a188SAmr Mokhtar
669f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_configure(dev_id, queue_id,
670f714a188SAmr Mokhtar &ts_params->qconf),
671f714a188SAmr Mokhtar "Failed to configure queue %u on device %u ",
672f714a188SAmr Mokhtar queue_id, dev_id);
673f714a188SAmr Mokhtar
674f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_start(dev_id),
675f714a188SAmr Mokhtar "Failed to start bbdev %u ", dev_id);
676f714a188SAmr Mokhtar
677f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_start(dev_id, queue_id),
678f714a188SAmr Mokhtar "Failed to start queue %u on device %u ", queue_id,
679f714a188SAmr Mokhtar dev_id);
680f714a188SAmr Mokhtar
681f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_start(dev_id, queue_id),
682f714a188SAmr Mokhtar "Failed to start queue %u on device %u ", queue_id,
683f714a188SAmr Mokhtar dev_id);
684f714a188SAmr Mokhtar
685f714a188SAmr Mokhtar /* Tests after enqueue operation */
686f714a188SAmr Mokhtar rte_bbdev_enqueue_enc_ops(dev_id, queue_id, enc_ops, num_ops);
687f714a188SAmr Mokhtar rte_bbdev_enqueue_dec_ops(dev_id, queue_id, dec_ops, num_ops);
688f714a188SAmr Mokhtar
689f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_stats_get(RTE_BBDEV_MAX_DEVS, &stats),
690f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get on device %u ",
691f714a188SAmr Mokhtar dev_id);
692f714a188SAmr Mokhtar
693f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_stats_get(dev_id, NULL),
694f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get on device %u ",
695f714a188SAmr Mokhtar dev_id);
696f714a188SAmr Mokhtar
697f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_get(dev_id, &stats),
698f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get on device %u ",
699f714a188SAmr Mokhtar dev_id);
700f714a188SAmr Mokhtar
701f714a188SAmr Mokhtar TEST_ASSERT(stats.enqueued_count == 2 * num_ops,
702f714a188SAmr Mokhtar "Failed test for rte_bbdev_enqueue_ops: "
703f714a188SAmr Mokhtar "invalid enqueued_count %" PRIu64 " ",
704f714a188SAmr Mokhtar stats.enqueued_count);
705f714a188SAmr Mokhtar
706f714a188SAmr Mokhtar TEST_ASSERT(stats.dequeued_count == 0,
707f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
708f714a188SAmr Mokhtar "invalid dequeued_count %" PRIu64 " ",
709f714a188SAmr Mokhtar stats.dequeued_count);
710f714a188SAmr Mokhtar
711f714a188SAmr Mokhtar /* Tests after dequeue operation */
712f714a188SAmr Mokhtar rte_bbdev_dequeue_enc_ops(dev_id, queue_id, enc_proc_ops, num_ops);
713f714a188SAmr Mokhtar rte_bbdev_dequeue_dec_ops(dev_id, queue_id, dec_proc_ops, num_ops);
714f714a188SAmr Mokhtar
715f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_get(dev_id, &stats),
716f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get on device %u ",
717f714a188SAmr Mokhtar dev_id);
718f714a188SAmr Mokhtar
719f714a188SAmr Mokhtar TEST_ASSERT(stats.dequeued_count == 2 * num_ops,
720f714a188SAmr Mokhtar "Failed test for rte_bbdev_dequeue_ops: "
721f714a188SAmr Mokhtar "invalid enqueued_count %" PRIu64 " ",
722f714a188SAmr Mokhtar stats.dequeued_count);
723f714a188SAmr Mokhtar
724f714a188SAmr Mokhtar TEST_ASSERT(stats.enqueue_err_count == 0,
725f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
726f714a188SAmr Mokhtar "invalid enqueue_err_count %" PRIu64 " ",
727f714a188SAmr Mokhtar stats.enqueue_err_count);
728f714a188SAmr Mokhtar
729f714a188SAmr Mokhtar TEST_ASSERT(stats.dequeue_err_count == 0,
730f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
731f714a188SAmr Mokhtar "invalid dequeue_err_count %" PRIu64 " ",
732f714a188SAmr Mokhtar stats.dequeue_err_count);
733f714a188SAmr Mokhtar
734f714a188SAmr Mokhtar /* Tests after reset operation */
735f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_stats_reset(RTE_BBDEV_MAX_DEVS),
736f714a188SAmr Mokhtar "Failed to reset statistic for device %u ", dev_id);
737f714a188SAmr Mokhtar
738f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_reset(dev_id),
739f714a188SAmr Mokhtar "Failed to reset statistic for device %u ", dev_id);
740f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_get(dev_id, &stats),
741f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get on device %u ",
742f714a188SAmr Mokhtar dev_id);
743f714a188SAmr Mokhtar
744f714a188SAmr Mokhtar TEST_ASSERT(stats.enqueued_count == 0,
745f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
746f714a188SAmr Mokhtar "invalid enqueued_count %" PRIu64 " ",
747f714a188SAmr Mokhtar stats.enqueued_count);
748f714a188SAmr Mokhtar
749f714a188SAmr Mokhtar TEST_ASSERT(stats.dequeued_count == 0,
750f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
751f714a188SAmr Mokhtar "invalid dequeued_count %" PRIu64 " ",
752f714a188SAmr Mokhtar stats.dequeued_count);
753f714a188SAmr Mokhtar
754f714a188SAmr Mokhtar TEST_ASSERT(stats.enqueue_err_count == 0,
755f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
756f714a188SAmr Mokhtar "invalid enqueue_err_count %" PRIu64 " ",
757f714a188SAmr Mokhtar stats.enqueue_err_count);
758f714a188SAmr Mokhtar
759f714a188SAmr Mokhtar TEST_ASSERT(stats.dequeue_err_count == 0,
760f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
761f714a188SAmr Mokhtar "invalid dequeue_err_count %" PRIu64 " ",
762f714a188SAmr Mokhtar stats.dequeue_err_count);
763f714a188SAmr Mokhtar
764f714a188SAmr Mokhtar return TEST_SUCCESS;
765f714a188SAmr Mokhtar }
766f714a188SAmr Mokhtar
767f714a188SAmr Mokhtar static int
test_bbdev_driver_init(void)768f714a188SAmr Mokhtar test_bbdev_driver_init(void)
769f714a188SAmr Mokhtar {
770f714a188SAmr Mokhtar struct rte_bbdev *dev1, *dev2;
771f714a188SAmr Mokhtar const char *name = "dev_name";
772d819c083SNicolas Chautru char name_tmp[32];
773f714a188SAmr Mokhtar int num_devs, num_devs_tmp;
774f714a188SAmr Mokhtar
775f714a188SAmr Mokhtar dev1 = rte_bbdev_allocate(NULL);
776f714a188SAmr Mokhtar TEST_ASSERT(dev1 == NULL,
777f714a188SAmr Mokhtar "Failed initialize bbdev driver with NULL name");
778f714a188SAmr Mokhtar
779f714a188SAmr Mokhtar dev1 = rte_bbdev_allocate(name);
780f714a188SAmr Mokhtar TEST_ASSERT(dev1 != NULL, "Failed to initialize bbdev driver");
781f714a188SAmr Mokhtar
782f714a188SAmr Mokhtar dev2 = rte_bbdev_allocate(name);
783f714a188SAmr Mokhtar TEST_ASSERT(dev2 == NULL,
784f714a188SAmr Mokhtar "Failed to initialize bbdev driver: "
785f714a188SAmr Mokhtar "driver with the same name has been initialized before");
786f714a188SAmr Mokhtar
787f714a188SAmr Mokhtar num_devs = rte_bbdev_count() - 1;
788f714a188SAmr Mokhtar num_devs_tmp = num_devs;
789f714a188SAmr Mokhtar
790f714a188SAmr Mokhtar /* Initialize the maximum amount of devices */
791f714a188SAmr Mokhtar do {
792d819c083SNicolas Chautru sprintf(name_tmp, "%s%i", "name_", num_devs);
793f714a188SAmr Mokhtar dev2 = rte_bbdev_allocate(name_tmp);
794f714a188SAmr Mokhtar TEST_ASSERT(dev2 != NULL,
795f714a188SAmr Mokhtar "Failed to initialize bbdev driver");
796f714a188SAmr Mokhtar ++num_devs;
797f714a188SAmr Mokhtar } while (num_devs < (RTE_BBDEV_MAX_DEVS - 1));
798f714a188SAmr Mokhtar
799d819c083SNicolas Chautru sprintf(name_tmp, "%s%i", "name_", num_devs);
800f714a188SAmr Mokhtar dev2 = rte_bbdev_allocate(name_tmp);
801f714a188SAmr Mokhtar TEST_ASSERT(dev2 == NULL, "Failed to initialize bbdev driver number %d "
802f714a188SAmr Mokhtar "more drivers than RTE_BBDEV_MAX_DEVS: %d ", num_devs,
803f714a188SAmr Mokhtar RTE_BBDEV_MAX_DEVS);
804f714a188SAmr Mokhtar
805f714a188SAmr Mokhtar num_devs--;
806f714a188SAmr Mokhtar
807f714a188SAmr Mokhtar while (num_devs >= num_devs_tmp) {
808d819c083SNicolas Chautru sprintf(name_tmp, "%s%i", "name_", num_devs);
809f714a188SAmr Mokhtar dev2 = rte_bbdev_get_named_dev(name_tmp);
810f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_release(dev2),
811f714a188SAmr Mokhtar "Failed to uninitialize bbdev driver %s ",
812f714a188SAmr Mokhtar name_tmp);
813f714a188SAmr Mokhtar num_devs--;
814f714a188SAmr Mokhtar }
815f714a188SAmr Mokhtar
816f714a188SAmr Mokhtar TEST_ASSERT(dev1->data->dev_id < RTE_BBDEV_MAX_DEVS,
817f714a188SAmr Mokhtar "Failed test rte_bbdev_allocate: "
818f714a188SAmr Mokhtar "invalid dev_id %" PRIu8 ", max number of devices %d ",
819f714a188SAmr Mokhtar dev1->data->dev_id, RTE_BBDEV_MAX_DEVS);
820f714a188SAmr Mokhtar
821f714a188SAmr Mokhtar TEST_ASSERT(dev1->state == RTE_BBDEV_INITIALIZED,
822f714a188SAmr Mokhtar "Failed test rte_bbdev_allocate: "
823f714a188SAmr Mokhtar "invalid state %d (0 - RTE_BBDEV_UNUSED, 1 - RTE_BBDEV_INITIALIZED",
824f714a188SAmr Mokhtar dev1->state);
825f714a188SAmr Mokhtar
826f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_release(NULL),
827f714a188SAmr Mokhtar "Failed to uninitialize bbdev driver with NULL bbdev");
828f714a188SAmr Mokhtar
829d819c083SNicolas Chautru sprintf(name_tmp, "%s", "invalid_name");
830f714a188SAmr Mokhtar dev2 = rte_bbdev_get_named_dev(name_tmp);
831f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_release(dev2),
832f714a188SAmr Mokhtar "Failed to uninitialize bbdev driver with invalid name");
833f714a188SAmr Mokhtar
834f714a188SAmr Mokhtar dev2 = rte_bbdev_get_named_dev(name);
835f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_release(dev2),
836f714a188SAmr Mokhtar "Failed to uninitialize bbdev driver: %s ", name);
837f714a188SAmr Mokhtar
838f714a188SAmr Mokhtar return TEST_SUCCESS;
839f714a188SAmr Mokhtar }
840f714a188SAmr Mokhtar
841f714a188SAmr Mokhtar static void
event_callback(uint16_t dev_id,enum rte_bbdev_event_type type,void * param,void * ret_param)842f714a188SAmr Mokhtar event_callback(uint16_t dev_id, enum rte_bbdev_event_type type, void *param,
843f714a188SAmr Mokhtar void *ret_param)
844f714a188SAmr Mokhtar {
845f714a188SAmr Mokhtar RTE_SET_USED(dev_id);
846f714a188SAmr Mokhtar RTE_SET_USED(ret_param);
847f714a188SAmr Mokhtar
848f714a188SAmr Mokhtar if (param == NULL)
849f714a188SAmr Mokhtar return;
850f714a188SAmr Mokhtar
851f714a188SAmr Mokhtar if (type == RTE_BBDEV_EVENT_UNKNOWN ||
852f714a188SAmr Mokhtar type == RTE_BBDEV_EVENT_ERROR ||
853f714a188SAmr Mokhtar type == RTE_BBDEV_EVENT_MAX)
854f714a188SAmr Mokhtar *(int *)param = type;
855f714a188SAmr Mokhtar }
856f714a188SAmr Mokhtar
857f714a188SAmr Mokhtar static int
test_bbdev_callback(void)858f714a188SAmr Mokhtar test_bbdev_callback(void)
859f714a188SAmr Mokhtar {
860f714a188SAmr Mokhtar struct rte_bbdev *dev1, *dev2;
861f714a188SAmr Mokhtar const char *name = "dev_name1";
862f714a188SAmr Mokhtar const char *name2 = "dev_name2";
863f714a188SAmr Mokhtar int event_status;
864f714a188SAmr Mokhtar uint8_t invalid_dev_id = RTE_BBDEV_MAX_DEVS;
865f714a188SAmr Mokhtar enum rte_bbdev_event_type invalid_event_type = RTE_BBDEV_EVENT_MAX;
866f714a188SAmr Mokhtar uint8_t dev_id;
867f714a188SAmr Mokhtar
868f714a188SAmr Mokhtar dev1 = rte_bbdev_allocate(name);
869f714a188SAmr Mokhtar TEST_ASSERT(dev1 != NULL, "Failed to initialize bbdev driver");
870f714a188SAmr Mokhtar
871f714a188SAmr Mokhtar /*
872f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_UNKNOWN - unregistered
873f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_ERROR - unregistered
874f714a188SAmr Mokhtar */
875f714a188SAmr Mokhtar event_status = -1;
876f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_UNKNOWN, NULL);
877f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_ERROR, NULL);
878f714a188SAmr Mokhtar TEST_ASSERT(event_status == -1,
879f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process: "
880f714a188SAmr Mokhtar "events were not registered ");
881f714a188SAmr Mokhtar
882f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_register(dev1->data->dev_id,
883f714a188SAmr Mokhtar RTE_BBDEV_EVENT_MAX, event_callback, NULL),
884f714a188SAmr Mokhtar "Failed to callback register for RTE_BBDEV_EVENT_MAX ");
885f714a188SAmr Mokhtar
886f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_unregister(dev1->data->dev_id,
887f714a188SAmr Mokhtar RTE_BBDEV_EVENT_MAX, event_callback, NULL),
888f714a188SAmr Mokhtar "Failed to unregister RTE_BBDEV_EVENT_MAX ");
889f714a188SAmr Mokhtar
890f714a188SAmr Mokhtar /*
891f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_UNKNOWN - registered
892f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_ERROR - unregistered
893f714a188SAmr Mokhtar */
894f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_register(dev1->data->dev_id,
895f714a188SAmr Mokhtar RTE_BBDEV_EVENT_UNKNOWN, event_callback, &event_status),
896f714a188SAmr Mokhtar "Failed to callback rgstr for RTE_BBDEV_EVENT_UNKNOWN");
897f714a188SAmr Mokhtar
898f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_UNKNOWN, NULL);
899f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_UNKNOWN,
900f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process "
901f714a188SAmr Mokhtar "for RTE_BBDEV_EVENT_UNKNOWN ");
902f714a188SAmr Mokhtar
903f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_ERROR, NULL);
904f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_UNKNOWN,
905f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process: "
906f714a188SAmr Mokhtar "event RTE_BBDEV_EVENT_ERROR was not registered ");
907f714a188SAmr Mokhtar
908f714a188SAmr Mokhtar /*
909f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_UNKNOWN - registered
910f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_ERROR - registered
911f714a188SAmr Mokhtar */
912f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_register(dev1->data->dev_id,
913f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, event_callback, &event_status),
914f714a188SAmr Mokhtar "Failed to callback rgstr for RTE_BBDEV_EVENT_ERROR ");
915f714a188SAmr Mokhtar
916f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_register(dev1->data->dev_id,
917f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, event_callback, &event_status),
918f714a188SAmr Mokhtar "Failed to callback register for RTE_BBDEV_EVENT_ERROR"
919f714a188SAmr Mokhtar "(re-registration) ");
920f714a188SAmr Mokhtar
921f714a188SAmr Mokhtar event_status = -1;
922f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_UNKNOWN, NULL);
923f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_UNKNOWN,
924f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process "
925f714a188SAmr Mokhtar "for RTE_BBDEV_EVENT_UNKNOWN ");
926f714a188SAmr Mokhtar
927f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_ERROR, NULL);
928f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_ERROR,
929f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process "
930f714a188SAmr Mokhtar "for RTE_BBDEV_EVENT_ERROR ");
931f714a188SAmr Mokhtar
932f714a188SAmr Mokhtar /*
933f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_UNKNOWN - registered
934f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_ERROR - unregistered
935f714a188SAmr Mokhtar */
936f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_unregister(dev1->data->dev_id,
937f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, event_callback, &event_status),
938f714a188SAmr Mokhtar "Failed to unregister RTE_BBDEV_EVENT_ERROR ");
939f714a188SAmr Mokhtar
940f714a188SAmr Mokhtar event_status = -1;
941f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_UNKNOWN, NULL);
942f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_UNKNOWN,
943f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process "
944f714a188SAmr Mokhtar "for RTE_BBDEV_EVENT_UNKNOWN ");
945f714a188SAmr Mokhtar
946f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_ERROR, NULL);
947f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_UNKNOWN,
948f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process: "
949f714a188SAmr Mokhtar "event RTE_BBDEV_EVENT_ERROR was unregistered ");
950f714a188SAmr Mokhtar
951f714a188SAmr Mokhtar /* rte_bbdev_callback_register with invalid inputs */
952f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_register(invalid_dev_id,
953f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, event_callback, &event_status),
954f714a188SAmr Mokhtar "Failed test for rte_bbdev_callback_register "
955f714a188SAmr Mokhtar "for invalid_dev_id ");
956f714a188SAmr Mokhtar
957f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_register(dev1->data->dev_id,
958f714a188SAmr Mokhtar invalid_event_type, event_callback, &event_status),
959f714a188SAmr Mokhtar "Failed to callback register for invalid event type ");
960f714a188SAmr Mokhtar
961f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_register(dev1->data->dev_id,
962f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, NULL, &event_status),
963f714a188SAmr Mokhtar "Failed to callback register - no callback function ");
964f714a188SAmr Mokhtar
965f714a188SAmr Mokhtar /* The impact of devices on each other */
966f714a188SAmr Mokhtar dev2 = rte_bbdev_allocate(name2);
967f714a188SAmr Mokhtar TEST_ASSERT(dev2 != NULL,
968f714a188SAmr Mokhtar "Failed to initialize bbdev driver");
969f714a188SAmr Mokhtar
970f714a188SAmr Mokhtar /*
971f714a188SAmr Mokhtar * dev2:
972f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_UNKNOWN - unregistered
973f714a188SAmr Mokhtar * RTE_BBDEV_EVENT_ERROR - unregistered
974f714a188SAmr Mokhtar */
975f714a188SAmr Mokhtar event_status = -1;
976f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_UNKNOWN, NULL);
977f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_ERROR, NULL);
978f714a188SAmr Mokhtar TEST_ASSERT(event_status == -1,
979f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process: "
980f714a188SAmr Mokhtar "events were not registered ");
981f714a188SAmr Mokhtar
982f714a188SAmr Mokhtar /*
983f714a188SAmr Mokhtar * dev1: RTE_BBDEV_EVENT_ERROR - unregistered
984f714a188SAmr Mokhtar * dev2: RTE_BBDEV_EVENT_ERROR - registered
985f714a188SAmr Mokhtar */
986f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_register(dev2->data->dev_id,
987f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, event_callback, &event_status),
988f714a188SAmr Mokhtar "Failed to callback rgstr for RTE_BBDEV_EVENT_ERROR");
989f714a188SAmr Mokhtar
990f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_ERROR, NULL);
991f714a188SAmr Mokhtar TEST_ASSERT(event_status == -1,
992f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process in dev1 "
993f714a188SAmr Mokhtar "for RTE_BBDEV_EVENT_ERROR ");
994f714a188SAmr Mokhtar
995f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_ERROR, NULL);
996f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_ERROR,
997f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process in dev2 "
998f714a188SAmr Mokhtar "for RTE_BBDEV_EVENT_ERROR ");
999f714a188SAmr Mokhtar
1000f714a188SAmr Mokhtar /*
1001f714a188SAmr Mokhtar * dev1: RTE_BBDEV_EVENT_UNKNOWN - registered
1002f714a188SAmr Mokhtar * dev2: RTE_BBDEV_EVENT_UNKNOWN - unregistered
1003f714a188SAmr Mokhtar */
1004f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_register(dev2->data->dev_id,
1005f714a188SAmr Mokhtar RTE_BBDEV_EVENT_UNKNOWN, event_callback, &event_status),
1006f714a188SAmr Mokhtar "Failed to callback register for RTE_BBDEV_EVENT_UNKNOWN "
1007f714a188SAmr Mokhtar "in dev 2 ");
1008f714a188SAmr Mokhtar
1009f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_UNKNOWN, NULL);
1010f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_UNKNOWN,
1011f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process in dev2"
1012f714a188SAmr Mokhtar " for RTE_BBDEV_EVENT_UNKNOWN ");
1013f714a188SAmr Mokhtar
1014f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_unregister(dev2->data->dev_id,
1015f714a188SAmr Mokhtar RTE_BBDEV_EVENT_UNKNOWN, event_callback, &event_status),
1016f714a188SAmr Mokhtar "Failed to unregister RTE_BBDEV_EVENT_UNKNOWN ");
1017f714a188SAmr Mokhtar
1018f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_unregister(dev2->data->dev_id,
1019f714a188SAmr Mokhtar RTE_BBDEV_EVENT_UNKNOWN, event_callback, &event_status),
1020f714a188SAmr Mokhtar "Failed to unregister RTE_BBDEV_EVENT_UNKNOWN : "
1021f714a188SAmr Mokhtar "unregister function called once again ");
1022f714a188SAmr Mokhtar
1023f714a188SAmr Mokhtar event_status = -1;
1024f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_UNKNOWN, NULL);
1025f714a188SAmr Mokhtar TEST_ASSERT(event_status == -1,
1026f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process in dev2"
1027f714a188SAmr Mokhtar " for RTE_BBDEV_EVENT_UNKNOWN ");
1028f714a188SAmr Mokhtar
1029f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_UNKNOWN, NULL);
1030f287b797SKamil Chalupnik TEST_ASSERT(event_status == (int) RTE_BBDEV_EVENT_UNKNOWN,
1031f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process in dev2 "
1032f714a188SAmr Mokhtar "for RTE_BBDEV_EVENT_UNKNOWN ");
1033f714a188SAmr Mokhtar
1034f714a188SAmr Mokhtar /* rte_bbdev_pmd_callback_process with invalid inputs */
1035f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(NULL, RTE_BBDEV_EVENT_UNKNOWN, NULL);
1036f714a188SAmr Mokhtar
1037f714a188SAmr Mokhtar event_status = -1;
1038f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, invalid_event_type, NULL);
1039f714a188SAmr Mokhtar TEST_ASSERT(event_status == -1,
1040f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process: "
1041f714a188SAmr Mokhtar "for invalid event type ");
1042f714a188SAmr Mokhtar
1043f714a188SAmr Mokhtar /* rte_dev_callback_unregister with invalid inputs */
1044f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_unregister(invalid_dev_id,
1045f714a188SAmr Mokhtar RTE_BBDEV_EVENT_UNKNOWN, event_callback, &event_status),
1046f714a188SAmr Mokhtar "Failed test for rte_dev_callback_unregister "
1047f714a188SAmr Mokhtar "for invalid_dev_id ");
1048f714a188SAmr Mokhtar
1049f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_unregister(dev1->data->dev_id,
1050f714a188SAmr Mokhtar invalid_event_type, event_callback, &event_status),
1051f714a188SAmr Mokhtar "Failed rte_dev_callback_unregister "
1052f714a188SAmr Mokhtar "for invalid event type ");
1053f714a188SAmr Mokhtar
1054f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_unregister(dev1->data->dev_id,
1055f714a188SAmr Mokhtar invalid_event_type, NULL, &event_status),
1056f714a188SAmr Mokhtar "Failed rte_dev_callback_unregister "
1057f714a188SAmr Mokhtar "when no callback function ");
1058f714a188SAmr Mokhtar
1059f714a188SAmr Mokhtar dev_id = dev1->data->dev_id;
1060f714a188SAmr Mokhtar
1061f714a188SAmr Mokhtar rte_bbdev_release(dev1);
1062f714a188SAmr Mokhtar rte_bbdev_release(dev2);
1063f714a188SAmr Mokhtar
1064f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_register(dev_id,
1065f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, event_callback, &event_status),
1066f714a188SAmr Mokhtar "Failed test for rte_bbdev_callback_register: "
1067f714a188SAmr Mokhtar "function called after rte_bbdev_driver_uninit .");
1068f714a188SAmr Mokhtar
1069f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_callback_unregister(dev_id,
1070f714a188SAmr Mokhtar RTE_BBDEV_EVENT_ERROR, event_callback, &event_status),
1071f714a188SAmr Mokhtar "Failed test for rte_dev_callback_unregister: "
1072f714a188SAmr Mokhtar "function called after rte_bbdev_driver_uninit. ");
1073f714a188SAmr Mokhtar
1074f714a188SAmr Mokhtar event_status = -1;
1075f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_UNKNOWN, NULL);
1076f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev1, RTE_BBDEV_EVENT_ERROR, NULL);
1077f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_UNKNOWN, NULL);
1078f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_ERROR, NULL);
1079f714a188SAmr Mokhtar TEST_ASSERT(event_status == -1,
1080f714a188SAmr Mokhtar "Failed test for rte_bbdev_pmd_callback_process: "
1081f714a188SAmr Mokhtar "callback function was called after rte_bbdev_driver_uninit");
1082f714a188SAmr Mokhtar
1083f714a188SAmr Mokhtar return TEST_SUCCESS;
1084f714a188SAmr Mokhtar }
1085f714a188SAmr Mokhtar
1086f714a188SAmr Mokhtar static int
test_bbdev_invalid_driver(void)1087f714a188SAmr Mokhtar test_bbdev_invalid_driver(void)
1088f714a188SAmr Mokhtar {
1089f714a188SAmr Mokhtar struct rte_bbdev dev1, *dev2;
1090f714a188SAmr Mokhtar uint8_t dev_id = null_dev_id;
1091f714a188SAmr Mokhtar uint16_t queue_id = 0;
1092f714a188SAmr Mokhtar struct rte_bbdev_stats stats;
1093f714a188SAmr Mokhtar struct bbdev_testsuite_params *ts_params = &testsuite_params;
1094f714a188SAmr Mokhtar struct rte_bbdev_queue_info qinfo;
1095f714a188SAmr Mokhtar struct rte_bbdev_ops dev_ops_tmp;
1096f714a188SAmr Mokhtar
1097f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stop(dev_id), "Failed to stop bbdev %u ",
1098f714a188SAmr Mokhtar dev_id);
1099f714a188SAmr Mokhtar
1100f714a188SAmr Mokhtar dev1 = rte_bbdev_devices[dev_id];
1101f714a188SAmr Mokhtar dev2 = &rte_bbdev_devices[dev_id];
1102f714a188SAmr Mokhtar
1103f714a188SAmr Mokhtar /* Tests for rte_bbdev_setup_queues */
1104f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1105f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_setup_queues(dev_id, 1, SOCKET_ID_ANY),
1106f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
1107f714a188SAmr Mokhtar "NULL dev_ops structure ");
1108f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1109f714a188SAmr Mokhtar
1110f714a188SAmr Mokhtar dev_ops_tmp = *dev2->dev_ops;
1111f714a188SAmr Mokhtar dev_ops_tmp.info_get = NULL;
1112f714a188SAmr Mokhtar dev2->dev_ops = &dev_ops_tmp;
1113f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_setup_queues(dev_id, 1, SOCKET_ID_ANY),
1114f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
1115f714a188SAmr Mokhtar "NULL info_get ");
1116f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1117f714a188SAmr Mokhtar
1118f714a188SAmr Mokhtar dev_ops_tmp = *dev2->dev_ops;
1119f714a188SAmr Mokhtar dev_ops_tmp.queue_release = NULL;
1120f714a188SAmr Mokhtar dev2->dev_ops = &dev_ops_tmp;
1121f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_setup_queues(dev_id, 1, SOCKET_ID_ANY),
1122f714a188SAmr Mokhtar "Failed test for rte_bbdev_setup_queues: "
1123f714a188SAmr Mokhtar "NULL queue_release ");
1124f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1125f714a188SAmr Mokhtar
1126f714a188SAmr Mokhtar dev2->data->socket_id = SOCKET_ID_ANY;
1127f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_setup_queues(dev_id, 1,
1128f714a188SAmr Mokhtar SOCKET_ID_ANY), "Failed to configure bbdev %u", dev_id);
1129f714a188SAmr Mokhtar
1130f714a188SAmr Mokhtar /* Test for rte_bbdev_queue_configure */
1131f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1132f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
1133f714a188SAmr Mokhtar &ts_params->qconf),
1134f714a188SAmr Mokhtar "Failed to configure queue %u on device %u "
1135f714a188SAmr Mokhtar "with NULL dev_ops structure ", queue_id, dev_id);
1136f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1137f714a188SAmr Mokhtar
1138f714a188SAmr Mokhtar dev_ops_tmp = *dev2->dev_ops;
1139f714a188SAmr Mokhtar dev_ops_tmp.queue_setup = NULL;
1140f714a188SAmr Mokhtar dev2->dev_ops = &dev_ops_tmp;
1141f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
1142f714a188SAmr Mokhtar &ts_params->qconf),
1143f714a188SAmr Mokhtar "Failed to configure queue %u on device %u "
1144f714a188SAmr Mokhtar "with NULL queue_setup ", queue_id, dev_id);
1145f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1146f714a188SAmr Mokhtar
1147f714a188SAmr Mokhtar dev_ops_tmp = *dev2->dev_ops;
1148f714a188SAmr Mokhtar dev_ops_tmp.info_get = NULL;
1149f714a188SAmr Mokhtar dev2->dev_ops = &dev_ops_tmp;
1150f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(dev_id, queue_id,
1151f714a188SAmr Mokhtar &ts_params->qconf),
1152f714a188SAmr Mokhtar "Failed to configure queue %u on device %u "
1153f714a188SAmr Mokhtar "with NULL info_get ", queue_id, dev_id);
1154f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1155f714a188SAmr Mokhtar
1156f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_configure(RTE_BBDEV_MAX_DEVS,
1157f714a188SAmr Mokhtar queue_id, &ts_params->qconf),
1158f714a188SAmr Mokhtar "Failed to configure queue %u on device %u ",
1159f714a188SAmr Mokhtar queue_id, dev_id);
1160f714a188SAmr Mokhtar
1161f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_configure(dev_id, queue_id,
1162f714a188SAmr Mokhtar &ts_params->qconf),
1163f714a188SAmr Mokhtar "Failed to configure queue %u on device %u ",
1164f714a188SAmr Mokhtar queue_id, dev_id);
1165f714a188SAmr Mokhtar
1166f714a188SAmr Mokhtar /* Test for rte_bbdev_queue_info_get */
1167f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1168f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_info_get(dev_id, queue_id, &qinfo),
1169f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
1170f714a188SAmr Mokhtar "NULL dev_ops structure ");
1171f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1172f714a188SAmr Mokhtar
1173f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_info_get(RTE_BBDEV_MAX_DEVS,
1174f714a188SAmr Mokhtar queue_id, &qinfo),
1175f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
1176f714a188SAmr Mokhtar "invalid dev_id ");
1177f714a188SAmr Mokhtar
1178f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_info_get(dev_id,
1179f714a188SAmr Mokhtar RTE_MAX_QUEUES_PER_PORT, &qinfo),
1180f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
1181f714a188SAmr Mokhtar "invalid queue_id ");
1182f714a188SAmr Mokhtar
1183f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_info_get(dev_id, queue_id, NULL),
1184f714a188SAmr Mokhtar "Failed test for rte_bbdev_info_get: "
1185f714a188SAmr Mokhtar "invalid dev_info ");
1186f714a188SAmr Mokhtar
1187f714a188SAmr Mokhtar /* Test for rte_bbdev_start */
1188f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1189f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_start(dev_id),
1190f714a188SAmr Mokhtar "Failed to start bbdev %u "
1191f714a188SAmr Mokhtar "with NULL dev_ops structure ", dev_id);
1192f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1193f714a188SAmr Mokhtar
1194f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_start(dev_id),
1195f714a188SAmr Mokhtar "Failed to start bbdev %u ", dev_id);
1196f714a188SAmr Mokhtar
1197f714a188SAmr Mokhtar /* Test for rte_bbdev_queue_start */
1198f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1199f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_start(dev_id, queue_id),
1200f714a188SAmr Mokhtar "Failed to start queue %u on device %u: "
1201f714a188SAmr Mokhtar "NULL dev_ops structure", queue_id, dev_id);
1202f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1203f714a188SAmr Mokhtar
1204f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_start(dev_id, queue_id),
1205f714a188SAmr Mokhtar "Failed to start queue %u on device %u ", queue_id,
1206f714a188SAmr Mokhtar dev_id);
1207f714a188SAmr Mokhtar
1208f714a188SAmr Mokhtar /* Tests for rte_bbdev_stats_get */
1209f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1210f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_stats_get(dev_id, &stats),
1211f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get on device %u ",
1212f714a188SAmr Mokhtar dev_id);
1213f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1214f714a188SAmr Mokhtar
1215f714a188SAmr Mokhtar dev_ops_tmp = *dev2->dev_ops;
1216f714a188SAmr Mokhtar dev_ops_tmp.stats_reset = NULL;
1217f714a188SAmr Mokhtar dev2->dev_ops = &dev_ops_tmp;
1218f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_get(dev_id, &stats),
1219f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get: "
1220f714a188SAmr Mokhtar "NULL stats_get ");
1221f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1222f714a188SAmr Mokhtar
1223f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_get(dev_id, &stats),
1224f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_get on device %u ",
1225f714a188SAmr Mokhtar dev_id);
1226f714a188SAmr Mokhtar
1227f714a188SAmr Mokhtar /*
1228f714a188SAmr Mokhtar * Tests for:
1229f714a188SAmr Mokhtar * rte_bbdev_callback_register,
1230f714a188SAmr Mokhtar * rte_bbdev_pmd_callback_process,
1231f714a188SAmr Mokhtar * rte_dev_callback_unregister
1232f714a188SAmr Mokhtar */
1233f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1234f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_register(dev_id,
1235f714a188SAmr Mokhtar RTE_BBDEV_EVENT_UNKNOWN, event_callback, NULL),
1236f714a188SAmr Mokhtar "Failed to callback rgstr for RTE_BBDEV_EVENT_UNKNOWN");
1237f714a188SAmr Mokhtar rte_bbdev_pmd_callback_process(dev2, RTE_BBDEV_EVENT_UNKNOWN, NULL);
1238f714a188SAmr Mokhtar
1239f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_callback_unregister(dev_id,
1240f714a188SAmr Mokhtar RTE_BBDEV_EVENT_UNKNOWN, event_callback, NULL),
1241f714a188SAmr Mokhtar "Failed to unregister RTE_BBDEV_EVENT_ERROR ");
1242f714a188SAmr Mokhtar
1243f714a188SAmr Mokhtar /* Tests for rte_bbdev_stats_reset */
1244f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1245f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_stats_reset(dev_id),
1246f714a188SAmr Mokhtar "Failed to reset statistic for device %u ", dev_id);
1247f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1248f714a188SAmr Mokhtar
1249f714a188SAmr Mokhtar dev_ops_tmp = *dev2->dev_ops;
1250f714a188SAmr Mokhtar dev_ops_tmp.stats_reset = NULL;
1251f714a188SAmr Mokhtar dev2->dev_ops = &dev_ops_tmp;
1252f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_reset(dev_id),
1253f714a188SAmr Mokhtar "Failed test for rte_bbdev_stats_reset: "
1254f714a188SAmr Mokhtar "NULL stats_reset ");
1255f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1256f714a188SAmr Mokhtar
1257f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stats_reset(dev_id),
1258f714a188SAmr Mokhtar "Failed to reset statistic for device %u ", dev_id);
1259f714a188SAmr Mokhtar
1260f714a188SAmr Mokhtar /* Tests for rte_bbdev_queue_stop */
1261f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1262f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_queue_stop(dev_id, queue_id),
1263f714a188SAmr Mokhtar "Failed to stop queue %u on device %u: "
1264f714a188SAmr Mokhtar "NULL dev_ops structure", queue_id, dev_id);
1265f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1266f714a188SAmr Mokhtar
1267f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_queue_stop(dev_id, queue_id),
1268f714a188SAmr Mokhtar "Failed to stop queue %u on device %u ", queue_id,
1269f714a188SAmr Mokhtar dev_id);
1270f714a188SAmr Mokhtar
1271f714a188SAmr Mokhtar /* Tests for rte_bbdev_stop */
1272f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1273f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_stop(dev_id),
1274f714a188SAmr Mokhtar "Failed to stop bbdev %u with NULL dev_ops structure ",
1275f714a188SAmr Mokhtar dev_id);
1276f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1277f714a188SAmr Mokhtar
1278f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_stop(dev_id),
1279f714a188SAmr Mokhtar "Failed to stop bbdev %u ", dev_id);
1280f714a188SAmr Mokhtar
1281f714a188SAmr Mokhtar /* Tests for rte_bbdev_close */
1282f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_close(RTE_BBDEV_MAX_DEVS),
1283f714a188SAmr Mokhtar "Failed to close bbdev with invalid dev_id");
1284f714a188SAmr Mokhtar
1285f714a188SAmr Mokhtar dev2->dev_ops = NULL;
1286f714a188SAmr Mokhtar TEST_ASSERT_FAIL(rte_bbdev_close(dev_id),
1287f714a188SAmr Mokhtar "Failed to close bbdev %u with NULL dev_ops structure ",
1288f714a188SAmr Mokhtar dev_id);
1289f714a188SAmr Mokhtar dev2->dev_ops = dev1.dev_ops;
1290f714a188SAmr Mokhtar
1291f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_close(dev_id),
1292f714a188SAmr Mokhtar "Failed to close bbdev %u ", dev_id);
1293f714a188SAmr Mokhtar
1294f714a188SAmr Mokhtar return TEST_SUCCESS;
1295f714a188SAmr Mokhtar }
1296f714a188SAmr Mokhtar
1297f714a188SAmr Mokhtar static int
test_bbdev_get_named_dev(void)1298f714a188SAmr Mokhtar test_bbdev_get_named_dev(void)
1299f714a188SAmr Mokhtar {
1300f714a188SAmr Mokhtar struct rte_bbdev *dev, *dev_tmp;
1301f714a188SAmr Mokhtar const char *name = "name";
1302f714a188SAmr Mokhtar
1303f714a188SAmr Mokhtar dev = rte_bbdev_allocate(name);
1304f714a188SAmr Mokhtar TEST_ASSERT(dev != NULL, "Failed to initialize bbdev driver");
1305f714a188SAmr Mokhtar
1306f714a188SAmr Mokhtar dev_tmp = rte_bbdev_get_named_dev(NULL);
1307f714a188SAmr Mokhtar TEST_ASSERT(dev_tmp == NULL, "Failed test for rte_bbdev_get_named_dev: "
1308f714a188SAmr Mokhtar "function called with NULL parameter");
1309f714a188SAmr Mokhtar
1310f714a188SAmr Mokhtar dev_tmp = rte_bbdev_get_named_dev(name);
1311f714a188SAmr Mokhtar
1312f714a188SAmr Mokhtar TEST_ASSERT(dev == dev_tmp, "Failed test for rte_bbdev_get_named_dev: "
1313f714a188SAmr Mokhtar "wrong device was returned ");
1314f714a188SAmr Mokhtar
1315f714a188SAmr Mokhtar TEST_ASSERT_SUCCESS(rte_bbdev_release(dev),
1316f714a188SAmr Mokhtar "Failed to uninitialize bbdev driver %s ", name);
1317f714a188SAmr Mokhtar
1318f714a188SAmr Mokhtar return TEST_SUCCESS;
1319f714a188SAmr Mokhtar }
1320f714a188SAmr Mokhtar
1321f714a188SAmr Mokhtar static struct unit_test_suite bbdev_null_testsuite = {
1322f714a188SAmr Mokhtar .suite_name = "BBDEV NULL Unit Test Suite",
1323f714a188SAmr Mokhtar .setup = testsuite_setup,
1324f714a188SAmr Mokhtar .teardown = testsuite_teardown,
1325f714a188SAmr Mokhtar .unit_test_cases = {
1326f714a188SAmr Mokhtar
1327f714a188SAmr Mokhtar TEST_CASE(test_bbdev_configure_invalid_dev_id),
1328f714a188SAmr Mokhtar
1329f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1330f714a188SAmr Mokhtar test_bbdev_configure_invalid_num_queues),
1331f714a188SAmr Mokhtar
1332f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1333f714a188SAmr Mokhtar test_bbdev_configure_stop_device),
1334f714a188SAmr Mokhtar
1335f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1336f714a188SAmr Mokhtar test_bbdev_configure_stop_queue),
1337f714a188SAmr Mokhtar
1338f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1339f714a188SAmr Mokhtar test_bbdev_configure_invalid_queue_configure),
1340f714a188SAmr Mokhtar
1341f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1342f714a188SAmr Mokhtar test_bbdev_op_pool),
1343f714a188SAmr Mokhtar
1344f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1345f714a188SAmr Mokhtar test_bbdev_op_type),
1346f714a188SAmr Mokhtar
1347f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1348f714a188SAmr Mokhtar test_bbdev_op_pool_size),
1349f714a188SAmr Mokhtar
1350f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1351f714a188SAmr Mokhtar test_bbdev_stats),
1352f714a188SAmr Mokhtar
1353f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1354f714a188SAmr Mokhtar test_bbdev_driver_init),
1355f714a188SAmr Mokhtar
1356f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1357f714a188SAmr Mokhtar test_bbdev_callback),
1358f714a188SAmr Mokhtar
1359f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1360f714a188SAmr Mokhtar test_bbdev_invalid_driver),
1361f714a188SAmr Mokhtar
1362f714a188SAmr Mokhtar TEST_CASE_ST(ut_setup, ut_teardown,
1363f714a188SAmr Mokhtar test_bbdev_get_named_dev),
1364f714a188SAmr Mokhtar
1365f714a188SAmr Mokhtar TEST_CASE(test_bbdev_count),
1366f714a188SAmr Mokhtar
1367f714a188SAmr Mokhtar TEST_CASES_END() /**< NULL terminate unit test array */
1368f714a188SAmr Mokhtar }
1369f714a188SAmr Mokhtar };
1370f714a188SAmr Mokhtar
1371f714a188SAmr Mokhtar REGISTER_TEST_COMMAND(unittest, bbdev_null_testsuite);
1372