xref: /dpdk/app/test/test_cryptodev.c (revision 3cf0c56ca5b1884c89c9a6bb4e5fdc978018d2b0)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Intel Corporation
3  * Copyright 2020 NXP
4  */
5 
6 #include <time.h>
7 
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
10 #include <rte_mbuf.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
16 #include <rte_errno.h>
17 
18 #include <rte_crypto.h>
19 #include <rte_cryptodev.h>
20 #include <rte_ethdev.h>
21 #include <rte_ip.h>
22 #include <rte_string_fns.h>
23 #include <rte_tcp.h>
24 #include <rte_udp.h>
25 
26 #ifdef RTE_CRYPTO_SCHEDULER
27 #include <rte_cryptodev_scheduler.h>
28 #include <rte_cryptodev_scheduler_operations.h>
29 #endif
30 
31 #include <rte_lcore.h>
32 
33 #include "test.h"
34 #include "test_cryptodev.h"
35 
36 #include "test_cryptodev_blockcipher.h"
37 #include "test_cryptodev_aes_test_vectors.h"
38 #include "test_cryptodev_des_test_vectors.h"
39 #include "test_cryptodev_hash_test_vectors.h"
40 #include "test_cryptodev_kasumi_test_vectors.h"
41 #include "test_cryptodev_kasumi_hash_test_vectors.h"
42 #include "test_cryptodev_snow3g_test_vectors.h"
43 #include "test_cryptodev_snow3g_hash_test_vectors.h"
44 #include "test_cryptodev_zuc_test_vectors.h"
45 #include "test_cryptodev_aead_test_vectors.h"
46 #include "test_cryptodev_hmac_test_vectors.h"
47 #include "test_cryptodev_mixed_test_vectors.h"
48 #include "test_cryptodev_sm4_test_vectors.h"
49 #ifdef RTE_LIB_SECURITY
50 #include "test_cryptodev_security_ipsec.h"
51 #include "test_cryptodev_security_ipsec_test_vectors.h"
52 #include "test_cryptodev_security_pdcp_test_vectors.h"
53 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
54 #include "test_cryptodev_security_pdcp_test_func.h"
55 #include "test_cryptodev_security_docsis_test_vectors.h"
56 #include "test_security_proto.h"
57 
58 #define SDAP_DISABLED	0
59 #define SDAP_ENABLED	1
60 #endif
61 
62 #define VDEV_ARGS_SIZE 100
63 #define MAX_NB_SESSIONS 4
64 
65 #define MAX_DRV_SERVICE_CTX_SIZE 256
66 
67 #define MAX_RAW_DEQUEUE_COUNT	65535
68 
69 #define IN_PLACE 0
70 #define OUT_OF_PLACE 1
71 
72 static int gbl_driver_id;
73 
74 static enum rte_security_session_action_type gbl_action_type =
75 	RTE_SECURITY_ACTION_TYPE_NONE;
76 
77 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
78 
79 struct crypto_unittest_params {
80 	struct rte_crypto_sym_xform cipher_xform;
81 	struct rte_crypto_sym_xform auth_xform;
82 	struct rte_crypto_sym_xform aead_xform;
83 #ifdef RTE_LIB_SECURITY
84 	struct rte_security_docsis_xform docsis_xform;
85 #endif
86 
87 	union {
88 		void *sess;
89 #ifdef RTE_LIB_SECURITY
90 		void *sec_session;
91 #endif
92 	};
93 #ifdef RTE_LIB_SECURITY
94 	enum rte_security_session_action_type type;
95 #endif
96 	struct rte_crypto_op *op;
97 
98 	struct rte_mbuf *obuf, *ibuf;
99 
100 	uint8_t *digest;
101 };
102 
103 #define ALIGN_POW2_ROUNDUP(num, align) \
104 	(((num) + (align) - 1) & ~((align) - 1))
105 
106 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
107 	for (j = 0; j < num_child_ts; index++, j++)			\
108 		parent_ts.unit_test_suites[index] = child_ts[j]
109 
110 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
111 	for (j = 0; j < num_blk_types; index++, j++)				\
112 		parent_ts.unit_test_suites[index] =				\
113 				build_blockcipher_test_suite(blk_types[j])
114 
115 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
116 	for (j = index; j < index + num_blk_types; j++)				\
117 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
118 
119 /*
120  * Forward declarations.
121  */
122 static int
123 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
124 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
125 		uint8_t *hmac_key);
126 
127 static int
128 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
129 		struct crypto_unittest_params *ut_params,
130 		struct crypto_testsuite_params *ts_param,
131 		const uint8_t *cipher,
132 		const uint8_t *digest,
133 		const uint8_t *iv);
134 
135 static int
136 security_proto_supported(enum rte_security_session_action_type action,
137 	enum rte_security_session_protocol proto);
138 
139 static int
140 dev_configure_and_start(uint64_t ff_disable);
141 
142 static int
143 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
144 			const enum rte_crypto_cipher_algorithm cipher_algo,
145 			const uint16_t key_size, const uint16_t iv_size);
146 
147 static int
148 check_auth_capability(const struct crypto_testsuite_params *ts_params,
149 			const enum rte_crypto_auth_algorithm auth_algo,
150 			const uint16_t key_size, const uint16_t iv_size,
151 			const uint16_t tag_size);
152 
153 static struct rte_mbuf *
154 setup_test_string(struct rte_mempool *mpool,
155 		const char *string, size_t len, uint8_t blocksize)
156 {
157 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
158 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
159 
160 	if (m) {
161 		char *dst;
162 
163 		memset(m->buf_addr, 0, m->buf_len);
164 		dst = rte_pktmbuf_append(m, t_len);
165 		if (!dst) {
166 			rte_pktmbuf_free(m);
167 			return NULL;
168 		}
169 		if (string != NULL)
170 			rte_memcpy(dst, string, t_len);
171 		else
172 			memset(dst, 0, t_len);
173 	}
174 
175 	return m;
176 }
177 
178 /* Get number of bytes in X bits (rounding up) */
179 static uint32_t
180 ceil_byte_length(uint32_t num_bits)
181 {
182 	if (num_bits % 8)
183 		return ((num_bits >> 3) + 1);
184 	else
185 		return (num_bits >> 3);
186 }
187 
188 static void
189 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
190 		uint8_t is_op_success)
191 {
192 	struct rte_crypto_op *op = user_data;
193 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
194 			RTE_CRYPTO_OP_STATUS_ERROR;
195 }
196 
197 static struct crypto_testsuite_params testsuite_params = { NULL };
198 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
199 static struct crypto_unittest_params unittest_params;
200 
201 int
202 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
203 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
204 		uint8_t len_in_bits, uint8_t cipher_iv_len)
205 {
206 	struct rte_crypto_sym_op *sop = op->sym;
207 	struct rte_crypto_op *ret_op = NULL;
208 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
209 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
210 	union rte_crypto_sym_ofs ofs;
211 	struct rte_crypto_sym_vec vec;
212 	struct rte_crypto_sgl sgl, dest_sgl;
213 	uint32_t max_len;
214 	union rte_cryptodev_session_ctx sess;
215 	uint64_t auth_end_iova;
216 	uint32_t count = 0;
217 	struct rte_crypto_raw_dp_ctx *ctx;
218 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
219 			auth_len = 0;
220 	int32_t n;
221 	uint32_t n_success;
222 	int ctx_service_size;
223 	int32_t status = 0;
224 	int enqueue_status, dequeue_status;
225 	struct crypto_unittest_params *ut_params = &unittest_params;
226 	int is_sgl = sop->m_src->nb_segs > 1;
227 	int ret = TEST_SUCCESS, is_oop = 0;
228 
229 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
230 	if (ctx_service_size < 0)
231 		return TEST_SKIPPED;
232 
233 	ctx = malloc(ctx_service_size);
234 	if (ctx == NULL)
235 		return TEST_FAILED;
236 
237 	/* Both are enums, setting crypto_sess will suit any session type */
238 	sess.crypto_sess = op->sym->session;
239 
240 	ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
241 	if (ret == -ENOTSUP) {
242 		ret = TEST_SKIPPED;
243 		goto exit;
244 	} else if (ret) {
245 		ret = TEST_FAILED;
246 		goto exit;
247 	}
248 
249 	cipher_iv.iova = 0;
250 	cipher_iv.va = NULL;
251 	aad_auth_iv.iova = 0;
252 	aad_auth_iv.va = NULL;
253 	digest.iova = 0;
254 	digest.va = NULL;
255 	sgl.vec = data_vec;
256 	vec.num = 1;
257 	vec.src_sgl = &sgl;
258 	vec.iv = &cipher_iv;
259 	vec.digest = &digest;
260 	vec.aad = &aad_auth_iv;
261 	vec.status = &status;
262 
263 	ofs.raw = 0;
264 
265 	if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
266 		is_oop = 1;
267 
268 	if (is_cipher && is_auth) {
269 		cipher_offset = sop->cipher.data.offset;
270 		cipher_len = sop->cipher.data.length;
271 		auth_offset = sop->auth.data.offset;
272 		auth_len = sop->auth.data.length;
273 		max_len = RTE_MAX(cipher_offset + cipher_len,
274 				auth_offset + auth_len);
275 		if (len_in_bits) {
276 			max_len = max_len >> 3;
277 			cipher_offset = cipher_offset >> 3;
278 			auth_offset = auth_offset >> 3;
279 			cipher_len = cipher_len >> 3;
280 			auth_len = auth_len >> 3;
281 		}
282 		ofs.ofs.cipher.head = cipher_offset;
283 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
284 		ofs.ofs.auth.head = auth_offset;
285 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
286 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
287 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
288 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
289 				op, void *, IV_OFFSET + cipher_iv_len);
290 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
291 				cipher_iv_len);
292 		digest.va = (void *)sop->auth.digest.data;
293 		digest.iova = sop->auth.digest.phys_addr;
294 
295 		if (is_sgl) {
296 			uint32_t remaining_off = auth_offset + auth_len;
297 			struct rte_mbuf *sgl_buf = sop->m_src;
298 			if (is_oop)
299 				sgl_buf = sop->m_dst;
300 
301 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
302 					&& sgl_buf->next != NULL) {
303 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
304 				sgl_buf = sgl_buf->next;
305 			}
306 
307 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
308 				sgl_buf, remaining_off);
309 		} else {
310 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
311 							 auth_offset + auth_len;
312 		}
313 		/* Then check if digest-encrypted conditions are met */
314 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
315 				(digest.iova == auth_end_iova) && is_sgl)
316 			max_len = RTE_MAX(max_len,
317 				auth_offset + auth_len +
318 				ut_params->auth_xform.auth.digest_length);
319 
320 	} else if (is_cipher) {
321 		cipher_offset = sop->cipher.data.offset;
322 		cipher_len = sop->cipher.data.length;
323 		max_len = cipher_len + cipher_offset;
324 		if (len_in_bits) {
325 			max_len = max_len >> 3;
326 			cipher_offset = cipher_offset >> 3;
327 			cipher_len = cipher_len >> 3;
328 		}
329 		ofs.ofs.cipher.head = cipher_offset;
330 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
331 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
332 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
333 
334 	} else if (is_auth) {
335 		auth_offset = sop->auth.data.offset;
336 		auth_len = sop->auth.data.length;
337 		max_len = auth_len + auth_offset;
338 		if (len_in_bits) {
339 			max_len = max_len >> 3;
340 			auth_offset = auth_offset >> 3;
341 			auth_len = auth_len >> 3;
342 		}
343 		ofs.ofs.auth.head = auth_offset;
344 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
345 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
346 				op, void *, IV_OFFSET + cipher_iv_len);
347 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
348 				cipher_iv_len);
349 		digest.va = (void *)sop->auth.digest.data;
350 		digest.iova = sop->auth.digest.phys_addr;
351 
352 	} else { /* aead */
353 		cipher_offset = sop->aead.data.offset;
354 		cipher_len = sop->aead.data.length;
355 		max_len = cipher_len + cipher_offset;
356 		if (len_in_bits) {
357 			max_len = max_len >> 3;
358 			cipher_offset = cipher_offset >> 3;
359 			cipher_len = cipher_len >> 3;
360 		}
361 		ofs.ofs.cipher.head = cipher_offset;
362 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
363 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
364 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
365 		aad_auth_iv.va = (void *)sop->aead.aad.data;
366 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
367 		digest.va = (void *)sop->aead.digest.data;
368 		digest.iova = sop->aead.digest.phys_addr;
369 	}
370 
371 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
372 			data_vec, RTE_DIM(data_vec));
373 	if (n < 0 || n > sop->m_src->nb_segs) {
374 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
375 		goto exit;
376 	}
377 
378 	sgl.num = n;
379 	/* Out of place */
380 	if (is_oop) {
381 		dest_sgl.vec = dest_data_vec;
382 		vec.dest_sgl = &dest_sgl;
383 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
384 				dest_data_vec, RTE_DIM(dest_data_vec));
385 		if (n < 0 || n > sop->m_dst->nb_segs) {
386 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
387 			goto exit;
388 		}
389 		dest_sgl.num = n;
390 	} else
391 		vec.dest_sgl = NULL;
392 
393 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
394 			&enqueue_status) < 1) {
395 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
396 		goto exit;
397 	}
398 
399 	if (enqueue_status == 0) {
400 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
401 		if (status < 0) {
402 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
403 			goto exit;
404 		}
405 	} else if (enqueue_status < 0) {
406 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
407 		goto exit;
408 	}
409 
410 	n = n_success = 0;
411 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
412 		n = rte_cryptodev_raw_dequeue_burst(ctx,
413 			NULL, 1, post_process_raw_dp_op,
414 				(void **)&ret_op, 0, &n_success,
415 				&dequeue_status);
416 		if (dequeue_status < 0) {
417 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
418 			goto exit;
419 		}
420 		if (n == 0)
421 			rte_pause();
422 	}
423 
424 	if (n == 1 && dequeue_status == 0) {
425 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
426 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
427 			goto exit;
428 		}
429 	}
430 
431 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
432 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
433 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
434 					RTE_CRYPTO_OP_STATUS_SUCCESS;
435 
436 exit:
437 	free(ctx);
438 	return ret;
439 }
440 
441 static void
442 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
443 {
444 	int32_t n, st;
445 	struct rte_crypto_sym_op *sop;
446 	union rte_crypto_sym_ofs ofs;
447 	struct rte_crypto_sgl sgl;
448 	struct rte_crypto_sym_vec symvec;
449 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
450 	struct rte_crypto_vec vec[UINT8_MAX];
451 
452 	sop = op->sym;
453 
454 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
455 		sop->aead.data.length, vec, RTE_DIM(vec));
456 
457 	if (n < 0 || n != sop->m_src->nb_segs) {
458 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
459 		return;
460 	}
461 
462 	sgl.vec = vec;
463 	sgl.num = n;
464 	symvec.src_sgl = &sgl;
465 	symvec.iv = &iv_ptr;
466 	symvec.digest = &digest_ptr;
467 	symvec.aad = &aad_ptr;
468 	symvec.status = &st;
469 	symvec.num = 1;
470 
471 	/* for CPU crypto the IOVA address is not required */
472 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
473 	digest_ptr.va = (void *)sop->aead.digest.data;
474 	aad_ptr.va = (void *)sop->aead.aad.data;
475 
476 	ofs.raw = 0;
477 
478 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
479 		&symvec);
480 
481 	if (n != 1)
482 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
483 	else
484 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
485 }
486 
487 static void
488 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
489 {
490 	int32_t n, st;
491 	struct rte_crypto_sym_op *sop;
492 	union rte_crypto_sym_ofs ofs;
493 	struct rte_crypto_sgl sgl;
494 	struct rte_crypto_sym_vec symvec;
495 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
496 	struct rte_crypto_vec vec[UINT8_MAX];
497 
498 	sop = op->sym;
499 
500 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
501 		sop->auth.data.length, vec, RTE_DIM(vec));
502 
503 	if (n < 0 || n != sop->m_src->nb_segs) {
504 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
505 		return;
506 	}
507 
508 	sgl.vec = vec;
509 	sgl.num = n;
510 	symvec.src_sgl = &sgl;
511 	symvec.iv = &iv_ptr;
512 	symvec.digest = &digest_ptr;
513 	symvec.status = &st;
514 	symvec.num = 1;
515 
516 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
517 	digest_ptr.va = (void *)sop->auth.digest.data;
518 
519 	ofs.raw = 0;
520 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
521 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
522 		(sop->cipher.data.offset + sop->cipher.data.length);
523 
524 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
525 		&symvec);
526 
527 	if (n != 1)
528 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
529 	else
530 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
531 }
532 
533 static struct rte_crypto_op *
534 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
535 {
536 
537 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
538 
539 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
540 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
541 		return NULL;
542 	}
543 
544 	op = NULL;
545 
546 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
547 		rte_pause();
548 
549 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
550 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
551 		return NULL;
552 	}
553 
554 	return op;
555 }
556 
557 static int
558 testsuite_setup(void)
559 {
560 	struct crypto_testsuite_params *ts_params = &testsuite_params;
561 	struct rte_cryptodev_info info;
562 	uint32_t i = 0, nb_devs, dev_id;
563 	uint16_t qp_id;
564 
565 	memset(ts_params, 0, sizeof(*ts_params));
566 
567 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
568 	if (ts_params->mbuf_pool == NULL) {
569 		/* Not already created so create */
570 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
571 				"CRYPTO_MBUFPOOL",
572 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
573 				rte_socket_id());
574 		if (ts_params->mbuf_pool == NULL) {
575 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
576 			return TEST_FAILED;
577 		}
578 	}
579 
580 	ts_params->large_mbuf_pool = rte_mempool_lookup(
581 			"CRYPTO_LARGE_MBUFPOOL");
582 	if (ts_params->large_mbuf_pool == NULL) {
583 		/* Not already created so create */
584 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
585 				"CRYPTO_LARGE_MBUFPOOL",
586 				1, 0, 0, UINT16_MAX,
587 				rte_socket_id());
588 		if (ts_params->large_mbuf_pool == NULL) {
589 			RTE_LOG(ERR, USER1,
590 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
591 			return TEST_FAILED;
592 		}
593 	}
594 
595 	ts_params->op_mpool = rte_crypto_op_pool_create(
596 			"MBUF_CRYPTO_SYM_OP_POOL",
597 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
598 			NUM_MBUFS, MBUF_CACHE_SIZE,
599 			DEFAULT_NUM_XFORMS *
600 			sizeof(struct rte_crypto_sym_xform) +
601 			MAXIMUM_IV_LENGTH,
602 			rte_socket_id());
603 	if (ts_params->op_mpool == NULL) {
604 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
605 		return TEST_FAILED;
606 	}
607 
608 	nb_devs = rte_cryptodev_count();
609 	if (nb_devs < 1) {
610 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
611 		return TEST_SKIPPED;
612 	}
613 
614 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
615 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
616 				rte_cryptodev_driver_name_get(gbl_driver_id));
617 		return TEST_SKIPPED;
618 	}
619 
620 	/* Create list of valid crypto devs */
621 	for (i = 0; i < nb_devs; i++) {
622 		rte_cryptodev_info_get(i, &info);
623 		if (info.driver_id == gbl_driver_id)
624 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
625 	}
626 
627 	if (ts_params->valid_dev_count < 1)
628 		return TEST_FAILED;
629 
630 	/* Set up all the qps on the first of the valid devices found */
631 
632 	dev_id = ts_params->valid_devs[0];
633 
634 	rte_cryptodev_info_get(dev_id, &info);
635 
636 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
637 	ts_params->conf.socket_id = SOCKET_ID_ANY;
638 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
639 
640 	unsigned int session_size =
641 		rte_cryptodev_sym_get_private_session_size(dev_id);
642 
643 #ifdef RTE_LIB_SECURITY
644 	unsigned int security_session_size = rte_security_session_get_size(
645 			rte_cryptodev_get_sec_ctx(dev_id));
646 
647 	if (session_size < security_session_size)
648 		session_size = security_session_size;
649 #endif
650 	/*
651 	 * Create mempool with maximum number of sessions.
652 	 */
653 	if (info.sym.max_nb_sessions != 0 &&
654 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
655 		RTE_LOG(ERR, USER1, "Device does not support "
656 				"at least %u sessions\n",
657 				MAX_NB_SESSIONS);
658 		return TEST_FAILED;
659 	}
660 
661 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
662 			"test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
663 			SOCKET_ID_ANY);
664 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
665 			"session mempool allocation failed");
666 
667 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
668 			&ts_params->conf),
669 			"Failed to configure cryptodev %u with %u qps",
670 			dev_id, ts_params->conf.nb_queue_pairs);
671 
672 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
673 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
674 
675 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
676 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
677 			dev_id, qp_id, &ts_params->qp_conf,
678 			rte_cryptodev_socket_id(dev_id)),
679 			"Failed to setup queue pair %u on cryptodev %u",
680 			qp_id, dev_id);
681 	}
682 
683 	return TEST_SUCCESS;
684 }
685 
686 static void
687 testsuite_teardown(void)
688 {
689 	struct crypto_testsuite_params *ts_params = &testsuite_params;
690 	int res;
691 
692 	if (ts_params->mbuf_pool != NULL) {
693 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
694 		rte_mempool_avail_count(ts_params->mbuf_pool));
695 	}
696 
697 	if (ts_params->op_mpool != NULL) {
698 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
699 		rte_mempool_avail_count(ts_params->op_mpool));
700 	}
701 
702 	if (ts_params->session_mpool != NULL) {
703 		rte_mempool_free(ts_params->session_mpool);
704 		ts_params->session_mpool = NULL;
705 	}
706 
707 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
708 	if (res)
709 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
710 }
711 
712 static int
713 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
714 		const int *algs, uint16_t num_algs)
715 {
716 	uint8_t dev_id = testsuite_params.valid_devs[0];
717 	bool some_alg_supported = FALSE;
718 	uint16_t i;
719 
720 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
721 		struct rte_cryptodev_sym_capability_idx alg = {
722 			type, {algs[i]}
723 		};
724 		if (rte_cryptodev_sym_capability_get(dev_id,
725 				&alg) != NULL)
726 			some_alg_supported = TRUE;
727 	}
728 	if (!some_alg_supported)
729 		return TEST_SKIPPED;
730 
731 	return 0;
732 }
733 
734 int
735 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
736 		uint16_t num_ciphers)
737 {
738 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
739 			(const int *) ciphers, num_ciphers);
740 }
741 
742 int
743 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
744 		uint16_t num_auths)
745 {
746 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
747 			(const int *) auths, num_auths);
748 }
749 
750 int
751 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
752 		uint16_t num_aeads)
753 {
754 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
755 			(const int *) aeads, num_aeads);
756 }
757 
758 static int
759 null_testsuite_setup(void)
760 {
761 	struct crypto_testsuite_params *ts_params = &testsuite_params;
762 	uint8_t dev_id = ts_params->valid_devs[0];
763 	struct rte_cryptodev_info dev_info;
764 	const enum rte_crypto_cipher_algorithm ciphers[] = {
765 		RTE_CRYPTO_CIPHER_NULL
766 	};
767 	const enum rte_crypto_auth_algorithm auths[] = {
768 		RTE_CRYPTO_AUTH_NULL
769 	};
770 
771 	rte_cryptodev_info_get(dev_id, &dev_info);
772 
773 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
774 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
775 				"testsuite not met\n");
776 		return TEST_SKIPPED;
777 	}
778 
779 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
780 			&& check_auth_capabilities_supported(auths,
781 			RTE_DIM(auths)) != 0) {
782 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
783 				"testsuite not met\n");
784 		return TEST_SKIPPED;
785 	}
786 
787 	return 0;
788 }
789 
790 static int
791 crypto_gen_testsuite_setup(void)
792 {
793 	struct crypto_testsuite_params *ts_params = &testsuite_params;
794 	uint8_t dev_id = ts_params->valid_devs[0];
795 	struct rte_cryptodev_info dev_info;
796 
797 	rte_cryptodev_info_get(dev_id, &dev_info);
798 
799 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
800 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
801 				"testsuite not met\n");
802 		return TEST_SKIPPED;
803 	}
804 
805 	return 0;
806 }
807 
808 #ifdef RTE_LIB_SECURITY
809 static int
810 ipsec_proto_testsuite_setup(void)
811 {
812 	struct crypto_testsuite_params *ts_params = &testsuite_params;
813 	struct crypto_unittest_params *ut_params = &unittest_params;
814 	struct rte_cryptodev_info dev_info;
815 	int ret = 0;
816 
817 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
818 
819 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
820 		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
821 				"testsuite not met\n");
822 		return TEST_SKIPPED;
823 	}
824 
825 	/* Reconfigure to enable security */
826 	ret = dev_configure_and_start(0);
827 	if (ret != TEST_SUCCESS)
828 		return ret;
829 
830 	/* Set action type */
831 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
832 
833 	if (security_proto_supported(
834 			RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
835 			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
836 		RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
837 				"test not met\n");
838 		ret = TEST_SKIPPED;
839 	}
840 
841 	test_ipsec_alg_list_populate();
842 	test_ipsec_ah_alg_list_populate();
843 
844 	/*
845 	 * Stop the device. Device would be started again by individual test
846 	 * case setup routine.
847 	 */
848 	rte_cryptodev_stop(ts_params->valid_devs[0]);
849 
850 	return ret;
851 }
852 
853 static int
854 pdcp_proto_testsuite_setup(void)
855 {
856 	struct crypto_testsuite_params *ts_params = &testsuite_params;
857 	uint8_t dev_id = ts_params->valid_devs[0];
858 	struct rte_cryptodev_info dev_info;
859 	const enum rte_crypto_cipher_algorithm ciphers[] = {
860 		RTE_CRYPTO_CIPHER_NULL,
861 		RTE_CRYPTO_CIPHER_AES_CTR,
862 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
863 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
864 	};
865 	const enum rte_crypto_auth_algorithm auths[] = {
866 		RTE_CRYPTO_AUTH_NULL,
867 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
868 		RTE_CRYPTO_AUTH_AES_CMAC,
869 		RTE_CRYPTO_AUTH_ZUC_EIA3
870 	};
871 
872 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
873 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
874 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
875 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
876 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
877 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
878 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
879 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
880 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
881 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
882 
883 	rte_cryptodev_info_get(dev_id, &dev_info);
884 
885 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
886 			!(dev_info.feature_flags &
887 			RTE_CRYPTODEV_FF_SECURITY)) {
888 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
889 				"testsuite not met\n");
890 		return TEST_SKIPPED;
891 	}
892 
893 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
894 			&& check_auth_capabilities_supported(auths,
895 			RTE_DIM(auths)) != 0) {
896 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
897 				"testsuite not met\n");
898 		return TEST_SKIPPED;
899 	}
900 
901 	return 0;
902 }
903 
904 static int
905 docsis_proto_testsuite_setup(void)
906 {
907 	struct crypto_testsuite_params *ts_params = &testsuite_params;
908 	uint8_t dev_id = ts_params->valid_devs[0];
909 	struct rte_cryptodev_info dev_info;
910 	const enum rte_crypto_cipher_algorithm ciphers[] = {
911 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
912 	};
913 
914 	rte_cryptodev_info_get(dev_id, &dev_info);
915 
916 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
917 			!(dev_info.feature_flags &
918 			RTE_CRYPTODEV_FF_SECURITY)) {
919 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
920 				"Proto testsuite not met\n");
921 		return TEST_SKIPPED;
922 	}
923 
924 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
925 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
926 				"testsuite not met\n");
927 		return TEST_SKIPPED;
928 	}
929 
930 	return 0;
931 }
932 #endif
933 
934 static int
935 aes_ccm_auth_testsuite_setup(void)
936 {
937 	struct crypto_testsuite_params *ts_params = &testsuite_params;
938 	uint8_t dev_id = ts_params->valid_devs[0];
939 	struct rte_cryptodev_info dev_info;
940 	const enum rte_crypto_aead_algorithm aeads[] = {
941 		RTE_CRYPTO_AEAD_AES_CCM
942 	};
943 
944 	rte_cryptodev_info_get(dev_id, &dev_info);
945 
946 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
947 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
948 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
949 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
950 				"testsuite not met\n");
951 		return TEST_SKIPPED;
952 	}
953 
954 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
955 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
956 				"testsuite not met\n");
957 		return TEST_SKIPPED;
958 	}
959 
960 	return 0;
961 }
962 
963 static int
964 aes_gcm_auth_testsuite_setup(void)
965 {
966 	struct crypto_testsuite_params *ts_params = &testsuite_params;
967 	uint8_t dev_id = ts_params->valid_devs[0];
968 	struct rte_cryptodev_info dev_info;
969 	const enum rte_crypto_aead_algorithm aeads[] = {
970 		RTE_CRYPTO_AEAD_AES_GCM
971 	};
972 
973 	rte_cryptodev_info_get(dev_id, &dev_info);
974 
975 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
976 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
977 				"testsuite not met\n");
978 		return TEST_SKIPPED;
979 	}
980 
981 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
982 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
983 				"testsuite not met\n");
984 		return TEST_SKIPPED;
985 	}
986 
987 	return 0;
988 }
989 
990 static int
991 aes_gmac_auth_testsuite_setup(void)
992 {
993 	struct crypto_testsuite_params *ts_params = &testsuite_params;
994 	uint8_t dev_id = ts_params->valid_devs[0];
995 	struct rte_cryptodev_info dev_info;
996 	const enum rte_crypto_auth_algorithm auths[] = {
997 		RTE_CRYPTO_AUTH_AES_GMAC
998 	};
999 
1000 	rte_cryptodev_info_get(dev_id, &dev_info);
1001 
1002 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1003 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1004 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1005 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1006 				"testsuite not met\n");
1007 		return TEST_SKIPPED;
1008 	}
1009 
1010 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1011 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1012 				"testsuite not met\n");
1013 		return TEST_SKIPPED;
1014 	}
1015 
1016 	return 0;
1017 }
1018 
1019 static int
1020 chacha20_poly1305_testsuite_setup(void)
1021 {
1022 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1023 	uint8_t dev_id = ts_params->valid_devs[0];
1024 	struct rte_cryptodev_info dev_info;
1025 	const enum rte_crypto_aead_algorithm aeads[] = {
1026 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1027 	};
1028 
1029 	rte_cryptodev_info_get(dev_id, &dev_info);
1030 
1031 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1032 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1033 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1034 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1035 				"Chacha20-Poly1305 testsuite not met\n");
1036 		return TEST_SKIPPED;
1037 	}
1038 
1039 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1040 		RTE_LOG(INFO, USER1, "Capability requirements for "
1041 				"Chacha20-Poly1305 testsuite not met\n");
1042 		return TEST_SKIPPED;
1043 	}
1044 
1045 	return 0;
1046 }
1047 
1048 static int
1049 snow3g_testsuite_setup(void)
1050 {
1051 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1052 	uint8_t dev_id = ts_params->valid_devs[0];
1053 	struct rte_cryptodev_info dev_info;
1054 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1055 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1056 
1057 	};
1058 	const enum rte_crypto_auth_algorithm auths[] = {
1059 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1060 	};
1061 
1062 	rte_cryptodev_info_get(dev_id, &dev_info);
1063 
1064 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1065 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1066 				"testsuite not met\n");
1067 		return TEST_SKIPPED;
1068 	}
1069 
1070 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1071 			&& check_auth_capabilities_supported(auths,
1072 			RTE_DIM(auths)) != 0) {
1073 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1074 				"testsuite not met\n");
1075 		return TEST_SKIPPED;
1076 	}
1077 
1078 	return 0;
1079 }
1080 
1081 static int
1082 zuc_testsuite_setup(void)
1083 {
1084 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1085 	uint8_t dev_id = ts_params->valid_devs[0];
1086 	struct rte_cryptodev_info dev_info;
1087 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1088 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1089 	};
1090 	const enum rte_crypto_auth_algorithm auths[] = {
1091 		RTE_CRYPTO_AUTH_ZUC_EIA3
1092 	};
1093 
1094 	rte_cryptodev_info_get(dev_id, &dev_info);
1095 
1096 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1097 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1098 				"testsuite not met\n");
1099 		return TEST_SKIPPED;
1100 	}
1101 
1102 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1103 			&& check_auth_capabilities_supported(auths,
1104 			RTE_DIM(auths)) != 0) {
1105 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1106 				"testsuite not met\n");
1107 		return TEST_SKIPPED;
1108 	}
1109 
1110 	return 0;
1111 }
1112 
1113 static int
1114 hmac_md5_auth_testsuite_setup(void)
1115 {
1116 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1117 	uint8_t dev_id = ts_params->valid_devs[0];
1118 	struct rte_cryptodev_info dev_info;
1119 	const enum rte_crypto_auth_algorithm auths[] = {
1120 		RTE_CRYPTO_AUTH_MD5_HMAC
1121 	};
1122 
1123 	rte_cryptodev_info_get(dev_id, &dev_info);
1124 
1125 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1126 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1127 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1128 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1129 				"Auth testsuite not met\n");
1130 		return TEST_SKIPPED;
1131 	}
1132 
1133 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1134 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1135 				"testsuite not met\n");
1136 		return TEST_SKIPPED;
1137 	}
1138 
1139 	return 0;
1140 }
1141 
1142 static int
1143 kasumi_testsuite_setup(void)
1144 {
1145 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1146 	uint8_t dev_id = ts_params->valid_devs[0];
1147 	struct rte_cryptodev_info dev_info;
1148 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1149 		RTE_CRYPTO_CIPHER_KASUMI_F8
1150 	};
1151 	const enum rte_crypto_auth_algorithm auths[] = {
1152 		RTE_CRYPTO_AUTH_KASUMI_F9
1153 	};
1154 
1155 	rte_cryptodev_info_get(dev_id, &dev_info);
1156 
1157 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1158 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1159 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1160 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1161 				"testsuite not met\n");
1162 		return TEST_SKIPPED;
1163 	}
1164 
1165 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1166 			&& check_auth_capabilities_supported(auths,
1167 			RTE_DIM(auths)) != 0) {
1168 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1169 				"testsuite not met\n");
1170 		return TEST_SKIPPED;
1171 	}
1172 
1173 	return 0;
1174 }
1175 
1176 static int
1177 negative_aes_gcm_testsuite_setup(void)
1178 {
1179 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1180 	uint8_t dev_id = ts_params->valid_devs[0];
1181 	struct rte_cryptodev_info dev_info;
1182 	const enum rte_crypto_aead_algorithm aeads[] = {
1183 		RTE_CRYPTO_AEAD_AES_GCM
1184 	};
1185 
1186 	rte_cryptodev_info_get(dev_id, &dev_info);
1187 
1188 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1189 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1190 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1191 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1192 				"AES GCM testsuite not met\n");
1193 		return TEST_SKIPPED;
1194 	}
1195 
1196 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1197 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1198 				"AES GCM testsuite not met\n");
1199 		return TEST_SKIPPED;
1200 	}
1201 
1202 	return 0;
1203 }
1204 
1205 static int
1206 negative_aes_gmac_testsuite_setup(void)
1207 {
1208 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1209 	uint8_t dev_id = ts_params->valid_devs[0];
1210 	struct rte_cryptodev_info dev_info;
1211 	const enum rte_crypto_auth_algorithm auths[] = {
1212 		RTE_CRYPTO_AUTH_AES_GMAC
1213 	};
1214 
1215 	rte_cryptodev_info_get(dev_id, &dev_info);
1216 
1217 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1218 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1219 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1220 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1221 				"AES GMAC testsuite not met\n");
1222 		return TEST_SKIPPED;
1223 	}
1224 
1225 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1226 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1227 				"AES GMAC testsuite not met\n");
1228 		return TEST_SKIPPED;
1229 	}
1230 
1231 	return 0;
1232 }
1233 
1234 static int
1235 mixed_cipher_hash_testsuite_setup(void)
1236 {
1237 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1238 	uint8_t dev_id = ts_params->valid_devs[0];
1239 	struct rte_cryptodev_info dev_info;
1240 	uint64_t feat_flags;
1241 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1242 		RTE_CRYPTO_CIPHER_NULL,
1243 		RTE_CRYPTO_CIPHER_AES_CTR,
1244 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1245 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1246 	};
1247 	const enum rte_crypto_auth_algorithm auths[] = {
1248 		RTE_CRYPTO_AUTH_NULL,
1249 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1250 		RTE_CRYPTO_AUTH_AES_CMAC,
1251 		RTE_CRYPTO_AUTH_ZUC_EIA3
1252 	};
1253 
1254 	rte_cryptodev_info_get(dev_id, &dev_info);
1255 	feat_flags = dev_info.feature_flags;
1256 
1257 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1258 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1259 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1260 				"Cipher Hash testsuite not met\n");
1261 		return TEST_SKIPPED;
1262 	}
1263 
1264 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1265 			&& check_auth_capabilities_supported(auths,
1266 			RTE_DIM(auths)) != 0) {
1267 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1268 				"Cipher Hash testsuite not met\n");
1269 		return TEST_SKIPPED;
1270 	}
1271 
1272 	return 0;
1273 }
1274 
1275 static int
1276 esn_testsuite_setup(void)
1277 {
1278 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1279 	uint8_t dev_id = ts_params->valid_devs[0];
1280 	struct rte_cryptodev_info dev_info;
1281 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1282 		RTE_CRYPTO_CIPHER_AES_CBC
1283 	};
1284 	const enum rte_crypto_auth_algorithm auths[] = {
1285 		RTE_CRYPTO_AUTH_SHA1_HMAC
1286 	};
1287 
1288 	rte_cryptodev_info_get(dev_id, &dev_info);
1289 
1290 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1291 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1292 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1293 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1294 				"testsuite not met\n");
1295 		return TEST_SKIPPED;
1296 	}
1297 
1298 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1299 			&& check_auth_capabilities_supported(auths,
1300 			RTE_DIM(auths)) != 0) {
1301 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1302 				"testsuite not met\n");
1303 		return TEST_SKIPPED;
1304 	}
1305 
1306 	return 0;
1307 }
1308 
1309 static int
1310 multi_session_testsuite_setup(void)
1311 {
1312 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1313 	uint8_t dev_id = ts_params->valid_devs[0];
1314 	struct rte_cryptodev_info dev_info;
1315 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1316 		RTE_CRYPTO_CIPHER_AES_CBC
1317 	};
1318 	const enum rte_crypto_auth_algorithm auths[] = {
1319 		RTE_CRYPTO_AUTH_SHA512_HMAC
1320 	};
1321 
1322 	rte_cryptodev_info_get(dev_id, &dev_info);
1323 
1324 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1325 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1326 				"Session testsuite not met\n");
1327 		return TEST_SKIPPED;
1328 	}
1329 
1330 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1331 			&& check_auth_capabilities_supported(auths,
1332 			RTE_DIM(auths)) != 0) {
1333 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1334 				"Session testsuite not met\n");
1335 		return TEST_SKIPPED;
1336 	}
1337 
1338 	return 0;
1339 }
1340 
1341 static int
1342 negative_hmac_sha1_testsuite_setup(void)
1343 {
1344 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1345 	uint8_t dev_id = ts_params->valid_devs[0];
1346 	struct rte_cryptodev_info dev_info;
1347 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1348 		RTE_CRYPTO_CIPHER_AES_CBC
1349 	};
1350 	const enum rte_crypto_auth_algorithm auths[] = {
1351 		RTE_CRYPTO_AUTH_SHA1_HMAC
1352 	};
1353 
1354 	rte_cryptodev_info_get(dev_id, &dev_info);
1355 
1356 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1357 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1358 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1359 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1360 				"HMAC SHA1 testsuite not met\n");
1361 		return TEST_SKIPPED;
1362 	}
1363 
1364 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1365 			&& check_auth_capabilities_supported(auths,
1366 			RTE_DIM(auths)) != 0) {
1367 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1368 				"HMAC SHA1 testsuite not met\n");
1369 		return TEST_SKIPPED;
1370 	}
1371 
1372 	return 0;
1373 }
1374 
1375 static int
1376 dev_configure_and_start(uint64_t ff_disable)
1377 {
1378 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1379 	struct crypto_unittest_params *ut_params = &unittest_params;
1380 
1381 	uint16_t qp_id;
1382 
1383 	/* Clear unit test parameters before running test */
1384 	memset(ut_params, 0, sizeof(*ut_params));
1385 
1386 	/* Reconfigure device to default parameters */
1387 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1388 	ts_params->conf.ff_disable = ff_disable;
1389 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1390 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1391 
1392 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1393 			&ts_params->conf),
1394 			"Failed to configure cryptodev %u",
1395 			ts_params->valid_devs[0]);
1396 
1397 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1398 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1399 			ts_params->valid_devs[0], qp_id,
1400 			&ts_params->qp_conf,
1401 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1402 			"Failed to setup queue pair %u on cryptodev %u",
1403 			qp_id, ts_params->valid_devs[0]);
1404 	}
1405 
1406 
1407 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1408 
1409 	/* Start the device */
1410 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1411 			"Failed to start cryptodev %u",
1412 			ts_params->valid_devs[0]);
1413 
1414 	return TEST_SUCCESS;
1415 }
1416 
1417 int
1418 ut_setup(void)
1419 {
1420 	/* Configure and start the device with security feature disabled */
1421 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1422 }
1423 
1424 static int
1425 ut_setup_security(void)
1426 {
1427 	/* Configure and start the device with no features disabled */
1428 	return dev_configure_and_start(0);
1429 }
1430 
1431 static int
1432 ut_setup_security_rx_inject(void)
1433 {
1434 	struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1435 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1436 	struct rte_eth_conf port_conf = {
1437 		.rxmode = {
1438 			.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1439 				    RTE_ETH_RX_OFFLOAD_SECURITY,
1440 		},
1441 		.txmode = {
1442 			.offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1443 		},
1444 		.lpbk_mode = 1,  /* Enable loopback */
1445 	};
1446 	struct rte_cryptodev_info dev_info;
1447 	struct rte_eth_rxconf rx_conf = {
1448 		.rx_thresh = {
1449 			.pthresh = 8,
1450 			.hthresh = 8,
1451 			.wthresh = 8,
1452 		},
1453 		.rx_free_thresh = 32,
1454 	};
1455 	uint16_t nb_ports;
1456 	void *sec_ctx;
1457 	int ret;
1458 
1459 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1460 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1461 	    !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1462 		RTE_LOG(INFO, USER1,
1463 			"Feature requirements for IPsec Rx inject test case not met\n");
1464 		return TEST_SKIPPED;
1465 	}
1466 
1467 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1468 	if (sec_ctx == NULL)
1469 		return TEST_SKIPPED;
1470 
1471 	nb_ports = rte_eth_dev_count_avail();
1472 	if (nb_ports == 0)
1473 		return TEST_SKIPPED;
1474 
1475 	ret = rte_eth_dev_configure(0 /* port_id */,
1476 				    1 /* nb_rx_queue */,
1477 				    0 /* nb_tx_queue */,
1478 				    &port_conf);
1479 	if (ret) {
1480 		printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1481 		return TEST_SKIPPED;
1482 	}
1483 
1484 	/* Rx queue setup */
1485 	ret = rte_eth_rx_queue_setup(0 /* port_id */,
1486 				     0 /* rx_queue_id */,
1487 				     1024 /* nb_rx_desc */,
1488 				     SOCKET_ID_ANY,
1489 				     &rx_conf,
1490 				     mbuf_pool);
1491 	if (ret) {
1492 		printf("Could not setup eth port 0 queue 0\n");
1493 		return TEST_SKIPPED;
1494 	}
1495 
1496 	ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1497 	if (ret) {
1498 		printf("Could not enable Rx inject offload");
1499 		return TEST_SKIPPED;
1500 	}
1501 
1502 	ret = rte_eth_dev_start(0);
1503 	if (ret) {
1504 		printf("Could not start ethdev");
1505 		return TEST_SKIPPED;
1506 	}
1507 
1508 	ret = rte_eth_promiscuous_enable(0);
1509 	if (ret) {
1510 		printf("Could not enable promiscuous mode");
1511 		return TEST_SKIPPED;
1512 	}
1513 
1514 	/* Configure and start cryptodev with no features disabled */
1515 	return dev_configure_and_start(0);
1516 }
1517 
1518 void
1519 ut_teardown(void)
1520 {
1521 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1522 	struct crypto_unittest_params *ut_params = &unittest_params;
1523 
1524 	/* free crypto session structure */
1525 #ifdef RTE_LIB_SECURITY
1526 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1527 		if (ut_params->sec_session) {
1528 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1529 						(ts_params->valid_devs[0]),
1530 						ut_params->sec_session);
1531 			ut_params->sec_session = NULL;
1532 		}
1533 	} else
1534 #endif
1535 	{
1536 		if (ut_params->sess) {
1537 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1538 					ut_params->sess);
1539 			ut_params->sess = NULL;
1540 		}
1541 	}
1542 
1543 	/* free crypto operation structure */
1544 	rte_crypto_op_free(ut_params->op);
1545 
1546 	/*
1547 	 * free mbuf - both obuf and ibuf are usually the same,
1548 	 * so check if they point at the same address is necessary,
1549 	 * to avoid freeing the mbuf twice.
1550 	 */
1551 	if (ut_params->obuf) {
1552 		rte_pktmbuf_free(ut_params->obuf);
1553 		if (ut_params->ibuf == ut_params->obuf)
1554 			ut_params->ibuf = 0;
1555 		ut_params->obuf = 0;
1556 	}
1557 	if (ut_params->ibuf) {
1558 		rte_pktmbuf_free(ut_params->ibuf);
1559 		ut_params->ibuf = 0;
1560 	}
1561 
1562 	if (ts_params->mbuf_pool != NULL)
1563 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1564 			rte_mempool_avail_count(ts_params->mbuf_pool));
1565 
1566 	/* Stop the device */
1567 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1568 }
1569 
1570 static void
1571 ut_teardown_rx_inject(void)
1572 {
1573 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1574 	void *sec_ctx;
1575 	int ret;
1576 
1577 	if  (rte_eth_dev_count_avail() != 0) {
1578 		ret = rte_eth_dev_reset(0);
1579 		if (ret)
1580 			printf("Could not reset eth port 0");
1581 
1582 	}
1583 
1584 	ut_teardown();
1585 
1586 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1587 	if (sec_ctx == NULL)
1588 		return;
1589 
1590 	ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1591 	if (ret) {
1592 		printf("Could not disable Rx inject offload");
1593 		return;
1594 	}
1595 }
1596 
1597 static int
1598 test_device_configure_invalid_dev_id(void)
1599 {
1600 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1601 	uint16_t dev_id, num_devs = 0;
1602 
1603 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1604 			"Need at least %d devices for test", 1);
1605 
1606 	/* valid dev_id values */
1607 	dev_id = ts_params->valid_devs[0];
1608 
1609 	/* Stop the device in case it's started so it can be configured */
1610 	rte_cryptodev_stop(dev_id);
1611 
1612 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1613 			"Failed test for rte_cryptodev_configure: "
1614 			"invalid dev_num %u", dev_id);
1615 
1616 	/* invalid dev_id values */
1617 	dev_id = num_devs;
1618 
1619 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1620 			"Failed test for rte_cryptodev_configure: "
1621 			"invalid dev_num %u", dev_id);
1622 
1623 	dev_id = 0xff;
1624 
1625 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1626 			"Failed test for rte_cryptodev_configure:"
1627 			"invalid dev_num %u", dev_id);
1628 
1629 	return TEST_SUCCESS;
1630 }
1631 
1632 static int
1633 test_device_configure_invalid_queue_pair_ids(void)
1634 {
1635 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1636 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1637 
1638 	/* Stop the device in case it's started so it can be configured */
1639 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1640 
1641 	/* valid - max value queue pairs */
1642 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1643 
1644 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1645 			&ts_params->conf),
1646 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1647 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1648 
1649 	/* valid - one queue pairs */
1650 	ts_params->conf.nb_queue_pairs = 1;
1651 
1652 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1653 			&ts_params->conf),
1654 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1655 			ts_params->valid_devs[0],
1656 			ts_params->conf.nb_queue_pairs);
1657 
1658 
1659 	/* invalid - zero queue pairs */
1660 	ts_params->conf.nb_queue_pairs = 0;
1661 
1662 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1663 			&ts_params->conf),
1664 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1665 			" invalid qps: %u",
1666 			ts_params->valid_devs[0],
1667 			ts_params->conf.nb_queue_pairs);
1668 
1669 
1670 	/* invalid - max value supported by field queue pairs */
1671 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1672 
1673 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1674 			&ts_params->conf),
1675 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1676 			" invalid qps: %u",
1677 			ts_params->valid_devs[0],
1678 			ts_params->conf.nb_queue_pairs);
1679 
1680 
1681 	/* invalid - max value + 1 queue pairs */
1682 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1683 
1684 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1685 			&ts_params->conf),
1686 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1687 			" invalid qps: %u",
1688 			ts_params->valid_devs[0],
1689 			ts_params->conf.nb_queue_pairs);
1690 
1691 	/* revert to original testsuite value */
1692 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1693 
1694 	return TEST_SUCCESS;
1695 }
1696 
1697 static int
1698 test_queue_pair_descriptor_setup(void)
1699 {
1700 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1701 	struct rte_cryptodev_qp_conf qp_conf = {
1702 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1703 	};
1704 	uint16_t qp_id;
1705 
1706 	/* Stop the device in case it's started so it can be configured */
1707 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1708 
1709 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1710 			&ts_params->conf),
1711 			"Failed to configure cryptodev %u",
1712 			ts_params->valid_devs[0]);
1713 
1714 	/*
1715 	 * Test various ring sizes on this device. memzones can't be
1716 	 * freed so are re-used if ring is released and re-created.
1717 	 */
1718 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1719 	qp_conf.mp_session = ts_params->session_mpool;
1720 
1721 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1722 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1723 				ts_params->valid_devs[0], qp_id, &qp_conf,
1724 				rte_cryptodev_socket_id(
1725 						ts_params->valid_devs[0])),
1726 				"Failed test for "
1727 				"rte_cryptodev_queue_pair_setup: num_inflights "
1728 				"%u on qp %u on cryptodev %u",
1729 				qp_conf.nb_descriptors, qp_id,
1730 				ts_params->valid_devs[0]);
1731 	}
1732 
1733 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1734 
1735 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1736 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1737 				ts_params->valid_devs[0], qp_id, &qp_conf,
1738 				rte_cryptodev_socket_id(
1739 						ts_params->valid_devs[0])),
1740 				"Failed test for"
1741 				" rte_cryptodev_queue_pair_setup: num_inflights"
1742 				" %u on qp %u on cryptodev %u",
1743 				qp_conf.nb_descriptors, qp_id,
1744 				ts_params->valid_devs[0]);
1745 	}
1746 
1747 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1748 
1749 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1750 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1751 				ts_params->valid_devs[0], qp_id, &qp_conf,
1752 				rte_cryptodev_socket_id(
1753 						ts_params->valid_devs[0])),
1754 				"Failed test for "
1755 				"rte_cryptodev_queue_pair_setup: num_inflights"
1756 				" %u on qp %u on cryptodev %u",
1757 				qp_conf.nb_descriptors, qp_id,
1758 				ts_params->valid_devs[0]);
1759 	}
1760 
1761 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1762 
1763 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1764 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1765 				ts_params->valid_devs[0], qp_id, &qp_conf,
1766 				rte_cryptodev_socket_id(
1767 						ts_params->valid_devs[0])),
1768 				"Failed test for"
1769 				" rte_cryptodev_queue_pair_setup:"
1770 				"num_inflights %u on qp %u on cryptodev %u",
1771 				qp_conf.nb_descriptors, qp_id,
1772 				ts_params->valid_devs[0]);
1773 	}
1774 
1775 	/* test invalid queue pair id */
1776 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1777 
1778 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1779 
1780 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1781 			ts_params->valid_devs[0],
1782 			qp_id, &qp_conf,
1783 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1784 			"Failed test for rte_cryptodev_queue_pair_setup:"
1785 			"invalid qp %u on cryptodev %u",
1786 			qp_id, ts_params->valid_devs[0]);
1787 
1788 	qp_id = 0xffff; /*invalid*/
1789 
1790 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1791 			ts_params->valid_devs[0],
1792 			qp_id, &qp_conf,
1793 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1794 			"Failed test for rte_cryptodev_queue_pair_setup:"
1795 			"invalid qp %u on cryptodev %u",
1796 			qp_id, ts_params->valid_devs[0]);
1797 
1798 	return TEST_SUCCESS;
1799 }
1800 
1801 /* ***** Plaintext data for tests ***** */
1802 
1803 const char catch_22_quote_1[] =
1804 		"There was only one catch and that was Catch-22, which "
1805 		"specified that a concern for one's safety in the face of "
1806 		"dangers that were real and immediate was the process of a "
1807 		"rational mind. Orr was crazy and could be grounded. All he "
1808 		"had to do was ask; and as soon as he did, he would no longer "
1809 		"be crazy and would have to fly more missions. Orr would be "
1810 		"crazy to fly more missions and sane if he didn't, but if he "
1811 		"was sane he had to fly them. If he flew them he was crazy "
1812 		"and didn't have to; but if he didn't want to he was sane and "
1813 		"had to. Yossarian was moved very deeply by the absolute "
1814 		"simplicity of this clause of Catch-22 and let out a "
1815 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1816 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1817 
1818 const char catch_22_quote[] =
1819 		"What a lousy earth! He wondered how many people were "
1820 		"destitute that same night even in his own prosperous country, "
1821 		"how many homes were shanties, how many husbands were drunk "
1822 		"and wives socked, and how many children were bullied, abused, "
1823 		"or abandoned. How many families hungered for food they could "
1824 		"not afford to buy? How many hearts were broken? How many "
1825 		"suicides would take place that same night, how many people "
1826 		"would go insane? How many cockroaches and landlords would "
1827 		"triumph? How many winners were losers, successes failures, "
1828 		"and rich men poor men? How many wise guys were stupid? How "
1829 		"many happy endings were unhappy endings? How many honest men "
1830 		"were liars, brave men cowards, loyal men traitors, how many "
1831 		"sainted men were corrupt, how many people in positions of "
1832 		"trust had sold their souls to bodyguards, how many had never "
1833 		"had souls? How many straight-and-narrow paths were crooked "
1834 		"paths? How many best families were worst families and how "
1835 		"many good people were bad people? When you added them all up "
1836 		"and then subtracted, you might be left with only the children, "
1837 		"and perhaps with Albert Einstein and an old violinist or "
1838 		"sculptor somewhere.";
1839 
1840 #define QUOTE_480_BYTES		(480)
1841 #define QUOTE_512_BYTES		(512)
1842 #define QUOTE_768_BYTES		(768)
1843 #define QUOTE_1024_BYTES	(1024)
1844 
1845 
1846 
1847 /* ***** SHA1 Hash Tests ***** */
1848 
1849 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1850 
1851 static uint8_t hmac_sha1_key[] = {
1852 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1853 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1854 	0xDE, 0xF4, 0xDE, 0xAD };
1855 
1856 /* ***** SHA224 Hash Tests ***** */
1857 
1858 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
1859 
1860 
1861 /* ***** AES-CBC Cipher Tests ***** */
1862 
1863 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
1864 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
1865 
1866 static uint8_t aes_cbc_key[] = {
1867 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1868 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1869 
1870 static uint8_t aes_cbc_iv[] = {
1871 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1872 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1873 
1874 
1875 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1876 
1877 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1878 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1879 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1880 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1881 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1882 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1883 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1884 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1885 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1886 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1887 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1888 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1889 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1890 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1891 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1892 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1893 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1894 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1895 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1896 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1897 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1898 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1899 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1900 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1901 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1902 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1903 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1904 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1905 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1906 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1907 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1908 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1909 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1910 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1911 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1912 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1913 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1914 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1915 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1916 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1917 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1918 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1919 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1920 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1921 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1922 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1923 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1924 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1925 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1926 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1927 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1928 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1929 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1930 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1931 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1932 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1933 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1934 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1935 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1936 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1937 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1938 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1939 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1940 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1941 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1942 };
1943 
1944 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1945 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1946 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1947 	0x18, 0x8c, 0x1d, 0x32
1948 };
1949 
1950 
1951 /* Multisession Vector context Test */
1952 /*Begin Session 0 */
1953 static uint8_t ms_aes_cbc_key0[] = {
1954 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1955 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1956 };
1957 
1958 static uint8_t ms_aes_cbc_iv0[] = {
1959 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1960 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1961 };
1962 
1963 static const uint8_t ms_aes_cbc_cipher0[] = {
1964 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1965 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1966 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1967 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1968 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1969 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1970 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1971 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1972 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1973 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1974 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1975 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1976 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1977 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1978 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1979 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1980 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1981 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1982 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1983 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1984 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1985 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1986 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1987 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1988 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1989 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1990 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1991 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1992 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1993 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1994 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1995 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1996 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1997 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1998 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1999 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2000 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2001 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2002 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2003 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2004 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2005 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2006 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2007 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2008 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2009 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2010 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2011 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2012 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2013 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2014 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2015 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2016 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2017 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2018 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2019 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2020 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2021 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2022 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2023 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2024 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2025 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2026 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2027 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2028 };
2029 
2030 
2031 static  uint8_t ms_hmac_key0[] = {
2032 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2033 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2034 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2035 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2036 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2037 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2038 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2039 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2040 };
2041 
2042 static const uint8_t ms_hmac_digest0[] = {
2043 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2044 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2045 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2046 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2047 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2048 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2049 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2050 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2051 		};
2052 
2053 /* End Session 0 */
2054 /* Begin session 1 */
2055 
2056 static  uint8_t ms_aes_cbc_key1[] = {
2057 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2058 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2059 };
2060 
2061 static  uint8_t ms_aes_cbc_iv1[] = {
2062 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2063 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2064 };
2065 
2066 static const uint8_t ms_aes_cbc_cipher1[] = {
2067 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2068 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2069 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2070 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2071 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2072 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2073 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2074 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2075 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2076 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2077 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2078 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2079 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2080 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2081 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2082 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2083 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2084 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2085 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2086 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2087 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2088 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2089 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2090 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2091 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2092 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2093 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2094 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2095 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2096 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2097 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2098 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2099 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2100 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2101 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2102 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2103 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2104 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2105 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2106 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2107 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2108 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2109 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2110 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2111 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2112 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2113 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2114 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2115 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2116 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2117 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2118 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2119 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2120 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2121 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2122 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2123 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2124 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2125 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2126 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2127 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2128 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2129 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2130 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2131 
2132 };
2133 
2134 static uint8_t ms_hmac_key1[] = {
2135 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2136 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2137 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2138 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2139 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2140 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2141 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2142 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2143 };
2144 
2145 static const uint8_t ms_hmac_digest1[] = {
2146 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2147 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2148 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2149 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2150 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2151 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2152 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2153 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2154 };
2155 /* End Session 1  */
2156 /* Begin Session 2 */
2157 static  uint8_t ms_aes_cbc_key2[] = {
2158 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2159 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2160 };
2161 
2162 static  uint8_t ms_aes_cbc_iv2[] = {
2163 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2164 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2165 };
2166 
2167 static const uint8_t ms_aes_cbc_cipher2[] = {
2168 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2169 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2170 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2171 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2172 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2173 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2174 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2175 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2176 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2177 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2178 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2179 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2180 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2181 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2182 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2183 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2184 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2185 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2186 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2187 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2188 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2189 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2190 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2191 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2192 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2193 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2194 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2195 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2196 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2197 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2198 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2199 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2200 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2201 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2202 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2203 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2204 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2205 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2206 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2207 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2208 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2209 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2210 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2211 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2212 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2213 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2214 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2215 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2216 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2217 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2218 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2219 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2220 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2221 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2222 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2223 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2224 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2225 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2226 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2227 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2228 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2229 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2230 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2231 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2232 };
2233 
2234 static  uint8_t ms_hmac_key2[] = {
2235 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2236 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2237 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2238 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2239 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2240 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2241 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2242 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2243 };
2244 
2245 static const uint8_t ms_hmac_digest2[] = {
2246 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2247 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2248 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2249 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2250 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2251 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2252 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2253 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2254 };
2255 
2256 /* End Session 2 */
2257 
2258 
2259 static int
2260 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2261 {
2262 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2263 	struct crypto_unittest_params *ut_params = &unittest_params;
2264 	/* Verify the capabilities */
2265 	struct rte_cryptodev_sym_capability_idx cap_idx;
2266 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2267 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2268 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2269 			&cap_idx) == NULL)
2270 		return TEST_SKIPPED;
2271 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2272 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2273 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2274 			&cap_idx) == NULL)
2275 		return TEST_SKIPPED;
2276 
2277 	/* Generate test mbuf data and space for digest */
2278 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2279 			catch_22_quote,	QUOTE_512_BYTES, 0);
2280 
2281 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2282 			DIGEST_BYTE_LENGTH_SHA1);
2283 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2284 
2285 	/* Setup Cipher Parameters */
2286 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2287 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2288 
2289 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2290 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2291 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2292 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2293 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2294 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2295 
2296 	/* Setup HMAC Parameters */
2297 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2298 
2299 	ut_params->auth_xform.next = NULL;
2300 
2301 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2302 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2303 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2304 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2305 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2306 
2307 	rte_errno = 0;
2308 	ut_params->sess = rte_cryptodev_sym_session_create(
2309 			ts_params->valid_devs[0], &ut_params->cipher_xform,
2310 			ts_params->session_mpool);
2311 	if (rte_errno == ENOTSUP)
2312 		return TEST_SKIPPED;
2313 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2314 
2315 	/* Generate crypto op data structure */
2316 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2317 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2318 	TEST_ASSERT_NOT_NULL(ut_params->op,
2319 			"Failed to allocate symmetric crypto operation struct");
2320 
2321 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2322 
2323 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2324 
2325 	/* set crypto operation source mbuf */
2326 	sym_op->m_src = ut_params->ibuf;
2327 
2328 	/* Set crypto operation authentication parameters */
2329 	sym_op->auth.digest.data = ut_params->digest;
2330 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2331 			ut_params->ibuf, QUOTE_512_BYTES);
2332 
2333 	sym_op->auth.data.offset = 0;
2334 	sym_op->auth.data.length = QUOTE_512_BYTES;
2335 
2336 	/* Copy IV at the end of the crypto operation */
2337 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2338 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2339 
2340 	/* Set crypto operation cipher parameters */
2341 	sym_op->cipher.data.offset = 0;
2342 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2343 
2344 	/* Process crypto operation */
2345 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2346 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2347 			ut_params->op);
2348 	else
2349 		TEST_ASSERT_NOT_NULL(
2350 			process_crypto_request(ts_params->valid_devs[0],
2351 				ut_params->op),
2352 				"failed to process sym crypto op");
2353 
2354 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2355 			"crypto op processing failed");
2356 
2357 	/* Validate obuf */
2358 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2359 			uint8_t *);
2360 
2361 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2362 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2363 			QUOTE_512_BYTES,
2364 			"ciphertext data not as expected");
2365 
2366 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2367 
2368 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2369 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2370 			gbl_driver_id == rte_cryptodev_driver_id_get(
2371 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2372 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2373 					DIGEST_BYTE_LENGTH_SHA1,
2374 			"Generated digest data not as expected");
2375 
2376 	return TEST_SUCCESS;
2377 }
2378 
2379 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2380 
2381 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2382 
2383 static uint8_t hmac_sha512_key[] = {
2384 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2385 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2386 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2387 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2388 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2389 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2390 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2391 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2392 
2393 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2394 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2395 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2396 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2397 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2398 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2399 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2400 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2401 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2402 
2403 
2404 
2405 static int
2406 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2407 		struct crypto_unittest_params *ut_params,
2408 		uint8_t *cipher_key,
2409 		uint8_t *hmac_key);
2410 
2411 static int
2412 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2413 		struct crypto_unittest_params *ut_params,
2414 		struct crypto_testsuite_params *ts_params,
2415 		const uint8_t *cipher,
2416 		const uint8_t *digest,
2417 		const uint8_t *iv);
2418 
2419 
2420 static int
2421 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2422 		struct crypto_unittest_params *ut_params,
2423 		uint8_t *cipher_key,
2424 		uint8_t *hmac_key)
2425 {
2426 
2427 	/* Setup Cipher Parameters */
2428 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2429 	ut_params->cipher_xform.next = NULL;
2430 
2431 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2432 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2433 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2434 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2435 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2436 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2437 
2438 	/* Setup HMAC Parameters */
2439 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2440 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2441 
2442 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2443 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2444 	ut_params->auth_xform.auth.key.data = hmac_key;
2445 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2446 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2447 
2448 	return TEST_SUCCESS;
2449 }
2450 
2451 
2452 static int
2453 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2454 		struct crypto_unittest_params *ut_params,
2455 		struct crypto_testsuite_params *ts_params,
2456 		const uint8_t *cipher,
2457 		const uint8_t *digest,
2458 		const uint8_t *iv)
2459 {
2460 	int ret;
2461 
2462 	/* Generate test mbuf data and digest */
2463 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2464 			(const char *)
2465 			cipher,
2466 			QUOTE_512_BYTES, 0);
2467 
2468 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2469 			DIGEST_BYTE_LENGTH_SHA512);
2470 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2471 
2472 	rte_memcpy(ut_params->digest,
2473 			digest,
2474 			DIGEST_BYTE_LENGTH_SHA512);
2475 
2476 	/* Generate Crypto op data structure */
2477 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2478 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2479 	TEST_ASSERT_NOT_NULL(ut_params->op,
2480 			"Failed to allocate symmetric crypto operation struct");
2481 
2482 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2483 
2484 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2485 
2486 	/* set crypto operation source mbuf */
2487 	sym_op->m_src = ut_params->ibuf;
2488 
2489 	sym_op->auth.digest.data = ut_params->digest;
2490 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2491 			ut_params->ibuf, QUOTE_512_BYTES);
2492 
2493 	sym_op->auth.data.offset = 0;
2494 	sym_op->auth.data.length = QUOTE_512_BYTES;
2495 
2496 	/* Copy IV at the end of the crypto operation */
2497 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2498 			iv, CIPHER_IV_LENGTH_AES_CBC);
2499 
2500 	sym_op->cipher.data.offset = 0;
2501 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2502 
2503 	/* Process crypto operation */
2504 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2505 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2506 			ut_params->op);
2507 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2508 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2509 		if (ret != TEST_SUCCESS)
2510 			return ret;
2511 	} else
2512 		TEST_ASSERT_NOT_NULL(
2513 				process_crypto_request(ts_params->valid_devs[0],
2514 					ut_params->op),
2515 					"failed to process sym crypto op");
2516 
2517 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2518 			"crypto op processing failed");
2519 
2520 	ut_params->obuf = ut_params->op->sym->m_src;
2521 
2522 	/* Validate obuf */
2523 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2524 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2525 			catch_22_quote,
2526 			QUOTE_512_BYTES,
2527 			"Plaintext data not as expected");
2528 
2529 	/* Validate obuf */
2530 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2531 			"Digest verification failed");
2532 
2533 	return TEST_SUCCESS;
2534 }
2535 
2536 /* ***** SNOW 3G Tests ***** */
2537 static int
2538 create_wireless_algo_hash_session(uint8_t dev_id,
2539 	const uint8_t *key, const uint8_t key_len,
2540 	const uint8_t iv_len, const uint8_t auth_len,
2541 	enum rte_crypto_auth_operation op,
2542 	enum rte_crypto_auth_algorithm algo)
2543 {
2544 	uint8_t hash_key[key_len];
2545 
2546 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2547 	struct crypto_unittest_params *ut_params = &unittest_params;
2548 
2549 	memcpy(hash_key, key, key_len);
2550 
2551 	debug_hexdump(stdout, "key:", key, key_len);
2552 
2553 	/* Setup Authentication Parameters */
2554 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2555 	ut_params->auth_xform.next = NULL;
2556 
2557 	ut_params->auth_xform.auth.op = op;
2558 	ut_params->auth_xform.auth.algo = algo;
2559 	ut_params->auth_xform.auth.key.length = key_len;
2560 	ut_params->auth_xform.auth.key.data = hash_key;
2561 	ut_params->auth_xform.auth.digest_length = auth_len;
2562 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2563 	ut_params->auth_xform.auth.iv.length = iv_len;
2564 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2565 			&ut_params->auth_xform, ts_params->session_mpool);
2566 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2567 		return TEST_SKIPPED;
2568 
2569 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2570 	return 0;
2571 }
2572 
2573 static int
2574 create_wireless_algo_cipher_session(uint8_t dev_id,
2575 			enum rte_crypto_cipher_operation op,
2576 			enum rte_crypto_cipher_algorithm algo,
2577 			const uint8_t *key, const uint8_t key_len,
2578 			uint8_t iv_len)
2579 {
2580 	uint8_t cipher_key[key_len];
2581 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2582 	struct crypto_unittest_params *ut_params = &unittest_params;
2583 
2584 	memcpy(cipher_key, key, key_len);
2585 
2586 	/* Setup Cipher Parameters */
2587 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2588 	ut_params->cipher_xform.next = NULL;
2589 
2590 	ut_params->cipher_xform.cipher.algo = algo;
2591 	ut_params->cipher_xform.cipher.op = op;
2592 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2593 	ut_params->cipher_xform.cipher.key.length = key_len;
2594 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2595 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2596 
2597 	debug_hexdump(stdout, "key:", key, key_len);
2598 
2599 	/* Create Crypto session */
2600 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2601 			&ut_params->cipher_xform, ts_params->session_mpool);
2602 
2603 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2604 		return TEST_SKIPPED;
2605 
2606 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2607 	return 0;
2608 }
2609 
2610 static int
2611 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2612 			unsigned int cipher_len,
2613 			unsigned int cipher_offset)
2614 {
2615 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2616 	struct crypto_unittest_params *ut_params = &unittest_params;
2617 
2618 	/* Generate Crypto op data structure */
2619 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2620 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2621 	TEST_ASSERT_NOT_NULL(ut_params->op,
2622 				"Failed to allocate pktmbuf offload");
2623 
2624 	/* Set crypto operation data parameters */
2625 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2626 
2627 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2628 
2629 	/* set crypto operation source mbuf */
2630 	sym_op->m_src = ut_params->ibuf;
2631 
2632 	/* iv */
2633 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2634 			iv, iv_len);
2635 	sym_op->cipher.data.length = cipher_len;
2636 	sym_op->cipher.data.offset = cipher_offset;
2637 	return 0;
2638 }
2639 
2640 static int
2641 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2642 			unsigned int cipher_len,
2643 			unsigned int cipher_offset)
2644 {
2645 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2646 	struct crypto_unittest_params *ut_params = &unittest_params;
2647 
2648 	/* Generate Crypto op data structure */
2649 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2650 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2651 	TEST_ASSERT_NOT_NULL(ut_params->op,
2652 				"Failed to allocate pktmbuf offload");
2653 
2654 	/* Set crypto operation data parameters */
2655 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2656 
2657 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2658 
2659 	/* set crypto operation source mbuf */
2660 	sym_op->m_src = ut_params->ibuf;
2661 	sym_op->m_dst = ut_params->obuf;
2662 
2663 	/* iv */
2664 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2665 			iv, iv_len);
2666 	sym_op->cipher.data.length = cipher_len;
2667 	sym_op->cipher.data.offset = cipher_offset;
2668 	return 0;
2669 }
2670 
2671 static int
2672 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2673 		enum rte_crypto_cipher_operation cipher_op,
2674 		enum rte_crypto_auth_operation auth_op,
2675 		enum rte_crypto_auth_algorithm auth_algo,
2676 		enum rte_crypto_cipher_algorithm cipher_algo,
2677 		const uint8_t *a_key, uint8_t a_key_len,
2678 		const uint8_t *c_key, uint8_t c_key_len,
2679 		uint8_t auth_iv_len, uint8_t auth_len,
2680 		uint8_t cipher_iv_len)
2681 
2682 {
2683 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2684 	struct crypto_unittest_params *ut_params = &unittest_params;
2685 
2686 	/* Setup Authentication Parameters */
2687 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2688 	ut_params->auth_xform.next = NULL;
2689 
2690 	ut_params->auth_xform.auth.op = auth_op;
2691 	ut_params->auth_xform.auth.algo = auth_algo;
2692 	ut_params->auth_xform.auth.key.length = a_key_len;
2693 	ut_params->auth_xform.auth.key.data = a_key;
2694 	ut_params->auth_xform.auth.digest_length = auth_len;
2695 	/* Auth IV will be after cipher IV */
2696 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2697 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2698 
2699 	/* Setup Cipher Parameters */
2700 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2701 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2702 
2703 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2704 	ut_params->cipher_xform.cipher.op = cipher_op;
2705 	ut_params->cipher_xform.cipher.key.data = c_key;
2706 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2707 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2708 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2709 
2710 	debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
2711 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2712 
2713 	/* Create Crypto session*/
2714 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2715 			&ut_params->cipher_xform, ts_params->session_mpool);
2716 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2717 		return TEST_SKIPPED;
2718 
2719 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2720 	return 0;
2721 }
2722 
2723 static int
2724 create_wireless_cipher_auth_session(uint8_t dev_id,
2725 		enum rte_crypto_cipher_operation cipher_op,
2726 		enum rte_crypto_auth_operation auth_op,
2727 		enum rte_crypto_auth_algorithm auth_algo,
2728 		enum rte_crypto_cipher_algorithm cipher_algo,
2729 		const struct wireless_test_data *tdata)
2730 {
2731 	const uint8_t key_len = tdata->key.len;
2732 	uint8_t cipher_auth_key[key_len];
2733 
2734 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2735 	struct crypto_unittest_params *ut_params = &unittest_params;
2736 	const uint8_t *key = tdata->key.data;
2737 	const uint8_t auth_len = tdata->digest.len;
2738 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2739 	uint8_t auth_iv_len = tdata->auth_iv.len;
2740 
2741 	memcpy(cipher_auth_key, key, key_len);
2742 
2743 	/* Setup Authentication Parameters */
2744 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2745 	ut_params->auth_xform.next = NULL;
2746 
2747 	ut_params->auth_xform.auth.op = auth_op;
2748 	ut_params->auth_xform.auth.algo = auth_algo;
2749 	ut_params->auth_xform.auth.key.length = key_len;
2750 	/* Hash key = cipher key */
2751 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2752 	ut_params->auth_xform.auth.digest_length = auth_len;
2753 	/* Auth IV will be after cipher IV */
2754 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2755 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2756 
2757 	/* Setup Cipher Parameters */
2758 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2759 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2760 
2761 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2762 	ut_params->cipher_xform.cipher.op = cipher_op;
2763 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2764 	ut_params->cipher_xform.cipher.key.length = key_len;
2765 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2766 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2767 
2768 
2769 	debug_hexdump(stdout, "key:", key, key_len);
2770 
2771 	/* Create Crypto session*/
2772 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2773 			&ut_params->cipher_xform, ts_params->session_mpool);
2774 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2775 		return TEST_SKIPPED;
2776 
2777 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2778 	return 0;
2779 }
2780 
2781 static int
2782 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2783 		const struct wireless_test_data *tdata)
2784 {
2785 	return create_wireless_cipher_auth_session(dev_id,
2786 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2787 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2788 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2789 }
2790 
2791 static int
2792 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2793 		enum rte_crypto_cipher_operation cipher_op,
2794 		enum rte_crypto_auth_operation auth_op,
2795 		enum rte_crypto_auth_algorithm auth_algo,
2796 		enum rte_crypto_cipher_algorithm cipher_algo,
2797 		const uint8_t *a_key, const uint8_t a_key_len,
2798 		const uint8_t *c_key, const uint8_t c_key_len,
2799 		uint8_t auth_iv_len, uint8_t auth_len,
2800 		uint8_t cipher_iv_len)
2801 {
2802 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2803 	struct crypto_unittest_params *ut_params = &unittest_params;
2804 
2805 	/* Setup Authentication Parameters */
2806 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2807 	ut_params->auth_xform.auth.op = auth_op;
2808 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2809 	ut_params->auth_xform.auth.algo = auth_algo;
2810 	ut_params->auth_xform.auth.key.length = a_key_len;
2811 	ut_params->auth_xform.auth.key.data = a_key;
2812 	ut_params->auth_xform.auth.digest_length = auth_len;
2813 	/* Auth IV will be after cipher IV */
2814 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2815 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2816 
2817 	/* Setup Cipher Parameters */
2818 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2819 	ut_params->cipher_xform.next = NULL;
2820 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2821 	ut_params->cipher_xform.cipher.op = cipher_op;
2822 	ut_params->cipher_xform.cipher.key.data = c_key;
2823 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2824 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2825 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2826 
2827 	debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
2828 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2829 
2830 	/* Create Crypto session*/
2831 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2832 		ut_params->auth_xform.next = NULL;
2833 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2834 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2835 			&ut_params->cipher_xform, ts_params->session_mpool);
2836 	} else
2837 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2838 			&ut_params->auth_xform, ts_params->session_mpool);
2839 
2840 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2841 		return TEST_SKIPPED;
2842 
2843 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2844 
2845 	return 0;
2846 }
2847 
2848 static int
2849 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2850 		unsigned int auth_tag_len,
2851 		const uint8_t *iv, unsigned int iv_len,
2852 		unsigned int data_pad_len,
2853 		enum rte_crypto_auth_operation op,
2854 		unsigned int auth_len, unsigned int auth_offset)
2855 {
2856 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2857 
2858 	struct crypto_unittest_params *ut_params = &unittest_params;
2859 
2860 	/* Generate Crypto op data structure */
2861 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2862 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2863 	TEST_ASSERT_NOT_NULL(ut_params->op,
2864 		"Failed to allocate pktmbuf offload");
2865 
2866 	/* Set crypto operation data parameters */
2867 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2868 
2869 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2870 
2871 	/* set crypto operation source mbuf */
2872 	sym_op->m_src = ut_params->ibuf;
2873 
2874 	/* iv */
2875 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2876 			iv, iv_len);
2877 	/* digest */
2878 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2879 					ut_params->ibuf, auth_tag_len);
2880 
2881 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2882 				"no room to append auth tag");
2883 	ut_params->digest = sym_op->auth.digest.data;
2884 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2885 			ut_params->ibuf, data_pad_len);
2886 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2887 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2888 	else
2889 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2890 
2891 	debug_hexdump(stdout, "digest:",
2892 		sym_op->auth.digest.data,
2893 		auth_tag_len);
2894 
2895 	sym_op->auth.data.length = auth_len;
2896 	sym_op->auth.data.offset = auth_offset;
2897 
2898 	return 0;
2899 }
2900 
2901 static int
2902 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2903 	enum rte_crypto_auth_operation op)
2904 {
2905 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2906 	struct crypto_unittest_params *ut_params = &unittest_params;
2907 
2908 	const uint8_t *auth_tag = tdata->digest.data;
2909 	const unsigned int auth_tag_len = tdata->digest.len;
2910 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2911 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2912 
2913 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2914 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2915 	const uint8_t *auth_iv = tdata->auth_iv.data;
2916 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2917 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2918 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2919 
2920 	/* Generate Crypto op data structure */
2921 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2922 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2923 	TEST_ASSERT_NOT_NULL(ut_params->op,
2924 			"Failed to allocate pktmbuf offload");
2925 	/* Set crypto operation data parameters */
2926 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2927 
2928 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2929 
2930 	/* set crypto operation source mbuf */
2931 	sym_op->m_src = ut_params->ibuf;
2932 
2933 	/* digest */
2934 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2935 			ut_params->ibuf, auth_tag_len);
2936 
2937 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2938 			"no room to append auth tag");
2939 	ut_params->digest = sym_op->auth.digest.data;
2940 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2941 			ut_params->ibuf, data_pad_len);
2942 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2943 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2944 	else
2945 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2946 
2947 	debug_hexdump(stdout, "digest:",
2948 		sym_op->auth.digest.data,
2949 		auth_tag_len);
2950 
2951 	/* Copy cipher and auth IVs at the end of the crypto operation */
2952 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2953 						IV_OFFSET);
2954 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2955 	iv_ptr += cipher_iv_len;
2956 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2957 
2958 	sym_op->cipher.data.length = cipher_len;
2959 	sym_op->cipher.data.offset = 0;
2960 	sym_op->auth.data.length = auth_len;
2961 	sym_op->auth.data.offset = 0;
2962 
2963 	return 0;
2964 }
2965 
2966 static int
2967 create_zuc_cipher_hash_generate_operation(
2968 		const struct wireless_test_data *tdata)
2969 {
2970 	return create_wireless_cipher_hash_operation(tdata,
2971 		RTE_CRYPTO_AUTH_OP_GENERATE);
2972 }
2973 
2974 static int
2975 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2976 		const unsigned auth_tag_len,
2977 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2978 		unsigned data_pad_len,
2979 		enum rte_crypto_auth_operation op,
2980 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2981 		const unsigned cipher_len, const unsigned cipher_offset,
2982 		const unsigned auth_len, const unsigned auth_offset)
2983 {
2984 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2985 	struct crypto_unittest_params *ut_params = &unittest_params;
2986 
2987 	enum rte_crypto_cipher_algorithm cipher_algo =
2988 			ut_params->cipher_xform.cipher.algo;
2989 	enum rte_crypto_auth_algorithm auth_algo =
2990 			ut_params->auth_xform.auth.algo;
2991 
2992 	/* Generate Crypto op data structure */
2993 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2994 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2995 	TEST_ASSERT_NOT_NULL(ut_params->op,
2996 			"Failed to allocate pktmbuf offload");
2997 	/* Set crypto operation data parameters */
2998 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2999 
3000 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3001 
3002 	/* set crypto operation source mbuf */
3003 	sym_op->m_src = ut_params->ibuf;
3004 
3005 	/* digest */
3006 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3007 			ut_params->ibuf, auth_tag_len);
3008 
3009 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3010 			"no room to append auth tag");
3011 	ut_params->digest = sym_op->auth.digest.data;
3012 
3013 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3014 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3015 				ut_params->ibuf, data_pad_len);
3016 	} else {
3017 		struct rte_mbuf *m = ut_params->ibuf;
3018 		unsigned int offset = data_pad_len;
3019 
3020 		while (offset > m->data_len && m->next != NULL) {
3021 			offset -= m->data_len;
3022 			m = m->next;
3023 		}
3024 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3025 			m, offset);
3026 	}
3027 
3028 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3029 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3030 	else
3031 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3032 
3033 	debug_hexdump(stdout, "digest:",
3034 		sym_op->auth.digest.data,
3035 		auth_tag_len);
3036 
3037 	/* Copy cipher and auth IVs at the end of the crypto operation */
3038 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3039 						IV_OFFSET);
3040 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3041 	iv_ptr += cipher_iv_len;
3042 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3043 
3044 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3045 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3046 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3047 		sym_op->cipher.data.length = cipher_len;
3048 		sym_op->cipher.data.offset = cipher_offset;
3049 	} else {
3050 		sym_op->cipher.data.length = cipher_len >> 3;
3051 		sym_op->cipher.data.offset = cipher_offset >> 3;
3052 	}
3053 
3054 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3055 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3056 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3057 		sym_op->auth.data.length = auth_len;
3058 		sym_op->auth.data.offset = auth_offset;
3059 	} else {
3060 		sym_op->auth.data.length = auth_len >> 3;
3061 		sym_op->auth.data.offset = auth_offset >> 3;
3062 	}
3063 
3064 	return 0;
3065 }
3066 
3067 static int
3068 create_wireless_algo_auth_cipher_operation(
3069 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3070 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3071 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3072 		unsigned int data_pad_len,
3073 		unsigned int cipher_len, unsigned int cipher_offset,
3074 		unsigned int auth_len, unsigned int auth_offset,
3075 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3076 {
3077 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3078 	struct crypto_unittest_params *ut_params = &unittest_params;
3079 
3080 	enum rte_crypto_cipher_algorithm cipher_algo =
3081 			ut_params->cipher_xform.cipher.algo;
3082 	enum rte_crypto_auth_algorithm auth_algo =
3083 			ut_params->auth_xform.auth.algo;
3084 
3085 	/* Generate Crypto op data structure */
3086 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3087 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3088 	TEST_ASSERT_NOT_NULL(ut_params->op,
3089 			"Failed to allocate pktmbuf offload");
3090 
3091 	/* Set crypto operation data parameters */
3092 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3093 
3094 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3095 
3096 	/* set crypto operation mbufs */
3097 	sym_op->m_src = ut_params->ibuf;
3098 	if (op_mode == OUT_OF_PLACE)
3099 		sym_op->m_dst = ut_params->obuf;
3100 
3101 	/* digest */
3102 	if (!do_sgl) {
3103 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3104 			(op_mode == IN_PLACE ?
3105 				ut_params->ibuf : ut_params->obuf),
3106 			uint8_t *, data_pad_len);
3107 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3108 			(op_mode == IN_PLACE ?
3109 				ut_params->ibuf : ut_params->obuf),
3110 			data_pad_len);
3111 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3112 	} else {
3113 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3114 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3115 				sym_op->m_src : sym_op->m_dst);
3116 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3117 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3118 			sgl_buf = sgl_buf->next;
3119 		}
3120 
3121 		/* The last segment should be large enough to hold full digest */
3122 		if (sgl_buf->data_len < auth_tag_len) {
3123 			rte_pktmbuf_free(sgl_buf->next);
3124 			sgl_buf->next = NULL;
3125 			TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3126 					auth_tag_len - sgl_buf->data_len),
3127 					"No room to append auth tag");
3128 		}
3129 
3130 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3131 				uint8_t *, remaining_off);
3132 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3133 				remaining_off);
3134 		memset(sym_op->auth.digest.data, 0, remaining_off);
3135 		while (sgl_buf->next != NULL) {
3136 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3137 				0, rte_pktmbuf_data_len(sgl_buf));
3138 			sgl_buf = sgl_buf->next;
3139 		}
3140 	}
3141 
3142 	/* Copy digest for the verification */
3143 	if (verify)
3144 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3145 
3146 	/* Copy cipher and auth IVs at the end of the crypto operation */
3147 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3148 			ut_params->op, uint8_t *, IV_OFFSET);
3149 
3150 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3151 	iv_ptr += cipher_iv_len;
3152 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3153 
3154 	/* Only copy over the offset data needed from src to dst in OOP,
3155 	 * if the auth and cipher offsets are not aligned
3156 	 */
3157 	if (op_mode == OUT_OF_PLACE) {
3158 		if (cipher_offset > auth_offset)
3159 			rte_memcpy(
3160 				rte_pktmbuf_mtod_offset(
3161 					sym_op->m_dst,
3162 					uint8_t *, auth_offset >> 3),
3163 				rte_pktmbuf_mtod_offset(
3164 					sym_op->m_src,
3165 					uint8_t *, auth_offset >> 3),
3166 				((cipher_offset >> 3) - (auth_offset >> 3)));
3167 	}
3168 
3169 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3170 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3171 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3172 		sym_op->cipher.data.length = cipher_len;
3173 		sym_op->cipher.data.offset = cipher_offset;
3174 	} else {
3175 		sym_op->cipher.data.length = cipher_len >> 3;
3176 		sym_op->cipher.data.offset = cipher_offset >> 3;
3177 	}
3178 
3179 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3180 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3181 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3182 		sym_op->auth.data.length = auth_len;
3183 		sym_op->auth.data.offset = auth_offset;
3184 	} else {
3185 		sym_op->auth.data.length = auth_len >> 3;
3186 		sym_op->auth.data.offset = auth_offset >> 3;
3187 	}
3188 
3189 	return 0;
3190 }
3191 
3192 static int
3193 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3194 {
3195 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3196 	struct crypto_unittest_params *ut_params = &unittest_params;
3197 
3198 	int retval;
3199 	unsigned plaintext_pad_len;
3200 	unsigned plaintext_len;
3201 	uint8_t *plaintext;
3202 	struct rte_cryptodev_info dev_info;
3203 
3204 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3205 	uint64_t feat_flags = dev_info.feature_flags;
3206 
3207 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3208 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3209 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3210 		return TEST_SKIPPED;
3211 	}
3212 
3213 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3214 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3215 		printf("Device doesn't support RAW data-path APIs.\n");
3216 		return TEST_SKIPPED;
3217 	}
3218 
3219 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3220 		return TEST_SKIPPED;
3221 
3222 	/* Verify the capabilities */
3223 	struct rte_cryptodev_sym_capability_idx cap_idx;
3224 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3225 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3226 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3227 			&cap_idx) == NULL)
3228 		return TEST_SKIPPED;
3229 
3230 	/* Create SNOW 3G session */
3231 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3232 			tdata->key.data, tdata->key.len,
3233 			tdata->auth_iv.len, tdata->digest.len,
3234 			RTE_CRYPTO_AUTH_OP_GENERATE,
3235 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3236 	if (retval < 0)
3237 		return retval;
3238 
3239 	/* alloc mbuf and set payload */
3240 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3241 
3242 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3243 	rte_pktmbuf_tailroom(ut_params->ibuf));
3244 
3245 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3246 	/* Append data which is padded to a multiple of */
3247 	/* the algorithms block size */
3248 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3249 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3250 				plaintext_pad_len);
3251 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3252 
3253 	/* Create SNOW 3G operation */
3254 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3255 			tdata->auth_iv.data, tdata->auth_iv.len,
3256 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3257 			tdata->validAuthLenInBits.len,
3258 			0);
3259 	if (retval < 0)
3260 		return retval;
3261 
3262 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3263 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3264 					       0);
3265 		if (retval != TEST_SUCCESS)
3266 			return retval;
3267 	} else
3268 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3269 				ut_params->op);
3270 	ut_params->obuf = ut_params->op->sym->m_src;
3271 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3272 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3273 						    uint8_t *,
3274 						    plaintext_pad_len);
3275 
3276 	/* Validate obuf */
3277 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3278 	ut_params->digest,
3279 	tdata->digest.data,
3280 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3281 	"SNOW 3G Generated auth tag not as expected");
3282 
3283 	return 0;
3284 }
3285 
3286 static int
3287 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3288 {
3289 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3290 	struct crypto_unittest_params *ut_params = &unittest_params;
3291 
3292 	int retval;
3293 	unsigned plaintext_pad_len;
3294 	unsigned plaintext_len;
3295 	uint8_t *plaintext;
3296 	struct rte_cryptodev_info dev_info;
3297 
3298 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3299 	uint64_t feat_flags = dev_info.feature_flags;
3300 
3301 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3302 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3303 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3304 		return TEST_SKIPPED;
3305 	}
3306 
3307 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3308 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3309 		printf("Device doesn't support RAW data-path APIs.\n");
3310 		return TEST_SKIPPED;
3311 	}
3312 
3313 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3314 		return TEST_SKIPPED;
3315 
3316 	/* Verify the capabilities */
3317 	struct rte_cryptodev_sym_capability_idx cap_idx;
3318 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3319 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3320 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3321 			&cap_idx) == NULL)
3322 		return TEST_SKIPPED;
3323 
3324 	/* Create SNOW 3G session */
3325 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3326 				tdata->key.data, tdata->key.len,
3327 				tdata->auth_iv.len, tdata->digest.len,
3328 				RTE_CRYPTO_AUTH_OP_VERIFY,
3329 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3330 	if (retval < 0)
3331 		return retval;
3332 	/* alloc mbuf and set payload */
3333 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3334 
3335 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3336 	rte_pktmbuf_tailroom(ut_params->ibuf));
3337 
3338 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3339 	/* Append data which is padded to a multiple of */
3340 	/* the algorithms block size */
3341 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3342 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3343 				plaintext_pad_len);
3344 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3345 
3346 	/* Create SNOW 3G operation */
3347 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3348 			tdata->digest.len,
3349 			tdata->auth_iv.data, tdata->auth_iv.len,
3350 			plaintext_pad_len,
3351 			RTE_CRYPTO_AUTH_OP_VERIFY,
3352 			tdata->validAuthLenInBits.len,
3353 			0);
3354 	if (retval < 0)
3355 		return retval;
3356 
3357 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3358 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3359 					       0);
3360 		if (retval != TEST_SUCCESS)
3361 			return retval;
3362 	} else
3363 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3364 				ut_params->op);
3365 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3366 	ut_params->obuf = ut_params->op->sym->m_src;
3367 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3368 						    uint8_t *,
3369 						    plaintext_pad_len);
3370 
3371 	/* Validate obuf */
3372 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3373 		return 0;
3374 	else
3375 		return -1;
3376 
3377 	return 0;
3378 }
3379 
3380 static int
3381 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3382 {
3383 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3384 	struct crypto_unittest_params *ut_params = &unittest_params;
3385 
3386 	int retval;
3387 	unsigned plaintext_pad_len;
3388 	unsigned plaintext_len;
3389 	uint8_t *plaintext;
3390 	struct rte_cryptodev_info dev_info;
3391 
3392 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3393 	uint64_t feat_flags = dev_info.feature_flags;
3394 
3395 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3396 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3397 		printf("Device doesn't support RAW data-path APIs.\n");
3398 		return TEST_SKIPPED;
3399 	}
3400 
3401 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3402 		return TEST_SKIPPED;
3403 
3404 	/* Verify the capabilities */
3405 	struct rte_cryptodev_sym_capability_idx cap_idx;
3406 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3407 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3408 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3409 			&cap_idx) == NULL)
3410 		return TEST_SKIPPED;
3411 
3412 	/* Create KASUMI session */
3413 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3414 			tdata->key.data, tdata->key.len,
3415 			0, tdata->digest.len,
3416 			RTE_CRYPTO_AUTH_OP_GENERATE,
3417 			RTE_CRYPTO_AUTH_KASUMI_F9);
3418 	if (retval < 0)
3419 		return retval;
3420 
3421 	/* alloc mbuf and set payload */
3422 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3423 
3424 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3425 	rte_pktmbuf_tailroom(ut_params->ibuf));
3426 
3427 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3428 	/* Append data which is padded to a multiple of */
3429 	/* the algorithms block size */
3430 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3431 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3432 				plaintext_pad_len);
3433 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3434 
3435 	/* Create KASUMI operation */
3436 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3437 			NULL, 0,
3438 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3439 			tdata->plaintext.len,
3440 			0);
3441 	if (retval < 0)
3442 		return retval;
3443 
3444 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3445 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3446 			ut_params->op);
3447 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3448 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3449 					       0);
3450 		if (retval != TEST_SUCCESS)
3451 			return retval;
3452 	} else
3453 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3454 			ut_params->op);
3455 
3456 	ut_params->obuf = ut_params->op->sym->m_src;
3457 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3458 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3459 						    uint8_t *,
3460 						    plaintext_pad_len);
3461 
3462 	/* Validate obuf */
3463 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3464 	ut_params->digest,
3465 	tdata->digest.data,
3466 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3467 	"KASUMI Generated auth tag not as expected");
3468 
3469 	return 0;
3470 }
3471 
3472 static int
3473 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3474 {
3475 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3476 	struct crypto_unittest_params *ut_params = &unittest_params;
3477 
3478 	int retval;
3479 	unsigned plaintext_pad_len;
3480 	unsigned plaintext_len;
3481 	uint8_t *plaintext;
3482 	struct rte_cryptodev_info dev_info;
3483 
3484 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3485 	uint64_t feat_flags = dev_info.feature_flags;
3486 
3487 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3488 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3489 		printf("Device doesn't support RAW data-path APIs.\n");
3490 		return TEST_SKIPPED;
3491 	}
3492 
3493 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3494 		return TEST_SKIPPED;
3495 
3496 	/* Verify the capabilities */
3497 	struct rte_cryptodev_sym_capability_idx cap_idx;
3498 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3499 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3500 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3501 			&cap_idx) == NULL)
3502 		return TEST_SKIPPED;
3503 
3504 	/* Create KASUMI session */
3505 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3506 				tdata->key.data, tdata->key.len,
3507 				0, tdata->digest.len,
3508 				RTE_CRYPTO_AUTH_OP_VERIFY,
3509 				RTE_CRYPTO_AUTH_KASUMI_F9);
3510 	if (retval < 0)
3511 		return retval;
3512 	/* alloc mbuf and set payload */
3513 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3514 
3515 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3516 	rte_pktmbuf_tailroom(ut_params->ibuf));
3517 
3518 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3519 	/* Append data which is padded to a multiple */
3520 	/* of the algorithms block size */
3521 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3522 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3523 				plaintext_pad_len);
3524 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3525 
3526 	/* Create KASUMI operation */
3527 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3528 			tdata->digest.len,
3529 			NULL, 0,
3530 			plaintext_pad_len,
3531 			RTE_CRYPTO_AUTH_OP_VERIFY,
3532 			tdata->plaintext.len,
3533 			0);
3534 	if (retval < 0)
3535 		return retval;
3536 
3537 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3538 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3539 					       0);
3540 		if (retval != TEST_SUCCESS)
3541 			return retval;
3542 	} else
3543 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3544 				ut_params->op);
3545 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3546 	ut_params->obuf = ut_params->op->sym->m_src;
3547 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3548 						    uint8_t *,
3549 						    plaintext_pad_len);
3550 
3551 	/* Validate obuf */
3552 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3553 		return 0;
3554 	else
3555 		return -1;
3556 
3557 	return 0;
3558 }
3559 
3560 static int
3561 test_snow3g_hash_generate_test_case_1(void)
3562 {
3563 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3564 }
3565 
3566 static int
3567 test_snow3g_hash_generate_test_case_2(void)
3568 {
3569 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3570 }
3571 
3572 static int
3573 test_snow3g_hash_generate_test_case_3(void)
3574 {
3575 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3576 }
3577 
3578 static int
3579 test_snow3g_hash_generate_test_case_4(void)
3580 {
3581 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3582 }
3583 
3584 static int
3585 test_snow3g_hash_generate_test_case_5(void)
3586 {
3587 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3588 }
3589 
3590 static int
3591 test_snow3g_hash_generate_test_case_6(void)
3592 {
3593 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3594 }
3595 
3596 static int
3597 test_snow3g_hash_verify_test_case_1(void)
3598 {
3599 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3600 
3601 }
3602 
3603 static int
3604 test_snow3g_hash_verify_test_case_2(void)
3605 {
3606 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3607 }
3608 
3609 static int
3610 test_snow3g_hash_verify_test_case_3(void)
3611 {
3612 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3613 }
3614 
3615 static int
3616 test_snow3g_hash_verify_test_case_4(void)
3617 {
3618 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3619 }
3620 
3621 static int
3622 test_snow3g_hash_verify_test_case_5(void)
3623 {
3624 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3625 }
3626 
3627 static int
3628 test_snow3g_hash_verify_test_case_6(void)
3629 {
3630 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3631 }
3632 
3633 static int
3634 test_kasumi_hash_generate_test_case_1(void)
3635 {
3636 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3637 }
3638 
3639 static int
3640 test_kasumi_hash_generate_test_case_2(void)
3641 {
3642 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3643 }
3644 
3645 static int
3646 test_kasumi_hash_generate_test_case_3(void)
3647 {
3648 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3649 }
3650 
3651 static int
3652 test_kasumi_hash_generate_test_case_4(void)
3653 {
3654 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3655 }
3656 
3657 static int
3658 test_kasumi_hash_generate_test_case_5(void)
3659 {
3660 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3661 }
3662 
3663 static int
3664 test_kasumi_hash_generate_test_case_6(void)
3665 {
3666 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3667 }
3668 
3669 static int
3670 test_kasumi_hash_verify_test_case_1(void)
3671 {
3672 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3673 }
3674 
3675 static int
3676 test_kasumi_hash_verify_test_case_2(void)
3677 {
3678 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3679 }
3680 
3681 static int
3682 test_kasumi_hash_verify_test_case_3(void)
3683 {
3684 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3685 }
3686 
3687 static int
3688 test_kasumi_hash_verify_test_case_4(void)
3689 {
3690 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3691 }
3692 
3693 static int
3694 test_kasumi_hash_verify_test_case_5(void)
3695 {
3696 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3697 }
3698 
3699 static int
3700 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3701 {
3702 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3703 	struct crypto_unittest_params *ut_params = &unittest_params;
3704 
3705 	int retval;
3706 	uint8_t *plaintext, *ciphertext;
3707 	unsigned plaintext_pad_len;
3708 	unsigned plaintext_len;
3709 	struct rte_cryptodev_info dev_info;
3710 
3711 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3712 	uint64_t feat_flags = dev_info.feature_flags;
3713 
3714 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3715 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3716 		printf("Device doesn't support RAW data-path APIs.\n");
3717 		return TEST_SKIPPED;
3718 	}
3719 
3720 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3721 		return TEST_SKIPPED;
3722 
3723 	/* Verify the capabilities */
3724 	struct rte_cryptodev_sym_capability_idx cap_idx;
3725 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3726 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3727 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3728 			&cap_idx) == NULL)
3729 		return TEST_SKIPPED;
3730 
3731 	/* Create KASUMI session */
3732 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3733 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3734 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3735 					tdata->key.data, tdata->key.len,
3736 					tdata->cipher_iv.len);
3737 	if (retval < 0)
3738 		return retval;
3739 
3740 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3741 
3742 	/* Clear mbuf payload */
3743 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3744 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3745 
3746 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3747 	/* Append data which is padded to a multiple */
3748 	/* of the algorithms block size */
3749 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3750 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3751 				plaintext_pad_len);
3752 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3753 
3754 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3755 
3756 	/* Create KASUMI operation */
3757 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3758 				tdata->cipher_iv.len,
3759 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3760 				tdata->validCipherOffsetInBits.len);
3761 	if (retval < 0)
3762 		return retval;
3763 
3764 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3765 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3766 					       tdata->cipher_iv.len);
3767 		if (retval != TEST_SUCCESS)
3768 			return retval;
3769 	} else
3770 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3771 				ut_params->op);
3772 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3773 
3774 	ut_params->obuf = ut_params->op->sym->m_dst;
3775 	if (ut_params->obuf)
3776 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3777 	else
3778 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3779 
3780 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3781 
3782 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3783 				(tdata->validCipherOffsetInBits.len >> 3);
3784 	/* Validate obuf */
3785 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3786 		ciphertext,
3787 		reference_ciphertext,
3788 		tdata->validCipherLenInBits.len,
3789 		"KASUMI Ciphertext data not as expected");
3790 	return 0;
3791 }
3792 
3793 static int
3794 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3795 {
3796 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3797 	struct crypto_unittest_params *ut_params = &unittest_params;
3798 
3799 	int retval;
3800 
3801 	unsigned int plaintext_pad_len;
3802 	unsigned int plaintext_len;
3803 
3804 	uint8_t buffer[10000];
3805 	const uint8_t *ciphertext;
3806 
3807 	struct rte_cryptodev_info dev_info;
3808 
3809 	/* Verify the capabilities */
3810 	struct rte_cryptodev_sym_capability_idx cap_idx;
3811 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3812 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3813 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3814 			&cap_idx) == NULL)
3815 		return TEST_SKIPPED;
3816 
3817 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3818 
3819 	uint64_t feat_flags = dev_info.feature_flags;
3820 
3821 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3822 		printf("Device doesn't support in-place scatter-gather. "
3823 				"Test Skipped.\n");
3824 		return TEST_SKIPPED;
3825 	}
3826 
3827 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3828 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3829 		printf("Device doesn't support RAW data-path APIs.\n");
3830 		return TEST_SKIPPED;
3831 	}
3832 
3833 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3834 		return TEST_SKIPPED;
3835 
3836 	/* Create KASUMI session */
3837 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3838 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3839 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3840 					tdata->key.data, tdata->key.len,
3841 					tdata->cipher_iv.len);
3842 	if (retval < 0)
3843 		return retval;
3844 
3845 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3846 
3847 
3848 	/* Append data which is padded to a multiple */
3849 	/* of the algorithms block size */
3850 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3851 
3852 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3853 			plaintext_pad_len, 10, 0);
3854 
3855 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3856 
3857 	/* Create KASUMI operation */
3858 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3859 				tdata->cipher_iv.len,
3860 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3861 				tdata->validCipherOffsetInBits.len);
3862 	if (retval < 0)
3863 		return retval;
3864 
3865 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3866 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3867 					       tdata->cipher_iv.len);
3868 		if (retval != TEST_SUCCESS)
3869 			return retval;
3870 	} else
3871 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3872 						ut_params->op);
3873 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3874 
3875 	ut_params->obuf = ut_params->op->sym->m_dst;
3876 
3877 	if (ut_params->obuf)
3878 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3879 				plaintext_len, buffer);
3880 	else
3881 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3882 				tdata->validCipherOffsetInBits.len >> 3,
3883 				plaintext_len, buffer);
3884 
3885 	/* Validate obuf */
3886 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3887 
3888 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3889 				(tdata->validCipherOffsetInBits.len >> 3);
3890 	/* Validate obuf */
3891 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3892 		ciphertext,
3893 		reference_ciphertext,
3894 		tdata->validCipherLenInBits.len,
3895 		"KASUMI Ciphertext data not as expected");
3896 	return 0;
3897 }
3898 
3899 static int
3900 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3901 {
3902 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3903 	struct crypto_unittest_params *ut_params = &unittest_params;
3904 
3905 	int retval;
3906 	uint8_t *plaintext, *ciphertext;
3907 	unsigned plaintext_pad_len;
3908 	unsigned plaintext_len;
3909 
3910 	/* Verify the capabilities */
3911 	struct rte_cryptodev_sym_capability_idx cap_idx;
3912 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3913 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3914 	/* Data-path service does not support OOP */
3915 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3916 			&cap_idx) == NULL)
3917 		return TEST_SKIPPED;
3918 
3919 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3920 		return TEST_SKIPPED;
3921 
3922 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3923 		return TEST_SKIPPED;
3924 
3925 	/* Create KASUMI session */
3926 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3927 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3928 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3929 					tdata->key.data, tdata->key.len,
3930 					tdata->cipher_iv.len);
3931 	if (retval < 0)
3932 		return retval;
3933 
3934 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3935 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3936 
3937 	/* Clear mbuf payload */
3938 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3939 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3940 
3941 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3942 	/* Append data which is padded to a multiple */
3943 	/* of the algorithms block size */
3944 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3945 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3946 				plaintext_pad_len);
3947 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3948 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3949 
3950 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3951 
3952 	/* Create KASUMI operation */
3953 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3954 				tdata->cipher_iv.len,
3955 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3956 				tdata->validCipherOffsetInBits.len);
3957 	if (retval < 0)
3958 		return retval;
3959 
3960 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3961 						ut_params->op);
3962 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3963 
3964 	ut_params->obuf = ut_params->op->sym->m_dst;
3965 	if (ut_params->obuf)
3966 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3967 	else
3968 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3969 
3970 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3971 
3972 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3973 				(tdata->validCipherOffsetInBits.len >> 3);
3974 	/* Validate obuf */
3975 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3976 		ciphertext,
3977 		reference_ciphertext,
3978 		tdata->validCipherLenInBits.len,
3979 		"KASUMI Ciphertext data not as expected");
3980 	return 0;
3981 }
3982 
3983 static int
3984 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3985 {
3986 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3987 	struct crypto_unittest_params *ut_params = &unittest_params;
3988 
3989 	int retval;
3990 	unsigned int plaintext_pad_len;
3991 	unsigned int plaintext_len;
3992 
3993 	const uint8_t *ciphertext;
3994 	uint8_t buffer[2048];
3995 
3996 	struct rte_cryptodev_info dev_info;
3997 
3998 	/* Verify the capabilities */
3999 	struct rte_cryptodev_sym_capability_idx cap_idx;
4000 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4001 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4002 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4003 			&cap_idx) == NULL)
4004 		return TEST_SKIPPED;
4005 
4006 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4007 		return TEST_SKIPPED;
4008 
4009 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4010 		return TEST_SKIPPED;
4011 
4012 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4013 
4014 	uint64_t feat_flags = dev_info.feature_flags;
4015 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4016 		printf("Device doesn't support out-of-place scatter-gather "
4017 				"in both input and output mbufs. "
4018 				"Test Skipped.\n");
4019 		return TEST_SKIPPED;
4020 	}
4021 
4022 	/* Create KASUMI session */
4023 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4024 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4025 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4026 					tdata->key.data, tdata->key.len,
4027 					tdata->cipher_iv.len);
4028 	if (retval < 0)
4029 		return retval;
4030 
4031 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4032 	/* Append data which is padded to a multiple */
4033 	/* of the algorithms block size */
4034 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4035 
4036 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4037 			plaintext_pad_len, 10, 0);
4038 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4039 			plaintext_pad_len, 3, 0);
4040 
4041 	/* Append data which is padded to a multiple */
4042 	/* of the algorithms block size */
4043 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4044 
4045 	/* Create KASUMI operation */
4046 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4047 				tdata->cipher_iv.len,
4048 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4049 				tdata->validCipherOffsetInBits.len);
4050 	if (retval < 0)
4051 		return retval;
4052 
4053 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4054 						ut_params->op);
4055 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4056 
4057 	ut_params->obuf = ut_params->op->sym->m_dst;
4058 	if (ut_params->obuf)
4059 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4060 				plaintext_pad_len, buffer);
4061 	else
4062 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4063 				tdata->validCipherOffsetInBits.len >> 3,
4064 				plaintext_pad_len, buffer);
4065 
4066 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4067 				(tdata->validCipherOffsetInBits.len >> 3);
4068 	/* Validate obuf */
4069 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4070 		ciphertext,
4071 		reference_ciphertext,
4072 		tdata->validCipherLenInBits.len,
4073 		"KASUMI Ciphertext data not as expected");
4074 	return 0;
4075 }
4076 
4077 
4078 static int
4079 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4080 {
4081 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4082 	struct crypto_unittest_params *ut_params = &unittest_params;
4083 
4084 	int retval;
4085 	uint8_t *ciphertext, *plaintext;
4086 	unsigned ciphertext_pad_len;
4087 	unsigned ciphertext_len;
4088 
4089 	/* Verify the capabilities */
4090 	struct rte_cryptodev_sym_capability_idx cap_idx;
4091 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4092 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4093 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4094 			&cap_idx) == NULL)
4095 		return TEST_SKIPPED;
4096 
4097 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4098 		return TEST_SKIPPED;
4099 
4100 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4101 		return TEST_SKIPPED;
4102 
4103 	/* Create KASUMI session */
4104 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4105 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4106 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4107 					tdata->key.data, tdata->key.len,
4108 					tdata->cipher_iv.len);
4109 	if (retval < 0)
4110 		return retval;
4111 
4112 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4113 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4114 
4115 	/* Clear mbuf payload */
4116 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4117 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4118 
4119 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4120 	/* Append data which is padded to a multiple */
4121 	/* of the algorithms block size */
4122 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4123 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4124 				ciphertext_pad_len);
4125 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4126 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4127 
4128 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4129 
4130 	/* Create KASUMI operation */
4131 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4132 				tdata->cipher_iv.len,
4133 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4134 				tdata->validCipherOffsetInBits.len);
4135 	if (retval < 0)
4136 		return retval;
4137 
4138 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4139 						ut_params->op);
4140 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4141 
4142 	ut_params->obuf = ut_params->op->sym->m_dst;
4143 	if (ut_params->obuf)
4144 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4145 	else
4146 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4147 
4148 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4149 
4150 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4151 				(tdata->validCipherOffsetInBits.len >> 3);
4152 	/* Validate obuf */
4153 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4154 		plaintext,
4155 		reference_plaintext,
4156 		tdata->validCipherLenInBits.len,
4157 		"KASUMI Plaintext data not as expected");
4158 	return 0;
4159 }
4160 
4161 static int
4162 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4163 {
4164 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4165 	struct crypto_unittest_params *ut_params = &unittest_params;
4166 
4167 	int retval;
4168 	uint8_t *ciphertext, *plaintext;
4169 	unsigned ciphertext_pad_len;
4170 	unsigned ciphertext_len;
4171 	struct rte_cryptodev_info dev_info;
4172 
4173 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4174 	uint64_t feat_flags = dev_info.feature_flags;
4175 
4176 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4177 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4178 		printf("Device doesn't support RAW data-path APIs.\n");
4179 		return TEST_SKIPPED;
4180 	}
4181 
4182 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4183 		return TEST_SKIPPED;
4184 
4185 	/* Verify the capabilities */
4186 	struct rte_cryptodev_sym_capability_idx cap_idx;
4187 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4188 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4189 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4190 			&cap_idx) == NULL)
4191 		return TEST_SKIPPED;
4192 
4193 	/* Create KASUMI session */
4194 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4195 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4196 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4197 					tdata->key.data, tdata->key.len,
4198 					tdata->cipher_iv.len);
4199 	if (retval < 0)
4200 		return retval;
4201 
4202 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4203 
4204 	/* Clear mbuf payload */
4205 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4206 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4207 
4208 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4209 	/* Append data which is padded to a multiple */
4210 	/* of the algorithms block size */
4211 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4212 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4213 				ciphertext_pad_len);
4214 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4215 
4216 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4217 
4218 	/* Create KASUMI operation */
4219 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4220 			tdata->cipher_iv.len,
4221 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4222 			tdata->validCipherOffsetInBits.len);
4223 	if (retval < 0)
4224 		return retval;
4225 
4226 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4227 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4228 					       0);
4229 		if (retval != TEST_SUCCESS)
4230 			return retval;
4231 	} else
4232 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4233 						ut_params->op);
4234 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4235 
4236 	ut_params->obuf = ut_params->op->sym->m_dst;
4237 	if (ut_params->obuf)
4238 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4239 	else
4240 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4241 
4242 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4243 
4244 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4245 				(tdata->validCipherOffsetInBits.len >> 3);
4246 	/* Validate obuf */
4247 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4248 		plaintext,
4249 		reference_plaintext,
4250 		tdata->validCipherLenInBits.len,
4251 		"KASUMI Plaintext data not as expected");
4252 	return 0;
4253 }
4254 
4255 static int
4256 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4257 {
4258 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4259 	struct crypto_unittest_params *ut_params = &unittest_params;
4260 
4261 	int retval;
4262 	uint8_t *plaintext, *ciphertext;
4263 	unsigned plaintext_pad_len;
4264 	unsigned plaintext_len;
4265 	struct rte_cryptodev_info dev_info;
4266 
4267 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4268 	uint64_t feat_flags = dev_info.feature_flags;
4269 
4270 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4271 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4272 		printf("Device doesn't support RAW data-path APIs.\n");
4273 		return TEST_SKIPPED;
4274 	}
4275 
4276 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4277 		return TEST_SKIPPED;
4278 
4279 	/* Verify the capabilities */
4280 	struct rte_cryptodev_sym_capability_idx cap_idx;
4281 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4282 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4283 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4284 			&cap_idx) == NULL)
4285 		return TEST_SKIPPED;
4286 
4287 	/* Create SNOW 3G session */
4288 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4289 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4290 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4291 					tdata->key.data, tdata->key.len,
4292 					tdata->cipher_iv.len);
4293 	if (retval < 0)
4294 		return retval;
4295 
4296 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4297 
4298 	/* Clear mbuf payload */
4299 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4300 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4301 
4302 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4303 	/* Append data which is padded to a multiple of */
4304 	/* the algorithms block size */
4305 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4306 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4307 				plaintext_pad_len);
4308 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4309 
4310 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4311 
4312 	/* Create SNOW 3G operation */
4313 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4314 					tdata->cipher_iv.len,
4315 					tdata->validCipherLenInBits.len,
4316 					0);
4317 	if (retval < 0)
4318 		return retval;
4319 
4320 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4321 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4322 					       tdata->cipher_iv.len);
4323 		if (retval != TEST_SUCCESS)
4324 			return retval;
4325 	} else
4326 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4327 						ut_params->op);
4328 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4329 
4330 	ut_params->obuf = ut_params->op->sym->m_dst;
4331 	if (ut_params->obuf)
4332 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4333 	else
4334 		ciphertext = plaintext;
4335 
4336 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4337 
4338 	/* Validate obuf */
4339 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4340 		ciphertext,
4341 		tdata->ciphertext.data,
4342 		tdata->validDataLenInBits.len,
4343 		"SNOW 3G Ciphertext data not as expected");
4344 	return 0;
4345 }
4346 
4347 
4348 static int
4349 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4350 {
4351 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4352 	struct crypto_unittest_params *ut_params = &unittest_params;
4353 	uint8_t *plaintext, *ciphertext;
4354 
4355 	int retval;
4356 	unsigned plaintext_pad_len;
4357 	unsigned plaintext_len;
4358 	struct rte_cryptodev_info dev_info;
4359 
4360 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4361 	uint64_t feat_flags = dev_info.feature_flags;
4362 
4363 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4364 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4365 		printf("Device does not support RAW data-path APIs.\n");
4366 		return -ENOTSUP;
4367 	}
4368 
4369 	/* Verify the capabilities */
4370 	struct rte_cryptodev_sym_capability_idx cap_idx;
4371 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4372 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4373 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4374 			&cap_idx) == NULL)
4375 		return TEST_SKIPPED;
4376 
4377 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4378 		return TEST_SKIPPED;
4379 
4380 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4381 		return TEST_SKIPPED;
4382 
4383 	/* Create SNOW 3G session */
4384 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4385 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4386 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4387 					tdata->key.data, tdata->key.len,
4388 					tdata->cipher_iv.len);
4389 	if (retval < 0)
4390 		return retval;
4391 
4392 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4393 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4394 
4395 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4396 			"Failed to allocate input buffer in mempool");
4397 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4398 			"Failed to allocate output buffer in mempool");
4399 
4400 	/* Clear mbuf payload */
4401 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4402 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4403 
4404 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4405 	/* Append data which is padded to a multiple of */
4406 	/* the algorithms block size */
4407 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4408 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4409 				plaintext_pad_len);
4410 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4411 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4412 
4413 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4414 
4415 	/* Create SNOW 3G operation */
4416 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4417 					tdata->cipher_iv.len,
4418 					tdata->validCipherLenInBits.len,
4419 					0);
4420 	if (retval < 0)
4421 		return retval;
4422 
4423 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4424 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4425 					       tdata->cipher_iv.len);
4426 		if (retval != TEST_SUCCESS)
4427 			return retval;
4428 	} else
4429 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4430 						ut_params->op);
4431 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4432 
4433 	ut_params->obuf = ut_params->op->sym->m_dst;
4434 	if (ut_params->obuf)
4435 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4436 	else
4437 		ciphertext = plaintext;
4438 
4439 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4440 
4441 	/* Validate obuf */
4442 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4443 		ciphertext,
4444 		tdata->ciphertext.data,
4445 		tdata->validDataLenInBits.len,
4446 		"SNOW 3G Ciphertext data not as expected");
4447 	return 0;
4448 }
4449 
4450 static int
4451 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4452 		uint8_t sgl_in, uint8_t sgl_out)
4453 {
4454 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4455 	struct crypto_unittest_params *ut_params = &unittest_params;
4456 
4457 	int retval;
4458 	unsigned int plaintext_pad_len;
4459 	unsigned int plaintext_len;
4460 	uint8_t buffer[10000];
4461 	const uint8_t *ciphertext;
4462 
4463 	struct rte_cryptodev_info dev_info;
4464 
4465 	/* Verify the capabilities */
4466 	struct rte_cryptodev_sym_capability_idx cap_idx;
4467 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4468 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4469 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4470 			&cap_idx) == NULL)
4471 		return TEST_SKIPPED;
4472 
4473 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4474 		return TEST_SKIPPED;
4475 
4476 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4477 		return TEST_SKIPPED;
4478 
4479 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4480 
4481 	uint64_t feat_flags = dev_info.feature_flags;
4482 
4483 	if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4484 			|| ((!sgl_in && sgl_out) &&
4485 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4486 			|| ((sgl_in && !sgl_out) &&
4487 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4488 		printf("Device doesn't support out-of-place scatter gather type. "
4489 				"Test Skipped.\n");
4490 		return TEST_SKIPPED;
4491 	}
4492 
4493 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4494 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4495 		printf("Device does not support RAW data-path APIs.\n");
4496 		return -ENOTSUP;
4497 	}
4498 
4499 	/* Create SNOW 3G session */
4500 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4501 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4502 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4503 					tdata->key.data, tdata->key.len,
4504 					tdata->cipher_iv.len);
4505 	if (retval < 0)
4506 		return retval;
4507 
4508 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4509 	/* Append data which is padded to a multiple of */
4510 	/* the algorithms block size */
4511 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4512 
4513 	if (sgl_in)
4514 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4515 				plaintext_pad_len, 10, 0);
4516 	else {
4517 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4518 		rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4519 	}
4520 
4521 	if (sgl_out)
4522 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4523 				plaintext_pad_len, 3, 0);
4524 	else {
4525 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4526 		rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4527 	}
4528 
4529 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4530 			"Failed to allocate input buffer in mempool");
4531 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4532 			"Failed to allocate output buffer in mempool");
4533 
4534 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4535 
4536 	/* Create SNOW 3G operation */
4537 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4538 					tdata->cipher_iv.len,
4539 					tdata->validCipherLenInBits.len,
4540 					0);
4541 	if (retval < 0)
4542 		return retval;
4543 
4544 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4545 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4546 					       tdata->cipher_iv.len);
4547 		if (retval != TEST_SUCCESS)
4548 			return retval;
4549 	} else
4550 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4551 						ut_params->op);
4552 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4553 
4554 	ut_params->obuf = ut_params->op->sym->m_dst;
4555 	if (ut_params->obuf)
4556 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4557 				plaintext_len, buffer);
4558 	else
4559 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4560 				plaintext_len, buffer);
4561 
4562 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4563 
4564 	/* Validate obuf */
4565 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4566 		ciphertext,
4567 		tdata->ciphertext.data,
4568 		tdata->validDataLenInBits.len,
4569 		"SNOW 3G Ciphertext data not as expected");
4570 
4571 	return 0;
4572 }
4573 
4574 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4575 static void
4576 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4577 {
4578 	uint8_t curr_byte, prev_byte;
4579 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4580 	uint8_t lower_byte_mask = (1 << offset) - 1;
4581 	unsigned i;
4582 
4583 	prev_byte = buffer[0];
4584 	buffer[0] >>= offset;
4585 
4586 	for (i = 1; i < length_in_bytes; i++) {
4587 		curr_byte = buffer[i];
4588 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4589 				(curr_byte >> offset);
4590 		prev_byte = curr_byte;
4591 	}
4592 }
4593 
4594 static int
4595 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4596 {
4597 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4598 	struct crypto_unittest_params *ut_params = &unittest_params;
4599 	uint8_t *plaintext, *ciphertext;
4600 	int retval;
4601 	uint32_t plaintext_len;
4602 	uint32_t plaintext_pad_len;
4603 	uint8_t extra_offset = 4;
4604 	uint8_t *expected_ciphertext_shifted;
4605 	struct rte_cryptodev_info dev_info;
4606 
4607 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4608 	uint64_t feat_flags = dev_info.feature_flags;
4609 
4610 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4611 			((tdata->validDataLenInBits.len % 8) != 0)) {
4612 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4613 		return TEST_SKIPPED;
4614 	}
4615 
4616 	/* Verify the capabilities */
4617 	struct rte_cryptodev_sym_capability_idx cap_idx;
4618 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4619 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4620 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4621 			&cap_idx) == NULL)
4622 		return TEST_SKIPPED;
4623 
4624 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4625 		return TEST_SKIPPED;
4626 
4627 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4628 		return TEST_SKIPPED;
4629 
4630 	/* Create SNOW 3G session */
4631 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4632 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4633 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4634 					tdata->key.data, tdata->key.len,
4635 					tdata->cipher_iv.len);
4636 	if (retval < 0)
4637 		return retval;
4638 
4639 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4640 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4641 
4642 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4643 			"Failed to allocate input buffer in mempool");
4644 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4645 			"Failed to allocate output buffer in mempool");
4646 
4647 	/* Clear mbuf payload */
4648 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4649 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4650 
4651 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4652 	/*
4653 	 * Append data which is padded to a
4654 	 * multiple of the algorithms block size
4655 	 */
4656 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4657 
4658 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4659 						plaintext_pad_len);
4660 
4661 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4662 
4663 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4664 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4665 
4666 #ifdef RTE_APP_TEST_DEBUG
4667 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4668 #endif
4669 	/* Create SNOW 3G operation */
4670 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4671 					tdata->cipher_iv.len,
4672 					tdata->validCipherLenInBits.len,
4673 					extra_offset);
4674 	if (retval < 0)
4675 		return retval;
4676 
4677 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4678 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4679 					       tdata->cipher_iv.len);
4680 		if (retval != TEST_SUCCESS)
4681 			return retval;
4682 	} else
4683 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4684 						ut_params->op);
4685 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4686 
4687 	ut_params->obuf = ut_params->op->sym->m_dst;
4688 	if (ut_params->obuf)
4689 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4690 	else
4691 		ciphertext = plaintext;
4692 
4693 #ifdef RTE_APP_TEST_DEBUG
4694 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4695 #endif
4696 
4697 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4698 
4699 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4700 			"failed to reserve memory for ciphertext shifted\n");
4701 
4702 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4703 			ceil_byte_length(tdata->ciphertext.len));
4704 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4705 			extra_offset);
4706 	/* Validate obuf */
4707 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4708 		ciphertext,
4709 		expected_ciphertext_shifted,
4710 		tdata->validDataLenInBits.len,
4711 		extra_offset,
4712 		"SNOW 3G Ciphertext data not as expected");
4713 	return 0;
4714 }
4715 
4716 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4717 {
4718 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4719 	struct crypto_unittest_params *ut_params = &unittest_params;
4720 
4721 	int retval;
4722 
4723 	uint8_t *plaintext, *ciphertext;
4724 	unsigned ciphertext_pad_len;
4725 	unsigned ciphertext_len;
4726 	struct rte_cryptodev_info dev_info;
4727 
4728 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4729 	uint64_t feat_flags = dev_info.feature_flags;
4730 
4731 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4732 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4733 		printf("Device doesn't support RAW data-path APIs.\n");
4734 		return TEST_SKIPPED;
4735 	}
4736 
4737 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4738 		return TEST_SKIPPED;
4739 
4740 	/* Verify the capabilities */
4741 	struct rte_cryptodev_sym_capability_idx cap_idx;
4742 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4743 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4744 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4745 			&cap_idx) == NULL)
4746 		return TEST_SKIPPED;
4747 
4748 	/* Create SNOW 3G session */
4749 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4750 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4751 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4752 					tdata->key.data, tdata->key.len,
4753 					tdata->cipher_iv.len);
4754 	if (retval < 0)
4755 		return retval;
4756 
4757 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4758 
4759 	/* Clear mbuf payload */
4760 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4761 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4762 
4763 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4764 	/* Append data which is padded to a multiple of */
4765 	/* the algorithms block size */
4766 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4767 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4768 				ciphertext_pad_len);
4769 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4770 
4771 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4772 
4773 	/* Create SNOW 3G operation */
4774 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4775 					tdata->cipher_iv.len,
4776 					tdata->validCipherLenInBits.len,
4777 					tdata->cipher.offset_bits);
4778 	if (retval < 0)
4779 		return retval;
4780 
4781 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4782 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4783 					       tdata->cipher_iv.len);
4784 		if (retval != TEST_SUCCESS)
4785 			return retval;
4786 	} else
4787 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4788 						ut_params->op);
4789 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4790 	ut_params->obuf = ut_params->op->sym->m_dst;
4791 	if (ut_params->obuf)
4792 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4793 	else
4794 		plaintext = ciphertext;
4795 
4796 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4797 
4798 	/* Validate obuf */
4799 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4800 				tdata->plaintext.data,
4801 				tdata->validDataLenInBits.len,
4802 				"SNOW 3G Plaintext data not as expected");
4803 	return 0;
4804 }
4805 
4806 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4807 {
4808 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4809 	struct crypto_unittest_params *ut_params = &unittest_params;
4810 
4811 	int retval;
4812 
4813 	uint8_t *plaintext, *ciphertext;
4814 	unsigned ciphertext_pad_len;
4815 	unsigned ciphertext_len;
4816 	struct rte_cryptodev_info dev_info;
4817 
4818 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4819 	uint64_t feat_flags = dev_info.feature_flags;
4820 
4821 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4822 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4823 		printf("Device does not support RAW data-path APIs.\n");
4824 		return -ENOTSUP;
4825 	}
4826 	/* Verify the capabilities */
4827 	struct rte_cryptodev_sym_capability_idx cap_idx;
4828 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4829 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4830 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4831 			&cap_idx) == NULL)
4832 		return TEST_SKIPPED;
4833 
4834 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4835 		return TEST_SKIPPED;
4836 
4837 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4838 		return TEST_SKIPPED;
4839 
4840 	/* Create SNOW 3G session */
4841 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4842 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4843 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4844 					tdata->key.data, tdata->key.len,
4845 					tdata->cipher_iv.len);
4846 	if (retval < 0)
4847 		return retval;
4848 
4849 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4850 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4851 
4852 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4853 			"Failed to allocate input buffer");
4854 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4855 			"Failed to allocate output buffer");
4856 
4857 	/* Clear mbuf payload */
4858 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4859 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4860 
4861 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4862 		       rte_pktmbuf_tailroom(ut_params->obuf));
4863 
4864 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4865 	/* Append data which is padded to a multiple of */
4866 	/* the algorithms block size */
4867 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4868 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4869 				ciphertext_pad_len);
4870 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4871 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4872 
4873 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4874 
4875 	/* Create SNOW 3G operation */
4876 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4877 					tdata->cipher_iv.len,
4878 					tdata->validCipherLenInBits.len,
4879 					0);
4880 	if (retval < 0)
4881 		return retval;
4882 
4883 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4884 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4885 					       tdata->cipher_iv.len);
4886 		if (retval != TEST_SUCCESS)
4887 			return retval;
4888 	} else
4889 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4890 						ut_params->op);
4891 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4892 	ut_params->obuf = ut_params->op->sym->m_dst;
4893 	if (ut_params->obuf)
4894 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4895 	else
4896 		plaintext = ciphertext;
4897 
4898 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4899 
4900 	/* Validate obuf */
4901 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4902 				tdata->plaintext.data,
4903 				tdata->validDataLenInBits.len,
4904 				"SNOW 3G Plaintext data not as expected");
4905 	return 0;
4906 }
4907 
4908 static int
4909 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4910 {
4911 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4912 	struct crypto_unittest_params *ut_params = &unittest_params;
4913 
4914 	int retval;
4915 
4916 	uint8_t *plaintext, *ciphertext;
4917 	unsigned int plaintext_pad_len;
4918 	unsigned int plaintext_len;
4919 
4920 	struct rte_cryptodev_info dev_info;
4921 
4922 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4923 	uint64_t feat_flags = dev_info.feature_flags;
4924 
4925 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4926 			((tdata->validAuthLenInBits.len % 8 != 0) ||
4927 			(tdata->validDataLenInBits.len % 8 != 0))) {
4928 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4929 		return TEST_SKIPPED;
4930 	}
4931 
4932 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4933 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4934 		printf("Device doesn't support RAW data-path APIs.\n");
4935 		return TEST_SKIPPED;
4936 	}
4937 
4938 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4939 		return TEST_SKIPPED;
4940 
4941 	/* Check if device supports ZUC EEA3 */
4942 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
4943 			tdata->key.len, tdata->cipher_iv.len) < 0)
4944 		return TEST_SKIPPED;
4945 
4946 	/* Check if device supports ZUC EIA3 */
4947 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
4948 			tdata->key.len, tdata->auth_iv.len,
4949 			tdata->digest.len) < 0)
4950 		return TEST_SKIPPED;
4951 
4952 	/* Create ZUC session */
4953 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4954 			ts_params->valid_devs[0],
4955 			tdata);
4956 	if (retval != 0)
4957 		return retval;
4958 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4959 
4960 	/* clear mbuf payload */
4961 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4962 			rte_pktmbuf_tailroom(ut_params->ibuf));
4963 
4964 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4965 	/* Append data which is padded to a multiple of */
4966 	/* the algorithms block size */
4967 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4968 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4969 				plaintext_pad_len);
4970 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4971 
4972 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4973 
4974 	/* Create ZUC operation */
4975 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4976 	if (retval < 0)
4977 		return retval;
4978 
4979 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4980 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
4981 					       tdata->cipher_iv.len);
4982 		if (retval != TEST_SUCCESS)
4983 			return retval;
4984 	} else
4985 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4986 			ut_params->op);
4987 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4988 	ut_params->obuf = ut_params->op->sym->m_src;
4989 	if (ut_params->obuf)
4990 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4991 	else
4992 		ciphertext = plaintext;
4993 
4994 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4995 	/* Validate obuf */
4996 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4997 			ciphertext,
4998 			tdata->ciphertext.data,
4999 			tdata->validDataLenInBits.len,
5000 			"ZUC Ciphertext data not as expected");
5001 
5002 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5003 						    uint8_t *,
5004 						    plaintext_pad_len);
5005 
5006 	/* Validate obuf */
5007 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5008 			ut_params->digest,
5009 			tdata->digest.data,
5010 			tdata->digest.len,
5011 			"ZUC Generated auth tag not as expected");
5012 	return 0;
5013 }
5014 
5015 static int
5016 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5017 {
5018 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5019 	struct crypto_unittest_params *ut_params = &unittest_params;
5020 
5021 	int retval;
5022 
5023 	uint8_t *plaintext, *ciphertext;
5024 	unsigned plaintext_pad_len;
5025 	unsigned plaintext_len;
5026 	struct rte_cryptodev_info dev_info;
5027 
5028 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5029 	uint64_t feat_flags = dev_info.feature_flags;
5030 
5031 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5032 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5033 		printf("Device doesn't support RAW data-path APIs.\n");
5034 		return TEST_SKIPPED;
5035 	}
5036 
5037 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5038 		return TEST_SKIPPED;
5039 
5040 	/* Verify the capabilities */
5041 	struct rte_cryptodev_sym_capability_idx cap_idx;
5042 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5043 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5044 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5045 			&cap_idx) == NULL)
5046 		return TEST_SKIPPED;
5047 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5048 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5049 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5050 			&cap_idx) == NULL)
5051 		return TEST_SKIPPED;
5052 
5053 	/* Create SNOW 3G session */
5054 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5055 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5056 			RTE_CRYPTO_AUTH_OP_GENERATE,
5057 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5058 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5059 			tdata->key.data, tdata->key.len,
5060 			tdata->key.data, tdata->key.len,
5061 			tdata->auth_iv.len, tdata->digest.len,
5062 			tdata->cipher_iv.len);
5063 	if (retval != 0)
5064 		return retval;
5065 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5066 
5067 	/* clear mbuf payload */
5068 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5069 			rte_pktmbuf_tailroom(ut_params->ibuf));
5070 
5071 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5072 	/* Append data which is padded to a multiple of */
5073 	/* the algorithms block size */
5074 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5075 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5076 				plaintext_pad_len);
5077 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5078 
5079 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5080 
5081 	/* Create SNOW 3G operation */
5082 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5083 			tdata->digest.len, tdata->auth_iv.data,
5084 			tdata->auth_iv.len,
5085 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5086 			tdata->cipher_iv.data, tdata->cipher_iv.len,
5087 			tdata->validCipherLenInBits.len,
5088 			0,
5089 			tdata->validAuthLenInBits.len,
5090 			0
5091 			);
5092 	if (retval < 0)
5093 		return retval;
5094 
5095 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5096 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5097 					       tdata->cipher_iv.len);
5098 		if (retval != TEST_SUCCESS)
5099 			return retval;
5100 	} else
5101 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5102 			ut_params->op);
5103 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5104 	ut_params->obuf = ut_params->op->sym->m_src;
5105 	if (ut_params->obuf)
5106 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5107 	else
5108 		ciphertext = plaintext;
5109 
5110 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5111 	/* Validate obuf */
5112 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5113 			ciphertext,
5114 			tdata->ciphertext.data,
5115 			tdata->validDataLenInBits.len,
5116 			"SNOW 3G Ciphertext data not as expected");
5117 
5118 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5119 						    uint8_t *,
5120 						    plaintext_pad_len);
5121 
5122 	/* Validate obuf */
5123 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5124 			ut_params->digest,
5125 			tdata->digest.data,
5126 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5127 			"SNOW 3G Generated auth tag not as expected");
5128 	return 0;
5129 }
5130 
5131 static int
5132 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5133 	uint8_t op_mode, uint8_t verify)
5134 {
5135 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5136 	struct crypto_unittest_params *ut_params = &unittest_params;
5137 
5138 	int retval;
5139 
5140 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5141 	unsigned int plaintext_pad_len;
5142 	unsigned int plaintext_len;
5143 	unsigned int ciphertext_pad_len;
5144 	unsigned int ciphertext_len;
5145 	unsigned int digest_offset;
5146 
5147 	struct rte_cryptodev_info dev_info;
5148 
5149 	/* Verify the capabilities */
5150 	struct rte_cryptodev_sym_capability_idx cap_idx;
5151 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5152 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5153 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5154 			&cap_idx) == NULL)
5155 		return TEST_SKIPPED;
5156 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5157 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5158 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5159 			&cap_idx) == NULL)
5160 		return TEST_SKIPPED;
5161 
5162 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5163 		return TEST_SKIPPED;
5164 
5165 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5166 
5167 	uint64_t feat_flags = dev_info.feature_flags;
5168 
5169 	if (op_mode == OUT_OF_PLACE) {
5170 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5171 			printf("Device doesn't support digest encrypted.\n");
5172 			return TEST_SKIPPED;
5173 		}
5174 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5175 			return TEST_SKIPPED;
5176 	}
5177 
5178 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5179 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5180 		printf("Device doesn't support RAW data-path APIs.\n");
5181 		return TEST_SKIPPED;
5182 	}
5183 
5184 	/* Create SNOW 3G session */
5185 	retval = create_wireless_algo_auth_cipher_session(
5186 			ts_params->valid_devs[0],
5187 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5188 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5189 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5190 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5191 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5192 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5193 			tdata->key.data, tdata->key.len,
5194 			tdata->key.data, tdata->key.len,
5195 			tdata->auth_iv.len, tdata->digest.len,
5196 			tdata->cipher_iv.len);
5197 	if (retval != 0)
5198 		return retval;
5199 
5200 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5201 	if (op_mode == OUT_OF_PLACE)
5202 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5203 
5204 	/* clear mbuf payload */
5205 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5206 		rte_pktmbuf_tailroom(ut_params->ibuf));
5207 	if (op_mode == OUT_OF_PLACE)
5208 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5209 			rte_pktmbuf_tailroom(ut_params->obuf));
5210 
5211 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5212 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5213 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5214 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5215 
5216 	if (verify) {
5217 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5218 					ciphertext_pad_len);
5219 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5220 		if (op_mode == OUT_OF_PLACE)
5221 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5222 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5223 			ciphertext_len);
5224 	} else {
5225 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5226 					plaintext_pad_len);
5227 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5228 		if (op_mode == OUT_OF_PLACE)
5229 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5230 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5231 	}
5232 
5233 	/* Create SNOW 3G operation */
5234 	retval = create_wireless_algo_auth_cipher_operation(
5235 		tdata->digest.data, tdata->digest.len,
5236 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5237 		tdata->auth_iv.data, tdata->auth_iv.len,
5238 		(tdata->digest.offset_bytes == 0 ?
5239 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5240 			: tdata->digest.offset_bytes),
5241 		tdata->validCipherLenInBits.len,
5242 		tdata->cipher.offset_bits,
5243 		tdata->validAuthLenInBits.len,
5244 		tdata->auth.offset_bits,
5245 		op_mode, 0, verify);
5246 
5247 	if (retval < 0)
5248 		return retval;
5249 
5250 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5251 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5252 					       tdata->cipher_iv.len);
5253 		if (retval != TEST_SUCCESS)
5254 			return retval;
5255 	} else
5256 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5257 			ut_params->op);
5258 
5259 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5260 
5261 	ut_params->obuf = (op_mode == IN_PLACE ?
5262 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5263 
5264 	if (verify) {
5265 		if (ut_params->obuf)
5266 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5267 							uint8_t *);
5268 		else
5269 			plaintext = ciphertext +
5270 				(tdata->cipher.offset_bits >> 3);
5271 
5272 		debug_hexdump(stdout, "plaintext:", plaintext,
5273 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5274 		debug_hexdump(stdout, "plaintext expected:",
5275 			tdata->plaintext.data,
5276 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5277 	} else {
5278 		if (ut_params->obuf)
5279 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5280 							uint8_t *);
5281 		else
5282 			ciphertext = plaintext;
5283 
5284 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5285 			ciphertext_len);
5286 		debug_hexdump(stdout, "ciphertext expected:",
5287 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5288 
5289 		if (tdata->digest.offset_bytes == 0)
5290 			digest_offset = plaintext_pad_len;
5291 		else
5292 			digest_offset = tdata->digest.offset_bytes;
5293 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5294 						    uint8_t *, digest_offset);
5295 
5296 		debug_hexdump(stdout, "digest:", ut_params->digest,
5297 			tdata->digest.len);
5298 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5299 				tdata->digest.len);
5300 	}
5301 
5302 	/* Validate obuf */
5303 	if (verify) {
5304 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5305 			plaintext,
5306 			tdata->plaintext.data,
5307 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5308 			 (tdata->digest.len << 3)),
5309 			tdata->cipher.offset_bits,
5310 			"SNOW 3G Plaintext data not as expected");
5311 	} else {
5312 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5313 			ciphertext,
5314 			tdata->ciphertext.data,
5315 			(tdata->validDataLenInBits.len -
5316 			 tdata->cipher.offset_bits),
5317 			tdata->cipher.offset_bits,
5318 			"SNOW 3G Ciphertext data not as expected");
5319 
5320 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5321 			ut_params->digest,
5322 			tdata->digest.data,
5323 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5324 			"SNOW 3G Generated auth tag not as expected");
5325 	}
5326 	return 0;
5327 }
5328 
5329 static int
5330 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5331 	uint8_t op_mode, uint8_t verify)
5332 {
5333 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5334 	struct crypto_unittest_params *ut_params = &unittest_params;
5335 
5336 	int retval;
5337 
5338 	const uint8_t *plaintext = NULL;
5339 	const uint8_t *ciphertext = NULL;
5340 	const uint8_t *digest = NULL;
5341 	unsigned int plaintext_pad_len;
5342 	unsigned int plaintext_len;
5343 	unsigned int ciphertext_pad_len;
5344 	unsigned int ciphertext_len;
5345 	uint8_t buffer[10000];
5346 	uint8_t digest_buffer[10000];
5347 
5348 	struct rte_cryptodev_info dev_info;
5349 
5350 	/* Verify the capabilities */
5351 	struct rte_cryptodev_sym_capability_idx cap_idx;
5352 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5353 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5354 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5355 			&cap_idx) == NULL)
5356 		return TEST_SKIPPED;
5357 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5358 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5359 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5360 			&cap_idx) == NULL)
5361 		return TEST_SKIPPED;
5362 
5363 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5364 		return TEST_SKIPPED;
5365 
5366 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5367 
5368 	uint64_t feat_flags = dev_info.feature_flags;
5369 
5370 	if (op_mode == IN_PLACE) {
5371 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5372 			printf("Device doesn't support in-place scatter-gather "
5373 					"in both input and output mbufs.\n");
5374 			return TEST_SKIPPED;
5375 		}
5376 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5377 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5378 			printf("Device doesn't support RAW data-path APIs.\n");
5379 			return TEST_SKIPPED;
5380 		}
5381 	} else {
5382 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5383 			return TEST_SKIPPED;
5384 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5385 			printf("Device doesn't support out-of-place scatter-gather "
5386 					"in both input and output mbufs.\n");
5387 			return TEST_SKIPPED;
5388 		}
5389 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5390 			printf("Device doesn't support digest encrypted.\n");
5391 			return TEST_SKIPPED;
5392 		}
5393 	}
5394 
5395 	/* Create SNOW 3G session */
5396 	retval = create_wireless_algo_auth_cipher_session(
5397 			ts_params->valid_devs[0],
5398 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5399 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5400 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5401 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5402 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5403 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5404 			tdata->key.data, tdata->key.len,
5405 			tdata->key.data, tdata->key.len,
5406 			tdata->auth_iv.len, tdata->digest.len,
5407 			tdata->cipher_iv.len);
5408 
5409 	if (retval != 0)
5410 		return retval;
5411 
5412 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5413 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5414 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5415 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5416 
5417 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5418 			plaintext_pad_len, 15, 0);
5419 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5420 			"Failed to allocate input buffer in mempool");
5421 
5422 	if (op_mode == OUT_OF_PLACE) {
5423 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5424 				plaintext_pad_len, 15, 0);
5425 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5426 				"Failed to allocate output buffer in mempool");
5427 	}
5428 
5429 	if (verify) {
5430 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5431 			tdata->ciphertext.data);
5432 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5433 					ciphertext_len, buffer);
5434 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5435 			ciphertext_len);
5436 	} else {
5437 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5438 			tdata->plaintext.data);
5439 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5440 					plaintext_len, buffer);
5441 		debug_hexdump(stdout, "plaintext:", plaintext,
5442 			plaintext_len);
5443 	}
5444 	memset(buffer, 0, sizeof(buffer));
5445 
5446 	/* Create SNOW 3G operation */
5447 	retval = create_wireless_algo_auth_cipher_operation(
5448 		tdata->digest.data, tdata->digest.len,
5449 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5450 		tdata->auth_iv.data, tdata->auth_iv.len,
5451 		(tdata->digest.offset_bytes == 0 ?
5452 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5453 			: tdata->digest.offset_bytes),
5454 		tdata->validCipherLenInBits.len,
5455 		tdata->cipher.offset_bits,
5456 		tdata->validAuthLenInBits.len,
5457 		tdata->auth.offset_bits,
5458 		op_mode, 1, verify);
5459 
5460 	if (retval < 0)
5461 		return retval;
5462 
5463 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5464 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5465 					       tdata->cipher_iv.len);
5466 		if (retval != TEST_SUCCESS)
5467 			return retval;
5468 	} else
5469 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5470 			ut_params->op);
5471 
5472 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5473 
5474 	ut_params->obuf = (op_mode == IN_PLACE ?
5475 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5476 
5477 	if (verify) {
5478 		if (ut_params->obuf)
5479 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5480 					plaintext_len, buffer);
5481 		else
5482 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5483 					plaintext_len, buffer);
5484 
5485 		debug_hexdump(stdout, "plaintext:", plaintext,
5486 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5487 		debug_hexdump(stdout, "plaintext expected:",
5488 			tdata->plaintext.data,
5489 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5490 	} else {
5491 		if (ut_params->obuf)
5492 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5493 					ciphertext_len, buffer);
5494 		else
5495 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5496 					ciphertext_len, buffer);
5497 
5498 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5499 			ciphertext_len);
5500 		debug_hexdump(stdout, "ciphertext expected:",
5501 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5502 
5503 		if (ut_params->obuf)
5504 			digest = rte_pktmbuf_read(ut_params->obuf,
5505 				(tdata->digest.offset_bytes == 0 ?
5506 				plaintext_pad_len : tdata->digest.offset_bytes),
5507 				tdata->digest.len, digest_buffer);
5508 		else
5509 			digest = rte_pktmbuf_read(ut_params->ibuf,
5510 				(tdata->digest.offset_bytes == 0 ?
5511 				plaintext_pad_len : tdata->digest.offset_bytes),
5512 				tdata->digest.len, digest_buffer);
5513 
5514 		debug_hexdump(stdout, "digest:", digest,
5515 			tdata->digest.len);
5516 		debug_hexdump(stdout, "digest expected:",
5517 			tdata->digest.data, tdata->digest.len);
5518 	}
5519 
5520 	/* Validate obuf */
5521 	if (verify) {
5522 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5523 			plaintext,
5524 			tdata->plaintext.data,
5525 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5526 			 (tdata->digest.len << 3)),
5527 			tdata->cipher.offset_bits,
5528 			"SNOW 3G Plaintext data not as expected");
5529 	} else {
5530 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5531 			ciphertext,
5532 			tdata->ciphertext.data,
5533 			(tdata->validDataLenInBits.len -
5534 			 tdata->cipher.offset_bits),
5535 			tdata->cipher.offset_bits,
5536 			"SNOW 3G Ciphertext data not as expected");
5537 
5538 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5539 			digest,
5540 			tdata->digest.data,
5541 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5542 			"SNOW 3G Generated auth tag not as expected");
5543 	}
5544 	return 0;
5545 }
5546 
5547 static int
5548 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5549 	uint8_t op_mode, uint8_t verify)
5550 {
5551 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5552 	struct crypto_unittest_params *ut_params = &unittest_params;
5553 
5554 	int retval;
5555 
5556 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5557 	unsigned int plaintext_pad_len;
5558 	unsigned int plaintext_len;
5559 	unsigned int ciphertext_pad_len;
5560 	unsigned int ciphertext_len;
5561 	unsigned int digest_offset;
5562 
5563 	struct rte_cryptodev_info dev_info;
5564 
5565 	/* Verify the capabilities */
5566 	struct rte_cryptodev_sym_capability_idx cap_idx;
5567 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5568 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5569 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5570 			&cap_idx) == NULL)
5571 		return TEST_SKIPPED;
5572 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5573 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5574 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5575 			&cap_idx) == NULL)
5576 		return TEST_SKIPPED;
5577 
5578 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5579 
5580 	uint64_t feat_flags = dev_info.feature_flags;
5581 
5582 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5583 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5584 		printf("Device doesn't support RAW data-path APIs.\n");
5585 		return TEST_SKIPPED;
5586 	}
5587 
5588 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5589 		return TEST_SKIPPED;
5590 
5591 	if (op_mode == OUT_OF_PLACE) {
5592 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5593 			return TEST_SKIPPED;
5594 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5595 			printf("Device doesn't support digest encrypted.\n");
5596 			return TEST_SKIPPED;
5597 		}
5598 	}
5599 
5600 	/* Create KASUMI session */
5601 	retval = create_wireless_algo_auth_cipher_session(
5602 			ts_params->valid_devs[0],
5603 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5604 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5605 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5606 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5607 			RTE_CRYPTO_AUTH_KASUMI_F9,
5608 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5609 			tdata->key.data, tdata->key.len,
5610 			tdata->key.data, tdata->key.len,
5611 			0, tdata->digest.len,
5612 			tdata->cipher_iv.len);
5613 
5614 	if (retval != 0)
5615 		return retval;
5616 
5617 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5618 	if (op_mode == OUT_OF_PLACE)
5619 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5620 
5621 	/* clear mbuf payload */
5622 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5623 		rte_pktmbuf_tailroom(ut_params->ibuf));
5624 	if (op_mode == OUT_OF_PLACE)
5625 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5626 			rte_pktmbuf_tailroom(ut_params->obuf));
5627 
5628 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5629 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5630 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5631 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5632 
5633 	if (verify) {
5634 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5635 					ciphertext_pad_len);
5636 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5637 		if (op_mode == OUT_OF_PLACE)
5638 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5639 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5640 			ciphertext_len);
5641 	} else {
5642 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5643 					plaintext_pad_len);
5644 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5645 		if (op_mode == OUT_OF_PLACE)
5646 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5647 		debug_hexdump(stdout, "plaintext:", plaintext,
5648 			plaintext_len);
5649 	}
5650 
5651 	/* Create KASUMI operation */
5652 	retval = create_wireless_algo_auth_cipher_operation(
5653 		tdata->digest.data, tdata->digest.len,
5654 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5655 		NULL, 0,
5656 		(tdata->digest.offset_bytes == 0 ?
5657 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5658 			: tdata->digest.offset_bytes),
5659 		tdata->validCipherLenInBits.len,
5660 		tdata->validCipherOffsetInBits.len,
5661 		tdata->validAuthLenInBits.len,
5662 		0,
5663 		op_mode, 0, verify);
5664 
5665 	if (retval < 0)
5666 		return retval;
5667 
5668 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5669 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5670 					       tdata->cipher_iv.len);
5671 		if (retval != TEST_SUCCESS)
5672 			return retval;
5673 	} else
5674 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5675 			ut_params->op);
5676 
5677 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5678 
5679 	ut_params->obuf = (op_mode == IN_PLACE ?
5680 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5681 
5682 
5683 	if (verify) {
5684 		if (ut_params->obuf)
5685 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5686 							uint8_t *);
5687 		else
5688 			plaintext = ciphertext;
5689 
5690 		debug_hexdump(stdout, "plaintext:", plaintext,
5691 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5692 		debug_hexdump(stdout, "plaintext expected:",
5693 			tdata->plaintext.data,
5694 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5695 	} else {
5696 		if (ut_params->obuf)
5697 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5698 							uint8_t *);
5699 		else
5700 			ciphertext = plaintext;
5701 
5702 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5703 			ciphertext_len);
5704 		debug_hexdump(stdout, "ciphertext expected:",
5705 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5706 
5707 		if (tdata->digest.offset_bytes == 0)
5708 			digest_offset = plaintext_pad_len;
5709 		else
5710 			digest_offset = tdata->digest.offset_bytes;
5711 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5712 						    uint8_t *, digest_offset);
5713 
5714 		debug_hexdump(stdout, "digest:", ut_params->digest,
5715 			tdata->digest.len);
5716 		debug_hexdump(stdout, "digest expected:",
5717 			tdata->digest.data, tdata->digest.len);
5718 	}
5719 
5720 	/* Validate obuf */
5721 	if (verify) {
5722 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5723 			plaintext,
5724 			tdata->plaintext.data,
5725 			tdata->plaintext.len >> 3,
5726 			"KASUMI Plaintext data not as expected");
5727 	} else {
5728 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5729 			ciphertext,
5730 			tdata->ciphertext.data,
5731 			tdata->ciphertext.len >> 3,
5732 			"KASUMI Ciphertext data not as expected");
5733 
5734 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5735 			ut_params->digest,
5736 			tdata->digest.data,
5737 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5738 			"KASUMI Generated auth tag not as expected");
5739 	}
5740 	return 0;
5741 }
5742 
5743 static int
5744 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5745 	uint8_t op_mode, uint8_t verify)
5746 {
5747 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5748 	struct crypto_unittest_params *ut_params = &unittest_params;
5749 
5750 	int retval;
5751 
5752 	const uint8_t *plaintext = NULL;
5753 	const uint8_t *ciphertext = NULL;
5754 	const uint8_t *digest = NULL;
5755 	unsigned int plaintext_pad_len;
5756 	unsigned int plaintext_len;
5757 	unsigned int ciphertext_pad_len;
5758 	unsigned int ciphertext_len;
5759 	uint8_t buffer[10000];
5760 	uint8_t digest_buffer[10000];
5761 
5762 	struct rte_cryptodev_info dev_info;
5763 
5764 	/* Verify the capabilities */
5765 	struct rte_cryptodev_sym_capability_idx cap_idx;
5766 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5767 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5768 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5769 			&cap_idx) == NULL)
5770 		return TEST_SKIPPED;
5771 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5772 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5773 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5774 			&cap_idx) == NULL)
5775 		return TEST_SKIPPED;
5776 
5777 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5778 		return TEST_SKIPPED;
5779 
5780 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5781 
5782 	uint64_t feat_flags = dev_info.feature_flags;
5783 
5784 	if (op_mode == IN_PLACE) {
5785 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5786 			printf("Device doesn't support in-place scatter-gather "
5787 					"in both input and output mbufs.\n");
5788 			return TEST_SKIPPED;
5789 		}
5790 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5791 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5792 			printf("Device doesn't support RAW data-path APIs.\n");
5793 			return TEST_SKIPPED;
5794 		}
5795 	} else {
5796 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5797 			return TEST_SKIPPED;
5798 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5799 			printf("Device doesn't support out-of-place scatter-gather "
5800 					"in both input and output mbufs.\n");
5801 			return TEST_SKIPPED;
5802 		}
5803 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5804 			printf("Device doesn't support digest encrypted.\n");
5805 			return TEST_SKIPPED;
5806 		}
5807 	}
5808 
5809 	/* Create KASUMI session */
5810 	retval = create_wireless_algo_auth_cipher_session(
5811 			ts_params->valid_devs[0],
5812 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5813 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5814 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5815 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5816 			RTE_CRYPTO_AUTH_KASUMI_F9,
5817 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5818 			tdata->key.data, tdata->key.len,
5819 			tdata->key.data, tdata->key.len,
5820 			0, tdata->digest.len,
5821 			tdata->cipher_iv.len);
5822 
5823 	if (retval != 0)
5824 		return retval;
5825 
5826 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5827 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5828 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5829 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5830 
5831 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5832 			plaintext_pad_len, 15, 0);
5833 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5834 			"Failed to allocate input buffer in mempool");
5835 
5836 	if (op_mode == OUT_OF_PLACE) {
5837 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5838 				plaintext_pad_len, 15, 0);
5839 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5840 				"Failed to allocate output buffer in mempool");
5841 	}
5842 
5843 	if (verify) {
5844 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5845 			tdata->ciphertext.data);
5846 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5847 					ciphertext_len, buffer);
5848 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5849 			ciphertext_len);
5850 	} else {
5851 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5852 			tdata->plaintext.data);
5853 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5854 					plaintext_len, buffer);
5855 		debug_hexdump(stdout, "plaintext:", plaintext,
5856 			plaintext_len);
5857 	}
5858 	memset(buffer, 0, sizeof(buffer));
5859 
5860 	/* Create KASUMI operation */
5861 	retval = create_wireless_algo_auth_cipher_operation(
5862 		tdata->digest.data, tdata->digest.len,
5863 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5864 		NULL, 0,
5865 		(tdata->digest.offset_bytes == 0 ?
5866 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5867 			: tdata->digest.offset_bytes),
5868 		tdata->validCipherLenInBits.len,
5869 		tdata->validCipherOffsetInBits.len,
5870 		tdata->validAuthLenInBits.len,
5871 		0,
5872 		op_mode, 1, verify);
5873 
5874 	if (retval < 0)
5875 		return retval;
5876 
5877 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5878 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5879 					       tdata->cipher_iv.len);
5880 		if (retval != TEST_SUCCESS)
5881 			return retval;
5882 	} else
5883 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5884 			ut_params->op);
5885 
5886 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5887 
5888 	ut_params->obuf = (op_mode == IN_PLACE ?
5889 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5890 
5891 	if (verify) {
5892 		if (ut_params->obuf)
5893 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5894 					plaintext_len, buffer);
5895 		else
5896 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5897 					plaintext_len, buffer);
5898 
5899 		debug_hexdump(stdout, "plaintext:", plaintext,
5900 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5901 		debug_hexdump(stdout, "plaintext expected:",
5902 			tdata->plaintext.data,
5903 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5904 	} else {
5905 		if (ut_params->obuf)
5906 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5907 					ciphertext_len, buffer);
5908 		else
5909 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5910 					ciphertext_len, buffer);
5911 
5912 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5913 			ciphertext_len);
5914 		debug_hexdump(stdout, "ciphertext expected:",
5915 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5916 
5917 		if (ut_params->obuf)
5918 			digest = rte_pktmbuf_read(ut_params->obuf,
5919 				(tdata->digest.offset_bytes == 0 ?
5920 				plaintext_pad_len : tdata->digest.offset_bytes),
5921 				tdata->digest.len, digest_buffer);
5922 		else
5923 			digest = rte_pktmbuf_read(ut_params->ibuf,
5924 				(tdata->digest.offset_bytes == 0 ?
5925 				plaintext_pad_len : tdata->digest.offset_bytes),
5926 				tdata->digest.len, digest_buffer);
5927 
5928 		debug_hexdump(stdout, "digest:", digest,
5929 			tdata->digest.len);
5930 		debug_hexdump(stdout, "digest expected:",
5931 			tdata->digest.data, tdata->digest.len);
5932 	}
5933 
5934 	/* Validate obuf */
5935 	if (verify) {
5936 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5937 			plaintext,
5938 			tdata->plaintext.data,
5939 			tdata->plaintext.len >> 3,
5940 			"KASUMI Plaintext data not as expected");
5941 	} else {
5942 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5943 			ciphertext,
5944 			tdata->ciphertext.data,
5945 			tdata->validDataLenInBits.len,
5946 			"KASUMI Ciphertext data not as expected");
5947 
5948 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5949 			digest,
5950 			tdata->digest.data,
5951 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5952 			"KASUMI Generated auth tag not as expected");
5953 	}
5954 	return 0;
5955 }
5956 
5957 static int
5958 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5959 {
5960 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5961 	struct crypto_unittest_params *ut_params = &unittest_params;
5962 
5963 	int retval;
5964 
5965 	uint8_t *plaintext, *ciphertext;
5966 	unsigned plaintext_pad_len;
5967 	unsigned plaintext_len;
5968 	struct rte_cryptodev_info dev_info;
5969 
5970 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5971 	uint64_t feat_flags = dev_info.feature_flags;
5972 
5973 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5974 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5975 		printf("Device doesn't support RAW data-path APIs.\n");
5976 		return TEST_SKIPPED;
5977 	}
5978 
5979 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5980 		return TEST_SKIPPED;
5981 
5982 	/* Verify the capabilities */
5983 	struct rte_cryptodev_sym_capability_idx cap_idx;
5984 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5985 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5986 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5987 			&cap_idx) == NULL)
5988 		return TEST_SKIPPED;
5989 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5990 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5991 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5992 			&cap_idx) == NULL)
5993 		return TEST_SKIPPED;
5994 
5995 	/* Create KASUMI session */
5996 	retval = create_wireless_algo_cipher_auth_session(
5997 			ts_params->valid_devs[0],
5998 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5999 			RTE_CRYPTO_AUTH_OP_GENERATE,
6000 			RTE_CRYPTO_AUTH_KASUMI_F9,
6001 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6002 			tdata->key.data, tdata->key.len,
6003 			tdata->key.data, tdata->key.len,
6004 			0, tdata->digest.len,
6005 			tdata->cipher_iv.len);
6006 	if (retval != 0)
6007 		return retval;
6008 
6009 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6010 
6011 	/* clear mbuf payload */
6012 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6013 			rte_pktmbuf_tailroom(ut_params->ibuf));
6014 
6015 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6016 	/* Append data which is padded to a multiple of */
6017 	/* the algorithms block size */
6018 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6019 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6020 				plaintext_pad_len);
6021 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6022 
6023 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6024 
6025 	/* Create KASUMI operation */
6026 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6027 				tdata->digest.len, NULL, 0,
6028 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6029 				tdata->cipher_iv.data, tdata->cipher_iv.len,
6030 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6031 				tdata->validCipherOffsetInBits.len,
6032 				tdata->validAuthLenInBits.len,
6033 				0
6034 				);
6035 	if (retval < 0)
6036 		return retval;
6037 
6038 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6039 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6040 					       tdata->cipher_iv.len);
6041 		if (retval != TEST_SUCCESS)
6042 			return retval;
6043 	} else
6044 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6045 			ut_params->op);
6046 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6047 
6048 	if (ut_params->op->sym->m_dst)
6049 		ut_params->obuf = ut_params->op->sym->m_dst;
6050 	else
6051 		ut_params->obuf = ut_params->op->sym->m_src;
6052 
6053 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6054 				tdata->validCipherOffsetInBits.len >> 3);
6055 
6056 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6057 						    uint8_t *,
6058 						    plaintext_pad_len);
6059 
6060 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6061 				(tdata->validCipherOffsetInBits.len >> 3);
6062 	/* Validate obuf */
6063 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6064 		ciphertext,
6065 		reference_ciphertext,
6066 		tdata->validCipherLenInBits.len,
6067 		"KASUMI Ciphertext data not as expected");
6068 
6069 	/* Validate obuf */
6070 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6071 		ut_params->digest,
6072 		tdata->digest.data,
6073 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6074 		"KASUMI Generated auth tag not as expected");
6075 	return 0;
6076 }
6077 
6078 static int
6079 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6080 			const enum rte_crypto_cipher_algorithm cipher_algo,
6081 			const uint16_t key_size, const uint16_t iv_size)
6082 {
6083 	struct rte_cryptodev_sym_capability_idx cap_idx;
6084 	const struct rte_cryptodev_symmetric_capability *cap;
6085 
6086 	/* Check if device supports the algorithm */
6087 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6088 	cap_idx.algo.cipher = cipher_algo;
6089 
6090 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6091 			&cap_idx);
6092 
6093 	if (cap == NULL)
6094 		return -1;
6095 
6096 	/* Check if device supports key size and IV size */
6097 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6098 			iv_size) < 0) {
6099 		return -1;
6100 	}
6101 
6102 	return 0;
6103 }
6104 
6105 static int
6106 check_auth_capability(const struct crypto_testsuite_params *ts_params,
6107 			const enum rte_crypto_auth_algorithm auth_algo,
6108 			const uint16_t key_size, const uint16_t iv_size,
6109 			const uint16_t tag_size)
6110 {
6111 	struct rte_cryptodev_sym_capability_idx cap_idx;
6112 	const struct rte_cryptodev_symmetric_capability *cap;
6113 
6114 	/* Check if device supports the algorithm */
6115 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6116 	cap_idx.algo.auth = auth_algo;
6117 
6118 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6119 			&cap_idx);
6120 
6121 	if (cap == NULL)
6122 		return -1;
6123 
6124 	/* Check if device supports key size and IV size */
6125 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6126 			tag_size, iv_size) < 0) {
6127 		return -1;
6128 	}
6129 
6130 	return 0;
6131 }
6132 
6133 static int
6134 test_zuc_cipher(const struct wireless_test_data *tdata,
6135 		enum rte_crypto_cipher_operation direction)
6136 {
6137 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6138 	struct crypto_unittest_params *ut_params = &unittest_params;
6139 
6140 	int retval;
6141 	uint8_t *plaintext = NULL;
6142 	uint8_t *ciphertext = NULL;
6143 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6144 	unsigned int plaintext_len = 0;
6145 	unsigned int ciphertext_len = 0;
6146 	struct rte_cryptodev_info dev_info;
6147 
6148 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6149 	uint64_t feat_flags = dev_info.feature_flags;
6150 
6151 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6152 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6153 		printf("Device doesn't support RAW data-path APIs.\n");
6154 		return TEST_SKIPPED;
6155 	}
6156 
6157 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6158 		return TEST_SKIPPED;
6159 
6160 	/* Check if device supports ZUC EEA3 */
6161 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6162 			tdata->key.len, tdata->cipher_iv.len) < 0)
6163 		return TEST_SKIPPED;
6164 
6165 	/* Create ZUC session */
6166 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6167 					direction,
6168 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
6169 					tdata->key.data, tdata->key.len,
6170 					tdata->cipher_iv.len);
6171 	if (retval != 0)
6172 		return retval;
6173 
6174 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6175 
6176 	/* Clear mbuf payload */
6177 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6178 	       rte_pktmbuf_tailroom(ut_params->ibuf));
6179 
6180 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6181 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6182 		/* Append data which is padded to a multiple */
6183 		/* of the algorithms block size */
6184 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6185 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6186 				plaintext_pad_len);
6187 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6188 
6189 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6190 	} else {
6191 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6192 		/* Append data which is padded to a multiple */
6193 		/* of the algorithms block size */
6194 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6195 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6196 				ciphertext_pad_len);
6197 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6198 
6199 		debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6200 	}
6201 
6202 	/* Create ZUC operation */
6203 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6204 					tdata->cipher_iv.len,
6205 					tdata->plaintext.len,
6206 					tdata->validCipherOffsetInBits.len);
6207 	if (retval < 0)
6208 		return retval;
6209 
6210 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6211 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6212 					       tdata->cipher_iv.len);
6213 		if (retval != TEST_SUCCESS)
6214 			return retval;
6215 	} else
6216 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6217 						ut_params->op);
6218 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6219 
6220 	ut_params->obuf = ut_params->op->sym->m_dst;
6221 
6222 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6223 		if (ut_params->obuf)
6224 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6225 		else
6226 			ciphertext = plaintext;
6227 
6228 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6229 
6230 		/* Validate obuf */
6231 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6232 				ciphertext,
6233 				tdata->ciphertext.data,
6234 				tdata->validCipherLenInBits.len,
6235 				"ZUC Ciphertext data not as expected");
6236 	} else {
6237 		if (ut_params->obuf)
6238 			plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6239 		else
6240 			plaintext = ciphertext;
6241 
6242 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6243 
6244 		const uint8_t *reference_plaintext = tdata->plaintext.data +
6245 				(tdata->validCipherOffsetInBits.len >> 3);
6246 
6247 		/* Validate obuf */
6248 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6249 				plaintext,
6250 				reference_plaintext,
6251 				tdata->validCipherLenInBits.len,
6252 				"ZUC Plaintext data not as expected");
6253 	}
6254 
6255 	return 0;
6256 }
6257 
6258 static int
6259 test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6260 		enum rte_crypto_cipher_operation direction)
6261 {
6262 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6263 	struct crypto_unittest_params *ut_params = &unittest_params;
6264 
6265 	int retval;
6266 
6267 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6268 	unsigned int plaintext_len = 0;
6269 	unsigned int ciphertext_len = 0;
6270 	const uint8_t *ciphertext, *plaintext;
6271 	uint8_t buffer[2048];
6272 	struct rte_cryptodev_info dev_info;
6273 
6274 	/* Check if device supports ZUC EEA3 */
6275 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6276 			tdata->key.len, tdata->cipher_iv.len) < 0)
6277 		return TEST_SKIPPED;
6278 
6279 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6280 		return TEST_SKIPPED;
6281 
6282 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6283 
6284 	uint64_t feat_flags = dev_info.feature_flags;
6285 
6286 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6287 		printf("Device doesn't support in-place scatter-gather. "
6288 				"Test Skipped.\n");
6289 		return TEST_SKIPPED;
6290 	}
6291 
6292 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6293 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6294 		printf("Device doesn't support RAW data-path APIs.\n");
6295 		return TEST_SKIPPED;
6296 	}
6297 
6298 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6299 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6300 
6301 		/* Append data which is padded to a multiple */
6302 		/* of the algorithms block size */
6303 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6304 
6305 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6306 				plaintext_pad_len, 10, 0);
6307 
6308 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6309 				tdata->plaintext.data);
6310 	} else {
6311 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6312 
6313 		/* Append data which is padded to a multiple */
6314 		/* of the algorithms block size */
6315 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6316 
6317 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6318 				ciphertext_pad_len, 10, 0);
6319 
6320 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6321 				tdata->ciphertext.data);
6322 
6323 	}
6324 
6325 	/* Create ZUC session */
6326 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6327 			direction,
6328 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6329 			tdata->key.data, tdata->key.len,
6330 			tdata->cipher_iv.len);
6331 	if (retval < 0)
6332 		return retval;
6333 
6334 	/* Clear mbuf payload */
6335 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6336 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6337 	else
6338 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6339 
6340 	/* Create ZUC operation */
6341 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6342 			tdata->cipher_iv.len, tdata->plaintext.len,
6343 			tdata->validCipherOffsetInBits.len);
6344 	if (retval < 0)
6345 		return retval;
6346 
6347 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6348 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6349 					       tdata->cipher_iv.len);
6350 		if (retval != TEST_SUCCESS)
6351 			return retval;
6352 	} else
6353 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6354 						ut_params->op);
6355 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6356 
6357 	ut_params->obuf = ut_params->op->sym->m_dst;
6358 
6359 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6360 		if (ut_params->obuf)
6361 			ciphertext = rte_pktmbuf_read(ut_params->obuf,
6362 				0, plaintext_len, buffer);
6363 		else
6364 			ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6365 				0, plaintext_len, buffer);
6366 
6367 		/* Validate obuf */
6368 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6369 
6370 		/* Validate obuf */
6371 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6372 			ciphertext,
6373 			tdata->ciphertext.data,
6374 			tdata->validCipherLenInBits.len,
6375 			"ZUC Ciphertext data not as expected");
6376 	} else {
6377 		if (ut_params->obuf)
6378 			plaintext = rte_pktmbuf_read(ut_params->obuf,
6379 				0, ciphertext_len, buffer);
6380 		else
6381 			plaintext = rte_pktmbuf_read(ut_params->ibuf,
6382 				0, ciphertext_len, buffer);
6383 
6384 		/* Validate obuf */
6385 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6386 
6387 		/* Validate obuf */
6388 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6389 			plaintext,
6390 			tdata->plaintext.data,
6391 			tdata->validCipherLenInBits.len,
6392 			"ZUC Plaintext data not as expected");
6393 		}
6394 
6395 	return 0;
6396 }
6397 
6398 static int
6399 test_zuc_authentication(const struct wireless_test_data *tdata,
6400 		enum rte_crypto_auth_operation auth_op)
6401 {
6402 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6403 	struct crypto_unittest_params *ut_params = &unittest_params;
6404 
6405 	int retval;
6406 	unsigned plaintext_pad_len;
6407 	unsigned plaintext_len;
6408 	uint8_t *plaintext;
6409 
6410 	struct rte_cryptodev_info dev_info;
6411 
6412 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6413 	uint64_t feat_flags = dev_info.feature_flags;
6414 
6415 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6416 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6417 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6418 		return TEST_SKIPPED;
6419 	}
6420 
6421 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6422 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6423 		printf("Device doesn't support RAW data-path APIs.\n");
6424 		return TEST_SKIPPED;
6425 	}
6426 
6427 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6428 		return TEST_SKIPPED;
6429 
6430 	/* Check if device supports ZUC EIA3 */
6431 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6432 			tdata->key.len, tdata->auth_iv.len,
6433 			tdata->digest.len) < 0)
6434 		return TEST_SKIPPED;
6435 
6436 	/* Create ZUC session */
6437 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6438 			tdata->key.data, tdata->key.len,
6439 			tdata->auth_iv.len, tdata->digest.len,
6440 			auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6441 	if (retval != 0)
6442 		return retval;
6443 
6444 	/* alloc mbuf and set payload */
6445 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6446 
6447 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6448 	rte_pktmbuf_tailroom(ut_params->ibuf));
6449 
6450 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6451 	/* Append data which is padded to a multiple of */
6452 	/* the algorithms block size */
6453 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6454 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6455 				plaintext_pad_len);
6456 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6457 
6458 	/* Create ZUC operation */
6459 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
6460 			tdata->digest.len,
6461 			tdata->auth_iv.data, tdata->auth_iv.len,
6462 			plaintext_pad_len,
6463 			auth_op, tdata->validAuthLenInBits.len, 0);
6464 	if (retval < 0)
6465 		return retval;
6466 
6467 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6468 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6469 					       0);
6470 		if (retval != TEST_SUCCESS)
6471 			return retval;
6472 	} else
6473 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6474 				ut_params->op);
6475 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6476 	ut_params->obuf = ut_params->op->sym->m_src;
6477 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6478 						    uint8_t *,
6479 						    plaintext_pad_len);
6480 
6481 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6482 		/* Validate obuf */
6483 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6484 				ut_params->digest,
6485 				tdata->digest.data,
6486 				tdata->digest.len,
6487 				"ZUC Generated auth tag not as expected");
6488 		return 0;
6489 	}
6490 
6491 	/* Validate obuf */
6492 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6493 		return 0;
6494 	else
6495 		return -1;
6496 
6497 	return 0;
6498 }
6499 
6500 static int
6501 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6502 	uint8_t op_mode, uint8_t verify)
6503 {
6504 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6505 	struct crypto_unittest_params *ut_params = &unittest_params;
6506 
6507 	int retval;
6508 
6509 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6510 	unsigned int plaintext_pad_len;
6511 	unsigned int plaintext_len;
6512 	unsigned int ciphertext_pad_len;
6513 	unsigned int ciphertext_len;
6514 	unsigned int digest_offset;
6515 
6516 	struct rte_cryptodev_info dev_info;
6517 
6518 	/* Check if device supports ZUC EEA3 */
6519 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6520 			tdata->key.len, tdata->cipher_iv.len) < 0)
6521 		return TEST_SKIPPED;
6522 
6523 	/* Check if device supports ZUC EIA3 */
6524 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6525 			tdata->key.len, tdata->auth_iv.len,
6526 			tdata->digest.len) < 0)
6527 		return TEST_SKIPPED;
6528 
6529 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6530 		return TEST_SKIPPED;
6531 
6532 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6533 
6534 	uint64_t feat_flags = dev_info.feature_flags;
6535 
6536 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6537 		printf("Device doesn't support digest encrypted.\n");
6538 		return TEST_SKIPPED;
6539 	}
6540 	if (op_mode == IN_PLACE) {
6541 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6542 			printf("Device doesn't support in-place scatter-gather "
6543 					"in both input and output mbufs.\n");
6544 			return TEST_SKIPPED;
6545 		}
6546 
6547 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6548 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6549 			printf("Device doesn't support RAW data-path APIs.\n");
6550 			return TEST_SKIPPED;
6551 		}
6552 	} else {
6553 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6554 			return TEST_SKIPPED;
6555 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6556 			printf("Device doesn't support out-of-place scatter-gather "
6557 					"in both input and output mbufs.\n");
6558 			return TEST_SKIPPED;
6559 		}
6560 	}
6561 
6562 	/* Create ZUC session */
6563 	retval = create_wireless_algo_auth_cipher_session(
6564 			ts_params->valid_devs[0],
6565 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6566 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6567 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6568 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6569 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6570 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6571 			tdata->key.data, tdata->key.len,
6572 			tdata->key.data, tdata->key.len,
6573 			tdata->auth_iv.len, tdata->digest.len,
6574 			tdata->cipher_iv.len);
6575 
6576 	if (retval != 0)
6577 		return retval;
6578 
6579 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6580 	if (op_mode == OUT_OF_PLACE)
6581 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6582 
6583 	/* clear mbuf payload */
6584 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6585 		rte_pktmbuf_tailroom(ut_params->ibuf));
6586 	if (op_mode == OUT_OF_PLACE)
6587 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6588 			rte_pktmbuf_tailroom(ut_params->obuf));
6589 
6590 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6591 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6592 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6593 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6594 
6595 	if (verify) {
6596 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6597 					ciphertext_pad_len);
6598 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6599 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6600 			ciphertext_len);
6601 	} else {
6602 		/* make sure enough space to cover partial digest verify case */
6603 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6604 					ciphertext_pad_len);
6605 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6606 		debug_hexdump(stdout, "plaintext:", plaintext,
6607 			plaintext_len);
6608 	}
6609 
6610 	if (op_mode == OUT_OF_PLACE)
6611 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6612 
6613 	/* Create ZUC operation */
6614 	retval = create_wireless_algo_auth_cipher_operation(
6615 		tdata->digest.data, tdata->digest.len,
6616 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6617 		tdata->auth_iv.data, tdata->auth_iv.len,
6618 		(tdata->digest.offset_bytes == 0 ?
6619 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6620 			: tdata->digest.offset_bytes),
6621 		tdata->validCipherLenInBits.len,
6622 		tdata->validCipherOffsetInBits.len,
6623 		tdata->validAuthLenInBits.len,
6624 		0,
6625 		op_mode, 0, verify);
6626 
6627 	if (retval < 0)
6628 		return retval;
6629 
6630 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6631 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6632 					       tdata->cipher_iv.len);
6633 		if (retval != TEST_SUCCESS)
6634 			return retval;
6635 	} else
6636 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6637 			ut_params->op);
6638 
6639 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6640 
6641 	ut_params->obuf = (op_mode == IN_PLACE ?
6642 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6643 
6644 
6645 	if (verify) {
6646 		if (ut_params->obuf)
6647 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6648 							uint8_t *);
6649 		else
6650 			plaintext = ciphertext;
6651 
6652 		debug_hexdump(stdout, "plaintext:", plaintext,
6653 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6654 		debug_hexdump(stdout, "plaintext expected:",
6655 			tdata->plaintext.data,
6656 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6657 	} else {
6658 		if (ut_params->obuf)
6659 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6660 							uint8_t *);
6661 		else
6662 			ciphertext = plaintext;
6663 
6664 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6665 			ciphertext_len);
6666 		debug_hexdump(stdout, "ciphertext expected:",
6667 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6668 
6669 		if (tdata->digest.offset_bytes == 0)
6670 			digest_offset = plaintext_pad_len;
6671 		else
6672 			digest_offset =  tdata->digest.offset_bytes;
6673 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6674 					    uint8_t *, digest_offset);
6675 
6676 		debug_hexdump(stdout, "digest:", ut_params->digest,
6677 			tdata->digest.len);
6678 		debug_hexdump(stdout, "digest expected:",
6679 			tdata->digest.data, tdata->digest.len);
6680 	}
6681 
6682 	/* Validate obuf */
6683 	if (verify) {
6684 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6685 			plaintext,
6686 			tdata->plaintext.data,
6687 			tdata->plaintext.len >> 3,
6688 			"ZUC Plaintext data not as expected");
6689 	} else {
6690 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6691 			ciphertext,
6692 			tdata->ciphertext.data,
6693 			tdata->ciphertext.len >> 3,
6694 			"ZUC Ciphertext data not as expected");
6695 
6696 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6697 			ut_params->digest,
6698 			tdata->digest.data,
6699 			tdata->digest.len,
6700 			"ZUC Generated auth tag not as expected");
6701 	}
6702 	return 0;
6703 }
6704 
6705 static int
6706 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6707 	uint8_t op_mode, uint8_t verify)
6708 {
6709 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6710 	struct crypto_unittest_params *ut_params = &unittest_params;
6711 
6712 	int retval;
6713 
6714 	const uint8_t *plaintext = NULL;
6715 	const uint8_t *ciphertext = NULL;
6716 	const uint8_t *digest = NULL;
6717 	unsigned int plaintext_pad_len;
6718 	unsigned int plaintext_len;
6719 	unsigned int ciphertext_pad_len;
6720 	unsigned int ciphertext_len;
6721 	uint8_t buffer[10000];
6722 	uint8_t digest_buffer[10000];
6723 
6724 	struct rte_cryptodev_info dev_info;
6725 
6726 	/* Check if device supports ZUC EEA3 */
6727 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6728 			tdata->key.len, tdata->cipher_iv.len) < 0)
6729 		return TEST_SKIPPED;
6730 
6731 	/* Check if device supports ZUC EIA3 */
6732 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6733 			tdata->key.len, tdata->auth_iv.len,
6734 			tdata->digest.len) < 0)
6735 		return TEST_SKIPPED;
6736 
6737 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6738 		return TEST_SKIPPED;
6739 
6740 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6741 
6742 	uint64_t feat_flags = dev_info.feature_flags;
6743 
6744 	if (op_mode == IN_PLACE) {
6745 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6746 			printf("Device doesn't support in-place scatter-gather "
6747 					"in both input and output mbufs.\n");
6748 			return TEST_SKIPPED;
6749 		}
6750 
6751 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6752 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6753 			printf("Device doesn't support RAW data-path APIs.\n");
6754 			return TEST_SKIPPED;
6755 		}
6756 	} else {
6757 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6758 			return TEST_SKIPPED;
6759 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6760 			printf("Device doesn't support out-of-place scatter-gather "
6761 					"in both input and output mbufs.\n");
6762 			return TEST_SKIPPED;
6763 		}
6764 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6765 			printf("Device doesn't support digest encrypted.\n");
6766 			return TEST_SKIPPED;
6767 		}
6768 	}
6769 
6770 	/* Create ZUC session */
6771 	retval = create_wireless_algo_auth_cipher_session(
6772 			ts_params->valid_devs[0],
6773 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6774 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6775 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6776 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6777 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6778 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6779 			tdata->key.data, tdata->key.len,
6780 			tdata->key.data, tdata->key.len,
6781 			tdata->auth_iv.len, tdata->digest.len,
6782 			tdata->cipher_iv.len);
6783 
6784 	if (retval != 0)
6785 		return retval;
6786 
6787 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6788 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6789 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6790 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6791 
6792 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6793 			plaintext_pad_len, 15, 0);
6794 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6795 			"Failed to allocate input buffer in mempool");
6796 
6797 	if (op_mode == OUT_OF_PLACE) {
6798 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6799 				plaintext_pad_len, 15, 0);
6800 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6801 				"Failed to allocate output buffer in mempool");
6802 	}
6803 
6804 	if (verify) {
6805 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6806 			tdata->ciphertext.data);
6807 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6808 					ciphertext_len, buffer);
6809 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6810 			ciphertext_len);
6811 	} else {
6812 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6813 			tdata->plaintext.data);
6814 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6815 					plaintext_len, buffer);
6816 		debug_hexdump(stdout, "plaintext:", plaintext,
6817 			plaintext_len);
6818 	}
6819 	memset(buffer, 0, sizeof(buffer));
6820 
6821 	/* Create ZUC operation */
6822 	retval = create_wireless_algo_auth_cipher_operation(
6823 		tdata->digest.data, tdata->digest.len,
6824 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6825 		tdata->auth_iv.data, tdata->auth_iv.len,
6826 		(tdata->digest.offset_bytes == 0 ?
6827 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6828 			: tdata->digest.offset_bytes),
6829 		tdata->validCipherLenInBits.len,
6830 		tdata->validCipherOffsetInBits.len,
6831 		tdata->validAuthLenInBits.len,
6832 		0,
6833 		op_mode, 1, verify);
6834 
6835 	if (retval < 0)
6836 		return retval;
6837 
6838 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6839 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6840 					       tdata->cipher_iv.len);
6841 		if (retval != TEST_SUCCESS)
6842 			return retval;
6843 	} else
6844 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6845 			ut_params->op);
6846 
6847 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6848 
6849 	ut_params->obuf = (op_mode == IN_PLACE ?
6850 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6851 
6852 	if (verify) {
6853 		if (ut_params->obuf)
6854 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6855 					plaintext_len, buffer);
6856 		else
6857 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6858 					plaintext_len, buffer);
6859 
6860 		debug_hexdump(stdout, "plaintext:", plaintext,
6861 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6862 		debug_hexdump(stdout, "plaintext expected:",
6863 			tdata->plaintext.data,
6864 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6865 	} else {
6866 		if (ut_params->obuf)
6867 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6868 					ciphertext_len, buffer);
6869 		else
6870 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6871 					ciphertext_len, buffer);
6872 
6873 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6874 			ciphertext_len);
6875 		debug_hexdump(stdout, "ciphertext expected:",
6876 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6877 
6878 		if (ut_params->obuf)
6879 			digest = rte_pktmbuf_read(ut_params->obuf,
6880 				(tdata->digest.offset_bytes == 0 ?
6881 				plaintext_pad_len : tdata->digest.offset_bytes),
6882 				tdata->digest.len, digest_buffer);
6883 		else
6884 			digest = rte_pktmbuf_read(ut_params->ibuf,
6885 				(tdata->digest.offset_bytes == 0 ?
6886 				plaintext_pad_len : tdata->digest.offset_bytes),
6887 				tdata->digest.len, digest_buffer);
6888 
6889 		debug_hexdump(stdout, "digest:", digest,
6890 			tdata->digest.len);
6891 		debug_hexdump(stdout, "digest expected:",
6892 			tdata->digest.data, tdata->digest.len);
6893 	}
6894 
6895 	/* Validate obuf */
6896 	if (verify) {
6897 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6898 			plaintext,
6899 			tdata->plaintext.data,
6900 			tdata->plaintext.len >> 3,
6901 			"ZUC Plaintext data not as expected");
6902 	} else {
6903 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6904 			ciphertext,
6905 			tdata->ciphertext.data,
6906 			tdata->validDataLenInBits.len,
6907 			"ZUC Ciphertext data not as expected");
6908 
6909 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6910 			digest,
6911 			tdata->digest.data,
6912 			tdata->digest.len,
6913 			"ZUC Generated auth tag not as expected");
6914 	}
6915 	return 0;
6916 }
6917 
6918 static int
6919 test_kasumi_encryption_test_case_1(void)
6920 {
6921 	return test_kasumi_encryption(&kasumi_test_case_1);
6922 }
6923 
6924 static int
6925 test_kasumi_encryption_test_case_1_sgl(void)
6926 {
6927 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6928 }
6929 
6930 static int
6931 test_kasumi_encryption_test_case_1_oop(void)
6932 {
6933 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
6934 }
6935 
6936 static int
6937 test_kasumi_encryption_test_case_1_oop_sgl(void)
6938 {
6939 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6940 }
6941 
6942 static int
6943 test_kasumi_encryption_test_case_2(void)
6944 {
6945 	return test_kasumi_encryption(&kasumi_test_case_2);
6946 }
6947 
6948 static int
6949 test_kasumi_encryption_test_case_3(void)
6950 {
6951 	return test_kasumi_encryption(&kasumi_test_case_3);
6952 }
6953 
6954 static int
6955 test_kasumi_encryption_test_case_4(void)
6956 {
6957 	return test_kasumi_encryption(&kasumi_test_case_4);
6958 }
6959 
6960 static int
6961 test_kasumi_encryption_test_case_5(void)
6962 {
6963 	return test_kasumi_encryption(&kasumi_test_case_5);
6964 }
6965 
6966 static int
6967 test_kasumi_decryption_test_case_1(void)
6968 {
6969 	return test_kasumi_decryption(&kasumi_test_case_1);
6970 }
6971 
6972 static int
6973 test_kasumi_decryption_test_case_1_oop(void)
6974 {
6975 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
6976 }
6977 
6978 static int
6979 test_kasumi_decryption_test_case_2(void)
6980 {
6981 	return test_kasumi_decryption(&kasumi_test_case_2);
6982 }
6983 
6984 static int
6985 test_kasumi_decryption_test_case_3(void)
6986 {
6987 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6988 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6989 		return TEST_SKIPPED;
6990 	return test_kasumi_decryption(&kasumi_test_case_3);
6991 }
6992 
6993 static int
6994 test_kasumi_decryption_test_case_4(void)
6995 {
6996 	return test_kasumi_decryption(&kasumi_test_case_4);
6997 }
6998 
6999 static int
7000 test_kasumi_decryption_test_case_5(void)
7001 {
7002 	return test_kasumi_decryption(&kasumi_test_case_5);
7003 }
7004 static int
7005 test_snow3g_encryption_test_case_1(void)
7006 {
7007 	return test_snow3g_encryption(&snow3g_test_case_1);
7008 }
7009 
7010 static int
7011 test_snow3g_encryption_test_case_1_oop(void)
7012 {
7013 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
7014 }
7015 
7016 static int
7017 test_snow3g_encryption_test_case_1_oop_sgl(void)
7018 {
7019 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7020 }
7021 
7022 static int
7023 test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7024 {
7025 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7026 }
7027 
7028 static int
7029 test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7030 {
7031 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7032 }
7033 
7034 static int
7035 test_snow3g_encryption_test_case_1_offset_oop(void)
7036 {
7037 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7038 }
7039 
7040 static int
7041 test_snow3g_encryption_test_case_2(void)
7042 {
7043 	return test_snow3g_encryption(&snow3g_test_case_2);
7044 }
7045 
7046 static int
7047 test_snow3g_encryption_test_case_3(void)
7048 {
7049 	return test_snow3g_encryption(&snow3g_test_case_3);
7050 }
7051 
7052 static int
7053 test_snow3g_encryption_test_case_4(void)
7054 {
7055 	return test_snow3g_encryption(&snow3g_test_case_4);
7056 }
7057 
7058 static int
7059 test_snow3g_encryption_test_case_5(void)
7060 {
7061 	return test_snow3g_encryption(&snow3g_test_case_5);
7062 }
7063 
7064 static int
7065 test_snow3g_decryption_test_case_1(void)
7066 {
7067 	return test_snow3g_decryption(&snow3g_test_case_1);
7068 }
7069 
7070 static int
7071 test_snow3g_decryption_test_case_1_oop(void)
7072 {
7073 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
7074 }
7075 
7076 static int
7077 test_snow3g_decryption_test_case_2(void)
7078 {
7079 	return test_snow3g_decryption(&snow3g_test_case_2);
7080 }
7081 
7082 static int
7083 test_snow3g_decryption_test_case_3(void)
7084 {
7085 	return test_snow3g_decryption(&snow3g_test_case_3);
7086 }
7087 
7088 static int
7089 test_snow3g_decryption_test_case_4(void)
7090 {
7091 	return test_snow3g_decryption(&snow3g_test_case_4);
7092 }
7093 
7094 static int
7095 test_snow3g_decryption_test_case_5(void)
7096 {
7097 	return test_snow3g_decryption(&snow3g_test_case_5);
7098 }
7099 
7100 /*
7101  * Function prepares snow3g_hash_test_data from snow3g_test_data.
7102  * Pattern digest from snow3g_test_data must be allocated as
7103  * 4 last bytes in plaintext.
7104  */
7105 static void
7106 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7107 		struct snow3g_hash_test_data *output)
7108 {
7109 	if ((pattern != NULL) && (output != NULL)) {
7110 		output->key.len = pattern->key.len;
7111 
7112 		memcpy(output->key.data,
7113 		pattern->key.data, pattern->key.len);
7114 
7115 		output->auth_iv.len = pattern->auth_iv.len;
7116 
7117 		memcpy(output->auth_iv.data,
7118 		pattern->auth_iv.data, pattern->auth_iv.len);
7119 
7120 		output->plaintext.len = pattern->plaintext.len;
7121 
7122 		memcpy(output->plaintext.data,
7123 		pattern->plaintext.data, pattern->plaintext.len >> 3);
7124 
7125 		output->digest.len = pattern->digest.len;
7126 
7127 		memcpy(output->digest.data,
7128 		&pattern->plaintext.data[pattern->digest.offset_bytes],
7129 		pattern->digest.len);
7130 
7131 		output->validAuthLenInBits.len =
7132 		pattern->validAuthLenInBits.len;
7133 	}
7134 }
7135 
7136 /*
7137  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7138  */
7139 static int
7140 test_snow3g_decryption_with_digest_test_case_1(void)
7141 {
7142 	int ret;
7143 	struct snow3g_hash_test_data snow3g_hash_data;
7144 	struct rte_cryptodev_info dev_info;
7145 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7146 
7147 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7148 	uint64_t feat_flags = dev_info.feature_flags;
7149 
7150 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7151 		printf("Device doesn't support encrypted digest operations.\n");
7152 		return TEST_SKIPPED;
7153 	}
7154 
7155 	/*
7156 	 * Function prepare data for hash verification test case.
7157 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
7158 	 */
7159 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7160 
7161 	ret = test_snow3g_decryption(&snow3g_test_case_7);
7162 	if (ret != 0)
7163 		return ret;
7164 
7165 	return test_snow3g_authentication_verify(&snow3g_hash_data);
7166 }
7167 
7168 static int
7169 test_snow3g_cipher_auth_test_case_1(void)
7170 {
7171 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
7172 }
7173 
7174 static int
7175 test_snow3g_auth_cipher_test_case_1(void)
7176 {
7177 	return test_snow3g_auth_cipher(
7178 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7179 }
7180 
7181 static int
7182 test_snow3g_auth_cipher_test_case_2(void)
7183 {
7184 	return test_snow3g_auth_cipher(
7185 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7186 }
7187 
7188 static int
7189 test_snow3g_auth_cipher_test_case_2_oop(void)
7190 {
7191 	return test_snow3g_auth_cipher(
7192 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7193 }
7194 
7195 static int
7196 test_snow3g_auth_cipher_part_digest_enc(void)
7197 {
7198 	return test_snow3g_auth_cipher(
7199 		&snow3g_auth_cipher_partial_digest_encryption,
7200 			IN_PLACE, 0);
7201 }
7202 
7203 static int
7204 test_snow3g_auth_cipher_part_digest_enc_oop(void)
7205 {
7206 	return test_snow3g_auth_cipher(
7207 		&snow3g_auth_cipher_partial_digest_encryption,
7208 			OUT_OF_PLACE, 0);
7209 }
7210 
7211 static int
7212 test_snow3g_auth_cipher_test_case_3_sgl(void)
7213 {
7214 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7215 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7216 		return TEST_SKIPPED;
7217 	return test_snow3g_auth_cipher_sgl(
7218 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7219 }
7220 
7221 static int
7222 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7223 {
7224 	return test_snow3g_auth_cipher_sgl(
7225 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7226 }
7227 
7228 static int
7229 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7230 {
7231 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7232 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7233 		return TEST_SKIPPED;
7234 	return test_snow3g_auth_cipher_sgl(
7235 		&snow3g_auth_cipher_partial_digest_encryption,
7236 			IN_PLACE, 0);
7237 }
7238 
7239 static int
7240 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7241 {
7242 	return test_snow3g_auth_cipher_sgl(
7243 		&snow3g_auth_cipher_partial_digest_encryption,
7244 			OUT_OF_PLACE, 0);
7245 }
7246 
7247 static int
7248 test_snow3g_auth_cipher_total_digest_enc_1(void)
7249 {
7250 	return test_snow3g_auth_cipher(
7251 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7252 }
7253 
7254 static int
7255 test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7256 {
7257 	return test_snow3g_auth_cipher(
7258 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7259 }
7260 
7261 static int
7262 test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7263 {
7264 	return test_snow3g_auth_cipher_sgl(
7265 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7266 }
7267 
7268 static int
7269 test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7270 {
7271 	return test_snow3g_auth_cipher_sgl(
7272 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7273 }
7274 
7275 static int
7276 test_snow3g_auth_cipher_verify_test_case_1(void)
7277 {
7278 	return test_snow3g_auth_cipher(
7279 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7280 }
7281 
7282 static int
7283 test_snow3g_auth_cipher_verify_test_case_2(void)
7284 {
7285 	return test_snow3g_auth_cipher(
7286 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7287 }
7288 
7289 static int
7290 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7291 {
7292 	return test_snow3g_auth_cipher(
7293 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7294 }
7295 
7296 static int
7297 test_snow3g_auth_cipher_verify_part_digest_enc(void)
7298 {
7299 	return test_snow3g_auth_cipher(
7300 		&snow3g_auth_cipher_partial_digest_encryption,
7301 			IN_PLACE, 1);
7302 }
7303 
7304 static int
7305 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7306 {
7307 	return test_snow3g_auth_cipher(
7308 		&snow3g_auth_cipher_partial_digest_encryption,
7309 			OUT_OF_PLACE, 1);
7310 }
7311 
7312 static int
7313 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7314 {
7315 	return test_snow3g_auth_cipher_sgl(
7316 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7317 }
7318 
7319 static int
7320 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7321 {
7322 	return test_snow3g_auth_cipher_sgl(
7323 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7324 }
7325 
7326 static int
7327 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7328 {
7329 	return test_snow3g_auth_cipher_sgl(
7330 		&snow3g_auth_cipher_partial_digest_encryption,
7331 			IN_PLACE, 1);
7332 }
7333 
7334 static int
7335 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7336 {
7337 	return test_snow3g_auth_cipher_sgl(
7338 		&snow3g_auth_cipher_partial_digest_encryption,
7339 			OUT_OF_PLACE, 1);
7340 }
7341 
7342 static int
7343 test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7344 {
7345 	return test_snow3g_auth_cipher(
7346 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7347 }
7348 
7349 static int
7350 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7351 {
7352 	return test_snow3g_auth_cipher(
7353 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7354 }
7355 
7356 static int
7357 test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7358 {
7359 	return test_snow3g_auth_cipher_sgl(
7360 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7361 }
7362 
7363 static int
7364 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7365 {
7366 	return test_snow3g_auth_cipher_sgl(
7367 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7368 }
7369 
7370 static int
7371 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7372 {
7373 	return test_snow3g_auth_cipher(
7374 		&snow3g_test_case_7, IN_PLACE, 0);
7375 }
7376 
7377 static int
7378 test_kasumi_auth_cipher_test_case_1(void)
7379 {
7380 	return test_kasumi_auth_cipher(
7381 		&kasumi_test_case_3, IN_PLACE, 0);
7382 }
7383 
7384 static int
7385 test_kasumi_auth_cipher_test_case_2(void)
7386 {
7387 	return test_kasumi_auth_cipher(
7388 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7389 }
7390 
7391 static int
7392 test_kasumi_auth_cipher_test_case_2_oop(void)
7393 {
7394 	return test_kasumi_auth_cipher(
7395 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7396 }
7397 
7398 static int
7399 test_kasumi_auth_cipher_test_case_2_sgl(void)
7400 {
7401 	return test_kasumi_auth_cipher_sgl(
7402 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7403 }
7404 
7405 static int
7406 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7407 {
7408 	return test_kasumi_auth_cipher_sgl(
7409 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7410 }
7411 
7412 static int
7413 test_kasumi_auth_cipher_verify_test_case_1(void)
7414 {
7415 	return test_kasumi_auth_cipher(
7416 		&kasumi_test_case_3, IN_PLACE, 1);
7417 }
7418 
7419 static int
7420 test_kasumi_auth_cipher_verify_test_case_2(void)
7421 {
7422 	return test_kasumi_auth_cipher(
7423 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7424 }
7425 
7426 static int
7427 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7428 {
7429 	return test_kasumi_auth_cipher(
7430 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7431 }
7432 
7433 static int
7434 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7435 {
7436 	return test_kasumi_auth_cipher_sgl(
7437 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7438 }
7439 
7440 static int
7441 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7442 {
7443 	return test_kasumi_auth_cipher_sgl(
7444 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7445 }
7446 
7447 static int
7448 test_kasumi_cipher_auth_test_case_1(void)
7449 {
7450 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7451 }
7452 
7453 static int
7454 test_zuc_encryption_test_case_1(void)
7455 {
7456 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7457 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7458 }
7459 
7460 static int
7461 test_zuc_encryption_test_case_2(void)
7462 {
7463 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7464 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7465 }
7466 
7467 static int
7468 test_zuc_encryption_test_case_3(void)
7469 {
7470 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7471 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7472 }
7473 
7474 static int
7475 test_zuc_encryption_test_case_4(void)
7476 {
7477 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7478 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7479 }
7480 
7481 static int
7482 test_zuc_encryption_test_case_5(void)
7483 {
7484 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7485 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7486 }
7487 
7488 static int
7489 test_zuc_encryption_test_case_6_sgl(void)
7490 {
7491 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7492 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7493 }
7494 
7495 static int
7496 test_zuc_decryption_test_case_1(void)
7497 {
7498 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7499 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7500 }
7501 
7502 static int
7503 test_zuc_decryption_test_case_2(void)
7504 {
7505 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7506 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7507 }
7508 
7509 static int
7510 test_zuc_decryption_test_case_3(void)
7511 {
7512 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7513 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7514 }
7515 
7516 static int
7517 test_zuc_decryption_test_case_4(void)
7518 {
7519 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7520 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7521 }
7522 
7523 static int
7524 test_zuc_decryption_test_case_5(void)
7525 {
7526 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7527 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7528 }
7529 
7530 static int
7531 test_zuc_decryption_test_case_6_sgl(void)
7532 {
7533 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7534 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7535 }
7536 
7537 static int
7538 test_zuc_hash_generate_test_case_1(void)
7539 {
7540 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7541 			RTE_CRYPTO_AUTH_OP_GENERATE);
7542 }
7543 
7544 static int
7545 test_zuc_hash_generate_test_case_2(void)
7546 {
7547 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7548 			RTE_CRYPTO_AUTH_OP_GENERATE);
7549 }
7550 
7551 static int
7552 test_zuc_hash_generate_test_case_3(void)
7553 {
7554 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7555 			RTE_CRYPTO_AUTH_OP_GENERATE);
7556 }
7557 
7558 static int
7559 test_zuc_hash_generate_test_case_4(void)
7560 {
7561 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7562 			RTE_CRYPTO_AUTH_OP_GENERATE);
7563 }
7564 
7565 static int
7566 test_zuc_hash_generate_test_case_5(void)
7567 {
7568 	return test_zuc_authentication(&zuc_test_auth_5670b,
7569 			RTE_CRYPTO_AUTH_OP_GENERATE);
7570 }
7571 
7572 static int
7573 test_zuc_hash_generate_test_case_6(void)
7574 {
7575 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7576 			RTE_CRYPTO_AUTH_OP_GENERATE);
7577 }
7578 
7579 static int
7580 test_zuc_hash_generate_test_case_7(void)
7581 {
7582 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7583 			RTE_CRYPTO_AUTH_OP_GENERATE);
7584 }
7585 
7586 static int
7587 test_zuc_hash_generate_test_case_8(void)
7588 {
7589 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7590 			RTE_CRYPTO_AUTH_OP_GENERATE);
7591 }
7592 
7593 static int
7594 test_zuc_hash_verify_test_case_1(void)
7595 {
7596 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7597 			RTE_CRYPTO_AUTH_OP_VERIFY);
7598 }
7599 
7600 static int
7601 test_zuc_hash_verify_test_case_2(void)
7602 {
7603 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7604 			RTE_CRYPTO_AUTH_OP_VERIFY);
7605 }
7606 
7607 static int
7608 test_zuc_hash_verify_test_case_3(void)
7609 {
7610 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7611 			RTE_CRYPTO_AUTH_OP_VERIFY);
7612 }
7613 
7614 static int
7615 test_zuc_hash_verify_test_case_4(void)
7616 {
7617 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7618 			RTE_CRYPTO_AUTH_OP_VERIFY);
7619 }
7620 
7621 static int
7622 test_zuc_hash_verify_test_case_5(void)
7623 {
7624 	return test_zuc_authentication(&zuc_test_auth_5670b,
7625 			RTE_CRYPTO_AUTH_OP_VERIFY);
7626 }
7627 
7628 static int
7629 test_zuc_hash_verify_test_case_6(void)
7630 {
7631 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7632 			RTE_CRYPTO_AUTH_OP_VERIFY);
7633 }
7634 
7635 static int
7636 test_zuc_hash_verify_test_case_7(void)
7637 {
7638 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7639 			RTE_CRYPTO_AUTH_OP_VERIFY);
7640 }
7641 
7642 static int
7643 test_zuc_hash_verify_test_case_8(void)
7644 {
7645 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7646 			RTE_CRYPTO_AUTH_OP_VERIFY);
7647 }
7648 
7649 static int
7650 test_zuc_cipher_auth_test_case_1(void)
7651 {
7652 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7653 }
7654 
7655 static int
7656 test_zuc_cipher_auth_test_case_2(void)
7657 {
7658 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7659 }
7660 
7661 static int
7662 test_zuc_auth_cipher_test_case_1(void)
7663 {
7664 	return test_zuc_auth_cipher(
7665 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7666 }
7667 
7668 static int
7669 test_zuc_auth_cipher_test_case_1_oop(void)
7670 {
7671 	return test_zuc_auth_cipher(
7672 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7673 }
7674 
7675 static int
7676 test_zuc_auth_cipher_test_case_1_sgl(void)
7677 {
7678 	return test_zuc_auth_cipher_sgl(
7679 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7680 }
7681 
7682 static int
7683 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7684 {
7685 	return test_zuc_auth_cipher_sgl(
7686 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7687 }
7688 
7689 static int
7690 test_zuc_auth_cipher_test_case_2(void)
7691 {
7692 	return test_zuc_auth_cipher(
7693 		&zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7694 }
7695 
7696 static int
7697 test_zuc_auth_cipher_test_case_2_oop(void)
7698 {
7699 	return test_zuc_auth_cipher(
7700 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7701 }
7702 
7703 static int
7704 test_zuc_auth_cipher_verify_test_case_1(void)
7705 {
7706 	return test_zuc_auth_cipher(
7707 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7708 }
7709 
7710 static int
7711 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7712 {
7713 	return test_zuc_auth_cipher(
7714 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7715 }
7716 
7717 static int
7718 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7719 {
7720 	return test_zuc_auth_cipher_sgl(
7721 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7722 }
7723 
7724 static int
7725 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7726 {
7727 	return test_zuc_auth_cipher_sgl(
7728 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7729 }
7730 
7731 static int
7732 test_zuc_auth_cipher_verify_test_case_2(void)
7733 {
7734 	return test_zuc_auth_cipher(
7735 		&zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7736 }
7737 
7738 static int
7739 test_zuc_auth_cipher_verify_test_case_2_oop(void)
7740 {
7741 	return test_zuc_auth_cipher(
7742 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7743 }
7744 
7745 static int
7746 test_zuc256_encryption_test_case_1(void)
7747 {
7748 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7749 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7750 }
7751 
7752 static int
7753 test_zuc256_encryption_test_case_2(void)
7754 {
7755 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7756 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7757 }
7758 
7759 static int
7760 test_zuc256_decryption_test_case_1(void)
7761 {
7762 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7763 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7764 }
7765 
7766 static int
7767 test_zuc256_decryption_test_case_2(void)
7768 {
7769 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7770 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7771 }
7772 
7773 static int
7774 test_zuc256_hash_generate_4b_tag_test_case_1(void)
7775 {
7776 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7777 			RTE_CRYPTO_AUTH_OP_GENERATE);
7778 }
7779 
7780 static int
7781 test_zuc256_hash_generate_4b_tag_test_case_2(void)
7782 {
7783 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7784 			RTE_CRYPTO_AUTH_OP_GENERATE);
7785 }
7786 
7787 static int
7788 test_zuc256_hash_generate_4b_tag_test_case_3(void)
7789 {
7790 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7791 			RTE_CRYPTO_AUTH_OP_GENERATE);
7792 }
7793 
7794 static int
7795 test_zuc256_hash_generate_8b_tag_test_case_1(void)
7796 {
7797 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7798 			RTE_CRYPTO_AUTH_OP_GENERATE);
7799 }
7800 
7801 static int
7802 test_zuc256_hash_generate_16b_tag_test_case_1(void)
7803 {
7804 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7805 			RTE_CRYPTO_AUTH_OP_GENERATE);
7806 }
7807 
7808 static int
7809 test_zuc256_hash_verify_4b_tag_test_case_1(void)
7810 {
7811 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7812 			RTE_CRYPTO_AUTH_OP_VERIFY);
7813 }
7814 
7815 static int
7816 test_zuc256_hash_verify_4b_tag_test_case_2(void)
7817 {
7818 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7819 			RTE_CRYPTO_AUTH_OP_VERIFY);
7820 }
7821 
7822 static int
7823 test_zuc256_hash_verify_4b_tag_test_case_3(void)
7824 {
7825 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7826 			RTE_CRYPTO_AUTH_OP_VERIFY);
7827 }
7828 
7829 static int
7830 test_zuc256_hash_verify_8b_tag_test_case_1(void)
7831 {
7832 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7833 			RTE_CRYPTO_AUTH_OP_VERIFY);
7834 }
7835 
7836 static int
7837 test_zuc256_hash_verify_16b_tag_test_case_1(void)
7838 {
7839 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7840 			RTE_CRYPTO_AUTH_OP_VERIFY);
7841 }
7842 
7843 static int
7844 test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7845 {
7846 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7847 }
7848 
7849 static int
7850 test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7851 {
7852 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7853 }
7854 
7855 static int
7856 test_zuc256_cipher_auth_8b_tag_test_case_1(void)
7857 {
7858 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
7859 }
7860 
7861 static int
7862 test_zuc256_cipher_auth_16b_tag_test_case_1(void)
7863 {
7864 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
7865 }
7866 
7867 static int
7868 test_zuc256_auth_cipher_4b_tag_test_case_1(void)
7869 {
7870 	return test_zuc_auth_cipher(
7871 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
7872 }
7873 
7874 static int
7875 test_zuc256_auth_cipher_4b_tag_test_case_2(void)
7876 {
7877 	return test_zuc_auth_cipher(
7878 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
7879 }
7880 
7881 static int
7882 test_zuc256_auth_cipher_8b_tag_test_case_1(void)
7883 {
7884 	return test_zuc_auth_cipher(
7885 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
7886 }
7887 
7888 static int
7889 test_zuc256_auth_cipher_16b_tag_test_case_1(void)
7890 {
7891 	return test_zuc_auth_cipher(
7892 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
7893 }
7894 
7895 static int
7896 test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
7897 {
7898 	return test_zuc_auth_cipher(
7899 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
7900 }
7901 
7902 static int
7903 test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
7904 {
7905 	return test_zuc_auth_cipher(
7906 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
7907 }
7908 
7909 static int
7910 test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
7911 {
7912 	return test_zuc_auth_cipher(
7913 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
7914 }
7915 
7916 static int
7917 test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
7918 {
7919 	return test_zuc_auth_cipher(
7920 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
7921 }
7922 
7923 static int
7924 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7925 {
7926 	uint8_t dev_id = testsuite_params.valid_devs[0];
7927 
7928 	struct rte_cryptodev_sym_capability_idx cap_idx;
7929 
7930 	/* Check if device supports particular cipher algorithm */
7931 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7932 	cap_idx.algo.cipher = tdata->cipher_algo;
7933 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7934 		return TEST_SKIPPED;
7935 
7936 	/* Check if device supports particular hash algorithm */
7937 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7938 	cap_idx.algo.auth = tdata->auth_algo;
7939 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7940 		return TEST_SKIPPED;
7941 
7942 	return 0;
7943 }
7944 
7945 static int
7946 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7947 	uint8_t op_mode, uint8_t verify)
7948 {
7949 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7950 	struct crypto_unittest_params *ut_params = &unittest_params;
7951 
7952 	int retval;
7953 
7954 	uint8_t *plaintext = NULL, *ciphertext = NULL;
7955 	unsigned int plaintext_pad_len;
7956 	unsigned int plaintext_len;
7957 	unsigned int ciphertext_pad_len;
7958 	unsigned int ciphertext_len;
7959 	unsigned int digest_offset;
7960 
7961 	struct rte_cryptodev_info dev_info;
7962 	struct rte_crypto_op *op;
7963 
7964 	/* Check if device supports particular algorithms separately */
7965 	if (test_mixed_check_if_unsupported(tdata))
7966 		return TEST_SKIPPED;
7967 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7968 		return TEST_SKIPPED;
7969 
7970 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7971 		return TEST_SKIPPED;
7972 
7973 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7974 
7975 	uint64_t feat_flags = dev_info.feature_flags;
7976 
7977 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7978 		printf("Device doesn't support digest encrypted.\n");
7979 		return TEST_SKIPPED;
7980 	}
7981 
7982 	/* Create the session */
7983 	if (verify)
7984 		retval = create_wireless_algo_cipher_auth_session(
7985 				ts_params->valid_devs[0],
7986 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
7987 				RTE_CRYPTO_AUTH_OP_VERIFY,
7988 				tdata->auth_algo,
7989 				tdata->cipher_algo,
7990 				tdata->auth_key.data, tdata->auth_key.len,
7991 				tdata->cipher_key.data, tdata->cipher_key.len,
7992 				tdata->auth_iv.len, tdata->digest_enc.len,
7993 				tdata->cipher_iv.len);
7994 	else
7995 		retval = create_wireless_algo_auth_cipher_session(
7996 				ts_params->valid_devs[0],
7997 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7998 				RTE_CRYPTO_AUTH_OP_GENERATE,
7999 				tdata->auth_algo,
8000 				tdata->cipher_algo,
8001 				tdata->auth_key.data, tdata->auth_key.len,
8002 				tdata->cipher_key.data, tdata->cipher_key.len,
8003 				tdata->auth_iv.len, tdata->digest_enc.len,
8004 				tdata->cipher_iv.len);
8005 	if (retval != 0)
8006 		return retval;
8007 
8008 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8009 	if (op_mode == OUT_OF_PLACE)
8010 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8011 
8012 	/* clear mbuf payload */
8013 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8014 		rte_pktmbuf_tailroom(ut_params->ibuf));
8015 	if (op_mode == OUT_OF_PLACE) {
8016 
8017 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8018 				rte_pktmbuf_tailroom(ut_params->obuf));
8019 	}
8020 
8021 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8022 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8023 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8024 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8025 
8026 	if (verify) {
8027 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8028 				ciphertext_pad_len);
8029 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8030 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8031 				ciphertext_len);
8032 	} else {
8033 		/* make sure enough space to cover partial digest verify case */
8034 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8035 				ciphertext_pad_len);
8036 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8037 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8038 	}
8039 
8040 	if (op_mode == OUT_OF_PLACE)
8041 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8042 
8043 	/* Create the operation */
8044 	retval = create_wireless_algo_auth_cipher_operation(
8045 			tdata->digest_enc.data, tdata->digest_enc.len,
8046 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8047 			tdata->auth_iv.data, tdata->auth_iv.len,
8048 			(tdata->digest_enc.offset == 0 ?
8049 				plaintext_pad_len
8050 				: tdata->digest_enc.offset),
8051 			tdata->validCipherLen.len_bits,
8052 			tdata->cipher.offset_bits,
8053 			tdata->validAuthLen.len_bits,
8054 			tdata->auth.offset_bits,
8055 			op_mode, 0, verify);
8056 
8057 	if (retval < 0)
8058 		return retval;
8059 
8060 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8061 
8062 	/* Check if the op failed because the device doesn't */
8063 	/* support this particular combination of algorithms */
8064 	if (op == NULL && ut_params->op->status ==
8065 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8066 		printf("Device doesn't support this mixed combination. "
8067 				"Test Skipped.\n");
8068 		return TEST_SKIPPED;
8069 	}
8070 	ut_params->op = op;
8071 
8072 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8073 
8074 	ut_params->obuf = (op_mode == IN_PLACE ?
8075 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8076 
8077 	if (verify) {
8078 		if (ut_params->obuf)
8079 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8080 							uint8_t *);
8081 		else
8082 			plaintext = ciphertext +
8083 					(tdata->cipher.offset_bits >> 3);
8084 
8085 		debug_hexdump(stdout, "plaintext:", plaintext,
8086 				tdata->plaintext.len_bits >> 3);
8087 		debug_hexdump(stdout, "plaintext expected:",
8088 				tdata->plaintext.data,
8089 				tdata->plaintext.len_bits >> 3);
8090 	} else {
8091 		if (ut_params->obuf)
8092 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8093 					uint8_t *);
8094 		else
8095 			ciphertext = plaintext;
8096 
8097 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8098 				ciphertext_len);
8099 		debug_hexdump(stdout, "ciphertext expected:",
8100 				tdata->ciphertext.data,
8101 				tdata->ciphertext.len_bits >> 3);
8102 
8103 		if (tdata->digest_enc.offset == 0)
8104 			digest_offset = plaintext_pad_len;
8105 		else
8106 			digest_offset = tdata->digest_enc.offset;
8107 
8108 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8109 					    uint8_t *, digest_offset);
8110 
8111 		debug_hexdump(stdout, "digest:", ut_params->digest,
8112 				tdata->digest_enc.len);
8113 		debug_hexdump(stdout, "digest expected:",
8114 				tdata->digest_enc.data,
8115 				tdata->digest_enc.len);
8116 	}
8117 
8118 	if (!verify) {
8119 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8120 				ut_params->digest,
8121 				tdata->digest_enc.data,
8122 				tdata->digest_enc.len,
8123 				"Generated auth tag not as expected");
8124 	}
8125 
8126 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8127 		if (verify) {
8128 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8129 					plaintext,
8130 					tdata->plaintext.data,
8131 					tdata->plaintext.len_bits >> 3,
8132 					"Plaintext data not as expected");
8133 		} else {
8134 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8135 					ciphertext,
8136 					tdata->ciphertext.data,
8137 					tdata->validDataLen.len_bits,
8138 					"Ciphertext data not as expected");
8139 		}
8140 	}
8141 
8142 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8143 			"crypto op processing failed");
8144 
8145 	return 0;
8146 }
8147 
8148 static int
8149 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8150 	uint8_t op_mode, uint8_t verify)
8151 {
8152 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8153 	struct crypto_unittest_params *ut_params = &unittest_params;
8154 
8155 	int retval;
8156 
8157 	const uint8_t *plaintext = NULL;
8158 	const uint8_t *ciphertext = NULL;
8159 	const uint8_t *digest = NULL;
8160 	unsigned int plaintext_pad_len;
8161 	unsigned int plaintext_len;
8162 	unsigned int ciphertext_pad_len;
8163 	unsigned int ciphertext_len;
8164 	uint8_t buffer[10000];
8165 	uint8_t digest_buffer[10000];
8166 
8167 	struct rte_cryptodev_info dev_info;
8168 	struct rte_crypto_op *op;
8169 
8170 	/* Check if device supports particular algorithms */
8171 	if (test_mixed_check_if_unsupported(tdata))
8172 		return TEST_SKIPPED;
8173 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8174 		return TEST_SKIPPED;
8175 
8176 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8177 
8178 	uint64_t feat_flags = dev_info.feature_flags;
8179 
8180 	if (op_mode == IN_PLACE) {
8181 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8182 			printf("Device doesn't support in-place scatter-gather "
8183 					"in both input and output mbufs.\n");
8184 			return TEST_SKIPPED;
8185 		}
8186 	} else {
8187 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8188 			printf("Device doesn't support out-of-place scatter-gather "
8189 					"in both input and output mbufs.\n");
8190 			return TEST_SKIPPED;
8191 		}
8192 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8193 			printf("Device doesn't support digest encrypted.\n");
8194 			return TEST_SKIPPED;
8195 		}
8196 	}
8197 
8198 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8199 		return TEST_SKIPPED;
8200 
8201 	/* Create the session */
8202 	if (verify)
8203 		retval = create_wireless_algo_cipher_auth_session(
8204 				ts_params->valid_devs[0],
8205 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8206 				RTE_CRYPTO_AUTH_OP_VERIFY,
8207 				tdata->auth_algo,
8208 				tdata->cipher_algo,
8209 				tdata->auth_key.data, tdata->auth_key.len,
8210 				tdata->cipher_key.data, tdata->cipher_key.len,
8211 				tdata->auth_iv.len, tdata->digest_enc.len,
8212 				tdata->cipher_iv.len);
8213 	else
8214 		retval = create_wireless_algo_auth_cipher_session(
8215 				ts_params->valid_devs[0],
8216 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8217 				RTE_CRYPTO_AUTH_OP_GENERATE,
8218 				tdata->auth_algo,
8219 				tdata->cipher_algo,
8220 				tdata->auth_key.data, tdata->auth_key.len,
8221 				tdata->cipher_key.data, tdata->cipher_key.len,
8222 				tdata->auth_iv.len, tdata->digest_enc.len,
8223 				tdata->cipher_iv.len);
8224 	if (retval != 0)
8225 		return retval;
8226 
8227 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8228 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8229 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8230 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8231 
8232 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8233 			ciphertext_pad_len, 15, 0);
8234 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8235 			"Failed to allocate input buffer in mempool");
8236 
8237 	if (op_mode == OUT_OF_PLACE) {
8238 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8239 				plaintext_pad_len, 15, 0);
8240 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
8241 				"Failed to allocate output buffer in mempool");
8242 	}
8243 
8244 	if (verify) {
8245 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8246 			tdata->ciphertext.data);
8247 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8248 					ciphertext_len, buffer);
8249 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8250 			ciphertext_len);
8251 	} else {
8252 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8253 			tdata->plaintext.data);
8254 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8255 					plaintext_len, buffer);
8256 		debug_hexdump(stdout, "plaintext:", plaintext,
8257 			plaintext_len);
8258 	}
8259 	memset(buffer, 0, sizeof(buffer));
8260 
8261 	/* Create the operation */
8262 	retval = create_wireless_algo_auth_cipher_operation(
8263 			tdata->digest_enc.data, tdata->digest_enc.len,
8264 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8265 			tdata->auth_iv.data, tdata->auth_iv.len,
8266 			(tdata->digest_enc.offset == 0 ?
8267 				plaintext_pad_len
8268 				: tdata->digest_enc.offset),
8269 			tdata->validCipherLen.len_bits,
8270 			tdata->cipher.offset_bits,
8271 			tdata->validAuthLen.len_bits,
8272 			tdata->auth.offset_bits,
8273 			op_mode, 1, verify);
8274 
8275 	if (retval < 0)
8276 		return retval;
8277 
8278 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8279 
8280 	/* Check if the op failed because the device doesn't */
8281 	/* support this particular combination of algorithms */
8282 	if (op == NULL && ut_params->op->status ==
8283 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8284 		printf("Device doesn't support this mixed combination. "
8285 				"Test Skipped.\n");
8286 		return TEST_SKIPPED;
8287 	}
8288 	ut_params->op = op;
8289 
8290 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8291 
8292 	ut_params->obuf = (op_mode == IN_PLACE ?
8293 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8294 
8295 	if (verify) {
8296 		if (ut_params->obuf)
8297 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8298 					plaintext_len, buffer);
8299 		else
8300 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8301 					plaintext_len, buffer);
8302 
8303 		debug_hexdump(stdout, "plaintext:", plaintext,
8304 				(tdata->plaintext.len_bits >> 3) -
8305 				tdata->digest_enc.len);
8306 		debug_hexdump(stdout, "plaintext expected:",
8307 				tdata->plaintext.data,
8308 				(tdata->plaintext.len_bits >> 3) -
8309 				tdata->digest_enc.len);
8310 	} else {
8311 		if (ut_params->obuf)
8312 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8313 					ciphertext_len, buffer);
8314 		else
8315 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8316 					ciphertext_len, buffer);
8317 
8318 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8319 			ciphertext_len);
8320 		debug_hexdump(stdout, "ciphertext expected:",
8321 			tdata->ciphertext.data,
8322 			tdata->ciphertext.len_bits >> 3);
8323 
8324 		if (ut_params->obuf)
8325 			digest = rte_pktmbuf_read(ut_params->obuf,
8326 					(tdata->digest_enc.offset == 0 ?
8327 						plaintext_pad_len :
8328 						tdata->digest_enc.offset),
8329 					tdata->digest_enc.len, digest_buffer);
8330 		else
8331 			digest = rte_pktmbuf_read(ut_params->ibuf,
8332 					(tdata->digest_enc.offset == 0 ?
8333 						plaintext_pad_len :
8334 						tdata->digest_enc.offset),
8335 					tdata->digest_enc.len, digest_buffer);
8336 
8337 		debug_hexdump(stdout, "digest:", digest,
8338 				tdata->digest_enc.len);
8339 		debug_hexdump(stdout, "digest expected:",
8340 				tdata->digest_enc.data, tdata->digest_enc.len);
8341 	}
8342 
8343 	if (!verify) {
8344 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8345 				digest,
8346 				tdata->digest_enc.data,
8347 				tdata->digest_enc.len,
8348 				"Generated auth tag not as expected");
8349 	}
8350 
8351 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8352 		if (verify) {
8353 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8354 					plaintext,
8355 					tdata->plaintext.data,
8356 					tdata->plaintext.len_bits >> 3,
8357 					"Plaintext data not as expected");
8358 		} else {
8359 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8360 					ciphertext,
8361 					tdata->ciphertext.data,
8362 					tdata->validDataLen.len_bits,
8363 					"Ciphertext data not as expected");
8364 		}
8365 	}
8366 
8367 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8368 			"crypto op processing failed");
8369 
8370 	return 0;
8371 }
8372 
8373 /** AUTH AES CMAC + CIPHER AES CTR */
8374 
8375 static int
8376 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8377 {
8378 	return test_mixed_auth_cipher(
8379 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8380 }
8381 
8382 static int
8383 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8384 {
8385 	return test_mixed_auth_cipher(
8386 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8387 }
8388 
8389 static int
8390 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8391 {
8392 	return test_mixed_auth_cipher_sgl(
8393 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8394 }
8395 
8396 static int
8397 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8398 {
8399 	return test_mixed_auth_cipher_sgl(
8400 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8401 }
8402 
8403 static int
8404 test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8405 {
8406 	return test_mixed_auth_cipher(
8407 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8408 }
8409 
8410 static int
8411 test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8412 {
8413 	return test_mixed_auth_cipher(
8414 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8415 }
8416 
8417 static int
8418 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8419 {
8420 	return test_mixed_auth_cipher(
8421 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8422 }
8423 
8424 static int
8425 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8426 {
8427 	return test_mixed_auth_cipher(
8428 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8429 }
8430 
8431 static int
8432 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8433 {
8434 	return test_mixed_auth_cipher(
8435 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8436 }
8437 
8438 static int
8439 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8440 {
8441 	return test_mixed_auth_cipher_sgl(
8442 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8443 }
8444 
8445 static int
8446 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8447 {
8448 	return test_mixed_auth_cipher_sgl(
8449 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8450 }
8451 
8452 static int
8453 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8454 {
8455 	return test_mixed_auth_cipher(
8456 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8457 }
8458 
8459 /** MIXED AUTH + CIPHER */
8460 
8461 static int
8462 test_auth_zuc_cipher_snow_test_case_1(void)
8463 {
8464 	return test_mixed_auth_cipher(
8465 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8466 }
8467 
8468 static int
8469 test_verify_auth_zuc_cipher_snow_test_case_1(void)
8470 {
8471 	return test_mixed_auth_cipher(
8472 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8473 }
8474 
8475 static int
8476 test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8477 {
8478 	return test_mixed_auth_cipher(
8479 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8480 }
8481 
8482 static int
8483 test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8484 {
8485 	return test_mixed_auth_cipher(
8486 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8487 }
8488 
8489 
8490 static int
8491 test_auth_aes_cmac_cipher_snow_test_case_1(void)
8492 {
8493 	return test_mixed_auth_cipher(
8494 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8495 }
8496 
8497 static int
8498 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8499 {
8500 	return test_mixed_auth_cipher(
8501 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8502 }
8503 
8504 static int
8505 test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8506 {
8507 	return test_mixed_auth_cipher(
8508 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8509 }
8510 
8511 static int
8512 test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8513 {
8514 	return test_mixed_auth_cipher(
8515 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8516 }
8517 
8518 static int
8519 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8520 {
8521 	return test_mixed_auth_cipher(
8522 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8523 }
8524 
8525 static int
8526 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8527 {
8528 	return test_mixed_auth_cipher(
8529 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8530 }
8531 
8532 static int
8533 test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8534 {
8535 	return test_mixed_auth_cipher(
8536 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8537 }
8538 
8539 static int
8540 test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8541 {
8542 	return test_mixed_auth_cipher(
8543 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8544 }
8545 
8546 static int
8547 test_auth_snow_cipher_aes_ctr_test_case_1(void)
8548 {
8549 	return test_mixed_auth_cipher(
8550 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8551 }
8552 
8553 static int
8554 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8555 {
8556 	return test_mixed_auth_cipher(
8557 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8558 }
8559 
8560 static int
8561 test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8562 {
8563 	return test_mixed_auth_cipher_sgl(
8564 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8565 }
8566 
8567 static int
8568 test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8569 {
8570 	return test_mixed_auth_cipher(
8571 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8572 }
8573 
8574 static int
8575 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8576 {
8577 	return test_mixed_auth_cipher_sgl(
8578 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8579 }
8580 
8581 static int
8582 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8583 {
8584 	return test_mixed_auth_cipher(
8585 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8586 }
8587 
8588 static int
8589 test_auth_snow_cipher_zuc_test_case_1(void)
8590 {
8591 	return test_mixed_auth_cipher(
8592 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8593 }
8594 
8595 static int
8596 test_verify_auth_snow_cipher_zuc_test_case_1(void)
8597 {
8598 	return test_mixed_auth_cipher(
8599 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8600 }
8601 
8602 static int
8603 test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8604 {
8605 	return test_mixed_auth_cipher(
8606 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8607 }
8608 
8609 static int
8610 test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8611 {
8612 	return test_mixed_auth_cipher(
8613 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8614 }
8615 
8616 static int
8617 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8618 {
8619 	return test_mixed_auth_cipher(
8620 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8621 }
8622 
8623 static int
8624 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8625 {
8626 	return test_mixed_auth_cipher(
8627 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8628 }
8629 static int
8630 test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8631 {
8632 	return test_mixed_auth_cipher(
8633 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8634 }
8635 
8636 static int
8637 test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8638 {
8639 	return test_mixed_auth_cipher(
8640 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8641 }
8642 
8643 static int
8644 test_auth_null_cipher_snow_test_case_1(void)
8645 {
8646 	return test_mixed_auth_cipher(
8647 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8648 }
8649 
8650 static int
8651 test_verify_auth_null_cipher_snow_test_case_1(void)
8652 {
8653 	return test_mixed_auth_cipher(
8654 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8655 }
8656 
8657 static int
8658 test_auth_null_cipher_zuc_test_case_1(void)
8659 {
8660 	return test_mixed_auth_cipher(
8661 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8662 }
8663 
8664 static int
8665 test_verify_auth_null_cipher_zuc_test_case_1(void)
8666 {
8667 	return test_mixed_auth_cipher(
8668 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8669 }
8670 
8671 static int
8672 test_auth_snow_cipher_null_test_case_1(void)
8673 {
8674 	return test_mixed_auth_cipher(
8675 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8676 }
8677 
8678 static int
8679 test_verify_auth_snow_cipher_null_test_case_1(void)
8680 {
8681 	return test_mixed_auth_cipher(
8682 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8683 }
8684 
8685 static int
8686 test_auth_zuc_cipher_null_test_case_1(void)
8687 {
8688 	return test_mixed_auth_cipher(
8689 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8690 }
8691 
8692 static int
8693 test_verify_auth_zuc_cipher_null_test_case_1(void)
8694 {
8695 	return test_mixed_auth_cipher(
8696 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8697 }
8698 
8699 static int
8700 test_auth_null_cipher_aes_ctr_test_case_1(void)
8701 {
8702 	return test_mixed_auth_cipher(
8703 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8704 }
8705 
8706 static int
8707 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8708 {
8709 	return test_mixed_auth_cipher(
8710 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8711 }
8712 
8713 static int
8714 test_auth_aes_cmac_cipher_null_test_case_1(void)
8715 {
8716 	return test_mixed_auth_cipher(
8717 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8718 }
8719 
8720 static int
8721 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8722 {
8723 	return test_mixed_auth_cipher(
8724 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8725 }
8726 
8727 /* ***** AEAD algorithm Tests ***** */
8728 
8729 static int
8730 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8731 		enum rte_crypto_aead_operation op,
8732 		const uint8_t *key, const uint8_t key_len,
8733 		const uint16_t aad_len, const uint8_t auth_len,
8734 		uint8_t iv_len)
8735 {
8736 	uint8_t aead_key[key_len];
8737 
8738 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8739 	struct crypto_unittest_params *ut_params = &unittest_params;
8740 
8741 	memcpy(aead_key, key, key_len);
8742 
8743 	/* Setup AEAD Parameters */
8744 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8745 	ut_params->aead_xform.next = NULL;
8746 	ut_params->aead_xform.aead.algo = algo;
8747 	ut_params->aead_xform.aead.op = op;
8748 	ut_params->aead_xform.aead.key.data = aead_key;
8749 	ut_params->aead_xform.aead.key.length = key_len;
8750 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8751 	ut_params->aead_xform.aead.iv.length = iv_len;
8752 	ut_params->aead_xform.aead.digest_length = auth_len;
8753 	ut_params->aead_xform.aead.aad_length = aad_len;
8754 
8755 	debug_hexdump(stdout, "key:", key, key_len);
8756 
8757 	/* Create Crypto session*/
8758 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8759 			&ut_params->aead_xform, ts_params->session_mpool);
8760 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8761 		return TEST_SKIPPED;
8762 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8763 	return 0;
8764 }
8765 
8766 static int
8767 create_aead_xform(struct rte_crypto_op *op,
8768 		enum rte_crypto_aead_algorithm algo,
8769 		enum rte_crypto_aead_operation aead_op,
8770 		uint8_t *key, const uint8_t key_len,
8771 		const uint8_t aad_len, const uint8_t auth_len,
8772 		uint8_t iv_len)
8773 {
8774 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8775 			"failed to allocate space for crypto transform");
8776 
8777 	struct rte_crypto_sym_op *sym_op = op->sym;
8778 
8779 	/* Setup AEAD Parameters */
8780 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8781 	sym_op->xform->next = NULL;
8782 	sym_op->xform->aead.algo = algo;
8783 	sym_op->xform->aead.op = aead_op;
8784 	sym_op->xform->aead.key.data = key;
8785 	sym_op->xform->aead.key.length = key_len;
8786 	sym_op->xform->aead.iv.offset = IV_OFFSET;
8787 	sym_op->xform->aead.iv.length = iv_len;
8788 	sym_op->xform->aead.digest_length = auth_len;
8789 	sym_op->xform->aead.aad_length = aad_len;
8790 
8791 	debug_hexdump(stdout, "key:", key, key_len);
8792 
8793 	return 0;
8794 }
8795 
8796 static int
8797 create_aead_operation(enum rte_crypto_aead_operation op,
8798 		const struct aead_test_data *tdata)
8799 {
8800 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8801 	struct crypto_unittest_params *ut_params = &unittest_params;
8802 
8803 	uint8_t *plaintext, *ciphertext;
8804 	unsigned int aad_pad_len, plaintext_pad_len;
8805 
8806 	/* Generate Crypto op data structure */
8807 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8808 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8809 	TEST_ASSERT_NOT_NULL(ut_params->op,
8810 			"Failed to allocate symmetric crypto operation struct");
8811 
8812 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8813 
8814 	/* Append aad data */
8815 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8816 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8817 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8818 				aad_pad_len);
8819 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8820 				"no room to append aad");
8821 
8822 		sym_op->aead.aad.phys_addr =
8823 				rte_pktmbuf_iova(ut_params->ibuf);
8824 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
8825 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8826 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8827 			tdata->aad.len);
8828 
8829 		/* Append IV at the end of the crypto operation*/
8830 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8831 				uint8_t *, IV_OFFSET);
8832 
8833 		/* Copy IV 1 byte after the IV pointer, according to the API */
8834 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8835 		debug_hexdump(stdout, "iv:", iv_ptr + 1,
8836 			tdata->iv.len);
8837 	} else {
8838 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8839 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8840 				aad_pad_len);
8841 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8842 				"no room to append aad");
8843 
8844 		sym_op->aead.aad.phys_addr =
8845 				rte_pktmbuf_iova(ut_params->ibuf);
8846 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8847 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8848 			tdata->aad.len);
8849 
8850 		/* Append IV at the end of the crypto operation*/
8851 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8852 				uint8_t *, IV_OFFSET);
8853 
8854 		if (tdata->iv.len == 0) {
8855 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8856 			debug_hexdump(stdout, "iv:", iv_ptr,
8857 				AES_GCM_J0_LENGTH);
8858 		} else {
8859 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8860 			debug_hexdump(stdout, "iv:", iv_ptr,
8861 				tdata->iv.len);
8862 		}
8863 	}
8864 
8865 	/* Append plaintext/ciphertext */
8866 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8867 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8868 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8869 				plaintext_pad_len);
8870 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8871 
8872 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8873 		debug_hexdump(stdout, "plaintext:", plaintext,
8874 				tdata->plaintext.len);
8875 
8876 		if (ut_params->obuf) {
8877 			ciphertext = (uint8_t *)rte_pktmbuf_append(
8878 					ut_params->obuf,
8879 					plaintext_pad_len + aad_pad_len);
8880 			TEST_ASSERT_NOT_NULL(ciphertext,
8881 					"no room to append ciphertext");
8882 
8883 			memset(ciphertext + aad_pad_len, 0,
8884 					tdata->ciphertext.len);
8885 		}
8886 	} else {
8887 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8888 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8889 				plaintext_pad_len);
8890 		TEST_ASSERT_NOT_NULL(ciphertext,
8891 				"no room to append ciphertext");
8892 
8893 		memcpy(ciphertext, tdata->ciphertext.data,
8894 				tdata->ciphertext.len);
8895 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8896 				tdata->ciphertext.len);
8897 
8898 		if (ut_params->obuf) {
8899 			plaintext = (uint8_t *)rte_pktmbuf_append(
8900 					ut_params->obuf,
8901 					plaintext_pad_len + aad_pad_len);
8902 			TEST_ASSERT_NOT_NULL(plaintext,
8903 					"no room to append plaintext");
8904 
8905 			memset(plaintext + aad_pad_len, 0,
8906 					tdata->plaintext.len);
8907 		}
8908 	}
8909 
8910 	/* Append digest data */
8911 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8912 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8913 				ut_params->obuf ? ut_params->obuf :
8914 						ut_params->ibuf,
8915 						tdata->auth_tag.len);
8916 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8917 				"no room to append digest");
8918 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8919 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8920 				ut_params->obuf ? ut_params->obuf :
8921 						ut_params->ibuf,
8922 						plaintext_pad_len +
8923 						aad_pad_len);
8924 	} else {
8925 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8926 				ut_params->ibuf, tdata->auth_tag.len);
8927 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8928 				"no room to append digest");
8929 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8930 				ut_params->ibuf,
8931 				plaintext_pad_len + aad_pad_len);
8932 
8933 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8934 			tdata->auth_tag.len);
8935 		debug_hexdump(stdout, "digest:",
8936 			sym_op->aead.digest.data,
8937 			tdata->auth_tag.len);
8938 	}
8939 
8940 	sym_op->aead.data.length = tdata->plaintext.len;
8941 	sym_op->aead.data.offset = aad_pad_len;
8942 
8943 	return 0;
8944 }
8945 
8946 static int
8947 test_authenticated_encryption(const struct aead_test_data *tdata)
8948 {
8949 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8950 	struct crypto_unittest_params *ut_params = &unittest_params;
8951 
8952 	int retval;
8953 	uint8_t *ciphertext, *auth_tag;
8954 	uint16_t plaintext_pad_len;
8955 	uint32_t i;
8956 	struct rte_cryptodev_info dev_info;
8957 
8958 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8959 	uint64_t feat_flags = dev_info.feature_flags;
8960 
8961 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8962 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8963 		printf("Device doesn't support RAW data-path APIs.\n");
8964 		return TEST_SKIPPED;
8965 	}
8966 
8967 	/* Verify the capabilities */
8968 	struct rte_cryptodev_sym_capability_idx cap_idx;
8969 	const struct rte_cryptodev_symmetric_capability *capability;
8970 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8971 	cap_idx.algo.aead = tdata->algo;
8972 	capability = rte_cryptodev_sym_capability_get(
8973 			ts_params->valid_devs[0], &cap_idx);
8974 	if (capability == NULL)
8975 		return TEST_SKIPPED;
8976 	if (rte_cryptodev_sym_capability_check_aead(
8977 			capability, tdata->key.len, tdata->auth_tag.len,
8978 			tdata->aad.len, tdata->iv.len))
8979 		return TEST_SKIPPED;
8980 
8981 	/* Create AEAD session */
8982 	retval = create_aead_session(ts_params->valid_devs[0],
8983 			tdata->algo,
8984 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
8985 			tdata->key.data, tdata->key.len,
8986 			tdata->aad.len, tdata->auth_tag.len,
8987 			tdata->iv.len);
8988 	if (retval != TEST_SUCCESS)
8989 		return retval;
8990 
8991 	if (tdata->aad.len > MBUF_SIZE) {
8992 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8993 		/* Populate full size of add data */
8994 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8995 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8996 	} else
8997 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8998 
8999 	/* clear mbuf payload */
9000 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9001 			rte_pktmbuf_tailroom(ut_params->ibuf));
9002 
9003 	/* Create AEAD operation */
9004 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9005 	if (retval < 0)
9006 		return retval;
9007 
9008 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9009 
9010 	ut_params->op->sym->m_src = ut_params->ibuf;
9011 
9012 	/* Process crypto operation */
9013 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9014 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9015 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9016 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9017 					       0);
9018 		if (retval != TEST_SUCCESS)
9019 			return retval;
9020 	} else
9021 		TEST_ASSERT_NOT_NULL(
9022 			process_crypto_request(ts_params->valid_devs[0],
9023 			ut_params->op), "failed to process sym crypto op");
9024 
9025 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9026 			"crypto op processing failed");
9027 
9028 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9029 
9030 	if (ut_params->op->sym->m_dst) {
9031 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9032 				uint8_t *);
9033 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9034 				uint8_t *, plaintext_pad_len);
9035 	} else {
9036 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9037 				uint8_t *,
9038 				ut_params->op->sym->cipher.data.offset);
9039 		auth_tag = ciphertext + plaintext_pad_len;
9040 	}
9041 
9042 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9043 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9044 
9045 	/* Validate obuf */
9046 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9047 			ciphertext,
9048 			tdata->ciphertext.data,
9049 			tdata->ciphertext.len,
9050 			"Ciphertext data not as expected");
9051 
9052 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9053 			auth_tag,
9054 			tdata->auth_tag.data,
9055 			tdata->auth_tag.len,
9056 			"Generated auth tag not as expected");
9057 
9058 	return 0;
9059 
9060 }
9061 
9062 #ifdef RTE_LIB_SECURITY
9063 static int
9064 security_proto_supported(enum rte_security_session_action_type action,
9065 	enum rte_security_session_protocol proto)
9066 {
9067 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9068 
9069 	const struct rte_security_capability *capabilities;
9070 	const struct rte_security_capability *capability;
9071 	uint16_t i = 0;
9072 
9073 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9074 
9075 
9076 	capabilities = rte_security_capabilities_get(ctx);
9077 
9078 	if (capabilities == NULL)
9079 		return -ENOTSUP;
9080 
9081 	while ((capability = &capabilities[i++])->action !=
9082 			RTE_SECURITY_ACTION_TYPE_NONE) {
9083 		if (capability->action == action &&
9084 				capability->protocol == proto)
9085 			return 0;
9086 	}
9087 
9088 	return -ENOTSUP;
9089 }
9090 
9091 /* Basic algorithm run function for async inplace mode.
9092  * Creates a session from input parameters and runs one operation
9093  * on input_vec. Checks the output of the crypto operation against
9094  * output_vec.
9095  */
9096 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9097 			   enum rte_crypto_auth_operation opa,
9098 			   const uint8_t *input_vec, unsigned int input_vec_len,
9099 			   const uint8_t *output_vec,
9100 			   unsigned int output_vec_len,
9101 			   enum rte_crypto_cipher_algorithm cipher_alg,
9102 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
9103 			   enum rte_crypto_auth_algorithm auth_alg,
9104 			   const uint8_t *auth_key, uint32_t auth_key_len,
9105 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
9106 			   uint8_t packet_direction, uint8_t sn_size,
9107 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9108 {
9109 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9110 	struct crypto_unittest_params *ut_params = &unittest_params;
9111 	uint8_t *plaintext;
9112 	int ret = TEST_SUCCESS;
9113 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9114 	struct rte_cryptodev_info dev_info;
9115 	uint64_t feat_flags;
9116 
9117 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9118 	feat_flags = dev_info.feature_flags;
9119 
9120 	/* Verify the capabilities */
9121 	struct rte_security_capability_idx sec_cap_idx;
9122 
9123 	sec_cap_idx.action = ut_params->type;
9124 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9125 	sec_cap_idx.pdcp.domain = domain;
9126 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9127 		return TEST_SKIPPED;
9128 
9129 	/* Generate test mbuf data */
9130 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9131 
9132 	/* clear mbuf payload */
9133 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9134 			rte_pktmbuf_tailroom(ut_params->ibuf));
9135 
9136 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9137 						  input_vec_len);
9138 	memcpy(plaintext, input_vec, input_vec_len);
9139 
9140 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9141 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9142 		printf("Device does not support RAW data-path APIs.\n");
9143 		return TEST_SKIPPED;
9144 	}
9145 	/* Out of place support */
9146 	if (oop) {
9147 		/*
9148 		 * For out-op-place we need to alloc another mbuf
9149 		 */
9150 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9151 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9152 	}
9153 
9154 	/* Setup Cipher Parameters */
9155 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9156 	ut_params->cipher_xform.cipher.algo = cipher_alg;
9157 	ut_params->cipher_xform.cipher.op = opc;
9158 	ut_params->cipher_xform.cipher.key.data = cipher_key;
9159 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9160 	ut_params->cipher_xform.cipher.iv.length =
9161 				packet_direction ? 4 : 0;
9162 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9163 
9164 	/* Setup HMAC Parameters if ICV header is required */
9165 	if (auth_alg != 0) {
9166 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9167 		ut_params->auth_xform.next = NULL;
9168 		ut_params->auth_xform.auth.algo = auth_alg;
9169 		ut_params->auth_xform.auth.op = opa;
9170 		ut_params->auth_xform.auth.key.data = auth_key;
9171 		ut_params->auth_xform.auth.key.length = auth_key_len;
9172 
9173 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9174 	} else {
9175 		ut_params->cipher_xform.next = NULL;
9176 	}
9177 
9178 	struct rte_security_session_conf sess_conf = {
9179 		.action_type = ut_params->type,
9180 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9181 		{.pdcp = {
9182 			.bearer = bearer,
9183 			.domain = domain,
9184 			.pkt_dir = packet_direction,
9185 			.sn_size = sn_size,
9186 			.hfn = packet_direction ? 0 : hfn,
9187 			/**
9188 			 * hfn can be set as pdcp_test_hfn[i]
9189 			 * if hfn_ovrd is not set. Here, PDCP
9190 			 * packet direction is just used to
9191 			 * run half of the cases with session
9192 			 * HFN and other half with per packet
9193 			 * HFN.
9194 			 */
9195 			.hfn_threshold = hfn_threshold,
9196 			.hfn_ovrd = packet_direction ? 1 : 0,
9197 			.sdap_enabled = sdap,
9198 		} },
9199 		.crypto_xform = &ut_params->cipher_xform
9200 	};
9201 
9202 	/* Create security session */
9203 	ut_params->sec_session = rte_security_session_create(ctx,
9204 				&sess_conf, ts_params->session_mpool);
9205 
9206 	if (!ut_params->sec_session) {
9207 		printf("TestCase %s()-%d line %d failed %s: ",
9208 			__func__, i, __LINE__, "Failed to allocate session");
9209 		ret = TEST_FAILED;
9210 		goto on_err;
9211 	}
9212 
9213 	/* Generate crypto op data structure */
9214 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9215 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9216 	if (!ut_params->op) {
9217 		printf("TestCase %s()-%d line %d failed %s: ",
9218 			__func__, i, __LINE__,
9219 			"Failed to allocate symmetric crypto operation struct");
9220 		ret = TEST_FAILED;
9221 		goto on_err;
9222 	}
9223 
9224 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9225 					uint32_t *, IV_OFFSET);
9226 	*per_pkt_hfn = packet_direction ? hfn : 0;
9227 
9228 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9229 
9230 	/* set crypto operation source mbuf */
9231 	ut_params->op->sym->m_src = ut_params->ibuf;
9232 	if (oop)
9233 		ut_params->op->sym->m_dst = ut_params->obuf;
9234 
9235 	/* Process crypto operation */
9236 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9237 		/* filling lengths */
9238 		ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9239 		ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9240 
9241 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9242 		if (ret != TEST_SUCCESS)
9243 			return ret;
9244 	} else {
9245 		ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9246 	}
9247 	if (ut_params->op == NULL) {
9248 		printf("TestCase %s()-%d line %d failed %s: ",
9249 			__func__, i, __LINE__,
9250 			"failed to process sym crypto op");
9251 		ret = TEST_FAILED;
9252 		goto on_err;
9253 	}
9254 
9255 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9256 		printf("TestCase %s()-%d line %d failed %s: ",
9257 			__func__, i, __LINE__, "crypto op processing failed");
9258 		ret = TEST_FAILED;
9259 		goto on_err;
9260 	}
9261 
9262 	/* Validate obuf */
9263 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9264 			uint8_t *);
9265 	if (oop) {
9266 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9267 				uint8_t *);
9268 	}
9269 
9270 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
9271 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9272 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9273 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9274 		ret = TEST_FAILED;
9275 		goto on_err;
9276 	}
9277 
9278 on_err:
9279 	rte_crypto_op_free(ut_params->op);
9280 	ut_params->op = NULL;
9281 
9282 	if (ut_params->sec_session)
9283 		rte_security_session_destroy(ctx, ut_params->sec_session);
9284 	ut_params->sec_session = NULL;
9285 
9286 	rte_pktmbuf_free(ut_params->ibuf);
9287 	ut_params->ibuf = NULL;
9288 	if (oop) {
9289 		rte_pktmbuf_free(ut_params->obuf);
9290 		ut_params->obuf = NULL;
9291 	}
9292 
9293 	return ret;
9294 }
9295 
9296 static int
9297 test_pdcp_proto_SGL(int i, int oop,
9298 	enum rte_crypto_cipher_operation opc,
9299 	enum rte_crypto_auth_operation opa,
9300 	uint8_t *input_vec,
9301 	unsigned int input_vec_len,
9302 	uint8_t *output_vec,
9303 	unsigned int output_vec_len,
9304 	uint32_t fragsz,
9305 	uint32_t fragsz_oop)
9306 {
9307 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9308 	struct crypto_unittest_params *ut_params = &unittest_params;
9309 	uint8_t *plaintext;
9310 	struct rte_mbuf *buf, *buf_oop = NULL;
9311 	int ret = TEST_SUCCESS;
9312 	int to_trn = 0;
9313 	int to_trn_tbl[16];
9314 	int segs = 1;
9315 	unsigned int trn_data = 0;
9316 	struct rte_cryptodev_info dev_info;
9317 	uint64_t feat_flags;
9318 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9319 	struct rte_mbuf *temp_mbuf;
9320 
9321 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9322 	feat_flags = dev_info.feature_flags;
9323 
9324 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9325 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9326 		printf("Device does not support RAW data-path APIs.\n");
9327 		return -ENOTSUP;
9328 	}
9329 	/* Verify the capabilities */
9330 	struct rte_security_capability_idx sec_cap_idx;
9331 
9332 	sec_cap_idx.action = ut_params->type;
9333 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9334 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9335 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9336 		return TEST_SKIPPED;
9337 
9338 	if (fragsz > input_vec_len)
9339 		fragsz = input_vec_len;
9340 
9341 	uint16_t plaintext_len = fragsz;
9342 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9343 
9344 	if (fragsz_oop > output_vec_len)
9345 		frag_size_oop = output_vec_len;
9346 
9347 	int ecx = 0;
9348 	if (input_vec_len % fragsz != 0) {
9349 		if (input_vec_len / fragsz + 1 > 16)
9350 			return 1;
9351 	} else if (input_vec_len / fragsz > 16)
9352 		return 1;
9353 
9354 	/* Out of place support */
9355 	if (oop) {
9356 		/*
9357 		 * For out-op-place we need to alloc another mbuf
9358 		 */
9359 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9360 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9361 		buf_oop = ut_params->obuf;
9362 	}
9363 
9364 	/* Generate test mbuf data */
9365 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9366 
9367 	/* clear mbuf payload */
9368 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9369 			rte_pktmbuf_tailroom(ut_params->ibuf));
9370 
9371 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9372 						  plaintext_len);
9373 	memcpy(plaintext, input_vec, plaintext_len);
9374 	trn_data += plaintext_len;
9375 
9376 	buf = ut_params->ibuf;
9377 
9378 	/*
9379 	 * Loop until no more fragments
9380 	 */
9381 
9382 	while (trn_data < input_vec_len) {
9383 		++segs;
9384 		to_trn = (input_vec_len - trn_data < fragsz) ?
9385 				(input_vec_len - trn_data) : fragsz;
9386 
9387 		to_trn_tbl[ecx++] = to_trn;
9388 
9389 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9390 		buf = buf->next;
9391 
9392 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9393 				rte_pktmbuf_tailroom(buf));
9394 
9395 		/* OOP */
9396 		if (oop && !fragsz_oop) {
9397 			buf_oop->next =
9398 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
9399 			buf_oop = buf_oop->next;
9400 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9401 					0, rte_pktmbuf_tailroom(buf_oop));
9402 			rte_pktmbuf_append(buf_oop, to_trn);
9403 		}
9404 
9405 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9406 				to_trn);
9407 
9408 		memcpy(plaintext, input_vec + trn_data, to_trn);
9409 		trn_data += to_trn;
9410 	}
9411 
9412 	ut_params->ibuf->nb_segs = segs;
9413 
9414 	segs = 1;
9415 	if (fragsz_oop && oop) {
9416 		to_trn = 0;
9417 		ecx = 0;
9418 
9419 		trn_data = frag_size_oop;
9420 		while (trn_data < output_vec_len) {
9421 			++segs;
9422 			to_trn =
9423 				(output_vec_len - trn_data <
9424 						frag_size_oop) ?
9425 				(output_vec_len - trn_data) :
9426 						frag_size_oop;
9427 
9428 			to_trn_tbl[ecx++] = to_trn;
9429 
9430 			buf_oop->next =
9431 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
9432 			buf_oop = buf_oop->next;
9433 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9434 					0, rte_pktmbuf_tailroom(buf_oop));
9435 			rte_pktmbuf_append(buf_oop, to_trn);
9436 
9437 			trn_data += to_trn;
9438 		}
9439 		ut_params->obuf->nb_segs = segs;
9440 	}
9441 
9442 	/* Setup Cipher Parameters */
9443 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9444 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9445 	ut_params->cipher_xform.cipher.op = opc;
9446 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9447 	ut_params->cipher_xform.cipher.key.length =
9448 					pdcp_test_params[i].cipher_key_len;
9449 	ut_params->cipher_xform.cipher.iv.length = 0;
9450 
9451 	/* Setup HMAC Parameters if ICV header is required */
9452 	if (pdcp_test_params[i].auth_alg != 0) {
9453 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9454 		ut_params->auth_xform.next = NULL;
9455 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9456 		ut_params->auth_xform.auth.op = opa;
9457 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9458 		ut_params->auth_xform.auth.key.length =
9459 					pdcp_test_params[i].auth_key_len;
9460 
9461 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9462 	} else {
9463 		ut_params->cipher_xform.next = NULL;
9464 	}
9465 
9466 	struct rte_security_session_conf sess_conf = {
9467 		.action_type = ut_params->type,
9468 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9469 		{.pdcp = {
9470 			.bearer = pdcp_test_bearer[i],
9471 			.domain = pdcp_test_params[i].domain,
9472 			.pkt_dir = pdcp_test_packet_direction[i],
9473 			.sn_size = pdcp_test_data_sn_size[i],
9474 			.hfn = pdcp_test_hfn[i],
9475 			.hfn_threshold = pdcp_test_hfn_threshold[i],
9476 			.hfn_ovrd = 0,
9477 		} },
9478 		.crypto_xform = &ut_params->cipher_xform
9479 	};
9480 
9481 	/* Create security session */
9482 	ut_params->sec_session = rte_security_session_create(ctx,
9483 				&sess_conf, ts_params->session_mpool);
9484 
9485 	if (!ut_params->sec_session) {
9486 		printf("TestCase %s()-%d line %d failed %s: ",
9487 			__func__, i, __LINE__, "Failed to allocate session");
9488 		ret = TEST_FAILED;
9489 		goto on_err;
9490 	}
9491 
9492 	/* Generate crypto op data structure */
9493 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9494 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9495 	if (!ut_params->op) {
9496 		printf("TestCase %s()-%d line %d failed %s: ",
9497 			__func__, i, __LINE__,
9498 			"Failed to allocate symmetric crypto operation struct");
9499 		ret = TEST_FAILED;
9500 		goto on_err;
9501 	}
9502 
9503 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9504 
9505 	/* set crypto operation source mbuf */
9506 	ut_params->op->sym->m_src = ut_params->ibuf;
9507 	if (oop)
9508 		ut_params->op->sym->m_dst = ut_params->obuf;
9509 
9510 	/* Process crypto operation */
9511 	temp_mbuf = ut_params->op->sym->m_src;
9512 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9513 		/* filling lengths */
9514 		while (temp_mbuf) {
9515 			ut_params->op->sym->cipher.data.length
9516 				+= temp_mbuf->pkt_len;
9517 			ut_params->op->sym->auth.data.length
9518 				+= temp_mbuf->pkt_len;
9519 			temp_mbuf = temp_mbuf->next;
9520 		}
9521 
9522 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9523 		if (ret != TEST_SUCCESS)
9524 			return ret;
9525 	} else {
9526 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9527 							ut_params->op);
9528 	}
9529 	if (ut_params->op == NULL) {
9530 		printf("TestCase %s()-%d line %d failed %s: ",
9531 			__func__, i, __LINE__,
9532 			"failed to process sym crypto op");
9533 		ret = TEST_FAILED;
9534 		goto on_err;
9535 	}
9536 
9537 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9538 		printf("TestCase %s()-%d line %d failed %s: ",
9539 			__func__, i, __LINE__, "crypto op processing failed");
9540 		ret = TEST_FAILED;
9541 		goto on_err;
9542 	}
9543 
9544 	/* Validate obuf */
9545 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9546 			uint8_t *);
9547 	if (oop) {
9548 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9549 				uint8_t *);
9550 	}
9551 	if (fragsz_oop)
9552 		fragsz = frag_size_oop;
9553 	if (memcmp(ciphertext, output_vec, fragsz)) {
9554 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9555 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9556 		rte_hexdump(stdout, "reference", output_vec, fragsz);
9557 		ret = TEST_FAILED;
9558 		goto on_err;
9559 	}
9560 
9561 	buf = ut_params->op->sym->m_src->next;
9562 	if (oop)
9563 		buf = ut_params->op->sym->m_dst->next;
9564 
9565 	unsigned int off = fragsz;
9566 
9567 	ecx = 0;
9568 	while (buf) {
9569 		ciphertext = rte_pktmbuf_mtod(buf,
9570 				uint8_t *);
9571 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9572 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9573 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9574 			rte_hexdump(stdout, "reference", output_vec + off,
9575 					to_trn_tbl[ecx]);
9576 			ret = TEST_FAILED;
9577 			goto on_err;
9578 		}
9579 		off += to_trn_tbl[ecx++];
9580 		buf = buf->next;
9581 	}
9582 on_err:
9583 	rte_crypto_op_free(ut_params->op);
9584 	ut_params->op = NULL;
9585 
9586 	if (ut_params->sec_session)
9587 		rte_security_session_destroy(ctx, ut_params->sec_session);
9588 	ut_params->sec_session = NULL;
9589 
9590 	rte_pktmbuf_free(ut_params->ibuf);
9591 	ut_params->ibuf = NULL;
9592 	if (oop) {
9593 		rte_pktmbuf_free(ut_params->obuf);
9594 		ut_params->obuf = NULL;
9595 	}
9596 
9597 	return ret;
9598 }
9599 
9600 int
9601 test_pdcp_proto_cplane_encap(int i)
9602 {
9603 	return test_pdcp_proto(
9604 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9605 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9606 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9607 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9608 		pdcp_test_params[i].cipher_key_len,
9609 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9610 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9611 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9612 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9613 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9614 }
9615 
9616 int
9617 test_pdcp_proto_uplane_encap(int i)
9618 {
9619 	return test_pdcp_proto(
9620 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9621 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9622 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9623 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9624 		pdcp_test_params[i].cipher_key_len,
9625 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9626 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9627 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9628 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9629 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9630 }
9631 
9632 int
9633 test_pdcp_proto_uplane_encap_with_int(int i)
9634 {
9635 	return test_pdcp_proto(
9636 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9637 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9638 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9639 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9640 		pdcp_test_params[i].cipher_key_len,
9641 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9642 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9643 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9644 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9645 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9646 }
9647 
9648 int
9649 test_pdcp_proto_cplane_decap(int i)
9650 {
9651 	return test_pdcp_proto(
9652 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9653 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9654 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9655 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9656 		pdcp_test_params[i].cipher_key_len,
9657 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9658 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9659 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9660 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9661 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9662 }
9663 
9664 int
9665 test_pdcp_proto_uplane_decap(int i)
9666 {
9667 	return test_pdcp_proto(
9668 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9669 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9670 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9671 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9672 		pdcp_test_params[i].cipher_key_len,
9673 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9674 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9675 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9676 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9677 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9678 }
9679 
9680 int
9681 test_pdcp_proto_uplane_decap_with_int(int i)
9682 {
9683 	return test_pdcp_proto(
9684 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9685 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9686 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9687 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9688 		pdcp_test_params[i].cipher_key_len,
9689 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9690 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9691 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9692 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9693 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9694 }
9695 
9696 static int
9697 test_PDCP_PROTO_SGL_in_place_32B(void)
9698 {
9699 	/* i can be used for running any PDCP case
9700 	 * In this case it is uplane 12-bit AES-SNOW DL encap
9701 	 */
9702 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9703 	return test_pdcp_proto_SGL(i, IN_PLACE,
9704 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9705 			RTE_CRYPTO_AUTH_OP_GENERATE,
9706 			pdcp_test_data_in[i],
9707 			pdcp_test_data_in_len[i],
9708 			pdcp_test_data_out[i],
9709 			pdcp_test_data_in_len[i]+4,
9710 			32, 0);
9711 }
9712 static int
9713 test_PDCP_PROTO_SGL_oop_32B_128B(void)
9714 {
9715 	/* i can be used for running any PDCP case
9716 	 * In this case it is uplane 18-bit NULL-NULL DL encap
9717 	 */
9718 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9719 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9720 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9721 			RTE_CRYPTO_AUTH_OP_GENERATE,
9722 			pdcp_test_data_in[i],
9723 			pdcp_test_data_in_len[i],
9724 			pdcp_test_data_out[i],
9725 			pdcp_test_data_in_len[i]+4,
9726 			32, 128);
9727 }
9728 static int
9729 test_PDCP_PROTO_SGL_oop_32B_40B(void)
9730 {
9731 	/* i can be used for running any PDCP case
9732 	 * In this case it is uplane 18-bit AES DL encap
9733 	 */
9734 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9735 			+ DOWNLINK;
9736 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9737 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9738 			RTE_CRYPTO_AUTH_OP_GENERATE,
9739 			pdcp_test_data_in[i],
9740 			pdcp_test_data_in_len[i],
9741 			pdcp_test_data_out[i],
9742 			pdcp_test_data_in_len[i],
9743 			32, 40);
9744 }
9745 static int
9746 test_PDCP_PROTO_SGL_oop_128B_32B(void)
9747 {
9748 	/* i can be used for running any PDCP case
9749 	 * In this case it is cplane 12-bit AES-ZUC DL encap
9750 	 */
9751 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9752 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9753 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9754 			RTE_CRYPTO_AUTH_OP_GENERATE,
9755 			pdcp_test_data_in[i],
9756 			pdcp_test_data_in_len[i],
9757 			pdcp_test_data_out[i],
9758 			pdcp_test_data_in_len[i]+4,
9759 			128, 32);
9760 }
9761 
9762 static int
9763 test_PDCP_SDAP_PROTO_encap_all(void)
9764 {
9765 	int i = 0, size = 0;
9766 	int err, all_err = TEST_SUCCESS;
9767 	const struct pdcp_sdap_test *cur_test;
9768 
9769 	size = RTE_DIM(list_pdcp_sdap_tests);
9770 
9771 	for (i = 0; i < size; i++) {
9772 		cur_test = &list_pdcp_sdap_tests[i];
9773 		err = test_pdcp_proto(
9774 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9775 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9776 			cur_test->in_len, cur_test->data_out,
9777 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9778 			cur_test->param.cipher_alg, cur_test->cipher_key,
9779 			cur_test->param.cipher_key_len,
9780 			cur_test->param.auth_alg,
9781 			cur_test->auth_key, cur_test->param.auth_key_len,
9782 			cur_test->bearer, cur_test->param.domain,
9783 			cur_test->packet_direction, cur_test->sn_size,
9784 			cur_test->hfn,
9785 			cur_test->hfn_threshold, SDAP_ENABLED);
9786 		if (err) {
9787 			printf("\t%d) %s: Encapsulation failed\n",
9788 					cur_test->test_idx,
9789 					cur_test->param.name);
9790 			err = TEST_FAILED;
9791 		} else {
9792 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9793 					cur_test->param.name);
9794 			err = TEST_SUCCESS;
9795 		}
9796 		all_err += err;
9797 	}
9798 
9799 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9800 
9801 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9802 }
9803 
9804 static int
9805 test_PDCP_PROTO_short_mac(void)
9806 {
9807 	int i = 0, size = 0;
9808 	int err, all_err = TEST_SUCCESS;
9809 	const struct pdcp_short_mac_test *cur_test;
9810 
9811 	size = RTE_DIM(list_pdcp_smac_tests);
9812 
9813 	for (i = 0; i < size; i++) {
9814 		cur_test = &list_pdcp_smac_tests[i];
9815 		err = test_pdcp_proto(
9816 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9817 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9818 			cur_test->in_len, cur_test->data_out,
9819 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9820 			RTE_CRYPTO_CIPHER_NULL, NULL,
9821 			0, cur_test->param.auth_alg,
9822 			cur_test->auth_key, cur_test->param.auth_key_len,
9823 			0, cur_test->param.domain, 0, 0,
9824 			0, 0, 0);
9825 		if (err) {
9826 			printf("\t%d) %s: Short MAC test failed\n",
9827 					cur_test->test_idx,
9828 					cur_test->param.name);
9829 			err = TEST_FAILED;
9830 		} else {
9831 			printf("\t%d) %s: Short MAC test PASS\n",
9832 					cur_test->test_idx,
9833 					cur_test->param.name);
9834 			rte_hexdump(stdout, "MAC I",
9835 				    cur_test->data_out + cur_test->in_len + 2,
9836 				    2);
9837 			err = TEST_SUCCESS;
9838 		}
9839 		all_err += err;
9840 	}
9841 
9842 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9843 
9844 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9845 
9846 }
9847 
9848 static int
9849 test_PDCP_SDAP_PROTO_decap_all(void)
9850 {
9851 	int i = 0, size = 0;
9852 	int err, all_err = TEST_SUCCESS;
9853 	const struct pdcp_sdap_test *cur_test;
9854 
9855 	size = RTE_DIM(list_pdcp_sdap_tests);
9856 
9857 	for (i = 0; i < size; i++) {
9858 		cur_test = &list_pdcp_sdap_tests[i];
9859 		err = test_pdcp_proto(
9860 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9861 			RTE_CRYPTO_AUTH_OP_VERIFY,
9862 			cur_test->data_out,
9863 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9864 			cur_test->data_in, cur_test->in_len,
9865 			cur_test->param.cipher_alg,
9866 			cur_test->cipher_key, cur_test->param.cipher_key_len,
9867 			cur_test->param.auth_alg, cur_test->auth_key,
9868 			cur_test->param.auth_key_len, cur_test->bearer,
9869 			cur_test->param.domain, cur_test->packet_direction,
9870 			cur_test->sn_size, cur_test->hfn,
9871 			cur_test->hfn_threshold, SDAP_ENABLED);
9872 		if (err) {
9873 			printf("\t%d) %s: Decapsulation failed\n",
9874 					cur_test->test_idx,
9875 					cur_test->param.name);
9876 			err = TEST_FAILED;
9877 		} else {
9878 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9879 					cur_test->param.name);
9880 			err = TEST_SUCCESS;
9881 		}
9882 		all_err += err;
9883 	}
9884 
9885 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9886 
9887 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9888 }
9889 
9890 static inline void
9891 ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
9892 {
9893 }
9894 
9895 static inline void
9896 ext_mbuf_memzone_free(int nb_segs)
9897 {
9898 	int i;
9899 
9900 	for (i = 0; i <= nb_segs; i++) {
9901 		char mz_name[RTE_MEMZONE_NAMESIZE];
9902 		const struct rte_memzone *memzone;
9903 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9904 		memzone = rte_memzone_lookup(mz_name);
9905 		if (memzone != NULL) {
9906 			rte_memzone_free(memzone);
9907 			memzone = NULL;
9908 		}
9909 	}
9910 }
9911 
9912 static inline struct rte_mbuf *
9913 ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
9914 		int nb_segs, const void *input_text)
9915 {
9916 	struct rte_mbuf *m = NULL, *mbuf = NULL;
9917 	size_t data_off = 0;
9918 	uint8_t *dst;
9919 	int i, size;
9920 	int t_len;
9921 
9922 	if (pkt_len < 1) {
9923 		printf("Packet size must be 1 or more (is %d)\n", pkt_len);
9924 		return NULL;
9925 	}
9926 
9927 	if (nb_segs < 1) {
9928 		printf("Number of segments must be 1 or more (is %d)\n",
9929 				nb_segs);
9930 		return NULL;
9931 	}
9932 
9933 	t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
9934 	size = pkt_len;
9935 
9936 	/* Create chained mbuf_src with external buffer */
9937 	for (i = 0; size > 0; i++) {
9938 		struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
9939 		uint16_t data_len = RTE_MIN(size, t_len);
9940 		char mz_name[RTE_MEMZONE_NAMESIZE];
9941 		const struct rte_memzone *memzone;
9942 		void *ext_buf_addr = NULL;
9943 		rte_iova_t buf_iova;
9944 		bool freed = false;
9945 		uint16_t buf_len;
9946 
9947 		buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
9948 			sizeof(struct rte_mbuf_ext_shared_info), 8);
9949 
9950 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
9951 		memzone = rte_memzone_lookup(mz_name);
9952 		if (memzone != NULL && memzone->len != buf_len) {
9953 			rte_memzone_free(memzone);
9954 			memzone = NULL;
9955 		}
9956 		if (memzone == NULL) {
9957 			memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
9958 				RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
9959 			if (memzone == NULL) {
9960 				printf("Can't allocate memory zone %s\n", mz_name);
9961 				return NULL;
9962 			}
9963 		}
9964 
9965 		ext_buf_addr = memzone->addr;
9966 		memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
9967 
9968 		/* Create buffer to hold rte_mbuf header */
9969 		m = rte_pktmbuf_alloc(mbuf_pool);
9970 		if (i == 0)
9971 			mbuf = m;
9972 
9973 		if (m == NULL) {
9974 			printf("Cannot create segment for source mbuf");
9975 			goto fail;
9976 		}
9977 
9978 		/* Save shared data (like callback function) in external buffer's end */
9979 		ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
9980 			ext_mbuf_callback_fn_free, &freed);
9981 		if (ret_shinfo == NULL) {
9982 			printf("Shared mem initialization failed!\n");
9983 			goto fail;
9984 		}
9985 
9986 		buf_iova = rte_mem_virt2iova(ext_buf_addr);
9987 
9988 		/* Attach external buffer to mbuf */
9989 		rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
9990 			ret_shinfo);
9991 		if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
9992 			printf("External buffer is not attached to mbuf\n");
9993 			goto fail;
9994 		}
9995 
9996 		dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
9997 		if (dst == NULL) {
9998 			printf("Cannot append %d bytes to the mbuf\n", data_len);
9999 			goto fail;
10000 		}
10001 
10002 		if (mbuf != m)
10003 			rte_pktmbuf_chain(mbuf, m);
10004 
10005 		size -= data_len;
10006 		data_off += data_len;
10007 	}
10008 
10009 	return mbuf;
10010 
10011 fail:
10012 	rte_pktmbuf_free(mbuf);
10013 	ext_mbuf_memzone_free(nb_segs);
10014 	return NULL;
10015 }
10016 
10017 static int
10018 test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10019 			       struct crypto_unittest_params *ut_params,
10020 			       struct rte_security_ipsec_xform *ipsec_xform,
10021 			       const struct ipsec_test_data *td,
10022 			       const struct ipsec_test_flags *flags,
10023 			       int pkt_num)
10024 {
10025 	uint8_t dev_id = ts_params->valid_devs[0];
10026 	enum rte_security_ipsec_sa_direction dir;
10027 	int ret;
10028 
10029 	dir = ipsec_xform->direction;
10030 
10031 	/* Generate crypto op data structure */
10032 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10033 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10034 	if (!ut_params->op) {
10035 		printf("Could not allocate crypto op");
10036 		return TEST_FAILED;
10037 	}
10038 
10039 	/* Attach session to operation */
10040 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10041 
10042 	/* Set crypto operation mbufs */
10043 	ut_params->op->sym->m_src = ut_params->ibuf;
10044 	ut_params->op->sym->m_dst = NULL;
10045 
10046 	/* Copy IV in crypto operation when IV generation is disabled */
10047 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10048 	    ipsec_xform->options.iv_gen_disable == 1) {
10049 		uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10050 							uint8_t *,
10051 							IV_OFFSET);
10052 		int len;
10053 
10054 		if (td->aead)
10055 			len = td->xform.aead.aead.iv.length;
10056 		else if (td->aes_gmac)
10057 			len = td->xform.chain.auth.auth.iv.length;
10058 		else
10059 			len = td->xform.chain.cipher.cipher.iv.length;
10060 
10061 		memcpy(iv, td->iv.data, len);
10062 	}
10063 
10064 	/* Process crypto operation */
10065 	process_crypto_request(dev_id, ut_params->op);
10066 
10067 	ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10068 
10069 	rte_crypto_op_free(ut_params->op);
10070 	ut_params->op = NULL;
10071 
10072 	return ret;
10073 }
10074 
10075 static int
10076 test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10077 			  struct crypto_unittest_params *ut_params,
10078 			  void *ctx)
10079 {
10080 	uint64_t timeout, userdata;
10081 	struct rte_ether_hdr *hdr;
10082 	struct rte_mbuf *m;
10083 	void **sec_sess;
10084 	int ret;
10085 
10086 	RTE_SET_USED(ts_params);
10087 
10088 	hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10089 	hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10090 
10091 	ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10092 	ut_params->ibuf->port = 0;
10093 
10094 	sec_sess = &ut_params->sec_session;
10095 	ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10096 
10097 	if (ret != 1)
10098 		return TEST_FAILED;
10099 
10100 	ut_params->ibuf = NULL;
10101 
10102 	/* Add a timeout for 1 s */
10103 	timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10104 
10105 	do {
10106 		/* Get packet from port 0, queue 0 */
10107 		ret = rte_eth_rx_burst(0, 0, &m, 1);
10108 	} while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10109 
10110 	if (ret == 0) {
10111 		printf("Could not receive packets from ethdev\n");
10112 		return TEST_FAILED;
10113 	}
10114 
10115 	if (m == NULL) {
10116 		printf("Received mbuf is NULL\n");
10117 		return TEST_FAILED;
10118 	}
10119 
10120 	ut_params->ibuf = m;
10121 
10122 	if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10123 		printf("Received packet is not Rx security processed\n");
10124 		return TEST_FAILED;
10125 	}
10126 
10127 	if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10128 		printf("Received packet has failed Rx security processing\n");
10129 		return TEST_FAILED;
10130 	}
10131 
10132 	/*
10133 	 * 'ut_params' is set as userdata. Verify that the field is returned
10134 	 * correctly.
10135 	 */
10136 	userdata = *(uint64_t *)rte_security_dynfield(m);
10137 	if (userdata != (uint64_t)ut_params) {
10138 		printf("Userdata retrieved not matching expected\n");
10139 		return TEST_FAILED;
10140 	}
10141 
10142 	/* Trim L2 header */
10143 	rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10144 
10145 	return TEST_SUCCESS;
10146 }
10147 
10148 static int
10149 test_ipsec_proto_process(const struct ipsec_test_data td[],
10150 			 struct ipsec_test_data res_d[],
10151 			 int nb_td,
10152 			 bool silent,
10153 			 const struct ipsec_test_flags *flags)
10154 {
10155 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10156 				0x0000, 0x001a};
10157 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10158 				0xe82c, 0x4887};
10159 	const struct rte_ipv4_hdr *ipv4 =
10160 			(const struct rte_ipv4_hdr *)td[0].output_text.data;
10161 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10162 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10163 	struct crypto_unittest_params *ut_params = &unittest_params;
10164 	struct rte_security_capability_idx sec_cap_idx;
10165 	const struct rte_security_capability *sec_cap;
10166 	struct rte_security_ipsec_xform ipsec_xform;
10167 	uint8_t dev_id = ts_params->valid_devs[0];
10168 	enum rte_security_ipsec_sa_direction dir;
10169 	struct ipsec_test_data *res_d_tmp = NULL;
10170 	uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10171 	int salt_len, i, ret = TEST_SUCCESS;
10172 	void *ctx;
10173 	uint32_t src, dst;
10174 	uint32_t verify;
10175 
10176 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10177 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10178 
10179 	/* Use first test data to create session */
10180 
10181 	/* Copy IPsec xform */
10182 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10183 
10184 	dir = ipsec_xform.direction;
10185 	verify = flags->tunnel_hdr_verify;
10186 
10187 	memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10188 	memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10189 
10190 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10191 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10192 			src += 1;
10193 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10194 			dst += 1;
10195 	}
10196 
10197 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10198 		if (td->ipsec_xform.tunnel.type ==
10199 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10200 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10201 			       sizeof(src));
10202 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10203 			       sizeof(dst));
10204 
10205 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10206 				ipsec_xform.tunnel.ipv4.df = 0;
10207 
10208 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10209 				ipsec_xform.tunnel.ipv4.df = 1;
10210 
10211 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10212 				ipsec_xform.tunnel.ipv4.dscp = 0;
10213 
10214 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10215 				ipsec_xform.tunnel.ipv4.dscp =
10216 						TEST_IPSEC_DSCP_VAL;
10217 
10218 		} else {
10219 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10220 				ipsec_xform.tunnel.ipv6.dscp = 0;
10221 
10222 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10223 				ipsec_xform.tunnel.ipv6.dscp =
10224 						TEST_IPSEC_DSCP_VAL;
10225 
10226 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10227 			       sizeof(v6_src));
10228 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10229 			       sizeof(v6_dst));
10230 		}
10231 	}
10232 
10233 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
10234 
10235 	sec_cap_idx.action = ut_params->type;
10236 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10237 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10238 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10239 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10240 
10241 	if (flags->udp_encap)
10242 		ipsec_xform.options.udp_encap = 1;
10243 
10244 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10245 	if (sec_cap == NULL)
10246 		return TEST_SKIPPED;
10247 
10248 	/* Copy cipher session parameters */
10249 	if (td[0].aead) {
10250 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10251 		       sizeof(ut_params->aead_xform));
10252 		ut_params->aead_xform.aead.key.data = td[0].key.data;
10253 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10254 
10255 		/* Verify crypto capabilities */
10256 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10257 			if (!silent)
10258 				RTE_LOG(INFO, USER1,
10259 					"Crypto capabilities not supported\n");
10260 			return TEST_SKIPPED;
10261 		}
10262 	} else if (td[0].auth_only) {
10263 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10264 		       sizeof(ut_params->auth_xform));
10265 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10266 
10267 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10268 			if (!silent)
10269 				RTE_LOG(INFO, USER1,
10270 					"Auth crypto capabilities not supported\n");
10271 			return TEST_SKIPPED;
10272 		}
10273 	} else {
10274 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10275 		       sizeof(ut_params->cipher_xform));
10276 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10277 		       sizeof(ut_params->auth_xform));
10278 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10279 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10280 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10281 
10282 		/* Verify crypto capabilities */
10283 
10284 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10285 			if (!silent)
10286 				RTE_LOG(INFO, USER1,
10287 					"Cipher crypto capabilities not supported\n");
10288 			return TEST_SKIPPED;
10289 		}
10290 
10291 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10292 			if (!silent)
10293 				RTE_LOG(INFO, USER1,
10294 					"Auth crypto capabilities not supported\n");
10295 			return TEST_SKIPPED;
10296 		}
10297 	}
10298 
10299 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10300 		return TEST_SKIPPED;
10301 
10302 	struct rte_security_session_conf sess_conf = {
10303 		.action_type = ut_params->type,
10304 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10305 	};
10306 
10307 	if (td[0].aead || td[0].aes_gmac) {
10308 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10309 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10310 	}
10311 
10312 	if (td[0].aead) {
10313 		sess_conf.ipsec = ipsec_xform;
10314 		sess_conf.crypto_xform = &ut_params->aead_xform;
10315 	} else if (td[0].auth_only) {
10316 		sess_conf.ipsec = ipsec_xform;
10317 		sess_conf.crypto_xform = &ut_params->auth_xform;
10318 	} else {
10319 		sess_conf.ipsec = ipsec_xform;
10320 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10321 			sess_conf.crypto_xform = &ut_params->cipher_xform;
10322 			ut_params->cipher_xform.next = &ut_params->auth_xform;
10323 		} else {
10324 			sess_conf.crypto_xform = &ut_params->auth_xform;
10325 			ut_params->auth_xform.next = &ut_params->cipher_xform;
10326 		}
10327 	}
10328 
10329 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10330 		sess_conf.userdata = ut_params;
10331 
10332 	/* Create security session */
10333 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10334 					ts_params->session_mpool);
10335 
10336 	if (ut_params->sec_session == NULL)
10337 		return TEST_SKIPPED;
10338 
10339 	for (i = 0; i < nb_td; i++) {
10340 		if (flags->antireplay &&
10341 		    (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10342 			sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10343 			ret = rte_security_session_update(ctx,
10344 				ut_params->sec_session, &sess_conf);
10345 			if (ret) {
10346 				printf("Could not update sequence number in "
10347 				       "session\n");
10348 				return TEST_SKIPPED;
10349 			}
10350 		}
10351 
10352 		/* Copy test data before modification */
10353 		memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10354 		if (test_ipsec_pkt_update(input_text, flags)) {
10355 			ret = TEST_FAILED;
10356 			goto mbuf_free;
10357 		}
10358 
10359 		/* Setup source mbuf payload */
10360 		if (flags->use_ext_mbuf) {
10361 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10362 					td[i].input_text.len, nb_segs, input_text);
10363 		} else {
10364 			ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10365 					td[i].input_text.len, nb_segs, 0);
10366 			pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10367 		}
10368 
10369 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10370 			ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10371 							ctx);
10372 		else
10373 			ret = test_ipsec_proto_crypto_op_enq(ts_params,
10374 							     ut_params,
10375 							     &ipsec_xform,
10376 							     &td[i], flags,
10377 							     i + 1);
10378 
10379 		if (ret != TEST_SUCCESS)
10380 			goto mbuf_free;
10381 
10382 		if (res_d != NULL)
10383 			res_d_tmp = &res_d[i];
10384 
10385 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10386 					      res_d_tmp, silent, flags);
10387 		if (ret != TEST_SUCCESS)
10388 			goto mbuf_free;
10389 
10390 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10391 					      flags, dir);
10392 		if (ret != TEST_SUCCESS)
10393 			goto mbuf_free;
10394 
10395 		rte_pktmbuf_free(ut_params->ibuf);
10396 		ut_params->ibuf = NULL;
10397 	}
10398 
10399 mbuf_free:
10400 	if (flags->use_ext_mbuf)
10401 		ext_mbuf_memzone_free(nb_segs);
10402 
10403 	rte_pktmbuf_free(ut_params->ibuf);
10404 	ut_params->ibuf = NULL;
10405 
10406 	if (ut_params->sec_session)
10407 		rte_security_session_destroy(ctx, ut_params->sec_session);
10408 	ut_params->sec_session = NULL;
10409 
10410 	return ret;
10411 }
10412 
10413 static int
10414 test_ipsec_proto_known_vec(const void *test_data)
10415 {
10416 	struct ipsec_test_data td_outb;
10417 	struct ipsec_test_flags flags;
10418 
10419 	memset(&flags, 0, sizeof(flags));
10420 
10421 	memcpy(&td_outb, test_data, sizeof(td_outb));
10422 
10423 	if (td_outb.aes_gmac || td_outb.aead ||
10424 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10425 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10426 		/* Disable IV gen to be able to test with known vectors */
10427 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10428 	}
10429 
10430 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10431 }
10432 
10433 static int
10434 test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10435 {
10436 	struct ipsec_test_data td_outb;
10437 	struct ipsec_test_flags flags;
10438 
10439 	memset(&flags, 0, sizeof(flags));
10440 	flags.use_ext_mbuf = true;
10441 
10442 	memcpy(&td_outb, test_data, sizeof(td_outb));
10443 
10444 	if (td_outb.aes_gmac || td_outb.aead ||
10445 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10446 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10447 		/* Disable IV gen to be able to test with known vectors */
10448 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10449 	}
10450 
10451 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10452 }
10453 
10454 static int
10455 test_ipsec_proto_known_vec_inb(const void *test_data)
10456 {
10457 	const struct ipsec_test_data *td = test_data;
10458 	struct ipsec_test_flags flags;
10459 	struct ipsec_test_data td_inb;
10460 
10461 	memset(&flags, 0, sizeof(flags));
10462 
10463 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10464 		test_ipsec_td_in_from_out(td, &td_inb);
10465 	else
10466 		memcpy(&td_inb, td, sizeof(td_inb));
10467 
10468 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10469 }
10470 
10471 static int
10472 test_ipsec_proto_known_vec_fragmented(const void *test_data)
10473 {
10474 	struct ipsec_test_data td_outb;
10475 	struct ipsec_test_flags flags;
10476 
10477 	memset(&flags, 0, sizeof(flags));
10478 	flags.fragment = true;
10479 
10480 	memcpy(&td_outb, test_data, sizeof(td_outb));
10481 
10482 	/* Disable IV gen to be able to test with known vectors */
10483 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
10484 
10485 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10486 }
10487 
10488 static int
10489 test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10490 {
10491 	const struct ipsec_test_data *td = test_data;
10492 	struct ipsec_test_flags flags;
10493 	struct ipsec_test_data td_inb;
10494 
10495 	memset(&flags, 0, sizeof(flags));
10496 	flags.rx_inject = true;
10497 
10498 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10499 		test_ipsec_td_in_from_out(td, &td_inb);
10500 	else
10501 		memcpy(&td_inb, td, sizeof(td_inb));
10502 
10503 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10504 }
10505 
10506 static int
10507 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10508 {
10509 	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10510 	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10511 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10512 	int ret;
10513 
10514 	if (flags->iv_gen ||
10515 	    flags->sa_expiry_pkts_soft ||
10516 	    flags->sa_expiry_pkts_hard)
10517 		nb_pkts = IPSEC_TEST_PACKETS_MAX;
10518 
10519 	for (i = 0; i < RTE_DIM(alg_list); i++) {
10520 		test_ipsec_td_prepare(alg_list[i].param1,
10521 				      alg_list[i].param2,
10522 				      flags,
10523 				      td_outb,
10524 				      nb_pkts);
10525 
10526 		if (!td_outb->aead) {
10527 			enum rte_crypto_cipher_algorithm cipher_alg;
10528 			enum rte_crypto_auth_algorithm auth_alg;
10529 
10530 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10531 			auth_alg = td_outb->xform.chain.auth.auth.algo;
10532 
10533 			if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10534 				continue;
10535 
10536 			/* ICV is not applicable for NULL auth */
10537 			if (flags->icv_corrupt &&
10538 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
10539 				continue;
10540 
10541 			/* IV is not applicable for NULL cipher */
10542 			if (flags->iv_gen &&
10543 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10544 				continue;
10545 		}
10546 
10547 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10548 					       flags);
10549 		if (ret == TEST_SKIPPED)
10550 			continue;
10551 
10552 		if (ret == TEST_FAILED)
10553 			return TEST_FAILED;
10554 
10555 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10556 
10557 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10558 					       flags);
10559 		if (ret == TEST_SKIPPED)
10560 			continue;
10561 
10562 		if (ret == TEST_FAILED)
10563 			return TEST_FAILED;
10564 
10565 		if (flags->display_alg)
10566 			test_sec_alg_display(alg_list[i].param1, alg_list[i].param2);
10567 
10568 		pass_cnt++;
10569 	}
10570 
10571 	if (pass_cnt > 0)
10572 		return TEST_SUCCESS;
10573 	else
10574 		return TEST_SKIPPED;
10575 }
10576 
10577 static int
10578 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10579 {
10580 	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10581 	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10582 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10583 	int ret;
10584 
10585 	for (i = 0; i < RTE_DIM(ah_alg_list); i++) {
10586 		test_ipsec_td_prepare(ah_alg_list[i].param1,
10587 				      ah_alg_list[i].param2,
10588 				      flags,
10589 				      td_outb,
10590 				      nb_pkts);
10591 
10592 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10593 					       flags);
10594 		if (ret == TEST_SKIPPED)
10595 			continue;
10596 
10597 		if (ret == TEST_FAILED)
10598 			return TEST_FAILED;
10599 
10600 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10601 
10602 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10603 					       flags);
10604 		if (ret == TEST_SKIPPED)
10605 			continue;
10606 
10607 		if (ret == TEST_FAILED)
10608 			return TEST_FAILED;
10609 
10610 		if (flags->display_alg)
10611 			test_sec_alg_display(ah_alg_list[i].param1, ah_alg_list[i].param2);
10612 
10613 		pass_cnt++;
10614 	}
10615 
10616 	if (pass_cnt > 0)
10617 		return TEST_SUCCESS;
10618 	else
10619 		return TEST_SKIPPED;
10620 }
10621 
10622 static int
10623 test_ipsec_proto_display_list(void)
10624 {
10625 	struct ipsec_test_flags flags;
10626 
10627 	memset(&flags, 0, sizeof(flags));
10628 
10629 	flags.display_alg = true;
10630 
10631 	return test_ipsec_proto_all(&flags);
10632 }
10633 
10634 static int
10635 test_ipsec_proto_ah_tunnel_ipv4(void)
10636 {
10637 	struct ipsec_test_flags flags;
10638 
10639 	memset(&flags, 0, sizeof(flags));
10640 
10641 	flags.ah = true;
10642 	flags.display_alg = true;
10643 
10644 	return test_ipsec_ah_proto_all(&flags);
10645 }
10646 
10647 static int
10648 test_ipsec_proto_ah_transport_ipv4(void)
10649 {
10650 	struct ipsec_test_flags flags;
10651 
10652 	memset(&flags, 0, sizeof(flags));
10653 
10654 	flags.ah = true;
10655 	flags.transport = true;
10656 
10657 	return test_ipsec_ah_proto_all(&flags);
10658 }
10659 
10660 static int
10661 test_ipsec_proto_iv_gen(void)
10662 {
10663 	struct ipsec_test_flags flags;
10664 
10665 	memset(&flags, 0, sizeof(flags));
10666 
10667 	flags.iv_gen = true;
10668 
10669 	return test_ipsec_proto_all(&flags);
10670 }
10671 
10672 static int
10673 test_ipsec_proto_sa_exp_pkts_soft(void)
10674 {
10675 	struct ipsec_test_flags flags;
10676 
10677 	memset(&flags, 0, sizeof(flags));
10678 
10679 	flags.sa_expiry_pkts_soft = true;
10680 
10681 	return test_ipsec_proto_all(&flags);
10682 }
10683 
10684 static int
10685 test_ipsec_proto_sa_exp_pkts_hard(void)
10686 {
10687 	struct ipsec_test_flags flags;
10688 
10689 	memset(&flags, 0, sizeof(flags));
10690 
10691 	flags.sa_expiry_pkts_hard = true;
10692 
10693 	return test_ipsec_proto_all(&flags);
10694 }
10695 
10696 static int
10697 test_ipsec_proto_err_icv_corrupt(void)
10698 {
10699 	struct ipsec_test_flags flags;
10700 
10701 	memset(&flags, 0, sizeof(flags));
10702 
10703 	flags.icv_corrupt = true;
10704 
10705 	return test_ipsec_proto_all(&flags);
10706 }
10707 
10708 static int
10709 test_ipsec_proto_udp_encap_custom_ports(void)
10710 {
10711 	struct ipsec_test_flags flags;
10712 
10713 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10714 			RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10715 		return TEST_SKIPPED;
10716 
10717 	memset(&flags, 0, sizeof(flags));
10718 
10719 	flags.udp_encap = true;
10720 	flags.udp_encap_custom_ports = true;
10721 
10722 	return test_ipsec_proto_all(&flags);
10723 }
10724 
10725 static int
10726 test_ipsec_proto_udp_encap(void)
10727 {
10728 	struct ipsec_test_flags flags;
10729 
10730 	memset(&flags, 0, sizeof(flags));
10731 
10732 	flags.udp_encap = true;
10733 
10734 	return test_ipsec_proto_all(&flags);
10735 }
10736 
10737 static int
10738 test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10739 {
10740 	struct ipsec_test_flags flags;
10741 
10742 	memset(&flags, 0, sizeof(flags));
10743 
10744 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10745 
10746 	return test_ipsec_proto_all(&flags);
10747 }
10748 
10749 static int
10750 test_ipsec_proto_tunnel_dst_addr_verify(void)
10751 {
10752 	struct ipsec_test_flags flags;
10753 
10754 	memset(&flags, 0, sizeof(flags));
10755 
10756 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10757 
10758 	return test_ipsec_proto_all(&flags);
10759 }
10760 
10761 static int
10762 test_ipsec_proto_udp_ports_verify(void)
10763 {
10764 	struct ipsec_test_flags flags;
10765 
10766 	memset(&flags, 0, sizeof(flags));
10767 
10768 	flags.udp_encap = true;
10769 	flags.udp_ports_verify = true;
10770 
10771 	return test_ipsec_proto_all(&flags);
10772 }
10773 
10774 static int
10775 test_ipsec_proto_inner_ip_csum(void)
10776 {
10777 	struct ipsec_test_flags flags;
10778 
10779 	memset(&flags, 0, sizeof(flags));
10780 
10781 	flags.ip_csum = true;
10782 
10783 	return test_ipsec_proto_all(&flags);
10784 }
10785 
10786 static int
10787 test_ipsec_proto_inner_l4_csum(void)
10788 {
10789 	struct ipsec_test_flags flags;
10790 
10791 	memset(&flags, 0, sizeof(flags));
10792 
10793 	flags.l4_csum = true;
10794 
10795 	return test_ipsec_proto_all(&flags);
10796 }
10797 
10798 static int
10799 test_ipsec_proto_tunnel_v4_in_v4(void)
10800 {
10801 	struct ipsec_test_flags flags;
10802 
10803 	memset(&flags, 0, sizeof(flags));
10804 
10805 	flags.ipv6 = false;
10806 	flags.tunnel_ipv6 = false;
10807 
10808 	return test_ipsec_proto_all(&flags);
10809 }
10810 
10811 static int
10812 test_ipsec_proto_tunnel_v6_in_v6(void)
10813 {
10814 	struct ipsec_test_flags flags;
10815 
10816 	memset(&flags, 0, sizeof(flags));
10817 
10818 	flags.ipv6 = true;
10819 	flags.tunnel_ipv6 = true;
10820 
10821 	return test_ipsec_proto_all(&flags);
10822 }
10823 
10824 static int
10825 test_ipsec_proto_tunnel_v4_in_v6(void)
10826 {
10827 	struct ipsec_test_flags flags;
10828 
10829 	memset(&flags, 0, sizeof(flags));
10830 
10831 	flags.ipv6 = false;
10832 	flags.tunnel_ipv6 = true;
10833 
10834 	return test_ipsec_proto_all(&flags);
10835 }
10836 
10837 static int
10838 test_ipsec_proto_tunnel_v6_in_v4(void)
10839 {
10840 	struct ipsec_test_flags flags;
10841 
10842 	memset(&flags, 0, sizeof(flags));
10843 
10844 	flags.ipv6 = true;
10845 	flags.tunnel_ipv6 = false;
10846 
10847 	return test_ipsec_proto_all(&flags);
10848 }
10849 
10850 static int
10851 test_ipsec_proto_transport_v4(void)
10852 {
10853 	struct ipsec_test_flags flags;
10854 
10855 	memset(&flags, 0, sizeof(flags));
10856 
10857 	flags.ipv6 = false;
10858 	flags.transport = true;
10859 
10860 	return test_ipsec_proto_all(&flags);
10861 }
10862 
10863 static int
10864 test_ipsec_proto_transport_l4_csum(void)
10865 {
10866 	struct ipsec_test_flags flags = {
10867 		.l4_csum = true,
10868 		.transport = true,
10869 	};
10870 
10871 	return test_ipsec_proto_all(&flags);
10872 }
10873 
10874 static int
10875 test_ipsec_proto_stats(void)
10876 {
10877 	struct ipsec_test_flags flags;
10878 
10879 	memset(&flags, 0, sizeof(flags));
10880 
10881 	flags.stats_success = true;
10882 
10883 	return test_ipsec_proto_all(&flags);
10884 }
10885 
10886 static int
10887 test_ipsec_proto_pkt_fragment(void)
10888 {
10889 	struct ipsec_test_flags flags;
10890 
10891 	memset(&flags, 0, sizeof(flags));
10892 
10893 	flags.fragment = true;
10894 
10895 	return test_ipsec_proto_all(&flags);
10896 
10897 }
10898 
10899 static int
10900 test_ipsec_proto_copy_df_inner_0(void)
10901 {
10902 	struct ipsec_test_flags flags;
10903 
10904 	memset(&flags, 0, sizeof(flags));
10905 
10906 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10907 
10908 	return test_ipsec_proto_all(&flags);
10909 }
10910 
10911 static int
10912 test_ipsec_proto_copy_df_inner_1(void)
10913 {
10914 	struct ipsec_test_flags flags;
10915 
10916 	memset(&flags, 0, sizeof(flags));
10917 
10918 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10919 
10920 	return test_ipsec_proto_all(&flags);
10921 }
10922 
10923 static int
10924 test_ipsec_proto_set_df_0_inner_1(void)
10925 {
10926 	struct ipsec_test_flags flags;
10927 
10928 	memset(&flags, 0, sizeof(flags));
10929 
10930 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10931 
10932 	return test_ipsec_proto_all(&flags);
10933 }
10934 
10935 static int
10936 test_ipsec_proto_set_df_1_inner_0(void)
10937 {
10938 	struct ipsec_test_flags flags;
10939 
10940 	memset(&flags, 0, sizeof(flags));
10941 
10942 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10943 
10944 	return test_ipsec_proto_all(&flags);
10945 }
10946 
10947 static int
10948 test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10949 {
10950 	struct ipsec_test_flags flags;
10951 
10952 	memset(&flags, 0, sizeof(flags));
10953 
10954 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10955 
10956 	return test_ipsec_proto_all(&flags);
10957 }
10958 
10959 static int
10960 test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
10961 {
10962 	struct ipsec_test_flags flags;
10963 
10964 	memset(&flags, 0, sizeof(flags));
10965 
10966 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10967 
10968 	return test_ipsec_proto_all(&flags);
10969 }
10970 
10971 static int
10972 test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
10973 {
10974 	struct ipsec_test_flags flags;
10975 
10976 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10977 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10978 		return TEST_SKIPPED;
10979 
10980 	memset(&flags, 0, sizeof(flags));
10981 
10982 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10983 
10984 	return test_ipsec_proto_all(&flags);
10985 }
10986 
10987 static int
10988 test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
10989 {
10990 	struct ipsec_test_flags flags;
10991 
10992 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10993 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10994 		return TEST_SKIPPED;
10995 
10996 	memset(&flags, 0, sizeof(flags));
10997 
10998 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
10999 
11000 	return test_ipsec_proto_all(&flags);
11001 }
11002 
11003 static int
11004 test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11005 {
11006 	struct ipsec_test_flags flags;
11007 
11008 	memset(&flags, 0, sizeof(flags));
11009 
11010 	flags.ipv6 = true;
11011 	flags.tunnel_ipv6 = true;
11012 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11013 
11014 	return test_ipsec_proto_all(&flags);
11015 }
11016 
11017 static int
11018 test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11019 {
11020 	struct ipsec_test_flags flags;
11021 
11022 	memset(&flags, 0, sizeof(flags));
11023 
11024 	flags.ipv6 = true;
11025 	flags.tunnel_ipv6 = true;
11026 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11027 
11028 	return test_ipsec_proto_all(&flags);
11029 }
11030 
11031 static int
11032 test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11033 {
11034 	struct ipsec_test_flags flags;
11035 
11036 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11037 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11038 		return TEST_SKIPPED;
11039 
11040 	memset(&flags, 0, sizeof(flags));
11041 
11042 	flags.ipv6 = true;
11043 	flags.tunnel_ipv6 = true;
11044 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11045 
11046 	return test_ipsec_proto_all(&flags);
11047 }
11048 
11049 static int
11050 test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11051 {
11052 	struct ipsec_test_flags flags;
11053 
11054 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11055 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11056 		return TEST_SKIPPED;
11057 
11058 	memset(&flags, 0, sizeof(flags));
11059 
11060 	flags.ipv6 = true;
11061 	flags.tunnel_ipv6 = true;
11062 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11063 
11064 	return test_ipsec_proto_all(&flags);
11065 }
11066 
11067 static int
11068 test_ipsec_proto_sgl(void)
11069 {
11070 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11071 	struct rte_cryptodev_info dev_info;
11072 
11073 	struct ipsec_test_flags flags = {
11074 		.nb_segs_in_mbuf = 5
11075 	};
11076 
11077 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11078 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11079 		printf("Device doesn't support in-place scatter-gather. "
11080 				"Test Skipped.\n");
11081 		return TEST_SKIPPED;
11082 	}
11083 
11084 	return test_ipsec_proto_all(&flags);
11085 }
11086 
11087 static int
11088 test_ipsec_proto_sgl_ext_mbuf(void)
11089 {
11090 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11091 	struct rte_cryptodev_info dev_info;
11092 
11093 	struct ipsec_test_flags flags = {
11094 		.nb_segs_in_mbuf = 5,
11095 		.use_ext_mbuf = 1
11096 	};
11097 
11098 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11099 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11100 		printf("Device doesn't support in-place scatter-gather. "
11101 				"Test Skipped.\n");
11102 		return TEST_SKIPPED;
11103 	}
11104 
11105 	return test_ipsec_proto_all(&flags);
11106 }
11107 
11108 static int
11109 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11110 		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11111 		      uint64_t winsz)
11112 {
11113 	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
11114 	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
11115 	struct ipsec_test_flags flags;
11116 	uint32_t i = 0, ret = 0;
11117 
11118 	if (nb_pkts == 0)
11119 		return TEST_FAILED;
11120 
11121 	memset(&flags, 0, sizeof(flags));
11122 	flags.antireplay = true;
11123 
11124 	for (i = 0; i < nb_pkts; i++) {
11125 		memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11126 		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11127 		td_outb[i].ipsec_xform.replay_win_sz = winsz;
11128 		td_outb[i].ipsec_xform.options.esn = esn_en;
11129 	}
11130 
11131 	for (i = 0; i < nb_pkts; i++)
11132 		td_outb[i].ipsec_xform.esn.value = esn[i];
11133 
11134 	ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11135 				       &flags);
11136 	if (ret != TEST_SUCCESS)
11137 		return ret;
11138 
11139 	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11140 
11141 	for (i = 0; i < nb_pkts; i++) {
11142 		td_inb[i].ipsec_xform.options.esn = esn_en;
11143 		/* Set antireplay flag for packets to be dropped */
11144 		td_inb[i].ar_packet = replayed_pkt[i];
11145 	}
11146 
11147 	ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11148 				       &flags);
11149 
11150 	return ret;
11151 }
11152 
11153 static int
11154 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11155 {
11156 
11157 	uint32_t nb_pkts = 5;
11158 	bool replayed_pkt[5];
11159 	uint64_t esn[5];
11160 
11161 	/* 1. Advance the TOP of the window to WS * 2 */
11162 	esn[0] = winsz * 2;
11163 	/* 2. Test sequence number within the new window(WS + 1) */
11164 	esn[1] = winsz + 1;
11165 	/* 3. Test sequence number less than the window BOTTOM */
11166 	esn[2] = winsz;
11167 	/* 4. Test sequence number in the middle of the window */
11168 	esn[3] = winsz + (winsz / 2);
11169 	/* 5. Test replay of the packet in the middle of the window */
11170 	esn[4] = winsz + (winsz / 2);
11171 
11172 	replayed_pkt[0] = false;
11173 	replayed_pkt[1] = false;
11174 	replayed_pkt[2] = true;
11175 	replayed_pkt[3] = false;
11176 	replayed_pkt[4] = true;
11177 
11178 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11179 				     false, winsz);
11180 }
11181 
11182 static int
11183 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11184 {
11185 	return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11186 }
11187 
11188 static int
11189 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11190 {
11191 	return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11192 }
11193 
11194 static int
11195 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11196 {
11197 	return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11198 }
11199 
11200 static int
11201 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11202 {
11203 
11204 	uint32_t nb_pkts = 7;
11205 	bool replayed_pkt[7];
11206 	uint64_t esn[7];
11207 
11208 	/* Set the initial sequence number */
11209 	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11210 	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11211 	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11212 	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11213 	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11214 	/* 3. Test with sequence number within window (1<<32 - 1) */
11215 	esn[3] = (uint64_t)((1ULL << 32) - 1);
11216 	/* 4. Test with sequence number within window (1<<32 - 1) */
11217 	esn[4] = (uint64_t)(1ULL << 32);
11218 	/* 5. Test with duplicate sequence number within
11219 	 * new window (1<<32 - 1)
11220 	 */
11221 	esn[5] = (uint64_t)((1ULL << 32) - 1);
11222 	/* 6. Test with duplicate sequence number within new window (1<<32) */
11223 	esn[6] = (uint64_t)(1ULL << 32);
11224 
11225 	replayed_pkt[0] = false;
11226 	replayed_pkt[1] = false;
11227 	replayed_pkt[2] = false;
11228 	replayed_pkt[3] = false;
11229 	replayed_pkt[4] = false;
11230 	replayed_pkt[5] = true;
11231 	replayed_pkt[6] = true;
11232 
11233 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11234 				     true, winsz);
11235 }
11236 
11237 static int
11238 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11239 {
11240 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11241 }
11242 
11243 static int
11244 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11245 {
11246 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11247 }
11248 
11249 static int
11250 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11251 {
11252 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11253 }
11254 
11255 static int
11256 test_PDCP_PROTO_all(void)
11257 {
11258 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11259 	struct crypto_unittest_params *ut_params = &unittest_params;
11260 	struct rte_cryptodev_info dev_info;
11261 	int status;
11262 
11263 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11264 	uint64_t feat_flags = dev_info.feature_flags;
11265 
11266 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11267 		return TEST_SKIPPED;
11268 
11269 	/* Set action type */
11270 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11271 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11272 		gbl_action_type;
11273 
11274 	if (security_proto_supported(ut_params->type,
11275 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
11276 		return TEST_SKIPPED;
11277 
11278 	status = test_PDCP_PROTO_cplane_encap_all();
11279 	status += test_PDCP_PROTO_cplane_decap_all();
11280 	status += test_PDCP_PROTO_uplane_encap_all();
11281 	status += test_PDCP_PROTO_uplane_decap_all();
11282 	status += test_PDCP_PROTO_SGL_in_place_32B();
11283 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
11284 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
11285 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
11286 	status += test_PDCP_SDAP_PROTO_encap_all();
11287 	status += test_PDCP_SDAP_PROTO_decap_all();
11288 	status += test_PDCP_PROTO_short_mac();
11289 
11290 	if (status)
11291 		return TEST_FAILED;
11292 	else
11293 		return TEST_SUCCESS;
11294 }
11295 
11296 static int
11297 test_ipsec_proto_ipv4_ttl_decrement(void)
11298 {
11299 	struct ipsec_test_flags flags = {
11300 		.dec_ttl_or_hop_limit = true
11301 	};
11302 
11303 	return test_ipsec_proto_all(&flags);
11304 }
11305 
11306 static int
11307 test_ipsec_proto_ipv6_hop_limit_decrement(void)
11308 {
11309 	struct ipsec_test_flags flags = {
11310 		.ipv6 = true,
11311 		.dec_ttl_or_hop_limit = true
11312 	};
11313 
11314 	return test_ipsec_proto_all(&flags);
11315 }
11316 
11317 static int
11318 test_docsis_proto_uplink(const void *data)
11319 {
11320 	const struct docsis_test_data *d_td = data;
11321 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11322 	struct crypto_unittest_params *ut_params = &unittest_params;
11323 	uint8_t *plaintext = NULL;
11324 	uint8_t *ciphertext = NULL;
11325 	uint8_t *iv_ptr;
11326 	int32_t cipher_len, crc_len;
11327 	uint32_t crc_data_len;
11328 	int ret = TEST_SUCCESS;
11329 
11330 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11331 
11332 	/* Verify the capabilities */
11333 	struct rte_security_capability_idx sec_cap_idx;
11334 	const struct rte_security_capability *sec_cap;
11335 	const struct rte_cryptodev_capabilities *crypto_cap;
11336 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11337 	int j = 0;
11338 
11339 	/* Set action type */
11340 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11341 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11342 		gbl_action_type;
11343 
11344 	if (security_proto_supported(ut_params->type,
11345 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11346 		return TEST_SKIPPED;
11347 
11348 	sec_cap_idx.action = ut_params->type;
11349 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11350 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11351 
11352 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11353 	if (sec_cap == NULL)
11354 		return TEST_SKIPPED;
11355 
11356 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11357 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11358 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11359 				crypto_cap->sym.xform_type ==
11360 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11361 				crypto_cap->sym.cipher.algo ==
11362 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11363 			sym_cap = &crypto_cap->sym;
11364 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11365 						d_td->key.len,
11366 						d_td->iv.len) == 0)
11367 				break;
11368 		}
11369 	}
11370 
11371 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11372 		return TEST_SKIPPED;
11373 
11374 	/* Setup source mbuf payload */
11375 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11376 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11377 			rte_pktmbuf_tailroom(ut_params->ibuf));
11378 
11379 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11380 			d_td->ciphertext.len);
11381 
11382 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11383 
11384 	/* Setup cipher session parameters */
11385 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11386 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11387 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11388 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11389 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11390 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11391 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11392 	ut_params->cipher_xform.next = NULL;
11393 
11394 	/* Setup DOCSIS session parameters */
11395 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11396 
11397 	struct rte_security_session_conf sess_conf = {
11398 		.action_type = ut_params->type,
11399 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11400 		.docsis = ut_params->docsis_xform,
11401 		.crypto_xform = &ut_params->cipher_xform,
11402 	};
11403 
11404 	/* Create security session */
11405 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11406 					ts_params->session_mpool);
11407 
11408 	if (!ut_params->sec_session) {
11409 		printf("Test function %s line %u: failed to allocate session\n",
11410 			__func__, __LINE__);
11411 		ret = TEST_FAILED;
11412 		goto on_err;
11413 	}
11414 
11415 	/* Generate crypto op data structure */
11416 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11417 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11418 	if (!ut_params->op) {
11419 		printf("Test function %s line %u: failed to allocate symmetric "
11420 			"crypto operation\n", __func__, __LINE__);
11421 		ret = TEST_FAILED;
11422 		goto on_err;
11423 	}
11424 
11425 	/* Setup CRC operation parameters */
11426 	crc_len = d_td->ciphertext.no_crc == false ?
11427 			(d_td->ciphertext.len -
11428 				d_td->ciphertext.crc_offset -
11429 				RTE_ETHER_CRC_LEN) :
11430 			0;
11431 	crc_len = crc_len > 0 ? crc_len : 0;
11432 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11433 	ut_params->op->sym->auth.data.length = crc_len;
11434 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11435 
11436 	/* Setup cipher operation parameters */
11437 	cipher_len = d_td->ciphertext.no_cipher == false ?
11438 			(d_td->ciphertext.len -
11439 				d_td->ciphertext.cipher_offset) :
11440 			0;
11441 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11442 	ut_params->op->sym->cipher.data.length = cipher_len;
11443 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11444 
11445 	/* Setup cipher IV */
11446 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11447 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11448 
11449 	/* Attach session to operation */
11450 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11451 
11452 	/* Set crypto operation mbufs */
11453 	ut_params->op->sym->m_src = ut_params->ibuf;
11454 	ut_params->op->sym->m_dst = NULL;
11455 
11456 	/* Process crypto operation */
11457 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11458 			NULL) {
11459 		printf("Test function %s line %u: failed to process security "
11460 			"crypto op\n", __func__, __LINE__);
11461 		ret = TEST_FAILED;
11462 		goto on_err;
11463 	}
11464 
11465 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11466 		printf("Test function %s line %u: failed to process crypto op\n",
11467 			__func__, __LINE__);
11468 		ret = TEST_FAILED;
11469 		goto on_err;
11470 	}
11471 
11472 	/* Validate plaintext */
11473 	plaintext = ciphertext;
11474 
11475 	if (memcmp(plaintext, d_td->plaintext.data,
11476 			d_td->plaintext.len - crc_data_len)) {
11477 		printf("Test function %s line %u: plaintext not as expected\n",
11478 			__func__, __LINE__);
11479 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
11480 				d_td->plaintext.len);
11481 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11482 		ret = TEST_FAILED;
11483 		goto on_err;
11484 	}
11485 
11486 on_err:
11487 	rte_crypto_op_free(ut_params->op);
11488 	ut_params->op = NULL;
11489 
11490 	if (ut_params->sec_session)
11491 		rte_security_session_destroy(ctx, ut_params->sec_session);
11492 	ut_params->sec_session = NULL;
11493 
11494 	rte_pktmbuf_free(ut_params->ibuf);
11495 	ut_params->ibuf = NULL;
11496 
11497 	return ret;
11498 }
11499 
11500 static int
11501 test_docsis_proto_downlink(const void *data)
11502 {
11503 	const struct docsis_test_data *d_td = data;
11504 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11505 	struct crypto_unittest_params *ut_params = &unittest_params;
11506 	uint8_t *plaintext = NULL;
11507 	uint8_t *ciphertext = NULL;
11508 	uint8_t *iv_ptr;
11509 	int32_t cipher_len, crc_len;
11510 	int ret = TEST_SUCCESS;
11511 
11512 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11513 
11514 	/* Verify the capabilities */
11515 	struct rte_security_capability_idx sec_cap_idx;
11516 	const struct rte_security_capability *sec_cap;
11517 	const struct rte_cryptodev_capabilities *crypto_cap;
11518 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11519 	int j = 0;
11520 
11521 	/* Set action type */
11522 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11523 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11524 		gbl_action_type;
11525 
11526 	if (security_proto_supported(ut_params->type,
11527 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11528 		return TEST_SKIPPED;
11529 
11530 	sec_cap_idx.action = ut_params->type;
11531 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11532 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11533 
11534 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11535 	if (sec_cap == NULL)
11536 		return TEST_SKIPPED;
11537 
11538 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11539 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11540 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11541 				crypto_cap->sym.xform_type ==
11542 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11543 				crypto_cap->sym.cipher.algo ==
11544 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11545 			sym_cap = &crypto_cap->sym;
11546 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11547 						d_td->key.len,
11548 						d_td->iv.len) == 0)
11549 				break;
11550 		}
11551 	}
11552 
11553 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11554 		return TEST_SKIPPED;
11555 
11556 	/* Setup source mbuf payload */
11557 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11558 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11559 			rte_pktmbuf_tailroom(ut_params->ibuf));
11560 
11561 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11562 			d_td->plaintext.len);
11563 
11564 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11565 
11566 	/* Setup cipher session parameters */
11567 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11568 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11569 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11570 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11571 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11572 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11573 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11574 	ut_params->cipher_xform.next = NULL;
11575 
11576 	/* Setup DOCSIS session parameters */
11577 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11578 
11579 	struct rte_security_session_conf sess_conf = {
11580 		.action_type = ut_params->type,
11581 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11582 		.docsis = ut_params->docsis_xform,
11583 		.crypto_xform = &ut_params->cipher_xform,
11584 	};
11585 
11586 	/* Create security session */
11587 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11588 					ts_params->session_mpool);
11589 
11590 	if (!ut_params->sec_session) {
11591 		printf("Test function %s line %u: failed to allocate session\n",
11592 			__func__, __LINE__);
11593 		ret = TEST_FAILED;
11594 		goto on_err;
11595 	}
11596 
11597 	/* Generate crypto op data structure */
11598 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11599 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11600 	if (!ut_params->op) {
11601 		printf("Test function %s line %u: failed to allocate symmetric "
11602 			"crypto operation\n", __func__, __LINE__);
11603 		ret = TEST_FAILED;
11604 		goto on_err;
11605 	}
11606 
11607 	/* Setup CRC operation parameters */
11608 	crc_len = d_td->plaintext.no_crc == false ?
11609 			(d_td->plaintext.len -
11610 				d_td->plaintext.crc_offset -
11611 				RTE_ETHER_CRC_LEN) :
11612 			0;
11613 	crc_len = crc_len > 0 ? crc_len : 0;
11614 	ut_params->op->sym->auth.data.length = crc_len;
11615 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11616 
11617 	/* Setup cipher operation parameters */
11618 	cipher_len = d_td->plaintext.no_cipher == false ?
11619 			(d_td->plaintext.len -
11620 				d_td->plaintext.cipher_offset) :
11621 			0;
11622 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11623 	ut_params->op->sym->cipher.data.length = cipher_len;
11624 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11625 
11626 	/* Setup cipher IV */
11627 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11628 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11629 
11630 	/* Attach session to operation */
11631 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11632 
11633 	/* Set crypto operation mbufs */
11634 	ut_params->op->sym->m_src = ut_params->ibuf;
11635 	ut_params->op->sym->m_dst = NULL;
11636 
11637 	/* Process crypto operation */
11638 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11639 			NULL) {
11640 		printf("Test function %s line %u: failed to process crypto op\n",
11641 			__func__, __LINE__);
11642 		ret = TEST_FAILED;
11643 		goto on_err;
11644 	}
11645 
11646 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11647 		printf("Test function %s line %u: crypto op processing failed\n",
11648 			__func__, __LINE__);
11649 		ret = TEST_FAILED;
11650 		goto on_err;
11651 	}
11652 
11653 	/* Validate ciphertext */
11654 	ciphertext = plaintext;
11655 
11656 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11657 		printf("Test function %s line %u: plaintext not as expected\n",
11658 			__func__, __LINE__);
11659 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11660 				d_td->ciphertext.len);
11661 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11662 		ret = TEST_FAILED;
11663 		goto on_err;
11664 	}
11665 
11666 on_err:
11667 	rte_crypto_op_free(ut_params->op);
11668 	ut_params->op = NULL;
11669 
11670 	if (ut_params->sec_session)
11671 		rte_security_session_destroy(ctx, ut_params->sec_session);
11672 	ut_params->sec_session = NULL;
11673 
11674 	rte_pktmbuf_free(ut_params->ibuf);
11675 	ut_params->ibuf = NULL;
11676 
11677 	return ret;
11678 }
11679 #endif
11680 
11681 static int
11682 test_AES_GCM_authenticated_encryption_test_case_1(void)
11683 {
11684 	return test_authenticated_encryption(&gcm_test_case_1);
11685 }
11686 
11687 static int
11688 test_AES_GCM_authenticated_encryption_test_case_2(void)
11689 {
11690 	return test_authenticated_encryption(&gcm_test_case_2);
11691 }
11692 
11693 static int
11694 test_AES_GCM_authenticated_encryption_test_case_3(void)
11695 {
11696 	return test_authenticated_encryption(&gcm_test_case_3);
11697 }
11698 
11699 static int
11700 test_AES_GCM_authenticated_encryption_test_case_4(void)
11701 {
11702 	return test_authenticated_encryption(&gcm_test_case_4);
11703 }
11704 
11705 static int
11706 test_AES_GCM_authenticated_encryption_test_case_5(void)
11707 {
11708 	return test_authenticated_encryption(&gcm_test_case_5);
11709 }
11710 
11711 static int
11712 test_AES_GCM_authenticated_encryption_test_case_6(void)
11713 {
11714 	return test_authenticated_encryption(&gcm_test_case_6);
11715 }
11716 
11717 static int
11718 test_AES_GCM_authenticated_encryption_test_case_7(void)
11719 {
11720 	return test_authenticated_encryption(&gcm_test_case_7);
11721 }
11722 
11723 static int
11724 test_AES_GCM_authenticated_encryption_test_case_8(void)
11725 {
11726 	return test_authenticated_encryption(&gcm_test_case_8);
11727 }
11728 
11729 static int
11730 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
11731 {
11732 	return test_authenticated_encryption(&gcm_J0_test_case_1);
11733 }
11734 
11735 static int
11736 test_AES_GCM_auth_encryption_test_case_192_1(void)
11737 {
11738 	return test_authenticated_encryption(&gcm_test_case_192_1);
11739 }
11740 
11741 static int
11742 test_AES_GCM_auth_encryption_test_case_192_2(void)
11743 {
11744 	return test_authenticated_encryption(&gcm_test_case_192_2);
11745 }
11746 
11747 static int
11748 test_AES_GCM_auth_encryption_test_case_192_3(void)
11749 {
11750 	return test_authenticated_encryption(&gcm_test_case_192_3);
11751 }
11752 
11753 static int
11754 test_AES_GCM_auth_encryption_test_case_192_4(void)
11755 {
11756 	return test_authenticated_encryption(&gcm_test_case_192_4);
11757 }
11758 
11759 static int
11760 test_AES_GCM_auth_encryption_test_case_192_5(void)
11761 {
11762 	return test_authenticated_encryption(&gcm_test_case_192_5);
11763 }
11764 
11765 static int
11766 test_AES_GCM_auth_encryption_test_case_192_6(void)
11767 {
11768 	return test_authenticated_encryption(&gcm_test_case_192_6);
11769 }
11770 
11771 static int
11772 test_AES_GCM_auth_encryption_test_case_192_7(void)
11773 {
11774 	return test_authenticated_encryption(&gcm_test_case_192_7);
11775 }
11776 
11777 static int
11778 test_AES_GCM_auth_encryption_test_case_256_1(void)
11779 {
11780 	return test_authenticated_encryption(&gcm_test_case_256_1);
11781 }
11782 
11783 static int
11784 test_AES_GCM_auth_encryption_test_case_256_2(void)
11785 {
11786 	return test_authenticated_encryption(&gcm_test_case_256_2);
11787 }
11788 
11789 static int
11790 test_AES_GCM_auth_encryption_test_case_256_3(void)
11791 {
11792 	return test_authenticated_encryption(&gcm_test_case_256_3);
11793 }
11794 
11795 static int
11796 test_AES_GCM_auth_encryption_test_case_256_4(void)
11797 {
11798 	return test_authenticated_encryption(&gcm_test_case_256_4);
11799 }
11800 
11801 static int
11802 test_AES_GCM_auth_encryption_test_case_256_5(void)
11803 {
11804 	return test_authenticated_encryption(&gcm_test_case_256_5);
11805 }
11806 
11807 static int
11808 test_AES_GCM_auth_encryption_test_case_256_6(void)
11809 {
11810 	return test_authenticated_encryption(&gcm_test_case_256_6);
11811 }
11812 
11813 static int
11814 test_AES_GCM_auth_encryption_test_case_256_7(void)
11815 {
11816 	return test_authenticated_encryption(&gcm_test_case_256_7);
11817 }
11818 
11819 static int
11820 test_AES_GCM_auth_encryption_test_case_aad_1(void)
11821 {
11822 	return test_authenticated_encryption(&gcm_test_case_aad_1);
11823 }
11824 
11825 static int
11826 test_AES_GCM_auth_encryption_test_case_aad_2(void)
11827 {
11828 	return test_authenticated_encryption(&gcm_test_case_aad_2);
11829 }
11830 
11831 static int
11832 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
11833 {
11834 	struct aead_test_data tdata;
11835 	int res;
11836 
11837 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11838 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11839 	tdata.iv.data[0] += 1;
11840 	res = test_authenticated_encryption(&tdata);
11841 	if (res == TEST_SKIPPED)
11842 		return res;
11843 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11844 	return TEST_SUCCESS;
11845 }
11846 
11847 static int
11848 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
11849 {
11850 	struct aead_test_data tdata;
11851 	int res;
11852 
11853 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11854 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11855 	tdata.plaintext.data[0] += 1;
11856 	res = test_authenticated_encryption(&tdata);
11857 	if (res == TEST_SKIPPED)
11858 		return res;
11859 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11860 	return TEST_SUCCESS;
11861 }
11862 
11863 static int
11864 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
11865 {
11866 	struct aead_test_data tdata;
11867 	int res;
11868 
11869 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11870 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11871 	tdata.ciphertext.data[0] += 1;
11872 	res = test_authenticated_encryption(&tdata);
11873 	if (res == TEST_SKIPPED)
11874 		return res;
11875 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11876 	return TEST_SUCCESS;
11877 }
11878 
11879 static int
11880 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
11881 {
11882 	struct aead_test_data tdata;
11883 	int res;
11884 
11885 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11886 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11887 	tdata.aad.len += 1;
11888 	res = test_authenticated_encryption(&tdata);
11889 	if (res == TEST_SKIPPED)
11890 		return res;
11891 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11892 	return TEST_SUCCESS;
11893 }
11894 
11895 static int
11896 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
11897 {
11898 	struct aead_test_data tdata;
11899 	uint8_t aad[gcm_test_case_7.aad.len];
11900 	int res;
11901 
11902 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11903 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11904 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
11905 	aad[0] += 1;
11906 	tdata.aad.data = aad;
11907 	res = test_authenticated_encryption(&tdata);
11908 	if (res == TEST_SKIPPED)
11909 		return res;
11910 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11911 	return TEST_SUCCESS;
11912 }
11913 
11914 static int
11915 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
11916 {
11917 	struct aead_test_data tdata;
11918 	int res;
11919 
11920 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11921 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11922 	tdata.auth_tag.data[0] += 1;
11923 	res = test_authenticated_encryption(&tdata);
11924 	if (res == TEST_SKIPPED)
11925 		return res;
11926 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11927 	return TEST_SUCCESS;
11928 }
11929 
11930 static int
11931 test_authenticated_decryption(const struct aead_test_data *tdata)
11932 {
11933 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11934 	struct crypto_unittest_params *ut_params = &unittest_params;
11935 
11936 	int retval;
11937 	uint8_t *plaintext;
11938 	uint32_t i;
11939 	struct rte_cryptodev_info dev_info;
11940 
11941 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11942 	uint64_t feat_flags = dev_info.feature_flags;
11943 
11944 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11945 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11946 		printf("Device doesn't support RAW data-path APIs.\n");
11947 		return TEST_SKIPPED;
11948 	}
11949 
11950 	/* Verify the capabilities */
11951 	struct rte_cryptodev_sym_capability_idx cap_idx;
11952 	const struct rte_cryptodev_symmetric_capability *capability;
11953 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11954 	cap_idx.algo.aead = tdata->algo;
11955 	capability = rte_cryptodev_sym_capability_get(
11956 			ts_params->valid_devs[0], &cap_idx);
11957 	if (capability == NULL)
11958 		return TEST_SKIPPED;
11959 	if (rte_cryptodev_sym_capability_check_aead(
11960 			capability, tdata->key.len, tdata->auth_tag.len,
11961 			tdata->aad.len, tdata->iv.len))
11962 		return TEST_SKIPPED;
11963 
11964 	/* Create AEAD session */
11965 	retval = create_aead_session(ts_params->valid_devs[0],
11966 			tdata->algo,
11967 			RTE_CRYPTO_AEAD_OP_DECRYPT,
11968 			tdata->key.data, tdata->key.len,
11969 			tdata->aad.len, tdata->auth_tag.len,
11970 			tdata->iv.len);
11971 	if (retval != TEST_SUCCESS)
11972 		return retval;
11973 
11974 	/* alloc mbuf and set payload */
11975 	if (tdata->aad.len > MBUF_SIZE) {
11976 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11977 		/* Populate full size of add data */
11978 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
11979 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
11980 	} else
11981 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11982 
11983 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11984 			rte_pktmbuf_tailroom(ut_params->ibuf));
11985 
11986 	/* Create AEAD operation */
11987 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11988 	if (retval < 0)
11989 		return retval;
11990 
11991 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11992 
11993 	ut_params->op->sym->m_src = ut_params->ibuf;
11994 
11995 	/* Process crypto operation */
11996 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11997 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11998 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
11999 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12000 					       0);
12001 		if (retval != TEST_SUCCESS)
12002 			return retval;
12003 	} else
12004 		TEST_ASSERT_NOT_NULL(
12005 			process_crypto_request(ts_params->valid_devs[0],
12006 			ut_params->op), "failed to process sym crypto op");
12007 
12008 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12009 			"crypto op processing failed");
12010 
12011 	if (ut_params->op->sym->m_dst)
12012 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
12013 				uint8_t *);
12014 	else
12015 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12016 				uint8_t *,
12017 				ut_params->op->sym->cipher.data.offset);
12018 
12019 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12020 
12021 	/* Validate obuf */
12022 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12023 			plaintext,
12024 			tdata->plaintext.data,
12025 			tdata->plaintext.len,
12026 			"Plaintext data not as expected");
12027 
12028 	TEST_ASSERT_EQUAL(ut_params->op->status,
12029 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12030 			"Authentication failed");
12031 
12032 	return 0;
12033 }
12034 
12035 static int
12036 test_AES_GCM_authenticated_decryption_test_case_1(void)
12037 {
12038 	return test_authenticated_decryption(&gcm_test_case_1);
12039 }
12040 
12041 static int
12042 test_AES_GCM_authenticated_decryption_test_case_2(void)
12043 {
12044 	return test_authenticated_decryption(&gcm_test_case_2);
12045 }
12046 
12047 static int
12048 test_AES_GCM_authenticated_decryption_test_case_3(void)
12049 {
12050 	return test_authenticated_decryption(&gcm_test_case_3);
12051 }
12052 
12053 static int
12054 test_AES_GCM_authenticated_decryption_test_case_4(void)
12055 {
12056 	return test_authenticated_decryption(&gcm_test_case_4);
12057 }
12058 
12059 static int
12060 test_AES_GCM_authenticated_decryption_test_case_5(void)
12061 {
12062 	return test_authenticated_decryption(&gcm_test_case_5);
12063 }
12064 
12065 static int
12066 test_AES_GCM_authenticated_decryption_test_case_6(void)
12067 {
12068 	return test_authenticated_decryption(&gcm_test_case_6);
12069 }
12070 
12071 static int
12072 test_AES_GCM_authenticated_decryption_test_case_7(void)
12073 {
12074 	return test_authenticated_decryption(&gcm_test_case_7);
12075 }
12076 
12077 static int
12078 test_AES_GCM_authenticated_decryption_test_case_8(void)
12079 {
12080 	return test_authenticated_decryption(&gcm_test_case_8);
12081 }
12082 
12083 static int
12084 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
12085 {
12086 	return test_authenticated_decryption(&gcm_J0_test_case_1);
12087 }
12088 
12089 static int
12090 test_AES_GCM_auth_decryption_test_case_192_1(void)
12091 {
12092 	return test_authenticated_decryption(&gcm_test_case_192_1);
12093 }
12094 
12095 static int
12096 test_AES_GCM_auth_decryption_test_case_192_2(void)
12097 {
12098 	return test_authenticated_decryption(&gcm_test_case_192_2);
12099 }
12100 
12101 static int
12102 test_AES_GCM_auth_decryption_test_case_192_3(void)
12103 {
12104 	return test_authenticated_decryption(&gcm_test_case_192_3);
12105 }
12106 
12107 static int
12108 test_AES_GCM_auth_decryption_test_case_192_4(void)
12109 {
12110 	return test_authenticated_decryption(&gcm_test_case_192_4);
12111 }
12112 
12113 static int
12114 test_AES_GCM_auth_decryption_test_case_192_5(void)
12115 {
12116 	return test_authenticated_decryption(&gcm_test_case_192_5);
12117 }
12118 
12119 static int
12120 test_AES_GCM_auth_decryption_test_case_192_6(void)
12121 {
12122 	return test_authenticated_decryption(&gcm_test_case_192_6);
12123 }
12124 
12125 static int
12126 test_AES_GCM_auth_decryption_test_case_192_7(void)
12127 {
12128 	return test_authenticated_decryption(&gcm_test_case_192_7);
12129 }
12130 
12131 static int
12132 test_AES_GCM_auth_decryption_test_case_256_1(void)
12133 {
12134 	return test_authenticated_decryption(&gcm_test_case_256_1);
12135 }
12136 
12137 static int
12138 test_AES_GCM_auth_decryption_test_case_256_2(void)
12139 {
12140 	return test_authenticated_decryption(&gcm_test_case_256_2);
12141 }
12142 
12143 static int
12144 test_AES_GCM_auth_decryption_test_case_256_3(void)
12145 {
12146 	return test_authenticated_decryption(&gcm_test_case_256_3);
12147 }
12148 
12149 static int
12150 test_AES_GCM_auth_decryption_test_case_256_4(void)
12151 {
12152 	return test_authenticated_decryption(&gcm_test_case_256_4);
12153 }
12154 
12155 static int
12156 test_AES_GCM_auth_decryption_test_case_256_5(void)
12157 {
12158 	return test_authenticated_decryption(&gcm_test_case_256_5);
12159 }
12160 
12161 static int
12162 test_AES_GCM_auth_decryption_test_case_256_6(void)
12163 {
12164 	return test_authenticated_decryption(&gcm_test_case_256_6);
12165 }
12166 
12167 static int
12168 test_AES_GCM_auth_decryption_test_case_256_7(void)
12169 {
12170 	return test_authenticated_decryption(&gcm_test_case_256_7);
12171 }
12172 
12173 static int
12174 test_AES_GCM_auth_decryption_test_case_aad_1(void)
12175 {
12176 	return test_authenticated_decryption(&gcm_test_case_aad_1);
12177 }
12178 
12179 static int
12180 test_AES_GCM_auth_decryption_test_case_aad_2(void)
12181 {
12182 	return test_authenticated_decryption(&gcm_test_case_aad_2);
12183 }
12184 
12185 static int
12186 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
12187 {
12188 	struct aead_test_data tdata;
12189 	int res;
12190 
12191 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12192 	tdata.iv.data[0] += 1;
12193 	res = test_authenticated_decryption(&tdata);
12194 	if (res == TEST_SKIPPED)
12195 		return res;
12196 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12197 	return TEST_SUCCESS;
12198 }
12199 
12200 static int
12201 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
12202 {
12203 	struct aead_test_data tdata;
12204 	int res;
12205 
12206 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12207 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12208 	tdata.plaintext.data[0] += 1;
12209 	res = test_authenticated_decryption(&tdata);
12210 	if (res == TEST_SKIPPED)
12211 		return res;
12212 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12213 	return TEST_SUCCESS;
12214 }
12215 
12216 static int
12217 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
12218 {
12219 	struct aead_test_data tdata;
12220 	int res;
12221 
12222 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12223 	tdata.ciphertext.data[0] += 1;
12224 	res = test_authenticated_decryption(&tdata);
12225 	if (res == TEST_SKIPPED)
12226 		return res;
12227 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12228 	return TEST_SUCCESS;
12229 }
12230 
12231 static int
12232 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
12233 {
12234 	struct aead_test_data tdata;
12235 	int res;
12236 
12237 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12238 	tdata.aad.len += 1;
12239 	res = test_authenticated_decryption(&tdata);
12240 	if (res == TEST_SKIPPED)
12241 		return res;
12242 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12243 	return TEST_SUCCESS;
12244 }
12245 
12246 static int
12247 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
12248 {
12249 	struct aead_test_data tdata;
12250 	uint8_t aad[gcm_test_case_7.aad.len];
12251 	int res;
12252 
12253 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12254 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12255 	aad[0] += 1;
12256 	tdata.aad.data = aad;
12257 	res = test_authenticated_decryption(&tdata);
12258 	if (res == TEST_SKIPPED)
12259 		return res;
12260 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12261 	return TEST_SUCCESS;
12262 }
12263 
12264 static int
12265 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
12266 {
12267 	struct aead_test_data tdata;
12268 	int res;
12269 
12270 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12271 	tdata.auth_tag.data[0] += 1;
12272 	res = test_authenticated_decryption(&tdata);
12273 	if (res == TEST_SKIPPED)
12274 		return res;
12275 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
12276 	return TEST_SUCCESS;
12277 }
12278 
12279 static int
12280 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
12281 {
12282 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12283 	struct crypto_unittest_params *ut_params = &unittest_params;
12284 
12285 	int retval;
12286 	uint8_t *ciphertext, *auth_tag;
12287 	uint16_t plaintext_pad_len;
12288 	struct rte_cryptodev_info dev_info;
12289 
12290 	/* Verify the capabilities */
12291 	struct rte_cryptodev_sym_capability_idx cap_idx;
12292 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12293 	cap_idx.algo.aead = tdata->algo;
12294 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12295 			&cap_idx) == NULL)
12296 		return TEST_SKIPPED;
12297 
12298 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12299 	uint64_t feat_flags = dev_info.feature_flags;
12300 
12301 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12302 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
12303 		return TEST_SKIPPED;
12304 
12305 	/* not supported with CPU crypto */
12306 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12307 		return TEST_SKIPPED;
12308 
12309 	/* Create AEAD session */
12310 	retval = create_aead_session(ts_params->valid_devs[0],
12311 			tdata->algo,
12312 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
12313 			tdata->key.data, tdata->key.len,
12314 			tdata->aad.len, tdata->auth_tag.len,
12315 			tdata->iv.len);
12316 	if (retval < 0)
12317 		return retval;
12318 
12319 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12320 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12321 
12322 	/* clear mbuf payload */
12323 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12324 			rte_pktmbuf_tailroom(ut_params->ibuf));
12325 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12326 			rte_pktmbuf_tailroom(ut_params->obuf));
12327 
12328 	/* Create AEAD operation */
12329 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12330 	if (retval < 0)
12331 		return retval;
12332 
12333 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12334 
12335 	ut_params->op->sym->m_src = ut_params->ibuf;
12336 	ut_params->op->sym->m_dst = ut_params->obuf;
12337 
12338 	/* Process crypto operation */
12339 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12340 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12341 					       0);
12342 		if (retval != TEST_SUCCESS)
12343 			return retval;
12344 	} else
12345 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12346 			ut_params->op), "failed to process sym crypto op");
12347 
12348 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12349 			"crypto op processing failed");
12350 
12351 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12352 
12353 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12354 			ut_params->op->sym->cipher.data.offset);
12355 	auth_tag = ciphertext + plaintext_pad_len;
12356 
12357 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12358 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12359 
12360 	/* Validate obuf */
12361 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12362 			ciphertext,
12363 			tdata->ciphertext.data,
12364 			tdata->ciphertext.len,
12365 			"Ciphertext data not as expected");
12366 
12367 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12368 			auth_tag,
12369 			tdata->auth_tag.data,
12370 			tdata->auth_tag.len,
12371 			"Generated auth tag not as expected");
12372 
12373 	return 0;
12374 
12375 }
12376 
12377 static int
12378 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
12379 {
12380 	return test_authenticated_encryption_oop(&gcm_test_case_5);
12381 }
12382 
12383 static int
12384 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
12385 {
12386 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12387 	struct crypto_unittest_params *ut_params = &unittest_params;
12388 
12389 	int retval;
12390 	uint8_t *plaintext;
12391 	struct rte_cryptodev_info dev_info;
12392 
12393 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12394 	uint64_t feat_flags = dev_info.feature_flags;
12395 
12396 	/* Verify the capabilities */
12397 	struct rte_cryptodev_sym_capability_idx cap_idx;
12398 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12399 	cap_idx.algo.aead = tdata->algo;
12400 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12401 			&cap_idx) == NULL)
12402 		return TEST_SKIPPED;
12403 
12404 	/* not supported with CPU crypto and raw data-path APIs*/
12405 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
12406 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
12407 		return TEST_SKIPPED;
12408 
12409 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12410 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12411 		printf("Device does not support RAW data-path APIs.\n");
12412 		return TEST_SKIPPED;
12413 	}
12414 
12415 	/* Create AEAD session */
12416 	retval = create_aead_session(ts_params->valid_devs[0],
12417 			tdata->algo,
12418 			RTE_CRYPTO_AEAD_OP_DECRYPT,
12419 			tdata->key.data, tdata->key.len,
12420 			tdata->aad.len, tdata->auth_tag.len,
12421 			tdata->iv.len);
12422 	if (retval < 0)
12423 		return retval;
12424 
12425 	/* alloc mbuf and set payload */
12426 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12427 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12428 
12429 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12430 			rte_pktmbuf_tailroom(ut_params->ibuf));
12431 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12432 			rte_pktmbuf_tailroom(ut_params->obuf));
12433 
12434 	/* Create AEAD operation */
12435 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12436 	if (retval < 0)
12437 		return retval;
12438 
12439 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12440 
12441 	ut_params->op->sym->m_src = ut_params->ibuf;
12442 	ut_params->op->sym->m_dst = ut_params->obuf;
12443 
12444 	/* Process crypto operation */
12445 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12446 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12447 					       0);
12448 		if (retval != TEST_SUCCESS)
12449 			return retval;
12450 	} else
12451 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12452 			ut_params->op), "failed to process sym crypto op");
12453 
12454 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12455 			"crypto op processing failed");
12456 
12457 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12458 			ut_params->op->sym->cipher.data.offset);
12459 
12460 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12461 
12462 	/* Validate obuf */
12463 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12464 			plaintext,
12465 			tdata->plaintext.data,
12466 			tdata->plaintext.len,
12467 			"Plaintext data not as expected");
12468 
12469 	TEST_ASSERT_EQUAL(ut_params->op->status,
12470 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12471 			"Authentication failed");
12472 	return 0;
12473 }
12474 
12475 static int
12476 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
12477 {
12478 	return test_authenticated_decryption_oop(&gcm_test_case_5);
12479 }
12480 
12481 static int
12482 test_authenticated_encryption_sessionless(
12483 		const struct aead_test_data *tdata)
12484 {
12485 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12486 	struct crypto_unittest_params *ut_params = &unittest_params;
12487 
12488 	int retval;
12489 	uint8_t *ciphertext, *auth_tag;
12490 	uint16_t plaintext_pad_len;
12491 	uint8_t key[tdata->key.len + 1];
12492 	struct rte_cryptodev_info dev_info;
12493 
12494 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12495 	uint64_t feat_flags = dev_info.feature_flags;
12496 
12497 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12498 		printf("Device doesn't support Sessionless ops.\n");
12499 		return TEST_SKIPPED;
12500 	}
12501 
12502 	/* not supported with CPU crypto */
12503 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12504 		return TEST_SKIPPED;
12505 
12506 	/* Verify the capabilities */
12507 	struct rte_cryptodev_sym_capability_idx cap_idx;
12508 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12509 	cap_idx.algo.aead = tdata->algo;
12510 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12511 			&cap_idx) == NULL)
12512 		return TEST_SKIPPED;
12513 
12514 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12515 
12516 	/* clear mbuf payload */
12517 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12518 			rte_pktmbuf_tailroom(ut_params->ibuf));
12519 
12520 	/* Create AEAD operation */
12521 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12522 	if (retval < 0)
12523 		return retval;
12524 
12525 	/* Create GCM xform */
12526 	memcpy(key, tdata->key.data, tdata->key.len);
12527 	retval = create_aead_xform(ut_params->op,
12528 			tdata->algo,
12529 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
12530 			key, tdata->key.len,
12531 			tdata->aad.len, tdata->auth_tag.len,
12532 			tdata->iv.len);
12533 	if (retval < 0)
12534 		return retval;
12535 
12536 	ut_params->op->sym->m_src = ut_params->ibuf;
12537 
12538 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12539 			RTE_CRYPTO_OP_SESSIONLESS,
12540 			"crypto op session type not sessionless");
12541 
12542 	/* Process crypto operation */
12543 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12544 			ut_params->op), "failed to process sym crypto op");
12545 
12546 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12547 
12548 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12549 			"crypto op status not success");
12550 
12551 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12552 
12553 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12554 			ut_params->op->sym->cipher.data.offset);
12555 	auth_tag = ciphertext + plaintext_pad_len;
12556 
12557 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12558 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12559 
12560 	/* Validate obuf */
12561 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12562 			ciphertext,
12563 			tdata->ciphertext.data,
12564 			tdata->ciphertext.len,
12565 			"Ciphertext data not as expected");
12566 
12567 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12568 			auth_tag,
12569 			tdata->auth_tag.data,
12570 			tdata->auth_tag.len,
12571 			"Generated auth tag not as expected");
12572 
12573 	return 0;
12574 
12575 }
12576 
12577 static int
12578 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
12579 {
12580 	return test_authenticated_encryption_sessionless(
12581 			&gcm_test_case_5);
12582 }
12583 
12584 static int
12585 test_authenticated_decryption_sessionless(
12586 		const struct aead_test_data *tdata)
12587 {
12588 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12589 	struct crypto_unittest_params *ut_params = &unittest_params;
12590 
12591 	int retval;
12592 	uint8_t *plaintext;
12593 	uint8_t key[tdata->key.len + 1];
12594 	struct rte_cryptodev_info dev_info;
12595 
12596 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12597 	uint64_t feat_flags = dev_info.feature_flags;
12598 
12599 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12600 		printf("Device doesn't support Sessionless ops.\n");
12601 		return TEST_SKIPPED;
12602 	}
12603 
12604 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12605 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12606 		printf("Device doesn't support RAW data-path APIs.\n");
12607 		return TEST_SKIPPED;
12608 	}
12609 
12610 	/* not supported with CPU crypto */
12611 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12612 		return TEST_SKIPPED;
12613 
12614 	/* Verify the capabilities */
12615 	struct rte_cryptodev_sym_capability_idx cap_idx;
12616 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12617 	cap_idx.algo.aead = tdata->algo;
12618 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12619 			&cap_idx) == NULL)
12620 		return TEST_SKIPPED;
12621 
12622 	/* alloc mbuf and set payload */
12623 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12624 
12625 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12626 			rte_pktmbuf_tailroom(ut_params->ibuf));
12627 
12628 	/* Create AEAD operation */
12629 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12630 	if (retval < 0)
12631 		return retval;
12632 
12633 	/* Create AEAD xform */
12634 	memcpy(key, tdata->key.data, tdata->key.len);
12635 	retval = create_aead_xform(ut_params->op,
12636 			tdata->algo,
12637 			RTE_CRYPTO_AEAD_OP_DECRYPT,
12638 			key, tdata->key.len,
12639 			tdata->aad.len, tdata->auth_tag.len,
12640 			tdata->iv.len);
12641 	if (retval < 0)
12642 		return retval;
12643 
12644 	ut_params->op->sym->m_src = ut_params->ibuf;
12645 
12646 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12647 			RTE_CRYPTO_OP_SESSIONLESS,
12648 			"crypto op session type not sessionless");
12649 
12650 	/* Process crypto operation */
12651 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12652 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12653 					       0);
12654 		if (retval != TEST_SUCCESS)
12655 			return retval;
12656 	} else
12657 		TEST_ASSERT_NOT_NULL(process_crypto_request(
12658 			ts_params->valid_devs[0], ut_params->op),
12659 				"failed to process sym crypto op");
12660 
12661 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12662 
12663 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12664 			"crypto op status not success");
12665 
12666 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12667 			ut_params->op->sym->cipher.data.offset);
12668 
12669 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12670 
12671 	/* Validate obuf */
12672 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12673 			plaintext,
12674 			tdata->plaintext.data,
12675 			tdata->plaintext.len,
12676 			"Plaintext data not as expected");
12677 
12678 	TEST_ASSERT_EQUAL(ut_params->op->status,
12679 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12680 			"Authentication failed");
12681 	return 0;
12682 }
12683 
12684 static int
12685 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
12686 {
12687 	return test_authenticated_decryption_sessionless(
12688 			&gcm_test_case_5);
12689 }
12690 
12691 static int
12692 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
12693 {
12694 	return test_authenticated_encryption(&ccm_test_case_128_1);
12695 }
12696 
12697 static int
12698 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
12699 {
12700 	return test_authenticated_encryption(&ccm_test_case_128_2);
12701 }
12702 
12703 static int
12704 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
12705 {
12706 	return test_authenticated_encryption(&ccm_test_case_128_3);
12707 }
12708 
12709 static int
12710 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
12711 {
12712 	return test_authenticated_decryption(&ccm_test_case_128_1);
12713 }
12714 
12715 static int
12716 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
12717 {
12718 	return test_authenticated_decryption(&ccm_test_case_128_2);
12719 }
12720 
12721 static int
12722 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
12723 {
12724 	return test_authenticated_decryption(&ccm_test_case_128_3);
12725 }
12726 
12727 static int
12728 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
12729 {
12730 	return test_authenticated_encryption(&ccm_test_case_192_1);
12731 }
12732 
12733 static int
12734 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
12735 {
12736 	return test_authenticated_encryption(&ccm_test_case_192_2);
12737 }
12738 
12739 static int
12740 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
12741 {
12742 	return test_authenticated_encryption(&ccm_test_case_192_3);
12743 }
12744 
12745 static int
12746 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
12747 {
12748 	return test_authenticated_decryption(&ccm_test_case_192_1);
12749 }
12750 
12751 static int
12752 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
12753 {
12754 	return test_authenticated_decryption(&ccm_test_case_192_2);
12755 }
12756 
12757 static int
12758 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
12759 {
12760 	return test_authenticated_decryption(&ccm_test_case_192_3);
12761 }
12762 
12763 static int
12764 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
12765 {
12766 	return test_authenticated_encryption(&ccm_test_case_256_1);
12767 }
12768 
12769 static int
12770 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
12771 {
12772 	return test_authenticated_encryption(&ccm_test_case_256_2);
12773 }
12774 
12775 static int
12776 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
12777 {
12778 	return test_authenticated_encryption(&ccm_test_case_256_3);
12779 }
12780 
12781 static int
12782 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
12783 {
12784 	return test_authenticated_decryption(&ccm_test_case_256_1);
12785 }
12786 
12787 static int
12788 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
12789 {
12790 	return test_authenticated_decryption(&ccm_test_case_256_2);
12791 }
12792 
12793 static int
12794 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
12795 {
12796 	return test_authenticated_decryption(&ccm_test_case_256_3);
12797 }
12798 
12799 static int
12800 test_stats(void)
12801 {
12802 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12803 	struct rte_cryptodev_stats stats;
12804 
12805 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12806 		return TEST_SKIPPED;
12807 
12808 	/* Verify the capabilities */
12809 	struct rte_cryptodev_sym_capability_idx cap_idx;
12810 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12811 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
12812 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12813 			&cap_idx) == NULL)
12814 		return TEST_SKIPPED;
12815 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12816 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12817 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12818 			&cap_idx) == NULL)
12819 		return TEST_SKIPPED;
12820 
12821 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
12822 			== -ENOTSUP)
12823 		return TEST_SKIPPED;
12824 
12825 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
12826 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
12827 			&stats) == -ENODEV),
12828 		"rte_cryptodev_stats_get invalid dev failed");
12829 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
12830 		"rte_cryptodev_stats_get invalid Param failed");
12831 
12832 	/* Test expected values */
12833 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
12834 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12835 			&stats),
12836 		"rte_cryptodev_stats_get failed");
12837 	TEST_ASSERT((stats.enqueued_count == 1),
12838 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
12839 	TEST_ASSERT((stats.dequeued_count == 1),
12840 		"rte_cryptodev_stats_get returned unexpected dequeued stat");
12841 	TEST_ASSERT((stats.enqueue_err_count == 0),
12842 		"rte_cryptodev_stats_get returned unexpected enqueued error count stat");
12843 	TEST_ASSERT((stats.dequeue_err_count == 0),
12844 		"rte_cryptodev_stats_get returned unexpected dequeued error count stat");
12845 
12846 	/* invalid device but should ignore and not reset device stats*/
12847 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
12848 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12849 			&stats),
12850 		"rte_cryptodev_stats_get failed");
12851 	TEST_ASSERT((stats.enqueued_count == 1),
12852 		"rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
12853 
12854 	/* check that a valid reset clears stats */
12855 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
12856 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
12857 			&stats),
12858 					  "rte_cryptodev_stats_get failed");
12859 	TEST_ASSERT((stats.enqueued_count == 0),
12860 		"rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
12861 	TEST_ASSERT((stats.dequeued_count == 0),
12862 		"rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
12863 
12864 	return TEST_SUCCESS;
12865 }
12866 
12867 static int
12868 test_device_reconfigure(void)
12869 {
12870 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12871 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
12872 	struct rte_cryptodev_qp_conf qp_conf = {
12873 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT,
12874 		.mp_session = ts_params->session_mpool
12875 	};
12876 	uint16_t qp_id, dev_id, num_devs = 0;
12877 
12878 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
12879 			"Need at least %d devices for test", 1);
12880 
12881 	dev_id = ts_params->valid_devs[0];
12882 
12883 	/* Stop the device in case it's started so it can be configured */
12884 	rte_cryptodev_stop(dev_id);
12885 
12886 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
12887 			"Failed test for rte_cryptodev_configure: "
12888 			"dev_num %u", dev_id);
12889 
12890 	/* Reconfigure with same configure params */
12891 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
12892 			"Failed test for rte_cryptodev_configure: "
12893 			"dev_num %u", dev_id);
12894 
12895 	/* Reconfigure with just one queue pair */
12896 	ts_params->conf.nb_queue_pairs = 1;
12897 
12898 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12899 			&ts_params->conf),
12900 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
12901 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
12902 
12903 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
12904 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12905 				ts_params->valid_devs[0], qp_id, &qp_conf,
12906 				rte_cryptodev_socket_id(
12907 						ts_params->valid_devs[0])),
12908 				"Failed test for "
12909 				"rte_cryptodev_queue_pair_setup: num_inflights "
12910 				"%u on qp %u on cryptodev %u",
12911 				qp_conf.nb_descriptors, qp_id,
12912 				ts_params->valid_devs[0]);
12913 	}
12914 
12915 	/* Reconfigure with max number of queue pairs */
12916 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
12917 
12918 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12919 			&ts_params->conf),
12920 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
12921 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
12922 
12923 	qp_conf.mp_session = ts_params->session_mpool;
12924 
12925 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
12926 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12927 				ts_params->valid_devs[0], qp_id, &qp_conf,
12928 				rte_cryptodev_socket_id(
12929 						ts_params->valid_devs[0])),
12930 				"Failed test for "
12931 				"rte_cryptodev_queue_pair_setup: num_inflights "
12932 				"%u on qp %u on cryptodev %u",
12933 				qp_conf.nb_descriptors, qp_id,
12934 				ts_params->valid_devs[0]);
12935 	}
12936 
12937 	/* Start the device */
12938 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
12939 			"Failed to start cryptodev %u",
12940 			ts_params->valid_devs[0]);
12941 
12942 	/* Test expected values */
12943 	return test_AES_CBC_HMAC_SHA1_encrypt_digest();
12944 }
12945 
12946 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
12947 				   struct crypto_unittest_params *ut_params,
12948 				   enum rte_crypto_auth_operation op,
12949 				   const struct HMAC_MD5_vector *test_case)
12950 {
12951 	uint8_t key[64];
12952 
12953 	memcpy(key, test_case->key.data, test_case->key.len);
12954 
12955 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12956 	ut_params->auth_xform.next = NULL;
12957 	ut_params->auth_xform.auth.op = op;
12958 
12959 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
12960 
12961 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
12962 	ut_params->auth_xform.auth.key.length = test_case->key.len;
12963 	ut_params->auth_xform.auth.key.data = key;
12964 
12965 	ut_params->sess = rte_cryptodev_sym_session_create(
12966 		ts_params->valid_devs[0], &ut_params->auth_xform,
12967 			ts_params->session_mpool);
12968 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
12969 		return TEST_SKIPPED;
12970 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12971 
12972 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12973 
12974 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12975 			rte_pktmbuf_tailroom(ut_params->ibuf));
12976 
12977 	return 0;
12978 }
12979 
12980 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
12981 			      const struct HMAC_MD5_vector *test_case,
12982 			      uint8_t **plaintext)
12983 {
12984 	uint16_t plaintext_pad_len;
12985 
12986 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12987 
12988 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
12989 				16);
12990 
12991 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12992 			plaintext_pad_len);
12993 	memcpy(*plaintext, test_case->plaintext.data,
12994 			test_case->plaintext.len);
12995 
12996 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12997 			ut_params->ibuf, MD5_DIGEST_LEN);
12998 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12999 			"no room to append digest");
13000 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13001 			ut_params->ibuf, plaintext_pad_len);
13002 
13003 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13004 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
13005 			   test_case->auth_tag.len);
13006 	}
13007 
13008 	sym_op->auth.data.offset = 0;
13009 	sym_op->auth.data.length = test_case->plaintext.len;
13010 
13011 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13012 	ut_params->op->sym->m_src = ut_params->ibuf;
13013 
13014 	return 0;
13015 }
13016 
13017 static int
13018 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
13019 {
13020 	uint16_t plaintext_pad_len;
13021 	uint8_t *plaintext, *auth_tag;
13022 	int ret;
13023 
13024 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13025 	struct crypto_unittest_params *ut_params = &unittest_params;
13026 	struct rte_cryptodev_info dev_info;
13027 
13028 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13029 	uint64_t feat_flags = dev_info.feature_flags;
13030 
13031 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13032 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13033 		printf("Device doesn't support RAW data-path APIs.\n");
13034 		return TEST_SKIPPED;
13035 	}
13036 
13037 	/* Verify the capabilities */
13038 	struct rte_cryptodev_sym_capability_idx cap_idx;
13039 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13040 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13041 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13042 			&cap_idx) == NULL)
13043 		return TEST_SKIPPED;
13044 
13045 	if (MD5_HMAC_create_session(ts_params, ut_params,
13046 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
13047 		return TEST_FAILED;
13048 
13049 	/* Generate Crypto op data structure */
13050 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13051 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13052 	TEST_ASSERT_NOT_NULL(ut_params->op,
13053 			"Failed to allocate symmetric crypto operation struct");
13054 
13055 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13056 				16);
13057 
13058 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13059 		return TEST_FAILED;
13060 
13061 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13062 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13063 			ut_params->op);
13064 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13065 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13066 		if (ret != TEST_SUCCESS)
13067 			return ret;
13068 	} else
13069 		TEST_ASSERT_NOT_NULL(
13070 			process_crypto_request(ts_params->valid_devs[0],
13071 				ut_params->op),
13072 				"failed to process sym crypto op");
13073 
13074 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13075 			"crypto op processing failed");
13076 
13077 	if (ut_params->op->sym->m_dst) {
13078 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13079 				uint8_t *, plaintext_pad_len);
13080 	} else {
13081 		auth_tag = plaintext + plaintext_pad_len;
13082 	}
13083 
13084 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13085 			auth_tag,
13086 			test_case->auth_tag.data,
13087 			test_case->auth_tag.len,
13088 			"HMAC_MD5 generated tag not as expected");
13089 
13090 	return TEST_SUCCESS;
13091 }
13092 
13093 static int
13094 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
13095 {
13096 	uint8_t *plaintext;
13097 	int ret;
13098 
13099 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13100 	struct crypto_unittest_params *ut_params = &unittest_params;
13101 	struct rte_cryptodev_info dev_info;
13102 
13103 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13104 	uint64_t feat_flags = dev_info.feature_flags;
13105 
13106 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13107 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13108 		printf("Device doesn't support RAW data-path APIs.\n");
13109 		return TEST_SKIPPED;
13110 	}
13111 
13112 	/* Verify the capabilities */
13113 	struct rte_cryptodev_sym_capability_idx cap_idx;
13114 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13115 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13116 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13117 			&cap_idx) == NULL)
13118 		return TEST_SKIPPED;
13119 
13120 	if (MD5_HMAC_create_session(ts_params, ut_params,
13121 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
13122 		return TEST_FAILED;
13123 	}
13124 
13125 	/* Generate Crypto op data structure */
13126 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13127 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13128 	TEST_ASSERT_NOT_NULL(ut_params->op,
13129 			"Failed to allocate symmetric crypto operation struct");
13130 
13131 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13132 		return TEST_FAILED;
13133 
13134 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13135 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13136 			ut_params->op);
13137 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13138 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13139 		if (ret != TEST_SUCCESS)
13140 			return ret;
13141 	} else
13142 		TEST_ASSERT_NOT_NULL(
13143 			process_crypto_request(ts_params->valid_devs[0],
13144 				ut_params->op),
13145 				"failed to process sym crypto op");
13146 
13147 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13148 			"HMAC_MD5 crypto op processing failed");
13149 
13150 	return TEST_SUCCESS;
13151 }
13152 
13153 static int
13154 test_MD5_HMAC_generate_case_1(void)
13155 {
13156 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
13157 }
13158 
13159 static int
13160 test_MD5_HMAC_verify_case_1(void)
13161 {
13162 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
13163 }
13164 
13165 static int
13166 test_MD5_HMAC_generate_case_2(void)
13167 {
13168 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
13169 }
13170 
13171 static int
13172 test_MD5_HMAC_verify_case_2(void)
13173 {
13174 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
13175 }
13176 
13177 static int
13178 test_multi_session(void)
13179 {
13180 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13181 	struct crypto_unittest_params *ut_params = &unittest_params;
13182 	struct rte_cryptodev_info dev_info;
13183 	int i, nb_sess, ret = TEST_SUCCESS;
13184 	void **sessions;
13185 
13186 	/* Verify the capabilities */
13187 	struct rte_cryptodev_sym_capability_idx cap_idx;
13188 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13189 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13190 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13191 			&cap_idx) == NULL)
13192 		return TEST_SKIPPED;
13193 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13194 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13195 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13196 			&cap_idx) == NULL)
13197 		return TEST_SKIPPED;
13198 
13199 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
13200 			aes_cbc_key, hmac_sha512_key);
13201 
13202 
13203 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13204 
13205 	sessions = rte_malloc(NULL,
13206 			sizeof(void *) *
13207 			(MAX_NB_SESSIONS + 1), 0);
13208 
13209 	/* Create multiple crypto sessions*/
13210 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
13211 		sessions[i] = rte_cryptodev_sym_session_create(
13212 			ts_params->valid_devs[0], &ut_params->auth_xform,
13213 				ts_params->session_mpool);
13214 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13215 			nb_sess = i;
13216 			ret = TEST_SKIPPED;
13217 			break;
13218 		}
13219 
13220 		TEST_ASSERT_NOT_NULL(sessions[i],
13221 				"Session creation failed at session number %u",
13222 				i);
13223 
13224 		/* Attempt to send a request on each session */
13225 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13226 			sessions[i],
13227 			ut_params,
13228 			ts_params,
13229 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
13230 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
13231 			aes_cbc_iv);
13232 
13233 		/* free crypto operation structure */
13234 		rte_crypto_op_free(ut_params->op);
13235 
13236 		/*
13237 		 * free mbuf - both obuf and ibuf are usually the same,
13238 		 * so check if they point at the same address is necessary,
13239 		 * to avoid freeing the mbuf twice.
13240 		 */
13241 		if (ut_params->obuf) {
13242 			rte_pktmbuf_free(ut_params->obuf);
13243 			if (ut_params->ibuf == ut_params->obuf)
13244 				ut_params->ibuf = 0;
13245 			ut_params->obuf = 0;
13246 		}
13247 		if (ut_params->ibuf) {
13248 			rte_pktmbuf_free(ut_params->ibuf);
13249 			ut_params->ibuf = 0;
13250 		}
13251 
13252 		if (ret != TEST_SUCCESS) {
13253 			i++;
13254 			break;
13255 		}
13256 	}
13257 
13258 	nb_sess = i;
13259 
13260 	for (i = 0; i < nb_sess; i++) {
13261 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13262 				sessions[i]);
13263 	}
13264 
13265 	rte_free(sessions);
13266 
13267 	if (ret != TEST_SKIPPED)
13268 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
13269 
13270 	return ret;
13271 }
13272 
13273 struct multi_session_params {
13274 	struct crypto_unittest_params ut_params;
13275 	uint8_t *cipher_key;
13276 	uint8_t *hmac_key;
13277 	const uint8_t *cipher;
13278 	const uint8_t *digest;
13279 	uint8_t *iv;
13280 };
13281 
13282 #define MB_SESSION_NUMBER 3
13283 
13284 static int
13285 test_multi_session_random_usage(void)
13286 {
13287 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13288 	struct rte_cryptodev_info dev_info;
13289 	int index = 0, ret = TEST_SUCCESS;
13290 	uint32_t nb_sess, i, j;
13291 	void **sessions;
13292 	struct multi_session_params ut_paramz[] = {
13293 
13294 		{
13295 			.cipher_key = ms_aes_cbc_key0,
13296 			.hmac_key = ms_hmac_key0,
13297 			.cipher = ms_aes_cbc_cipher0,
13298 			.digest = ms_hmac_digest0,
13299 			.iv = ms_aes_cbc_iv0
13300 		},
13301 		{
13302 			.cipher_key = ms_aes_cbc_key1,
13303 			.hmac_key = ms_hmac_key1,
13304 			.cipher = ms_aes_cbc_cipher1,
13305 			.digest = ms_hmac_digest1,
13306 			.iv = ms_aes_cbc_iv1
13307 		},
13308 		{
13309 			.cipher_key = ms_aes_cbc_key2,
13310 			.hmac_key = ms_hmac_key2,
13311 			.cipher = ms_aes_cbc_cipher2,
13312 			.digest = ms_hmac_digest2,
13313 			.iv = ms_aes_cbc_iv2
13314 		},
13315 
13316 	};
13317 
13318 	/* Verify the capabilities */
13319 	struct rte_cryptodev_sym_capability_idx cap_idx;
13320 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13321 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13322 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13323 			&cap_idx) == NULL)
13324 		return TEST_SKIPPED;
13325 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13326 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13327 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13328 			&cap_idx) == NULL)
13329 		return TEST_SKIPPED;
13330 
13331 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13332 
13333 	sessions = rte_malloc(NULL, (sizeof(void *)
13334 					* MAX_NB_SESSIONS) + 1, 0);
13335 
13336 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
13337 
13338 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
13339 				sizeof(struct crypto_unittest_params));
13340 
13341 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
13342 				&ut_paramz[i].ut_params,
13343 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
13344 
13345 		/* Create multiple crypto sessions*/
13346 		sessions[i] = rte_cryptodev_sym_session_create(
13347 				ts_params->valid_devs[0],
13348 				&ut_paramz[i].ut_params.auth_xform,
13349 				ts_params->session_mpool);
13350 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13351 			nb_sess = i;
13352 			ret = TEST_SKIPPED;
13353 			goto session_clear;
13354 		}
13355 
13356 		TEST_ASSERT_NOT_NULL(sessions[i],
13357 				"Session creation failed at session number %u",
13358 				i);
13359 	}
13360 
13361 	nb_sess = i;
13362 
13363 	srand(time(NULL));
13364 	for (i = 0; i < 40000; i++) {
13365 
13366 		j = rand() % MB_SESSION_NUMBER;
13367 
13368 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13369 					sessions[j],
13370 					&ut_paramz[j].ut_params,
13371 					ts_params, ut_paramz[j].cipher,
13372 					ut_paramz[j].digest,
13373 					ut_paramz[j].iv);
13374 
13375 		rte_crypto_op_free(ut_paramz[j].ut_params.op);
13376 
13377 		/*
13378 		 * free mbuf - both obuf and ibuf are usually the same,
13379 		 * so check if they point at the same address is necessary,
13380 		 * to avoid freeing the mbuf twice.
13381 		 */
13382 		if (ut_paramz[j].ut_params.obuf) {
13383 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
13384 			if (ut_paramz[j].ut_params.ibuf
13385 					== ut_paramz[j].ut_params.obuf)
13386 				ut_paramz[j].ut_params.ibuf = 0;
13387 			ut_paramz[j].ut_params.obuf = 0;
13388 		}
13389 		if (ut_paramz[j].ut_params.ibuf) {
13390 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
13391 			ut_paramz[j].ut_params.ibuf = 0;
13392 		}
13393 
13394 		if (ret != TEST_SKIPPED) {
13395 			index = i;
13396 			break;
13397 		}
13398 	}
13399 
13400 session_clear:
13401 	for (i = 0; i < nb_sess; i++) {
13402 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13403 				sessions[i]);
13404 	}
13405 
13406 	rte_free(sessions);
13407 
13408 	if (ret != TEST_SKIPPED)
13409 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
13410 
13411 	return TEST_SUCCESS;
13412 }
13413 
13414 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
13415 			0xab, 0xab, 0xab, 0xab,
13416 			0xab, 0xab, 0xab, 0xab,
13417 			0xab, 0xab, 0xab, 0xab};
13418 
13419 static int
13420 test_null_invalid_operation(void)
13421 {
13422 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13423 	struct crypto_unittest_params *ut_params = &unittest_params;
13424 
13425 	/* This test is for NULL PMD only */
13426 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
13427 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13428 		return TEST_SKIPPED;
13429 
13430 	/* Setup Cipher Parameters */
13431 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13432 	ut_params->cipher_xform.next = NULL;
13433 
13434 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
13435 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13436 
13437 	/* Create Crypto session*/
13438 	ut_params->sess = rte_cryptodev_sym_session_create(
13439 			ts_params->valid_devs[0], &ut_params->cipher_xform,
13440 			ts_params->session_mpool);
13441 	TEST_ASSERT(ut_params->sess == NULL,
13442 			"Session creation succeeded unexpectedly");
13443 
13444 	/* Setup HMAC Parameters */
13445 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13446 	ut_params->auth_xform.next = NULL;
13447 
13448 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
13449 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13450 
13451 	/* Create Crypto session*/
13452 	ut_params->sess = rte_cryptodev_sym_session_create(
13453 			ts_params->valid_devs[0], &ut_params->auth_xform,
13454 			ts_params->session_mpool);
13455 	TEST_ASSERT(ut_params->sess == NULL,
13456 			"Session creation succeeded unexpectedly");
13457 
13458 	return TEST_SUCCESS;
13459 }
13460 
13461 
13462 #define NULL_BURST_LENGTH (32)
13463 
13464 static int
13465 test_null_burst_operation(void)
13466 {
13467 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13468 	struct crypto_unittest_params *ut_params = &unittest_params;
13469 
13470 	unsigned i, burst_len = NULL_BURST_LENGTH;
13471 
13472 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
13473 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
13474 
13475 	/* This test is for NULL PMD only */
13476 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
13477 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13478 		return TEST_SKIPPED;
13479 
13480 	/* Setup Cipher Parameters */
13481 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13482 	ut_params->cipher_xform.next = &ut_params->auth_xform;
13483 
13484 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
13485 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13486 
13487 	/* Setup HMAC Parameters */
13488 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13489 	ut_params->auth_xform.next = NULL;
13490 
13491 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
13492 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13493 
13494 	/* Create Crypto session*/
13495 	ut_params->sess = rte_cryptodev_sym_session_create(
13496 				ts_params->valid_devs[0],
13497 				&ut_params->auth_xform,
13498 				ts_params->session_mpool);
13499 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13500 		return TEST_SKIPPED;
13501 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13502 
13503 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
13504 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
13505 			burst_len, "failed to generate burst of crypto ops");
13506 
13507 	/* Generate an operation for each mbuf in burst */
13508 	for (i = 0; i < burst_len; i++) {
13509 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13510 
13511 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
13512 
13513 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
13514 				sizeof(unsigned));
13515 		*data = i;
13516 
13517 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
13518 
13519 		burst[i]->sym->m_src = m;
13520 	}
13521 
13522 	/* Process crypto operation */
13523 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
13524 			0, burst, burst_len),
13525 			burst_len,
13526 			"Error enqueuing burst");
13527 
13528 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
13529 			0, burst_dequeued, burst_len),
13530 			burst_len,
13531 			"Error dequeuing burst");
13532 
13533 
13534 	for (i = 0; i < burst_len; i++) {
13535 		TEST_ASSERT_EQUAL(
13536 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
13537 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
13538 					uint32_t *),
13539 			"data not as expected");
13540 
13541 		rte_pktmbuf_free(burst[i]->sym->m_src);
13542 		rte_crypto_op_free(burst[i]);
13543 	}
13544 
13545 	return TEST_SUCCESS;
13546 }
13547 
13548 static uint16_t
13549 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13550 		  uint16_t nb_ops, void *user_param)
13551 {
13552 	RTE_SET_USED(dev_id);
13553 	RTE_SET_USED(qp_id);
13554 	RTE_SET_USED(ops);
13555 	RTE_SET_USED(user_param);
13556 
13557 	printf("crypto enqueue callback called\n");
13558 	return nb_ops;
13559 }
13560 
13561 static uint16_t
13562 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13563 		  uint16_t nb_ops, void *user_param)
13564 {
13565 	RTE_SET_USED(dev_id);
13566 	RTE_SET_USED(qp_id);
13567 	RTE_SET_USED(ops);
13568 	RTE_SET_USED(user_param);
13569 
13570 	printf("crypto dequeue callback called\n");
13571 	return nb_ops;
13572 }
13573 
13574 /*
13575  * Thread using enqueue/dequeue callback with RCU.
13576  */
13577 static int
13578 test_enqdeq_callback_thread(void *arg)
13579 {
13580 	RTE_SET_USED(arg);
13581 	/* DP thread calls rte_cryptodev_enqueue_burst()/
13582 	 * rte_cryptodev_dequeue_burst() and invokes callback.
13583 	 */
13584 	test_null_burst_operation();
13585 	return 0;
13586 }
13587 
13588 static int
13589 test_enq_callback_setup(void)
13590 {
13591 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13592 	struct rte_cryptodev_info dev_info;
13593 	struct rte_cryptodev_qp_conf qp_conf = {
13594 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
13595 	};
13596 
13597 	struct rte_cryptodev_cb *cb;
13598 	uint16_t qp_id = 0;
13599 
13600 	/* Stop the device in case it's started so it can be configured */
13601 	rte_cryptodev_stop(ts_params->valid_devs[0]);
13602 
13603 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13604 
13605 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13606 			&ts_params->conf),
13607 			"Failed to configure cryptodev %u",
13608 			ts_params->valid_devs[0]);
13609 
13610 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13611 	qp_conf.mp_session = ts_params->session_mpool;
13612 
13613 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13614 			ts_params->valid_devs[0], qp_id, &qp_conf,
13615 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13616 			"Failed test for "
13617 			"rte_cryptodev_queue_pair_setup: num_inflights "
13618 			"%u on qp %u on cryptodev %u",
13619 			qp_conf.nb_descriptors, qp_id,
13620 			ts_params->valid_devs[0]);
13621 
13622 	/* Test with invalid crypto device */
13623 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
13624 			qp_id, test_enq_callback, NULL);
13625 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13626 			"cryptodev %u did not fail",
13627 			qp_id, RTE_CRYPTO_MAX_DEVS);
13628 
13629 	/* Test with invalid queue pair */
13630 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13631 			dev_info.max_nb_queue_pairs + 1,
13632 			test_enq_callback, NULL);
13633 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13634 			"cryptodev %u did not fail",
13635 			dev_info.max_nb_queue_pairs + 1,
13636 			ts_params->valid_devs[0]);
13637 
13638 	/* Test with NULL callback */
13639 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13640 			qp_id, NULL, NULL);
13641 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13642 			"cryptodev %u did not fail",
13643 			qp_id, ts_params->valid_devs[0]);
13644 
13645 	/* Test with valid configuration */
13646 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
13647 			qp_id, test_enq_callback, NULL);
13648 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
13649 			"qp %u on cryptodev %u",
13650 			qp_id, ts_params->valid_devs[0]);
13651 
13652 	rte_cryptodev_start(ts_params->valid_devs[0]);
13653 
13654 	/* Launch a thread */
13655 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
13656 				rte_get_next_lcore(-1, 1, 0));
13657 
13658 	/* Wait until reader exited. */
13659 	rte_eal_mp_wait_lcore();
13660 
13661 	/* Test with invalid crypto device */
13662 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13663 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
13664 			"Expected call to fail as crypto device is invalid");
13665 
13666 	/* Test with invalid queue pair */
13667 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13668 			ts_params->valid_devs[0],
13669 			dev_info.max_nb_queue_pairs + 1, cb),
13670 			"Expected call to fail as queue pair is invalid");
13671 
13672 	/* Test with NULL callback */
13673 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
13674 			ts_params->valid_devs[0], qp_id, NULL),
13675 			"Expected call to fail as callback is NULL");
13676 
13677 	/* Test with valid configuration */
13678 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
13679 			ts_params->valid_devs[0], qp_id, cb),
13680 			"Failed test to remove callback on "
13681 			"qp %u on cryptodev %u",
13682 			qp_id, ts_params->valid_devs[0]);
13683 
13684 	return TEST_SUCCESS;
13685 }
13686 
13687 static int
13688 test_deq_callback_setup(void)
13689 {
13690 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13691 	struct rte_cryptodev_info dev_info;
13692 	struct rte_cryptodev_qp_conf qp_conf = {
13693 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
13694 	};
13695 
13696 	struct rte_cryptodev_cb *cb;
13697 	uint16_t qp_id = 0;
13698 
13699 	/* Stop the device in case it's started so it can be configured */
13700 	rte_cryptodev_stop(ts_params->valid_devs[0]);
13701 
13702 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13703 
13704 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13705 			&ts_params->conf),
13706 			"Failed to configure cryptodev %u",
13707 			ts_params->valid_devs[0]);
13708 
13709 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13710 	qp_conf.mp_session = ts_params->session_mpool;
13711 
13712 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13713 			ts_params->valid_devs[0], qp_id, &qp_conf,
13714 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13715 			"Failed test for "
13716 			"rte_cryptodev_queue_pair_setup: num_inflights "
13717 			"%u on qp %u on cryptodev %u",
13718 			qp_conf.nb_descriptors, qp_id,
13719 			ts_params->valid_devs[0]);
13720 
13721 	/* Test with invalid crypto device */
13722 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
13723 			qp_id, test_deq_callback, NULL);
13724 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13725 			"cryptodev %u did not fail",
13726 			qp_id, RTE_CRYPTO_MAX_DEVS);
13727 
13728 	/* Test with invalid queue pair */
13729 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13730 			dev_info.max_nb_queue_pairs + 1,
13731 			test_deq_callback, NULL);
13732 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13733 			"cryptodev %u did not fail",
13734 			dev_info.max_nb_queue_pairs + 1,
13735 			ts_params->valid_devs[0]);
13736 
13737 	/* Test with NULL callback */
13738 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13739 			qp_id, NULL, NULL);
13740 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
13741 			"cryptodev %u did not fail",
13742 			qp_id, ts_params->valid_devs[0]);
13743 
13744 	/* Test with valid configuration */
13745 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
13746 			qp_id, test_deq_callback, NULL);
13747 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
13748 			"qp %u on cryptodev %u",
13749 			qp_id, ts_params->valid_devs[0]);
13750 
13751 	rte_cryptodev_start(ts_params->valid_devs[0]);
13752 
13753 	/* Launch a thread */
13754 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
13755 				rte_get_next_lcore(-1, 1, 0));
13756 
13757 	/* Wait until reader exited. */
13758 	rte_eal_mp_wait_lcore();
13759 
13760 	/* Test with invalid crypto device */
13761 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13762 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
13763 			"Expected call to fail as crypto device is invalid");
13764 
13765 	/* Test with invalid queue pair */
13766 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13767 			ts_params->valid_devs[0],
13768 			dev_info.max_nb_queue_pairs + 1, cb),
13769 			"Expected call to fail as queue pair is invalid");
13770 
13771 	/* Test with NULL callback */
13772 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
13773 			ts_params->valid_devs[0], qp_id, NULL),
13774 			"Expected call to fail as callback is NULL");
13775 
13776 	/* Test with valid configuration */
13777 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
13778 			ts_params->valid_devs[0], qp_id, cb),
13779 			"Failed test to remove callback on "
13780 			"qp %u on cryptodev %u",
13781 			qp_id, ts_params->valid_devs[0]);
13782 
13783 	return TEST_SUCCESS;
13784 }
13785 
13786 static void
13787 generate_gmac_large_plaintext(uint8_t *data)
13788 {
13789 	uint16_t i;
13790 
13791 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
13792 		memcpy(&data[i], &data[0], 32);
13793 }
13794 
13795 static int
13796 create_gmac_operation(enum rte_crypto_auth_operation op,
13797 		const struct gmac_test_data *tdata)
13798 {
13799 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13800 	struct crypto_unittest_params *ut_params = &unittest_params;
13801 	struct rte_crypto_sym_op *sym_op;
13802 
13803 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13804 
13805 	/* Generate Crypto op data structure */
13806 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13807 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13808 	TEST_ASSERT_NOT_NULL(ut_params->op,
13809 			"Failed to allocate symmetric crypto operation struct");
13810 
13811 	sym_op = ut_params->op->sym;
13812 
13813 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13814 			ut_params->ibuf, tdata->gmac_tag.len);
13815 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13816 			"no room to append digest");
13817 
13818 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13819 			ut_params->ibuf, plaintext_pad_len);
13820 
13821 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13822 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
13823 				tdata->gmac_tag.len);
13824 		debug_hexdump(stdout, "digest:",
13825 				sym_op->auth.digest.data,
13826 				tdata->gmac_tag.len);
13827 	}
13828 
13829 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13830 			uint8_t *, IV_OFFSET);
13831 
13832 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
13833 
13834 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
13835 
13836 	sym_op->cipher.data.length = 0;
13837 	sym_op->cipher.data.offset = 0;
13838 
13839 	sym_op->auth.data.offset = 0;
13840 	sym_op->auth.data.length = tdata->plaintext.len;
13841 
13842 	return 0;
13843 }
13844 
13845 static int
13846 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
13847 		const struct gmac_test_data *tdata,
13848 		void *digest_mem, uint64_t digest_phys)
13849 {
13850 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13851 	struct crypto_unittest_params *ut_params = &unittest_params;
13852 	struct rte_crypto_sym_op *sym_op;
13853 
13854 	/* Generate Crypto op data structure */
13855 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13856 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13857 	TEST_ASSERT_NOT_NULL(ut_params->op,
13858 			"Failed to allocate symmetric crypto operation struct");
13859 
13860 	sym_op = ut_params->op->sym;
13861 
13862 	sym_op->auth.digest.data = digest_mem;
13863 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13864 			"no room to append digest");
13865 
13866 	sym_op->auth.digest.phys_addr = digest_phys;
13867 
13868 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13869 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
13870 				tdata->gmac_tag.len);
13871 		debug_hexdump(stdout, "digest:",
13872 				sym_op->auth.digest.data,
13873 				tdata->gmac_tag.len);
13874 	}
13875 
13876 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13877 			uint8_t *, IV_OFFSET);
13878 
13879 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
13880 
13881 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
13882 
13883 	sym_op->cipher.data.length = 0;
13884 	sym_op->cipher.data.offset = 0;
13885 
13886 	sym_op->auth.data.offset = 0;
13887 	sym_op->auth.data.length = tdata->plaintext.len;
13888 
13889 	return 0;
13890 }
13891 
13892 static int create_gmac_session(uint8_t dev_id,
13893 		const struct gmac_test_data *tdata,
13894 		enum rte_crypto_auth_operation auth_op)
13895 {
13896 	uint8_t auth_key[tdata->key.len];
13897 
13898 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13899 	struct crypto_unittest_params *ut_params = &unittest_params;
13900 
13901 	memcpy(auth_key, tdata->key.data, tdata->key.len);
13902 
13903 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13904 	ut_params->auth_xform.next = NULL;
13905 
13906 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
13907 	ut_params->auth_xform.auth.op = auth_op;
13908 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
13909 	ut_params->auth_xform.auth.key.length = tdata->key.len;
13910 	ut_params->auth_xform.auth.key.data = auth_key;
13911 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13912 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
13913 
13914 
13915 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
13916 			&ut_params->auth_xform, ts_params->session_mpool);
13917 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13918 		return TEST_SKIPPED;
13919 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13920 
13921 	return 0;
13922 }
13923 
13924 static int
13925 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
13926 {
13927 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13928 	struct crypto_unittest_params *ut_params = &unittest_params;
13929 	struct rte_cryptodev_info dev_info;
13930 
13931 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13932 	uint64_t feat_flags = dev_info.feature_flags;
13933 
13934 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13935 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13936 		printf("Device doesn't support RAW data-path APIs.\n");
13937 		return TEST_SKIPPED;
13938 	}
13939 
13940 	int retval;
13941 
13942 	uint8_t *auth_tag, *plaintext;
13943 	uint16_t plaintext_pad_len;
13944 
13945 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
13946 			      "No GMAC length in the source data");
13947 
13948 	/* Verify the capabilities */
13949 	struct rte_cryptodev_sym_capability_idx cap_idx;
13950 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13951 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
13952 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13953 			&cap_idx) == NULL)
13954 		return TEST_SKIPPED;
13955 
13956 	retval = create_gmac_session(ts_params->valid_devs[0],
13957 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
13958 
13959 	if (retval == TEST_SKIPPED)
13960 		return TEST_SKIPPED;
13961 	if (retval < 0)
13962 		return retval;
13963 
13964 	if (tdata->plaintext.len > MBUF_SIZE)
13965 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13966 	else
13967 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13968 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13969 			"Failed to allocate input buffer in mempool");
13970 
13971 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13972 			rte_pktmbuf_tailroom(ut_params->ibuf));
13973 
13974 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13975 	/*
13976 	 * Runtime generate the large plain text instead of use hard code
13977 	 * plain text vector. It is done to avoid create huge source file
13978 	 * with the test vector.
13979 	 */
13980 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
13981 		generate_gmac_large_plaintext(tdata->plaintext.data);
13982 
13983 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13984 				plaintext_pad_len);
13985 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13986 
13987 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
13988 	debug_hexdump(stdout, "plaintext:", plaintext,
13989 			tdata->plaintext.len);
13990 
13991 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
13992 			tdata);
13993 
13994 	if (retval < 0)
13995 		return retval;
13996 
13997 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13998 
13999 	ut_params->op->sym->m_src = ut_params->ibuf;
14000 
14001 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14002 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14003 			ut_params->op);
14004 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14005 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14006 					       0);
14007 		if (retval != TEST_SUCCESS)
14008 			return retval;
14009 	} else
14010 		TEST_ASSERT_NOT_NULL(
14011 			process_crypto_request(ts_params->valid_devs[0],
14012 			ut_params->op), "failed to process sym crypto op");
14013 
14014 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14015 			"crypto op processing failed");
14016 
14017 	if (ut_params->op->sym->m_dst) {
14018 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14019 				uint8_t *, plaintext_pad_len);
14020 	} else {
14021 		auth_tag = plaintext + plaintext_pad_len;
14022 	}
14023 
14024 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14025 
14026 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14027 			auth_tag,
14028 			tdata->gmac_tag.data,
14029 			tdata->gmac_tag.len,
14030 			"GMAC Generated auth tag not as expected");
14031 
14032 	return 0;
14033 }
14034 
14035 static int
14036 test_AES_GMAC_authentication_test_case_1(void)
14037 {
14038 	return test_AES_GMAC_authentication(&gmac_test_case_1);
14039 }
14040 
14041 static int
14042 test_AES_GMAC_authentication_test_case_2(void)
14043 {
14044 	return test_AES_GMAC_authentication(&gmac_test_case_2);
14045 }
14046 
14047 static int
14048 test_AES_GMAC_authentication_test_case_3(void)
14049 {
14050 	return test_AES_GMAC_authentication(&gmac_test_case_3);
14051 }
14052 
14053 static int
14054 test_AES_GMAC_authentication_test_case_4(void)
14055 {
14056 	return test_AES_GMAC_authentication(&gmac_test_case_4);
14057 }
14058 
14059 static int
14060 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
14061 {
14062 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14063 	struct crypto_unittest_params *ut_params = &unittest_params;
14064 	int retval;
14065 	uint32_t plaintext_pad_len;
14066 	uint8_t *plaintext;
14067 	struct rte_cryptodev_info dev_info;
14068 
14069 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14070 	uint64_t feat_flags = dev_info.feature_flags;
14071 
14072 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14073 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14074 		printf("Device doesn't support RAW data-path APIs.\n");
14075 		return TEST_SKIPPED;
14076 	}
14077 
14078 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14079 			      "No GMAC length in the source data");
14080 
14081 	/* Verify the capabilities */
14082 	struct rte_cryptodev_sym_capability_idx cap_idx;
14083 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14084 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14085 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14086 			&cap_idx) == NULL)
14087 		return TEST_SKIPPED;
14088 
14089 	retval = create_gmac_session(ts_params->valid_devs[0],
14090 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
14091 
14092 	if (retval == TEST_SKIPPED)
14093 		return TEST_SKIPPED;
14094 	if (retval < 0)
14095 		return retval;
14096 
14097 	if (tdata->plaintext.len > MBUF_SIZE)
14098 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14099 	else
14100 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14101 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14102 			"Failed to allocate input buffer in mempool");
14103 
14104 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14105 			rte_pktmbuf_tailroom(ut_params->ibuf));
14106 
14107 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14108 
14109 	/*
14110 	 * Runtime generate the large plain text instead of use hard code
14111 	 * plain text vector. It is done to avoid create huge source file
14112 	 * with the test vector.
14113 	 */
14114 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14115 		generate_gmac_large_plaintext(tdata->plaintext.data);
14116 
14117 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14118 				plaintext_pad_len);
14119 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14120 
14121 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14122 	debug_hexdump(stdout, "plaintext:", plaintext,
14123 			tdata->plaintext.len);
14124 
14125 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
14126 			tdata);
14127 
14128 	if (retval < 0)
14129 		return retval;
14130 
14131 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14132 
14133 	ut_params->op->sym->m_src = ut_params->ibuf;
14134 
14135 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14136 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14137 			ut_params->op);
14138 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14139 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14140 					       0);
14141 		if (retval != TEST_SUCCESS)
14142 			return retval;
14143 	} else
14144 		TEST_ASSERT_NOT_NULL(
14145 			process_crypto_request(ts_params->valid_devs[0],
14146 			ut_params->op), "failed to process sym crypto op");
14147 
14148 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14149 			"crypto op processing failed");
14150 
14151 	return 0;
14152 
14153 }
14154 
14155 static int
14156 test_AES_GMAC_authentication_verify_test_case_1(void)
14157 {
14158 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
14159 }
14160 
14161 static int
14162 test_AES_GMAC_authentication_verify_test_case_2(void)
14163 {
14164 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
14165 }
14166 
14167 static int
14168 test_AES_GMAC_authentication_verify_test_case_3(void)
14169 {
14170 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
14171 }
14172 
14173 static int
14174 test_AES_GMAC_authentication_verify_test_case_4(void)
14175 {
14176 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
14177 }
14178 
14179 static int
14180 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
14181 				uint32_t fragsz)
14182 {
14183 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14184 	struct crypto_unittest_params *ut_params = &unittest_params;
14185 	struct rte_cryptodev_info dev_info;
14186 	uint64_t feature_flags;
14187 	unsigned int trn_data = 0;
14188 	void *digest_mem = NULL;
14189 	uint32_t segs = 1;
14190 	unsigned int to_trn = 0;
14191 	struct rte_mbuf *buf = NULL;
14192 	uint8_t *auth_tag, *plaintext;
14193 	int retval;
14194 
14195 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14196 			      "No GMAC length in the source data");
14197 
14198 	/* Verify the capabilities */
14199 	struct rte_cryptodev_sym_capability_idx cap_idx;
14200 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14201 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14202 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14203 			&cap_idx) == NULL)
14204 		return TEST_SKIPPED;
14205 
14206 	/* Check for any input SGL support */
14207 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14208 	feature_flags = dev_info.feature_flags;
14209 
14210 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
14211 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
14212 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
14213 		return TEST_SKIPPED;
14214 
14215 	if (fragsz > tdata->plaintext.len)
14216 		fragsz = tdata->plaintext.len;
14217 
14218 	uint16_t plaintext_len = fragsz;
14219 
14220 	retval = create_gmac_session(ts_params->valid_devs[0],
14221 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14222 
14223 	if (retval == TEST_SKIPPED)
14224 		return TEST_SKIPPED;
14225 	if (retval < 0)
14226 		return retval;
14227 
14228 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14229 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14230 			"Failed to allocate input buffer in mempool");
14231 
14232 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14233 			rte_pktmbuf_tailroom(ut_params->ibuf));
14234 
14235 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14236 				plaintext_len);
14237 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14238 
14239 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14240 
14241 	trn_data += plaintext_len;
14242 
14243 	buf = ut_params->ibuf;
14244 
14245 	/*
14246 	 * Loop until no more fragments
14247 	 */
14248 
14249 	while (trn_data < tdata->plaintext.len) {
14250 		++segs;
14251 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14252 				(tdata->plaintext.len - trn_data) : fragsz;
14253 
14254 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14255 		buf = buf->next;
14256 
14257 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14258 				rte_pktmbuf_tailroom(buf));
14259 
14260 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14261 				to_trn);
14262 
14263 		memcpy(plaintext, tdata->plaintext.data + trn_data,
14264 				to_trn);
14265 		trn_data += to_trn;
14266 		if (trn_data  == tdata->plaintext.len)
14267 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14268 					tdata->gmac_tag.len);
14269 	}
14270 	ut_params->ibuf->nb_segs = segs;
14271 
14272 	/*
14273 	 * Place digest at the end of the last buffer
14274 	 */
14275 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14276 
14277 	if (!digest_mem) {
14278 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14279 				+ tdata->gmac_tag.len);
14280 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14281 				tdata->plaintext.len);
14282 	}
14283 
14284 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
14285 			tdata, digest_mem, digest_phys);
14286 
14287 	if (retval < 0)
14288 		return retval;
14289 
14290 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14291 
14292 	ut_params->op->sym->m_src = ut_params->ibuf;
14293 
14294 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14295 		return TEST_SKIPPED;
14296 
14297 	TEST_ASSERT_NOT_NULL(
14298 		process_crypto_request(ts_params->valid_devs[0],
14299 		ut_params->op), "failed to process sym crypto op");
14300 
14301 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14302 			"crypto op processing failed");
14303 
14304 	auth_tag = digest_mem;
14305 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14306 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14307 			auth_tag,
14308 			tdata->gmac_tag.data,
14309 			tdata->gmac_tag.len,
14310 			"GMAC Generated auth tag not as expected");
14311 
14312 	return 0;
14313 }
14314 
14315 /* Segment size not multiple of block size (16B) */
14316 static int
14317 test_AES_GMAC_authentication_SGL_40B(void)
14318 {
14319 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
14320 }
14321 
14322 static int
14323 test_AES_GMAC_authentication_SGL_80B(void)
14324 {
14325 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
14326 }
14327 
14328 static int
14329 test_AES_GMAC_authentication_SGL_2048B(void)
14330 {
14331 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
14332 }
14333 
14334 /* Segment size not multiple of block size (16B) */
14335 static int
14336 test_AES_GMAC_authentication_SGL_2047B(void)
14337 {
14338 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
14339 }
14340 
14341 struct test_crypto_vector {
14342 	enum rte_crypto_cipher_algorithm crypto_algo;
14343 	unsigned int cipher_offset;
14344 	unsigned int cipher_len;
14345 
14346 	struct {
14347 		uint8_t data[64];
14348 		unsigned int len;
14349 	} cipher_key;
14350 
14351 	struct {
14352 		uint8_t data[64];
14353 		unsigned int len;
14354 	} iv;
14355 
14356 	struct {
14357 		const uint8_t *data;
14358 		unsigned int len;
14359 	} plaintext;
14360 
14361 	struct {
14362 		const uint8_t *data;
14363 		unsigned int len;
14364 	} ciphertext;
14365 
14366 	enum rte_crypto_auth_algorithm auth_algo;
14367 	unsigned int auth_offset;
14368 
14369 	struct {
14370 		uint8_t data[128];
14371 		unsigned int len;
14372 	} auth_key;
14373 
14374 	struct {
14375 		const uint8_t *data;
14376 		unsigned int len;
14377 	} aad;
14378 
14379 	struct {
14380 		uint8_t data[128];
14381 		unsigned int len;
14382 	} digest;
14383 };
14384 
14385 static const struct test_crypto_vector
14386 hmac_sha1_test_crypto_vector = {
14387 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14388 	.plaintext = {
14389 		.data = plaintext_hash,
14390 		.len = 512
14391 	},
14392 	.auth_key = {
14393 		.data = {
14394 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14395 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14396 			0xDE, 0xF4, 0xDE, 0xAD
14397 		},
14398 		.len = 20
14399 	},
14400 	.digest = {
14401 		.data = {
14402 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
14403 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
14404 			0x3F, 0x91, 0x64, 0x59
14405 		},
14406 		.len = 20
14407 	}
14408 };
14409 
14410 static const struct test_crypto_vector
14411 aes128_gmac_test_vector = {
14412 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
14413 	.plaintext = {
14414 		.data = plaintext_hash,
14415 		.len = 512
14416 	},
14417 	.iv = {
14418 		.data = {
14419 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14420 			0x08, 0x09, 0x0A, 0x0B
14421 		},
14422 		.len = 12
14423 	},
14424 	.auth_key = {
14425 		.data = {
14426 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14427 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
14428 		},
14429 		.len = 16
14430 	},
14431 	.digest = {
14432 		.data = {
14433 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
14434 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
14435 		},
14436 		.len = 16
14437 	}
14438 };
14439 
14440 static const struct test_crypto_vector
14441 aes128cbc_hmac_sha1_test_vector = {
14442 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14443 	.cipher_offset = 0,
14444 	.cipher_len = 512,
14445 	.cipher_key = {
14446 		.data = {
14447 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14448 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14449 		},
14450 		.len = 16
14451 	},
14452 	.iv = {
14453 		.data = {
14454 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14455 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14456 		},
14457 		.len = 16
14458 	},
14459 	.plaintext = {
14460 		.data = plaintext_hash,
14461 		.len = 512
14462 	},
14463 	.ciphertext = {
14464 		.data = ciphertext512_aes128cbc,
14465 		.len = 512
14466 	},
14467 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14468 	.auth_offset = 0,
14469 	.auth_key = {
14470 		.data = {
14471 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14472 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14473 			0xDE, 0xF4, 0xDE, 0xAD
14474 		},
14475 		.len = 20
14476 	},
14477 	.digest = {
14478 		.data = {
14479 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
14480 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14481 			0x18, 0x8C, 0x1D, 0x32
14482 		},
14483 		.len = 20
14484 	}
14485 };
14486 
14487 static const struct test_crypto_vector
14488 aes128cbc_hmac_sha1_aad_test_vector = {
14489 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14490 	.cipher_offset = 8,
14491 	.cipher_len = 496,
14492 	.cipher_key = {
14493 		.data = {
14494 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14495 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14496 		},
14497 		.len = 16
14498 	},
14499 	.iv = {
14500 		.data = {
14501 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14502 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14503 		},
14504 		.len = 16
14505 	},
14506 	.plaintext = {
14507 		.data = plaintext_hash,
14508 		.len = 512
14509 	},
14510 	.ciphertext = {
14511 		.data = ciphertext512_aes128cbc_aad,
14512 		.len = 512
14513 	},
14514 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14515 	.auth_offset = 0,
14516 	.auth_key = {
14517 		.data = {
14518 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14519 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14520 			0xDE, 0xF4, 0xDE, 0xAD
14521 		},
14522 		.len = 20
14523 	},
14524 	.digest = {
14525 		.data = {
14526 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
14527 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
14528 			0x62, 0x0F, 0xFB, 0x10
14529 		},
14530 		.len = 20
14531 	}
14532 };
14533 
14534 static void
14535 data_corruption(uint8_t *data)
14536 {
14537 	data[0] += 1;
14538 }
14539 
14540 static void
14541 tag_corruption(uint8_t *data, unsigned int tag_offset)
14542 {
14543 	data[tag_offset] += 1;
14544 }
14545 
14546 static int
14547 create_auth_session(struct crypto_unittest_params *ut_params,
14548 		uint8_t dev_id,
14549 		const struct test_crypto_vector *reference,
14550 		enum rte_crypto_auth_operation auth_op)
14551 {
14552 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14553 	uint8_t auth_key[reference->auth_key.len + 1];
14554 
14555 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14556 
14557 	/* Setup Authentication Parameters */
14558 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14559 	ut_params->auth_xform.auth.op = auth_op;
14560 	ut_params->auth_xform.next = NULL;
14561 	ut_params->auth_xform.auth.algo = reference->auth_algo;
14562 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14563 	ut_params->auth_xform.auth.key.data = auth_key;
14564 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
14565 
14566 	/* Create Crypto session*/
14567 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14568 				&ut_params->auth_xform,
14569 				ts_params->session_mpool);
14570 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14571 		return TEST_SKIPPED;
14572 
14573 	return 0;
14574 }
14575 
14576 static int
14577 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
14578 		uint8_t dev_id,
14579 		const struct test_crypto_vector *reference,
14580 		enum rte_crypto_auth_operation auth_op,
14581 		enum rte_crypto_cipher_operation cipher_op)
14582 {
14583 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14584 	uint8_t cipher_key[reference->cipher_key.len + 1];
14585 	uint8_t auth_key[reference->auth_key.len + 1];
14586 
14587 	memcpy(cipher_key, reference->cipher_key.data,
14588 			reference->cipher_key.len);
14589 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14590 
14591 	/* Setup Authentication Parameters */
14592 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14593 	ut_params->auth_xform.auth.op = auth_op;
14594 	ut_params->auth_xform.auth.algo = reference->auth_algo;
14595 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14596 	ut_params->auth_xform.auth.key.data = auth_key;
14597 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
14598 
14599 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
14600 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14601 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
14602 	} else {
14603 		ut_params->auth_xform.next = &ut_params->cipher_xform;
14604 
14605 		/* Setup Cipher Parameters */
14606 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14607 		ut_params->cipher_xform.next = NULL;
14608 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14609 		ut_params->cipher_xform.cipher.op = cipher_op;
14610 		ut_params->cipher_xform.cipher.key.data = cipher_key;
14611 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14612 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14613 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14614 	}
14615 
14616 	/* Create Crypto session*/
14617 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14618 				&ut_params->auth_xform,
14619 				ts_params->session_mpool);
14620 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14621 		return TEST_SKIPPED;
14622 
14623 	return 0;
14624 }
14625 
14626 static int
14627 create_auth_operation(struct crypto_testsuite_params *ts_params,
14628 		struct crypto_unittest_params *ut_params,
14629 		const struct test_crypto_vector *reference,
14630 		unsigned int auth_generate)
14631 {
14632 	/* Generate Crypto op data structure */
14633 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14634 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14635 	TEST_ASSERT_NOT_NULL(ut_params->op,
14636 			"Failed to allocate pktmbuf offload");
14637 
14638 	/* Set crypto operation data parameters */
14639 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14640 
14641 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14642 
14643 	/* set crypto operation source mbuf */
14644 	sym_op->m_src = ut_params->ibuf;
14645 
14646 	/* digest */
14647 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14648 			ut_params->ibuf, reference->digest.len);
14649 
14650 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14651 			"no room to append auth tag");
14652 
14653 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14654 			ut_params->ibuf, reference->plaintext.len);
14655 
14656 	if (auth_generate)
14657 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
14658 	else
14659 		memcpy(sym_op->auth.digest.data,
14660 				reference->digest.data,
14661 				reference->digest.len);
14662 
14663 	debug_hexdump(stdout, "digest:",
14664 			sym_op->auth.digest.data,
14665 			reference->digest.len);
14666 
14667 	sym_op->auth.data.length = reference->plaintext.len;
14668 	sym_op->auth.data.offset = 0;
14669 
14670 	return 0;
14671 }
14672 
14673 static int
14674 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
14675 		struct crypto_unittest_params *ut_params,
14676 		const struct test_crypto_vector *reference,
14677 		unsigned int auth_generate)
14678 {
14679 	/* Generate Crypto op data structure */
14680 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14681 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14682 	TEST_ASSERT_NOT_NULL(ut_params->op,
14683 			"Failed to allocate pktmbuf offload");
14684 
14685 	/* Set crypto operation data parameters */
14686 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14687 
14688 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14689 
14690 	/* set crypto operation source mbuf */
14691 	sym_op->m_src = ut_params->ibuf;
14692 
14693 	/* digest */
14694 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14695 			ut_params->ibuf, reference->digest.len);
14696 
14697 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14698 			"no room to append auth tag");
14699 
14700 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14701 			ut_params->ibuf, reference->ciphertext.len);
14702 
14703 	if (auth_generate)
14704 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
14705 	else
14706 		memcpy(sym_op->auth.digest.data,
14707 				reference->digest.data,
14708 				reference->digest.len);
14709 
14710 	debug_hexdump(stdout, "digest:",
14711 			sym_op->auth.digest.data,
14712 			reference->digest.len);
14713 
14714 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
14715 			reference->iv.data, reference->iv.len);
14716 
14717 	sym_op->cipher.data.length = 0;
14718 	sym_op->cipher.data.offset = 0;
14719 
14720 	sym_op->auth.data.length = reference->plaintext.len;
14721 	sym_op->auth.data.offset = 0;
14722 
14723 	return 0;
14724 }
14725 
14726 static int
14727 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
14728 		struct crypto_unittest_params *ut_params,
14729 		const struct test_crypto_vector *reference,
14730 		unsigned int auth_generate)
14731 {
14732 	/* Generate Crypto op data structure */
14733 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14734 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14735 	TEST_ASSERT_NOT_NULL(ut_params->op,
14736 			"Failed to allocate pktmbuf offload");
14737 
14738 	/* Set crypto operation data parameters */
14739 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14740 
14741 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14742 
14743 	/* set crypto operation source mbuf */
14744 	sym_op->m_src = ut_params->ibuf;
14745 
14746 	/* digest */
14747 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14748 			ut_params->ibuf, reference->digest.len);
14749 
14750 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14751 			"no room to append auth tag");
14752 
14753 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14754 			ut_params->ibuf, reference->ciphertext.len);
14755 
14756 	if (auth_generate)
14757 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
14758 	else
14759 		memcpy(sym_op->auth.digest.data,
14760 				reference->digest.data,
14761 				reference->digest.len);
14762 
14763 	debug_hexdump(stdout, "digest:",
14764 			sym_op->auth.digest.data,
14765 			reference->digest.len);
14766 
14767 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
14768 			reference->iv.data, reference->iv.len);
14769 
14770 	sym_op->cipher.data.length = reference->cipher_len;
14771 	sym_op->cipher.data.offset = reference->cipher_offset;
14772 
14773 	sym_op->auth.data.length = reference->plaintext.len;
14774 	sym_op->auth.data.offset = reference->auth_offset;
14775 
14776 	return 0;
14777 }
14778 
14779 static int
14780 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
14781 		struct crypto_unittest_params *ut_params,
14782 		const struct test_crypto_vector *reference)
14783 {
14784 	return create_auth_operation(ts_params, ut_params, reference, 0);
14785 }
14786 
14787 static int
14788 create_auth_verify_GMAC_operation(
14789 		struct crypto_testsuite_params *ts_params,
14790 		struct crypto_unittest_params *ut_params,
14791 		const struct test_crypto_vector *reference)
14792 {
14793 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
14794 }
14795 
14796 static int
14797 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
14798 		struct crypto_unittest_params *ut_params,
14799 		const struct test_crypto_vector *reference)
14800 {
14801 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
14802 }
14803 
14804 static int
14805 test_authentication_verify_fail_when_data_corruption(
14806 		struct crypto_testsuite_params *ts_params,
14807 		struct crypto_unittest_params *ut_params,
14808 		const struct test_crypto_vector *reference,
14809 		unsigned int data_corrupted)
14810 {
14811 	int retval;
14812 
14813 	uint8_t *plaintext;
14814 	struct rte_cryptodev_info dev_info;
14815 
14816 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14817 	uint64_t feat_flags = dev_info.feature_flags;
14818 
14819 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14820 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14821 		printf("Device doesn't support RAW data-path APIs.\n");
14822 		return TEST_SKIPPED;
14823 	}
14824 
14825 	/* Verify the capabilities */
14826 	struct rte_cryptodev_sym_capability_idx cap_idx;
14827 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14828 	cap_idx.algo.auth = reference->auth_algo;
14829 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14830 			&cap_idx) == NULL)
14831 		return TEST_SKIPPED;
14832 
14833 
14834 	/* Create session */
14835 	retval = create_auth_session(ut_params,
14836 			ts_params->valid_devs[0],
14837 			reference,
14838 			RTE_CRYPTO_AUTH_OP_VERIFY);
14839 
14840 	if (retval == TEST_SKIPPED)
14841 		return TEST_SKIPPED;
14842 	if (retval < 0)
14843 		return retval;
14844 
14845 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14846 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14847 			"Failed to allocate input buffer in mempool");
14848 
14849 	/* clear mbuf payload */
14850 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14851 			rte_pktmbuf_tailroom(ut_params->ibuf));
14852 
14853 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14854 			reference->plaintext.len);
14855 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14856 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14857 
14858 	debug_hexdump(stdout, "plaintext:", plaintext,
14859 		reference->plaintext.len);
14860 
14861 	/* Create operation */
14862 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
14863 
14864 	if (retval < 0)
14865 		return retval;
14866 
14867 	if (data_corrupted)
14868 		data_corruption(plaintext);
14869 	else
14870 		tag_corruption(plaintext, reference->plaintext.len);
14871 
14872 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
14873 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14874 			ut_params->op);
14875 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
14876 			RTE_CRYPTO_OP_STATUS_SUCCESS,
14877 			"authentication not failed");
14878 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14879 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14880 					       0);
14881 		if (retval != TEST_SUCCESS)
14882 			return retval;
14883 	} else {
14884 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14885 			ut_params->op);
14886 	}
14887 	if (ut_params->op == NULL)
14888 		return 0;
14889 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
14890 		return 0;
14891 
14892 	return -1;
14893 }
14894 
14895 static int
14896 test_authentication_verify_GMAC_fail_when_corruption(
14897 		struct crypto_testsuite_params *ts_params,
14898 		struct crypto_unittest_params *ut_params,
14899 		const struct test_crypto_vector *reference,
14900 		unsigned int data_corrupted)
14901 {
14902 	int retval;
14903 	uint8_t *plaintext;
14904 	struct rte_cryptodev_info dev_info;
14905 
14906 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14907 	uint64_t feat_flags = dev_info.feature_flags;
14908 
14909 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14910 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14911 		printf("Device doesn't support RAW data-path APIs.\n");
14912 		return TEST_SKIPPED;
14913 	}
14914 
14915 	/* Verify the capabilities */
14916 	struct rte_cryptodev_sym_capability_idx cap_idx;
14917 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14918 	cap_idx.algo.auth = reference->auth_algo;
14919 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14920 			&cap_idx) == NULL)
14921 		return TEST_SKIPPED;
14922 
14923 	/* Create session */
14924 	retval = create_auth_cipher_session(ut_params,
14925 			ts_params->valid_devs[0],
14926 			reference,
14927 			RTE_CRYPTO_AUTH_OP_VERIFY,
14928 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
14929 	if (retval == TEST_SKIPPED)
14930 		return TEST_SKIPPED;
14931 	if (retval < 0)
14932 		return retval;
14933 
14934 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14935 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14936 			"Failed to allocate input buffer in mempool");
14937 
14938 	/* clear mbuf payload */
14939 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14940 			rte_pktmbuf_tailroom(ut_params->ibuf));
14941 
14942 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14943 			reference->plaintext.len);
14944 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14945 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14946 
14947 	debug_hexdump(stdout, "plaintext:", plaintext,
14948 		reference->plaintext.len);
14949 
14950 	/* Create operation */
14951 	retval = create_auth_verify_GMAC_operation(ts_params,
14952 			ut_params,
14953 			reference);
14954 
14955 	if (retval < 0)
14956 		return retval;
14957 
14958 	if (data_corrupted)
14959 		data_corruption(plaintext);
14960 	else
14961 		tag_corruption(plaintext, reference->aad.len);
14962 
14963 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
14964 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14965 			ut_params->op);
14966 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
14967 			RTE_CRYPTO_OP_STATUS_SUCCESS,
14968 			"authentication not failed");
14969 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14970 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14971 					       0);
14972 		if (retval != TEST_SUCCESS)
14973 			return retval;
14974 	} else {
14975 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14976 			ut_params->op);
14977 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
14978 	}
14979 
14980 	return 0;
14981 }
14982 
14983 static int
14984 test_authenticated_decryption_fail_when_corruption(
14985 		struct crypto_testsuite_params *ts_params,
14986 		struct crypto_unittest_params *ut_params,
14987 		const struct test_crypto_vector *reference,
14988 		unsigned int data_corrupted)
14989 {
14990 	int retval;
14991 
14992 	uint8_t *ciphertext;
14993 	struct rte_cryptodev_info dev_info;
14994 
14995 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14996 	uint64_t feat_flags = dev_info.feature_flags;
14997 
14998 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14999 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15000 		printf("Device doesn't support RAW data-path APIs.\n");
15001 		return TEST_SKIPPED;
15002 	}
15003 
15004 	/* Verify the capabilities */
15005 	struct rte_cryptodev_sym_capability_idx cap_idx;
15006 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15007 	cap_idx.algo.auth = reference->auth_algo;
15008 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15009 			&cap_idx) == NULL)
15010 		return TEST_SKIPPED;
15011 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15012 	cap_idx.algo.cipher = reference->crypto_algo;
15013 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15014 			&cap_idx) == NULL)
15015 		return TEST_SKIPPED;
15016 
15017 	/* Create session */
15018 	retval = create_auth_cipher_session(ut_params,
15019 			ts_params->valid_devs[0],
15020 			reference,
15021 			RTE_CRYPTO_AUTH_OP_VERIFY,
15022 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
15023 	if (retval == TEST_SKIPPED)
15024 		return TEST_SKIPPED;
15025 	if (retval < 0)
15026 		return retval;
15027 
15028 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15029 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15030 			"Failed to allocate input buffer in mempool");
15031 
15032 	/* clear mbuf payload */
15033 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15034 			rte_pktmbuf_tailroom(ut_params->ibuf));
15035 
15036 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15037 			reference->ciphertext.len);
15038 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15039 	memcpy(ciphertext, reference->ciphertext.data,
15040 			reference->ciphertext.len);
15041 
15042 	/* Create operation */
15043 	retval = create_cipher_auth_verify_operation(ts_params,
15044 			ut_params,
15045 			reference);
15046 
15047 	if (retval < 0)
15048 		return retval;
15049 
15050 	if (data_corrupted)
15051 		data_corruption(ciphertext);
15052 	else
15053 		tag_corruption(ciphertext, reference->ciphertext.len);
15054 
15055 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15056 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15057 			ut_params->op);
15058 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15059 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15060 			"authentication not failed");
15061 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15062 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15063 					       0);
15064 		if (retval != TEST_SUCCESS)
15065 			return retval;
15066 	} else {
15067 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15068 			ut_params->op);
15069 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15070 	}
15071 
15072 	return 0;
15073 }
15074 
15075 static int
15076 test_authenticated_encrypt_with_esn(
15077 		struct crypto_testsuite_params *ts_params,
15078 		struct crypto_unittest_params *ut_params,
15079 		const struct test_crypto_vector *reference)
15080 {
15081 	int retval;
15082 
15083 	uint8_t *authciphertext, *plaintext, *auth_tag;
15084 	uint16_t plaintext_pad_len;
15085 	uint8_t cipher_key[reference->cipher_key.len + 1];
15086 	uint8_t auth_key[reference->auth_key.len + 1];
15087 	struct rte_cryptodev_info dev_info;
15088 
15089 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15090 	uint64_t feat_flags = dev_info.feature_flags;
15091 
15092 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15093 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15094 		printf("Device doesn't support RAW data-path APIs.\n");
15095 		return TEST_SKIPPED;
15096 	}
15097 
15098 	/* Verify the capabilities */
15099 	struct rte_cryptodev_sym_capability_idx cap_idx;
15100 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15101 	cap_idx.algo.auth = reference->auth_algo;
15102 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15103 			&cap_idx) == NULL)
15104 		return TEST_SKIPPED;
15105 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15106 	cap_idx.algo.cipher = reference->crypto_algo;
15107 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15108 			&cap_idx) == NULL)
15109 		return TEST_SKIPPED;
15110 
15111 	/* Create session */
15112 	memcpy(cipher_key, reference->cipher_key.data,
15113 			reference->cipher_key.len);
15114 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15115 
15116 	/* Setup Cipher Parameters */
15117 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15118 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15119 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15120 	ut_params->cipher_xform.cipher.key.data = cipher_key;
15121 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15122 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15123 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15124 
15125 	ut_params->cipher_xform.next = &ut_params->auth_xform;
15126 
15127 	/* Setup Authentication Parameters */
15128 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15129 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15130 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15131 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15132 	ut_params->auth_xform.auth.key.data = auth_key;
15133 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15134 	ut_params->auth_xform.next = NULL;
15135 
15136 	/* Create Crypto session*/
15137 	ut_params->sess = rte_cryptodev_sym_session_create(
15138 			ts_params->valid_devs[0], &ut_params->cipher_xform,
15139 			ts_params->session_mpool);
15140 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15141 		return TEST_SKIPPED;
15142 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15143 
15144 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15145 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15146 			"Failed to allocate input buffer in mempool");
15147 
15148 	/* clear mbuf payload */
15149 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15150 			rte_pktmbuf_tailroom(ut_params->ibuf));
15151 
15152 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15153 			reference->plaintext.len);
15154 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15155 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15156 
15157 	/* Create operation */
15158 	retval = create_cipher_auth_operation(ts_params,
15159 			ut_params,
15160 			reference, 0);
15161 
15162 	if (retval < 0)
15163 		return retval;
15164 
15165 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15166 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15167 			ut_params->op);
15168 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15169 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15170 					       0);
15171 		if (retval != TEST_SUCCESS)
15172 			return retval;
15173 	} else
15174 		ut_params->op = process_crypto_request(
15175 			ts_params->valid_devs[0], ut_params->op);
15176 
15177 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
15178 
15179 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15180 			"crypto op processing failed");
15181 
15182 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
15183 
15184 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
15185 			ut_params->op->sym->auth.data.offset);
15186 	auth_tag = authciphertext + plaintext_pad_len;
15187 	debug_hexdump(stdout, "ciphertext:", authciphertext,
15188 			reference->ciphertext.len);
15189 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
15190 
15191 	/* Validate obuf */
15192 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15193 			authciphertext,
15194 			reference->ciphertext.data,
15195 			reference->ciphertext.len,
15196 			"Ciphertext data not as expected");
15197 
15198 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15199 			auth_tag,
15200 			reference->digest.data,
15201 			reference->digest.len,
15202 			"Generated digest not as expected");
15203 
15204 	return TEST_SUCCESS;
15205 
15206 }
15207 
15208 static int
15209 test_authenticated_decrypt_with_esn(
15210 		struct crypto_testsuite_params *ts_params,
15211 		struct crypto_unittest_params *ut_params,
15212 		const struct test_crypto_vector *reference)
15213 {
15214 	int retval;
15215 
15216 	uint8_t *ciphertext;
15217 	uint8_t cipher_key[reference->cipher_key.len + 1];
15218 	uint8_t auth_key[reference->auth_key.len + 1];
15219 	struct rte_cryptodev_info dev_info;
15220 
15221 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15222 	uint64_t feat_flags = dev_info.feature_flags;
15223 
15224 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15225 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15226 		printf("Device doesn't support RAW data-path APIs.\n");
15227 		return TEST_SKIPPED;
15228 	}
15229 
15230 	/* Verify the capabilities */
15231 	struct rte_cryptodev_sym_capability_idx cap_idx;
15232 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15233 	cap_idx.algo.auth = reference->auth_algo;
15234 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15235 			&cap_idx) == NULL)
15236 		return TEST_SKIPPED;
15237 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15238 	cap_idx.algo.cipher = reference->crypto_algo;
15239 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15240 			&cap_idx) == NULL)
15241 		return TEST_SKIPPED;
15242 
15243 	/* Create session */
15244 	memcpy(cipher_key, reference->cipher_key.data,
15245 			reference->cipher_key.len);
15246 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15247 
15248 	/* Setup Authentication Parameters */
15249 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15250 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
15251 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15252 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15253 	ut_params->auth_xform.auth.key.data = auth_key;
15254 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15255 	ut_params->auth_xform.next = &ut_params->cipher_xform;
15256 
15257 	/* Setup Cipher Parameters */
15258 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15259 	ut_params->cipher_xform.next = NULL;
15260 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15261 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
15262 	ut_params->cipher_xform.cipher.key.data = cipher_key;
15263 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15264 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15265 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15266 
15267 	/* Create Crypto session*/
15268 	ut_params->sess = rte_cryptodev_sym_session_create(
15269 			ts_params->valid_devs[0], &ut_params->auth_xform,
15270 			ts_params->session_mpool);
15271 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15272 		return TEST_SKIPPED;
15273 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15274 
15275 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15276 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15277 			"Failed to allocate input buffer in mempool");
15278 
15279 	/* clear mbuf payload */
15280 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15281 			rte_pktmbuf_tailroom(ut_params->ibuf));
15282 
15283 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15284 			reference->ciphertext.len);
15285 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15286 	memcpy(ciphertext, reference->ciphertext.data,
15287 			reference->ciphertext.len);
15288 
15289 	/* Create operation */
15290 	retval = create_cipher_auth_verify_operation(ts_params,
15291 			ut_params,
15292 			reference);
15293 
15294 	if (retval < 0)
15295 		return retval;
15296 
15297 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15298 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15299 			ut_params->op);
15300 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15301 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15302 					       0);
15303 		if (retval != TEST_SUCCESS)
15304 			return retval;
15305 	} else
15306 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15307 			ut_params->op);
15308 
15309 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
15310 	TEST_ASSERT_EQUAL(ut_params->op->status,
15311 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15312 			"crypto op processing passed");
15313 
15314 	ut_params->obuf = ut_params->op->sym->m_src;
15315 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
15316 
15317 	return 0;
15318 }
15319 
15320 static int
15321 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
15322 		const struct aead_test_data *tdata,
15323 		void *digest_mem, uint64_t digest_phys)
15324 {
15325 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15326 	struct crypto_unittest_params *ut_params = &unittest_params;
15327 
15328 	const unsigned int auth_tag_len = tdata->auth_tag.len;
15329 	const unsigned int iv_len = tdata->iv.len;
15330 	unsigned int aad_len = tdata->aad.len;
15331 	unsigned int aad_len_pad = 0;
15332 
15333 	/* Generate Crypto op data structure */
15334 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15335 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15336 	TEST_ASSERT_NOT_NULL(ut_params->op,
15337 		"Failed to allocate symmetric crypto operation struct");
15338 
15339 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15340 
15341 	sym_op->aead.digest.data = digest_mem;
15342 
15343 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
15344 			"no room to append digest");
15345 
15346 	sym_op->aead.digest.phys_addr = digest_phys;
15347 
15348 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
15349 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
15350 				auth_tag_len);
15351 		debug_hexdump(stdout, "digest:",
15352 				sym_op->aead.digest.data,
15353 				auth_tag_len);
15354 	}
15355 
15356 	/* Append aad data */
15357 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
15358 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15359 				uint8_t *, IV_OFFSET);
15360 
15361 		/* Copy IV 1 byte after the IV pointer, according to the API */
15362 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
15363 
15364 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
15365 
15366 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15367 				ut_params->ibuf, aad_len);
15368 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15369 				"no room to prepend aad");
15370 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15371 				ut_params->ibuf);
15372 
15373 		memset(sym_op->aead.aad.data, 0, aad_len);
15374 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
15375 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15376 
15377 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15378 		debug_hexdump(stdout, "aad:",
15379 				sym_op->aead.aad.data, aad_len);
15380 	} else {
15381 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15382 				uint8_t *, IV_OFFSET);
15383 
15384 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
15385 
15386 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
15387 
15388 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15389 				ut_params->ibuf, aad_len_pad);
15390 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15391 				"no room to prepend aad");
15392 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15393 				ut_params->ibuf);
15394 
15395 		memset(sym_op->aead.aad.data, 0, aad_len);
15396 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15397 
15398 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15399 		debug_hexdump(stdout, "aad:",
15400 				sym_op->aead.aad.data, aad_len);
15401 	}
15402 
15403 	sym_op->aead.data.length = tdata->plaintext.len;
15404 	sym_op->aead.data.offset = aad_len_pad;
15405 
15406 	return 0;
15407 }
15408 
15409 #define SGL_MAX_NO	16
15410 
15411 static int
15412 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
15413 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
15414 {
15415 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15416 	struct crypto_unittest_params *ut_params = &unittest_params;
15417 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
15418 	int retval;
15419 	int to_trn = 0;
15420 	int to_trn_tbl[SGL_MAX_NO];
15421 	int segs = 1;
15422 	unsigned int trn_data = 0;
15423 	uint8_t *plaintext, *ciphertext, *auth_tag;
15424 	struct rte_cryptodev_info dev_info;
15425 
15426 	/* Verify the capabilities */
15427 	struct rte_cryptodev_sym_capability_idx cap_idx;
15428 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
15429 	cap_idx.algo.aead = tdata->algo;
15430 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15431 			&cap_idx) == NULL)
15432 		return TEST_SKIPPED;
15433 
15434 	/*
15435 	 * SGL not supported on AESNI_MB PMD CPU crypto,
15436 	 * OOP not supported on AESNI_GCM CPU crypto
15437 	 */
15438 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
15439 			(gbl_driver_id == rte_cryptodev_driver_id_get(
15440 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
15441 		return TEST_SKIPPED;
15442 
15443 	/* Detailed check for the particular SGL support flag */
15444 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15445 	if (!oop) {
15446 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
15447 		if (sgl_in && (!(dev_info.feature_flags &
15448 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
15449 			return TEST_SKIPPED;
15450 
15451 		uint64_t feat_flags = dev_info.feature_flags;
15452 
15453 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15454 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15455 			printf("Device doesn't support RAW data-path APIs.\n");
15456 			return TEST_SKIPPED;
15457 		}
15458 	} else {
15459 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
15460 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
15461 				tdata->plaintext.len;
15462 		/* Raw data path API does not support OOP */
15463 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
15464 			return TEST_SKIPPED;
15465 		if (sgl_in && !sgl_out) {
15466 			if (!(dev_info.feature_flags &
15467 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
15468 				return TEST_SKIPPED;
15469 		} else if (!sgl_in && sgl_out) {
15470 			if (!(dev_info.feature_flags &
15471 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
15472 				return TEST_SKIPPED;
15473 		} else if (sgl_in && sgl_out) {
15474 			if (!(dev_info.feature_flags &
15475 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
15476 				return TEST_SKIPPED;
15477 		}
15478 	}
15479 
15480 	if (fragsz > tdata->plaintext.len)
15481 		fragsz = tdata->plaintext.len;
15482 
15483 	uint16_t plaintext_len = fragsz;
15484 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
15485 
15486 	if (fragsz_oop > tdata->plaintext.len)
15487 		frag_size_oop = tdata->plaintext.len;
15488 
15489 	int ecx = 0;
15490 	void *digest_mem = NULL;
15491 
15492 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
15493 
15494 	if (tdata->plaintext.len % fragsz != 0) {
15495 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
15496 			return 1;
15497 	}	else {
15498 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
15499 			return 1;
15500 	}
15501 
15502 	/*
15503 	 * For out-op-place we need to alloc another mbuf
15504 	 */
15505 	if (oop) {
15506 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15507 		rte_pktmbuf_append(ut_params->obuf,
15508 				frag_size_oop + prepend_len);
15509 		buf_oop = ut_params->obuf;
15510 	}
15511 
15512 	/* Create AEAD session */
15513 	retval = create_aead_session(ts_params->valid_devs[0],
15514 			tdata->algo,
15515 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
15516 			tdata->key.data, tdata->key.len,
15517 			tdata->aad.len, tdata->auth_tag.len,
15518 			tdata->iv.len);
15519 	if (retval < 0)
15520 		return retval;
15521 
15522 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15523 
15524 	/* clear mbuf payload */
15525 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15526 			rte_pktmbuf_tailroom(ut_params->ibuf));
15527 
15528 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15529 			plaintext_len);
15530 
15531 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15532 
15533 	trn_data += plaintext_len;
15534 
15535 	buf = ut_params->ibuf;
15536 
15537 	/*
15538 	 * Loop until no more fragments
15539 	 */
15540 
15541 	while (trn_data < tdata->plaintext.len) {
15542 		++segs;
15543 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15544 				(tdata->plaintext.len - trn_data) : fragsz;
15545 
15546 		to_trn_tbl[ecx++] = to_trn;
15547 
15548 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15549 		buf = buf->next;
15550 
15551 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15552 				rte_pktmbuf_tailroom(buf));
15553 
15554 		/* OOP */
15555 		if (oop && !fragsz_oop) {
15556 			buf_last_oop = buf_oop->next =
15557 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
15558 			buf_oop = buf_oop->next;
15559 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15560 					0, rte_pktmbuf_tailroom(buf_oop));
15561 			rte_pktmbuf_append(buf_oop, to_trn);
15562 		}
15563 
15564 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15565 				to_trn);
15566 
15567 		memcpy(plaintext, tdata->plaintext.data + trn_data,
15568 				to_trn);
15569 		trn_data += to_trn;
15570 		if (trn_data  == tdata->plaintext.len) {
15571 			if (oop) {
15572 				if (!fragsz_oop)
15573 					digest_mem = rte_pktmbuf_append(buf_oop,
15574 						tdata->auth_tag.len);
15575 			} else
15576 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15577 					tdata->auth_tag.len);
15578 		}
15579 	}
15580 
15581 	uint64_t digest_phys = 0;
15582 
15583 	ut_params->ibuf->nb_segs = segs;
15584 
15585 	segs = 1;
15586 	if (fragsz_oop && oop) {
15587 		to_trn = 0;
15588 		ecx = 0;
15589 
15590 		if (frag_size_oop == tdata->plaintext.len) {
15591 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
15592 				tdata->auth_tag.len);
15593 
15594 			digest_phys = rte_pktmbuf_iova_offset(
15595 					ut_params->obuf,
15596 					tdata->plaintext.len + prepend_len);
15597 		}
15598 
15599 		trn_data = frag_size_oop;
15600 		while (trn_data < tdata->plaintext.len) {
15601 			++segs;
15602 			to_trn =
15603 				(tdata->plaintext.len - trn_data <
15604 						frag_size_oop) ?
15605 				(tdata->plaintext.len - trn_data) :
15606 						frag_size_oop;
15607 
15608 			to_trn_tbl[ecx++] = to_trn;
15609 
15610 			buf_last_oop = buf_oop->next =
15611 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
15612 			buf_oop = buf_oop->next;
15613 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15614 					0, rte_pktmbuf_tailroom(buf_oop));
15615 			rte_pktmbuf_append(buf_oop, to_trn);
15616 
15617 			trn_data += to_trn;
15618 
15619 			if (trn_data  == tdata->plaintext.len) {
15620 				digest_mem = rte_pktmbuf_append(buf_oop,
15621 					tdata->auth_tag.len);
15622 			}
15623 		}
15624 
15625 		ut_params->obuf->nb_segs = segs;
15626 	}
15627 
15628 	/*
15629 	 * Place digest at the end of the last buffer
15630 	 */
15631 	if (!digest_phys)
15632 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15633 	if (oop && buf_last_oop)
15634 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
15635 
15636 	if (!digest_mem && !oop) {
15637 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15638 				+ tdata->auth_tag.len);
15639 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15640 				tdata->plaintext.len);
15641 	}
15642 
15643 	/* Create AEAD operation */
15644 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
15645 			tdata, digest_mem, digest_phys);
15646 
15647 	if (retval < 0)
15648 		return retval;
15649 
15650 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15651 
15652 	ut_params->op->sym->m_src = ut_params->ibuf;
15653 	if (oop)
15654 		ut_params->op->sym->m_dst = ut_params->obuf;
15655 
15656 	/* Process crypto operation */
15657 	if (oop == IN_PLACE &&
15658 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15659 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
15660 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15661 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
15662 					       0);
15663 		if (retval != TEST_SUCCESS)
15664 			return retval;
15665 	} else
15666 		TEST_ASSERT_NOT_NULL(
15667 			process_crypto_request(ts_params->valid_devs[0],
15668 			ut_params->op), "failed to process sym crypto op");
15669 
15670 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15671 			"crypto op processing failed");
15672 
15673 
15674 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
15675 			uint8_t *, prepend_len);
15676 	if (oop) {
15677 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15678 				uint8_t *, prepend_len);
15679 	}
15680 
15681 	if (fragsz_oop)
15682 		fragsz = fragsz_oop;
15683 
15684 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15685 			ciphertext,
15686 			tdata->ciphertext.data,
15687 			fragsz,
15688 			"Ciphertext data not as expected");
15689 
15690 	buf = ut_params->op->sym->m_src->next;
15691 	if (oop)
15692 		buf = ut_params->op->sym->m_dst->next;
15693 
15694 	unsigned int off = fragsz;
15695 
15696 	ecx = 0;
15697 	while (buf) {
15698 		ciphertext = rte_pktmbuf_mtod(buf,
15699 				uint8_t *);
15700 
15701 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
15702 				ciphertext,
15703 				tdata->ciphertext.data + off,
15704 				to_trn_tbl[ecx],
15705 				"Ciphertext data not as expected");
15706 
15707 		off += to_trn_tbl[ecx++];
15708 		buf = buf->next;
15709 	}
15710 
15711 	auth_tag = digest_mem;
15712 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15713 			auth_tag,
15714 			tdata->auth_tag.data,
15715 			tdata->auth_tag.len,
15716 			"Generated auth tag not as expected");
15717 
15718 	return 0;
15719 }
15720 
15721 static int
15722 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
15723 {
15724 	return test_authenticated_encryption_SGL(
15725 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
15726 }
15727 
15728 static int
15729 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
15730 {
15731 	return test_authenticated_encryption_SGL(
15732 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
15733 }
15734 
15735 static int
15736 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
15737 {
15738 	return test_authenticated_encryption_SGL(
15739 			&gcm_test_case_8, OUT_OF_PLACE, 400,
15740 			gcm_test_case_8.plaintext.len);
15741 }
15742 
15743 static int
15744 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
15745 {
15746 	/* This test is not for OPENSSL PMD */
15747 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
15748 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
15749 		return TEST_SKIPPED;
15750 
15751 	return test_authenticated_encryption_SGL(
15752 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
15753 }
15754 
15755 static int
15756 test_authentication_verify_fail_when_data_corrupted(
15757 		struct crypto_testsuite_params *ts_params,
15758 		struct crypto_unittest_params *ut_params,
15759 		const struct test_crypto_vector *reference)
15760 {
15761 	return test_authentication_verify_fail_when_data_corruption(
15762 			ts_params, ut_params, reference, 1);
15763 }
15764 
15765 static int
15766 test_authentication_verify_fail_when_tag_corrupted(
15767 		struct crypto_testsuite_params *ts_params,
15768 		struct crypto_unittest_params *ut_params,
15769 		const struct test_crypto_vector *reference)
15770 {
15771 	return test_authentication_verify_fail_when_data_corruption(
15772 			ts_params, ut_params, reference, 0);
15773 }
15774 
15775 static int
15776 test_authentication_verify_GMAC_fail_when_data_corrupted(
15777 		struct crypto_testsuite_params *ts_params,
15778 		struct crypto_unittest_params *ut_params,
15779 		const struct test_crypto_vector *reference)
15780 {
15781 	return test_authentication_verify_GMAC_fail_when_corruption(
15782 			ts_params, ut_params, reference, 1);
15783 }
15784 
15785 static int
15786 test_authentication_verify_GMAC_fail_when_tag_corrupted(
15787 		struct crypto_testsuite_params *ts_params,
15788 		struct crypto_unittest_params *ut_params,
15789 		const struct test_crypto_vector *reference)
15790 {
15791 	return test_authentication_verify_GMAC_fail_when_corruption(
15792 			ts_params, ut_params, reference, 0);
15793 }
15794 
15795 static int
15796 test_authenticated_decryption_fail_when_data_corrupted(
15797 		struct crypto_testsuite_params *ts_params,
15798 		struct crypto_unittest_params *ut_params,
15799 		const struct test_crypto_vector *reference)
15800 {
15801 	return test_authenticated_decryption_fail_when_corruption(
15802 			ts_params, ut_params, reference, 1);
15803 }
15804 
15805 static int
15806 test_authenticated_decryption_fail_when_tag_corrupted(
15807 		struct crypto_testsuite_params *ts_params,
15808 		struct crypto_unittest_params *ut_params,
15809 		const struct test_crypto_vector *reference)
15810 {
15811 	return test_authenticated_decryption_fail_when_corruption(
15812 			ts_params, ut_params, reference, 0);
15813 }
15814 
15815 static int
15816 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
15817 {
15818 	return test_authentication_verify_fail_when_data_corrupted(
15819 			&testsuite_params, &unittest_params,
15820 			&hmac_sha1_test_crypto_vector);
15821 }
15822 
15823 static int
15824 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
15825 {
15826 	return test_authentication_verify_fail_when_tag_corrupted(
15827 			&testsuite_params, &unittest_params,
15828 			&hmac_sha1_test_crypto_vector);
15829 }
15830 
15831 static int
15832 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
15833 {
15834 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
15835 			&testsuite_params, &unittest_params,
15836 			&aes128_gmac_test_vector);
15837 }
15838 
15839 static int
15840 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
15841 {
15842 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
15843 			&testsuite_params, &unittest_params,
15844 			&aes128_gmac_test_vector);
15845 }
15846 
15847 static int
15848 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
15849 {
15850 	return test_authenticated_decryption_fail_when_data_corrupted(
15851 			&testsuite_params,
15852 			&unittest_params,
15853 			&aes128cbc_hmac_sha1_test_vector);
15854 }
15855 
15856 static int
15857 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
15858 {
15859 	return test_authenticated_decryption_fail_when_tag_corrupted(
15860 			&testsuite_params,
15861 			&unittest_params,
15862 			&aes128cbc_hmac_sha1_test_vector);
15863 }
15864 
15865 static int
15866 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
15867 {
15868 	return test_authenticated_encrypt_with_esn(
15869 			&testsuite_params,
15870 			&unittest_params,
15871 			&aes128cbc_hmac_sha1_aad_test_vector);
15872 }
15873 
15874 static int
15875 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
15876 {
15877 	return test_authenticated_decrypt_with_esn(
15878 			&testsuite_params,
15879 			&unittest_params,
15880 			&aes128cbc_hmac_sha1_aad_test_vector);
15881 }
15882 
15883 static int
15884 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
15885 {
15886 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
15887 }
15888 
15889 static int
15890 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
15891 {
15892 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
15893 }
15894 
15895 static int
15896 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
15897 {
15898 	return test_authenticated_encryption_SGL(
15899 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
15900 		chacha20_poly1305_case_2.plaintext.len);
15901 }
15902 
15903 #ifdef RTE_CRYPTO_SCHEDULER
15904 
15905 /* global AESNI worker IDs for the scheduler test */
15906 uint8_t aesni_ids[2];
15907 
15908 static int
15909 scheduler_testsuite_setup(void)
15910 {
15911 	uint32_t i = 0;
15912 	int32_t nb_devs, ret;
15913 	char vdev_args[VDEV_ARGS_SIZE] = {""};
15914 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
15915 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
15916 	uint16_t worker_core_count = 0;
15917 	uint16_t socket_id = 0;
15918 
15919 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
15920 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
15921 
15922 		/* Identify the Worker Cores
15923 		 * Use 2 worker cores for the device args
15924 		 */
15925 		RTE_LCORE_FOREACH_WORKER(i) {
15926 			if (worker_core_count > 1)
15927 				break;
15928 			snprintf(vdev_args, sizeof(vdev_args),
15929 					"%s%d", temp_str, i);
15930 			strcpy(temp_str, vdev_args);
15931 			strlcat(temp_str, ";", sizeof(temp_str));
15932 			worker_core_count++;
15933 			socket_id = rte_lcore_to_socket_id(i);
15934 		}
15935 		if (worker_core_count != 2) {
15936 			RTE_LOG(ERR, USER1,
15937 				"Cryptodev scheduler test require at least "
15938 				"two worker cores to run. "
15939 				"Please use the correct coremask.\n");
15940 			return TEST_FAILED;
15941 		}
15942 		strcpy(temp_str, vdev_args);
15943 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
15944 				temp_str, socket_id);
15945 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
15946 		nb_devs = rte_cryptodev_device_count_by_driver(
15947 				rte_cryptodev_driver_id_get(
15948 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
15949 		if (nb_devs < 1) {
15950 			ret = rte_vdev_init(
15951 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
15952 					vdev_args);
15953 			TEST_ASSERT(ret == 0,
15954 				"Failed to create instance %u of pmd : %s",
15955 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15956 		}
15957 	}
15958 	return testsuite_setup();
15959 }
15960 
15961 static int
15962 test_scheduler_attach_worker_op(void)
15963 {
15964 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15965 	uint8_t sched_id = ts_params->valid_devs[0];
15966 	uint32_t i, nb_devs_attached = 0;
15967 	int ret;
15968 	char vdev_name[32];
15969 	unsigned int count = rte_cryptodev_count();
15970 
15971 	/* create 2 AESNI_MB vdevs on top of existing devices */
15972 	for (i = count; i < count + 2; i++) {
15973 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
15974 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
15975 				i);
15976 		ret = rte_vdev_init(vdev_name, NULL);
15977 
15978 		TEST_ASSERT(ret == 0,
15979 			"Failed to create instance %u of"
15980 			" pmd : %s",
15981 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15982 
15983 		if (ret < 0) {
15984 			RTE_LOG(ERR, USER1,
15985 				"Failed to create 2 AESNI MB PMDs.\n");
15986 			return TEST_SKIPPED;
15987 		}
15988 	}
15989 
15990 	/* attach 2 AESNI_MB cdevs */
15991 	for (i = count; i < count + 2; i++) {
15992 		struct rte_cryptodev_info info;
15993 		unsigned int session_size;
15994 
15995 		rte_cryptodev_info_get(i, &info);
15996 		if (info.driver_id != rte_cryptodev_driver_id_get(
15997 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
15998 			continue;
15999 
16000 		session_size = rte_cryptodev_sym_get_private_session_size(i);
16001 		/*
16002 		 * Create the session mempool again, since now there are new devices
16003 		 * to use the mempool.
16004 		 */
16005 		if (ts_params->session_mpool) {
16006 			rte_mempool_free(ts_params->session_mpool);
16007 			ts_params->session_mpool = NULL;
16008 		}
16009 
16010 		if (info.sym.max_nb_sessions != 0 &&
16011 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
16012 			RTE_LOG(ERR, USER1,
16013 					"Device does not support "
16014 					"at least %u sessions\n",
16015 					MAX_NB_SESSIONS);
16016 			return TEST_FAILED;
16017 		}
16018 		/*
16019 		 * Create mempool with maximum number of sessions,
16020 		 * to include the session headers
16021 		 */
16022 		if (ts_params->session_mpool == NULL) {
16023 			ts_params->session_mpool =
16024 				rte_cryptodev_sym_session_pool_create(
16025 						"test_sess_mp",
16026 						MAX_NB_SESSIONS, session_size,
16027 						0, 0, SOCKET_ID_ANY);
16028 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
16029 					"session mempool allocation failed");
16030 		}
16031 
16032 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
16033 
16034 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
16035 				(uint8_t)i);
16036 
16037 		TEST_ASSERT(ret == 0,
16038 			"Failed to attach device %u of pmd : %s", i,
16039 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16040 
16041 		aesni_ids[nb_devs_attached] = (uint8_t)i;
16042 
16043 		nb_devs_attached++;
16044 	}
16045 
16046 	return 0;
16047 }
16048 
16049 static int
16050 test_scheduler_detach_worker_op(void)
16051 {
16052 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16053 	uint8_t sched_id = ts_params->valid_devs[0];
16054 	uint32_t i;
16055 	int ret;
16056 
16057 	for (i = 0; i < 2; i++) {
16058 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
16059 				aesni_ids[i]);
16060 		TEST_ASSERT(ret == 0,
16061 			"Failed to detach device %u", aesni_ids[i]);
16062 	}
16063 
16064 	return 0;
16065 }
16066 
16067 static int
16068 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
16069 {
16070 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16071 	uint8_t sched_id = ts_params->valid_devs[0];
16072 	/* set mode */
16073 	return rte_cryptodev_scheduler_mode_set(sched_id,
16074 		scheduler_mode);
16075 }
16076 
16077 static int
16078 test_scheduler_mode_roundrobin_op(void)
16079 {
16080 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
16081 			0, "Failed to set roundrobin mode");
16082 	return 0;
16083 
16084 }
16085 
16086 static int
16087 test_scheduler_mode_multicore_op(void)
16088 {
16089 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
16090 			0, "Failed to set multicore mode");
16091 
16092 	return 0;
16093 }
16094 
16095 static int
16096 test_scheduler_mode_failover_op(void)
16097 {
16098 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
16099 			0, "Failed to set failover mode");
16100 
16101 	return 0;
16102 }
16103 
16104 static int
16105 test_scheduler_mode_pkt_size_distr_op(void)
16106 {
16107 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
16108 			0, "Failed to set pktsize mode");
16109 
16110 	return 0;
16111 }
16112 
16113 static int
16114 scheduler_multicore_testsuite_setup(void)
16115 {
16116 	if (test_scheduler_attach_worker_op() < 0)
16117 		return TEST_SKIPPED;
16118 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
16119 		return TEST_SKIPPED;
16120 	return 0;
16121 }
16122 
16123 static int
16124 scheduler_roundrobin_testsuite_setup(void)
16125 {
16126 	if (test_scheduler_attach_worker_op() < 0)
16127 		return TEST_SKIPPED;
16128 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
16129 		return TEST_SKIPPED;
16130 	return 0;
16131 }
16132 
16133 static int
16134 scheduler_failover_testsuite_setup(void)
16135 {
16136 	if (test_scheduler_attach_worker_op() < 0)
16137 		return TEST_SKIPPED;
16138 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
16139 		return TEST_SKIPPED;
16140 	return 0;
16141 }
16142 
16143 static int
16144 scheduler_pkt_size_distr_testsuite_setup(void)
16145 {
16146 	if (test_scheduler_attach_worker_op() < 0)
16147 		return TEST_SKIPPED;
16148 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
16149 		return TEST_SKIPPED;
16150 	return 0;
16151 }
16152 
16153 static void
16154 scheduler_mode_testsuite_teardown(void)
16155 {
16156 	test_scheduler_detach_worker_op();
16157 }
16158 
16159 #endif /* RTE_CRYPTO_SCHEDULER */
16160 
16161 static struct unit_test_suite end_testsuite = {
16162 	.suite_name = NULL,
16163 	.setup = NULL,
16164 	.teardown = NULL,
16165 	.unit_test_suites = NULL
16166 };
16167 
16168 #ifdef RTE_LIB_SECURITY
16169 static struct unit_test_suite ipsec_proto_testsuite  = {
16170 	.suite_name = "IPsec Proto Unit Test Suite",
16171 	.setup = ipsec_proto_testsuite_setup,
16172 	.unit_test_cases = {
16173 		TEST_CASE_NAMED_WITH_DATA(
16174 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16175 			ut_setup_security, ut_teardown,
16176 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
16177 		TEST_CASE_NAMED_WITH_DATA(
16178 			"Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
16179 			ut_setup_security, ut_teardown,
16180 			test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
16181 		TEST_CASE_NAMED_WITH_DATA(
16182 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16183 			ut_setup_security, ut_teardown,
16184 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
16185 		TEST_CASE_NAMED_WITH_DATA(
16186 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16187 			ut_setup_security, ut_teardown,
16188 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
16189 		TEST_CASE_NAMED_WITH_DATA(
16190 			"Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16191 			ut_setup_security, ut_teardown,
16192 			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
16193 		TEST_CASE_NAMED_WITH_DATA(
16194 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16195 			ut_setup_security, ut_teardown,
16196 			test_ipsec_proto_known_vec,
16197 			&pkt_aes_128_cbc_md5),
16198 		TEST_CASE_NAMED_WITH_DATA(
16199 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16200 			ut_setup_security, ut_teardown,
16201 			test_ipsec_proto_known_vec,
16202 			&pkt_aes_128_cbc_hmac_sha256),
16203 		TEST_CASE_NAMED_WITH_DATA(
16204 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16205 			ut_setup_security, ut_teardown,
16206 			test_ipsec_proto_known_vec,
16207 			&pkt_aes_128_cbc_hmac_sha384),
16208 		TEST_CASE_NAMED_WITH_DATA(
16209 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16210 			ut_setup_security, ut_teardown,
16211 			test_ipsec_proto_known_vec,
16212 			&pkt_aes_128_cbc_hmac_sha512),
16213 		TEST_CASE_NAMED_WITH_DATA(
16214 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16215 			ut_setup_security, ut_teardown,
16216 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
16217 		TEST_CASE_NAMED_WITH_DATA(
16218 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16219 			ut_setup_security, ut_teardown,
16220 			test_ipsec_proto_known_vec,
16221 			&pkt_aes_128_cbc_hmac_sha256_v6),
16222 		TEST_CASE_NAMED_WITH_DATA(
16223 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16224 			ut_setup_security, ut_teardown,
16225 			test_ipsec_proto_known_vec,
16226 			&pkt_null_aes_xcbc),
16227 		TEST_CASE_NAMED_WITH_DATA(
16228 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16229 			ut_setup_security, ut_teardown,
16230 			test_ipsec_proto_known_vec,
16231 			&pkt_des_cbc_hmac_sha256),
16232 		TEST_CASE_NAMED_WITH_DATA(
16233 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16234 			ut_setup_security, ut_teardown,
16235 			test_ipsec_proto_known_vec,
16236 			&pkt_des_cbc_hmac_sha384),
16237 		TEST_CASE_NAMED_WITH_DATA(
16238 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16239 			ut_setup_security, ut_teardown,
16240 			test_ipsec_proto_known_vec,
16241 			&pkt_des_cbc_hmac_sha512),
16242 		TEST_CASE_NAMED_WITH_DATA(
16243 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16244 			ut_setup_security, ut_teardown,
16245 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
16246 		TEST_CASE_NAMED_WITH_DATA(
16247 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16248 			ut_setup_security, ut_teardown,
16249 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
16250 		TEST_CASE_NAMED_WITH_DATA(
16251 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16252 			ut_setup_security, ut_teardown,
16253 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
16254 		TEST_CASE_NAMED_WITH_DATA(
16255 			"Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16256 			ut_setup_security, ut_teardown,
16257 			test_ipsec_proto_known_vec,
16258 			&pkt_des_cbc_hmac_sha256_v6),
16259 		TEST_CASE_NAMED_WITH_DATA(
16260 			"Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16261 			ut_setup_security, ut_teardown,
16262 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
16263 		TEST_CASE_NAMED_WITH_DATA(
16264 			"Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16265 			ut_setup_security, ut_teardown,
16266 			test_ipsec_proto_known_vec,
16267 			&pkt_ah_tunnel_sha256),
16268 		TEST_CASE_NAMED_WITH_DATA(
16269 			"Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16270 			ut_setup_security, ut_teardown,
16271 			test_ipsec_proto_known_vec,
16272 			&pkt_ah_transport_sha256),
16273 		TEST_CASE_NAMED_WITH_DATA(
16274 			"Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16275 			ut_setup_security, ut_teardown,
16276 			test_ipsec_proto_known_vec,
16277 			&pkt_ah_ipv4_aes_gmac_128),
16278 		TEST_CASE_NAMED_WITH_DATA(
16279 			"Outbound fragmented packet",
16280 			ut_setup_security, ut_teardown,
16281 			test_ipsec_proto_known_vec_fragmented,
16282 			&pkt_aes_128_gcm_frag),
16283 		TEST_CASE_NAMED_WITH_DATA(
16284 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16285 			ut_setup_security, ut_teardown,
16286 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
16287 		TEST_CASE_NAMED_WITH_DATA(
16288 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16289 			ut_setup_security, ut_teardown,
16290 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
16291 		TEST_CASE_NAMED_WITH_DATA(
16292 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16293 			ut_setup_security, ut_teardown,
16294 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
16295 		TEST_CASE_NAMED_WITH_DATA(
16296 			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16297 			ut_setup_security, ut_teardown,
16298 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
16299 		TEST_CASE_NAMED_WITH_DATA(
16300 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
16301 			ut_setup_security, ut_teardown,
16302 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
16303 		TEST_CASE_NAMED_WITH_DATA(
16304 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16305 			ut_setup_security, ut_teardown,
16306 			test_ipsec_proto_known_vec_inb,
16307 			&pkt_aes_128_cbc_md5),
16308 		TEST_CASE_NAMED_WITH_DATA(
16309 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16310 			ut_setup_security, ut_teardown,
16311 			test_ipsec_proto_known_vec_inb,
16312 			&pkt_aes_128_cbc_hmac_sha256),
16313 		TEST_CASE_NAMED_WITH_DATA(
16314 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16315 			ut_setup_security, ut_teardown,
16316 			test_ipsec_proto_known_vec_inb,
16317 			&pkt_aes_128_cbc_hmac_sha384),
16318 		TEST_CASE_NAMED_WITH_DATA(
16319 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16320 			ut_setup_security, ut_teardown,
16321 			test_ipsec_proto_known_vec_inb,
16322 			&pkt_aes_128_cbc_hmac_sha512),
16323 		TEST_CASE_NAMED_WITH_DATA(
16324 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16325 			ut_setup_security, ut_teardown,
16326 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
16327 		TEST_CASE_NAMED_WITH_DATA(
16328 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16329 			ut_setup_security, ut_teardown,
16330 			test_ipsec_proto_known_vec_inb,
16331 			&pkt_aes_128_cbc_hmac_sha256_v6),
16332 		TEST_CASE_NAMED_WITH_DATA(
16333 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16334 			ut_setup_security, ut_teardown,
16335 			test_ipsec_proto_known_vec_inb,
16336 			&pkt_null_aes_xcbc),
16337 		TEST_CASE_NAMED_WITH_DATA(
16338 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16339 			ut_setup_security, ut_teardown,
16340 			test_ipsec_proto_known_vec_inb,
16341 			&pkt_des_cbc_hmac_sha256),
16342 		TEST_CASE_NAMED_WITH_DATA(
16343 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16344 			ut_setup_security, ut_teardown,
16345 			test_ipsec_proto_known_vec_inb,
16346 			&pkt_des_cbc_hmac_sha384),
16347 		TEST_CASE_NAMED_WITH_DATA(
16348 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16349 			ut_setup_security, ut_teardown,
16350 			test_ipsec_proto_known_vec_inb,
16351 			&pkt_des_cbc_hmac_sha512),
16352 		TEST_CASE_NAMED_WITH_DATA(
16353 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16354 			ut_setup_security, ut_teardown,
16355 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
16356 		TEST_CASE_NAMED_WITH_DATA(
16357 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16358 			ut_setup_security, ut_teardown,
16359 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
16360 		TEST_CASE_NAMED_WITH_DATA(
16361 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16362 			ut_setup_security, ut_teardown,
16363 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
16364 		TEST_CASE_NAMED_WITH_DATA(
16365 			"Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16366 			ut_setup_security, ut_teardown,
16367 			test_ipsec_proto_known_vec_inb,
16368 			&pkt_des_cbc_hmac_sha256_v6),
16369 		TEST_CASE_NAMED_WITH_DATA(
16370 			"Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16371 			ut_setup_security, ut_teardown,
16372 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
16373 		TEST_CASE_NAMED_WITH_DATA(
16374 			"Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16375 			ut_setup_security, ut_teardown,
16376 			test_ipsec_proto_known_vec_inb,
16377 			&pkt_ah_tunnel_sha256),
16378 		TEST_CASE_NAMED_WITH_DATA(
16379 			"Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16380 			ut_setup_security, ut_teardown,
16381 			test_ipsec_proto_known_vec_inb,
16382 			&pkt_ah_transport_sha256),
16383 		TEST_CASE_NAMED_WITH_DATA(
16384 			"Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16385 			ut_setup_security, ut_teardown,
16386 			test_ipsec_proto_known_vec_inb,
16387 			&pkt_ah_ipv4_aes_gmac_128),
16388 		TEST_CASE_NAMED_ST(
16389 			"Combined test alg list",
16390 			ut_setup_security, ut_teardown,
16391 			test_ipsec_proto_display_list),
16392 		TEST_CASE_NAMED_ST(
16393 			"Combined test alg list (AH)",
16394 			ut_setup_security, ut_teardown,
16395 			test_ipsec_proto_ah_tunnel_ipv4),
16396 		TEST_CASE_NAMED_ST(
16397 			"IV generation",
16398 			ut_setup_security, ut_teardown,
16399 			test_ipsec_proto_iv_gen),
16400 		TEST_CASE_NAMED_ST(
16401 			"UDP encapsulation",
16402 			ut_setup_security, ut_teardown,
16403 			test_ipsec_proto_udp_encap),
16404 		TEST_CASE_NAMED_ST(
16405 			"UDP encapsulation with custom ports",
16406 			ut_setup_security, ut_teardown,
16407 			test_ipsec_proto_udp_encap_custom_ports),
16408 		TEST_CASE_NAMED_ST(
16409 			"UDP encapsulation ports verification test",
16410 			ut_setup_security, ut_teardown,
16411 			test_ipsec_proto_udp_ports_verify),
16412 		TEST_CASE_NAMED_ST(
16413 			"SA expiry packets soft",
16414 			ut_setup_security, ut_teardown,
16415 			test_ipsec_proto_sa_exp_pkts_soft),
16416 		TEST_CASE_NAMED_ST(
16417 			"SA expiry packets hard",
16418 			ut_setup_security, ut_teardown,
16419 			test_ipsec_proto_sa_exp_pkts_hard),
16420 		TEST_CASE_NAMED_ST(
16421 			"Negative test: ICV corruption",
16422 			ut_setup_security, ut_teardown,
16423 			test_ipsec_proto_err_icv_corrupt),
16424 		TEST_CASE_NAMED_ST(
16425 			"Tunnel dst addr verification",
16426 			ut_setup_security, ut_teardown,
16427 			test_ipsec_proto_tunnel_dst_addr_verify),
16428 		TEST_CASE_NAMED_ST(
16429 			"Tunnel src and dst addr verification",
16430 			ut_setup_security, ut_teardown,
16431 			test_ipsec_proto_tunnel_src_dst_addr_verify),
16432 		TEST_CASE_NAMED_ST(
16433 			"Inner IP checksum",
16434 			ut_setup_security, ut_teardown,
16435 			test_ipsec_proto_inner_ip_csum),
16436 		TEST_CASE_NAMED_ST(
16437 			"Inner L4 checksum",
16438 			ut_setup_security, ut_teardown,
16439 			test_ipsec_proto_inner_l4_csum),
16440 		TEST_CASE_NAMED_ST(
16441 			"Tunnel IPv4 in IPv4",
16442 			ut_setup_security, ut_teardown,
16443 			test_ipsec_proto_tunnel_v4_in_v4),
16444 		TEST_CASE_NAMED_ST(
16445 			"Tunnel IPv6 in IPv6",
16446 			ut_setup_security, ut_teardown,
16447 			test_ipsec_proto_tunnel_v6_in_v6),
16448 		TEST_CASE_NAMED_ST(
16449 			"Tunnel IPv4 in IPv6",
16450 			ut_setup_security, ut_teardown,
16451 			test_ipsec_proto_tunnel_v4_in_v6),
16452 		TEST_CASE_NAMED_ST(
16453 			"Tunnel IPv6 in IPv4",
16454 			ut_setup_security, ut_teardown,
16455 			test_ipsec_proto_tunnel_v6_in_v4),
16456 		TEST_CASE_NAMED_ST(
16457 			"Transport IPv4",
16458 			ut_setup_security, ut_teardown,
16459 			test_ipsec_proto_transport_v4),
16460 		TEST_CASE_NAMED_ST(
16461 			"AH transport IPv4",
16462 			ut_setup_security, ut_teardown,
16463 			test_ipsec_proto_ah_transport_ipv4),
16464 		TEST_CASE_NAMED_ST(
16465 			"Transport l4 checksum",
16466 			ut_setup_security, ut_teardown,
16467 			test_ipsec_proto_transport_l4_csum),
16468 		TEST_CASE_NAMED_ST(
16469 			"Statistics: success",
16470 			ut_setup_security, ut_teardown,
16471 			test_ipsec_proto_stats),
16472 		TEST_CASE_NAMED_ST(
16473 			"Fragmented packet",
16474 			ut_setup_security, ut_teardown,
16475 			test_ipsec_proto_pkt_fragment),
16476 		TEST_CASE_NAMED_ST(
16477 			"Tunnel header copy DF (inner 0)",
16478 			ut_setup_security, ut_teardown,
16479 			test_ipsec_proto_copy_df_inner_0),
16480 		TEST_CASE_NAMED_ST(
16481 			"Tunnel header copy DF (inner 1)",
16482 			ut_setup_security, ut_teardown,
16483 			test_ipsec_proto_copy_df_inner_1),
16484 		TEST_CASE_NAMED_ST(
16485 			"Tunnel header set DF 0 (inner 1)",
16486 			ut_setup_security, ut_teardown,
16487 			test_ipsec_proto_set_df_0_inner_1),
16488 		TEST_CASE_NAMED_ST(
16489 			"Tunnel header set DF 1 (inner 0)",
16490 			ut_setup_security, ut_teardown,
16491 			test_ipsec_proto_set_df_1_inner_0),
16492 		TEST_CASE_NAMED_ST(
16493 			"Tunnel header IPv4 copy DSCP (inner 0)",
16494 			ut_setup_security, ut_teardown,
16495 			test_ipsec_proto_ipv4_copy_dscp_inner_0),
16496 		TEST_CASE_NAMED_ST(
16497 			"Tunnel header IPv4 copy DSCP (inner 1)",
16498 			ut_setup_security, ut_teardown,
16499 			test_ipsec_proto_ipv4_copy_dscp_inner_1),
16500 		TEST_CASE_NAMED_ST(
16501 			"Tunnel header IPv4 set DSCP 0 (inner 1)",
16502 			ut_setup_security, ut_teardown,
16503 			test_ipsec_proto_ipv4_set_dscp_0_inner_1),
16504 		TEST_CASE_NAMED_ST(
16505 			"Tunnel header IPv4 set DSCP 1 (inner 0)",
16506 			ut_setup_security, ut_teardown,
16507 			test_ipsec_proto_ipv4_set_dscp_1_inner_0),
16508 		TEST_CASE_NAMED_ST(
16509 			"Tunnel header IPv6 copy DSCP (inner 0)",
16510 			ut_setup_security, ut_teardown,
16511 			test_ipsec_proto_ipv6_copy_dscp_inner_0),
16512 		TEST_CASE_NAMED_ST(
16513 			"Tunnel header IPv6 copy DSCP (inner 1)",
16514 			ut_setup_security, ut_teardown,
16515 			test_ipsec_proto_ipv6_copy_dscp_inner_1),
16516 		TEST_CASE_NAMED_ST(
16517 			"Tunnel header IPv6 set DSCP 0 (inner 1)",
16518 			ut_setup_security, ut_teardown,
16519 			test_ipsec_proto_ipv6_set_dscp_0_inner_1),
16520 		TEST_CASE_NAMED_ST(
16521 			"Tunnel header IPv6 set DSCP 1 (inner 0)",
16522 			ut_setup_security, ut_teardown,
16523 			test_ipsec_proto_ipv6_set_dscp_1_inner_0),
16524 		TEST_CASE_NAMED_WITH_DATA(
16525 			"Antireplay with window size 1024",
16526 			ut_setup_security, ut_teardown,
16527 			test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
16528 		TEST_CASE_NAMED_WITH_DATA(
16529 			"Antireplay with window size 2048",
16530 			ut_setup_security, ut_teardown,
16531 			test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
16532 		TEST_CASE_NAMED_WITH_DATA(
16533 			"Antireplay with window size 4096",
16534 			ut_setup_security, ut_teardown,
16535 			test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
16536 		TEST_CASE_NAMED_WITH_DATA(
16537 			"ESN and Antireplay with window size 1024",
16538 			ut_setup_security, ut_teardown,
16539 			test_ipsec_proto_pkt_esn_antireplay1024,
16540 			&pkt_aes_128_gcm),
16541 		TEST_CASE_NAMED_WITH_DATA(
16542 			"ESN and Antireplay with window size 2048",
16543 			ut_setup_security, ut_teardown,
16544 			test_ipsec_proto_pkt_esn_antireplay2048,
16545 			&pkt_aes_128_gcm),
16546 		TEST_CASE_NAMED_WITH_DATA(
16547 			"ESN and Antireplay with window size 4096",
16548 			ut_setup_security, ut_teardown,
16549 			test_ipsec_proto_pkt_esn_antireplay4096,
16550 			&pkt_aes_128_gcm),
16551 		TEST_CASE_NAMED_ST(
16552 			"Tunnel header IPv4 decrement inner TTL",
16553 			ut_setup_security, ut_teardown,
16554 			test_ipsec_proto_ipv4_ttl_decrement),
16555 		TEST_CASE_NAMED_ST(
16556 			"Tunnel header IPv6 decrement inner hop limit",
16557 			ut_setup_security, ut_teardown,
16558 			test_ipsec_proto_ipv6_hop_limit_decrement),
16559 		TEST_CASE_NAMED_ST(
16560 			"Multi-segmented mode",
16561 			ut_setup_security, ut_teardown,
16562 			test_ipsec_proto_sgl),
16563 		TEST_CASE_NAMED_ST(
16564 			"Multi-segmented external mbuf mode",
16565 			ut_setup_security, ut_teardown,
16566 			test_ipsec_proto_sgl_ext_mbuf),
16567 		TEST_CASE_NAMED_WITH_DATA(
16568 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
16569 			ut_setup_security_rx_inject, ut_teardown_rx_inject,
16570 			test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
16571 		TEST_CASES_END() /**< NULL terminate unit test array */
16572 	}
16573 };
16574 
16575 static struct unit_test_suite pdcp_proto_testsuite  = {
16576 	.suite_name = "PDCP Proto Unit Test Suite",
16577 	.setup = pdcp_proto_testsuite_setup,
16578 	.unit_test_cases = {
16579 		TEST_CASE_ST(ut_setup_security, ut_teardown,
16580 			test_PDCP_PROTO_all),
16581 		TEST_CASES_END() /**< NULL terminate unit test array */
16582 	}
16583 };
16584 
16585 #define ADD_UPLINK_TESTCASE(data)						\
16586 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
16587 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
16588 
16589 #define ADD_DOWNLINK_TESTCASE(data)						\
16590 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
16591 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
16592 
16593 static struct unit_test_suite docsis_proto_testsuite  = {
16594 	.suite_name = "DOCSIS Proto Unit Test Suite",
16595 	.setup = docsis_proto_testsuite_setup,
16596 	.unit_test_cases = {
16597 		/* Uplink */
16598 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
16599 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
16600 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
16601 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
16602 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
16603 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
16604 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
16605 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
16606 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
16607 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
16608 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
16609 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
16610 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
16611 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
16612 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
16613 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
16614 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
16615 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
16616 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
16617 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
16618 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
16619 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
16620 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
16621 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
16622 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
16623 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
16624 		/* Downlink */
16625 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
16626 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
16627 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
16628 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
16629 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
16630 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
16631 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
16632 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
16633 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
16634 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
16635 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
16636 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
16637 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
16638 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
16639 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
16640 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
16641 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
16642 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
16643 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
16644 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
16645 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
16646 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
16647 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
16648 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
16649 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
16650 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
16651 		TEST_CASES_END() /**< NULL terminate unit test array */
16652 	}
16653 };
16654 #endif
16655 
16656 static struct unit_test_suite cryptodev_gen_testsuite  = {
16657 	.suite_name = "Crypto General Unit Test Suite",
16658 	.setup = crypto_gen_testsuite_setup,
16659 	.unit_test_cases = {
16660 		TEST_CASE_ST(ut_setup, ut_teardown,
16661 				test_device_reconfigure),
16662 		TEST_CASE_ST(ut_setup, ut_teardown,
16663 				test_device_configure_invalid_dev_id),
16664 		TEST_CASE_ST(ut_setup, ut_teardown,
16665 				test_queue_pair_descriptor_setup),
16666 		TEST_CASE_ST(ut_setup, ut_teardown,
16667 				test_device_configure_invalid_queue_pair_ids),
16668 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
16669 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
16670 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
16671 		TEST_CASES_END() /**< NULL terminate unit test array */
16672 	}
16673 };
16674 
16675 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
16676 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
16677 	.setup = negative_hmac_sha1_testsuite_setup,
16678 	.unit_test_cases = {
16679 		/** Negative tests */
16680 		TEST_CASE_ST(ut_setup, ut_teardown,
16681 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
16682 		TEST_CASE_ST(ut_setup, ut_teardown,
16683 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
16684 		TEST_CASE_ST(ut_setup, ut_teardown,
16685 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
16686 		TEST_CASE_ST(ut_setup, ut_teardown,
16687 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
16688 
16689 		TEST_CASES_END() /**< NULL terminate unit test array */
16690 	}
16691 };
16692 
16693 static struct unit_test_suite cryptodev_multi_session_testsuite = {
16694 	.suite_name = "Multi Session Unit Test Suite",
16695 	.setup = multi_session_testsuite_setup,
16696 	.unit_test_cases = {
16697 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
16698 		TEST_CASE_ST(ut_setup, ut_teardown,
16699 				test_multi_session_random_usage),
16700 
16701 		TEST_CASES_END() /**< NULL terminate unit test array */
16702 	}
16703 };
16704 
16705 static struct unit_test_suite cryptodev_null_testsuite  = {
16706 	.suite_name = "NULL Test Suite",
16707 	.setup = null_testsuite_setup,
16708 	.unit_test_cases = {
16709 		TEST_CASE_ST(ut_setup, ut_teardown,
16710 			test_null_invalid_operation),
16711 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
16712 		TEST_CASES_END()
16713 	}
16714 };
16715 
16716 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
16717 	.suite_name = "AES CCM Authenticated Test Suite",
16718 	.setup = aes_ccm_auth_testsuite_setup,
16719 	.unit_test_cases = {
16720 		/** AES CCM Authenticated Encryption 128 bits key*/
16721 		TEST_CASE_ST(ut_setup, ut_teardown,
16722 			test_AES_CCM_authenticated_encryption_test_case_128_1),
16723 		TEST_CASE_ST(ut_setup, ut_teardown,
16724 			test_AES_CCM_authenticated_encryption_test_case_128_2),
16725 		TEST_CASE_ST(ut_setup, ut_teardown,
16726 			test_AES_CCM_authenticated_encryption_test_case_128_3),
16727 
16728 		/** AES CCM Authenticated Decryption 128 bits key*/
16729 		TEST_CASE_ST(ut_setup, ut_teardown,
16730 			test_AES_CCM_authenticated_decryption_test_case_128_1),
16731 		TEST_CASE_ST(ut_setup, ut_teardown,
16732 			test_AES_CCM_authenticated_decryption_test_case_128_2),
16733 		TEST_CASE_ST(ut_setup, ut_teardown,
16734 			test_AES_CCM_authenticated_decryption_test_case_128_3),
16735 
16736 		/** AES CCM Authenticated Encryption 192 bits key */
16737 		TEST_CASE_ST(ut_setup, ut_teardown,
16738 			test_AES_CCM_authenticated_encryption_test_case_192_1),
16739 		TEST_CASE_ST(ut_setup, ut_teardown,
16740 			test_AES_CCM_authenticated_encryption_test_case_192_2),
16741 		TEST_CASE_ST(ut_setup, ut_teardown,
16742 			test_AES_CCM_authenticated_encryption_test_case_192_3),
16743 
16744 		/** AES CCM Authenticated Decryption 192 bits key*/
16745 		TEST_CASE_ST(ut_setup, ut_teardown,
16746 			test_AES_CCM_authenticated_decryption_test_case_192_1),
16747 		TEST_CASE_ST(ut_setup, ut_teardown,
16748 			test_AES_CCM_authenticated_decryption_test_case_192_2),
16749 		TEST_CASE_ST(ut_setup, ut_teardown,
16750 			test_AES_CCM_authenticated_decryption_test_case_192_3),
16751 
16752 		/** AES CCM Authenticated Encryption 256 bits key */
16753 		TEST_CASE_ST(ut_setup, ut_teardown,
16754 			test_AES_CCM_authenticated_encryption_test_case_256_1),
16755 		TEST_CASE_ST(ut_setup, ut_teardown,
16756 			test_AES_CCM_authenticated_encryption_test_case_256_2),
16757 		TEST_CASE_ST(ut_setup, ut_teardown,
16758 			test_AES_CCM_authenticated_encryption_test_case_256_3),
16759 
16760 		/** AES CCM Authenticated Decryption 256 bits key*/
16761 		TEST_CASE_ST(ut_setup, ut_teardown,
16762 			test_AES_CCM_authenticated_decryption_test_case_256_1),
16763 		TEST_CASE_ST(ut_setup, ut_teardown,
16764 			test_AES_CCM_authenticated_decryption_test_case_256_2),
16765 		TEST_CASE_ST(ut_setup, ut_teardown,
16766 			test_AES_CCM_authenticated_decryption_test_case_256_3),
16767 		TEST_CASES_END()
16768 	}
16769 };
16770 
16771 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
16772 	.suite_name = "AES GCM Authenticated Test Suite",
16773 	.setup = aes_gcm_auth_testsuite_setup,
16774 	.unit_test_cases = {
16775 		/** AES GCM Authenticated Encryption */
16776 		TEST_CASE_ST(ut_setup, ut_teardown,
16777 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
16778 		TEST_CASE_ST(ut_setup, ut_teardown,
16779 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
16780 		TEST_CASE_ST(ut_setup, ut_teardown,
16781 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
16782 		TEST_CASE_ST(ut_setup, ut_teardown,
16783 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
16784 		TEST_CASE_ST(ut_setup, ut_teardown,
16785 			test_AES_GCM_authenticated_encryption_test_case_1),
16786 		TEST_CASE_ST(ut_setup, ut_teardown,
16787 			test_AES_GCM_authenticated_encryption_test_case_2),
16788 		TEST_CASE_ST(ut_setup, ut_teardown,
16789 			test_AES_GCM_authenticated_encryption_test_case_3),
16790 		TEST_CASE_ST(ut_setup, ut_teardown,
16791 			test_AES_GCM_authenticated_encryption_test_case_4),
16792 		TEST_CASE_ST(ut_setup, ut_teardown,
16793 			test_AES_GCM_authenticated_encryption_test_case_5),
16794 		TEST_CASE_ST(ut_setup, ut_teardown,
16795 			test_AES_GCM_authenticated_encryption_test_case_6),
16796 		TEST_CASE_ST(ut_setup, ut_teardown,
16797 			test_AES_GCM_authenticated_encryption_test_case_7),
16798 		TEST_CASE_ST(ut_setup, ut_teardown,
16799 			test_AES_GCM_authenticated_encryption_test_case_8),
16800 		TEST_CASE_ST(ut_setup, ut_teardown,
16801 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
16802 
16803 		/** AES GCM Authenticated Decryption */
16804 		TEST_CASE_ST(ut_setup, ut_teardown,
16805 			test_AES_GCM_authenticated_decryption_test_case_1),
16806 		TEST_CASE_ST(ut_setup, ut_teardown,
16807 			test_AES_GCM_authenticated_decryption_test_case_2),
16808 		TEST_CASE_ST(ut_setup, ut_teardown,
16809 			test_AES_GCM_authenticated_decryption_test_case_3),
16810 		TEST_CASE_ST(ut_setup, ut_teardown,
16811 			test_AES_GCM_authenticated_decryption_test_case_4),
16812 		TEST_CASE_ST(ut_setup, ut_teardown,
16813 			test_AES_GCM_authenticated_decryption_test_case_5),
16814 		TEST_CASE_ST(ut_setup, ut_teardown,
16815 			test_AES_GCM_authenticated_decryption_test_case_6),
16816 		TEST_CASE_ST(ut_setup, ut_teardown,
16817 			test_AES_GCM_authenticated_decryption_test_case_7),
16818 		TEST_CASE_ST(ut_setup, ut_teardown,
16819 			test_AES_GCM_authenticated_decryption_test_case_8),
16820 		TEST_CASE_ST(ut_setup, ut_teardown,
16821 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
16822 
16823 		/** AES GCM Authenticated Encryption 192 bits key */
16824 		TEST_CASE_ST(ut_setup, ut_teardown,
16825 			test_AES_GCM_auth_encryption_test_case_192_1),
16826 		TEST_CASE_ST(ut_setup, ut_teardown,
16827 			test_AES_GCM_auth_encryption_test_case_192_2),
16828 		TEST_CASE_ST(ut_setup, ut_teardown,
16829 			test_AES_GCM_auth_encryption_test_case_192_3),
16830 		TEST_CASE_ST(ut_setup, ut_teardown,
16831 			test_AES_GCM_auth_encryption_test_case_192_4),
16832 		TEST_CASE_ST(ut_setup, ut_teardown,
16833 			test_AES_GCM_auth_encryption_test_case_192_5),
16834 		TEST_CASE_ST(ut_setup, ut_teardown,
16835 			test_AES_GCM_auth_encryption_test_case_192_6),
16836 		TEST_CASE_ST(ut_setup, ut_teardown,
16837 			test_AES_GCM_auth_encryption_test_case_192_7),
16838 
16839 		/** AES GCM Authenticated Decryption 192 bits key */
16840 		TEST_CASE_ST(ut_setup, ut_teardown,
16841 			test_AES_GCM_auth_decryption_test_case_192_1),
16842 		TEST_CASE_ST(ut_setup, ut_teardown,
16843 			test_AES_GCM_auth_decryption_test_case_192_2),
16844 		TEST_CASE_ST(ut_setup, ut_teardown,
16845 			test_AES_GCM_auth_decryption_test_case_192_3),
16846 		TEST_CASE_ST(ut_setup, ut_teardown,
16847 			test_AES_GCM_auth_decryption_test_case_192_4),
16848 		TEST_CASE_ST(ut_setup, ut_teardown,
16849 			test_AES_GCM_auth_decryption_test_case_192_5),
16850 		TEST_CASE_ST(ut_setup, ut_teardown,
16851 			test_AES_GCM_auth_decryption_test_case_192_6),
16852 		TEST_CASE_ST(ut_setup, ut_teardown,
16853 			test_AES_GCM_auth_decryption_test_case_192_7),
16854 
16855 		/** AES GCM Authenticated Encryption 256 bits key */
16856 		TEST_CASE_ST(ut_setup, ut_teardown,
16857 			test_AES_GCM_auth_encryption_test_case_256_1),
16858 		TEST_CASE_ST(ut_setup, ut_teardown,
16859 			test_AES_GCM_auth_encryption_test_case_256_2),
16860 		TEST_CASE_ST(ut_setup, ut_teardown,
16861 			test_AES_GCM_auth_encryption_test_case_256_3),
16862 		TEST_CASE_ST(ut_setup, ut_teardown,
16863 			test_AES_GCM_auth_encryption_test_case_256_4),
16864 		TEST_CASE_ST(ut_setup, ut_teardown,
16865 			test_AES_GCM_auth_encryption_test_case_256_5),
16866 		TEST_CASE_ST(ut_setup, ut_teardown,
16867 			test_AES_GCM_auth_encryption_test_case_256_6),
16868 		TEST_CASE_ST(ut_setup, ut_teardown,
16869 			test_AES_GCM_auth_encryption_test_case_256_7),
16870 
16871 		/** AES GCM Authenticated Decryption 256 bits key */
16872 		TEST_CASE_ST(ut_setup, ut_teardown,
16873 			test_AES_GCM_auth_decryption_test_case_256_1),
16874 		TEST_CASE_ST(ut_setup, ut_teardown,
16875 			test_AES_GCM_auth_decryption_test_case_256_2),
16876 		TEST_CASE_ST(ut_setup, ut_teardown,
16877 			test_AES_GCM_auth_decryption_test_case_256_3),
16878 		TEST_CASE_ST(ut_setup, ut_teardown,
16879 			test_AES_GCM_auth_decryption_test_case_256_4),
16880 		TEST_CASE_ST(ut_setup, ut_teardown,
16881 			test_AES_GCM_auth_decryption_test_case_256_5),
16882 		TEST_CASE_ST(ut_setup, ut_teardown,
16883 			test_AES_GCM_auth_decryption_test_case_256_6),
16884 		TEST_CASE_ST(ut_setup, ut_teardown,
16885 			test_AES_GCM_auth_decryption_test_case_256_7),
16886 
16887 		/** AES GCM Authenticated Encryption big aad size */
16888 		TEST_CASE_ST(ut_setup, ut_teardown,
16889 			test_AES_GCM_auth_encryption_test_case_aad_1),
16890 		TEST_CASE_ST(ut_setup, ut_teardown,
16891 			test_AES_GCM_auth_encryption_test_case_aad_2),
16892 
16893 		/** AES GCM Authenticated Decryption big aad size */
16894 		TEST_CASE_ST(ut_setup, ut_teardown,
16895 			test_AES_GCM_auth_decryption_test_case_aad_1),
16896 		TEST_CASE_ST(ut_setup, ut_teardown,
16897 			test_AES_GCM_auth_decryption_test_case_aad_2),
16898 
16899 		/** Out of place tests */
16900 		TEST_CASE_ST(ut_setup, ut_teardown,
16901 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
16902 		TEST_CASE_ST(ut_setup, ut_teardown,
16903 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
16904 
16905 		/** Session-less tests */
16906 		TEST_CASE_ST(ut_setup, ut_teardown,
16907 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
16908 		TEST_CASE_ST(ut_setup, ut_teardown,
16909 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
16910 
16911 		TEST_CASES_END()
16912 	}
16913 };
16914 
16915 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
16916 	.suite_name = "AES GMAC Authentication Test Suite",
16917 	.setup = aes_gmac_auth_testsuite_setup,
16918 	.unit_test_cases = {
16919 		TEST_CASE_ST(ut_setup, ut_teardown,
16920 			test_AES_GMAC_authentication_test_case_1),
16921 		TEST_CASE_ST(ut_setup, ut_teardown,
16922 			test_AES_GMAC_authentication_verify_test_case_1),
16923 		TEST_CASE_ST(ut_setup, ut_teardown,
16924 			test_AES_GMAC_authentication_test_case_2),
16925 		TEST_CASE_ST(ut_setup, ut_teardown,
16926 			test_AES_GMAC_authentication_verify_test_case_2),
16927 		TEST_CASE_ST(ut_setup, ut_teardown,
16928 			test_AES_GMAC_authentication_test_case_3),
16929 		TEST_CASE_ST(ut_setup, ut_teardown,
16930 			test_AES_GMAC_authentication_verify_test_case_3),
16931 		TEST_CASE_ST(ut_setup, ut_teardown,
16932 			test_AES_GMAC_authentication_test_case_4),
16933 		TEST_CASE_ST(ut_setup, ut_teardown,
16934 			test_AES_GMAC_authentication_verify_test_case_4),
16935 		TEST_CASE_ST(ut_setup, ut_teardown,
16936 			test_AES_GMAC_authentication_SGL_40B),
16937 		TEST_CASE_ST(ut_setup, ut_teardown,
16938 			test_AES_GMAC_authentication_SGL_80B),
16939 		TEST_CASE_ST(ut_setup, ut_teardown,
16940 			test_AES_GMAC_authentication_SGL_2048B),
16941 		TEST_CASE_ST(ut_setup, ut_teardown,
16942 			test_AES_GMAC_authentication_SGL_2047B),
16943 
16944 		TEST_CASES_END()
16945 	}
16946 };
16947 
16948 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
16949 	.suite_name = "Chacha20-Poly1305 Test Suite",
16950 	.setup = chacha20_poly1305_testsuite_setup,
16951 	.unit_test_cases = {
16952 		TEST_CASE_ST(ut_setup, ut_teardown,
16953 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
16954 		TEST_CASE_ST(ut_setup, ut_teardown,
16955 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
16956 		TEST_CASE_ST(ut_setup, ut_teardown,
16957 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
16958 		TEST_CASES_END()
16959 	}
16960 };
16961 
16962 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
16963 	.suite_name = "SNOW 3G Test Suite",
16964 	.setup = snow3g_testsuite_setup,
16965 	.unit_test_cases = {
16966 		/** SNOW 3G encrypt only (UEA2) */
16967 		TEST_CASE_ST(ut_setup, ut_teardown,
16968 			test_snow3g_encryption_test_case_1),
16969 		TEST_CASE_ST(ut_setup, ut_teardown,
16970 			test_snow3g_encryption_test_case_2),
16971 		TEST_CASE_ST(ut_setup, ut_teardown,
16972 			test_snow3g_encryption_test_case_3),
16973 		TEST_CASE_ST(ut_setup, ut_teardown,
16974 			test_snow3g_encryption_test_case_4),
16975 		TEST_CASE_ST(ut_setup, ut_teardown,
16976 			test_snow3g_encryption_test_case_5),
16977 
16978 		TEST_CASE_ST(ut_setup, ut_teardown,
16979 			test_snow3g_encryption_test_case_1_oop),
16980 		TEST_CASE_ST(ut_setup, ut_teardown,
16981 			test_snow3g_encryption_test_case_1_oop_sgl),
16982 		TEST_CASE_ST(ut_setup, ut_teardown,
16983 			test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
16984 		TEST_CASE_ST(ut_setup, ut_teardown,
16985 			test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
16986 		TEST_CASE_ST(ut_setup, ut_teardown,
16987 			test_snow3g_encryption_test_case_1_offset_oop),
16988 		TEST_CASE_ST(ut_setup, ut_teardown,
16989 			test_snow3g_decryption_test_case_1_oop),
16990 
16991 		/** SNOW 3G generate auth, then encrypt (UEA2) */
16992 		TEST_CASE_ST(ut_setup, ut_teardown,
16993 			test_snow3g_auth_cipher_test_case_1),
16994 		TEST_CASE_ST(ut_setup, ut_teardown,
16995 			test_snow3g_auth_cipher_test_case_2),
16996 		TEST_CASE_ST(ut_setup, ut_teardown,
16997 			test_snow3g_auth_cipher_test_case_2_oop),
16998 		TEST_CASE_ST(ut_setup, ut_teardown,
16999 			test_snow3g_auth_cipher_part_digest_enc),
17000 		TEST_CASE_ST(ut_setup, ut_teardown,
17001 			test_snow3g_auth_cipher_part_digest_enc_oop),
17002 		TEST_CASE_ST(ut_setup, ut_teardown,
17003 			test_snow3g_auth_cipher_test_case_3_sgl),
17004 		TEST_CASE_ST(ut_setup, ut_teardown,
17005 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
17006 		TEST_CASE_ST(ut_setup, ut_teardown,
17007 			test_snow3g_auth_cipher_part_digest_enc_sgl),
17008 		TEST_CASE_ST(ut_setup, ut_teardown,
17009 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
17010 		TEST_CASE_ST(ut_setup, ut_teardown,
17011 			test_snow3g_auth_cipher_total_digest_enc_1),
17012 		TEST_CASE_ST(ut_setup, ut_teardown,
17013 			test_snow3g_auth_cipher_total_digest_enc_1_oop),
17014 		TEST_CASE_ST(ut_setup, ut_teardown,
17015 			test_snow3g_auth_cipher_total_digest_enc_1_sgl),
17016 		TEST_CASE_ST(ut_setup, ut_teardown,
17017 			test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
17018 
17019 		/** SNOW 3G decrypt (UEA2), then verify auth */
17020 		TEST_CASE_ST(ut_setup, ut_teardown,
17021 			test_snow3g_auth_cipher_verify_test_case_1),
17022 		TEST_CASE_ST(ut_setup, ut_teardown,
17023 			test_snow3g_auth_cipher_verify_test_case_2),
17024 		TEST_CASE_ST(ut_setup, ut_teardown,
17025 			test_snow3g_auth_cipher_verify_test_case_2_oop),
17026 		TEST_CASE_ST(ut_setup, ut_teardown,
17027 			test_snow3g_auth_cipher_verify_part_digest_enc),
17028 		TEST_CASE_ST(ut_setup, ut_teardown,
17029 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
17030 		TEST_CASE_ST(ut_setup, ut_teardown,
17031 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
17032 		TEST_CASE_ST(ut_setup, ut_teardown,
17033 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
17034 		TEST_CASE_ST(ut_setup, ut_teardown,
17035 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
17036 		TEST_CASE_ST(ut_setup, ut_teardown,
17037 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
17038 		TEST_CASE_ST(ut_setup, ut_teardown,
17039 			test_snow3g_auth_cipher_verify_total_digest_enc_1),
17040 		TEST_CASE_ST(ut_setup, ut_teardown,
17041 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
17042 		TEST_CASE_ST(ut_setup, ut_teardown,
17043 			test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
17044 		TEST_CASE_ST(ut_setup, ut_teardown,
17045 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
17046 
17047 		/** SNOW 3G decrypt only (UEA2) */
17048 		TEST_CASE_ST(ut_setup, ut_teardown,
17049 			test_snow3g_decryption_test_case_1),
17050 		TEST_CASE_ST(ut_setup, ut_teardown,
17051 			test_snow3g_decryption_test_case_2),
17052 		TEST_CASE_ST(ut_setup, ut_teardown,
17053 			test_snow3g_decryption_test_case_3),
17054 		TEST_CASE_ST(ut_setup, ut_teardown,
17055 			test_snow3g_decryption_test_case_4),
17056 		TEST_CASE_ST(ut_setup, ut_teardown,
17057 			test_snow3g_decryption_test_case_5),
17058 		TEST_CASE_ST(ut_setup, ut_teardown,
17059 			test_snow3g_decryption_with_digest_test_case_1),
17060 		TEST_CASE_ST(ut_setup, ut_teardown,
17061 			test_snow3g_hash_generate_test_case_1),
17062 		TEST_CASE_ST(ut_setup, ut_teardown,
17063 			test_snow3g_hash_generate_test_case_2),
17064 		TEST_CASE_ST(ut_setup, ut_teardown,
17065 			test_snow3g_hash_generate_test_case_3),
17066 
17067 		/* Tests with buffers which length is not byte-aligned */
17068 		TEST_CASE_ST(ut_setup, ut_teardown,
17069 			test_snow3g_hash_generate_test_case_4),
17070 		TEST_CASE_ST(ut_setup, ut_teardown,
17071 			test_snow3g_hash_generate_test_case_5),
17072 		TEST_CASE_ST(ut_setup, ut_teardown,
17073 			test_snow3g_hash_generate_test_case_6),
17074 		TEST_CASE_ST(ut_setup, ut_teardown,
17075 			test_snow3g_hash_verify_test_case_1),
17076 		TEST_CASE_ST(ut_setup, ut_teardown,
17077 			test_snow3g_hash_verify_test_case_2),
17078 		TEST_CASE_ST(ut_setup, ut_teardown,
17079 			test_snow3g_hash_verify_test_case_3),
17080 
17081 		/* Tests with buffers which length is not byte-aligned */
17082 		TEST_CASE_ST(ut_setup, ut_teardown,
17083 			test_snow3g_hash_verify_test_case_4),
17084 		TEST_CASE_ST(ut_setup, ut_teardown,
17085 			test_snow3g_hash_verify_test_case_5),
17086 		TEST_CASE_ST(ut_setup, ut_teardown,
17087 			test_snow3g_hash_verify_test_case_6),
17088 		TEST_CASE_ST(ut_setup, ut_teardown,
17089 			test_snow3g_cipher_auth_test_case_1),
17090 		TEST_CASE_ST(ut_setup, ut_teardown,
17091 			test_snow3g_auth_cipher_with_digest_test_case_1),
17092 		TEST_CASES_END()
17093 	}
17094 };
17095 
17096 static struct unit_test_suite cryptodev_zuc_testsuite  = {
17097 	.suite_name = "ZUC Test Suite",
17098 	.setup = zuc_testsuite_setup,
17099 	.unit_test_cases = {
17100 		/** ZUC encrypt only (EEA3) */
17101 		TEST_CASE_ST(ut_setup, ut_teardown,
17102 			test_zuc_encryption_test_case_1),
17103 		TEST_CASE_ST(ut_setup, ut_teardown,
17104 			test_zuc_encryption_test_case_2),
17105 		TEST_CASE_ST(ut_setup, ut_teardown,
17106 			test_zuc_encryption_test_case_3),
17107 		TEST_CASE_ST(ut_setup, ut_teardown,
17108 			test_zuc_encryption_test_case_4),
17109 		TEST_CASE_ST(ut_setup, ut_teardown,
17110 			test_zuc_encryption_test_case_5),
17111 		TEST_CASE_ST(ut_setup, ut_teardown,
17112 			test_zuc_encryption_test_case_6_sgl),
17113 
17114 		/** ZUC decrypt only (EEA3) */
17115 		TEST_CASE_ST(ut_setup, ut_teardown,
17116 			test_zuc_decryption_test_case_1),
17117 		TEST_CASE_ST(ut_setup, ut_teardown,
17118 			test_zuc_decryption_test_case_2),
17119 		TEST_CASE_ST(ut_setup, ut_teardown,
17120 			test_zuc_decryption_test_case_3),
17121 		TEST_CASE_ST(ut_setup, ut_teardown,
17122 			test_zuc_decryption_test_case_4),
17123 		TEST_CASE_ST(ut_setup, ut_teardown,
17124 			test_zuc_decryption_test_case_5),
17125 		TEST_CASE_ST(ut_setup, ut_teardown,
17126 			test_zuc_decryption_test_case_6_sgl),
17127 
17128 		/** ZUC authenticate (EIA3) */
17129 		TEST_CASE_ST(ut_setup, ut_teardown,
17130 			test_zuc_hash_generate_test_case_1),
17131 		TEST_CASE_ST(ut_setup, ut_teardown,
17132 			test_zuc_hash_generate_test_case_2),
17133 		TEST_CASE_ST(ut_setup, ut_teardown,
17134 			test_zuc_hash_generate_test_case_3),
17135 		TEST_CASE_ST(ut_setup, ut_teardown,
17136 			test_zuc_hash_generate_test_case_4),
17137 		TEST_CASE_ST(ut_setup, ut_teardown,
17138 			test_zuc_hash_generate_test_case_5),
17139 		TEST_CASE_ST(ut_setup, ut_teardown,
17140 			test_zuc_hash_generate_test_case_6),
17141 		TEST_CASE_ST(ut_setup, ut_teardown,
17142 			test_zuc_hash_generate_test_case_7),
17143 		TEST_CASE_ST(ut_setup, ut_teardown,
17144 			test_zuc_hash_generate_test_case_8),
17145 
17146 		/** ZUC verify (EIA3) */
17147 		TEST_CASE_ST(ut_setup, ut_teardown,
17148 			test_zuc_hash_verify_test_case_1),
17149 		TEST_CASE_ST(ut_setup, ut_teardown,
17150 			test_zuc_hash_verify_test_case_2),
17151 		TEST_CASE_ST(ut_setup, ut_teardown,
17152 			test_zuc_hash_verify_test_case_3),
17153 		TEST_CASE_ST(ut_setup, ut_teardown,
17154 			test_zuc_hash_verify_test_case_4),
17155 		TEST_CASE_ST(ut_setup, ut_teardown,
17156 			test_zuc_hash_verify_test_case_5),
17157 		TEST_CASE_ST(ut_setup, ut_teardown,
17158 			test_zuc_hash_verify_test_case_6),
17159 		TEST_CASE_ST(ut_setup, ut_teardown,
17160 			test_zuc_hash_verify_test_case_7),
17161 		TEST_CASE_ST(ut_setup, ut_teardown,
17162 			test_zuc_hash_verify_test_case_8),
17163 
17164 		/** ZUC alg-chain (EEA3/EIA3) */
17165 		TEST_CASE_ST(ut_setup, ut_teardown,
17166 			test_zuc_cipher_auth_test_case_1),
17167 		TEST_CASE_ST(ut_setup, ut_teardown,
17168 			test_zuc_cipher_auth_test_case_2),
17169 
17170 		/** ZUC generate auth, then encrypt (EEA3) */
17171 		TEST_CASE_ST(ut_setup, ut_teardown,
17172 			test_zuc_auth_cipher_test_case_1),
17173 		TEST_CASE_ST(ut_setup, ut_teardown,
17174 			test_zuc_auth_cipher_test_case_1_oop),
17175 		TEST_CASE_ST(ut_setup, ut_teardown,
17176 			test_zuc_auth_cipher_test_case_1_sgl),
17177 		TEST_CASE_ST(ut_setup, ut_teardown,
17178 			test_zuc_auth_cipher_test_case_1_oop_sgl),
17179 		TEST_CASE_ST(ut_setup, ut_teardown,
17180 			test_zuc_auth_cipher_test_case_2),
17181 		TEST_CASE_ST(ut_setup, ut_teardown,
17182 			test_zuc_auth_cipher_test_case_2_oop),
17183 
17184 		/** ZUC decrypt (EEA3), then verify auth */
17185 		TEST_CASE_ST(ut_setup, ut_teardown,
17186 			test_zuc_auth_cipher_verify_test_case_1),
17187 		TEST_CASE_ST(ut_setup, ut_teardown,
17188 			test_zuc_auth_cipher_verify_test_case_1_oop),
17189 		TEST_CASE_ST(ut_setup, ut_teardown,
17190 			test_zuc_auth_cipher_verify_test_case_1_sgl),
17191 		TEST_CASE_ST(ut_setup, ut_teardown,
17192 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
17193 		TEST_CASE_ST(ut_setup, ut_teardown,
17194 			test_zuc_auth_cipher_verify_test_case_2),
17195 		TEST_CASE_ST(ut_setup, ut_teardown,
17196 			test_zuc_auth_cipher_verify_test_case_2_oop),
17197 
17198 		/** ZUC-256 encrypt only **/
17199 		TEST_CASE_ST(ut_setup, ut_teardown,
17200 			test_zuc256_encryption_test_case_1),
17201 		TEST_CASE_ST(ut_setup, ut_teardown,
17202 			test_zuc256_encryption_test_case_2),
17203 
17204 		/** ZUC-256 decrypt only **/
17205 		TEST_CASE_ST(ut_setup, ut_teardown,
17206 			test_zuc256_decryption_test_case_1),
17207 		TEST_CASE_ST(ut_setup, ut_teardown,
17208 			test_zuc256_decryption_test_case_2),
17209 
17210 		/** ZUC-256 authentication only **/
17211 		TEST_CASE_ST(ut_setup, ut_teardown,
17212 			test_zuc256_hash_generate_4b_tag_test_case_1),
17213 		TEST_CASE_ST(ut_setup, ut_teardown,
17214 			test_zuc256_hash_generate_4b_tag_test_case_2),
17215 		TEST_CASE_ST(ut_setup, ut_teardown,
17216 			test_zuc256_hash_generate_4b_tag_test_case_3),
17217 		TEST_CASE_ST(ut_setup, ut_teardown,
17218 			test_zuc256_hash_generate_8b_tag_test_case_1),
17219 		TEST_CASE_ST(ut_setup, ut_teardown,
17220 			test_zuc256_hash_generate_16b_tag_test_case_1),
17221 
17222 		/** ZUC-256 authentication verify only **/
17223 		TEST_CASE_ST(ut_setup, ut_teardown,
17224 			test_zuc256_hash_verify_4b_tag_test_case_1),
17225 		TEST_CASE_ST(ut_setup, ut_teardown,
17226 			test_zuc256_hash_verify_4b_tag_test_case_2),
17227 		TEST_CASE_ST(ut_setup, ut_teardown,
17228 			test_zuc256_hash_verify_4b_tag_test_case_3),
17229 		TEST_CASE_ST(ut_setup, ut_teardown,
17230 			test_zuc256_hash_verify_8b_tag_test_case_1),
17231 		TEST_CASE_ST(ut_setup, ut_teardown,
17232 			test_zuc256_hash_verify_16b_tag_test_case_1),
17233 
17234 		/** ZUC-256 encrypt and authenticate **/
17235 		TEST_CASE_ST(ut_setup, ut_teardown,
17236 			test_zuc256_cipher_auth_4b_tag_test_case_1),
17237 		TEST_CASE_ST(ut_setup, ut_teardown,
17238 			test_zuc256_cipher_auth_4b_tag_test_case_2),
17239 		TEST_CASE_ST(ut_setup, ut_teardown,
17240 			test_zuc256_cipher_auth_8b_tag_test_case_1),
17241 		TEST_CASE_ST(ut_setup, ut_teardown,
17242 			test_zuc256_cipher_auth_16b_tag_test_case_1),
17243 
17244 		/** ZUC-256 generate auth, then encrypt */
17245 		TEST_CASE_ST(ut_setup, ut_teardown,
17246 			test_zuc256_auth_cipher_4b_tag_test_case_1),
17247 		TEST_CASE_ST(ut_setup, ut_teardown,
17248 			test_zuc256_auth_cipher_4b_tag_test_case_2),
17249 		TEST_CASE_ST(ut_setup, ut_teardown,
17250 			test_zuc256_auth_cipher_8b_tag_test_case_1),
17251 		TEST_CASE_ST(ut_setup, ut_teardown,
17252 			test_zuc256_auth_cipher_16b_tag_test_case_1),
17253 
17254 		/** ZUC-256 decrypt, then verify auth */
17255 		TEST_CASE_ST(ut_setup, ut_teardown,
17256 			test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
17257 		TEST_CASE_ST(ut_setup, ut_teardown,
17258 			test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
17259 		TEST_CASE_ST(ut_setup, ut_teardown,
17260 			test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
17261 		TEST_CASE_ST(ut_setup, ut_teardown,
17262 			test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
17263 
17264 		TEST_CASES_END()
17265 	}
17266 };
17267 
17268 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
17269 	.suite_name = "HMAC_MD5 Authentication Test Suite",
17270 	.setup = hmac_md5_auth_testsuite_setup,
17271 	.unit_test_cases = {
17272 		TEST_CASE_ST(ut_setup, ut_teardown,
17273 			test_MD5_HMAC_generate_case_1),
17274 		TEST_CASE_ST(ut_setup, ut_teardown,
17275 			test_MD5_HMAC_verify_case_1),
17276 		TEST_CASE_ST(ut_setup, ut_teardown,
17277 			test_MD5_HMAC_generate_case_2),
17278 		TEST_CASE_ST(ut_setup, ut_teardown,
17279 			test_MD5_HMAC_verify_case_2),
17280 		TEST_CASES_END()
17281 	}
17282 };
17283 
17284 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
17285 	.suite_name = "Kasumi Test Suite",
17286 	.setup = kasumi_testsuite_setup,
17287 	.unit_test_cases = {
17288 		/** KASUMI hash only (UIA1) */
17289 		TEST_CASE_ST(ut_setup, ut_teardown,
17290 			test_kasumi_hash_generate_test_case_1),
17291 		TEST_CASE_ST(ut_setup, ut_teardown,
17292 			test_kasumi_hash_generate_test_case_2),
17293 		TEST_CASE_ST(ut_setup, ut_teardown,
17294 			test_kasumi_hash_generate_test_case_3),
17295 		TEST_CASE_ST(ut_setup, ut_teardown,
17296 			test_kasumi_hash_generate_test_case_4),
17297 		TEST_CASE_ST(ut_setup, ut_teardown,
17298 			test_kasumi_hash_generate_test_case_5),
17299 		TEST_CASE_ST(ut_setup, ut_teardown,
17300 			test_kasumi_hash_generate_test_case_6),
17301 
17302 		TEST_CASE_ST(ut_setup, ut_teardown,
17303 			test_kasumi_hash_verify_test_case_1),
17304 		TEST_CASE_ST(ut_setup, ut_teardown,
17305 			test_kasumi_hash_verify_test_case_2),
17306 		TEST_CASE_ST(ut_setup, ut_teardown,
17307 			test_kasumi_hash_verify_test_case_3),
17308 		TEST_CASE_ST(ut_setup, ut_teardown,
17309 			test_kasumi_hash_verify_test_case_4),
17310 		TEST_CASE_ST(ut_setup, ut_teardown,
17311 			test_kasumi_hash_verify_test_case_5),
17312 
17313 		/** KASUMI encrypt only (UEA1) */
17314 		TEST_CASE_ST(ut_setup, ut_teardown,
17315 			test_kasumi_encryption_test_case_1),
17316 		TEST_CASE_ST(ut_setup, ut_teardown,
17317 			test_kasumi_encryption_test_case_1_sgl),
17318 		TEST_CASE_ST(ut_setup, ut_teardown,
17319 			test_kasumi_encryption_test_case_1_oop),
17320 		TEST_CASE_ST(ut_setup, ut_teardown,
17321 			test_kasumi_encryption_test_case_1_oop_sgl),
17322 		TEST_CASE_ST(ut_setup, ut_teardown,
17323 			test_kasumi_encryption_test_case_2),
17324 		TEST_CASE_ST(ut_setup, ut_teardown,
17325 			test_kasumi_encryption_test_case_3),
17326 		TEST_CASE_ST(ut_setup, ut_teardown,
17327 			test_kasumi_encryption_test_case_4),
17328 		TEST_CASE_ST(ut_setup, ut_teardown,
17329 			test_kasumi_encryption_test_case_5),
17330 
17331 		/** KASUMI decrypt only (UEA1) */
17332 		TEST_CASE_ST(ut_setup, ut_teardown,
17333 			test_kasumi_decryption_test_case_1),
17334 		TEST_CASE_ST(ut_setup, ut_teardown,
17335 			test_kasumi_decryption_test_case_2),
17336 		TEST_CASE_ST(ut_setup, ut_teardown,
17337 			test_kasumi_decryption_test_case_3),
17338 		TEST_CASE_ST(ut_setup, ut_teardown,
17339 			test_kasumi_decryption_test_case_4),
17340 		TEST_CASE_ST(ut_setup, ut_teardown,
17341 			test_kasumi_decryption_test_case_5),
17342 		TEST_CASE_ST(ut_setup, ut_teardown,
17343 			test_kasumi_decryption_test_case_1_oop),
17344 		TEST_CASE_ST(ut_setup, ut_teardown,
17345 			test_kasumi_cipher_auth_test_case_1),
17346 
17347 		/** KASUMI generate auth, then encrypt (F8) */
17348 		TEST_CASE_ST(ut_setup, ut_teardown,
17349 			test_kasumi_auth_cipher_test_case_1),
17350 		TEST_CASE_ST(ut_setup, ut_teardown,
17351 			test_kasumi_auth_cipher_test_case_2),
17352 		TEST_CASE_ST(ut_setup, ut_teardown,
17353 			test_kasumi_auth_cipher_test_case_2_oop),
17354 		TEST_CASE_ST(ut_setup, ut_teardown,
17355 			test_kasumi_auth_cipher_test_case_2_sgl),
17356 		TEST_CASE_ST(ut_setup, ut_teardown,
17357 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
17358 
17359 		/** KASUMI decrypt (F8), then verify auth */
17360 		TEST_CASE_ST(ut_setup, ut_teardown,
17361 			test_kasumi_auth_cipher_verify_test_case_1),
17362 		TEST_CASE_ST(ut_setup, ut_teardown,
17363 			test_kasumi_auth_cipher_verify_test_case_2),
17364 		TEST_CASE_ST(ut_setup, ut_teardown,
17365 			test_kasumi_auth_cipher_verify_test_case_2_oop),
17366 		TEST_CASE_ST(ut_setup, ut_teardown,
17367 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
17368 		TEST_CASE_ST(ut_setup, ut_teardown,
17369 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
17370 
17371 		TEST_CASES_END()
17372 	}
17373 };
17374 
17375 static struct unit_test_suite cryptodev_esn_testsuite  = {
17376 	.suite_name = "ESN Test Suite",
17377 	.setup = esn_testsuite_setup,
17378 	.unit_test_cases = {
17379 		TEST_CASE_ST(ut_setup, ut_teardown,
17380 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
17381 		TEST_CASE_ST(ut_setup, ut_teardown,
17382 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
17383 		TEST_CASES_END()
17384 	}
17385 };
17386 
17387 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
17388 	.suite_name = "Negative AES GCM Test Suite",
17389 	.setup = negative_aes_gcm_testsuite_setup,
17390 	.unit_test_cases = {
17391 		TEST_CASE_ST(ut_setup, ut_teardown,
17392 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
17393 		TEST_CASE_ST(ut_setup, ut_teardown,
17394 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
17395 		TEST_CASE_ST(ut_setup, ut_teardown,
17396 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
17397 		TEST_CASE_ST(ut_setup, ut_teardown,
17398 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
17399 		TEST_CASE_ST(ut_setup, ut_teardown,
17400 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
17401 		TEST_CASE_ST(ut_setup, ut_teardown,
17402 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
17403 		TEST_CASE_ST(ut_setup, ut_teardown,
17404 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
17405 		TEST_CASE_ST(ut_setup, ut_teardown,
17406 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
17407 		TEST_CASE_ST(ut_setup, ut_teardown,
17408 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
17409 		TEST_CASE_ST(ut_setup, ut_teardown,
17410 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
17411 		TEST_CASE_ST(ut_setup, ut_teardown,
17412 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
17413 		TEST_CASE_ST(ut_setup, ut_teardown,
17414 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
17415 
17416 		TEST_CASES_END()
17417 	}
17418 };
17419 
17420 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
17421 	.suite_name = "Negative AES GMAC Test Suite",
17422 	.setup = negative_aes_gmac_testsuite_setup,
17423 	.unit_test_cases = {
17424 		TEST_CASE_ST(ut_setup, ut_teardown,
17425 			authentication_verify_AES128_GMAC_fail_data_corrupt),
17426 		TEST_CASE_ST(ut_setup, ut_teardown,
17427 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
17428 
17429 		TEST_CASES_END()
17430 	}
17431 };
17432 
17433 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
17434 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
17435 	.setup = mixed_cipher_hash_testsuite_setup,
17436 	.unit_test_cases = {
17437 		/** AUTH AES CMAC + CIPHER AES CTR */
17438 		TEST_CASE_ST(ut_setup, ut_teardown,
17439 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
17440 		TEST_CASE_ST(ut_setup, ut_teardown,
17441 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17442 		TEST_CASE_ST(ut_setup, ut_teardown,
17443 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17444 		TEST_CASE_ST(ut_setup, ut_teardown,
17445 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17446 		TEST_CASE_ST(ut_setup, ut_teardown,
17447 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
17448 		TEST_CASE_ST(ut_setup, ut_teardown,
17449 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
17450 		TEST_CASE_ST(ut_setup, ut_teardown,
17451 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
17452 		TEST_CASE_ST(ut_setup, ut_teardown,
17453 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
17454 		TEST_CASE_ST(ut_setup, ut_teardown,
17455 			test_aes_cmac_aes_ctr_digest_enc_test_case_2),
17456 		TEST_CASE_ST(ut_setup, ut_teardown,
17457 			test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17458 		TEST_CASE_ST(ut_setup, ut_teardown,
17459 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
17460 		TEST_CASE_ST(ut_setup, ut_teardown,
17461 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
17462 
17463 		/** AUTH ZUC + CIPHER SNOW3G */
17464 		TEST_CASE_ST(ut_setup, ut_teardown,
17465 			test_auth_zuc_cipher_snow_test_case_1),
17466 		TEST_CASE_ST(ut_setup, ut_teardown,
17467 			test_verify_auth_zuc_cipher_snow_test_case_1),
17468 		TEST_CASE_ST(ut_setup, ut_teardown,
17469 			test_auth_zuc_cipher_snow_test_case_1_inplace),
17470 		TEST_CASE_ST(ut_setup, ut_teardown,
17471 			test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
17472 		/** AUTH AES CMAC + CIPHER SNOW3G */
17473 		TEST_CASE_ST(ut_setup, ut_teardown,
17474 			test_auth_aes_cmac_cipher_snow_test_case_1),
17475 		TEST_CASE_ST(ut_setup, ut_teardown,
17476 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
17477 		TEST_CASE_ST(ut_setup, ut_teardown,
17478 			test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
17479 		TEST_CASE_ST(ut_setup, ut_teardown,
17480 			test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
17481 		/** AUTH ZUC + CIPHER AES CTR */
17482 		TEST_CASE_ST(ut_setup, ut_teardown,
17483 			test_auth_zuc_cipher_aes_ctr_test_case_1),
17484 		TEST_CASE_ST(ut_setup, ut_teardown,
17485 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
17486 		TEST_CASE_ST(ut_setup, ut_teardown,
17487 			test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
17488 		TEST_CASE_ST(ut_setup, ut_teardown,
17489 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
17490 		/** AUTH SNOW3G + CIPHER AES CTR */
17491 		TEST_CASE_ST(ut_setup, ut_teardown,
17492 			test_auth_snow_cipher_aes_ctr_test_case_1),
17493 		TEST_CASE_ST(ut_setup, ut_teardown,
17494 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
17495 		TEST_CASE_ST(ut_setup, ut_teardown,
17496 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
17497 		TEST_CASE_ST(ut_setup, ut_teardown,
17498 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
17499 		TEST_CASE_ST(ut_setup, ut_teardown,
17500 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
17501 		TEST_CASE_ST(ut_setup, ut_teardown,
17502 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
17503 		/** AUTH SNOW3G + CIPHER ZUC */
17504 		TEST_CASE_ST(ut_setup, ut_teardown,
17505 			test_auth_snow_cipher_zuc_test_case_1),
17506 		TEST_CASE_ST(ut_setup, ut_teardown,
17507 			test_verify_auth_snow_cipher_zuc_test_case_1),
17508 		TEST_CASE_ST(ut_setup, ut_teardown,
17509 			test_auth_snow_cipher_zuc_test_case_1_inplace),
17510 		TEST_CASE_ST(ut_setup, ut_teardown,
17511 			test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
17512 		/** AUTH AES CMAC + CIPHER ZUC */
17513 		TEST_CASE_ST(ut_setup, ut_teardown,
17514 			test_auth_aes_cmac_cipher_zuc_test_case_1),
17515 		TEST_CASE_ST(ut_setup, ut_teardown,
17516 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
17517 		TEST_CASE_ST(ut_setup, ut_teardown,
17518 			test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
17519 		TEST_CASE_ST(ut_setup, ut_teardown,
17520 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
17521 
17522 		/** AUTH NULL + CIPHER SNOW3G */
17523 		TEST_CASE_ST(ut_setup, ut_teardown,
17524 			test_auth_null_cipher_snow_test_case_1),
17525 		TEST_CASE_ST(ut_setup, ut_teardown,
17526 			test_verify_auth_null_cipher_snow_test_case_1),
17527 		/** AUTH NULL + CIPHER ZUC */
17528 		TEST_CASE_ST(ut_setup, ut_teardown,
17529 			test_auth_null_cipher_zuc_test_case_1),
17530 		TEST_CASE_ST(ut_setup, ut_teardown,
17531 			test_verify_auth_null_cipher_zuc_test_case_1),
17532 		/** AUTH SNOW3G + CIPHER NULL */
17533 		TEST_CASE_ST(ut_setup, ut_teardown,
17534 			test_auth_snow_cipher_null_test_case_1),
17535 		TEST_CASE_ST(ut_setup, ut_teardown,
17536 			test_verify_auth_snow_cipher_null_test_case_1),
17537 		/** AUTH ZUC + CIPHER NULL */
17538 		TEST_CASE_ST(ut_setup, ut_teardown,
17539 			test_auth_zuc_cipher_null_test_case_1),
17540 		TEST_CASE_ST(ut_setup, ut_teardown,
17541 			test_verify_auth_zuc_cipher_null_test_case_1),
17542 		/** AUTH NULL + CIPHER AES CTR */
17543 		TEST_CASE_ST(ut_setup, ut_teardown,
17544 			test_auth_null_cipher_aes_ctr_test_case_1),
17545 		TEST_CASE_ST(ut_setup, ut_teardown,
17546 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
17547 		/** AUTH AES CMAC + CIPHER NULL */
17548 		TEST_CASE_ST(ut_setup, ut_teardown,
17549 			test_auth_aes_cmac_cipher_null_test_case_1),
17550 		TEST_CASE_ST(ut_setup, ut_teardown,
17551 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
17552 		TEST_CASES_END()
17553 	}
17554 };
17555 
17556 static int
17557 run_cryptodev_testsuite(const char *pmd_name)
17558 {
17559 	uint8_t ret, j, i = 0, blk_start_idx = 0;
17560 	const enum blockcipher_test_type blk_suites[] = {
17561 		BLKCIPHER_AES_CHAIN_TYPE,
17562 		BLKCIPHER_AES_CIPHERONLY_TYPE,
17563 		BLKCIPHER_AES_DOCSIS_TYPE,
17564 		BLKCIPHER_3DES_CHAIN_TYPE,
17565 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
17566 		BLKCIPHER_DES_CIPHERONLY_TYPE,
17567 		BLKCIPHER_DES_DOCSIS_TYPE,
17568 		BLKCIPHER_SM4_CHAIN_TYPE,
17569 		BLKCIPHER_SM4_CIPHERONLY_TYPE,
17570 		BLKCIPHER_AUTHONLY_TYPE};
17571 	struct unit_test_suite *static_suites[] = {
17572 		&cryptodev_multi_session_testsuite,
17573 		&cryptodev_null_testsuite,
17574 		&cryptodev_aes_ccm_auth_testsuite,
17575 		&cryptodev_aes_gcm_auth_testsuite,
17576 		&cryptodev_aes_gmac_auth_testsuite,
17577 		&cryptodev_snow3g_testsuite,
17578 		&cryptodev_chacha20_poly1305_testsuite,
17579 		&cryptodev_zuc_testsuite,
17580 		&cryptodev_hmac_md5_auth_testsuite,
17581 		&cryptodev_kasumi_testsuite,
17582 		&cryptodev_esn_testsuite,
17583 		&cryptodev_negative_aes_gcm_testsuite,
17584 		&cryptodev_negative_aes_gmac_testsuite,
17585 		&cryptodev_mixed_cipher_hash_testsuite,
17586 		&cryptodev_negative_hmac_sha1_testsuite,
17587 		&cryptodev_gen_testsuite,
17588 #ifdef RTE_LIB_SECURITY
17589 		&ipsec_proto_testsuite,
17590 		&pdcp_proto_testsuite,
17591 		&docsis_proto_testsuite,
17592 #endif
17593 		&end_testsuite
17594 	};
17595 	static struct unit_test_suite ts = {
17596 		.suite_name = "Cryptodev Unit Test Suite",
17597 		.setup = testsuite_setup,
17598 		.teardown = testsuite_teardown,
17599 		.unit_test_cases = {TEST_CASES_END()}
17600 	};
17601 
17602 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
17603 
17604 	if (gbl_driver_id == -1) {
17605 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
17606 		return TEST_SKIPPED;
17607 	}
17608 
17609 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
17610 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
17611 
17612 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
17613 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
17614 	ret = unit_test_suite_runner(&ts);
17615 
17616 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
17617 	free(ts.unit_test_suites);
17618 	return ret;
17619 }
17620 
17621 static int
17622 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
17623 {
17624 	struct rte_cryptodev_info dev_info;
17625 	uint8_t i, nb_devs;
17626 	int driver_id;
17627 
17628 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
17629 	if (driver_id == -1) {
17630 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
17631 		return TEST_SKIPPED;
17632 	}
17633 
17634 	nb_devs = rte_cryptodev_count();
17635 	if (nb_devs < 1) {
17636 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
17637 		return TEST_SKIPPED;
17638 	}
17639 
17640 	for (i = 0; i < nb_devs; i++) {
17641 		rte_cryptodev_info_get(i, &dev_info);
17642 		if (dev_info.driver_id == driver_id) {
17643 			if (!(dev_info.feature_flags & flag)) {
17644 				RTE_LOG(INFO, USER1, "%s not supported\n",
17645 						flag_name);
17646 				return TEST_SKIPPED;
17647 			}
17648 			return 0; /* found */
17649 		}
17650 	}
17651 
17652 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
17653 	return TEST_SKIPPED;
17654 }
17655 
17656 static int
17657 test_cryptodev_qat(void)
17658 {
17659 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
17660 }
17661 
17662 static int
17663 test_cryptodev_uadk(void)
17664 {
17665 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
17666 }
17667 
17668 static int
17669 test_cryptodev_virtio(void)
17670 {
17671 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
17672 }
17673 
17674 static int
17675 test_cryptodev_aesni_mb(void)
17676 {
17677 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17678 }
17679 
17680 static int
17681 test_cryptodev_cpu_aesni_mb(void)
17682 {
17683 	int32_t rc;
17684 	enum rte_security_session_action_type at = gbl_action_type;
17685 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
17686 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17687 	gbl_action_type = at;
17688 	return rc;
17689 }
17690 
17691 static int
17692 test_cryptodev_chacha_poly_mb(void)
17693 {
17694 	int32_t rc;
17695 	enum rte_security_session_action_type at = gbl_action_type;
17696 	rc = run_cryptodev_testsuite(
17697 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
17698 	gbl_action_type = at;
17699 	return rc;
17700 }
17701 
17702 static int
17703 test_cryptodev_openssl(void)
17704 {
17705 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
17706 }
17707 
17708 static int
17709 test_cryptodev_aesni_gcm(void)
17710 {
17711 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
17712 }
17713 
17714 static int
17715 test_cryptodev_cpu_aesni_gcm(void)
17716 {
17717 	int32_t rc;
17718 	enum rte_security_session_action_type at = gbl_action_type;
17719 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
17720 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
17721 	gbl_action_type = at;
17722 	return rc;
17723 }
17724 
17725 static int
17726 test_cryptodev_mlx5(void)
17727 {
17728 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
17729 }
17730 
17731 static int
17732 test_cryptodev_null(void)
17733 {
17734 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
17735 }
17736 
17737 static int
17738 test_cryptodev_sw_snow3g(void)
17739 {
17740 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
17741 }
17742 
17743 static int
17744 test_cryptodev_sw_kasumi(void)
17745 {
17746 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
17747 }
17748 
17749 static int
17750 test_cryptodev_sw_zuc(void)
17751 {
17752 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
17753 }
17754 
17755 static int
17756 test_cryptodev_armv8(void)
17757 {
17758 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
17759 }
17760 
17761 static int
17762 test_cryptodev_mrvl(void)
17763 {
17764 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
17765 }
17766 
17767 #ifdef RTE_CRYPTO_SCHEDULER
17768 
17769 static int
17770 test_cryptodev_scheduler(void)
17771 {
17772 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
17773 	const enum blockcipher_test_type blk_suites[] = {
17774 		BLKCIPHER_AES_CHAIN_TYPE,
17775 		BLKCIPHER_AES_CIPHERONLY_TYPE,
17776 		BLKCIPHER_AUTHONLY_TYPE
17777 	};
17778 	static struct unit_test_suite scheduler_multicore = {
17779 		.suite_name = "Scheduler Multicore Unit Test Suite",
17780 		.setup = scheduler_multicore_testsuite_setup,
17781 		.teardown = scheduler_mode_testsuite_teardown,
17782 		.unit_test_cases = {TEST_CASES_END()}
17783 	};
17784 	static struct unit_test_suite scheduler_round_robin = {
17785 		.suite_name = "Scheduler Round Robin Unit Test Suite",
17786 		.setup = scheduler_roundrobin_testsuite_setup,
17787 		.teardown = scheduler_mode_testsuite_teardown,
17788 		.unit_test_cases = {TEST_CASES_END()}
17789 	};
17790 	static struct unit_test_suite scheduler_failover = {
17791 		.suite_name = "Scheduler Failover Unit Test Suite",
17792 		.setup = scheduler_failover_testsuite_setup,
17793 		.teardown = scheduler_mode_testsuite_teardown,
17794 		.unit_test_cases = {TEST_CASES_END()}
17795 	};
17796 	static struct unit_test_suite scheduler_pkt_size_distr = {
17797 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
17798 		.setup = scheduler_pkt_size_distr_testsuite_setup,
17799 		.teardown = scheduler_mode_testsuite_teardown,
17800 		.unit_test_cases = {TEST_CASES_END()}
17801 	};
17802 	struct unit_test_suite *sched_mode_suites[] = {
17803 		&scheduler_multicore,
17804 		&scheduler_round_robin,
17805 		&scheduler_failover,
17806 		&scheduler_pkt_size_distr
17807 	};
17808 	static struct unit_test_suite scheduler_config = {
17809 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
17810 		.unit_test_cases = {
17811 			TEST_CASE(test_scheduler_attach_worker_op),
17812 			TEST_CASE(test_scheduler_mode_multicore_op),
17813 			TEST_CASE(test_scheduler_mode_roundrobin_op),
17814 			TEST_CASE(test_scheduler_mode_failover_op),
17815 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
17816 			TEST_CASE(test_scheduler_detach_worker_op),
17817 
17818 			TEST_CASES_END() /**< NULL terminate array */
17819 		}
17820 	};
17821 	struct unit_test_suite *static_suites[] = {
17822 		&scheduler_config,
17823 		&end_testsuite
17824 	};
17825 	struct unit_test_suite *sched_mode_static_suites[] = {
17826 #ifdef RTE_LIB_SECURITY
17827 		&docsis_proto_testsuite,
17828 #endif
17829 		&end_testsuite
17830 	};
17831 	static struct unit_test_suite ts = {
17832 		.suite_name = "Scheduler Unit Test Suite",
17833 		.setup = scheduler_testsuite_setup,
17834 		.teardown = testsuite_teardown,
17835 		.unit_test_cases = {TEST_CASES_END()}
17836 	};
17837 
17838 	gbl_driver_id =	rte_cryptodev_driver_id_get(
17839 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17840 
17841 	if (gbl_driver_id == -1) {
17842 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
17843 		return TEST_SKIPPED;
17844 	}
17845 
17846 	if (rte_cryptodev_driver_id_get(
17847 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
17848 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
17849 		return TEST_SKIPPED;
17850 	}
17851 
17852 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
17853 		uint8_t blk_i = 0;
17854 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
17855 				(struct unit_test_suite *) *
17856 				(RTE_DIM(blk_suites) +
17857 				RTE_DIM(sched_mode_static_suites) + 1));
17858 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
17859 				blk_suites, RTE_DIM(blk_suites));
17860 		ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
17861 				sched_mode_static_suites,
17862 				RTE_DIM(sched_mode_static_suites));
17863 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
17864 	}
17865 
17866 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
17867 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
17868 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
17869 			RTE_DIM(sched_mode_suites));
17870 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
17871 	ret = unit_test_suite_runner(&ts);
17872 
17873 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
17874 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
17875 				(*sched_mode_suites[sched_i]),
17876 				RTE_DIM(blk_suites));
17877 		free(sched_mode_suites[sched_i]->unit_test_suites);
17878 	}
17879 	free(ts.unit_test_suites);
17880 	return ret;
17881 }
17882 
17883 REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
17884 
17885 #endif
17886 
17887 static int
17888 test_cryptodev_dpaa2_sec(void)
17889 {
17890 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
17891 }
17892 
17893 static int
17894 test_cryptodev_dpaa_sec(void)
17895 {
17896 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
17897 }
17898 
17899 static int
17900 test_cryptodev_ccp(void)
17901 {
17902 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
17903 }
17904 
17905 static int
17906 test_cryptodev_octeontx(void)
17907 {
17908 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
17909 }
17910 
17911 static int
17912 test_cryptodev_caam_jr(void)
17913 {
17914 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
17915 }
17916 
17917 static int
17918 test_cryptodev_nitrox(void)
17919 {
17920 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
17921 }
17922 
17923 static int
17924 test_cryptodev_bcmfs(void)
17925 {
17926 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
17927 }
17928 
17929 static int
17930 run_cryptodev_raw_testsuite(const char *pmd_name)
17931 {
17932 	int ret;
17933 
17934 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
17935 	if (ret)
17936 		return ret;
17937 
17938 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
17939 	ret = run_cryptodev_testsuite(pmd_name);
17940 	global_api_test_type = CRYPTODEV_API_TEST;
17941 
17942 	return ret;
17943 }
17944 
17945 static int
17946 test_cryptodev_qat_raw_api(void)
17947 {
17948 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
17949 }
17950 
17951 static int
17952 test_cryptodev_cn9k(void)
17953 {
17954 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
17955 }
17956 
17957 static int
17958 test_cryptodev_cn10k(void)
17959 {
17960 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
17961 }
17962 
17963 static int
17964 test_cryptodev_cn10k_raw_api(void)
17965 {
17966 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
17967 }
17968 
17969 static int
17970 test_cryptodev_dpaa2_sec_raw_api(void)
17971 {
17972 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
17973 }
17974 
17975 static int
17976 test_cryptodev_dpaa_sec_raw_api(void)
17977 {
17978 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
17979 }
17980 
17981 REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
17982 		test_cryptodev_cn10k_raw_api);
17983 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
17984 		test_cryptodev_dpaa2_sec_raw_api);
17985 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
17986 		test_cryptodev_dpaa_sec_raw_api);
17987 REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
17988 		test_cryptodev_qat_raw_api);
17989 REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
17990 REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
17991 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
17992 	test_cryptodev_cpu_aesni_mb);
17993 REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
17994 	test_cryptodev_chacha_poly_mb);
17995 REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
17996 REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
17997 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
17998 	test_cryptodev_cpu_aesni_gcm);
17999 REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
18000 REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
18001 REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
18002 REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
18003 REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
18004 REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
18005 REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
18006 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
18007 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
18008 REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
18009 REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
18010 REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
18011 REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
18012 REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
18013 REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
18014 REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
18015 REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
18016 REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
18017