Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright (C) 2018 Intel Corporation.
3 : : * Copyright (c) 2022, 2023 NVIDIA CORPORATION & AFFILIATES.
4 : : * All rights reserved.
5 : : */
6 : :
7 : : #include "spdk_internal/cunit.h"
8 : :
9 : : #include "spdk_internal/mock.h"
10 : : #include "thread/thread_internal.h"
11 : : #include "unit/lib/json_mock.c"
12 : : #include "common/lib/ut_multithread.c"
13 : :
14 : : #include <rte_crypto.h>
15 : : #include <rte_cryptodev.h>
16 : : #include <rte_version.h>
17 : :
18 : : #define MAX_TEST_BLOCKS 8192
19 : : struct rte_crypto_op *g_test_crypto_ops[MAX_TEST_BLOCKS];
20 : : struct rte_crypto_op *g_test_dev_full_ops[MAX_TEST_BLOCKS];
21 : :
22 : : uint16_t g_dequeue_mock;
23 : : uint16_t g_enqueue_mock;
24 : : unsigned ut_rte_crypto_op_bulk_alloc;
25 : : int ut_rte_crypto_op_attach_sym_session = 0;
26 : : #define MOCK_INFO_GET_1QP_AESNI 0
27 : : #define MOCK_INFO_GET_1QP_QAT 1
28 : : #define MOCK_INFO_GET_1QP_MLX5 2
29 : : #define MOCK_INFO_GET_1QP_BOGUS_PMD 3
30 : : int ut_rte_cryptodev_info_get = 0;
31 : : bool ut_rte_cryptodev_info_get_mocked = false;
32 : :
33 : : void mock_rte_pktmbuf_free_bulk(struct rte_mbuf **m, unsigned int cnt);
34 : : #define rte_pktmbuf_free_bulk mock_rte_pktmbuf_free_bulk
35 : : void
36 : 30 : mock_rte_pktmbuf_free_bulk(struct rte_mbuf **m, unsigned int cnt)
37 : : {
38 [ + - + - : 30 : spdk_mempool_put_bulk((struct spdk_mempool *)m[0]->pool, (void **)m, cnt);
+ - + - ]
39 : 30 : }
40 : :
41 : : void mock_rte_pktmbuf_free(struct rte_mbuf *m);
42 : : #define rte_pktmbuf_free mock_rte_pktmbuf_free
43 : : void
44 : 4728 : mock_rte_pktmbuf_free(struct rte_mbuf *m)
45 : : {
46 [ + - + - ]: 4728 : spdk_mempool_put((struct spdk_mempool *)m->pool, (void *)m);
47 : 4728 : }
48 : :
49 : : void
50 : 90 : rte_mempool_free(struct rte_mempool *mp)
51 : : {
52 : 90 : spdk_mempool_free((struct spdk_mempool *)mp);
53 : 90 : }
54 : :
55 : : int mock_rte_pktmbuf_alloc_bulk(struct rte_mempool *pool, struct rte_mbuf **mbufs,
56 : : unsigned count);
57 : : #define rte_pktmbuf_alloc_bulk mock_rte_pktmbuf_alloc_bulk
58 : : int
59 : 153 : mock_rte_pktmbuf_alloc_bulk(struct rte_mempool *pool, struct rte_mbuf **mbufs,
60 : : unsigned count)
61 : : {
62 : 51 : int rc;
63 : :
64 : 153 : rc = spdk_mempool_get_bulk((struct spdk_mempool *)pool, (void **)mbufs, count);
65 [ + + ]: 153 : if (rc) {
66 : 3 : return rc;
67 : : }
68 [ + + ]: 4920 : for (unsigned i = 0; i < count; i++) {
69 [ - + - + ]: 4770 : rte_pktmbuf_reset(mbufs[i]);
70 [ - + - + : 4770 : mbufs[i]->pool = pool;
- + - + ]
71 : 1590 : }
72 : 150 : return rc;
73 : 51 : }
74 : :
75 : : struct rte_mempool *
76 : 33 : rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts,
77 : : uint32_t elt_size, uint32_t cache_size,
78 : : uint16_t priv_size, int socket_id)
79 : : {
80 : 11 : struct spdk_mempool *tmp;
81 : :
82 : 44 : tmp = spdk_mempool_create(name, nb_elts, elt_size + priv_size,
83 : 11 : cache_size, socket_id);
84 : :
85 : 44 : return (struct rte_mempool *)tmp;
86 : :
87 : 11 : }
88 : :
89 : : struct rte_mempool *
90 : 33 : rte_pktmbuf_pool_create(const char *name, unsigned n, unsigned cache_size,
91 : : uint16_t priv_size, uint16_t data_room_size, int socket_id)
92 : : {
93 : 11 : struct spdk_mempool *tmp;
94 : :
95 : 44 : tmp = spdk_mempool_create(name, n, sizeof(struct rte_mbuf) + priv_size,
96 : 11 : cache_size, socket_id);
97 : :
98 : 44 : return (struct rte_mempool *)tmp;
99 : 11 : }
100 : :
101 : : struct rte_mempool *
102 : 0 : rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
103 : : unsigned cache_size, unsigned private_data_size,
104 : : rte_mempool_ctor_t *mp_init, void *mp_init_arg,
105 : : rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
106 : : int socket_id, unsigned flags)
107 : : {
108 : 0 : struct spdk_mempool *tmp;
109 : :
110 : 0 : tmp = spdk_mempool_create(name, n, elt_size + private_data_size,
111 : 0 : cache_size, socket_id);
112 : :
113 : 0 : return (struct rte_mempool *)tmp;
114 : 0 : }
115 : :
116 : : DEFINE_RETURN_MOCK(rte_crypto_op_pool_create, struct rte_mempool *);
117 : : struct rte_mempool *
118 : 30 : rte_crypto_op_pool_create(const char *name, enum rte_crypto_op_type type,
119 : : unsigned nb_elts, unsigned cache_size,
120 : : uint16_t priv_size, int socket_id)
121 : : {
122 : 10 : struct spdk_mempool *tmp;
123 : :
124 [ + + + + ]: 30 : HANDLE_RETURN_MOCK(rte_crypto_op_pool_create);
125 : :
126 : 36 : tmp = spdk_mempool_create(name, nb_elts,
127 : 9 : sizeof(struct rte_crypto_op) + priv_size,
128 : 9 : cache_size, socket_id);
129 : :
130 : 27 : return (struct rte_mempool *)tmp;
131 : :
132 : 10 : }
133 : :
134 : : /* Those functions are defined as static inline in DPDK, so we can't
135 : : * mock them straight away. We use defines to redirect them into
136 : : * our custom functions.
137 : : */
138 : : static bool g_resubmit_test = false;
139 : : #define rte_cryptodev_enqueue_burst mock_rte_cryptodev_enqueue_burst
140 : : static inline uint16_t
141 : 78 : mock_rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
142 : : struct rte_crypto_op **ops, uint16_t nb_ops)
143 : : {
144 : 26 : int i;
145 : :
146 : 78 : CU_ASSERT(nb_ops > 0);
147 : :
148 [ + + + - ]: 3249 : for (i = 0; i < nb_ops; i++) {
149 : : /* Use this empty (til now) array of pointers to store
150 : : * enqueued operations for assertion in dev_full test.
151 : : */
152 [ + - + - : 3171 : g_test_dev_full_ops[i] = *ops++;
+ - + - +
- ]
153 [ + + + + ]: 3171 : if (g_resubmit_test == true) {
154 [ # # # # : 0 : CU_ASSERT(g_test_dev_full_ops[i] == (void *)0xDEADBEEF);
# # ]
155 : 0 : }
156 : 1057 : }
157 : :
158 : 104 : return g_enqueue_mock;
159 : 26 : }
160 : :
161 : : #define rte_cryptodev_dequeue_burst mock_rte_cryptodev_dequeue_burst
162 : : static inline uint16_t
163 : 15 : mock_rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
164 : : struct rte_crypto_op **ops, uint16_t nb_ops)
165 : : {
166 : 5 : int i;
167 : :
168 : 15 : CU_ASSERT(nb_ops > 0);
169 : :
170 [ + + - + ]: 27 : for (i = 0; i < g_dequeue_mock; i++) {
171 [ - + - + : 12 : *ops++ = g_test_crypto_ops[i];
- + - + -
+ ]
172 : 4 : }
173 : :
174 : 20 : return g_dequeue_mock;
175 : 5 : }
176 : :
177 : : /* Instead of allocating real memory, assign the allocations to our
178 : : * test array for assertion in tests.
179 : : */
180 : : #define rte_crypto_op_bulk_alloc mock_rte_crypto_op_bulk_alloc
181 : : static inline unsigned
182 : 81 : mock_rte_crypto_op_bulk_alloc(struct rte_mempool *mempool,
183 : : enum rte_crypto_op_type type,
184 : : struct rte_crypto_op **ops, uint16_t nb_ops)
185 : : {
186 : 27 : int i;
187 : :
188 [ + + - + ]: 3255 : for (i = 0; i < nb_ops; i++) {
189 [ - + - + : 3174 : *ops++ = g_test_crypto_ops[i];
- + - + -
+ ]
190 : 1058 : }
191 : 108 : return ut_rte_crypto_op_bulk_alloc;
192 : 27 : }
193 : :
194 : : #define rte_mempool_put_bulk mock_rte_mempool_put_bulk
195 : : static __rte_always_inline void
196 : 10 : mock_rte_mempool_put_bulk(struct rte_mempool *mp, void *const *obj_table,
197 : : unsigned int n)
198 : : {
199 : 30 : return;
200 : : }
201 : : #define rte_crypto_op_attach_sym_session mock_rte_crypto_op_attach_sym_session
202 : : #if RTE_VERSION >= RTE_VERSION_NUM(22, 11, 0, 0)
203 : : static inline int
204 : 3171 : mock_rte_crypto_op_attach_sym_session(struct rte_crypto_op *op, void *sess)
205 : : #else
206 : : static inline int
207 : : mock_rte_crypto_op_attach_sym_session(struct rte_crypto_op *op,
208 : : struct rte_cryptodev_sym_session *sess)
209 : : #endif
210 : : {
211 : 3171 : return ut_rte_crypto_op_attach_sym_session;
212 : : }
213 : :
214 : : #define rte_lcore_count mock_rte_lcore_count
215 : : static inline unsigned
216 : 36 : mock_rte_lcore_count(void)
217 : : {
218 : 36 : return 1;
219 : : }
220 : :
221 : : #include "accel/dpdk_cryptodev/accel_dpdk_cryptodev.c"
222 : :
223 : : /* accel stubs */
224 : 9 : DEFINE_STUB_V(spdk_accel_task_complete, (struct spdk_accel_task *task, int status));
225 : 0 : DEFINE_STUB_V(spdk_accel_module_finish, (void));
226 : 0 : DEFINE_STUB_V(spdk_accel_module_list_add, (struct spdk_accel_module_if *accel_module));
227 : :
228 : : /* DPDK stubs */
229 : : #define DPDK_DYNFIELD_OFFSET offsetof(struct rte_mbuf, dynfield1[1])
230 : 33 : DEFINE_STUB(rte_mbuf_dynfield_register, int, (const struct rte_mbuf_dynfield *params),
231 : : DPDK_DYNFIELD_OFFSET);
232 : 36 : DEFINE_STUB(rte_cryptodev_count, uint8_t, (void), 0);
233 : 30 : DEFINE_STUB(rte_socket_id, unsigned, (void), 0);
234 : 36 : DEFINE_STUB(rte_cryptodev_device_count_by_driver, uint8_t, (uint8_t driver_id), 0);
235 : 33 : DEFINE_STUB(rte_cryptodev_configure, int, (uint8_t dev_id, struct rte_cryptodev_config *config), 0);
236 : 30 : DEFINE_STUB(rte_cryptodev_queue_pair_setup, int, (uint8_t dev_id, uint16_t queue_pair_id,
237 : : const struct rte_cryptodev_qp_conf *qp_conf, int socket_id), 0);
238 : 27 : DEFINE_STUB(rte_cryptodev_start, int, (uint8_t dev_id), 0);
239 : 24 : DEFINE_STUB_V(rte_cryptodev_stop, (uint8_t dev_id));
240 : 30 : DEFINE_STUB(rte_cryptodev_close, int, (uint8_t dev_id), 0);
241 : 36 : DEFINE_STUB(rte_vdev_init, int, (const char *name, const char *args), 0);
242 : 0 : DEFINE_STUB(rte_vdev_uninit, int, (const char *name), 0);
243 : :
244 : : #if RTE_VERSION >= RTE_VERSION_NUM(22, 11, 0, 0)
245 : 0 : DEFINE_STUB(rte_cryptodev_sym_session_create, void *,
246 : : (uint8_t dev_id, struct rte_crypto_sym_xform *xforms, struct rte_mempool *mempool), (void *)1);
247 : 0 : DEFINE_STUB(rte_cryptodev_sym_session_free, int, (uint8_t dev_id, void *sess), 0);
248 : : #else
249 : : DEFINE_STUB(rte_cryptodev_sym_session_create, struct rte_cryptodev_sym_session *,
250 : : (struct rte_mempool *mempool), (void *)1);
251 : : DEFINE_STUB(rte_cryptodev_sym_session_init, int, (uint8_t dev_id,
252 : : struct rte_cryptodev_sym_session *sess,
253 : : struct rte_crypto_sym_xform *xforms, struct rte_mempool *mempool), 0);
254 : : DEFINE_STUB(rte_cryptodev_sym_session_free, int, (struct rte_cryptodev_sym_session *sess), 0);
255 : : #endif
256 : :
257 : : struct rte_cryptodev *rte_cryptodevs;
258 : :
259 : : /* global vars and setup/cleanup functions used for all test functions */
260 : : struct spdk_io_channel *g_io_ch;
261 : : struct accel_dpdk_cryptodev_io_channel *g_crypto_ch;
262 : : struct accel_dpdk_cryptodev_device g_aesni_crypto_dev;
263 : : struct accel_dpdk_cryptodev_qp g_aesni_qp;
264 : : struct accel_dpdk_cryptodev_key_handle g_key_handle;
265 : : struct accel_dpdk_cryptodev_key_priv g_key_priv;
266 : : struct spdk_accel_crypto_key g_key;
267 : :
268 : : void
269 : 39 : rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info)
270 : : {
271 [ + - + - ]: 39 : dev_info->max_nb_queue_pairs = 1;
272 [ + + ]: 39 : if (ut_rte_cryptodev_info_get == MOCK_INFO_GET_1QP_AESNI) {
273 [ + - + - : 18 : dev_info->driver_name = g_driver_names[0];
+ - + - ]
274 [ + + ]: 27 : } else if (ut_rte_cryptodev_info_get == MOCK_INFO_GET_1QP_QAT) {
275 [ + - + - : 12 : dev_info->driver_name = g_driver_names[1];
+ - + - +
- ]
276 [ + + ]: 13 : } else if (ut_rte_cryptodev_info_get == MOCK_INFO_GET_1QP_MLX5) {
277 [ + - + - : 6 : dev_info->driver_name = g_driver_names[2];
+ - + - +
- ]
278 [ + + ]: 5 : } else if (ut_rte_cryptodev_info_get == MOCK_INFO_GET_1QP_BOGUS_PMD) {
279 [ + - + - ]: 3 : dev_info->driver_name = "junk";
280 : 1 : }
281 : 39 : }
282 : :
283 : : unsigned int
284 : 66 : rte_cryptodev_sym_get_private_session_size(uint8_t dev_id)
285 : : {
286 : 66 : return (unsigned int)dev_id;
287 : : }
288 : :
289 : : /* Global setup for all tests that share a bunch of preparation... */
290 : : static int
291 : 3 : test_setup(void)
292 : : {
293 : 1 : int i, rc;
294 : :
295 : : /* Prepare essential variables for test routines */
296 : 3 : g_io_ch = calloc(1, sizeof(*g_io_ch) + sizeof(struct accel_dpdk_cryptodev_io_channel));
297 : 3 : g_crypto_ch = (struct accel_dpdk_cryptodev_io_channel *)spdk_io_channel_get_ctx(g_io_ch);
298 [ + - + - : 3 : TAILQ_INIT(&g_crypto_ch->queued_tasks);
+ - + - +
- + - + -
+ - ]
299 [ + - + - : 3 : TAILQ_INIT(&g_crypto_ch->completed_tasks);
+ - + - +
- + - + -
+ - ]
300 : :
301 : 3 : g_aesni_crypto_dev.type = ACCEL_DPDK_CRYPTODEV_DRIVER_AESNI_MB;
302 [ + - ]: 3 : g_aesni_crypto_dev.qp_desc_nr = ACCEL_DPDK_CRYPTODEV_QP_DESCRIPTORS;
303 [ + - + - : 3 : TAILQ_INIT(&g_aesni_crypto_dev.qpairs);
+ - + - +
- ]
304 : :
305 : 3 : g_aesni_qp.device = &g_aesni_crypto_dev;
306 [ + - + - : 3 : g_crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_AESNI_MB] = &g_aesni_qp;
+ - + - ]
307 : :
308 : 3 : g_key_handle.device = &g_aesni_crypto_dev;
309 : 3 : g_key_priv.driver = ACCEL_DPDK_CRYPTODEV_DRIVER_AESNI_MB;
310 [ + - ]: 3 : g_key_priv.cipher = SPDK_ACCEL_CIPHER_AES_CBC;
311 [ + - + - : 3 : TAILQ_INIT(&g_key_priv.dev_keys);
+ - + - +
- ]
312 [ + - + - : 3 : TAILQ_INSERT_TAIL(&g_key_priv.dev_keys, &g_key_handle, link);
+ - + - +
- + - + -
+ - + - +
- + - +
- ]
313 : 3 : g_key.priv = &g_key_priv;
314 [ + - ]: 3 : g_key.module_if = &g_accel_dpdk_cryptodev_module;
315 : :
316 : :
317 : : /* Allocate a real mbuf pool so we can test error paths */
318 : 3 : g_mbuf_mp = rte_pktmbuf_pool_create("mbuf_mp", ACCEL_DPDK_CRYPTODEV_NUM_MBUFS,
319 : : (unsigned)SPDK_MEMPOOL_DEFAULT_CACHE_SIZE,
320 : : 0, 0, SPDK_ENV_SOCKET_ID_ANY);
321 : : /* Instead of allocating real rte mempools for these, it's easier and provides the
322 : : * same coverage just calloc them here.
323 : : */
324 [ + + + - ]: 24579 : for (i = 0; i < MAX_TEST_BLOCKS; i++) {
325 : 24576 : size_t size = ACCEL_DPDK_CRYPTODEV_IV_OFFSET + ACCEL_DPDK_CRYPTODEV_IV_LENGTH;
326 [ + + + - : 24576 : rc = posix_memalign((void **)&g_test_crypto_ops[i], 64, size);
+ - ]
327 [ + + ]: 24576 : if (rc != 0) {
328 [ # # ]: 0 : assert(false);
329 : : }
330 [ + + + - : 24576 : memset(g_test_crypto_ops[i], 0, ACCEL_DPDK_CRYPTODEV_IV_OFFSET);
+ - + - ]
331 : 8192 : }
332 : 3 : g_mbuf_offset = DPDK_DYNFIELD_OFFSET;
333 : :
334 : 3 : return 0;
335 : 1 : }
336 : :
337 : : /* Global teardown for all tests */
338 : : static int
339 : 3 : test_cleanup(void)
340 : : {
341 : 1 : int i;
342 : :
343 [ + + ]: 3 : if (g_crypto_op_mp) {
344 : 0 : rte_mempool_free(g_crypto_op_mp);
345 : 0 : g_crypto_op_mp = NULL;
346 : 0 : }
347 [ + + ]: 3 : if (g_mbuf_mp) {
348 : 3 : rte_mempool_free(g_mbuf_mp);
349 : 3 : g_mbuf_mp = NULL;
350 : 1 : }
351 [ + + ]: 3 : if (g_session_mp) {
352 : 0 : rte_mempool_free(g_session_mp);
353 : 0 : g_session_mp = NULL;
354 : 0 : }
355 [ + + ]: 3 : if (g_session_mp_priv != NULL) {
356 : : /* g_session_mp_priv may or may not be set depending on the DPDK version */
357 : 0 : rte_mempool_free(g_session_mp_priv);
358 : 0 : g_session_mp_priv = NULL;
359 : 0 : }
360 : :
361 [ + + - + ]: 24579 : for (i = 0; i < MAX_TEST_BLOCKS; i++) {
362 [ - + - + : 24576 : free(g_test_crypto_ops[i]);
- + ]
363 : 8192 : }
364 : 3 : free(g_io_ch);
365 : 3 : return 0;
366 : 1 : }
367 : :
368 : : static void
369 : 3 : test_error_paths(void)
370 : : {
371 : : /* Single element block size encrypt, just to test error paths
372 : : * in accel_dpdk_cryptodev_submit_tasks() */
373 : 3 : struct iovec src_iov = {.iov_base = (void *)0xDEADBEEF, .iov_len = 512 };
374 : 3 : struct iovec dst_iov = src_iov;
375 : 3 : struct accel_dpdk_cryptodev_task task = {};
376 : 3 : struct accel_dpdk_cryptodev_key_priv key_priv = {};
377 : 3 : struct spdk_accel_crypto_key key = {};
378 : 1 : int rc;
379 : :
380 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_ENCRYPT;
381 [ + - + - : 3 : task.base.s.iovcnt = 1;
+ - ]
382 [ + - + - : 3 : task.base.s.iovs = &src_iov;
+ - ]
383 [ + - + - : 3 : task.base.d.iovcnt = 1;
+ - ]
384 [ + - + - : 3 : task.base.d.iovs = &dst_iov;
+ - ]
385 [ + - + - ]: 3 : task.base.block_size = 512;
386 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
387 [ + - ]: 3 : task.base.iv = 1;
388 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc = 1;
389 : :
390 : : /* case 1 - no crypto key */
391 [ + - + - ]: 3 : task.base.crypto_key = NULL;
392 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
393 : 3 : CU_ASSERT(rc == -EINVAL);
394 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
395 : :
396 : : /* case 2 - crypto key with wrong module_if */
397 : 3 : key_priv.driver = ACCEL_DPDK_CRYPTODEV_DRIVER_AESNI_MB;
398 [ + - ]: 3 : key_priv.cipher = SPDK_ACCEL_CIPHER_AES_CBC;
399 [ + - + - : 3 : TAILQ_INIT(&key_priv.dev_keys);
+ - + - +
- ]
400 : 3 : key.priv = &key_priv;
401 [ + - ]: 3 : key.module_if = (struct spdk_accel_module_if *) 0x1;
402 [ + - + - ]: 3 : task.base.crypto_key = &key;
403 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
404 : 3 : CU_ASSERT(rc == -EINVAL);
405 [ + - ]: 3 : key.module_if = &g_accel_dpdk_cryptodev_module;
406 : :
407 : : /* case 3 - no key handle in the channel */
408 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
409 : 3 : CU_ASSERT(rc == -EINVAL);
410 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
411 : :
412 : : /* case 4 - invalid op */
413 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_COMPARE;
414 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
415 : 3 : CU_ASSERT(rc == -EINVAL);
416 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_ENCRYPT;
417 : :
418 : : /* case 5 - no entries in g_mbuf_mp */
419 : 3 : MOCK_SET(spdk_mempool_get, NULL);
420 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->queued_tasks) == true);
+ - ]
421 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
422 : 3 : CU_ASSERT(rc == 0);
423 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->queued_tasks) == false);
+ - ]
424 [ + - + - : 3 : CU_ASSERT(TAILQ_FIRST(&g_crypto_ch->queued_tasks) == &task);
+ - ]
425 : 3 : MOCK_CLEAR(spdk_mempool_get);
426 [ + - + - : 3 : TAILQ_INIT(&g_crypto_ch->queued_tasks);
+ - + - +
- + - + -
+ - ]
427 : :
428 : : /* case 6 - vtophys error in accel_dpdk_cryptodev_mbuf_attach_buf */
429 : 3 : MOCK_SET(spdk_vtophys, SPDK_VTOPHYS_ERROR);
430 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
431 : 3 : CU_ASSERT(rc == -EFAULT);
432 : 3 : MOCK_CLEAR(spdk_vtophys);
433 : 3 : }
434 : :
435 : : static void
436 : 3 : test_simple_encrypt(void)
437 : : {
438 : 3 : struct iovec src_iov[4] = {[0] = {.iov_base = (void *)0xDEADBEEF, .iov_len = 512 }};
439 [ + - + - ]: 3 : struct iovec dst_iov = src_iov[0];
440 : 3 : struct accel_dpdk_cryptodev_task task = {};
441 : 1 : struct rte_mbuf *mbuf, *next;
442 : 1 : int rc, i;
443 : :
444 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_ENCRYPT;
445 [ + - + - : 3 : task.base.s.iovcnt = 1;
+ - ]
446 [ + - + - : 3 : task.base.s.iovs = src_iov;
+ - ]
447 [ + - + - : 3 : task.base.d.iovcnt = 1;
+ - ]
448 [ + - + - : 3 : task.base.d.iovs = &dst_iov;
+ - ]
449 [ + - + - ]: 3 : task.base.block_size = 512;
450 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
451 [ + - ]: 3 : task.base.iv = 1;
452 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc = 1;
453 : :
454 : : /* Inplace encryption */
455 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
456 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
457 : 3 : CU_ASSERT(rc == 0);
458 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
459 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->buf_addr == src_iov[0].iov_base);
+ - + - +
- + - + -
+ - + - +
- ]
460 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->data_len == src_iov[0].iov_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
461 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - ]
462 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == 512);
+ - + - +
- + - + -
+ - + - +
- ]
463 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
464 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
465 : : uint64_t *) == (uint64_t)&task);
466 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst == NULL);
+ - + - +
- + - ]
467 : :
468 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
469 : :
470 : : /* out-of-place encryption */
471 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
472 [ + - ]: 3 : task.cryop_submitted = 0;
473 : 3 : dst_iov.iov_base = (void *)0xFEEDBEEF;
474 : :
475 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
476 : 3 : CU_ASSERT(rc == 0);
477 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
478 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->buf_addr == src_iov[0].iov_base);
+ - + - +
- + - + -
+ - + - +
- ]
479 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->data_len == src_iov[0].iov_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
480 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - ]
481 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == 512);
+ - + - +
- + - + -
+ - + - +
- ]
482 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
483 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
484 : : uint64_t *) == (uint64_t)&task);
485 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->buf_addr == dst_iov.iov_base);
+ - + - +
- + - + -
+ - ]
486 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->data_len == dst_iov.iov_len);
+ - + - +
- + - + -
+ - + - ]
487 : :
488 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
489 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_dst);
+ - + - +
- + - ]
490 : :
491 : : /* out-of-place encryption, fragmented payload */
492 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
493 [ + - + - : 3 : task.base.s.iovcnt = 4;
+ - ]
494 [ + + + - ]: 15 : for (i = 0; i < 4; i++) {
495 [ + - + - : 12 : src_iov[i].iov_base = (void *)0xDEADBEEF + i * 128;
+ - + - +
- ]
496 [ + - + - : 12 : src_iov[i].iov_len = 128;
+ - + - ]
497 : 4 : }
498 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
499 : 3 : CU_ASSERT(rc == 0);
500 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
501 [ + - + - : 3 : mbuf = g_test_crypto_ops[0]->sym->m_src;
+ - + - +
- + - ]
502 [ + + # # ]: 3 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
503 [ + - + - : 3 : CU_ASSERT(mbuf->buf_addr == src_iov[0].iov_base);
+ - + - ]
504 [ + - + - : 3 : CU_ASSERT(mbuf->data_len == src_iov[0].iov_len);
+ - + - +
- ]
505 [ + - + - ]: 3 : mbuf = mbuf->next;
506 [ + + + - ]: 12 : for (i = 1; i < 4; i++) {
507 [ + + # # ]: 9 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
508 [ + - + - : 9 : CU_ASSERT(mbuf->buf_addr == src_iov[i].iov_base);
+ - + - +
- + - ]
509 [ + - + - : 9 : CU_ASSERT(mbuf->data_len == src_iov[i].iov_len);
+ - + - +
- + - ]
510 [ + - + - ]: 9 : next = mbuf->next;
511 : 9 : rte_pktmbuf_free(mbuf);
512 : 9 : mbuf = next;
513 : 3 : }
514 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == 512);
+ - + - +
- + - + -
+ - + - +
- ]
515 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
516 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
517 : : uint64_t *) == (uint64_t)&task);
518 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->buf_addr == dst_iov.iov_base);
+ - + - +
- + - + -
+ - ]
519 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->data_len == dst_iov.iov_len);
+ - + - +
- + - + -
+ - + - ]
520 : :
521 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
522 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_dst);
+ - + - +
- + - ]
523 : :
524 : : /* Big logical block size, inplace encryption */
525 [ + - + - : 3 : src_iov[0].iov_len = ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN * 4;
+ - ]
526 [ + - + - ]: 3 : dst_iov = src_iov[0];
527 [ + - + - ]: 3 : task.base.block_size = ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN * 4;
528 [ + - + - : 3 : task.base.s.iovcnt = 1;
+ - ]
529 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc = 1;
530 : :
531 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
532 : 3 : CU_ASSERT(rc == 0);
533 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
534 [ + - + - : 3 : mbuf = g_test_crypto_ops[0]->sym->m_src;
+ - + - +
- + - ]
535 [ + + # # ]: 3 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
536 [ + - + - : 3 : CU_ASSERT(mbuf->buf_addr == src_iov[0].iov_base);
+ - + - ]
537 [ + - + - ]: 3 : CU_ASSERT(mbuf->data_len == ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN);
538 [ + - + - ]: 3 : mbuf = mbuf->next;
539 [ + + + - ]: 12 : for (i = 1; i < 4; i++) {
540 [ + + # # ]: 9 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
541 [ + - + - : 9 : CU_ASSERT(mbuf->buf_addr == (char *)src_iov[0].iov_base + i * ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN);
+ - + - +
- + - ]
542 [ + - + - ]: 9 : CU_ASSERT(mbuf->data_len == ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN);
543 [ + - + - ]: 9 : next = mbuf->next;
544 : 9 : rte_pktmbuf_free(mbuf);
545 : 9 : mbuf = next;
546 : 3 : }
547 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN * 4);
+ - + - +
- + - + -
+ - + - +
- ]
548 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
549 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
550 : : uint64_t *) == (uint64_t)&task);
551 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst == NULL);
+ - + - +
- + - ]
552 : :
553 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
554 : 3 : }
555 : :
556 : : static void
557 : 3 : test_simple_decrypt(void)
558 : : {
559 : 3 : struct iovec src_iov[4] = {[0] = {.iov_base = (void *)0xDEADBEEF, .iov_len = 512 }};
560 [ + - + - ]: 3 : struct iovec dst_iov = src_iov[0];
561 : 3 : struct accel_dpdk_cryptodev_task task = {};
562 : 1 : struct rte_mbuf *mbuf, *next;
563 : 1 : int rc, i;
564 : :
565 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_DECRYPT;
566 [ + - + - : 3 : task.base.s.iovcnt = 1;
+ - ]
567 [ + - + - : 3 : task.base.s.iovs = src_iov;
+ - ]
568 [ + - + - : 3 : task.base.d.iovcnt = 1;
+ - ]
569 [ + - + - : 3 : task.base.d.iovs = &dst_iov;
+ - ]
570 [ + - + - ]: 3 : task.base.block_size = 512;
571 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
572 [ + - ]: 3 : task.base.iv = 1;
573 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc = 1;
574 : :
575 : : /* Inplace decryption */
576 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
577 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
578 : 3 : CU_ASSERT(rc == 0);
579 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
580 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->buf_addr == src_iov[0].iov_base);
+ - + - +
- + - + -
+ - + - +
- ]
581 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->data_len == src_iov[0].iov_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
582 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - ]
583 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == 512);
+ - + - +
- + - + -
+ - + - +
- ]
584 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
585 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
586 : : uint64_t *) == (uint64_t)&task);
587 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst == NULL);
+ - + - +
- + - ]
588 : :
589 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
590 : :
591 : : /* out-of-place decryption */
592 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
593 [ + - ]: 3 : task.cryop_submitted = 0;
594 : 3 : dst_iov.iov_base = (void *)0xFEEDBEEF;
595 : :
596 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
597 : 3 : CU_ASSERT(rc == 0);
598 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
599 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->buf_addr == src_iov[0].iov_base);
+ - + - +
- + - + -
+ - + - +
- ]
600 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->data_len == src_iov[0].iov_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
601 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - ]
602 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == 512);
+ - + - +
- + - + -
+ - + - +
- ]
603 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
604 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
605 : : uint64_t *) == (uint64_t)&task);
606 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->buf_addr == dst_iov.iov_base);
+ - + - +
- + - + -
+ - ]
607 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->data_len == dst_iov.iov_len);
+ - + - +
- + - + -
+ - + - ]
608 : :
609 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
610 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_dst);
+ - + - +
- + - ]
611 : :
612 : : /* out-of-place decryption, fragmented payload */
613 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
614 [ + - + - : 3 : task.base.s.iovcnt = 4;
+ - ]
615 [ + + + - ]: 15 : for (i = 0; i < 4; i++) {
616 [ + - + - : 12 : src_iov[i].iov_base = (void *)0xDEADBEEF + i * 128;
+ - + - +
- ]
617 [ + - + - : 12 : src_iov[i].iov_len = 128;
+ - + - ]
618 : 4 : }
619 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
620 : 3 : CU_ASSERT(rc == 0);
621 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
622 [ + - + - : 3 : mbuf = g_test_crypto_ops[0]->sym->m_src;
+ - + - +
- + - ]
623 [ + + # # ]: 3 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
624 [ + - + - : 3 : CU_ASSERT(mbuf->buf_addr == src_iov[0].iov_base);
+ - + - ]
625 [ + - + - : 3 : CU_ASSERT(mbuf->data_len == src_iov[0].iov_len);
+ - + - +
- ]
626 [ + - + - ]: 3 : mbuf = mbuf->next;
627 [ + + + - ]: 12 : for (i = 1; i < 4; i++) {
628 [ + + # # ]: 9 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
629 [ + - + - : 9 : CU_ASSERT(mbuf->buf_addr == src_iov[i].iov_base);
+ - + - +
- + - ]
630 [ + - + - : 9 : CU_ASSERT(mbuf->data_len == src_iov[i].iov_len);
+ - + - +
- + - ]
631 [ + - + - ]: 9 : next = mbuf->next;
632 : 9 : rte_pktmbuf_free(mbuf);
633 : 9 : mbuf = next;
634 : 3 : }
635 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == 512);
+ - + - +
- + - + -
+ - + - +
- ]
636 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
637 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
638 : : uint64_t *) == (uint64_t)&task);
639 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->buf_addr == dst_iov.iov_base);
+ - + - +
- + - + -
+ - ]
640 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst->data_len == dst_iov.iov_len);
+ - + - +
- + - + -
+ - + - ]
641 : :
642 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
643 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_dst);
+ - + - +
- + - ]
644 : :
645 : : /* Big logical block size, inplace encryption */
646 [ + - + - : 3 : src_iov[0].iov_len = ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN * 4;
+ - ]
647 [ + - + - ]: 3 : dst_iov = src_iov[0];
648 [ + - + - ]: 3 : task.base.block_size = ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN * 4;
649 [ + - + - : 3 : task.base.s.iovcnt = 1;
+ - ]
650 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc = 1;
651 : :
652 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
653 : 3 : CU_ASSERT(rc == 0);
654 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
655 [ + - + - : 3 : mbuf = g_test_crypto_ops[0]->sym->m_src;
+ - + - +
- + - ]
656 [ + + # # ]: 3 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
657 [ + - + - : 3 : CU_ASSERT(mbuf->buf_addr == src_iov[0].iov_base);
+ - + - ]
658 [ + - + - ]: 3 : CU_ASSERT(mbuf->data_len == ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN);
659 [ + - + - ]: 3 : mbuf = mbuf->next;
660 [ + + + - ]: 12 : for (i = 1; i < 4; i++) {
661 [ + + # # ]: 9 : SPDK_CU_ASSERT_FATAL(mbuf != NULL);
662 [ + - + - : 9 : CU_ASSERT(mbuf->buf_addr == (char *)src_iov[0].iov_base + i * ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN);
+ - + - +
- + - ]
663 [ + - + - ]: 9 : CU_ASSERT(mbuf->data_len == ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN);
664 [ + - + - ]: 9 : next = mbuf->next;
665 : 9 : rte_pktmbuf_free(mbuf);
666 : 9 : mbuf = next;
667 : 3 : }
668 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == ACCEL_DPDK_CRYPTODEV_MAX_MBUF_LEN * 4);
+ - + - +
- + - + -
+ - + - +
- ]
669 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
670 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
671 : : uint64_t *) == (uint64_t)&task);
672 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst == NULL);
+ - + - +
- + - ]
673 : :
674 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
675 : 3 : }
676 : :
677 : : static void
678 : 3 : test_large_enc_dec(void)
679 : : {
680 : 3 : struct accel_dpdk_cryptodev_task task = {};
681 : 3 : uint32_t block_len = 512;
682 : 3 : uint32_t num_blocks = ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE * 2;
683 [ + - ]: 3 : uint32_t iov_len = num_blocks * block_len / 16;
684 [ + - ]: 3 : uint32_t blocks_in_iov = num_blocks / 16;
685 : 1 : uint32_t iov_idx;
686 : 2 : struct iovec src_iov[16];
687 : 2 : struct iovec dst_iov[16];
688 : 1 : uint32_t i;
689 : 1 : int rc;
690 : :
691 [ + + ]: 51 : for (i = 0; i < 16; i++) {
692 [ + - + - : 48 : src_iov[i].iov_base = (void *)0xDEADBEEF + i * iov_len;
+ - + - ]
693 [ + - + - : 48 : src_iov[i].iov_len = iov_len;
+ - + - ]
694 : :
695 [ + - + - : 48 : dst_iov[i].iov_base = (void *)0xDEADBEEF + i * iov_len;
+ - + - ]
696 [ + - + - : 48 : dst_iov[i].iov_len = iov_len;
+ - + - ]
697 : 16 : }
698 : :
699 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_DECRYPT;
700 [ + - + - : 3 : task.base.s.iovcnt = 16;
+ - ]
701 [ + - + - : 3 : task.base.s.iovs = src_iov;
+ - ]
702 [ + - + - : 3 : task.base.d.iovcnt = 16;
+ - ]
703 [ + - + - : 3 : task.base.d.iovs = dst_iov;
+ - ]
704 [ + - + - ]: 3 : task.base.block_size = 512;
705 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
706 [ + - ]: 3 : task.base.iv = 1;
707 : :
708 : : /* Test 1. Multi block size decryption, multi-element, inplace */
709 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
710 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc =
711 : : ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE;
712 : :
713 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
714 : 3 : CU_ASSERT(rc == 0);
715 [ + + ]: 3 : CU_ASSERT(task.inplace == true);
716 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE);
717 [ + - ]: 3 : CU_ASSERT(task.cryop_total == num_blocks);
718 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 0);
719 : :
720 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
721 [ + + ]: 384 : iov_idx = i / blocks_in_iov;
722 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
723 : : i % blocks_in_iov) * block_len));
724 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
725 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
726 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
727 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
728 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
729 : : uint64_t *) == (uint64_t)&task);
730 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst == NULL);
+ - + - +
- + - +
- ]
731 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
732 : 128 : }
733 : :
734 : : /* Call accel_dpdk_cryptodev_process_task like it was called by completion poller */
735 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
736 [ + - + - ]: 3 : task.cryop_completed = task.cryop_submitted;
737 : 3 : rc = accel_dpdk_cryptodev_process_task(g_crypto_ch, &task);
738 : :
739 : 3 : CU_ASSERT(rc == 0);
740 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE * 2);
741 [ + - + - ]: 3 : CU_ASSERT(task.cryop_total == task.cryop_submitted);
742 : :
743 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
744 [ + + ]: 384 : iov_idx = i / blocks_in_iov + 8;
745 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
746 : : i % blocks_in_iov) * block_len));
747 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
748 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
749 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
750 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
751 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
752 : : uint64_t *) == (uint64_t)&task);
753 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst == NULL);
+ - + - +
- + - +
- ]
754 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
755 : 128 : }
756 : :
757 : : /* Test 2. Multi block size decryption, multi-element, out-of-place */
758 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
759 : : /* Modify dst to make payload out-of-place */
760 [ + - + - ]: 3 : dst_iov[0].iov_base -= 1;
761 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc =
762 : : ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE;
763 : :
764 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
765 : 3 : CU_ASSERT(rc == 0);
766 [ + + ]: 3 : CU_ASSERT(task.inplace == false);
767 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE);
768 [ + - ]: 3 : CU_ASSERT(task.cryop_total == num_blocks);
769 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 0);
770 : :
771 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
772 [ + + ]: 384 : iov_idx = i / blocks_in_iov;
773 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
774 : : i % blocks_in_iov) * block_len));
775 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
776 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
777 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
778 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
779 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
780 : : uint64_t *) == (uint64_t)&task);
781 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->buf_addr == dst_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
782 : : i % blocks_in_iov) * block_len));
783 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
784 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->next == NULL);
+ - + - +
- + - + -
+ - + - ]
785 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
786 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_dst);
+ - + - +
- + - +
- ]
787 : 128 : }
788 : :
789 : : /* Call accel_dpdk_cryptodev_process_task like it was called by completion poller */
790 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
791 [ + - + - ]: 3 : task.cryop_completed = task.cryop_submitted;
792 : 3 : rc = accel_dpdk_cryptodev_process_task(g_crypto_ch, &task);
793 : :
794 : 3 : CU_ASSERT(rc == 0);
795 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE * 2);
796 [ + - + - ]: 3 : CU_ASSERT(task.cryop_total == task.cryop_submitted);
797 : :
798 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
799 [ + + ]: 384 : iov_idx = i / blocks_in_iov + 8;
800 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
801 : : i % blocks_in_iov) * block_len));
802 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
803 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
804 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
805 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
806 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
807 : : uint64_t *) == (uint64_t)&task);
808 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->buf_addr == dst_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
809 : : i % blocks_in_iov) * block_len));
810 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
811 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->next == NULL);
+ - + - +
- + - + -
+ - + - ]
812 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
813 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_dst);
+ - + - +
- + - +
- ]
814 : 128 : }
815 : :
816 : : /* Test 3. Multi block size encryption, multi-element, inplace */
817 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
818 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_ENCRYPT;
819 [ + - ]: 3 : task.cryop_submitted = 0;
820 : : /* Modify dst to make payload iplace */
821 [ + - + - ]: 3 : dst_iov[0].iov_base += 1;
822 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc =
823 : : ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE;
824 : :
825 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
826 : 3 : CU_ASSERT(rc == 0);
827 [ + + ]: 3 : CU_ASSERT(task.inplace == true);
828 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE);
829 [ + - ]: 3 : CU_ASSERT(task.cryop_total == num_blocks);
830 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 0);
831 : :
832 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
833 [ + + ]: 384 : iov_idx = i / blocks_in_iov;
834 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
835 : : i % blocks_in_iov) * block_len));
836 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
837 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
838 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
839 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
840 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
841 : : uint64_t *) == (uint64_t)&task);
842 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst == NULL);
+ - + - +
- + - +
- ]
843 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
844 : 128 : }
845 : :
846 : : /* Call accel_dpdk_cryptodev_process_task like it was called by completion poller */
847 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
848 [ + - + - ]: 3 : task.cryop_completed = task.cryop_submitted;
849 : 3 : rc = accel_dpdk_cryptodev_process_task(g_crypto_ch, &task);
850 : :
851 : 3 : CU_ASSERT(rc == 0);
852 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE * 2);
853 [ + - + - ]: 3 : CU_ASSERT(task.cryop_total == task.cryop_submitted);
854 : :
855 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
856 [ + + ]: 384 : iov_idx = i / blocks_in_iov + 8;
857 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
858 : : i % blocks_in_iov) * block_len));
859 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
860 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
861 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
862 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
863 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
864 : : uint64_t *) == (uint64_t)&task);
865 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst == NULL);
+ - + - +
- + - +
- ]
866 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
867 : 128 : }
868 : :
869 : : /* Multi block size encryption, multi-element, out-of-place */
870 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
871 [ + - ]: 3 : task.cryop_submitted = 0;
872 : : /* Modify dst to make payload out-of-place */
873 [ + - + - ]: 3 : dst_iov[0].iov_base -= 1;
874 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc =
875 : : ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE;
876 : :
877 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
878 [ + + ]: 3 : CU_ASSERT(task.inplace == false);
879 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE);
880 [ + - ]: 3 : CU_ASSERT(task.cryop_total == num_blocks);
881 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 0);
882 : :
883 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
884 [ + + ]: 384 : iov_idx = i / blocks_in_iov;
885 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
886 : : i % blocks_in_iov) * block_len));
887 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
888 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
889 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
890 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
891 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
892 : : uint64_t *) == (uint64_t)&task);
893 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->buf_addr == dst_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
894 : : i % blocks_in_iov) * block_len));
895 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
896 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->next == NULL);
+ - + - +
- + - + -
+ - + - ]
897 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
898 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_dst);
+ - + - +
- + - +
- ]
899 : 128 : }
900 : :
901 : : /* Call accel_dpdk_cryptodev_process_task like it was called by completion poller */
902 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
903 [ + - + - ]: 3 : task.cryop_completed = task.cryop_submitted;
904 : 3 : rc = accel_dpdk_cryptodev_process_task(g_crypto_ch, &task);
905 : :
906 : 3 : CU_ASSERT(rc == 0);
907 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE * 2);
908 [ + - + - ]: 3 : CU_ASSERT(task.cryop_total == task.cryop_submitted);
909 : :
910 [ + + ]: 387 : for (i = 0; i < ACCEL_DPDK_CRYPTODEV_MAX_ENQUEUE_ARRAY_SIZE; i++) {
911 [ + + ]: 384 : iov_idx = i / blocks_in_iov + 8;
912 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
913 : : i % blocks_in_iov) * block_len));
914 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
915 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
916 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
917 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
918 [ + - + - : 384 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
919 : : uint64_t *) == (uint64_t)&task);
920 [ + + + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->buf_addr == dst_iov[iov_idx].iov_base + ((
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
921 : : i % blocks_in_iov) * block_len));
922 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
923 [ + - + - : 384 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst->next == NULL);
+ - + - +
- + - + -
+ - + - ]
924 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
925 [ + - + - : 384 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_dst);
+ - + - +
- + - +
- ]
926 : 128 : }
927 : 3 : }
928 : :
929 : : static void
930 : 3 : test_dev_full(void)
931 : : {
932 : 3 : struct accel_dpdk_cryptodev_task task = {};
933 : 1 : struct rte_crypto_sym_op *sym_op;
934 : 3 : struct iovec src_iov = {.iov_base = (void *)0xDEADBEEF, .iov_len = 1024 };
935 : 3 : struct iovec dst_iov = src_iov;
936 : 1 : int rc;
937 : :
938 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_DECRYPT;
939 [ + - + - : 3 : task.base.s.iovcnt = 1;
+ - ]
940 [ + - + - : 3 : task.base.s.iovs = &src_iov;
+ - ]
941 [ + - + - : 3 : task.base.d.iovcnt = 1;
+ - ]
942 [ + - + - : 3 : task.base.d.iovs = &dst_iov;
+ - ]
943 [ + - + - ]: 3 : task.base.block_size = 512;
944 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
945 [ + - ]: 3 : task.base.iv = 1;
946 : :
947 : : /* Two element block size decryption, 2nd op was not submitted */
948 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
949 : 3 : g_enqueue_mock = g_dequeue_mock = 1;
950 : 3 : ut_rte_crypto_op_bulk_alloc = 2;
951 [ + - + - : 3 : g_test_crypto_ops[1]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+ - + - +
- + - +
- ]
952 : :
953 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
954 : 3 : CU_ASSERT(rc == 0);
955 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
956 [ + - ]: 3 : CU_ASSERT(task.cryop_total == 2);
957 [ + - + - : 3 : sym_op = g_test_crypto_ops[0]->sym;
+ - + - ]
958 [ + - + - : 3 : CU_ASSERT(sym_op->m_src->buf_addr == src_iov.iov_base);
+ - + - ]
959 [ + - + - : 3 : CU_ASSERT(sym_op->m_src->data_len == 512);
+ - + - ]
960 [ + - + - : 3 : CU_ASSERT(sym_op->m_src->next == NULL);
+ - + - ]
961 [ + - + - : 3 : CU_ASSERT(sym_op->cipher.data.length == 512);
+ - + - +
- + - ]
962 [ + - + - : 3 : CU_ASSERT(sym_op->cipher.data.offset == 0);
+ - + - +
- + - ]
963 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(sym_op->m_src, g_mbuf_offset, uint64_t *) == (uint64_t)&task);
+ - ]
964 [ + - + - ]: 3 : CU_ASSERT(sym_op->m_dst == NULL);
965 : : /* op which was not submitted is already released */
966 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
967 [ + - ]: 3 : task.cryop_submitted = 0;
968 : :
969 : : /* Two element block size decryption, no ops were submitted, task should be queued */
970 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
971 : 3 : g_enqueue_mock = g_dequeue_mock = 0;
972 : 3 : ut_rte_crypto_op_bulk_alloc = 2;
973 [ + - + - : 3 : g_test_crypto_ops[0]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+ - + - +
- + - ]
974 [ + - + - : 3 : g_test_crypto_ops[1]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+ - + - +
- + - +
- ]
975 : :
976 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->queued_tasks) == true);
+ - ]
977 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
978 : 3 : CU_ASSERT(rc == 0);
979 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 0);
980 [ + - + - : 3 : CU_ASSERT(!TAILQ_EMPTY(&g_crypto_ch->queued_tasks));
+ - ]
981 [ + - + - : 3 : CU_ASSERT(TAILQ_FIRST(&g_crypto_ch->queued_tasks) == &task);
+ - ]
982 [ + - + - : 3 : TAILQ_INIT(&g_crypto_ch->queued_tasks);
+ - + - +
- + - + -
+ - ]
983 : :
984 : : /* Non-busy reason for enqueue failure, all were rejected. */
985 : 3 : g_enqueue_mock = 0;
986 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
987 [ + - + - : 3 : g_test_crypto_ops[0]->status = RTE_CRYPTO_OP_STATUS_ERROR;
+ - + - +
- + - ]
988 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
989 : 3 : CU_ASSERT(rc == -EINVAL);
990 : :
991 : : /* QP is full, task should be queued */
992 [ + - + - ]: 3 : g_aesni_qp.num_enqueued_ops = g_aesni_crypto_dev.qp_desc_nr;
993 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->queued_tasks) == true);
+ - ]
994 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
995 : 3 : CU_ASSERT(rc == 0);
996 [ + - + - : 3 : CU_ASSERT(!TAILQ_EMPTY(&g_crypto_ch->queued_tasks));
+ - ]
997 [ + - + - : 3 : CU_ASSERT(TAILQ_FIRST(&g_crypto_ch->queued_tasks) == &task);
+ - ]
998 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
999 : :
1000 [ + - + - : 3 : TAILQ_INIT(&g_crypto_ch->queued_tasks);
+ - + - +
- + - + -
+ - ]
1001 : :
1002 : : /* Two element block size decryption, 2nd op was not submitted, but has RTE_CRYPTO_OP_STATUS_SUCCESS status */
1003 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
1004 : 3 : g_enqueue_mock = g_dequeue_mock = 1;
1005 : 3 : ut_rte_crypto_op_bulk_alloc = 2;
1006 [ + - + - : 3 : g_test_crypto_ops[1]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+ - + - +
- + - +
- ]
1007 : :
1008 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
1009 : 3 : CU_ASSERT(rc == 0);
1010 [ + - ]: 3 : CU_ASSERT(task.cryop_total == 2);
1011 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 2);
1012 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 1);
1013 [ + - + - : 3 : sym_op = g_test_crypto_ops[0]->sym;
+ - + - ]
1014 [ + - + - : 3 : CU_ASSERT(sym_op->m_src->buf_addr == src_iov.iov_base);
+ - + - ]
1015 [ + - + - : 3 : CU_ASSERT(sym_op->m_src->data_len == 512);
+ - + - ]
1016 [ + - + - : 3 : CU_ASSERT(sym_op->m_src->next == NULL);
+ - + - ]
1017 [ + - + - : 3 : CU_ASSERT(sym_op->cipher.data.length == 512);
+ - + - +
- + - ]
1018 [ + - + - : 3 : CU_ASSERT(sym_op->cipher.data.offset == 0);
+ - + - +
- + - ]
1019 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(sym_op->m_src, g_mbuf_offset, uint64_t *) == (uint64_t)&task);
+ - ]
1020 [ + - + - ]: 3 : CU_ASSERT(sym_op->m_dst == NULL);
1021 : : /* op which was not submitted is already released */
1022 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
1023 : :
1024 : : /* Two element block size decryption, 1st op was not submitted, but has RTE_CRYPTO_OP_STATUS_SUCCESS status */
1025 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
1026 : 3 : g_enqueue_mock = g_dequeue_mock = 0;
1027 : 3 : ut_rte_crypto_op_bulk_alloc = 2;
1028 [ + - + - : 3 : g_test_crypto_ops[0]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+ - + - +
- + - ]
1029 : :
1030 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
1031 : 3 : CU_ASSERT(rc == 0);
1032 [ + - ]: 3 : CU_ASSERT(task.cryop_total == 2);
1033 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
1034 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 1);
1035 [ + - + - : 3 : CU_ASSERT(!TAILQ_EMPTY(&g_crypto_ch->queued_tasks));
+ - ]
1036 [ + - + - : 3 : CU_ASSERT(TAILQ_FIRST(&g_crypto_ch->queued_tasks) == &task);
+ - ]
1037 [ + - + - : 3 : TAILQ_INIT(&g_crypto_ch->queued_tasks);
+ - + - +
- + - + -
+ - ]
1038 : :
1039 : : /* Single element block size decryption, 1st op was not submitted, but has RTE_CRYPTO_OP_STATUS_SUCCESS status.
1040 : : * Task should be queued in the completed_tasks list */
1041 [ + - ]: 3 : src_iov.iov_len = 512;
1042 [ + - ]: 3 : dst_iov.iov_len = 512;
1043 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
1044 : 3 : g_enqueue_mock = g_dequeue_mock = 0;
1045 : 3 : ut_rte_crypto_op_bulk_alloc = 1;
1046 [ + - + - : 3 : g_test_crypto_ops[0]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+ - + - +
- + - ]
1047 : :
1048 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
1049 : 3 : CU_ASSERT(rc == 0);
1050 [ + - ]: 3 : CU_ASSERT(task.cryop_total == 1);
1051 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 1);
1052 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 1);
1053 [ + - + - : 3 : CU_ASSERT(!TAILQ_EMPTY(&g_crypto_ch->completed_tasks));
+ - ]
1054 [ + - + - : 3 : CU_ASSERT(TAILQ_FIRST(&g_crypto_ch->completed_tasks) == &task);
+ - ]
1055 [ + - + - : 3 : TAILQ_INIT(&g_crypto_ch->completed_tasks);
+ - + - +
- + - + -
+ - ]
1056 : 3 : }
1057 : :
1058 : : static void
1059 : 3 : test_crazy_rw(void)
1060 : : {
1061 : 3 : struct accel_dpdk_cryptodev_task task = {};
1062 : 3 : struct iovec src_iov[4] = {
1063 : : [0] = {.iov_base = (void *)0xDEADBEEF, .iov_len = 512 },
1064 : : [1] = {.iov_base = (void *)0xDEADBEEF + 512, .iov_len = 1024 },
1065 : : [2] = {.iov_base = (void *)0xDEADBEEF + 512 + 1024, .iov_len = 512 }
1066 : : };
1067 : 3 : struct iovec *dst_iov = src_iov;
1068 : 3 : uint32_t block_len = 512, num_blocks = 4, i;
1069 : 1 : int rc;
1070 : :
1071 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_DECRYPT;
1072 [ + - + - : 3 : task.base.s.iovcnt = 3;
+ - ]
1073 [ + - + - : 3 : task.base.s.iovs = src_iov;
+ - ]
1074 [ + - + - : 3 : task.base.d.iovcnt = 3;
+ - ]
1075 [ + - + - : 3 : task.base.d.iovs = dst_iov;
+ - ]
1076 [ + - + - ]: 3 : task.base.block_size = 512;
1077 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
1078 [ + - ]: 3 : task.base.iv = 1;
1079 : :
1080 : : /* Multi block size read, single element, strange IOV makeup */
1081 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc = num_blocks;
1082 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
1083 : :
1084 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
1085 : 3 : CU_ASSERT(rc == 0);
1086 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == num_blocks);
1087 : :
1088 [ + + ]: 15 : for (i = 0; i < num_blocks; i++) {
1089 [ + - + - : 12 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
1090 [ + - + - : 12 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
1091 [ + - + - : 12 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
1092 : : uint64_t *) == (uint64_t)&task);
1093 [ + - + - : 12 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
1094 [ + - + - : 12 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[0].iov_base + (i * block_len));
+ - + - +
- + - + -
+ - + - +
- + - ]
1095 [ + - + - : 12 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
1096 [ + - + - : 12 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst == NULL);
+ - + - +
- + - +
- ]
1097 [ + - + - : 12 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
1098 : 4 : }
1099 : :
1100 : : /* Multi block size write, single element strange IOV makeup */
1101 : 3 : num_blocks = 8;
1102 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_ENCRYPT;
1103 [ + - ]: 3 : task.cryop_submitted = 0;
1104 [ + - + - : 3 : task.base.s.iovcnt = 4;
+ - ]
1105 [ + - + - : 3 : task.base.d.iovcnt = 4;
+ - ]
1106 [ + - + - : 3 : task.base.s.iovs[0].iov_len = 2048;
+ - + - +
- + - ]
1107 [ + - + - : 3 : task.base.s.iovs[0].iov_base = (void *)0xDEADBEEF;
+ - + - +
- + - ]
1108 [ + - + - : 3 : task.base.s.iovs[1].iov_len = 512;
+ - + - +
- + - ]
1109 [ + - + - : 3 : task.base.s.iovs[1].iov_base = (void *)0xDEADBEEF + 2048;
+ - + - +
- + - ]
1110 [ + - + - : 3 : task.base.s.iovs[2].iov_len = 512;
+ - + - +
- + - ]
1111 [ + - + - : 3 : task.base.s.iovs[2].iov_base = (void *)0xDEADBEEF + 2048 + 512;
+ - + - +
- + - ]
1112 [ + - + - : 3 : task.base.s.iovs[3].iov_len = 1024;
+ - + - +
- + - ]
1113 [ + - + - : 3 : task.base.s.iovs[3].iov_base = (void *)0xDEADBEEF + 2048 + 512 + 512;
+ - + - +
- + - ]
1114 : :
1115 : 3 : g_enqueue_mock = g_dequeue_mock = ut_rte_crypto_op_bulk_alloc = num_blocks;
1116 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
1117 : :
1118 : 3 : rc = accel_dpdk_cryptodev_submit_tasks(g_io_ch, &task.base);
1119 : 3 : CU_ASSERT(rc == 0);
1120 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == num_blocks);
1121 : :
1122 [ + + ]: 27 : for (i = 0; i < num_blocks; i++) {
1123 [ + - + - : 24 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.length == block_len);
+ - + - +
- + - + -
+ - + - +
- + - ]
1124 [ + - + - : 24 : CU_ASSERT(g_test_crypto_ops[i]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- + - ]
1125 [ + - + - : 24 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[i]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - + -
+ - ]
1126 : : uint64_t *) == (uint64_t)&task);
1127 [ + - + - : 24 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - + - ]
1128 [ + - + - : 24 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->buf_addr == src_iov[0].iov_base + (i * block_len));
+ - + - +
- + - + -
+ - + - +
- + - ]
1129 [ + - + - : 24 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_src->data_len == block_len);
+ - + - +
- + - + -
+ - + - ]
1130 [ + - + - : 24 : CU_ASSERT(g_test_crypto_ops[i]->sym->m_dst == NULL);
+ - + - +
- + - +
- ]
1131 [ + - + - : 24 : rte_pktmbuf_free(g_test_crypto_ops[i]->sym->m_src);
+ - + - +
- + - +
- ]
1132 : 8 : }
1133 : 3 : }
1134 : :
1135 : : static void
1136 : 12 : init_cleanup(void)
1137 : : {
1138 : 4 : struct accel_dpdk_cryptodev_device *dev, *tmp;
1139 : :
1140 [ + + ]: 12 : if (g_crypto_op_mp) {
1141 : 12 : rte_mempool_free(g_crypto_op_mp);
1142 : 12 : g_crypto_op_mp = NULL;
1143 : 4 : }
1144 [ + + ]: 12 : if (g_mbuf_mp) {
1145 : 12 : rte_mempool_free(g_mbuf_mp);
1146 : 12 : g_mbuf_mp = NULL;
1147 : 4 : }
1148 [ + + ]: 12 : if (g_session_mp) {
1149 : 12 : rte_mempool_free(g_session_mp);
1150 : 12 : g_session_mp = NULL;
1151 : 4 : }
1152 [ + + ]: 12 : if (g_session_mp_priv != NULL) {
1153 : : /* g_session_mp_priv may or may not be set depending on the DPDK version */
1154 : 0 : rte_mempool_free(g_session_mp_priv);
1155 : 0 : g_session_mp_priv = NULL;
1156 : 0 : }
1157 : :
1158 [ + + + - : 36 : TAILQ_FOREACH_SAFE(dev, &g_crypto_devices, link, tmp) {
+ - + - +
+ ]
1159 [ + + + - : 24 : TAILQ_REMOVE(&g_crypto_devices, dev, link);
+ - + + +
- + - + -
+ - + - +
- + - + -
+ - - + -
+ - + - +
+ - + - +
- + - + -
+ - + - ]
1160 : 24 : accel_dpdk_cryptodev_release(dev);
1161 : 8 : }
1162 : :
1163 : 12 : spdk_io_device_unregister(&g_accel_dpdk_cryptodev_module, NULL);
1164 : 12 : }
1165 : :
1166 : : static void
1167 : 3 : test_initdrivers(void)
1168 : : {
1169 : 1 : int rc;
1170 : : static struct rte_mempool *orig_mbuf_mp;
1171 : : static struct rte_mempool *orig_session_mp;
1172 : : static struct rte_mempool *orig_session_mp_priv;
1173 : :
1174 : : /* accel_dpdk_cryptodev_init calls spdk_io_device_register, we need to have a thread */
1175 : 3 : allocate_threads(1);
1176 : 3 : set_thread(0);
1177 : :
1178 : : /* These tests will alloc and free our g_mbuf_mp
1179 : : * so save that off here and restore it after each test is over.
1180 : : */
1181 : 3 : orig_mbuf_mp = g_mbuf_mp;
1182 : 3 : orig_session_mp = g_session_mp;
1183 : 3 : orig_session_mp_priv = g_session_mp_priv;
1184 : :
1185 : 3 : g_session_mp_priv = NULL;
1186 : 3 : g_session_mp = NULL;
1187 : 3 : g_mbuf_mp = NULL;
1188 : :
1189 : : /* No drivers available, not an error though */
1190 : 3 : MOCK_SET(rte_cryptodev_count, 0);
1191 : 3 : rc = accel_dpdk_cryptodev_init();
1192 : 3 : CU_ASSERT(rc == 0);
1193 : 3 : CU_ASSERT(g_mbuf_mp == NULL);
1194 : 3 : CU_ASSERT(g_session_mp == NULL);
1195 : 3 : CU_ASSERT(g_session_mp_priv == NULL);
1196 : :
1197 : : /* Can't create session pool. */
1198 : 3 : MOCK_SET(rte_cryptodev_count, 2);
1199 : 3 : MOCK_SET(spdk_mempool_create, NULL);
1200 : 3 : rc = accel_dpdk_cryptodev_init();
1201 : 3 : CU_ASSERT(rc == -ENOMEM);
1202 : 3 : CU_ASSERT(g_mbuf_mp == NULL);
1203 : 3 : CU_ASSERT(g_session_mp == NULL);
1204 : 3 : CU_ASSERT(g_session_mp_priv == NULL);
1205 : 3 : MOCK_CLEAR(spdk_mempool_create);
1206 : :
1207 : : /* Can't create op pool. */
1208 : 3 : MOCK_SET(rte_crypto_op_pool_create, NULL);
1209 : 3 : rc = accel_dpdk_cryptodev_init();
1210 : 3 : CU_ASSERT(rc == -ENOMEM);
1211 : 3 : CU_ASSERT(g_mbuf_mp == NULL);
1212 : 3 : CU_ASSERT(g_session_mp == NULL);
1213 : 3 : CU_ASSERT(g_session_mp_priv == NULL);
1214 : 3 : MOCK_CLEAR(rte_crypto_op_pool_create);
1215 : :
1216 : : /* Check resources are not sufficient */
1217 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1218 : 3 : rc = accel_dpdk_cryptodev_init();
1219 : 3 : CU_ASSERT(rc == -EINVAL);
1220 : :
1221 : : /* Test crypto dev configure failure. */
1222 : 3 : MOCK_SET(rte_cryptodev_device_count_by_driver, 2);
1223 : 3 : MOCK_SET(rte_cryptodev_info_get, MOCK_INFO_GET_1QP_AESNI);
1224 : 3 : MOCK_SET(rte_cryptodev_configure, -1);
1225 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1226 : 3 : rc = accel_dpdk_cryptodev_init();
1227 : 3 : MOCK_SET(rte_cryptodev_configure, 0);
1228 : 3 : CU_ASSERT(g_mbuf_mp == NULL);
1229 : 3 : CU_ASSERT(g_session_mp == NULL);
1230 : 3 : CU_ASSERT(g_session_mp_priv == NULL);
1231 : 3 : CU_ASSERT(rc == -EINVAL);
1232 : :
1233 : : /* Test failure of qp setup. */
1234 : 3 : MOCK_SET(rte_cryptodev_queue_pair_setup, -1);
1235 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1236 : 3 : rc = accel_dpdk_cryptodev_init();
1237 : 3 : CU_ASSERT(rc == -EINVAL);
1238 : 3 : CU_ASSERT(g_mbuf_mp == NULL);
1239 : 3 : CU_ASSERT(g_session_mp == NULL);
1240 : 3 : CU_ASSERT(g_session_mp_priv == NULL);
1241 : 3 : MOCK_SET(rte_cryptodev_queue_pair_setup, 0);
1242 : :
1243 : : /* Test failure of dev start. */
1244 : 3 : MOCK_SET(rte_cryptodev_start, -1);
1245 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1246 : 3 : rc = accel_dpdk_cryptodev_init();
1247 : 3 : CU_ASSERT(rc == -EINVAL);
1248 : 3 : CU_ASSERT(g_mbuf_mp == NULL);
1249 : 3 : CU_ASSERT(g_session_mp == NULL);
1250 : 3 : CU_ASSERT(g_session_mp_priv == NULL);
1251 : 3 : MOCK_SET(rte_cryptodev_start, 0);
1252 : :
1253 : : /* Test bogus PMD */
1254 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1255 : 3 : MOCK_SET(rte_cryptodev_info_get, MOCK_INFO_GET_1QP_BOGUS_PMD);
1256 : 3 : rc = accel_dpdk_cryptodev_init();
1257 : 3 : CU_ASSERT(g_mbuf_mp == NULL);
1258 : 3 : CU_ASSERT(g_session_mp == NULL);
1259 : 3 : CU_ASSERT(rc == -EINVAL);
1260 : :
1261 : : /* Test happy path QAT. */
1262 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1263 : 3 : MOCK_SET(rte_cryptodev_info_get, MOCK_INFO_GET_1QP_QAT);
1264 : 3 : rc = accel_dpdk_cryptodev_init();
1265 : 3 : CU_ASSERT(g_mbuf_mp != NULL);
1266 : 3 : CU_ASSERT(g_session_mp != NULL);
1267 : 3 : init_cleanup();
1268 : 3 : CU_ASSERT(rc == 0);
1269 : :
1270 : : /* Test happy path AESNI. */
1271 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1272 : 3 : MOCK_SET(rte_cryptodev_info_get, MOCK_INFO_GET_1QP_AESNI);
1273 : 3 : rc = accel_dpdk_cryptodev_init();
1274 : 3 : CU_ASSERT(g_mbuf_offset == DPDK_DYNFIELD_OFFSET);
1275 : 3 : init_cleanup();
1276 : 3 : CU_ASSERT(rc == 0);
1277 : :
1278 : : /* Test happy path MLX5. */
1279 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1280 : 3 : MOCK_SET(rte_cryptodev_info_get, MOCK_INFO_GET_1QP_MLX5);
1281 : 3 : rc = accel_dpdk_cryptodev_init();
1282 : 3 : CU_ASSERT(g_mbuf_offset == DPDK_DYNFIELD_OFFSET);
1283 : 3 : init_cleanup();
1284 : 3 : CU_ASSERT(rc == 0);
1285 : :
1286 : : /* Test failure of DPDK dev init. By now it is not longer an error
1287 : : * situation for entire crypto framework. */
1288 : 3 : MOCK_SET(rte_cryptodev_count, 2);
1289 : 3 : MOCK_SET(rte_cryptodev_device_count_by_driver, 2);
1290 : 3 : MOCK_SET(rte_vdev_init, -1);
1291 [ + + + + : 3 : MOCK_CLEARED_ASSERT(spdk_mempool_create);
# # ]
1292 : 3 : MOCK_SET(rte_cryptodev_info_get, MOCK_INFO_GET_1QP_QAT);
1293 : 3 : rc = accel_dpdk_cryptodev_init();
1294 : 3 : CU_ASSERT(rc == 0);
1295 : 3 : CU_ASSERT(g_mbuf_mp != NULL);
1296 : 3 : CU_ASSERT(g_session_mp != NULL);
1297 : : #if RTE_VERSION < RTE_VERSION_NUM(22, 11, 0, 0)
1298 : : CU_ASSERT(g_session_mp_priv != NULL);
1299 : : #endif
1300 : 3 : init_cleanup();
1301 : 3 : MOCK_SET(rte_vdev_init, 0);
1302 : 3 : MOCK_CLEAR(rte_cryptodev_device_count_by_driver);
1303 : :
1304 : : /* restore our initial values. */
1305 : 3 : g_mbuf_mp = orig_mbuf_mp;
1306 : 3 : g_session_mp = orig_session_mp;
1307 : 3 : g_session_mp_priv = orig_session_mp_priv;
1308 : 3 : free_threads();
1309 : 3 : }
1310 : :
1311 : : static void
1312 : 3 : test_supported_opcodes(void)
1313 : : {
1314 : 3 : bool rc = true;
1315 : 1 : enum spdk_accel_opcode opc;
1316 : :
1317 [ + + ]: 45 : for (opc = 0; opc < SPDK_ACCEL_OPC_LAST; opc++) {
1318 : 42 : rc = accel_dpdk_cryptodev_supports_opcode(opc);
1319 [ + + ]: 42 : switch (opc) {
1320 : 4 : case SPDK_ACCEL_OPC_ENCRYPT:
1321 : : case SPDK_ACCEL_OPC_DECRYPT:
1322 [ + - ]: 6 : CU_ASSERT(rc == true);
1323 : 6 : break;
1324 : 24 : default:
1325 [ - + ]: 36 : CU_ASSERT(rc == false);
1326 : 12 : }
1327 : 14 : }
1328 : 3 : }
1329 : :
1330 : : static void
1331 : 3 : test_poller(void)
1332 : : {
1333 : 3 : struct accel_dpdk_cryptodev_task task = {};
1334 : 3 : struct iovec src_iov = {.iov_base = (void *)0xDEADBEEF, .iov_len = 1024 };
1335 : 3 : struct iovec dst_iov = src_iov;
1336 : 2 : struct rte_mbuf *src_mbufs[2];
1337 : 1 : int rc;
1338 : :
1339 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_DECRYPT;
1340 [ + - + - : 3 : task.base.s.iovcnt = 1;
+ - ]
1341 [ + - + - : 3 : task.base.s.iovs = &src_iov;
+ - ]
1342 [ + - + - : 3 : task.base.d.iovcnt = 1;
+ - ]
1343 [ + - + - : 3 : task.base.d.iovs = &dst_iov;
+ - ]
1344 [ + - + - ]: 3 : task.base.block_size = 512;
1345 [ + - + - ]: 3 : task.base.crypto_key = &g_key;
1346 [ + - ]: 3 : task.base.iv = 1;
1347 : 3 : task.inplace = true;
1348 : :
1349 : : /* test regular 1 op to dequeue and complete */
1350 : 3 : g_dequeue_mock = g_enqueue_mock = 1;
1351 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 1;
1352 : 3 : rte_pktmbuf_alloc_bulk(g_mbuf_mp, src_mbufs, 1);
1353 [ + - + - : 3 : g_test_crypto_ops[0]->sym->m_src = src_mbufs[0];
+ - + - +
- + - + -
+ - ]
1354 [ + - + - : 3 : *RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - ]
1355 [ + - ]: 4 : uint64_t *) = (uintptr_t)&task;
1356 [ + - + - : 3 : g_test_crypto_ops[0]->sym->m_dst = NULL;
+ - + - +
- + - ]
1357 [ + - ]: 3 : task.cryop_submitted = 1;
1358 [ + - ]: 3 : task.cryop_total = 1;
1359 [ + - ]: 3 : task.cryop_completed = 0;
1360 [ + - ]: 3 : task.base.op_code = SPDK_ACCEL_OPC_DECRYPT;
1361 : 3 : rc = accel_dpdk_cryptodev_poller(g_crypto_ch);
1362 : 3 : CU_ASSERT(rc == 1);
1363 [ + - + - ]: 3 : CU_ASSERT(task.cryop_completed == task.cryop_submitted);
1364 [ + - ]: 3 : CU_ASSERT(g_aesni_qp.num_enqueued_ops == 0);
1365 : :
1366 : : /* 2 to dequeue but 2nd one failed */
1367 : 3 : g_dequeue_mock = g_enqueue_mock = 2;
1368 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 2;
1369 [ + - ]: 3 : task.cryop_submitted = 2;
1370 [ + - ]: 3 : task.cryop_total = 2;
1371 [ + - ]: 3 : task.cryop_completed = 0;
1372 : 3 : rte_pktmbuf_alloc_bulk(g_mbuf_mp, src_mbufs, 2);
1373 [ + - + - : 3 : g_test_crypto_ops[0]->sym->m_src = src_mbufs[0];
+ - + - +
- + - + -
+ - ]
1374 [ + - + - : 3 : *RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - ]
1375 [ + - ]: 4 : uint64_t *) = (uint64_t)&task;
1376 [ + - + - : 3 : g_test_crypto_ops[0]->sym->m_dst = NULL;
+ - + - +
- + - ]
1377 [ + - + - : 3 : g_test_crypto_ops[0]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+ - + - +
- + - ]
1378 [ + - + - : 3 : g_test_crypto_ops[1]->sym->m_src = src_mbufs[1];
+ - + - +
- + - + -
+ - + - +
- ]
1379 [ + - + - : 3 : *RTE_MBUF_DYNFIELD(g_test_crypto_ops[1]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
1380 [ + - ]: 4 : uint64_t *) = (uint64_t)&task;
1381 [ + - + - : 3 : g_test_crypto_ops[1]->sym->m_dst = NULL;
+ - + - +
- + - +
- ]
1382 [ + - + - : 3 : g_test_crypto_ops[1]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+ - + - +
- + - +
- ]
1383 : 3 : rc = accel_dpdk_cryptodev_poller(g_crypto_ch);
1384 [ + + + - ]: 3 : CU_ASSERT(task.is_failed == true);
1385 : 3 : CU_ASSERT(rc == 1);
1386 [ + - ]: 3 : CU_ASSERT(g_aesni_qp.num_enqueued_ops == 0);
1387 : :
1388 : : /* Dequeue a task which needs to be submitted again */
1389 : 3 : g_dequeue_mock = g_enqueue_mock = ut_rte_crypto_op_bulk_alloc = 1;
1390 [ + - ]: 3 : task.cryop_submitted = 1;
1391 [ + - ]: 3 : task.cryop_total = 2;
1392 [ + - ]: 3 : task.cryop_completed = 0;
1393 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 1;
1394 : 3 : rte_pktmbuf_alloc_bulk(g_mbuf_mp, src_mbufs, 1);
1395 [ + + + - : 3 : SPDK_CU_ASSERT_FATAL(src_mbufs[0] != NULL);
+ - # # ]
1396 [ + - + - : 3 : g_test_crypto_ops[0]->sym->m_src = src_mbufs[0];
+ - + - +
- + - + -
+ - ]
1397 [ + - + - : 3 : *RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - ]
1398 [ + - ]: 4 : uint64_t *) = (uintptr_t)&task;
1399 [ + - + - : 3 : g_test_crypto_ops[0]->sym->m_dst = NULL;
+ - + - +
- + - ]
1400 : 3 : rc = accel_dpdk_cryptodev_poller(g_crypto_ch);
1401 : 3 : CU_ASSERT(rc == 1);
1402 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 2);
1403 [ + - ]: 3 : CU_ASSERT(task.cryop_total == 2);
1404 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 1);
1405 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->buf_addr == src_iov.iov_base + task.base.block_size);
+ - + - +
- + - + -
+ - + - +
- ]
1406 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->data_len == task.base.block_size);
+ - + - +
- + - + -
+ - + - +
- ]
1407 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - ]
1408 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == task.base.block_size);
+ - + - +
- + - + -
+ - + - +
- + - +
- ]
1409 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
1410 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
1411 : : uint64_t *) == (uint64_t)&task);
1412 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst == NULL);
+ - + - +
- + - ]
1413 [ + - ]: 3 : CU_ASSERT(g_aesni_qp.num_enqueued_ops == 1);
1414 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
1415 : :
1416 : : /* Process queued tasks, qp is full */
1417 : 3 : g_dequeue_mock = g_enqueue_mock = 0;
1418 [ + - + - ]: 3 : g_aesni_qp.num_enqueued_ops = g_aesni_crypto_dev.qp_desc_nr;
1419 [ + - ]: 3 : task.cryop_submitted = 1;
1420 [ + - ]: 3 : task.cryop_total = 2;
1421 [ + - ]: 3 : task.cryop_completed = 1;
1422 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->queued_tasks));
+ - ]
1423 [ + - + - : 3 : TAILQ_INSERT_TAIL(&g_crypto_ch->queued_tasks, &task, link);
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- ]
1424 : :
1425 : 3 : rc = accel_dpdk_cryptodev_poller(g_crypto_ch);
1426 : 3 : CU_ASSERT(rc == 0);
1427 [ + - + - : 3 : CU_ASSERT(TAILQ_FIRST(&g_crypto_ch->queued_tasks) == &task);
+ - ]
1428 : :
1429 : : /* Try again when queue is empty, task should be submitted */
1430 : 3 : g_enqueue_mock = 1;
1431 [ + - ]: 3 : g_aesni_qp.num_enqueued_ops = 0;
1432 : 3 : rc = accel_dpdk_cryptodev_poller(g_crypto_ch);
1433 : 3 : CU_ASSERT(rc == 1);
1434 [ + - ]: 3 : CU_ASSERT(task.cryop_submitted == 2);
1435 [ + - ]: 3 : CU_ASSERT(task.cryop_total == 2);
1436 [ + - ]: 3 : CU_ASSERT(task.cryop_completed == 1);
1437 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->buf_addr == src_iov.iov_base + task.base.block_size);
+ - + - +
- + - + -
+ - + - +
- ]
1438 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->data_len == task.base.block_size);
+ - + - +
- + - + -
+ - + - +
- ]
1439 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_src->next == NULL);
+ - + - +
- + - + -
+ - ]
1440 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.length == task.base.block_size);
+ - + - +
- + - + -
+ - + - +
- + - +
- ]
1441 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->cipher.data.offset == 0);
+ - + - +
- + - + -
+ - + - +
- ]
1442 [ + - + - : 3 : CU_ASSERT(*RTE_MBUF_DYNFIELD(g_test_crypto_ops[0]->sym->m_src, g_mbuf_offset,
+ - + - +
- + - +
- ]
1443 : : uint64_t *) == (uint64_t)&task);
1444 [ + - + - : 3 : CU_ASSERT(g_test_crypto_ops[0]->sym->m_dst == NULL);
+ - + - +
- + - ]
1445 [ + - ]: 3 : CU_ASSERT(g_aesni_qp.num_enqueued_ops == 1);
1446 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->queued_tasks));
+ - ]
1447 [ + - + - : 3 : rte_pktmbuf_free(g_test_crypto_ops[0]->sym->m_src);
+ - + - +
- + - ]
1448 : :
1449 : : /* Complete tasks in the dedicated list */
1450 : 3 : g_dequeue_mock = g_enqueue_mock = 0;
1451 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->completed_tasks));
+ - ]
1452 [ + - + - : 3 : TAILQ_INSERT_TAIL(&g_crypto_ch->completed_tasks, &task, link);
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- ]
1453 : 3 : rc = accel_dpdk_cryptodev_poller(g_crypto_ch);
1454 : 3 : CU_ASSERT(rc == 1);
1455 [ + - + - : 3 : CU_ASSERT(TAILQ_EMPTY(&g_crypto_ch->completed_tasks));
+ - ]
1456 : 3 : }
1457 : :
1458 : : /* Helper function for accel_dpdk_cryptodev_assign_device_qps() */
1459 : : static void
1460 : 12 : _check_expected_values(struct accel_dpdk_cryptodev_io_channel *crypto_ch,
1461 : : uint8_t expected_qat_index,
1462 : : uint8_t next_qat_index)
1463 : : {
1464 : 4 : uint32_t num_qpairs;
1465 : :
1466 [ + + + - ]: 12 : memset(crypto_ch->device_qp, 0, sizeof(crypto_ch->device_qp));
1467 : :
1468 : 12 : num_qpairs = accel_dpdk_cryptodev_assign_device_qps(crypto_ch);
1469 : 12 : CU_ASSERT(num_qpairs == 3);
1470 : :
1471 [ + + + - : 12 : SPDK_CU_ASSERT_FATAL(crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_QAT] != NULL);
+ - + - +
- # # ]
1472 [ + - + - : 12 : CU_ASSERT(crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_QAT]->index == expected_qat_index);
+ - + - +
- + - ]
1473 [ + + + - : 12 : CU_ASSERT(crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_QAT]->in_use == true);
+ - + - +
- + - +
- ]
1474 : 12 : CU_ASSERT(g_next_qat_index == next_qat_index);
1475 [ + + + - : 12 : SPDK_CU_ASSERT_FATAL(crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_AESNI_MB] != NULL);
+ - + - +
- # # ]
1476 [ + + + - : 12 : CU_ASSERT(crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_AESNI_MB]->in_use == true);
+ - + - +
- + - +
- ]
1477 [ + + + - : 12 : SPDK_CU_ASSERT_FATAL(crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_MLX5_PCI] != NULL);
+ - + - +
- # # ]
1478 [ + + + - : 12 : CU_ASSERT(crypto_ch->device_qp[ACCEL_DPDK_CRYPTODEV_DRIVER_MLX5_PCI]->in_use == true);
+ - + - +
- + - +
- ]
1479 : 12 : }
1480 : :
1481 : : static void
1482 : 3 : test_assign_device_qp(void)
1483 : : {
1484 : 3 : struct accel_dpdk_cryptodev_device qat_dev = {
1485 : : .type = ACCEL_DPDK_CRYPTODEV_DRIVER_QAT,
1486 [ + - ]: 1 : .qpairs = TAILQ_HEAD_INITIALIZER(qat_dev.qpairs)
1487 : : };
1488 : 3 : struct accel_dpdk_cryptodev_device aesni_dev = {
1489 : : .type = ACCEL_DPDK_CRYPTODEV_DRIVER_AESNI_MB,
1490 [ + - ]: 1 : .qpairs = TAILQ_HEAD_INITIALIZER(aesni_dev.qpairs)
1491 : : };
1492 : 3 : struct accel_dpdk_cryptodev_device mlx5_dev = {
1493 : : .type = ACCEL_DPDK_CRYPTODEV_DRIVER_MLX5_PCI,
1494 [ + - ]: 1 : .qpairs = TAILQ_HEAD_INITIALIZER(mlx5_dev.qpairs)
1495 : : };
1496 : 1 : struct accel_dpdk_cryptodev_qp *qat_qps;
1497 : 3 : struct accel_dpdk_cryptodev_qp aesni_qps[4] = {};
1498 : 3 : struct accel_dpdk_cryptodev_qp mlx5_qps[4] = {};
1499 : 3 : struct accel_dpdk_cryptodev_io_channel io_ch = {};
1500 : 3 : TAILQ_HEAD(, accel_dpdk_cryptodev_device) devs_tmp = TAILQ_HEAD_INITIALIZER(devs_tmp);
1501 : 1 : int i;
1502 : :
1503 : 3 : g_qat_total_qp = 96;
1504 : 3 : qat_qps = calloc(g_qat_total_qp, sizeof(*qat_qps));
1505 [ + + # # ]: 3 : SPDK_CU_ASSERT_FATAL(qat_qps != NULL);
1506 : :
1507 [ + + + - ]: 15 : for (i = 0; i < 4; i++) {
1508 [ + - + - : 12 : aesni_qps[i].index = i;
+ - + - ]
1509 [ + - + - : 12 : aesni_qps[i].device = &aesni_dev;
+ - + - ]
1510 [ + - + - : 12 : TAILQ_INSERT_TAIL(&aesni_dev.qpairs, &aesni_qps[i], link);
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
1511 : :
1512 [ + - + - : 12 : mlx5_qps[i].index = i;
+ - + - ]
1513 [ + - + - : 12 : mlx5_qps[i].device = &mlx5_dev;
+ - + - ]
1514 [ + - + - : 12 : TAILQ_INSERT_TAIL(&mlx5_dev.qpairs, &mlx5_qps[i], link);
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - ]
1515 : 4 : }
1516 [ + + + - ]: 291 : for (i = 0; i < g_qat_total_qp; i++) {
1517 [ + - + - : 288 : qat_qps[i].index = i;
+ - ]
1518 [ + - + - : 288 : qat_qps[i].device = &qat_dev;
+ - ]
1519 [ + - + - : 288 : TAILQ_INSERT_TAIL(&qat_dev.qpairs, &qat_qps[i], link);
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - ]
1520 : 96 : }
1521 : :
1522 : : /* Swap g_crypto_devices so that other tests are not affected */
1523 [ + + + + : 3 : TAILQ_SWAP(&g_crypto_devices, &devs_tmp, accel_dpdk_cryptodev_device, link);
+ - + - -
+ # # # #
# # + - -
+ # # # #
# # + - ]
1524 : :
1525 [ + - + - : 3 : TAILQ_INSERT_TAIL(&g_crypto_devices, &qat_dev, link);
+ - + - +
- + - + -
+ - + - ]
1526 [ + - + - : 3 : TAILQ_INSERT_TAIL(&g_crypto_devices, &aesni_dev, link);
+ - + - +
- + - + -
+ - + - ]
1527 [ + - + - : 3 : TAILQ_INSERT_TAIL(&g_crypto_devices, &mlx5_dev, link);
+ - + - +
- + - + -
+ - + - ]
1528 : :
1529 : : /* QAT testing is more complex as the code under test load balances by
1530 : : * assigning each subsequent device/qp to every QAT_VF_SPREAD modulo
1531 : : * g_qat_total_qp. For the current latest QAT we'll have 48 virtual functions
1532 : : * each with 2 qp so the "spread" between assignments is 32. */
1533 : :
1534 : : /* First assignment will assign to 0 and next at 32. */
1535 : 3 : _check_expected_values(&io_ch, 0, ACCEL_DPDK_CRYPTODEV_QAT_VF_SPREAD);
1536 : :
1537 : : /* Second assignment will assign to 32 and next at 64. */
1538 : 3 : _check_expected_values(&io_ch, ACCEL_DPDK_CRYPTODEV_QAT_VF_SPREAD,
1539 : : ACCEL_DPDK_CRYPTODEV_QAT_VF_SPREAD * 2);
1540 : :
1541 : : /* Third assignment will assign to 64 and next at 0. */
1542 : 3 : _check_expected_values(&io_ch, ACCEL_DPDK_CRYPTODEV_QAT_VF_SPREAD * 2, 0);
1543 : :
1544 : : /* Fourth assignment will assign to 1 and next at 33. */
1545 : 3 : _check_expected_values(&io_ch, 1, ACCEL_DPDK_CRYPTODEV_QAT_VF_SPREAD + 1);
1546 : :
1547 [ + - + + : 3 : TAILQ_SWAP(&devs_tmp, &g_crypto_devices, accel_dpdk_cryptodev_device, link);
+ - + - +
- + - + -
+ - # # -
+ # # # #
# # + - ]
1548 : :
1549 : 3 : free(qat_qps);
1550 : 3 : }
1551 : :
1552 : : int
1553 : 3 : main(int argc, char **argv)
1554 : : {
1555 : 3 : CU_pSuite suite = NULL;
1556 : 1 : unsigned int num_failures;
1557 : :
1558 : 3 : CU_initialize_registry();
1559 : :
1560 : 3 : suite = CU_add_suite("dpdk_cryptodev", test_setup, test_cleanup);
1561 : 3 : CU_ADD_TEST(suite, test_error_paths);
1562 : 3 : CU_ADD_TEST(suite, test_simple_encrypt);
1563 : 3 : CU_ADD_TEST(suite, test_simple_decrypt);
1564 : 3 : CU_ADD_TEST(suite, test_large_enc_dec);
1565 : 3 : CU_ADD_TEST(suite, test_dev_full);
1566 : 3 : CU_ADD_TEST(suite, test_crazy_rw);
1567 : 3 : CU_ADD_TEST(suite, test_initdrivers);
1568 : 3 : CU_ADD_TEST(suite, test_supported_opcodes);
1569 : 3 : CU_ADD_TEST(suite, test_poller);
1570 : 3 : CU_ADD_TEST(suite, test_assign_device_qp);
1571 : :
1572 : 3 : num_failures = spdk_ut_run_tests(argc, argv, NULL);
1573 : 3 : CU_cleanup_registry();
1574 : 4 : return num_failures;
1575 : 1 : }
|