xref: /dpdk/app/test/test_cryptodev.c (revision 7983ec4be57afc4ffeef7d72c60b1e5145d8318a)
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_cryptodev_security_tls_record.h"
57 #include "test_security_proto.h"
58 
59 #define SDAP_DISABLED	0
60 #define SDAP_ENABLED	1
61 #endif
62 
63 #define VDEV_ARGS_SIZE 100
64 #define MAX_NB_SESSIONS 4
65 
66 #define MAX_DRV_SERVICE_CTX_SIZE 256
67 
68 #define MAX_RAW_DEQUEUE_COUNT	65535
69 
70 #define IN_PLACE 0
71 #define OUT_OF_PLACE 1
72 
73 static int gbl_driver_id;
74 
75 static enum rte_security_session_action_type gbl_action_type =
76 	RTE_SECURITY_ACTION_TYPE_NONE;
77 
78 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
79 
80 struct crypto_unittest_params {
81 	struct rte_crypto_sym_xform cipher_xform;
82 	struct rte_crypto_sym_xform auth_xform;
83 	struct rte_crypto_sym_xform aead_xform;
84 #ifdef RTE_LIB_SECURITY
85 	struct rte_security_docsis_xform docsis_xform;
86 #endif
87 
88 	union {
89 		void *sess;
90 #ifdef RTE_LIB_SECURITY
91 		void *sec_session;
92 #endif
93 	};
94 #ifdef RTE_LIB_SECURITY
95 	enum rte_security_session_action_type type;
96 #endif
97 	struct rte_crypto_op *op;
98 
99 	struct rte_mbuf *obuf, *ibuf;
100 
101 	uint8_t *digest;
102 };
103 
104 #define ALIGN_POW2_ROUNDUP(num, align) \
105 	(((num) + (align) - 1) & ~((align) - 1))
106 
107 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
108 	for (j = 0; j < num_child_ts; index++, j++)			\
109 		parent_ts.unit_test_suites[index] = child_ts[j]
110 
111 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
112 	for (j = 0; j < num_blk_types; index++, j++)				\
113 		parent_ts.unit_test_suites[index] =				\
114 				build_blockcipher_test_suite(blk_types[j])
115 
116 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
117 	for (j = index; j < index + num_blk_types; j++)				\
118 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
119 
120 /*
121  * Forward declarations.
122  */
123 static int
124 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
125 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
126 		uint8_t *hmac_key);
127 
128 static int
129 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
130 		struct crypto_unittest_params *ut_params,
131 		struct crypto_testsuite_params *ts_param,
132 		const uint8_t *cipher,
133 		const uint8_t *digest,
134 		const uint8_t *iv);
135 
136 static int
137 security_proto_supported(enum rte_security_session_action_type action,
138 	enum rte_security_session_protocol proto);
139 
140 static int
141 dev_configure_and_start(uint64_t ff_disable);
142 
143 static int
144 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
145 			const enum rte_crypto_cipher_algorithm cipher_algo,
146 			const uint16_t key_size, const uint16_t iv_size);
147 
148 static int
149 check_auth_capability(const struct crypto_testsuite_params *ts_params,
150 			const enum rte_crypto_auth_algorithm auth_algo,
151 			const uint16_t key_size, const uint16_t iv_size,
152 			const uint16_t tag_size);
153 
154 static struct rte_mbuf *
155 setup_test_string(struct rte_mempool *mpool,
156 		const char *string, size_t len, uint8_t blocksize)
157 {
158 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
159 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
160 
161 	if (m) {
162 		char *dst;
163 
164 		memset(m->buf_addr, 0, m->buf_len);
165 		dst = rte_pktmbuf_append(m, t_len);
166 		if (!dst) {
167 			rte_pktmbuf_free(m);
168 			return NULL;
169 		}
170 		if (string != NULL)
171 			rte_memcpy(dst, string, t_len);
172 		else
173 			memset(dst, 0, t_len);
174 	}
175 
176 	return m;
177 }
178 
179 /* Get number of bytes in X bits (rounding up) */
180 static uint32_t
181 ceil_byte_length(uint32_t num_bits)
182 {
183 	if (num_bits % 8)
184 		return ((num_bits >> 3) + 1);
185 	else
186 		return (num_bits >> 3);
187 }
188 
189 static void
190 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
191 		uint8_t is_op_success)
192 {
193 	struct rte_crypto_op *op = user_data;
194 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
195 			RTE_CRYPTO_OP_STATUS_ERROR;
196 }
197 
198 static struct crypto_testsuite_params testsuite_params = { NULL };
199 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
200 static struct crypto_unittest_params unittest_params;
201 
202 int
203 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
204 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
205 		uint8_t len_in_bits, uint8_t cipher_iv_len)
206 {
207 	struct rte_crypto_sym_op *sop = op->sym;
208 	struct rte_crypto_op *ret_op = NULL;
209 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
210 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
211 	union rte_crypto_sym_ofs ofs;
212 	struct rte_crypto_sym_vec vec;
213 	struct rte_crypto_sgl sgl, dest_sgl;
214 	uint32_t max_len;
215 	union rte_cryptodev_session_ctx sess;
216 	uint64_t auth_end_iova;
217 	uint32_t count = 0;
218 	struct rte_crypto_raw_dp_ctx *ctx;
219 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
220 			auth_len = 0;
221 	int32_t n;
222 	uint32_t n_success;
223 	int ctx_service_size;
224 	int32_t status = 0;
225 	int enqueue_status, dequeue_status;
226 	struct crypto_unittest_params *ut_params = &unittest_params;
227 	int is_sgl = sop->m_src->nb_segs > 1;
228 	int ret = TEST_SUCCESS, is_oop = 0;
229 
230 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
231 	if (ctx_service_size < 0)
232 		return TEST_SKIPPED;
233 
234 	ctx = malloc(ctx_service_size);
235 	if (ctx == NULL)
236 		return TEST_FAILED;
237 
238 	/* Both are enums, setting crypto_sess will suit any session type */
239 	sess.crypto_sess = op->sym->session;
240 
241 	ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
242 	if (ret == -ENOTSUP) {
243 		ret = TEST_SKIPPED;
244 		goto exit;
245 	} else if (ret) {
246 		ret = TEST_FAILED;
247 		goto exit;
248 	}
249 
250 	cipher_iv.iova = 0;
251 	cipher_iv.va = NULL;
252 	aad_auth_iv.iova = 0;
253 	aad_auth_iv.va = NULL;
254 	digest.iova = 0;
255 	digest.va = NULL;
256 	sgl.vec = data_vec;
257 	vec.num = 1;
258 	vec.src_sgl = &sgl;
259 	vec.iv = &cipher_iv;
260 	vec.digest = &digest;
261 	vec.aad = &aad_auth_iv;
262 	vec.status = &status;
263 
264 	ofs.raw = 0;
265 
266 	if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
267 		is_oop = 1;
268 
269 	if (is_cipher && is_auth) {
270 		cipher_offset = sop->cipher.data.offset;
271 		cipher_len = sop->cipher.data.length;
272 		auth_offset = sop->auth.data.offset;
273 		auth_len = sop->auth.data.length;
274 		max_len = RTE_MAX(cipher_offset + cipher_len,
275 				auth_offset + auth_len);
276 		if (len_in_bits) {
277 			max_len = max_len >> 3;
278 			cipher_offset = cipher_offset >> 3;
279 			auth_offset = auth_offset >> 3;
280 			cipher_len = cipher_len >> 3;
281 			auth_len = auth_len >> 3;
282 		}
283 		ofs.ofs.cipher.head = cipher_offset;
284 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
285 		ofs.ofs.auth.head = auth_offset;
286 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
287 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
288 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
289 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
290 				op, void *, IV_OFFSET + cipher_iv_len);
291 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
292 				cipher_iv_len);
293 		digest.va = (void *)sop->auth.digest.data;
294 		digest.iova = sop->auth.digest.phys_addr;
295 
296 		if (is_sgl) {
297 			uint32_t remaining_off = auth_offset + auth_len;
298 			struct rte_mbuf *sgl_buf = sop->m_src;
299 			if (is_oop)
300 				sgl_buf = sop->m_dst;
301 
302 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
303 					&& sgl_buf->next != NULL) {
304 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
305 				sgl_buf = sgl_buf->next;
306 			}
307 
308 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
309 				sgl_buf, remaining_off);
310 		} else {
311 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
312 							 auth_offset + auth_len;
313 		}
314 		/* Then check if digest-encrypted conditions are met */
315 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
316 				(digest.iova == auth_end_iova) && is_sgl)
317 			max_len = RTE_MAX(max_len,
318 				auth_offset + auth_len +
319 				ut_params->auth_xform.auth.digest_length);
320 
321 	} else if (is_cipher) {
322 		cipher_offset = sop->cipher.data.offset;
323 		cipher_len = sop->cipher.data.length;
324 		max_len = cipher_len + cipher_offset;
325 		if (len_in_bits) {
326 			max_len = max_len >> 3;
327 			cipher_offset = cipher_offset >> 3;
328 			cipher_len = cipher_len >> 3;
329 		}
330 		ofs.ofs.cipher.head = cipher_offset;
331 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
332 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
333 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
334 
335 	} else if (is_auth) {
336 		auth_offset = sop->auth.data.offset;
337 		auth_len = sop->auth.data.length;
338 		max_len = auth_len + auth_offset;
339 		if (len_in_bits) {
340 			max_len = max_len >> 3;
341 			auth_offset = auth_offset >> 3;
342 			auth_len = auth_len >> 3;
343 		}
344 		ofs.ofs.auth.head = auth_offset;
345 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
346 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
347 				op, void *, IV_OFFSET + cipher_iv_len);
348 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
349 				cipher_iv_len);
350 		digest.va = (void *)sop->auth.digest.data;
351 		digest.iova = sop->auth.digest.phys_addr;
352 
353 	} else { /* aead */
354 		cipher_offset = sop->aead.data.offset;
355 		cipher_len = sop->aead.data.length;
356 		max_len = cipher_len + cipher_offset;
357 		if (len_in_bits) {
358 			max_len = max_len >> 3;
359 			cipher_offset = cipher_offset >> 3;
360 			cipher_len = cipher_len >> 3;
361 		}
362 		ofs.ofs.cipher.head = cipher_offset;
363 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
364 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
365 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
366 		aad_auth_iv.va = (void *)sop->aead.aad.data;
367 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
368 		digest.va = (void *)sop->aead.digest.data;
369 		digest.iova = sop->aead.digest.phys_addr;
370 	}
371 
372 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
373 			data_vec, RTE_DIM(data_vec));
374 	if (n < 0 || n > sop->m_src->nb_segs) {
375 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
376 		goto exit;
377 	}
378 
379 	sgl.num = n;
380 	/* Out of place */
381 	if (is_oop) {
382 		dest_sgl.vec = dest_data_vec;
383 		vec.dest_sgl = &dest_sgl;
384 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
385 				dest_data_vec, RTE_DIM(dest_data_vec));
386 		if (n < 0 || n > sop->m_dst->nb_segs) {
387 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
388 			goto exit;
389 		}
390 		dest_sgl.num = n;
391 	} else
392 		vec.dest_sgl = NULL;
393 
394 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
395 			&enqueue_status) < 1) {
396 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
397 		goto exit;
398 	}
399 
400 	if (enqueue_status == 0) {
401 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
402 		if (status < 0) {
403 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
404 			goto exit;
405 		}
406 	} else if (enqueue_status < 0) {
407 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
408 		goto exit;
409 	}
410 
411 	n = n_success = 0;
412 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
413 		n = rte_cryptodev_raw_dequeue_burst(ctx,
414 			NULL, 1, post_process_raw_dp_op,
415 				(void **)&ret_op, 0, &n_success,
416 				&dequeue_status);
417 		if (dequeue_status < 0) {
418 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
419 			goto exit;
420 		}
421 		if (n == 0)
422 			rte_pause();
423 	}
424 
425 	if (n == 1 && dequeue_status == 0) {
426 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
427 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
428 			goto exit;
429 		}
430 	}
431 
432 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
433 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
434 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
435 					RTE_CRYPTO_OP_STATUS_SUCCESS;
436 
437 exit:
438 	free(ctx);
439 	return ret;
440 }
441 
442 static void
443 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
444 {
445 	int32_t n, st;
446 	struct rte_crypto_sym_op *sop;
447 	union rte_crypto_sym_ofs ofs;
448 	struct rte_crypto_sgl sgl;
449 	struct rte_crypto_sym_vec symvec;
450 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
451 	struct rte_crypto_vec vec[UINT8_MAX];
452 
453 	sop = op->sym;
454 
455 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
456 		sop->aead.data.length, vec, RTE_DIM(vec));
457 
458 	if (n < 0 || n != sop->m_src->nb_segs) {
459 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
460 		return;
461 	}
462 
463 	sgl.vec = vec;
464 	sgl.num = n;
465 	symvec.src_sgl = &sgl;
466 	symvec.iv = &iv_ptr;
467 	symvec.digest = &digest_ptr;
468 	symvec.aad = &aad_ptr;
469 	symvec.status = &st;
470 	symvec.num = 1;
471 
472 	/* for CPU crypto the IOVA address is not required */
473 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
474 	digest_ptr.va = (void *)sop->aead.digest.data;
475 	aad_ptr.va = (void *)sop->aead.aad.data;
476 
477 	ofs.raw = 0;
478 
479 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
480 		&symvec);
481 
482 	if (n != 1)
483 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
484 	else
485 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
486 }
487 
488 static void
489 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
490 {
491 	int32_t n, st;
492 	struct rte_crypto_sym_op *sop;
493 	union rte_crypto_sym_ofs ofs;
494 	struct rte_crypto_sgl sgl;
495 	struct rte_crypto_sym_vec symvec;
496 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
497 	struct rte_crypto_vec vec[UINT8_MAX];
498 
499 	sop = op->sym;
500 
501 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
502 		sop->auth.data.length, vec, RTE_DIM(vec));
503 
504 	if (n < 0 || n != sop->m_src->nb_segs) {
505 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
506 		return;
507 	}
508 
509 	sgl.vec = vec;
510 	sgl.num = n;
511 	symvec.src_sgl = &sgl;
512 	symvec.iv = &iv_ptr;
513 	symvec.digest = &digest_ptr;
514 	symvec.status = &st;
515 	symvec.num = 1;
516 
517 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
518 	digest_ptr.va = (void *)sop->auth.digest.data;
519 
520 	ofs.raw = 0;
521 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
522 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
523 		(sop->cipher.data.offset + sop->cipher.data.length);
524 
525 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
526 		&symvec);
527 
528 	if (n != 1)
529 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
530 	else
531 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
532 }
533 
534 static struct rte_crypto_op *
535 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
536 {
537 
538 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
539 
540 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
541 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
542 		return NULL;
543 	}
544 
545 	op = NULL;
546 
547 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
548 		rte_pause();
549 
550 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
551 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
552 		return NULL;
553 	}
554 
555 	return op;
556 }
557 
558 static int
559 testsuite_setup(void)
560 {
561 	struct crypto_testsuite_params *ts_params = &testsuite_params;
562 	struct rte_cryptodev_info info;
563 	uint32_t i = 0, nb_devs, dev_id;
564 	uint16_t qp_id;
565 
566 	memset(ts_params, 0, sizeof(*ts_params));
567 
568 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
569 	if (ts_params->mbuf_pool == NULL) {
570 		/* Not already created so create */
571 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
572 				"CRYPTO_MBUFPOOL",
573 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
574 				rte_socket_id());
575 		if (ts_params->mbuf_pool == NULL) {
576 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
577 			return TEST_FAILED;
578 		}
579 	}
580 
581 	ts_params->large_mbuf_pool = rte_mempool_lookup(
582 			"CRYPTO_LARGE_MBUFPOOL");
583 	if (ts_params->large_mbuf_pool == NULL) {
584 		/* Not already created so create */
585 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
586 				"CRYPTO_LARGE_MBUFPOOL",
587 				1, 0, 0, UINT16_MAX,
588 				rte_socket_id());
589 		if (ts_params->large_mbuf_pool == NULL) {
590 			RTE_LOG(ERR, USER1,
591 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
592 			return TEST_FAILED;
593 		}
594 	}
595 
596 	ts_params->op_mpool = rte_crypto_op_pool_create(
597 			"MBUF_CRYPTO_SYM_OP_POOL",
598 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
599 			NUM_MBUFS, MBUF_CACHE_SIZE,
600 			DEFAULT_NUM_XFORMS *
601 			sizeof(struct rte_crypto_sym_xform) +
602 			MAXIMUM_IV_LENGTH,
603 			rte_socket_id());
604 	if (ts_params->op_mpool == NULL) {
605 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
606 		return TEST_FAILED;
607 	}
608 
609 	nb_devs = rte_cryptodev_count();
610 	if (nb_devs < 1) {
611 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
612 		return TEST_SKIPPED;
613 	}
614 
615 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
616 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
617 				rte_cryptodev_driver_name_get(gbl_driver_id));
618 		return TEST_SKIPPED;
619 	}
620 
621 	/* Create list of valid crypto devs */
622 	for (i = 0; i < nb_devs; i++) {
623 		rte_cryptodev_info_get(i, &info);
624 		if (info.driver_id == gbl_driver_id)
625 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
626 	}
627 
628 	if (ts_params->valid_dev_count < 1)
629 		return TEST_FAILED;
630 
631 	/* Set up all the qps on the first of the valid devices found */
632 
633 	dev_id = ts_params->valid_devs[0];
634 
635 	rte_cryptodev_info_get(dev_id, &info);
636 
637 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
638 	ts_params->conf.socket_id = SOCKET_ID_ANY;
639 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
640 
641 	unsigned int session_size =
642 		rte_cryptodev_sym_get_private_session_size(dev_id);
643 
644 #ifdef RTE_LIB_SECURITY
645 	unsigned int security_session_size = rte_security_session_get_size(
646 			rte_cryptodev_get_sec_ctx(dev_id));
647 
648 	if (session_size < security_session_size)
649 		session_size = security_session_size;
650 #endif
651 	/*
652 	 * Create mempool with maximum number of sessions.
653 	 */
654 	if (info.sym.max_nb_sessions != 0 &&
655 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
656 		RTE_LOG(ERR, USER1, "Device does not support "
657 				"at least %u sessions\n",
658 				MAX_NB_SESSIONS);
659 		return TEST_FAILED;
660 	}
661 
662 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
663 			"test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
664 			SOCKET_ID_ANY);
665 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
666 			"session mempool allocation failed");
667 
668 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
669 			&ts_params->conf),
670 			"Failed to configure cryptodev %u with %u qps",
671 			dev_id, ts_params->conf.nb_queue_pairs);
672 
673 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
674 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
675 
676 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
677 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
678 			dev_id, qp_id, &ts_params->qp_conf,
679 			rte_cryptodev_socket_id(dev_id)),
680 			"Failed to setup queue pair %u on cryptodev %u",
681 			qp_id, dev_id);
682 	}
683 
684 	return TEST_SUCCESS;
685 }
686 
687 static void
688 testsuite_teardown(void)
689 {
690 	struct crypto_testsuite_params *ts_params = &testsuite_params;
691 	int res;
692 
693 	if (ts_params->mbuf_pool != NULL) {
694 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
695 		rte_mempool_avail_count(ts_params->mbuf_pool));
696 	}
697 
698 	if (ts_params->op_mpool != NULL) {
699 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
700 		rte_mempool_avail_count(ts_params->op_mpool));
701 	}
702 
703 	if (ts_params->session_mpool != NULL) {
704 		rte_mempool_free(ts_params->session_mpool);
705 		ts_params->session_mpool = NULL;
706 	}
707 
708 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
709 	if (res)
710 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
711 }
712 
713 static int
714 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
715 		const int *algs, uint16_t num_algs)
716 {
717 	uint8_t dev_id = testsuite_params.valid_devs[0];
718 	bool some_alg_supported = FALSE;
719 	uint16_t i;
720 
721 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
722 		struct rte_cryptodev_sym_capability_idx alg = {
723 			type, {algs[i]}
724 		};
725 		if (rte_cryptodev_sym_capability_get(dev_id,
726 				&alg) != NULL)
727 			some_alg_supported = TRUE;
728 	}
729 	if (!some_alg_supported)
730 		return TEST_SKIPPED;
731 
732 	return 0;
733 }
734 
735 int
736 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
737 		uint16_t num_ciphers)
738 {
739 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
740 			(const int *) ciphers, num_ciphers);
741 }
742 
743 int
744 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
745 		uint16_t num_auths)
746 {
747 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
748 			(const int *) auths, num_auths);
749 }
750 
751 int
752 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
753 		uint16_t num_aeads)
754 {
755 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
756 			(const int *) aeads, num_aeads);
757 }
758 
759 static int
760 null_testsuite_setup(void)
761 {
762 	struct crypto_testsuite_params *ts_params = &testsuite_params;
763 	uint8_t dev_id = ts_params->valid_devs[0];
764 	struct rte_cryptodev_info dev_info;
765 	const enum rte_crypto_cipher_algorithm ciphers[] = {
766 		RTE_CRYPTO_CIPHER_NULL
767 	};
768 	const enum rte_crypto_auth_algorithm auths[] = {
769 		RTE_CRYPTO_AUTH_NULL
770 	};
771 
772 	rte_cryptodev_info_get(dev_id, &dev_info);
773 
774 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
775 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
776 				"testsuite not met\n");
777 		return TEST_SKIPPED;
778 	}
779 
780 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
781 			&& check_auth_capabilities_supported(auths,
782 			RTE_DIM(auths)) != 0) {
783 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
784 				"testsuite not met\n");
785 		return TEST_SKIPPED;
786 	}
787 
788 	return 0;
789 }
790 
791 static int
792 crypto_gen_testsuite_setup(void)
793 {
794 	struct crypto_testsuite_params *ts_params = &testsuite_params;
795 	uint8_t dev_id = ts_params->valid_devs[0];
796 	struct rte_cryptodev_info dev_info;
797 
798 	rte_cryptodev_info_get(dev_id, &dev_info);
799 
800 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
801 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
802 				"testsuite not met\n");
803 		return TEST_SKIPPED;
804 	}
805 
806 	return 0;
807 }
808 
809 #ifdef RTE_LIB_SECURITY
810 static int
811 sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
812 {
813 	struct crypto_testsuite_params *ts_params = &testsuite_params;
814 	struct crypto_unittest_params *ut_params = &unittest_params;
815 	struct rte_cryptodev_info dev_info;
816 	int ret = 0;
817 
818 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
819 
820 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
821 		RTE_LOG(INFO, USER1,
822 			"Feature flag requirements for security protocol testsuite not met\n");
823 		return TEST_SKIPPED;
824 	}
825 
826 	/* Reconfigure to enable security */
827 	ret = dev_configure_and_start(0);
828 	if (ret != TEST_SUCCESS)
829 		return ret;
830 
831 	/* Set action type */
832 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
833 
834 	if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
835 		RTE_LOG(INFO, USER1,
836 			"Capability requirements for security protocol test not met\n");
837 		ret = TEST_SKIPPED;
838 	}
839 
840 	test_sec_alg_list_populate();
841 	test_sec_auth_only_alg_list_populate();
842 
843 	/*
844 	 * Stop the device. Device would be started again by individual test
845 	 * case setup routine.
846 	 */
847 	rte_cryptodev_stop(ts_params->valid_devs[0]);
848 
849 	return ret;
850 }
851 
852 static int
853 ipsec_proto_testsuite_setup(void)
854 {
855 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
856 }
857 
858 static int
859 tls_record_proto_testsuite_setup(void)
860 {
861 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
862 }
863 
864 static int
865 pdcp_proto_testsuite_setup(void)
866 {
867 	struct crypto_testsuite_params *ts_params = &testsuite_params;
868 	uint8_t dev_id = ts_params->valid_devs[0];
869 	struct rte_cryptodev_info dev_info;
870 	const enum rte_crypto_cipher_algorithm ciphers[] = {
871 		RTE_CRYPTO_CIPHER_NULL,
872 		RTE_CRYPTO_CIPHER_AES_CTR,
873 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
874 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
875 	};
876 	const enum rte_crypto_auth_algorithm auths[] = {
877 		RTE_CRYPTO_AUTH_NULL,
878 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
879 		RTE_CRYPTO_AUTH_AES_CMAC,
880 		RTE_CRYPTO_AUTH_ZUC_EIA3
881 	};
882 
883 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
884 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
885 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
886 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
887 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
888 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
889 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
890 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
891 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
892 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
893 
894 	rte_cryptodev_info_get(dev_id, &dev_info);
895 
896 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
897 			!(dev_info.feature_flags &
898 			RTE_CRYPTODEV_FF_SECURITY)) {
899 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
900 				"testsuite not met\n");
901 		return TEST_SKIPPED;
902 	}
903 
904 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
905 			&& check_auth_capabilities_supported(auths,
906 			RTE_DIM(auths)) != 0) {
907 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
908 				"testsuite not met\n");
909 		return TEST_SKIPPED;
910 	}
911 
912 	return 0;
913 }
914 
915 static int
916 docsis_proto_testsuite_setup(void)
917 {
918 	struct crypto_testsuite_params *ts_params = &testsuite_params;
919 	uint8_t dev_id = ts_params->valid_devs[0];
920 	struct rte_cryptodev_info dev_info;
921 	const enum rte_crypto_cipher_algorithm ciphers[] = {
922 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
923 	};
924 
925 	rte_cryptodev_info_get(dev_id, &dev_info);
926 
927 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
928 			!(dev_info.feature_flags &
929 			RTE_CRYPTODEV_FF_SECURITY)) {
930 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
931 				"Proto testsuite not met\n");
932 		return TEST_SKIPPED;
933 	}
934 
935 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
936 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
937 				"testsuite not met\n");
938 		return TEST_SKIPPED;
939 	}
940 
941 	return 0;
942 }
943 #endif
944 
945 static int
946 aes_ccm_auth_testsuite_setup(void)
947 {
948 	struct crypto_testsuite_params *ts_params = &testsuite_params;
949 	uint8_t dev_id = ts_params->valid_devs[0];
950 	struct rte_cryptodev_info dev_info;
951 	const enum rte_crypto_aead_algorithm aeads[] = {
952 		RTE_CRYPTO_AEAD_AES_CCM
953 	};
954 
955 	rte_cryptodev_info_get(dev_id, &dev_info);
956 
957 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
958 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
959 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
960 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
961 				"testsuite not met\n");
962 		return TEST_SKIPPED;
963 	}
964 
965 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
966 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
967 				"testsuite not met\n");
968 		return TEST_SKIPPED;
969 	}
970 
971 	return 0;
972 }
973 
974 static int
975 aes_gcm_auth_testsuite_setup(void)
976 {
977 	struct crypto_testsuite_params *ts_params = &testsuite_params;
978 	uint8_t dev_id = ts_params->valid_devs[0];
979 	struct rte_cryptodev_info dev_info;
980 	const enum rte_crypto_aead_algorithm aeads[] = {
981 		RTE_CRYPTO_AEAD_AES_GCM
982 	};
983 
984 	rte_cryptodev_info_get(dev_id, &dev_info);
985 
986 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
987 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
988 				"testsuite not met\n");
989 		return TEST_SKIPPED;
990 	}
991 
992 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
993 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
994 				"testsuite not met\n");
995 		return TEST_SKIPPED;
996 	}
997 
998 	return 0;
999 }
1000 
1001 static int
1002 aes_gmac_auth_testsuite_setup(void)
1003 {
1004 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1005 	uint8_t dev_id = ts_params->valid_devs[0];
1006 	struct rte_cryptodev_info dev_info;
1007 	const enum rte_crypto_auth_algorithm auths[] = {
1008 		RTE_CRYPTO_AUTH_AES_GMAC
1009 	};
1010 
1011 	rte_cryptodev_info_get(dev_id, &dev_info);
1012 
1013 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1014 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1015 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1016 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1017 				"testsuite not met\n");
1018 		return TEST_SKIPPED;
1019 	}
1020 
1021 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1022 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1023 				"testsuite not met\n");
1024 		return TEST_SKIPPED;
1025 	}
1026 
1027 	return 0;
1028 }
1029 
1030 static int
1031 chacha20_poly1305_testsuite_setup(void)
1032 {
1033 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1034 	uint8_t dev_id = ts_params->valid_devs[0];
1035 	struct rte_cryptodev_info dev_info;
1036 	const enum rte_crypto_aead_algorithm aeads[] = {
1037 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1038 	};
1039 
1040 	rte_cryptodev_info_get(dev_id, &dev_info);
1041 
1042 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1043 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1044 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1045 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1046 				"Chacha20-Poly1305 testsuite not met\n");
1047 		return TEST_SKIPPED;
1048 	}
1049 
1050 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1051 		RTE_LOG(INFO, USER1, "Capability requirements for "
1052 				"Chacha20-Poly1305 testsuite not met\n");
1053 		return TEST_SKIPPED;
1054 	}
1055 
1056 	return 0;
1057 }
1058 
1059 static int
1060 snow3g_testsuite_setup(void)
1061 {
1062 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1063 	uint8_t dev_id = ts_params->valid_devs[0];
1064 	struct rte_cryptodev_info dev_info;
1065 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1066 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1067 
1068 	};
1069 	const enum rte_crypto_auth_algorithm auths[] = {
1070 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1071 	};
1072 
1073 	rte_cryptodev_info_get(dev_id, &dev_info);
1074 
1075 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1076 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1077 				"testsuite not met\n");
1078 		return TEST_SKIPPED;
1079 	}
1080 
1081 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1082 			&& check_auth_capabilities_supported(auths,
1083 			RTE_DIM(auths)) != 0) {
1084 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1085 				"testsuite not met\n");
1086 		return TEST_SKIPPED;
1087 	}
1088 
1089 	return 0;
1090 }
1091 
1092 static int
1093 zuc_testsuite_setup(void)
1094 {
1095 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1096 	uint8_t dev_id = ts_params->valid_devs[0];
1097 	struct rte_cryptodev_info dev_info;
1098 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1099 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1100 	};
1101 	const enum rte_crypto_auth_algorithm auths[] = {
1102 		RTE_CRYPTO_AUTH_ZUC_EIA3
1103 	};
1104 
1105 	rte_cryptodev_info_get(dev_id, &dev_info);
1106 
1107 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1108 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1109 				"testsuite not met\n");
1110 		return TEST_SKIPPED;
1111 	}
1112 
1113 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1114 			&& check_auth_capabilities_supported(auths,
1115 			RTE_DIM(auths)) != 0) {
1116 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1117 				"testsuite not met\n");
1118 		return TEST_SKIPPED;
1119 	}
1120 
1121 	return 0;
1122 }
1123 
1124 static int
1125 hmac_md5_auth_testsuite_setup(void)
1126 {
1127 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1128 	uint8_t dev_id = ts_params->valid_devs[0];
1129 	struct rte_cryptodev_info dev_info;
1130 	const enum rte_crypto_auth_algorithm auths[] = {
1131 		RTE_CRYPTO_AUTH_MD5_HMAC
1132 	};
1133 
1134 	rte_cryptodev_info_get(dev_id, &dev_info);
1135 
1136 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1137 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1138 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1139 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1140 				"Auth testsuite not met\n");
1141 		return TEST_SKIPPED;
1142 	}
1143 
1144 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1145 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1146 				"testsuite not met\n");
1147 		return TEST_SKIPPED;
1148 	}
1149 
1150 	return 0;
1151 }
1152 
1153 static int
1154 kasumi_testsuite_setup(void)
1155 {
1156 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1157 	uint8_t dev_id = ts_params->valid_devs[0];
1158 	struct rte_cryptodev_info dev_info;
1159 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1160 		RTE_CRYPTO_CIPHER_KASUMI_F8
1161 	};
1162 	const enum rte_crypto_auth_algorithm auths[] = {
1163 		RTE_CRYPTO_AUTH_KASUMI_F9
1164 	};
1165 
1166 	rte_cryptodev_info_get(dev_id, &dev_info);
1167 
1168 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1169 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1170 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1171 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1172 				"testsuite not met\n");
1173 		return TEST_SKIPPED;
1174 	}
1175 
1176 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1177 			&& check_auth_capabilities_supported(auths,
1178 			RTE_DIM(auths)) != 0) {
1179 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1180 				"testsuite not met\n");
1181 		return TEST_SKIPPED;
1182 	}
1183 
1184 	return 0;
1185 }
1186 
1187 static int
1188 negative_aes_gcm_testsuite_setup(void)
1189 {
1190 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1191 	uint8_t dev_id = ts_params->valid_devs[0];
1192 	struct rte_cryptodev_info dev_info;
1193 	const enum rte_crypto_aead_algorithm aeads[] = {
1194 		RTE_CRYPTO_AEAD_AES_GCM
1195 	};
1196 
1197 	rte_cryptodev_info_get(dev_id, &dev_info);
1198 
1199 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1200 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1201 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1202 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1203 				"AES GCM testsuite not met\n");
1204 		return TEST_SKIPPED;
1205 	}
1206 
1207 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1208 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1209 				"AES GCM testsuite not met\n");
1210 		return TEST_SKIPPED;
1211 	}
1212 
1213 	return 0;
1214 }
1215 
1216 static int
1217 negative_aes_gmac_testsuite_setup(void)
1218 {
1219 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1220 	uint8_t dev_id = ts_params->valid_devs[0];
1221 	struct rte_cryptodev_info dev_info;
1222 	const enum rte_crypto_auth_algorithm auths[] = {
1223 		RTE_CRYPTO_AUTH_AES_GMAC
1224 	};
1225 
1226 	rte_cryptodev_info_get(dev_id, &dev_info);
1227 
1228 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1229 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1230 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1231 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1232 				"AES GMAC testsuite not met\n");
1233 		return TEST_SKIPPED;
1234 	}
1235 
1236 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1237 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1238 				"AES GMAC testsuite not met\n");
1239 		return TEST_SKIPPED;
1240 	}
1241 
1242 	return 0;
1243 }
1244 
1245 static int
1246 mixed_cipher_hash_testsuite_setup(void)
1247 {
1248 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1249 	uint8_t dev_id = ts_params->valid_devs[0];
1250 	struct rte_cryptodev_info dev_info;
1251 	uint64_t feat_flags;
1252 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1253 		RTE_CRYPTO_CIPHER_NULL,
1254 		RTE_CRYPTO_CIPHER_AES_CTR,
1255 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1256 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1257 	};
1258 	const enum rte_crypto_auth_algorithm auths[] = {
1259 		RTE_CRYPTO_AUTH_NULL,
1260 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1261 		RTE_CRYPTO_AUTH_AES_CMAC,
1262 		RTE_CRYPTO_AUTH_ZUC_EIA3
1263 	};
1264 
1265 	rte_cryptodev_info_get(dev_id, &dev_info);
1266 	feat_flags = dev_info.feature_flags;
1267 
1268 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1269 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1270 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1271 				"Cipher Hash testsuite not met\n");
1272 		return TEST_SKIPPED;
1273 	}
1274 
1275 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1276 			&& check_auth_capabilities_supported(auths,
1277 			RTE_DIM(auths)) != 0) {
1278 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1279 				"Cipher Hash testsuite not met\n");
1280 		return TEST_SKIPPED;
1281 	}
1282 
1283 	return 0;
1284 }
1285 
1286 static int
1287 esn_testsuite_setup(void)
1288 {
1289 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1290 	uint8_t dev_id = ts_params->valid_devs[0];
1291 	struct rte_cryptodev_info dev_info;
1292 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1293 		RTE_CRYPTO_CIPHER_AES_CBC
1294 	};
1295 	const enum rte_crypto_auth_algorithm auths[] = {
1296 		RTE_CRYPTO_AUTH_SHA1_HMAC
1297 	};
1298 
1299 	rte_cryptodev_info_get(dev_id, &dev_info);
1300 
1301 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1302 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1303 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1304 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1305 				"testsuite not met\n");
1306 		return TEST_SKIPPED;
1307 	}
1308 
1309 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1310 			&& check_auth_capabilities_supported(auths,
1311 			RTE_DIM(auths)) != 0) {
1312 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1313 				"testsuite not met\n");
1314 		return TEST_SKIPPED;
1315 	}
1316 
1317 	return 0;
1318 }
1319 
1320 static int
1321 multi_session_testsuite_setup(void)
1322 {
1323 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1324 	uint8_t dev_id = ts_params->valid_devs[0];
1325 	struct rte_cryptodev_info dev_info;
1326 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1327 		RTE_CRYPTO_CIPHER_AES_CBC
1328 	};
1329 	const enum rte_crypto_auth_algorithm auths[] = {
1330 		RTE_CRYPTO_AUTH_SHA512_HMAC
1331 	};
1332 
1333 	rte_cryptodev_info_get(dev_id, &dev_info);
1334 
1335 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1336 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1337 				"Session testsuite not met\n");
1338 		return TEST_SKIPPED;
1339 	}
1340 
1341 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1342 			&& check_auth_capabilities_supported(auths,
1343 			RTE_DIM(auths)) != 0) {
1344 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1345 				"Session testsuite not met\n");
1346 		return TEST_SKIPPED;
1347 	}
1348 
1349 	return 0;
1350 }
1351 
1352 static int
1353 negative_hmac_sha1_testsuite_setup(void)
1354 {
1355 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1356 	uint8_t dev_id = ts_params->valid_devs[0];
1357 	struct rte_cryptodev_info dev_info;
1358 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1359 		RTE_CRYPTO_CIPHER_AES_CBC
1360 	};
1361 	const enum rte_crypto_auth_algorithm auths[] = {
1362 		RTE_CRYPTO_AUTH_SHA1_HMAC
1363 	};
1364 
1365 	rte_cryptodev_info_get(dev_id, &dev_info);
1366 
1367 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1368 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1369 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1370 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1371 				"HMAC SHA1 testsuite not met\n");
1372 		return TEST_SKIPPED;
1373 	}
1374 
1375 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1376 			&& check_auth_capabilities_supported(auths,
1377 			RTE_DIM(auths)) != 0) {
1378 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1379 				"HMAC SHA1 testsuite not met\n");
1380 		return TEST_SKIPPED;
1381 	}
1382 
1383 	return 0;
1384 }
1385 
1386 static int
1387 dev_configure_and_start(uint64_t ff_disable)
1388 {
1389 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1390 	struct crypto_unittest_params *ut_params = &unittest_params;
1391 
1392 	uint16_t qp_id;
1393 
1394 	/* Clear unit test parameters before running test */
1395 	memset(ut_params, 0, sizeof(*ut_params));
1396 
1397 	/* Reconfigure device to default parameters */
1398 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1399 	ts_params->conf.ff_disable = ff_disable;
1400 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1401 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1402 
1403 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1404 			&ts_params->conf),
1405 			"Failed to configure cryptodev %u",
1406 			ts_params->valid_devs[0]);
1407 
1408 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1409 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1410 			ts_params->valid_devs[0], qp_id,
1411 			&ts_params->qp_conf,
1412 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1413 			"Failed to setup queue pair %u on cryptodev %u",
1414 			qp_id, ts_params->valid_devs[0]);
1415 	}
1416 
1417 
1418 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1419 
1420 	/* Start the device */
1421 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1422 			"Failed to start cryptodev %u",
1423 			ts_params->valid_devs[0]);
1424 
1425 	return TEST_SUCCESS;
1426 }
1427 
1428 int
1429 ut_setup(void)
1430 {
1431 	/* Configure and start the device with security feature disabled */
1432 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1433 }
1434 
1435 static int
1436 ut_setup_security(void)
1437 {
1438 	/* Configure and start the device with no features disabled */
1439 	return dev_configure_and_start(0);
1440 }
1441 
1442 static int
1443 ut_setup_security_rx_inject(void)
1444 {
1445 	struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1446 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1447 	struct rte_eth_conf port_conf = {
1448 		.rxmode = {
1449 			.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1450 				    RTE_ETH_RX_OFFLOAD_SECURITY,
1451 		},
1452 		.txmode = {
1453 			.offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1454 		},
1455 		.lpbk_mode = 1,  /* Enable loopback */
1456 	};
1457 	struct rte_cryptodev_info dev_info;
1458 	struct rte_eth_rxconf rx_conf = {
1459 		.rx_thresh = {
1460 			.pthresh = 8,
1461 			.hthresh = 8,
1462 			.wthresh = 8,
1463 		},
1464 		.rx_free_thresh = 32,
1465 	};
1466 	uint16_t nb_ports;
1467 	void *sec_ctx;
1468 	int ret;
1469 
1470 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1471 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1472 	    !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1473 		RTE_LOG(INFO, USER1,
1474 			"Feature requirements for IPsec Rx inject test case not met\n");
1475 		return TEST_SKIPPED;
1476 	}
1477 
1478 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1479 	if (sec_ctx == NULL)
1480 		return TEST_SKIPPED;
1481 
1482 	nb_ports = rte_eth_dev_count_avail();
1483 	if (nb_ports == 0)
1484 		return TEST_SKIPPED;
1485 
1486 	ret = rte_eth_dev_configure(0 /* port_id */,
1487 				    1 /* nb_rx_queue */,
1488 				    0 /* nb_tx_queue */,
1489 				    &port_conf);
1490 	if (ret) {
1491 		printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1492 		return TEST_SKIPPED;
1493 	}
1494 
1495 	/* Rx queue setup */
1496 	ret = rte_eth_rx_queue_setup(0 /* port_id */,
1497 				     0 /* rx_queue_id */,
1498 				     1024 /* nb_rx_desc */,
1499 				     SOCKET_ID_ANY,
1500 				     &rx_conf,
1501 				     mbuf_pool);
1502 	if (ret) {
1503 		printf("Could not setup eth port 0 queue 0\n");
1504 		return TEST_SKIPPED;
1505 	}
1506 
1507 	ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1508 	if (ret) {
1509 		printf("Could not enable Rx inject offload");
1510 		return TEST_SKIPPED;
1511 	}
1512 
1513 	ret = rte_eth_dev_start(0);
1514 	if (ret) {
1515 		printf("Could not start ethdev");
1516 		return TEST_SKIPPED;
1517 	}
1518 
1519 	ret = rte_eth_promiscuous_enable(0);
1520 	if (ret) {
1521 		printf("Could not enable promiscuous mode");
1522 		return TEST_SKIPPED;
1523 	}
1524 
1525 	/* Configure and start cryptodev with no features disabled */
1526 	return dev_configure_and_start(0);
1527 }
1528 
1529 static inline void
1530 ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1531 {
1532 }
1533 
1534 static inline void
1535 ext_mbuf_memzone_free(int nb_segs)
1536 {
1537 	int i;
1538 
1539 	for (i = 0; i <= nb_segs; i++) {
1540 		char mz_name[RTE_MEMZONE_NAMESIZE];
1541 		const struct rte_memzone *memzone;
1542 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1543 		memzone = rte_memzone_lookup(mz_name);
1544 		if (memzone != NULL) {
1545 			rte_memzone_free(memzone);
1546 			memzone = NULL;
1547 		}
1548 	}
1549 }
1550 
1551 static inline struct rte_mbuf *
1552 ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1553 		int nb_segs, const void *input_text)
1554 {
1555 	struct rte_mbuf *m = NULL, *mbuf = NULL;
1556 	size_t data_off = 0;
1557 	uint8_t *dst;
1558 	int i, size;
1559 	int t_len;
1560 
1561 	if (pkt_len < 1) {
1562 		printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1563 		return NULL;
1564 	}
1565 
1566 	if (nb_segs < 1) {
1567 		printf("Number of segments must be 1 or more (is %d)\n",
1568 				nb_segs);
1569 		return NULL;
1570 	}
1571 
1572 	t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1573 	size = pkt_len;
1574 
1575 	/* Create chained mbuf_src with external buffer */
1576 	for (i = 0; size > 0; i++) {
1577 		struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1578 		uint16_t data_len = RTE_MIN(size, t_len);
1579 		char mz_name[RTE_MEMZONE_NAMESIZE];
1580 		const struct rte_memzone *memzone;
1581 		void *ext_buf_addr = NULL;
1582 		rte_iova_t buf_iova;
1583 		bool freed = false;
1584 		uint16_t buf_len;
1585 
1586 		buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1587 			sizeof(struct rte_mbuf_ext_shared_info), 8);
1588 
1589 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1590 		memzone = rte_memzone_lookup(mz_name);
1591 		if (memzone != NULL && memzone->len != buf_len) {
1592 			rte_memzone_free(memzone);
1593 			memzone = NULL;
1594 		}
1595 		if (memzone == NULL) {
1596 			memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1597 				RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1598 			if (memzone == NULL) {
1599 				printf("Can't allocate memory zone %s\n", mz_name);
1600 				return NULL;
1601 			}
1602 		}
1603 
1604 		ext_buf_addr = memzone->addr;
1605 		if (input_text)
1606 			memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1607 
1608 		/* Create buffer to hold rte_mbuf header */
1609 		m = rte_pktmbuf_alloc(mbuf_pool);
1610 		if (i == 0)
1611 			mbuf = m;
1612 
1613 		if (m == NULL) {
1614 			printf("Cannot create segment for source mbuf");
1615 			goto fail;
1616 		}
1617 
1618 		/* Save shared data (like callback function) in external buffer’s end */
1619 		ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1620 			ext_mbuf_callback_fn_free, &freed);
1621 		if (ret_shinfo == NULL) {
1622 			printf("Shared mem initialization failed!\n");
1623 			goto fail;
1624 		}
1625 
1626 		buf_iova = rte_mem_virt2iova(ext_buf_addr);
1627 
1628 		/* Attach external buffer to mbuf */
1629 		rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1630 			ret_shinfo);
1631 		if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1632 			printf("External buffer is not attached to mbuf\n");
1633 			goto fail;
1634 		}
1635 
1636 		if (input_text) {
1637 			dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1638 			if (dst == NULL) {
1639 				printf("Cannot append %d bytes to the mbuf\n", data_len);
1640 				goto fail;
1641 			}
1642 		}
1643 
1644 		if (mbuf != m)
1645 			rte_pktmbuf_chain(mbuf, m);
1646 
1647 		size -= data_len;
1648 		data_off += data_len;
1649 	}
1650 
1651 	return mbuf;
1652 
1653 fail:
1654 	rte_pktmbuf_free(mbuf);
1655 	ext_mbuf_memzone_free(nb_segs);
1656 	return NULL;
1657 }
1658 
1659 void
1660 ut_teardown(void)
1661 {
1662 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1663 	struct crypto_unittest_params *ut_params = &unittest_params;
1664 
1665 	/* free crypto session structure */
1666 #ifdef RTE_LIB_SECURITY
1667 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1668 		if (ut_params->sec_session) {
1669 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1670 						(ts_params->valid_devs[0]),
1671 						ut_params->sec_session);
1672 			ut_params->sec_session = NULL;
1673 		}
1674 	} else
1675 #endif
1676 	{
1677 		if (ut_params->sess) {
1678 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1679 					ut_params->sess);
1680 			ut_params->sess = NULL;
1681 		}
1682 	}
1683 
1684 	/* free crypto operation structure */
1685 	rte_crypto_op_free(ut_params->op);
1686 
1687 	/*
1688 	 * free mbuf - both obuf and ibuf are usually the same,
1689 	 * so check if they point at the same address is necessary,
1690 	 * to avoid freeing the mbuf twice.
1691 	 */
1692 	if (ut_params->obuf) {
1693 		rte_pktmbuf_free(ut_params->obuf);
1694 		if (ut_params->ibuf == ut_params->obuf)
1695 			ut_params->ibuf = 0;
1696 		ut_params->obuf = 0;
1697 	}
1698 	if (ut_params->ibuf) {
1699 		ext_mbuf_memzone_free(1);
1700 		rte_pktmbuf_free(ut_params->ibuf);
1701 		ut_params->ibuf = 0;
1702 	}
1703 
1704 	if (ts_params->mbuf_pool != NULL)
1705 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1706 			rte_mempool_avail_count(ts_params->mbuf_pool));
1707 
1708 	/* Stop the device */
1709 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1710 }
1711 
1712 static void
1713 ut_teardown_rx_inject(void)
1714 {
1715 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 	void *sec_ctx;
1717 	int ret;
1718 
1719 	if  (rte_eth_dev_count_avail() != 0) {
1720 		ret = rte_eth_dev_reset(0);
1721 		if (ret)
1722 			printf("Could not reset eth port 0");
1723 
1724 	}
1725 
1726 	ut_teardown();
1727 
1728 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1729 	if (sec_ctx == NULL)
1730 		return;
1731 
1732 	ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1733 	if (ret) {
1734 		printf("Could not disable Rx inject offload");
1735 		return;
1736 	}
1737 }
1738 
1739 static int
1740 test_device_configure_invalid_dev_id(void)
1741 {
1742 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1743 	uint16_t dev_id, num_devs = 0;
1744 
1745 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1746 			"Need at least %d devices for test", 1);
1747 
1748 	/* valid dev_id values */
1749 	dev_id = ts_params->valid_devs[0];
1750 
1751 	/* Stop the device in case it's started so it can be configured */
1752 	rte_cryptodev_stop(dev_id);
1753 
1754 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1755 			"Failed test for rte_cryptodev_configure: "
1756 			"invalid dev_num %u", dev_id);
1757 
1758 	/* invalid dev_id values */
1759 	dev_id = num_devs;
1760 
1761 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1762 			"Failed test for rte_cryptodev_configure: "
1763 			"invalid dev_num %u", dev_id);
1764 
1765 	dev_id = 0xff;
1766 
1767 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1768 			"Failed test for rte_cryptodev_configure:"
1769 			"invalid dev_num %u", dev_id);
1770 
1771 	return TEST_SUCCESS;
1772 }
1773 
1774 static int
1775 test_device_configure_invalid_queue_pair_ids(void)
1776 {
1777 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1778 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1779 
1780 	/* Stop the device in case it's started so it can be configured */
1781 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1782 
1783 	/* valid - max value queue pairs */
1784 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1785 
1786 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1787 			&ts_params->conf),
1788 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1789 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1790 
1791 	/* valid - one queue pairs */
1792 	ts_params->conf.nb_queue_pairs = 1;
1793 
1794 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1795 			&ts_params->conf),
1796 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1797 			ts_params->valid_devs[0],
1798 			ts_params->conf.nb_queue_pairs);
1799 
1800 
1801 	/* invalid - zero queue pairs */
1802 	ts_params->conf.nb_queue_pairs = 0;
1803 
1804 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1805 			&ts_params->conf),
1806 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1807 			" invalid qps: %u",
1808 			ts_params->valid_devs[0],
1809 			ts_params->conf.nb_queue_pairs);
1810 
1811 
1812 	/* invalid - max value supported by field queue pairs */
1813 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1814 
1815 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1816 			&ts_params->conf),
1817 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1818 			" invalid qps: %u",
1819 			ts_params->valid_devs[0],
1820 			ts_params->conf.nb_queue_pairs);
1821 
1822 
1823 	/* invalid - max value + 1 queue pairs */
1824 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1825 
1826 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1827 			&ts_params->conf),
1828 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1829 			" invalid qps: %u",
1830 			ts_params->valid_devs[0],
1831 			ts_params->conf.nb_queue_pairs);
1832 
1833 	/* revert to original testsuite value */
1834 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1835 
1836 	return TEST_SUCCESS;
1837 }
1838 
1839 static int
1840 test_queue_pair_descriptor_setup(void)
1841 {
1842 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1843 	struct rte_cryptodev_qp_conf qp_conf = {
1844 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1845 	};
1846 	uint16_t qp_id;
1847 
1848 	/* Stop the device in case it's started so it can be configured */
1849 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1850 
1851 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1852 			&ts_params->conf),
1853 			"Failed to configure cryptodev %u",
1854 			ts_params->valid_devs[0]);
1855 
1856 	/*
1857 	 * Test various ring sizes on this device. memzones can't be
1858 	 * freed so are re-used if ring is released and re-created.
1859 	 */
1860 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1861 	qp_conf.mp_session = ts_params->session_mpool;
1862 
1863 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1864 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1865 				ts_params->valid_devs[0], qp_id, &qp_conf,
1866 				rte_cryptodev_socket_id(
1867 						ts_params->valid_devs[0])),
1868 				"Failed test for "
1869 				"rte_cryptodev_queue_pair_setup: num_inflights "
1870 				"%u on qp %u on cryptodev %u",
1871 				qp_conf.nb_descriptors, qp_id,
1872 				ts_params->valid_devs[0]);
1873 	}
1874 
1875 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1876 
1877 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1878 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1879 				ts_params->valid_devs[0], qp_id, &qp_conf,
1880 				rte_cryptodev_socket_id(
1881 						ts_params->valid_devs[0])),
1882 				"Failed test for"
1883 				" rte_cryptodev_queue_pair_setup: num_inflights"
1884 				" %u on qp %u on cryptodev %u",
1885 				qp_conf.nb_descriptors, qp_id,
1886 				ts_params->valid_devs[0]);
1887 	}
1888 
1889 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1890 
1891 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1892 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1893 				ts_params->valid_devs[0], qp_id, &qp_conf,
1894 				rte_cryptodev_socket_id(
1895 						ts_params->valid_devs[0])),
1896 				"Failed test for "
1897 				"rte_cryptodev_queue_pair_setup: num_inflights"
1898 				" %u on qp %u on cryptodev %u",
1899 				qp_conf.nb_descriptors, qp_id,
1900 				ts_params->valid_devs[0]);
1901 	}
1902 
1903 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1904 
1905 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1906 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1907 				ts_params->valid_devs[0], qp_id, &qp_conf,
1908 				rte_cryptodev_socket_id(
1909 						ts_params->valid_devs[0])),
1910 				"Failed test for"
1911 				" rte_cryptodev_queue_pair_setup:"
1912 				"num_inflights %u on qp %u on cryptodev %u",
1913 				qp_conf.nb_descriptors, qp_id,
1914 				ts_params->valid_devs[0]);
1915 	}
1916 
1917 	/* test invalid queue pair id */
1918 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1919 
1920 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1921 
1922 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1923 			ts_params->valid_devs[0],
1924 			qp_id, &qp_conf,
1925 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1926 			"Failed test for rte_cryptodev_queue_pair_setup:"
1927 			"invalid qp %u on cryptodev %u",
1928 			qp_id, ts_params->valid_devs[0]);
1929 
1930 	qp_id = 0xffff; /*invalid*/
1931 
1932 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1933 			ts_params->valid_devs[0],
1934 			qp_id, &qp_conf,
1935 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1936 			"Failed test for rte_cryptodev_queue_pair_setup:"
1937 			"invalid qp %u on cryptodev %u",
1938 			qp_id, ts_params->valid_devs[0]);
1939 
1940 	return TEST_SUCCESS;
1941 }
1942 
1943 /* ***** Plaintext data for tests ***** */
1944 
1945 const char catch_22_quote_1[] =
1946 		"There was only one catch and that was Catch-22, which "
1947 		"specified that a concern for one's safety in the face of "
1948 		"dangers that were real and immediate was the process of a "
1949 		"rational mind. Orr was crazy and could be grounded. All he "
1950 		"had to do was ask; and as soon as he did, he would no longer "
1951 		"be crazy and would have to fly more missions. Orr would be "
1952 		"crazy to fly more missions and sane if he didn't, but if he "
1953 		"was sane he had to fly them. If he flew them he was crazy "
1954 		"and didn't have to; but if he didn't want to he was sane and "
1955 		"had to. Yossarian was moved very deeply by the absolute "
1956 		"simplicity of this clause of Catch-22 and let out a "
1957 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1958 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1959 
1960 const char catch_22_quote[] =
1961 		"What a lousy earth! He wondered how many people were "
1962 		"destitute that same night even in his own prosperous country, "
1963 		"how many homes were shanties, how many husbands were drunk "
1964 		"and wives socked, and how many children were bullied, abused, "
1965 		"or abandoned. How many families hungered for food they could "
1966 		"not afford to buy? How many hearts were broken? How many "
1967 		"suicides would take place that same night, how many people "
1968 		"would go insane? How many cockroaches and landlords would "
1969 		"triumph? How many winners were losers, successes failures, "
1970 		"and rich men poor men? How many wise guys were stupid? How "
1971 		"many happy endings were unhappy endings? How many honest men "
1972 		"were liars, brave men cowards, loyal men traitors, how many "
1973 		"sainted men were corrupt, how many people in positions of "
1974 		"trust had sold their souls to bodyguards, how many had never "
1975 		"had souls? How many straight-and-narrow paths were crooked "
1976 		"paths? How many best families were worst families and how "
1977 		"many good people were bad people? When you added them all up "
1978 		"and then subtracted, you might be left with only the children, "
1979 		"and perhaps with Albert Einstein and an old violinist or "
1980 		"sculptor somewhere.";
1981 
1982 #define QUOTE_480_BYTES		(480)
1983 #define QUOTE_512_BYTES		(512)
1984 #define QUOTE_768_BYTES		(768)
1985 #define QUOTE_1024_BYTES	(1024)
1986 
1987 
1988 
1989 /* ***** SHA1 Hash Tests ***** */
1990 
1991 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1992 
1993 static uint8_t hmac_sha1_key[] = {
1994 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1995 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1996 	0xDE, 0xF4, 0xDE, 0xAD };
1997 
1998 /* ***** SHA224 Hash Tests ***** */
1999 
2000 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
2001 
2002 
2003 /* ***** AES-CBC Cipher Tests ***** */
2004 
2005 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
2006 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
2007 
2008 static uint8_t aes_cbc_key[] = {
2009 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2010 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2011 
2012 static uint8_t aes_cbc_iv[] = {
2013 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2014 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2015 
2016 
2017 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2018 
2019 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2020 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2021 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2022 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2023 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2024 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2025 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2026 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2027 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2028 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2029 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2030 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2031 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2032 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2033 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2034 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2035 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2036 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2037 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2038 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2039 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2040 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2041 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2042 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2043 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2044 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2045 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2046 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2047 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2048 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2049 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2050 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2051 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2052 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2053 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2054 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2055 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2056 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2057 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2058 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2059 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2060 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2061 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2062 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2063 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2064 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2065 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2066 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2067 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2068 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2069 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2070 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2071 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2072 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2073 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2074 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2075 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2076 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2077 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2078 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2079 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2080 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2081 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2082 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2083 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2084 };
2085 
2086 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2087 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2088 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2089 	0x18, 0x8c, 0x1d, 0x32
2090 };
2091 
2092 
2093 /* Multisession Vector context Test */
2094 /*Begin Session 0 */
2095 static uint8_t ms_aes_cbc_key0[] = {
2096 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2097 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2098 };
2099 
2100 static uint8_t ms_aes_cbc_iv0[] = {
2101 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2102 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2103 };
2104 
2105 static const uint8_t ms_aes_cbc_cipher0[] = {
2106 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2107 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2108 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2109 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2110 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2111 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2112 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2113 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2114 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2115 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2116 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2117 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2118 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2119 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2120 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2121 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2122 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2123 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2124 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2125 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2126 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2127 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2128 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2129 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2130 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2131 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2132 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2133 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2134 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2135 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2136 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2137 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2138 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2139 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2140 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2141 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2142 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2143 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2144 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2145 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2146 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2147 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2148 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2149 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2150 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2151 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2152 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2153 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2154 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2155 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2156 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2157 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2158 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2159 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2160 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2161 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2162 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2163 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2164 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2165 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2166 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2167 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2168 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2169 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2170 };
2171 
2172 
2173 static  uint8_t ms_hmac_key0[] = {
2174 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2175 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2176 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2177 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2178 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2179 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2180 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2181 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2182 };
2183 
2184 static const uint8_t ms_hmac_digest0[] = {
2185 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2186 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2187 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2188 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2189 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2190 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2191 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2192 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2193 		};
2194 
2195 /* End Session 0 */
2196 /* Begin session 1 */
2197 
2198 static  uint8_t ms_aes_cbc_key1[] = {
2199 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2200 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2201 };
2202 
2203 static  uint8_t ms_aes_cbc_iv1[] = {
2204 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2205 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2206 };
2207 
2208 static const uint8_t ms_aes_cbc_cipher1[] = {
2209 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2210 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2211 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2212 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2213 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2214 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2215 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2216 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2217 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2218 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2219 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2220 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2221 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2222 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2223 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2224 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2225 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2226 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2227 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2228 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2229 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2230 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2231 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2232 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2233 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2234 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2235 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2236 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2237 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2238 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2239 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2240 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2241 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2242 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2243 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2244 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2245 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2246 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2247 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2248 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2249 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2250 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2251 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2252 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2253 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2254 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2255 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2256 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2257 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2258 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2259 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2260 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2261 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2262 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2263 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2264 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2265 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2266 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2267 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2268 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2269 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2270 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2271 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2272 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2273 
2274 };
2275 
2276 static uint8_t ms_hmac_key1[] = {
2277 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2278 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2279 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2280 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2281 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2282 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2283 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2284 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2285 };
2286 
2287 static const uint8_t ms_hmac_digest1[] = {
2288 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2289 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2290 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2291 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2292 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2293 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2294 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2295 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2296 };
2297 /* End Session 1  */
2298 /* Begin Session 2 */
2299 static  uint8_t ms_aes_cbc_key2[] = {
2300 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2301 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2302 };
2303 
2304 static  uint8_t ms_aes_cbc_iv2[] = {
2305 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2306 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2307 };
2308 
2309 static const uint8_t ms_aes_cbc_cipher2[] = {
2310 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2311 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2312 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2313 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2314 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2315 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2316 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2317 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2318 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2319 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2320 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2321 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2322 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2323 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2324 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2325 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2326 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2327 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2328 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2329 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2330 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2331 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2332 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2333 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2334 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2335 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2336 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2337 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2338 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2339 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2340 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2341 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2342 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2343 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2344 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2345 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2346 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2347 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2348 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2349 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2350 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2351 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2352 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2353 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2354 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2355 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2356 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2357 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2358 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2359 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2360 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2361 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2362 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2363 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2364 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2365 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2366 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2367 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2368 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2369 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2370 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2371 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2372 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2373 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2374 };
2375 
2376 static  uint8_t ms_hmac_key2[] = {
2377 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2378 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2379 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2380 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2381 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2382 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2383 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2384 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2385 };
2386 
2387 static const uint8_t ms_hmac_digest2[] = {
2388 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2389 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2390 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2391 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2392 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2393 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2394 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2395 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2396 };
2397 
2398 /* End Session 2 */
2399 
2400 
2401 static int
2402 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2403 {
2404 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2405 	struct crypto_unittest_params *ut_params = &unittest_params;
2406 	/* Verify the capabilities */
2407 	struct rte_cryptodev_sym_capability_idx cap_idx;
2408 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2409 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2410 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2411 			&cap_idx) == NULL)
2412 		return TEST_SKIPPED;
2413 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2414 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2415 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2416 			&cap_idx) == NULL)
2417 		return TEST_SKIPPED;
2418 
2419 	/* Generate test mbuf data and space for digest */
2420 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2421 			catch_22_quote,	QUOTE_512_BYTES, 0);
2422 
2423 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2424 			DIGEST_BYTE_LENGTH_SHA1);
2425 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2426 
2427 	/* Setup Cipher Parameters */
2428 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2429 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2430 
2431 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2432 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2433 	ut_params->cipher_xform.cipher.key.data = aes_cbc_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 
2441 	ut_params->auth_xform.next = NULL;
2442 
2443 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2444 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2445 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2446 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2447 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2448 
2449 	rte_errno = 0;
2450 	ut_params->sess = rte_cryptodev_sym_session_create(
2451 			ts_params->valid_devs[0], &ut_params->cipher_xform,
2452 			ts_params->session_mpool);
2453 	if (rte_errno == ENOTSUP)
2454 		return TEST_SKIPPED;
2455 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2456 
2457 	/* Generate crypto op data structure */
2458 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2459 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2460 	TEST_ASSERT_NOT_NULL(ut_params->op,
2461 			"Failed to allocate symmetric crypto operation struct");
2462 
2463 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2464 
2465 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2466 
2467 	/* set crypto operation source mbuf */
2468 	sym_op->m_src = ut_params->ibuf;
2469 
2470 	/* Set crypto operation authentication parameters */
2471 	sym_op->auth.digest.data = ut_params->digest;
2472 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2473 			ut_params->ibuf, QUOTE_512_BYTES);
2474 
2475 	sym_op->auth.data.offset = 0;
2476 	sym_op->auth.data.length = QUOTE_512_BYTES;
2477 
2478 	/* Copy IV at the end of the crypto operation */
2479 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2480 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2481 
2482 	/* Set crypto operation cipher parameters */
2483 	sym_op->cipher.data.offset = 0;
2484 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2485 
2486 	/* Process crypto operation */
2487 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2488 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2489 			ut_params->op);
2490 	else
2491 		TEST_ASSERT_NOT_NULL(
2492 			process_crypto_request(ts_params->valid_devs[0],
2493 				ut_params->op),
2494 				"failed to process sym crypto op");
2495 
2496 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2497 			"crypto op processing failed");
2498 
2499 	/* Validate obuf */
2500 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2501 			uint8_t *);
2502 
2503 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2504 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2505 			QUOTE_512_BYTES,
2506 			"ciphertext data not as expected");
2507 
2508 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2509 
2510 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2511 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2512 			gbl_driver_id == rte_cryptodev_driver_id_get(
2513 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2514 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2515 					DIGEST_BYTE_LENGTH_SHA1,
2516 			"Generated digest data not as expected");
2517 
2518 	return TEST_SUCCESS;
2519 }
2520 
2521 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2522 
2523 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2524 
2525 static uint8_t hmac_sha512_key[] = {
2526 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2527 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2528 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2529 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2530 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2531 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2532 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2533 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2534 
2535 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2536 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2537 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2538 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2539 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2540 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2541 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2542 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2543 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2544 
2545 
2546 
2547 static int
2548 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2549 		struct crypto_unittest_params *ut_params,
2550 		uint8_t *cipher_key,
2551 		uint8_t *hmac_key);
2552 
2553 static int
2554 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2555 		struct crypto_unittest_params *ut_params,
2556 		struct crypto_testsuite_params *ts_params,
2557 		const uint8_t *cipher,
2558 		const uint8_t *digest,
2559 		const uint8_t *iv);
2560 
2561 
2562 static int
2563 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2564 		struct crypto_unittest_params *ut_params,
2565 		uint8_t *cipher_key,
2566 		uint8_t *hmac_key)
2567 {
2568 
2569 	/* Setup Cipher Parameters */
2570 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2571 	ut_params->cipher_xform.next = NULL;
2572 
2573 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2574 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2575 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2576 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2577 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2578 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2579 
2580 	/* Setup HMAC Parameters */
2581 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2582 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2583 
2584 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2585 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2586 	ut_params->auth_xform.auth.key.data = hmac_key;
2587 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2588 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2589 
2590 	return TEST_SUCCESS;
2591 }
2592 
2593 
2594 static int
2595 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2596 		struct crypto_unittest_params *ut_params,
2597 		struct crypto_testsuite_params *ts_params,
2598 		const uint8_t *cipher,
2599 		const uint8_t *digest,
2600 		const uint8_t *iv)
2601 {
2602 	int ret;
2603 
2604 	/* Generate test mbuf data and digest */
2605 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2606 			(const char *)
2607 			cipher,
2608 			QUOTE_512_BYTES, 0);
2609 
2610 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2611 			DIGEST_BYTE_LENGTH_SHA512);
2612 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2613 
2614 	rte_memcpy(ut_params->digest,
2615 			digest,
2616 			DIGEST_BYTE_LENGTH_SHA512);
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 symmetric crypto operation struct");
2623 
2624 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2625 
2626 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2627 
2628 	/* set crypto operation source mbuf */
2629 	sym_op->m_src = ut_params->ibuf;
2630 
2631 	sym_op->auth.digest.data = ut_params->digest;
2632 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2633 			ut_params->ibuf, QUOTE_512_BYTES);
2634 
2635 	sym_op->auth.data.offset = 0;
2636 	sym_op->auth.data.length = QUOTE_512_BYTES;
2637 
2638 	/* Copy IV at the end of the crypto operation */
2639 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2640 			iv, CIPHER_IV_LENGTH_AES_CBC);
2641 
2642 	sym_op->cipher.data.offset = 0;
2643 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2644 
2645 	/* Process crypto operation */
2646 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2647 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2648 			ut_params->op);
2649 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2650 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2651 		if (ret != TEST_SUCCESS)
2652 			return ret;
2653 	} else
2654 		TEST_ASSERT_NOT_NULL(
2655 				process_crypto_request(ts_params->valid_devs[0],
2656 					ut_params->op),
2657 					"failed to process sym crypto op");
2658 
2659 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2660 			"crypto op processing failed");
2661 
2662 	ut_params->obuf = ut_params->op->sym->m_src;
2663 
2664 	/* Validate obuf */
2665 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2666 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2667 			catch_22_quote,
2668 			QUOTE_512_BYTES,
2669 			"Plaintext data not as expected");
2670 
2671 	/* Validate obuf */
2672 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2673 			"Digest verification failed");
2674 
2675 	return TEST_SUCCESS;
2676 }
2677 
2678 /* ***** SNOW 3G Tests ***** */
2679 static int
2680 create_wireless_algo_hash_session(uint8_t dev_id,
2681 	const uint8_t *key, const uint8_t key_len,
2682 	const uint8_t iv_len, const uint8_t auth_len,
2683 	enum rte_crypto_auth_operation op,
2684 	enum rte_crypto_auth_algorithm algo)
2685 {
2686 	uint8_t hash_key[key_len];
2687 
2688 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2689 	struct crypto_unittest_params *ut_params = &unittest_params;
2690 
2691 	memcpy(hash_key, key, key_len);
2692 
2693 	debug_hexdump(stdout, "key:", key, key_len);
2694 
2695 	/* Setup Authentication Parameters */
2696 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2697 	ut_params->auth_xform.next = NULL;
2698 
2699 	ut_params->auth_xform.auth.op = op;
2700 	ut_params->auth_xform.auth.algo = algo;
2701 	ut_params->auth_xform.auth.key.length = key_len;
2702 	ut_params->auth_xform.auth.key.data = hash_key;
2703 	ut_params->auth_xform.auth.digest_length = auth_len;
2704 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2705 	ut_params->auth_xform.auth.iv.length = iv_len;
2706 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2707 			&ut_params->auth_xform, ts_params->session_mpool);
2708 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2709 		return TEST_SKIPPED;
2710 
2711 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2712 	return 0;
2713 }
2714 
2715 static int
2716 create_wireless_algo_cipher_session(uint8_t dev_id,
2717 			enum rte_crypto_cipher_operation op,
2718 			enum rte_crypto_cipher_algorithm algo,
2719 			const uint8_t *key, const uint8_t key_len,
2720 			uint8_t iv_len)
2721 {
2722 	uint8_t cipher_key[key_len];
2723 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2724 	struct crypto_unittest_params *ut_params = &unittest_params;
2725 
2726 	memcpy(cipher_key, key, key_len);
2727 
2728 	/* Setup Cipher Parameters */
2729 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2730 	ut_params->cipher_xform.next = NULL;
2731 
2732 	ut_params->cipher_xform.cipher.algo = algo;
2733 	ut_params->cipher_xform.cipher.op = op;
2734 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2735 	ut_params->cipher_xform.cipher.key.length = key_len;
2736 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2737 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2738 
2739 	debug_hexdump(stdout, "key:", key, key_len);
2740 
2741 	/* Create Crypto session */
2742 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2743 			&ut_params->cipher_xform, ts_params->session_mpool);
2744 
2745 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2746 		return TEST_SKIPPED;
2747 
2748 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2749 	return 0;
2750 }
2751 
2752 static int
2753 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2754 			unsigned int cipher_len,
2755 			unsigned int cipher_offset)
2756 {
2757 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2758 	struct crypto_unittest_params *ut_params = &unittest_params;
2759 
2760 	/* Generate Crypto op data structure */
2761 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2762 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2763 	TEST_ASSERT_NOT_NULL(ut_params->op,
2764 				"Failed to allocate pktmbuf offload");
2765 
2766 	/* Set crypto operation data parameters */
2767 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2768 
2769 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2770 
2771 	/* set crypto operation source mbuf */
2772 	sym_op->m_src = ut_params->ibuf;
2773 
2774 	/* iv */
2775 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2776 			iv, iv_len);
2777 	sym_op->cipher.data.length = cipher_len;
2778 	sym_op->cipher.data.offset = cipher_offset;
2779 	return 0;
2780 }
2781 
2782 static int
2783 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2784 			unsigned int cipher_len,
2785 			unsigned int cipher_offset)
2786 {
2787 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2788 	struct crypto_unittest_params *ut_params = &unittest_params;
2789 
2790 	/* Generate Crypto op data structure */
2791 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2792 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2793 	TEST_ASSERT_NOT_NULL(ut_params->op,
2794 				"Failed to allocate pktmbuf offload");
2795 
2796 	/* Set crypto operation data parameters */
2797 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2798 
2799 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2800 
2801 	/* set crypto operation source mbuf */
2802 	sym_op->m_src = ut_params->ibuf;
2803 	sym_op->m_dst = ut_params->obuf;
2804 
2805 	/* iv */
2806 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2807 			iv, iv_len);
2808 	sym_op->cipher.data.length = cipher_len;
2809 	sym_op->cipher.data.offset = cipher_offset;
2810 	return 0;
2811 }
2812 
2813 static int
2814 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2815 		enum rte_crypto_cipher_operation cipher_op,
2816 		enum rte_crypto_auth_operation auth_op,
2817 		enum rte_crypto_auth_algorithm auth_algo,
2818 		enum rte_crypto_cipher_algorithm cipher_algo,
2819 		const uint8_t *a_key, uint8_t a_key_len,
2820 		const uint8_t *c_key, uint8_t c_key_len,
2821 		uint8_t auth_iv_len, uint8_t auth_len,
2822 		uint8_t cipher_iv_len)
2823 
2824 {
2825 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2826 	struct crypto_unittest_params *ut_params = &unittest_params;
2827 
2828 	/* Setup Authentication Parameters */
2829 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2830 	ut_params->auth_xform.next = NULL;
2831 
2832 	ut_params->auth_xform.auth.op = auth_op;
2833 	ut_params->auth_xform.auth.algo = auth_algo;
2834 	ut_params->auth_xform.auth.key.length = a_key_len;
2835 	ut_params->auth_xform.auth.key.data = a_key;
2836 	ut_params->auth_xform.auth.digest_length = auth_len;
2837 	/* Auth IV will be after cipher IV */
2838 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2839 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2840 
2841 	/* Setup Cipher Parameters */
2842 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2843 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2844 
2845 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2846 	ut_params->cipher_xform.cipher.op = cipher_op;
2847 	ut_params->cipher_xform.cipher.key.data = c_key;
2848 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2849 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2850 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2851 
2852 	debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
2853 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2854 
2855 	/* Create Crypto session*/
2856 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2857 			&ut_params->cipher_xform, ts_params->session_mpool);
2858 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2859 		return TEST_SKIPPED;
2860 
2861 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2862 	return 0;
2863 }
2864 
2865 static int
2866 create_wireless_cipher_auth_session(uint8_t dev_id,
2867 		enum rte_crypto_cipher_operation cipher_op,
2868 		enum rte_crypto_auth_operation auth_op,
2869 		enum rte_crypto_auth_algorithm auth_algo,
2870 		enum rte_crypto_cipher_algorithm cipher_algo,
2871 		const struct wireless_test_data *tdata)
2872 {
2873 	const uint8_t key_len = tdata->key.len;
2874 	uint8_t cipher_auth_key[key_len];
2875 
2876 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2877 	struct crypto_unittest_params *ut_params = &unittest_params;
2878 	const uint8_t *key = tdata->key.data;
2879 	const uint8_t auth_len = tdata->digest.len;
2880 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2881 	uint8_t auth_iv_len = tdata->auth_iv.len;
2882 
2883 	memcpy(cipher_auth_key, key, key_len);
2884 
2885 	/* Setup Authentication Parameters */
2886 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2887 	ut_params->auth_xform.next = NULL;
2888 
2889 	ut_params->auth_xform.auth.op = auth_op;
2890 	ut_params->auth_xform.auth.algo = auth_algo;
2891 	ut_params->auth_xform.auth.key.length = key_len;
2892 	/* Hash key = cipher key */
2893 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2894 	ut_params->auth_xform.auth.digest_length = auth_len;
2895 	/* Auth IV will be after cipher IV */
2896 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2897 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2898 
2899 	/* Setup Cipher Parameters */
2900 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2901 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2902 
2903 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2904 	ut_params->cipher_xform.cipher.op = cipher_op;
2905 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2906 	ut_params->cipher_xform.cipher.key.length = key_len;
2907 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2908 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2909 
2910 
2911 	debug_hexdump(stdout, "key:", key, key_len);
2912 
2913 	/* Create Crypto session*/
2914 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2915 			&ut_params->cipher_xform, ts_params->session_mpool);
2916 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2917 		return TEST_SKIPPED;
2918 
2919 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2920 	return 0;
2921 }
2922 
2923 static int
2924 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2925 		const struct wireless_test_data *tdata)
2926 {
2927 	return create_wireless_cipher_auth_session(dev_id,
2928 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2929 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2930 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2931 }
2932 
2933 static int
2934 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2935 		enum rte_crypto_cipher_operation cipher_op,
2936 		enum rte_crypto_auth_operation auth_op,
2937 		enum rte_crypto_auth_algorithm auth_algo,
2938 		enum rte_crypto_cipher_algorithm cipher_algo,
2939 		const uint8_t *a_key, const uint8_t a_key_len,
2940 		const uint8_t *c_key, const uint8_t c_key_len,
2941 		uint8_t auth_iv_len, uint8_t auth_len,
2942 		uint8_t cipher_iv_len)
2943 {
2944 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2945 	struct crypto_unittest_params *ut_params = &unittest_params;
2946 
2947 	/* Setup Authentication Parameters */
2948 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2949 	ut_params->auth_xform.auth.op = auth_op;
2950 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2951 	ut_params->auth_xform.auth.algo = auth_algo;
2952 	ut_params->auth_xform.auth.key.length = a_key_len;
2953 	ut_params->auth_xform.auth.key.data = a_key;
2954 	ut_params->auth_xform.auth.digest_length = auth_len;
2955 	/* Auth IV will be after cipher IV */
2956 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2957 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2958 
2959 	/* Setup Cipher Parameters */
2960 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2961 	ut_params->cipher_xform.next = NULL;
2962 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2963 	ut_params->cipher_xform.cipher.op = cipher_op;
2964 	ut_params->cipher_xform.cipher.key.data = c_key;
2965 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2966 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2967 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2968 
2969 	debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
2970 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2971 
2972 	/* Create Crypto session*/
2973 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2974 		ut_params->auth_xform.next = NULL;
2975 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2976 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2977 			&ut_params->cipher_xform, ts_params->session_mpool);
2978 	} else
2979 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2980 			&ut_params->auth_xform, ts_params->session_mpool);
2981 
2982 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2983 		return TEST_SKIPPED;
2984 
2985 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2986 
2987 	return 0;
2988 }
2989 
2990 static int
2991 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2992 		unsigned int auth_tag_len,
2993 		const uint8_t *iv, unsigned int iv_len,
2994 		unsigned int data_pad_len,
2995 		enum rte_crypto_auth_operation op,
2996 		unsigned int auth_len, unsigned int auth_offset)
2997 {
2998 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2999 
3000 	struct crypto_unittest_params *ut_params = &unittest_params;
3001 
3002 	/* Generate Crypto op data structure */
3003 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3004 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3005 	TEST_ASSERT_NOT_NULL(ut_params->op,
3006 		"Failed to allocate pktmbuf offload");
3007 
3008 	/* Set crypto operation data parameters */
3009 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3010 
3011 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3012 
3013 	/* set crypto operation source mbuf */
3014 	sym_op->m_src = ut_params->ibuf;
3015 
3016 	/* iv */
3017 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3018 			iv, iv_len);
3019 	/* digest */
3020 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3021 					ut_params->ibuf, auth_tag_len);
3022 
3023 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3024 				"no room to append auth tag");
3025 	ut_params->digest = sym_op->auth.digest.data;
3026 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3027 			ut_params->ibuf, data_pad_len);
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 	sym_op->auth.data.length = auth_len;
3038 	sym_op->auth.data.offset = auth_offset;
3039 
3040 	return 0;
3041 }
3042 
3043 static int
3044 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3045 	enum rte_crypto_auth_operation op)
3046 {
3047 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3048 	struct crypto_unittest_params *ut_params = &unittest_params;
3049 
3050 	const uint8_t *auth_tag = tdata->digest.data;
3051 	const unsigned int auth_tag_len = tdata->digest.len;
3052 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3053 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3054 
3055 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
3056 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3057 	const uint8_t *auth_iv = tdata->auth_iv.data;
3058 	const uint8_t auth_iv_len = tdata->auth_iv.len;
3059 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3060 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
3061 
3062 	/* Generate Crypto op data structure */
3063 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3064 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3065 	TEST_ASSERT_NOT_NULL(ut_params->op,
3066 			"Failed to allocate pktmbuf offload");
3067 	/* Set crypto operation data parameters */
3068 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3069 
3070 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3071 
3072 	/* set crypto operation source mbuf */
3073 	sym_op->m_src = ut_params->ibuf;
3074 
3075 	/* digest */
3076 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3077 			ut_params->ibuf, auth_tag_len);
3078 
3079 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3080 			"no room to append auth tag");
3081 	ut_params->digest = sym_op->auth.digest.data;
3082 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3083 			ut_params->ibuf, data_pad_len);
3084 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3085 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3086 	else
3087 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3088 
3089 	debug_hexdump(stdout, "digest:",
3090 		sym_op->auth.digest.data,
3091 		auth_tag_len);
3092 
3093 	/* Copy cipher and auth IVs at the end of the crypto operation */
3094 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3095 						IV_OFFSET);
3096 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3097 	iv_ptr += cipher_iv_len;
3098 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3099 
3100 	sym_op->cipher.data.length = cipher_len;
3101 	sym_op->cipher.data.offset = 0;
3102 	sym_op->auth.data.length = auth_len;
3103 	sym_op->auth.data.offset = 0;
3104 
3105 	return 0;
3106 }
3107 
3108 static int
3109 create_zuc_cipher_hash_generate_operation(
3110 		const struct wireless_test_data *tdata)
3111 {
3112 	return create_wireless_cipher_hash_operation(tdata,
3113 		RTE_CRYPTO_AUTH_OP_GENERATE);
3114 }
3115 
3116 static int
3117 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3118 		const unsigned auth_tag_len,
3119 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3120 		unsigned data_pad_len,
3121 		enum rte_crypto_auth_operation op,
3122 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3123 		const unsigned cipher_len, const unsigned cipher_offset,
3124 		const unsigned auth_len, const unsigned auth_offset)
3125 {
3126 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3127 	struct crypto_unittest_params *ut_params = &unittest_params;
3128 
3129 	enum rte_crypto_cipher_algorithm cipher_algo =
3130 			ut_params->cipher_xform.cipher.algo;
3131 	enum rte_crypto_auth_algorithm auth_algo =
3132 			ut_params->auth_xform.auth.algo;
3133 
3134 	/* Generate Crypto op data structure */
3135 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3136 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3137 	TEST_ASSERT_NOT_NULL(ut_params->op,
3138 			"Failed to allocate pktmbuf offload");
3139 	/* Set crypto operation data parameters */
3140 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3141 
3142 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3143 
3144 	/* set crypto operation source mbuf */
3145 	sym_op->m_src = ut_params->ibuf;
3146 
3147 	/* digest */
3148 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3149 			ut_params->ibuf, auth_tag_len);
3150 
3151 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3152 			"no room to append auth tag");
3153 	ut_params->digest = sym_op->auth.digest.data;
3154 
3155 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3156 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3157 				ut_params->ibuf, data_pad_len);
3158 	} else {
3159 		struct rte_mbuf *m = ut_params->ibuf;
3160 		unsigned int offset = data_pad_len;
3161 
3162 		while (offset > m->data_len && m->next != NULL) {
3163 			offset -= m->data_len;
3164 			m = m->next;
3165 		}
3166 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3167 			m, offset);
3168 	}
3169 
3170 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3171 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3172 	else
3173 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3174 
3175 	debug_hexdump(stdout, "digest:",
3176 		sym_op->auth.digest.data,
3177 		auth_tag_len);
3178 
3179 	/* Copy cipher and auth IVs at the end of the crypto operation */
3180 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3181 						IV_OFFSET);
3182 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3183 	iv_ptr += cipher_iv_len;
3184 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3185 
3186 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3187 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3188 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3189 		sym_op->cipher.data.length = cipher_len;
3190 		sym_op->cipher.data.offset = cipher_offset;
3191 	} else {
3192 		sym_op->cipher.data.length = cipher_len >> 3;
3193 		sym_op->cipher.data.offset = cipher_offset >> 3;
3194 	}
3195 
3196 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3197 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3198 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3199 		sym_op->auth.data.length = auth_len;
3200 		sym_op->auth.data.offset = auth_offset;
3201 	} else {
3202 		sym_op->auth.data.length = auth_len >> 3;
3203 		sym_op->auth.data.offset = auth_offset >> 3;
3204 	}
3205 
3206 	return 0;
3207 }
3208 
3209 static int
3210 create_wireless_algo_auth_cipher_operation(
3211 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3212 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3213 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3214 		unsigned int data_pad_len,
3215 		unsigned int cipher_len, unsigned int cipher_offset,
3216 		unsigned int auth_len, unsigned int auth_offset,
3217 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3218 {
3219 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3220 	struct crypto_unittest_params *ut_params = &unittest_params;
3221 
3222 	enum rte_crypto_cipher_algorithm cipher_algo =
3223 			ut_params->cipher_xform.cipher.algo;
3224 	enum rte_crypto_auth_algorithm auth_algo =
3225 			ut_params->auth_xform.auth.algo;
3226 
3227 	/* Generate Crypto op data structure */
3228 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3229 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3230 	TEST_ASSERT_NOT_NULL(ut_params->op,
3231 			"Failed to allocate pktmbuf offload");
3232 
3233 	/* Set crypto operation data parameters */
3234 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3235 
3236 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3237 
3238 	/* set crypto operation mbufs */
3239 	sym_op->m_src = ut_params->ibuf;
3240 	if (op_mode == OUT_OF_PLACE)
3241 		sym_op->m_dst = ut_params->obuf;
3242 
3243 	/* digest */
3244 	if (!do_sgl) {
3245 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3246 			(op_mode == IN_PLACE ?
3247 				ut_params->ibuf : ut_params->obuf),
3248 			uint8_t *, data_pad_len);
3249 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3250 			(op_mode == IN_PLACE ?
3251 				ut_params->ibuf : ut_params->obuf),
3252 			data_pad_len);
3253 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3254 	} else {
3255 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3256 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3257 				sym_op->m_src : sym_op->m_dst);
3258 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3259 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3260 			sgl_buf = sgl_buf->next;
3261 		}
3262 
3263 		/* The last segment should be large enough to hold full digest */
3264 		if (sgl_buf->data_len < auth_tag_len) {
3265 			rte_pktmbuf_free(sgl_buf->next);
3266 			sgl_buf->next = NULL;
3267 			TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3268 					auth_tag_len - sgl_buf->data_len),
3269 					"No room to append auth tag");
3270 		}
3271 
3272 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3273 				uint8_t *, remaining_off);
3274 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3275 				remaining_off);
3276 		memset(sym_op->auth.digest.data, 0, remaining_off);
3277 		while (sgl_buf->next != NULL) {
3278 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3279 				0, rte_pktmbuf_data_len(sgl_buf));
3280 			sgl_buf = sgl_buf->next;
3281 		}
3282 	}
3283 
3284 	/* Copy digest for the verification */
3285 	if (verify)
3286 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3287 
3288 	/* Copy cipher and auth IVs at the end of the crypto operation */
3289 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3290 			ut_params->op, uint8_t *, IV_OFFSET);
3291 
3292 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3293 	iv_ptr += cipher_iv_len;
3294 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3295 
3296 	/* Only copy over the offset data needed from src to dst in OOP,
3297 	 * if the auth and cipher offsets are not aligned
3298 	 */
3299 	if (op_mode == OUT_OF_PLACE) {
3300 		if (cipher_offset > auth_offset)
3301 			rte_memcpy(
3302 				rte_pktmbuf_mtod_offset(
3303 					sym_op->m_dst,
3304 					uint8_t *, auth_offset >> 3),
3305 				rte_pktmbuf_mtod_offset(
3306 					sym_op->m_src,
3307 					uint8_t *, auth_offset >> 3),
3308 				((cipher_offset >> 3) - (auth_offset >> 3)));
3309 	}
3310 
3311 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3312 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3313 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3314 		sym_op->cipher.data.length = cipher_len;
3315 		sym_op->cipher.data.offset = cipher_offset;
3316 	} else {
3317 		sym_op->cipher.data.length = cipher_len >> 3;
3318 		sym_op->cipher.data.offset = cipher_offset >> 3;
3319 	}
3320 
3321 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3322 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3323 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3324 		sym_op->auth.data.length = auth_len;
3325 		sym_op->auth.data.offset = auth_offset;
3326 	} else {
3327 		sym_op->auth.data.length = auth_len >> 3;
3328 		sym_op->auth.data.offset = auth_offset >> 3;
3329 	}
3330 
3331 	return 0;
3332 }
3333 
3334 static int
3335 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3336 {
3337 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3338 	struct crypto_unittest_params *ut_params = &unittest_params;
3339 
3340 	int retval;
3341 	unsigned plaintext_pad_len;
3342 	unsigned plaintext_len;
3343 	uint8_t *plaintext;
3344 	struct rte_cryptodev_info dev_info;
3345 
3346 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3347 	uint64_t feat_flags = dev_info.feature_flags;
3348 
3349 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3350 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3351 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3352 		return TEST_SKIPPED;
3353 	}
3354 
3355 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3356 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3357 		printf("Device doesn't support RAW data-path APIs.\n");
3358 		return TEST_SKIPPED;
3359 	}
3360 
3361 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3362 		return TEST_SKIPPED;
3363 
3364 	/* Verify the capabilities */
3365 	struct rte_cryptodev_sym_capability_idx cap_idx;
3366 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3367 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3368 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3369 			&cap_idx) == NULL)
3370 		return TEST_SKIPPED;
3371 
3372 	/* Create SNOW 3G session */
3373 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3374 			tdata->key.data, tdata->key.len,
3375 			tdata->auth_iv.len, tdata->digest.len,
3376 			RTE_CRYPTO_AUTH_OP_GENERATE,
3377 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3378 	if (retval < 0)
3379 		return retval;
3380 
3381 	/* alloc mbuf and set payload */
3382 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3383 
3384 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3385 	rte_pktmbuf_tailroom(ut_params->ibuf));
3386 
3387 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3388 	/* Append data which is padded to a multiple of */
3389 	/* the algorithms block size */
3390 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3391 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3392 				plaintext_pad_len);
3393 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3394 
3395 	/* Create SNOW 3G operation */
3396 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3397 			tdata->auth_iv.data, tdata->auth_iv.len,
3398 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3399 			tdata->validAuthLenInBits.len,
3400 			0);
3401 	if (retval < 0)
3402 		return retval;
3403 
3404 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3405 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3406 					       0);
3407 		if (retval != TEST_SUCCESS)
3408 			return retval;
3409 	} else
3410 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3411 				ut_params->op);
3412 	ut_params->obuf = ut_params->op->sym->m_src;
3413 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3414 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3415 						    uint8_t *,
3416 						    plaintext_pad_len);
3417 
3418 	/* Validate obuf */
3419 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3420 	ut_params->digest,
3421 	tdata->digest.data,
3422 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3423 	"SNOW 3G Generated auth tag not as expected");
3424 
3425 	return 0;
3426 }
3427 
3428 static int
3429 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3430 {
3431 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3432 	struct crypto_unittest_params *ut_params = &unittest_params;
3433 
3434 	int retval;
3435 	unsigned plaintext_pad_len;
3436 	unsigned plaintext_len;
3437 	uint8_t *plaintext;
3438 	struct rte_cryptodev_info dev_info;
3439 
3440 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3441 	uint64_t feat_flags = dev_info.feature_flags;
3442 
3443 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3444 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3445 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3446 		return TEST_SKIPPED;
3447 	}
3448 
3449 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3450 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3451 		printf("Device doesn't support RAW data-path APIs.\n");
3452 		return TEST_SKIPPED;
3453 	}
3454 
3455 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3456 		return TEST_SKIPPED;
3457 
3458 	/* Verify the capabilities */
3459 	struct rte_cryptodev_sym_capability_idx cap_idx;
3460 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3461 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3462 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3463 			&cap_idx) == NULL)
3464 		return TEST_SKIPPED;
3465 
3466 	/* Create SNOW 3G session */
3467 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3468 				tdata->key.data, tdata->key.len,
3469 				tdata->auth_iv.len, tdata->digest.len,
3470 				RTE_CRYPTO_AUTH_OP_VERIFY,
3471 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3472 	if (retval < 0)
3473 		return retval;
3474 	/* alloc mbuf and set payload */
3475 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3476 
3477 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3478 	rte_pktmbuf_tailroom(ut_params->ibuf));
3479 
3480 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3481 	/* Append data which is padded to a multiple of */
3482 	/* the algorithms block size */
3483 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3484 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3485 				plaintext_pad_len);
3486 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3487 
3488 	/* Create SNOW 3G operation */
3489 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3490 			tdata->digest.len,
3491 			tdata->auth_iv.data, tdata->auth_iv.len,
3492 			plaintext_pad_len,
3493 			RTE_CRYPTO_AUTH_OP_VERIFY,
3494 			tdata->validAuthLenInBits.len,
3495 			0);
3496 	if (retval < 0)
3497 		return retval;
3498 
3499 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3500 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3501 					       0);
3502 		if (retval != TEST_SUCCESS)
3503 			return retval;
3504 	} else
3505 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3506 				ut_params->op);
3507 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3508 	ut_params->obuf = ut_params->op->sym->m_src;
3509 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3510 						    uint8_t *,
3511 						    plaintext_pad_len);
3512 
3513 	/* Validate obuf */
3514 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3515 		return 0;
3516 	else
3517 		return -1;
3518 
3519 	return 0;
3520 }
3521 
3522 static int
3523 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3524 {
3525 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3526 	struct crypto_unittest_params *ut_params = &unittest_params;
3527 
3528 	int retval;
3529 	unsigned plaintext_pad_len;
3530 	unsigned plaintext_len;
3531 	uint8_t *plaintext;
3532 	struct rte_cryptodev_info dev_info;
3533 
3534 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3535 	uint64_t feat_flags = dev_info.feature_flags;
3536 
3537 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3538 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3539 		printf("Device doesn't support RAW data-path APIs.\n");
3540 		return TEST_SKIPPED;
3541 	}
3542 
3543 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3544 		return TEST_SKIPPED;
3545 
3546 	/* Verify the capabilities */
3547 	struct rte_cryptodev_sym_capability_idx cap_idx;
3548 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3549 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3550 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3551 			&cap_idx) == NULL)
3552 		return TEST_SKIPPED;
3553 
3554 	/* Create KASUMI session */
3555 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3556 			tdata->key.data, tdata->key.len,
3557 			0, tdata->digest.len,
3558 			RTE_CRYPTO_AUTH_OP_GENERATE,
3559 			RTE_CRYPTO_AUTH_KASUMI_F9);
3560 	if (retval < 0)
3561 		return retval;
3562 
3563 	/* alloc mbuf and set payload */
3564 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3565 
3566 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3567 	rte_pktmbuf_tailroom(ut_params->ibuf));
3568 
3569 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3570 	/* Append data which is padded to a multiple of */
3571 	/* the algorithms block size */
3572 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3573 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3574 				plaintext_pad_len);
3575 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3576 
3577 	/* Create KASUMI operation */
3578 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3579 			NULL, 0,
3580 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3581 			tdata->plaintext.len,
3582 			0);
3583 	if (retval < 0)
3584 		return retval;
3585 
3586 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3587 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3588 			ut_params->op);
3589 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3590 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3591 					       0);
3592 		if (retval != TEST_SUCCESS)
3593 			return retval;
3594 	} else
3595 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3596 			ut_params->op);
3597 
3598 	ut_params->obuf = ut_params->op->sym->m_src;
3599 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3600 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3601 						    uint8_t *,
3602 						    plaintext_pad_len);
3603 
3604 	/* Validate obuf */
3605 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3606 	ut_params->digest,
3607 	tdata->digest.data,
3608 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3609 	"KASUMI Generated auth tag not as expected");
3610 
3611 	return 0;
3612 }
3613 
3614 static int
3615 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3616 {
3617 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3618 	struct crypto_unittest_params *ut_params = &unittest_params;
3619 
3620 	int retval;
3621 	unsigned plaintext_pad_len;
3622 	unsigned plaintext_len;
3623 	uint8_t *plaintext;
3624 	struct rte_cryptodev_info dev_info;
3625 
3626 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3627 	uint64_t feat_flags = dev_info.feature_flags;
3628 
3629 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3630 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3631 		printf("Device doesn't support RAW data-path APIs.\n");
3632 		return TEST_SKIPPED;
3633 	}
3634 
3635 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3636 		return TEST_SKIPPED;
3637 
3638 	/* Verify the capabilities */
3639 	struct rte_cryptodev_sym_capability_idx cap_idx;
3640 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3641 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3642 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3643 			&cap_idx) == NULL)
3644 		return TEST_SKIPPED;
3645 
3646 	/* Create KASUMI session */
3647 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3648 				tdata->key.data, tdata->key.len,
3649 				0, tdata->digest.len,
3650 				RTE_CRYPTO_AUTH_OP_VERIFY,
3651 				RTE_CRYPTO_AUTH_KASUMI_F9);
3652 	if (retval < 0)
3653 		return retval;
3654 	/* alloc mbuf and set payload */
3655 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3656 
3657 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3658 	rte_pktmbuf_tailroom(ut_params->ibuf));
3659 
3660 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3661 	/* Append data which is padded to a multiple */
3662 	/* of the algorithms block size */
3663 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3664 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3665 				plaintext_pad_len);
3666 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3667 
3668 	/* Create KASUMI operation */
3669 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3670 			tdata->digest.len,
3671 			NULL, 0,
3672 			plaintext_pad_len,
3673 			RTE_CRYPTO_AUTH_OP_VERIFY,
3674 			tdata->plaintext.len,
3675 			0);
3676 	if (retval < 0)
3677 		return retval;
3678 
3679 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3680 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3681 					       0);
3682 		if (retval != TEST_SUCCESS)
3683 			return retval;
3684 	} else
3685 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3686 				ut_params->op);
3687 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3688 	ut_params->obuf = ut_params->op->sym->m_src;
3689 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3690 						    uint8_t *,
3691 						    plaintext_pad_len);
3692 
3693 	/* Validate obuf */
3694 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3695 		return 0;
3696 	else
3697 		return -1;
3698 
3699 	return 0;
3700 }
3701 
3702 static int
3703 test_snow3g_hash_generate_test_case_1(void)
3704 {
3705 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3706 }
3707 
3708 static int
3709 test_snow3g_hash_generate_test_case_2(void)
3710 {
3711 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3712 }
3713 
3714 static int
3715 test_snow3g_hash_generate_test_case_3(void)
3716 {
3717 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3718 }
3719 
3720 static int
3721 test_snow3g_hash_generate_test_case_4(void)
3722 {
3723 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3724 }
3725 
3726 static int
3727 test_snow3g_hash_generate_test_case_5(void)
3728 {
3729 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3730 }
3731 
3732 static int
3733 test_snow3g_hash_generate_test_case_6(void)
3734 {
3735 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3736 }
3737 
3738 static int
3739 test_snow3g_hash_verify_test_case_1(void)
3740 {
3741 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3742 
3743 }
3744 
3745 static int
3746 test_snow3g_hash_verify_test_case_2(void)
3747 {
3748 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3749 }
3750 
3751 static int
3752 test_snow3g_hash_verify_test_case_3(void)
3753 {
3754 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3755 }
3756 
3757 static int
3758 test_snow3g_hash_verify_test_case_4(void)
3759 {
3760 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3761 }
3762 
3763 static int
3764 test_snow3g_hash_verify_test_case_5(void)
3765 {
3766 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3767 }
3768 
3769 static int
3770 test_snow3g_hash_verify_test_case_6(void)
3771 {
3772 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3773 }
3774 
3775 static int
3776 test_kasumi_hash_generate_test_case_1(void)
3777 {
3778 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3779 }
3780 
3781 static int
3782 test_kasumi_hash_generate_test_case_2(void)
3783 {
3784 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3785 }
3786 
3787 static int
3788 test_kasumi_hash_generate_test_case_3(void)
3789 {
3790 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3791 }
3792 
3793 static int
3794 test_kasumi_hash_generate_test_case_4(void)
3795 {
3796 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3797 }
3798 
3799 static int
3800 test_kasumi_hash_generate_test_case_5(void)
3801 {
3802 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3803 }
3804 
3805 static int
3806 test_kasumi_hash_generate_test_case_6(void)
3807 {
3808 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3809 }
3810 
3811 static int
3812 test_kasumi_hash_verify_test_case_1(void)
3813 {
3814 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3815 }
3816 
3817 static int
3818 test_kasumi_hash_verify_test_case_2(void)
3819 {
3820 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3821 }
3822 
3823 static int
3824 test_kasumi_hash_verify_test_case_3(void)
3825 {
3826 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3827 }
3828 
3829 static int
3830 test_kasumi_hash_verify_test_case_4(void)
3831 {
3832 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3833 }
3834 
3835 static int
3836 test_kasumi_hash_verify_test_case_5(void)
3837 {
3838 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3839 }
3840 
3841 static int
3842 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3843 {
3844 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3845 	struct crypto_unittest_params *ut_params = &unittest_params;
3846 
3847 	int retval;
3848 	uint8_t *plaintext, *ciphertext;
3849 	unsigned plaintext_pad_len;
3850 	unsigned plaintext_len;
3851 	struct rte_cryptodev_info dev_info;
3852 
3853 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3854 	uint64_t feat_flags = dev_info.feature_flags;
3855 
3856 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3857 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3858 		printf("Device doesn't support RAW data-path APIs.\n");
3859 		return TEST_SKIPPED;
3860 	}
3861 
3862 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3863 		return TEST_SKIPPED;
3864 
3865 	/* Verify the capabilities */
3866 	struct rte_cryptodev_sym_capability_idx cap_idx;
3867 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3868 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3869 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3870 			&cap_idx) == NULL)
3871 		return TEST_SKIPPED;
3872 
3873 	/* Create KASUMI session */
3874 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3875 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3876 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3877 					tdata->key.data, tdata->key.len,
3878 					tdata->cipher_iv.len);
3879 	if (retval < 0)
3880 		return retval;
3881 
3882 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3883 
3884 	/* Clear mbuf payload */
3885 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3886 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3887 
3888 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3889 	/* Append data which is padded to a multiple */
3890 	/* of the algorithms block size */
3891 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3892 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3893 				plaintext_pad_len);
3894 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3895 
3896 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3897 
3898 	/* Create KASUMI operation */
3899 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3900 				tdata->cipher_iv.len,
3901 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3902 				tdata->validCipherOffsetInBits.len);
3903 	if (retval < 0)
3904 		return retval;
3905 
3906 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3907 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3908 					       tdata->cipher_iv.len);
3909 		if (retval != TEST_SUCCESS)
3910 			return retval;
3911 	} else
3912 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3913 				ut_params->op);
3914 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3915 
3916 	ut_params->obuf = ut_params->op->sym->m_dst;
3917 	if (ut_params->obuf)
3918 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3919 	else
3920 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3921 
3922 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3923 
3924 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3925 				(tdata->validCipherOffsetInBits.len >> 3);
3926 	/* Validate obuf */
3927 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3928 		ciphertext,
3929 		reference_ciphertext,
3930 		tdata->validCipherLenInBits.len,
3931 		"KASUMI Ciphertext data not as expected");
3932 	return 0;
3933 }
3934 
3935 static int
3936 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3937 {
3938 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3939 	struct crypto_unittest_params *ut_params = &unittest_params;
3940 
3941 	int retval;
3942 
3943 	unsigned int plaintext_pad_len;
3944 	unsigned int plaintext_len;
3945 
3946 	uint8_t buffer[10000];
3947 	const uint8_t *ciphertext;
3948 
3949 	struct rte_cryptodev_info dev_info;
3950 
3951 	/* Verify the capabilities */
3952 	struct rte_cryptodev_sym_capability_idx cap_idx;
3953 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3954 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3955 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3956 			&cap_idx) == NULL)
3957 		return TEST_SKIPPED;
3958 
3959 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3960 
3961 	uint64_t feat_flags = dev_info.feature_flags;
3962 
3963 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3964 		printf("Device doesn't support in-place scatter-gather. "
3965 				"Test Skipped.\n");
3966 		return TEST_SKIPPED;
3967 	}
3968 
3969 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3970 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3971 		printf("Device doesn't support RAW data-path APIs.\n");
3972 		return TEST_SKIPPED;
3973 	}
3974 
3975 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3976 		return TEST_SKIPPED;
3977 
3978 	/* Create KASUMI session */
3979 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3980 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3981 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3982 					tdata->key.data, tdata->key.len,
3983 					tdata->cipher_iv.len);
3984 	if (retval < 0)
3985 		return retval;
3986 
3987 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3988 
3989 
3990 	/* Append data which is padded to a multiple */
3991 	/* of the algorithms block size */
3992 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3993 
3994 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3995 			plaintext_pad_len, 10, 0);
3996 
3997 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3998 
3999 	/* Create KASUMI operation */
4000 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4001 				tdata->cipher_iv.len,
4002 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4003 				tdata->validCipherOffsetInBits.len);
4004 	if (retval < 0)
4005 		return retval;
4006 
4007 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4008 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4009 					       tdata->cipher_iv.len);
4010 		if (retval != TEST_SUCCESS)
4011 			return retval;
4012 	} else
4013 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4014 						ut_params->op);
4015 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4016 
4017 	ut_params->obuf = ut_params->op->sym->m_dst;
4018 
4019 	if (ut_params->obuf)
4020 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4021 				plaintext_len, buffer);
4022 	else
4023 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4024 				tdata->validCipherOffsetInBits.len >> 3,
4025 				plaintext_len, buffer);
4026 
4027 	/* Validate obuf */
4028 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4029 
4030 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4031 				(tdata->validCipherOffsetInBits.len >> 3);
4032 	/* Validate obuf */
4033 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4034 		ciphertext,
4035 		reference_ciphertext,
4036 		tdata->validCipherLenInBits.len,
4037 		"KASUMI Ciphertext data not as expected");
4038 	return 0;
4039 }
4040 
4041 static int
4042 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4043 {
4044 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4045 	struct crypto_unittest_params *ut_params = &unittest_params;
4046 
4047 	int retval;
4048 	uint8_t *plaintext, *ciphertext;
4049 	unsigned plaintext_pad_len;
4050 	unsigned plaintext_len;
4051 
4052 	/* Verify the capabilities */
4053 	struct rte_cryptodev_sym_capability_idx cap_idx;
4054 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4055 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4056 	/* Data-path service does not support OOP */
4057 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4058 			&cap_idx) == NULL)
4059 		return TEST_SKIPPED;
4060 
4061 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4062 		return TEST_SKIPPED;
4063 
4064 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4065 		return TEST_SKIPPED;
4066 
4067 	/* Create KASUMI session */
4068 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4069 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4070 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4071 					tdata->key.data, tdata->key.len,
4072 					tdata->cipher_iv.len);
4073 	if (retval < 0)
4074 		return retval;
4075 
4076 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4077 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4078 
4079 	/* Clear mbuf payload */
4080 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4081 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4082 
4083 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4084 	/* Append data which is padded to a multiple */
4085 	/* of the algorithms block size */
4086 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4087 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4088 				plaintext_pad_len);
4089 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4090 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4091 
4092 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4093 
4094 	/* Create KASUMI operation */
4095 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4096 				tdata->cipher_iv.len,
4097 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4098 				tdata->validCipherOffsetInBits.len);
4099 	if (retval < 0)
4100 		return retval;
4101 
4102 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4103 						ut_params->op);
4104 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4105 
4106 	ut_params->obuf = ut_params->op->sym->m_dst;
4107 	if (ut_params->obuf)
4108 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4109 	else
4110 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4111 
4112 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4113 
4114 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4115 				(tdata->validCipherOffsetInBits.len >> 3);
4116 	/* Validate obuf */
4117 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4118 		ciphertext,
4119 		reference_ciphertext,
4120 		tdata->validCipherLenInBits.len,
4121 		"KASUMI Ciphertext data not as expected");
4122 	return 0;
4123 }
4124 
4125 static int
4126 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4127 {
4128 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4129 	struct crypto_unittest_params *ut_params = &unittest_params;
4130 
4131 	int retval;
4132 	unsigned int plaintext_pad_len;
4133 	unsigned int plaintext_len;
4134 
4135 	const uint8_t *ciphertext;
4136 	uint8_t buffer[2048];
4137 
4138 	struct rte_cryptodev_info dev_info;
4139 
4140 	/* Verify the capabilities */
4141 	struct rte_cryptodev_sym_capability_idx cap_idx;
4142 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4143 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4144 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4145 			&cap_idx) == NULL)
4146 		return TEST_SKIPPED;
4147 
4148 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4149 		return TEST_SKIPPED;
4150 
4151 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4152 		return TEST_SKIPPED;
4153 
4154 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4155 
4156 	uint64_t feat_flags = dev_info.feature_flags;
4157 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4158 		printf("Device doesn't support out-of-place scatter-gather "
4159 				"in both input and output mbufs. "
4160 				"Test Skipped.\n");
4161 		return TEST_SKIPPED;
4162 	}
4163 
4164 	/* Create KASUMI session */
4165 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4166 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4167 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4168 					tdata->key.data, tdata->key.len,
4169 					tdata->cipher_iv.len);
4170 	if (retval < 0)
4171 		return retval;
4172 
4173 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4174 	/* Append data which is padded to a multiple */
4175 	/* of the algorithms block size */
4176 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4177 
4178 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4179 			plaintext_pad_len, 10, 0);
4180 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4181 			plaintext_pad_len, 3, 0);
4182 
4183 	/* Append data which is padded to a multiple */
4184 	/* of the algorithms block size */
4185 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4186 
4187 	/* Create KASUMI operation */
4188 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4189 				tdata->cipher_iv.len,
4190 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4191 				tdata->validCipherOffsetInBits.len);
4192 	if (retval < 0)
4193 		return retval;
4194 
4195 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4196 						ut_params->op);
4197 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4198 
4199 	ut_params->obuf = ut_params->op->sym->m_dst;
4200 	if (ut_params->obuf)
4201 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4202 				plaintext_pad_len, buffer);
4203 	else
4204 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4205 				tdata->validCipherOffsetInBits.len >> 3,
4206 				plaintext_pad_len, buffer);
4207 
4208 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4209 				(tdata->validCipherOffsetInBits.len >> 3);
4210 	/* Validate obuf */
4211 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4212 		ciphertext,
4213 		reference_ciphertext,
4214 		tdata->validCipherLenInBits.len,
4215 		"KASUMI Ciphertext data not as expected");
4216 	return 0;
4217 }
4218 
4219 
4220 static int
4221 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4222 {
4223 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4224 	struct crypto_unittest_params *ut_params = &unittest_params;
4225 
4226 	int retval;
4227 	uint8_t *ciphertext, *plaintext;
4228 	unsigned ciphertext_pad_len;
4229 	unsigned ciphertext_len;
4230 
4231 	/* Verify the capabilities */
4232 	struct rte_cryptodev_sym_capability_idx cap_idx;
4233 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4234 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4235 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4236 			&cap_idx) == NULL)
4237 		return TEST_SKIPPED;
4238 
4239 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4240 		return TEST_SKIPPED;
4241 
4242 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4243 		return TEST_SKIPPED;
4244 
4245 	/* Create KASUMI session */
4246 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4247 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4248 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4249 					tdata->key.data, tdata->key.len,
4250 					tdata->cipher_iv.len);
4251 	if (retval < 0)
4252 		return retval;
4253 
4254 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4255 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4256 
4257 	/* Clear mbuf payload */
4258 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4259 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4260 
4261 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4262 	/* Append data which is padded to a multiple */
4263 	/* of the algorithms block size */
4264 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4265 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4266 				ciphertext_pad_len);
4267 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4268 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4269 
4270 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4271 
4272 	/* Create KASUMI operation */
4273 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4274 				tdata->cipher_iv.len,
4275 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4276 				tdata->validCipherOffsetInBits.len);
4277 	if (retval < 0)
4278 		return retval;
4279 
4280 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4281 						ut_params->op);
4282 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4283 
4284 	ut_params->obuf = ut_params->op->sym->m_dst;
4285 	if (ut_params->obuf)
4286 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4287 	else
4288 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4289 
4290 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4291 
4292 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4293 				(tdata->validCipherOffsetInBits.len >> 3);
4294 	/* Validate obuf */
4295 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4296 		plaintext,
4297 		reference_plaintext,
4298 		tdata->validCipherLenInBits.len,
4299 		"KASUMI Plaintext data not as expected");
4300 	return 0;
4301 }
4302 
4303 static int
4304 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4305 {
4306 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4307 	struct crypto_unittest_params *ut_params = &unittest_params;
4308 
4309 	int retval;
4310 	uint8_t *ciphertext, *plaintext;
4311 	unsigned ciphertext_pad_len;
4312 	unsigned ciphertext_len;
4313 	struct rte_cryptodev_info dev_info;
4314 
4315 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4316 	uint64_t feat_flags = dev_info.feature_flags;
4317 
4318 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4319 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4320 		printf("Device doesn't support RAW data-path APIs.\n");
4321 		return TEST_SKIPPED;
4322 	}
4323 
4324 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4325 		return TEST_SKIPPED;
4326 
4327 	/* Verify the capabilities */
4328 	struct rte_cryptodev_sym_capability_idx cap_idx;
4329 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4330 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4331 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4332 			&cap_idx) == NULL)
4333 		return TEST_SKIPPED;
4334 
4335 	/* Create KASUMI session */
4336 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4337 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4338 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4339 					tdata->key.data, tdata->key.len,
4340 					tdata->cipher_iv.len);
4341 	if (retval < 0)
4342 		return retval;
4343 
4344 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4345 
4346 	/* Clear mbuf payload */
4347 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4348 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4349 
4350 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4351 	/* Append data which is padded to a multiple */
4352 	/* of the algorithms block size */
4353 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4354 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4355 				ciphertext_pad_len);
4356 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4357 
4358 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4359 
4360 	/* Create KASUMI operation */
4361 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4362 			tdata->cipher_iv.len,
4363 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4364 			tdata->validCipherOffsetInBits.len);
4365 	if (retval < 0)
4366 		return retval;
4367 
4368 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4369 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4370 					       0);
4371 		if (retval != TEST_SUCCESS)
4372 			return retval;
4373 	} else
4374 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4375 						ut_params->op);
4376 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4377 
4378 	ut_params->obuf = ut_params->op->sym->m_dst;
4379 	if (ut_params->obuf)
4380 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4381 	else
4382 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4383 
4384 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4385 
4386 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4387 				(tdata->validCipherOffsetInBits.len >> 3);
4388 	/* Validate obuf */
4389 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4390 		plaintext,
4391 		reference_plaintext,
4392 		tdata->validCipherLenInBits.len,
4393 		"KASUMI Plaintext data not as expected");
4394 	return 0;
4395 }
4396 
4397 static int
4398 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4399 {
4400 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4401 	struct crypto_unittest_params *ut_params = &unittest_params;
4402 
4403 	int retval;
4404 	uint8_t *plaintext, *ciphertext;
4405 	unsigned plaintext_pad_len;
4406 	unsigned plaintext_len;
4407 	struct rte_cryptodev_info dev_info;
4408 
4409 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4410 	uint64_t feat_flags = dev_info.feature_flags;
4411 
4412 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4413 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4414 		printf("Device doesn't support RAW data-path APIs.\n");
4415 		return TEST_SKIPPED;
4416 	}
4417 
4418 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4419 		return TEST_SKIPPED;
4420 
4421 	/* Verify the capabilities */
4422 	struct rte_cryptodev_sym_capability_idx cap_idx;
4423 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4424 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4425 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4426 			&cap_idx) == NULL)
4427 		return TEST_SKIPPED;
4428 
4429 	/* Create SNOW 3G session */
4430 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4431 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4432 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4433 					tdata->key.data, tdata->key.len,
4434 					tdata->cipher_iv.len);
4435 	if (retval < 0)
4436 		return retval;
4437 
4438 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4439 
4440 	/* Clear mbuf payload */
4441 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4442 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4443 
4444 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4445 	/* Append data which is padded to a multiple of */
4446 	/* the algorithms block size */
4447 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4448 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4449 				plaintext_pad_len);
4450 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4451 
4452 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4453 
4454 	/* Create SNOW 3G operation */
4455 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4456 					tdata->cipher_iv.len,
4457 					tdata->validCipherLenInBits.len,
4458 					0);
4459 	if (retval < 0)
4460 		return retval;
4461 
4462 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4463 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4464 					       tdata->cipher_iv.len);
4465 		if (retval != TEST_SUCCESS)
4466 			return retval;
4467 	} else
4468 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4469 						ut_params->op);
4470 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4471 
4472 	ut_params->obuf = ut_params->op->sym->m_dst;
4473 	if (ut_params->obuf)
4474 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4475 	else
4476 		ciphertext = plaintext;
4477 
4478 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4479 
4480 	/* Validate obuf */
4481 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4482 		ciphertext,
4483 		tdata->ciphertext.data,
4484 		tdata->validDataLenInBits.len,
4485 		"SNOW 3G Ciphertext data not as expected");
4486 	return 0;
4487 }
4488 
4489 
4490 static int
4491 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4492 {
4493 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4494 	struct crypto_unittest_params *ut_params = &unittest_params;
4495 	uint8_t *plaintext, *ciphertext;
4496 
4497 	int retval;
4498 	unsigned plaintext_pad_len;
4499 	unsigned plaintext_len;
4500 	struct rte_cryptodev_info dev_info;
4501 
4502 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4503 	uint64_t feat_flags = dev_info.feature_flags;
4504 
4505 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4506 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4507 		printf("Device does not support RAW data-path APIs.\n");
4508 		return -ENOTSUP;
4509 	}
4510 
4511 	/* Verify the capabilities */
4512 	struct rte_cryptodev_sym_capability_idx cap_idx;
4513 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4514 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4515 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4516 			&cap_idx) == NULL)
4517 		return TEST_SKIPPED;
4518 
4519 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4520 		return TEST_SKIPPED;
4521 
4522 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4523 		return TEST_SKIPPED;
4524 
4525 	/* Create SNOW 3G session */
4526 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4527 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4528 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4529 					tdata->key.data, tdata->key.len,
4530 					tdata->cipher_iv.len);
4531 	if (retval < 0)
4532 		return retval;
4533 
4534 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4535 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4536 
4537 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4538 			"Failed to allocate input buffer in mempool");
4539 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4540 			"Failed to allocate output buffer in mempool");
4541 
4542 	/* Clear mbuf payload */
4543 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4544 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4545 
4546 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4547 	/* Append data which is padded to a multiple of */
4548 	/* the algorithms block size */
4549 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4550 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4551 				plaintext_pad_len);
4552 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4553 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4554 
4555 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4556 
4557 	/* Create SNOW 3G operation */
4558 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4559 					tdata->cipher_iv.len,
4560 					tdata->validCipherLenInBits.len,
4561 					0);
4562 	if (retval < 0)
4563 		return retval;
4564 
4565 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4566 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4567 					       tdata->cipher_iv.len);
4568 		if (retval != TEST_SUCCESS)
4569 			return retval;
4570 	} else
4571 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4572 						ut_params->op);
4573 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4574 
4575 	ut_params->obuf = ut_params->op->sym->m_dst;
4576 	if (ut_params->obuf)
4577 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4578 	else
4579 		ciphertext = plaintext;
4580 
4581 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4582 
4583 	/* Validate obuf */
4584 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4585 		ciphertext,
4586 		tdata->ciphertext.data,
4587 		tdata->validDataLenInBits.len,
4588 		"SNOW 3G Ciphertext data not as expected");
4589 	return 0;
4590 }
4591 
4592 static int
4593 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4594 		uint8_t sgl_in, uint8_t sgl_out)
4595 {
4596 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4597 	struct crypto_unittest_params *ut_params = &unittest_params;
4598 
4599 	int retval;
4600 	unsigned int plaintext_pad_len;
4601 	unsigned int plaintext_len;
4602 	uint8_t buffer[10000];
4603 	const uint8_t *ciphertext;
4604 
4605 	struct rte_cryptodev_info dev_info;
4606 
4607 	/* Verify the capabilities */
4608 	struct rte_cryptodev_sym_capability_idx cap_idx;
4609 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4610 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4611 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4612 			&cap_idx) == NULL)
4613 		return TEST_SKIPPED;
4614 
4615 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4616 		return TEST_SKIPPED;
4617 
4618 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4619 		return TEST_SKIPPED;
4620 
4621 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4622 
4623 	uint64_t feat_flags = dev_info.feature_flags;
4624 
4625 	if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4626 			|| ((!sgl_in && sgl_out) &&
4627 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4628 			|| ((sgl_in && !sgl_out) &&
4629 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4630 		printf("Device doesn't support out-of-place scatter gather type. "
4631 				"Test Skipped.\n");
4632 		return TEST_SKIPPED;
4633 	}
4634 
4635 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4636 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4637 		printf("Device does not support RAW data-path APIs.\n");
4638 		return -ENOTSUP;
4639 	}
4640 
4641 	/* Create SNOW 3G session */
4642 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4643 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4644 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4645 					tdata->key.data, tdata->key.len,
4646 					tdata->cipher_iv.len);
4647 	if (retval < 0)
4648 		return retval;
4649 
4650 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4651 	/* Append data which is padded to a multiple of */
4652 	/* the algorithms block size */
4653 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4654 
4655 	if (sgl_in)
4656 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4657 				plaintext_pad_len, 10, 0);
4658 	else {
4659 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4660 		rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4661 	}
4662 
4663 	if (sgl_out)
4664 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4665 				plaintext_pad_len, 3, 0);
4666 	else {
4667 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4668 		rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4669 	}
4670 
4671 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4672 			"Failed to allocate input buffer in mempool");
4673 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4674 			"Failed to allocate output buffer in mempool");
4675 
4676 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4677 
4678 	/* Create SNOW 3G operation */
4679 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4680 					tdata->cipher_iv.len,
4681 					tdata->validCipherLenInBits.len,
4682 					0);
4683 	if (retval < 0)
4684 		return retval;
4685 
4686 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4687 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4688 					       tdata->cipher_iv.len);
4689 		if (retval != TEST_SUCCESS)
4690 			return retval;
4691 	} else
4692 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4693 						ut_params->op);
4694 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4695 
4696 	ut_params->obuf = ut_params->op->sym->m_dst;
4697 	if (ut_params->obuf)
4698 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4699 				plaintext_len, buffer);
4700 	else
4701 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4702 				plaintext_len, buffer);
4703 
4704 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4705 
4706 	/* Validate obuf */
4707 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4708 		ciphertext,
4709 		tdata->ciphertext.data,
4710 		tdata->validDataLenInBits.len,
4711 		"SNOW 3G Ciphertext data not as expected");
4712 
4713 	return 0;
4714 }
4715 
4716 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4717 static void
4718 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4719 {
4720 	uint8_t curr_byte, prev_byte;
4721 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4722 	uint8_t lower_byte_mask = (1 << offset) - 1;
4723 	unsigned i;
4724 
4725 	prev_byte = buffer[0];
4726 	buffer[0] >>= offset;
4727 
4728 	for (i = 1; i < length_in_bytes; i++) {
4729 		curr_byte = buffer[i];
4730 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4731 				(curr_byte >> offset);
4732 		prev_byte = curr_byte;
4733 	}
4734 }
4735 
4736 static int
4737 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4738 {
4739 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4740 	struct crypto_unittest_params *ut_params = &unittest_params;
4741 	uint8_t *plaintext, *ciphertext;
4742 	int retval;
4743 	uint32_t plaintext_len;
4744 	uint32_t plaintext_pad_len;
4745 	uint8_t extra_offset = 4;
4746 	uint8_t *expected_ciphertext_shifted;
4747 	struct rte_cryptodev_info dev_info;
4748 
4749 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4750 	uint64_t feat_flags = dev_info.feature_flags;
4751 
4752 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4753 			((tdata->validDataLenInBits.len % 8) != 0)) {
4754 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4755 		return TEST_SKIPPED;
4756 	}
4757 
4758 	/* Verify the capabilities */
4759 	struct rte_cryptodev_sym_capability_idx cap_idx;
4760 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4761 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4762 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4763 			&cap_idx) == NULL)
4764 		return TEST_SKIPPED;
4765 
4766 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4767 		return TEST_SKIPPED;
4768 
4769 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4770 		return TEST_SKIPPED;
4771 
4772 	/* Create SNOW 3G session */
4773 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4774 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4775 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4776 					tdata->key.data, tdata->key.len,
4777 					tdata->cipher_iv.len);
4778 	if (retval < 0)
4779 		return retval;
4780 
4781 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4782 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4783 
4784 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4785 			"Failed to allocate input buffer in mempool");
4786 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4787 			"Failed to allocate output buffer in mempool");
4788 
4789 	/* Clear mbuf payload */
4790 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4791 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4792 
4793 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4794 	/*
4795 	 * Append data which is padded to a
4796 	 * multiple of the algorithms block size
4797 	 */
4798 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4799 
4800 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4801 						plaintext_pad_len);
4802 
4803 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4804 
4805 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4806 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4807 
4808 #ifdef RTE_APP_TEST_DEBUG
4809 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4810 #endif
4811 	/* Create SNOW 3G operation */
4812 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4813 					tdata->cipher_iv.len,
4814 					tdata->validCipherLenInBits.len,
4815 					extra_offset);
4816 	if (retval < 0)
4817 		return retval;
4818 
4819 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4820 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4821 					       tdata->cipher_iv.len);
4822 		if (retval != TEST_SUCCESS)
4823 			return retval;
4824 	} else
4825 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4826 						ut_params->op);
4827 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4828 
4829 	ut_params->obuf = ut_params->op->sym->m_dst;
4830 	if (ut_params->obuf)
4831 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4832 	else
4833 		ciphertext = plaintext;
4834 
4835 #ifdef RTE_APP_TEST_DEBUG
4836 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4837 #endif
4838 
4839 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4840 
4841 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4842 			"failed to reserve memory for ciphertext shifted\n");
4843 
4844 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4845 			ceil_byte_length(tdata->ciphertext.len));
4846 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4847 			extra_offset);
4848 	/* Validate obuf */
4849 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4850 		ciphertext,
4851 		expected_ciphertext_shifted,
4852 		tdata->validDataLenInBits.len,
4853 		extra_offset,
4854 		"SNOW 3G Ciphertext data not as expected");
4855 	return 0;
4856 }
4857 
4858 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4859 {
4860 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4861 	struct crypto_unittest_params *ut_params = &unittest_params;
4862 
4863 	int retval;
4864 
4865 	uint8_t *plaintext, *ciphertext;
4866 	unsigned ciphertext_pad_len;
4867 	unsigned ciphertext_len;
4868 	struct rte_cryptodev_info dev_info;
4869 
4870 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4871 	uint64_t feat_flags = dev_info.feature_flags;
4872 
4873 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4874 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4875 		printf("Device doesn't support RAW data-path APIs.\n");
4876 		return TEST_SKIPPED;
4877 	}
4878 
4879 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4880 		return TEST_SKIPPED;
4881 
4882 	/* Verify the capabilities */
4883 	struct rte_cryptodev_sym_capability_idx cap_idx;
4884 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4885 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4886 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4887 			&cap_idx) == NULL)
4888 		return TEST_SKIPPED;
4889 
4890 	/* Create SNOW 3G session */
4891 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4892 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4893 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4894 					tdata->key.data, tdata->key.len,
4895 					tdata->cipher_iv.len);
4896 	if (retval < 0)
4897 		return retval;
4898 
4899 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4900 
4901 	/* Clear mbuf payload */
4902 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4903 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4904 
4905 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4906 	/* Append data which is padded to a multiple of */
4907 	/* the algorithms block size */
4908 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4909 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4910 				ciphertext_pad_len);
4911 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4912 
4913 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4914 
4915 	/* Create SNOW 3G operation */
4916 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4917 					tdata->cipher_iv.len,
4918 					tdata->validCipherLenInBits.len,
4919 					tdata->cipher.offset_bits);
4920 	if (retval < 0)
4921 		return retval;
4922 
4923 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4924 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4925 					       tdata->cipher_iv.len);
4926 		if (retval != TEST_SUCCESS)
4927 			return retval;
4928 	} else
4929 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4930 						ut_params->op);
4931 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4932 	ut_params->obuf = ut_params->op->sym->m_dst;
4933 	if (ut_params->obuf)
4934 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4935 	else
4936 		plaintext = ciphertext;
4937 
4938 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4939 
4940 	/* Validate obuf */
4941 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4942 				tdata->plaintext.data,
4943 				tdata->validDataLenInBits.len,
4944 				"SNOW 3G Plaintext data not as expected");
4945 	return 0;
4946 }
4947 
4948 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4949 {
4950 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4951 	struct crypto_unittest_params *ut_params = &unittest_params;
4952 
4953 	int retval;
4954 
4955 	uint8_t *plaintext, *ciphertext;
4956 	unsigned ciphertext_pad_len;
4957 	unsigned ciphertext_len;
4958 	struct rte_cryptodev_info dev_info;
4959 
4960 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4961 	uint64_t feat_flags = dev_info.feature_flags;
4962 
4963 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4964 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4965 		printf("Device does not support RAW data-path APIs.\n");
4966 		return -ENOTSUP;
4967 	}
4968 	/* Verify the capabilities */
4969 	struct rte_cryptodev_sym_capability_idx cap_idx;
4970 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4971 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4972 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4973 			&cap_idx) == NULL)
4974 		return TEST_SKIPPED;
4975 
4976 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4977 		return TEST_SKIPPED;
4978 
4979 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4980 		return TEST_SKIPPED;
4981 
4982 	/* Create SNOW 3G session */
4983 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4984 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4985 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4986 					tdata->key.data, tdata->key.len,
4987 					tdata->cipher_iv.len);
4988 	if (retval < 0)
4989 		return retval;
4990 
4991 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4992 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4993 
4994 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4995 			"Failed to allocate input buffer");
4996 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4997 			"Failed to allocate output buffer");
4998 
4999 	/* Clear mbuf payload */
5000 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5001 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5002 
5003 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5004 		       rte_pktmbuf_tailroom(ut_params->obuf));
5005 
5006 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5007 	/* Append data which is padded to a multiple of */
5008 	/* the algorithms block size */
5009 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5010 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5011 				ciphertext_pad_len);
5012 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5013 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5014 
5015 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5016 
5017 	/* Create SNOW 3G operation */
5018 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5019 					tdata->cipher_iv.len,
5020 					tdata->validCipherLenInBits.len,
5021 					0);
5022 	if (retval < 0)
5023 		return retval;
5024 
5025 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5026 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5027 					       tdata->cipher_iv.len);
5028 		if (retval != TEST_SUCCESS)
5029 			return retval;
5030 	} else
5031 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5032 						ut_params->op);
5033 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5034 	ut_params->obuf = ut_params->op->sym->m_dst;
5035 	if (ut_params->obuf)
5036 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5037 	else
5038 		plaintext = ciphertext;
5039 
5040 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5041 
5042 	/* Validate obuf */
5043 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5044 				tdata->plaintext.data,
5045 				tdata->validDataLenInBits.len,
5046 				"SNOW 3G Plaintext data not as expected");
5047 	return 0;
5048 }
5049 
5050 static int
5051 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5052 {
5053 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5054 	struct crypto_unittest_params *ut_params = &unittest_params;
5055 
5056 	int retval;
5057 
5058 	uint8_t *plaintext, *ciphertext;
5059 	unsigned int plaintext_pad_len;
5060 	unsigned int plaintext_len;
5061 
5062 	struct rte_cryptodev_info dev_info;
5063 
5064 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5065 	uint64_t feat_flags = dev_info.feature_flags;
5066 
5067 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5068 			((tdata->validAuthLenInBits.len % 8 != 0) ||
5069 			(tdata->validDataLenInBits.len % 8 != 0))) {
5070 		printf("Device doesn't support NON-Byte Aligned Data.\n");
5071 		return TEST_SKIPPED;
5072 	}
5073 
5074 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5075 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5076 		printf("Device doesn't support RAW data-path APIs.\n");
5077 		return TEST_SKIPPED;
5078 	}
5079 
5080 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5081 		return TEST_SKIPPED;
5082 
5083 	/* Check if device supports ZUC EEA3 */
5084 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5085 			tdata->key.len, tdata->cipher_iv.len) < 0)
5086 		return TEST_SKIPPED;
5087 
5088 	/* Check if device supports ZUC EIA3 */
5089 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5090 			tdata->key.len, tdata->auth_iv.len,
5091 			tdata->digest.len) < 0)
5092 		return TEST_SKIPPED;
5093 
5094 	/* Create ZUC session */
5095 	retval = create_zuc_cipher_auth_encrypt_generate_session(
5096 			ts_params->valid_devs[0],
5097 			tdata);
5098 	if (retval != 0)
5099 		return retval;
5100 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5101 
5102 	/* clear mbuf payload */
5103 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5104 			rte_pktmbuf_tailroom(ut_params->ibuf));
5105 
5106 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5107 	/* Append data which is padded to a multiple of */
5108 	/* the algorithms block size */
5109 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5110 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5111 				plaintext_pad_len);
5112 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5113 
5114 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5115 
5116 	/* Create ZUC operation */
5117 	retval = create_zuc_cipher_hash_generate_operation(tdata);
5118 	if (retval < 0)
5119 		return retval;
5120 
5121 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5122 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5123 					       tdata->cipher_iv.len);
5124 		if (retval != TEST_SUCCESS)
5125 			return retval;
5126 	} else
5127 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5128 			ut_params->op);
5129 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5130 	ut_params->obuf = ut_params->op->sym->m_src;
5131 	if (ut_params->obuf)
5132 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5133 	else
5134 		ciphertext = plaintext;
5135 
5136 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5137 	/* Validate obuf */
5138 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5139 			ciphertext,
5140 			tdata->ciphertext.data,
5141 			tdata->validDataLenInBits.len,
5142 			"ZUC Ciphertext data not as expected");
5143 
5144 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5145 						    uint8_t *,
5146 						    plaintext_pad_len);
5147 
5148 	/* Validate obuf */
5149 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5150 			ut_params->digest,
5151 			tdata->digest.data,
5152 			tdata->digest.len,
5153 			"ZUC Generated auth tag not as expected");
5154 	return 0;
5155 }
5156 
5157 static int
5158 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5159 {
5160 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5161 	struct crypto_unittest_params *ut_params = &unittest_params;
5162 
5163 	int retval;
5164 
5165 	uint8_t *plaintext, *ciphertext;
5166 	unsigned plaintext_pad_len;
5167 	unsigned plaintext_len;
5168 	struct rte_cryptodev_info dev_info;
5169 
5170 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5171 	uint64_t feat_flags = dev_info.feature_flags;
5172 
5173 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5174 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5175 		printf("Device doesn't support RAW data-path APIs.\n");
5176 		return TEST_SKIPPED;
5177 	}
5178 
5179 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5180 		return TEST_SKIPPED;
5181 
5182 	/* Verify the capabilities */
5183 	struct rte_cryptodev_sym_capability_idx cap_idx;
5184 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5185 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5186 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5187 			&cap_idx) == NULL)
5188 		return TEST_SKIPPED;
5189 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5190 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5191 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5192 			&cap_idx) == NULL)
5193 		return TEST_SKIPPED;
5194 
5195 	/* Create SNOW 3G session */
5196 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5197 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5198 			RTE_CRYPTO_AUTH_OP_GENERATE,
5199 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5200 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5201 			tdata->key.data, tdata->key.len,
5202 			tdata->key.data, tdata->key.len,
5203 			tdata->auth_iv.len, tdata->digest.len,
5204 			tdata->cipher_iv.len);
5205 	if (retval != 0)
5206 		return retval;
5207 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5208 
5209 	/* clear mbuf payload */
5210 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5211 			rte_pktmbuf_tailroom(ut_params->ibuf));
5212 
5213 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5214 	/* Append data which is padded to a multiple of */
5215 	/* the algorithms block size */
5216 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5217 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5218 				plaintext_pad_len);
5219 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5220 
5221 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5222 
5223 	/* Create SNOW 3G operation */
5224 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5225 			tdata->digest.len, tdata->auth_iv.data,
5226 			tdata->auth_iv.len,
5227 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5228 			tdata->cipher_iv.data, tdata->cipher_iv.len,
5229 			tdata->validCipherLenInBits.len,
5230 			0,
5231 			tdata->validAuthLenInBits.len,
5232 			0
5233 			);
5234 	if (retval < 0)
5235 		return retval;
5236 
5237 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5238 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5239 					       tdata->cipher_iv.len);
5240 		if (retval != TEST_SUCCESS)
5241 			return retval;
5242 	} else
5243 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5244 			ut_params->op);
5245 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5246 	ut_params->obuf = ut_params->op->sym->m_src;
5247 	if (ut_params->obuf)
5248 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5249 	else
5250 		ciphertext = plaintext;
5251 
5252 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5253 	/* Validate obuf */
5254 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5255 			ciphertext,
5256 			tdata->ciphertext.data,
5257 			tdata->validDataLenInBits.len,
5258 			"SNOW 3G Ciphertext data not as expected");
5259 
5260 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5261 						    uint8_t *,
5262 						    plaintext_pad_len);
5263 
5264 	/* Validate obuf */
5265 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5266 			ut_params->digest,
5267 			tdata->digest.data,
5268 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5269 			"SNOW 3G Generated auth tag not as expected");
5270 	return 0;
5271 }
5272 
5273 static int
5274 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5275 	uint8_t op_mode, uint8_t verify)
5276 {
5277 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5278 	struct crypto_unittest_params *ut_params = &unittest_params;
5279 
5280 	int retval;
5281 
5282 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5283 	unsigned int plaintext_pad_len;
5284 	unsigned int plaintext_len;
5285 	unsigned int ciphertext_pad_len;
5286 	unsigned int ciphertext_len;
5287 	unsigned int digest_offset;
5288 
5289 	struct rte_cryptodev_info dev_info;
5290 
5291 	/* Verify the capabilities */
5292 	struct rte_cryptodev_sym_capability_idx cap_idx;
5293 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5294 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5295 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5296 			&cap_idx) == NULL)
5297 		return TEST_SKIPPED;
5298 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5299 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5300 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5301 			&cap_idx) == NULL)
5302 		return TEST_SKIPPED;
5303 
5304 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5305 		return TEST_SKIPPED;
5306 
5307 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5308 
5309 	uint64_t feat_flags = dev_info.feature_flags;
5310 
5311 	if (op_mode == OUT_OF_PLACE) {
5312 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5313 			printf("Device doesn't support digest encrypted.\n");
5314 			return TEST_SKIPPED;
5315 		}
5316 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5317 			return TEST_SKIPPED;
5318 	}
5319 
5320 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5321 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5322 		printf("Device doesn't support RAW data-path APIs.\n");
5323 		return TEST_SKIPPED;
5324 	}
5325 
5326 	/* Create SNOW 3G session */
5327 	retval = create_wireless_algo_auth_cipher_session(
5328 			ts_params->valid_devs[0],
5329 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5330 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5331 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5332 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5333 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5334 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5335 			tdata->key.data, tdata->key.len,
5336 			tdata->key.data, tdata->key.len,
5337 			tdata->auth_iv.len, tdata->digest.len,
5338 			tdata->cipher_iv.len);
5339 	if (retval != 0)
5340 		return retval;
5341 
5342 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5343 	if (op_mode == OUT_OF_PLACE)
5344 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5345 
5346 	/* clear mbuf payload */
5347 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5348 		rte_pktmbuf_tailroom(ut_params->ibuf));
5349 	if (op_mode == OUT_OF_PLACE)
5350 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5351 			rte_pktmbuf_tailroom(ut_params->obuf));
5352 
5353 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5354 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5355 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5356 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5357 
5358 	if (verify) {
5359 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5360 					ciphertext_pad_len);
5361 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5362 		if (op_mode == OUT_OF_PLACE)
5363 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5364 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5365 			ciphertext_len);
5366 	} else {
5367 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5368 					plaintext_pad_len);
5369 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5370 		if (op_mode == OUT_OF_PLACE)
5371 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5372 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5373 	}
5374 
5375 	/* Create SNOW 3G operation */
5376 	retval = create_wireless_algo_auth_cipher_operation(
5377 		tdata->digest.data, tdata->digest.len,
5378 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5379 		tdata->auth_iv.data, tdata->auth_iv.len,
5380 		(tdata->digest.offset_bytes == 0 ?
5381 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5382 			: tdata->digest.offset_bytes),
5383 		tdata->validCipherLenInBits.len,
5384 		tdata->cipher.offset_bits,
5385 		tdata->validAuthLenInBits.len,
5386 		tdata->auth.offset_bits,
5387 		op_mode, 0, verify);
5388 
5389 	if (retval < 0)
5390 		return retval;
5391 
5392 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5393 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5394 					       tdata->cipher_iv.len);
5395 		if (retval != TEST_SUCCESS)
5396 			return retval;
5397 	} else
5398 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5399 			ut_params->op);
5400 
5401 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5402 
5403 	ut_params->obuf = (op_mode == IN_PLACE ?
5404 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5405 
5406 	if (verify) {
5407 		if (ut_params->obuf)
5408 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5409 							uint8_t *);
5410 		else
5411 			plaintext = ciphertext +
5412 				(tdata->cipher.offset_bits >> 3);
5413 
5414 		debug_hexdump(stdout, "plaintext:", plaintext,
5415 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5416 		debug_hexdump(stdout, "plaintext expected:",
5417 			tdata->plaintext.data,
5418 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5419 	} else {
5420 		if (ut_params->obuf)
5421 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5422 							uint8_t *);
5423 		else
5424 			ciphertext = plaintext;
5425 
5426 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5427 			ciphertext_len);
5428 		debug_hexdump(stdout, "ciphertext expected:",
5429 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5430 
5431 		if (tdata->digest.offset_bytes == 0)
5432 			digest_offset = plaintext_pad_len;
5433 		else
5434 			digest_offset = tdata->digest.offset_bytes;
5435 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5436 						    uint8_t *, digest_offset);
5437 
5438 		debug_hexdump(stdout, "digest:", ut_params->digest,
5439 			tdata->digest.len);
5440 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5441 				tdata->digest.len);
5442 	}
5443 
5444 	/* Validate obuf */
5445 	if (verify) {
5446 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5447 			plaintext,
5448 			tdata->plaintext.data,
5449 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5450 			 (tdata->digest.len << 3)),
5451 			tdata->cipher.offset_bits,
5452 			"SNOW 3G Plaintext data not as expected");
5453 	} else {
5454 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5455 			ciphertext,
5456 			tdata->ciphertext.data,
5457 			(tdata->validDataLenInBits.len -
5458 			 tdata->cipher.offset_bits),
5459 			tdata->cipher.offset_bits,
5460 			"SNOW 3G Ciphertext data not as expected");
5461 
5462 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5463 			ut_params->digest,
5464 			tdata->digest.data,
5465 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5466 			"SNOW 3G Generated auth tag not as expected");
5467 	}
5468 	return 0;
5469 }
5470 
5471 static int
5472 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5473 	uint8_t op_mode, uint8_t verify)
5474 {
5475 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5476 	struct crypto_unittest_params *ut_params = &unittest_params;
5477 
5478 	int retval;
5479 
5480 	const uint8_t *plaintext = NULL;
5481 	const uint8_t *ciphertext = NULL;
5482 	const uint8_t *digest = NULL;
5483 	unsigned int plaintext_pad_len;
5484 	unsigned int plaintext_len;
5485 	unsigned int ciphertext_pad_len;
5486 	unsigned int ciphertext_len;
5487 	uint8_t buffer[10000];
5488 	uint8_t digest_buffer[10000];
5489 
5490 	struct rte_cryptodev_info dev_info;
5491 
5492 	/* Verify the capabilities */
5493 	struct rte_cryptodev_sym_capability_idx cap_idx;
5494 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5495 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5496 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5497 			&cap_idx) == NULL)
5498 		return TEST_SKIPPED;
5499 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5500 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5501 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5502 			&cap_idx) == NULL)
5503 		return TEST_SKIPPED;
5504 
5505 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5506 		return TEST_SKIPPED;
5507 
5508 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5509 
5510 	uint64_t feat_flags = dev_info.feature_flags;
5511 
5512 	if (op_mode == IN_PLACE) {
5513 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5514 			printf("Device doesn't support in-place scatter-gather "
5515 					"in both input and output mbufs.\n");
5516 			return TEST_SKIPPED;
5517 		}
5518 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5519 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5520 			printf("Device doesn't support RAW data-path APIs.\n");
5521 			return TEST_SKIPPED;
5522 		}
5523 	} else {
5524 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5525 			return TEST_SKIPPED;
5526 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5527 			printf("Device doesn't support out-of-place scatter-gather "
5528 					"in both input and output mbufs.\n");
5529 			return TEST_SKIPPED;
5530 		}
5531 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5532 			printf("Device doesn't support digest encrypted.\n");
5533 			return TEST_SKIPPED;
5534 		}
5535 	}
5536 
5537 	/* Create SNOW 3G session */
5538 	retval = create_wireless_algo_auth_cipher_session(
5539 			ts_params->valid_devs[0],
5540 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5541 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5542 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5543 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5544 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5545 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5546 			tdata->key.data, tdata->key.len,
5547 			tdata->key.data, tdata->key.len,
5548 			tdata->auth_iv.len, tdata->digest.len,
5549 			tdata->cipher_iv.len);
5550 
5551 	if (retval != 0)
5552 		return retval;
5553 
5554 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5555 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5556 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5557 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5558 
5559 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5560 			plaintext_pad_len, 15, 0);
5561 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5562 			"Failed to allocate input buffer in mempool");
5563 
5564 	if (op_mode == OUT_OF_PLACE) {
5565 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5566 				plaintext_pad_len, 15, 0);
5567 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5568 				"Failed to allocate output buffer in mempool");
5569 	}
5570 
5571 	if (verify) {
5572 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5573 			tdata->ciphertext.data);
5574 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5575 					ciphertext_len, buffer);
5576 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5577 			ciphertext_len);
5578 	} else {
5579 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5580 			tdata->plaintext.data);
5581 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5582 					plaintext_len, buffer);
5583 		debug_hexdump(stdout, "plaintext:", plaintext,
5584 			plaintext_len);
5585 	}
5586 	memset(buffer, 0, sizeof(buffer));
5587 
5588 	/* Create SNOW 3G operation */
5589 	retval = create_wireless_algo_auth_cipher_operation(
5590 		tdata->digest.data, tdata->digest.len,
5591 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5592 		tdata->auth_iv.data, tdata->auth_iv.len,
5593 		(tdata->digest.offset_bytes == 0 ?
5594 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5595 			: tdata->digest.offset_bytes),
5596 		tdata->validCipherLenInBits.len,
5597 		tdata->cipher.offset_bits,
5598 		tdata->validAuthLenInBits.len,
5599 		tdata->auth.offset_bits,
5600 		op_mode, 1, verify);
5601 
5602 	if (retval < 0)
5603 		return retval;
5604 
5605 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5606 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5607 					       tdata->cipher_iv.len);
5608 		if (retval != TEST_SUCCESS)
5609 			return retval;
5610 	} else
5611 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5612 			ut_params->op);
5613 
5614 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5615 
5616 	ut_params->obuf = (op_mode == IN_PLACE ?
5617 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5618 
5619 	if (verify) {
5620 		if (ut_params->obuf)
5621 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5622 					plaintext_len, buffer);
5623 		else
5624 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5625 					plaintext_len, buffer);
5626 
5627 		debug_hexdump(stdout, "plaintext:", plaintext,
5628 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5629 		debug_hexdump(stdout, "plaintext expected:",
5630 			tdata->plaintext.data,
5631 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5632 	} else {
5633 		if (ut_params->obuf)
5634 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5635 					ciphertext_len, buffer);
5636 		else
5637 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5638 					ciphertext_len, buffer);
5639 
5640 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5641 			ciphertext_len);
5642 		debug_hexdump(stdout, "ciphertext expected:",
5643 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5644 
5645 		if (ut_params->obuf)
5646 			digest = rte_pktmbuf_read(ut_params->obuf,
5647 				(tdata->digest.offset_bytes == 0 ?
5648 				plaintext_pad_len : tdata->digest.offset_bytes),
5649 				tdata->digest.len, digest_buffer);
5650 		else
5651 			digest = rte_pktmbuf_read(ut_params->ibuf,
5652 				(tdata->digest.offset_bytes == 0 ?
5653 				plaintext_pad_len : tdata->digest.offset_bytes),
5654 				tdata->digest.len, digest_buffer);
5655 
5656 		debug_hexdump(stdout, "digest:", digest,
5657 			tdata->digest.len);
5658 		debug_hexdump(stdout, "digest expected:",
5659 			tdata->digest.data, tdata->digest.len);
5660 	}
5661 
5662 	/* Validate obuf */
5663 	if (verify) {
5664 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5665 			plaintext,
5666 			tdata->plaintext.data,
5667 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5668 			 (tdata->digest.len << 3)),
5669 			tdata->cipher.offset_bits,
5670 			"SNOW 3G Plaintext data not as expected");
5671 	} else {
5672 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5673 			ciphertext,
5674 			tdata->ciphertext.data,
5675 			(tdata->validDataLenInBits.len -
5676 			 tdata->cipher.offset_bits),
5677 			tdata->cipher.offset_bits,
5678 			"SNOW 3G Ciphertext data not as expected");
5679 
5680 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5681 			digest,
5682 			tdata->digest.data,
5683 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5684 			"SNOW 3G Generated auth tag not as expected");
5685 	}
5686 	return 0;
5687 }
5688 
5689 static int
5690 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5691 	uint8_t op_mode, uint8_t verify)
5692 {
5693 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5694 	struct crypto_unittest_params *ut_params = &unittest_params;
5695 
5696 	int retval;
5697 
5698 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5699 	unsigned int plaintext_pad_len;
5700 	unsigned int plaintext_len;
5701 	unsigned int ciphertext_pad_len;
5702 	unsigned int ciphertext_len;
5703 	unsigned int digest_offset;
5704 
5705 	struct rte_cryptodev_info dev_info;
5706 
5707 	/* Verify the capabilities */
5708 	struct rte_cryptodev_sym_capability_idx cap_idx;
5709 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5710 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5711 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5712 			&cap_idx) == NULL)
5713 		return TEST_SKIPPED;
5714 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5715 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5716 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5717 			&cap_idx) == NULL)
5718 		return TEST_SKIPPED;
5719 
5720 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5721 
5722 	uint64_t feat_flags = dev_info.feature_flags;
5723 
5724 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5725 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5726 		printf("Device doesn't support RAW data-path APIs.\n");
5727 		return TEST_SKIPPED;
5728 	}
5729 
5730 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5731 		return TEST_SKIPPED;
5732 
5733 	if (op_mode == OUT_OF_PLACE) {
5734 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5735 			return TEST_SKIPPED;
5736 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5737 			printf("Device doesn't support digest encrypted.\n");
5738 			return TEST_SKIPPED;
5739 		}
5740 	}
5741 
5742 	/* Create KASUMI session */
5743 	retval = create_wireless_algo_auth_cipher_session(
5744 			ts_params->valid_devs[0],
5745 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5746 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5747 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5748 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5749 			RTE_CRYPTO_AUTH_KASUMI_F9,
5750 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5751 			tdata->key.data, tdata->key.len,
5752 			tdata->key.data, tdata->key.len,
5753 			0, tdata->digest.len,
5754 			tdata->cipher_iv.len);
5755 
5756 	if (retval != 0)
5757 		return retval;
5758 
5759 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5760 	if (op_mode == OUT_OF_PLACE)
5761 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5762 
5763 	/* clear mbuf payload */
5764 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5765 		rte_pktmbuf_tailroom(ut_params->ibuf));
5766 	if (op_mode == OUT_OF_PLACE)
5767 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5768 			rte_pktmbuf_tailroom(ut_params->obuf));
5769 
5770 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5771 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5772 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5773 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5774 
5775 	if (verify) {
5776 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5777 					ciphertext_pad_len);
5778 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5779 		if (op_mode == OUT_OF_PLACE)
5780 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5781 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5782 			ciphertext_len);
5783 	} else {
5784 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5785 					plaintext_pad_len);
5786 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5787 		if (op_mode == OUT_OF_PLACE)
5788 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5789 		debug_hexdump(stdout, "plaintext:", plaintext,
5790 			plaintext_len);
5791 	}
5792 
5793 	/* Create KASUMI operation */
5794 	retval = create_wireless_algo_auth_cipher_operation(
5795 		tdata->digest.data, tdata->digest.len,
5796 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5797 		NULL, 0,
5798 		(tdata->digest.offset_bytes == 0 ?
5799 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5800 			: tdata->digest.offset_bytes),
5801 		tdata->validCipherLenInBits.len,
5802 		tdata->validCipherOffsetInBits.len,
5803 		tdata->validAuthLenInBits.len,
5804 		0,
5805 		op_mode, 0, verify);
5806 
5807 	if (retval < 0)
5808 		return retval;
5809 
5810 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5811 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5812 					       tdata->cipher_iv.len);
5813 		if (retval != TEST_SUCCESS)
5814 			return retval;
5815 	} else
5816 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5817 			ut_params->op);
5818 
5819 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5820 
5821 	ut_params->obuf = (op_mode == IN_PLACE ?
5822 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5823 
5824 
5825 	if (verify) {
5826 		if (ut_params->obuf)
5827 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5828 							uint8_t *);
5829 		else
5830 			plaintext = ciphertext;
5831 
5832 		debug_hexdump(stdout, "plaintext:", plaintext,
5833 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5834 		debug_hexdump(stdout, "plaintext expected:",
5835 			tdata->plaintext.data,
5836 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5837 	} else {
5838 		if (ut_params->obuf)
5839 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5840 							uint8_t *);
5841 		else
5842 			ciphertext = plaintext;
5843 
5844 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5845 			ciphertext_len);
5846 		debug_hexdump(stdout, "ciphertext expected:",
5847 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5848 
5849 		if (tdata->digest.offset_bytes == 0)
5850 			digest_offset = plaintext_pad_len;
5851 		else
5852 			digest_offset = tdata->digest.offset_bytes;
5853 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5854 						    uint8_t *, digest_offset);
5855 
5856 		debug_hexdump(stdout, "digest:", ut_params->digest,
5857 			tdata->digest.len);
5858 		debug_hexdump(stdout, "digest expected:",
5859 			tdata->digest.data, tdata->digest.len);
5860 	}
5861 
5862 	/* Validate obuf */
5863 	if (verify) {
5864 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5865 			plaintext,
5866 			tdata->plaintext.data,
5867 			tdata->plaintext.len >> 3,
5868 			"KASUMI Plaintext data not as expected");
5869 	} else {
5870 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5871 			ciphertext,
5872 			tdata->ciphertext.data,
5873 			tdata->ciphertext.len >> 3,
5874 			"KASUMI Ciphertext data not as expected");
5875 
5876 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5877 			ut_params->digest,
5878 			tdata->digest.data,
5879 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5880 			"KASUMI Generated auth tag not as expected");
5881 	}
5882 	return 0;
5883 }
5884 
5885 static int
5886 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5887 	uint8_t op_mode, uint8_t verify)
5888 {
5889 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5890 	struct crypto_unittest_params *ut_params = &unittest_params;
5891 
5892 	int retval;
5893 
5894 	const uint8_t *plaintext = NULL;
5895 	const uint8_t *ciphertext = NULL;
5896 	const uint8_t *digest = NULL;
5897 	unsigned int plaintext_pad_len;
5898 	unsigned int plaintext_len;
5899 	unsigned int ciphertext_pad_len;
5900 	unsigned int ciphertext_len;
5901 	uint8_t buffer[10000];
5902 	uint8_t digest_buffer[10000];
5903 
5904 	struct rte_cryptodev_info dev_info;
5905 
5906 	/* Verify the capabilities */
5907 	struct rte_cryptodev_sym_capability_idx cap_idx;
5908 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5909 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5910 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5911 			&cap_idx) == NULL)
5912 		return TEST_SKIPPED;
5913 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5914 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5915 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5916 			&cap_idx) == NULL)
5917 		return TEST_SKIPPED;
5918 
5919 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5920 		return TEST_SKIPPED;
5921 
5922 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5923 
5924 	uint64_t feat_flags = dev_info.feature_flags;
5925 
5926 	if (op_mode == IN_PLACE) {
5927 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5928 			printf("Device doesn't support in-place scatter-gather "
5929 					"in both input and output mbufs.\n");
5930 			return TEST_SKIPPED;
5931 		}
5932 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5933 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5934 			printf("Device doesn't support RAW data-path APIs.\n");
5935 			return TEST_SKIPPED;
5936 		}
5937 	} else {
5938 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5939 			return TEST_SKIPPED;
5940 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5941 			printf("Device doesn't support out-of-place scatter-gather "
5942 					"in both input and output mbufs.\n");
5943 			return TEST_SKIPPED;
5944 		}
5945 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5946 			printf("Device doesn't support digest encrypted.\n");
5947 			return TEST_SKIPPED;
5948 		}
5949 	}
5950 
5951 	/* Create KASUMI session */
5952 	retval = create_wireless_algo_auth_cipher_session(
5953 			ts_params->valid_devs[0],
5954 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5955 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5956 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5957 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5958 			RTE_CRYPTO_AUTH_KASUMI_F9,
5959 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5960 			tdata->key.data, tdata->key.len,
5961 			tdata->key.data, tdata->key.len,
5962 			0, tdata->digest.len,
5963 			tdata->cipher_iv.len);
5964 
5965 	if (retval != 0)
5966 		return retval;
5967 
5968 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5969 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5970 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5971 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5972 
5973 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5974 			plaintext_pad_len, 15, 0);
5975 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5976 			"Failed to allocate input buffer in mempool");
5977 
5978 	if (op_mode == OUT_OF_PLACE) {
5979 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5980 				plaintext_pad_len, 15, 0);
5981 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5982 				"Failed to allocate output buffer in mempool");
5983 	}
5984 
5985 	if (verify) {
5986 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5987 			tdata->ciphertext.data);
5988 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5989 					ciphertext_len, buffer);
5990 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5991 			ciphertext_len);
5992 	} else {
5993 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5994 			tdata->plaintext.data);
5995 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5996 					plaintext_len, buffer);
5997 		debug_hexdump(stdout, "plaintext:", plaintext,
5998 			plaintext_len);
5999 	}
6000 	memset(buffer, 0, sizeof(buffer));
6001 
6002 	/* Create KASUMI operation */
6003 	retval = create_wireless_algo_auth_cipher_operation(
6004 		tdata->digest.data, tdata->digest.len,
6005 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6006 		NULL, 0,
6007 		(tdata->digest.offset_bytes == 0 ?
6008 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6009 			: tdata->digest.offset_bytes),
6010 		tdata->validCipherLenInBits.len,
6011 		tdata->validCipherOffsetInBits.len,
6012 		tdata->validAuthLenInBits.len,
6013 		0,
6014 		op_mode, 1, verify);
6015 
6016 	if (retval < 0)
6017 		return retval;
6018 
6019 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6020 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6021 					       tdata->cipher_iv.len);
6022 		if (retval != TEST_SUCCESS)
6023 			return retval;
6024 	} else
6025 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6026 			ut_params->op);
6027 
6028 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6029 
6030 	ut_params->obuf = (op_mode == IN_PLACE ?
6031 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6032 
6033 	if (verify) {
6034 		if (ut_params->obuf)
6035 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6036 					plaintext_len, buffer);
6037 		else
6038 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6039 					plaintext_len, buffer);
6040 
6041 		debug_hexdump(stdout, "plaintext:", plaintext,
6042 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6043 		debug_hexdump(stdout, "plaintext expected:",
6044 			tdata->plaintext.data,
6045 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6046 	} else {
6047 		if (ut_params->obuf)
6048 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6049 					ciphertext_len, buffer);
6050 		else
6051 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6052 					ciphertext_len, buffer);
6053 
6054 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6055 			ciphertext_len);
6056 		debug_hexdump(stdout, "ciphertext expected:",
6057 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6058 
6059 		if (ut_params->obuf)
6060 			digest = rte_pktmbuf_read(ut_params->obuf,
6061 				(tdata->digest.offset_bytes == 0 ?
6062 				plaintext_pad_len : tdata->digest.offset_bytes),
6063 				tdata->digest.len, digest_buffer);
6064 		else
6065 			digest = rte_pktmbuf_read(ut_params->ibuf,
6066 				(tdata->digest.offset_bytes == 0 ?
6067 				plaintext_pad_len : tdata->digest.offset_bytes),
6068 				tdata->digest.len, digest_buffer);
6069 
6070 		debug_hexdump(stdout, "digest:", digest,
6071 			tdata->digest.len);
6072 		debug_hexdump(stdout, "digest expected:",
6073 			tdata->digest.data, tdata->digest.len);
6074 	}
6075 
6076 	/* Validate obuf */
6077 	if (verify) {
6078 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6079 			plaintext,
6080 			tdata->plaintext.data,
6081 			tdata->plaintext.len >> 3,
6082 			"KASUMI Plaintext data not as expected");
6083 	} else {
6084 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6085 			ciphertext,
6086 			tdata->ciphertext.data,
6087 			tdata->validDataLenInBits.len,
6088 			"KASUMI Ciphertext data not as expected");
6089 
6090 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6091 			digest,
6092 			tdata->digest.data,
6093 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6094 			"KASUMI Generated auth tag not as expected");
6095 	}
6096 	return 0;
6097 }
6098 
6099 static int
6100 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6101 {
6102 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6103 	struct crypto_unittest_params *ut_params = &unittest_params;
6104 
6105 	int retval;
6106 
6107 	uint8_t *plaintext, *ciphertext;
6108 	unsigned plaintext_pad_len;
6109 	unsigned plaintext_len;
6110 	struct rte_cryptodev_info dev_info;
6111 
6112 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6113 	uint64_t feat_flags = dev_info.feature_flags;
6114 
6115 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6116 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6117 		printf("Device doesn't support RAW data-path APIs.\n");
6118 		return TEST_SKIPPED;
6119 	}
6120 
6121 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6122 		return TEST_SKIPPED;
6123 
6124 	/* Verify the capabilities */
6125 	struct rte_cryptodev_sym_capability_idx cap_idx;
6126 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6127 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6128 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6129 			&cap_idx) == NULL)
6130 		return TEST_SKIPPED;
6131 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6132 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6133 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6134 			&cap_idx) == NULL)
6135 		return TEST_SKIPPED;
6136 
6137 	/* Create KASUMI session */
6138 	retval = create_wireless_algo_cipher_auth_session(
6139 			ts_params->valid_devs[0],
6140 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6141 			RTE_CRYPTO_AUTH_OP_GENERATE,
6142 			RTE_CRYPTO_AUTH_KASUMI_F9,
6143 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6144 			tdata->key.data, tdata->key.len,
6145 			tdata->key.data, tdata->key.len,
6146 			0, tdata->digest.len,
6147 			tdata->cipher_iv.len);
6148 	if (retval != 0)
6149 		return retval;
6150 
6151 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6152 
6153 	/* clear mbuf payload */
6154 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6155 			rte_pktmbuf_tailroom(ut_params->ibuf));
6156 
6157 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6158 	/* Append data which is padded to a multiple of */
6159 	/* the algorithms block size */
6160 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6161 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6162 				plaintext_pad_len);
6163 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6164 
6165 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6166 
6167 	/* Create KASUMI operation */
6168 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6169 				tdata->digest.len, NULL, 0,
6170 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6171 				tdata->cipher_iv.data, tdata->cipher_iv.len,
6172 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6173 				tdata->validCipherOffsetInBits.len,
6174 				tdata->validAuthLenInBits.len,
6175 				0
6176 				);
6177 	if (retval < 0)
6178 		return retval;
6179 
6180 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6181 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6182 					       tdata->cipher_iv.len);
6183 		if (retval != TEST_SUCCESS)
6184 			return retval;
6185 	} else
6186 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6187 			ut_params->op);
6188 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6189 
6190 	if (ut_params->op->sym->m_dst)
6191 		ut_params->obuf = ut_params->op->sym->m_dst;
6192 	else
6193 		ut_params->obuf = ut_params->op->sym->m_src;
6194 
6195 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6196 				tdata->validCipherOffsetInBits.len >> 3);
6197 
6198 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6199 						    uint8_t *,
6200 						    plaintext_pad_len);
6201 
6202 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6203 				(tdata->validCipherOffsetInBits.len >> 3);
6204 	/* Validate obuf */
6205 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6206 		ciphertext,
6207 		reference_ciphertext,
6208 		tdata->validCipherLenInBits.len,
6209 		"KASUMI Ciphertext data not as expected");
6210 
6211 	/* Validate obuf */
6212 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6213 		ut_params->digest,
6214 		tdata->digest.data,
6215 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6216 		"KASUMI Generated auth tag not as expected");
6217 	return 0;
6218 }
6219 
6220 static int
6221 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6222 			const enum rte_crypto_cipher_algorithm cipher_algo,
6223 			const uint16_t key_size, const uint16_t iv_size)
6224 {
6225 	struct rte_cryptodev_sym_capability_idx cap_idx;
6226 	const struct rte_cryptodev_symmetric_capability *cap;
6227 
6228 	/* Check if device supports the algorithm */
6229 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6230 	cap_idx.algo.cipher = cipher_algo;
6231 
6232 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6233 			&cap_idx);
6234 
6235 	if (cap == NULL)
6236 		return -1;
6237 
6238 	/* Check if device supports key size and IV size */
6239 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6240 			iv_size) < 0) {
6241 		return -1;
6242 	}
6243 
6244 	return 0;
6245 }
6246 
6247 static int
6248 check_auth_capability(const struct crypto_testsuite_params *ts_params,
6249 			const enum rte_crypto_auth_algorithm auth_algo,
6250 			const uint16_t key_size, const uint16_t iv_size,
6251 			const uint16_t tag_size)
6252 {
6253 	struct rte_cryptodev_sym_capability_idx cap_idx;
6254 	const struct rte_cryptodev_symmetric_capability *cap;
6255 
6256 	/* Check if device supports the algorithm */
6257 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6258 	cap_idx.algo.auth = auth_algo;
6259 
6260 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6261 			&cap_idx);
6262 
6263 	if (cap == NULL)
6264 		return -1;
6265 
6266 	/* Check if device supports key size and IV size */
6267 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6268 			tag_size, iv_size) < 0) {
6269 		return -1;
6270 	}
6271 
6272 	return 0;
6273 }
6274 
6275 static int
6276 test_zuc_cipher(const struct wireless_test_data *tdata,
6277 		enum rte_crypto_cipher_operation direction)
6278 {
6279 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6280 	struct crypto_unittest_params *ut_params = &unittest_params;
6281 
6282 	int retval;
6283 	uint8_t *plaintext = NULL;
6284 	uint8_t *ciphertext = NULL;
6285 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6286 	unsigned int plaintext_len = 0;
6287 	unsigned int ciphertext_len = 0;
6288 	struct rte_cryptodev_info dev_info;
6289 
6290 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6291 	uint64_t feat_flags = dev_info.feature_flags;
6292 
6293 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6294 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6295 		printf("Device doesn't support RAW data-path APIs.\n");
6296 		return TEST_SKIPPED;
6297 	}
6298 
6299 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6300 		return TEST_SKIPPED;
6301 
6302 	/* Check if device supports ZUC EEA3 */
6303 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6304 			tdata->key.len, tdata->cipher_iv.len) < 0)
6305 		return TEST_SKIPPED;
6306 
6307 	/* Create ZUC session */
6308 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6309 					direction,
6310 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
6311 					tdata->key.data, tdata->key.len,
6312 					tdata->cipher_iv.len);
6313 	if (retval != 0)
6314 		return retval;
6315 
6316 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6317 
6318 	/* Clear mbuf payload */
6319 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6320 	       rte_pktmbuf_tailroom(ut_params->ibuf));
6321 
6322 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6323 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6324 		/* Append data which is padded to a multiple */
6325 		/* of the algorithms block size */
6326 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6327 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6328 				plaintext_pad_len);
6329 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6330 
6331 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6332 	} else {
6333 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6334 		/* Append data which is padded to a multiple */
6335 		/* of the algorithms block size */
6336 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6337 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6338 				ciphertext_pad_len);
6339 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6340 
6341 		debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6342 	}
6343 
6344 	/* Create ZUC operation */
6345 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6346 					tdata->cipher_iv.len,
6347 					tdata->plaintext.len,
6348 					tdata->validCipherOffsetInBits.len);
6349 	if (retval < 0)
6350 		return retval;
6351 
6352 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6353 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6354 					       tdata->cipher_iv.len);
6355 		if (retval != TEST_SUCCESS)
6356 			return retval;
6357 	} else
6358 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6359 						ut_params->op);
6360 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6361 
6362 	ut_params->obuf = ut_params->op->sym->m_dst;
6363 
6364 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6365 		if (ut_params->obuf)
6366 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6367 		else
6368 			ciphertext = plaintext;
6369 
6370 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6371 
6372 		/* Validate obuf */
6373 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6374 				ciphertext,
6375 				tdata->ciphertext.data,
6376 				tdata->validCipherLenInBits.len,
6377 				"ZUC Ciphertext data not as expected");
6378 	} else {
6379 		if (ut_params->obuf)
6380 			plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6381 		else
6382 			plaintext = ciphertext;
6383 
6384 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6385 
6386 		const uint8_t *reference_plaintext = tdata->plaintext.data +
6387 				(tdata->validCipherOffsetInBits.len >> 3);
6388 
6389 		/* Validate obuf */
6390 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6391 				plaintext,
6392 				reference_plaintext,
6393 				tdata->validCipherLenInBits.len,
6394 				"ZUC Plaintext data not as expected");
6395 	}
6396 
6397 	return 0;
6398 }
6399 
6400 static int
6401 test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6402 		enum rte_crypto_cipher_operation direction)
6403 {
6404 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6405 	struct crypto_unittest_params *ut_params = &unittest_params;
6406 
6407 	int retval;
6408 
6409 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6410 	unsigned int plaintext_len = 0;
6411 	unsigned int ciphertext_len = 0;
6412 	const uint8_t *ciphertext, *plaintext;
6413 	uint8_t buffer[2048];
6414 	struct rte_cryptodev_info dev_info;
6415 
6416 	/* Check if device supports ZUC EEA3 */
6417 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6418 			tdata->key.len, tdata->cipher_iv.len) < 0)
6419 		return TEST_SKIPPED;
6420 
6421 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6422 		return TEST_SKIPPED;
6423 
6424 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6425 
6426 	uint64_t feat_flags = dev_info.feature_flags;
6427 
6428 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6429 		printf("Device doesn't support in-place scatter-gather. "
6430 				"Test Skipped.\n");
6431 		return TEST_SKIPPED;
6432 	}
6433 
6434 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6435 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6436 		printf("Device doesn't support RAW data-path APIs.\n");
6437 		return TEST_SKIPPED;
6438 	}
6439 
6440 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6441 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6442 
6443 		/* Append data which is padded to a multiple */
6444 		/* of the algorithms block size */
6445 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6446 
6447 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6448 				plaintext_pad_len, 10, 0);
6449 
6450 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6451 				tdata->plaintext.data);
6452 	} else {
6453 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6454 
6455 		/* Append data which is padded to a multiple */
6456 		/* of the algorithms block size */
6457 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6458 
6459 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6460 				ciphertext_pad_len, 10, 0);
6461 
6462 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6463 				tdata->ciphertext.data);
6464 
6465 	}
6466 
6467 	/* Create ZUC session */
6468 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6469 			direction,
6470 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6471 			tdata->key.data, tdata->key.len,
6472 			tdata->cipher_iv.len);
6473 	if (retval < 0)
6474 		return retval;
6475 
6476 	/* Clear mbuf payload */
6477 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6478 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6479 	else
6480 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6481 
6482 	/* Create ZUC operation */
6483 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6484 			tdata->cipher_iv.len, tdata->plaintext.len,
6485 			tdata->validCipherOffsetInBits.len);
6486 	if (retval < 0)
6487 		return retval;
6488 
6489 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6490 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6491 					       tdata->cipher_iv.len);
6492 		if (retval != TEST_SUCCESS)
6493 			return retval;
6494 	} else
6495 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6496 						ut_params->op);
6497 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6498 
6499 	ut_params->obuf = ut_params->op->sym->m_dst;
6500 
6501 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6502 		if (ut_params->obuf)
6503 			ciphertext = rte_pktmbuf_read(ut_params->obuf,
6504 				0, plaintext_len, buffer);
6505 		else
6506 			ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6507 				0, plaintext_len, buffer);
6508 
6509 		/* Validate obuf */
6510 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6511 
6512 		/* Validate obuf */
6513 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6514 			ciphertext,
6515 			tdata->ciphertext.data,
6516 			tdata->validCipherLenInBits.len,
6517 			"ZUC Ciphertext data not as expected");
6518 	} else {
6519 		if (ut_params->obuf)
6520 			plaintext = rte_pktmbuf_read(ut_params->obuf,
6521 				0, ciphertext_len, buffer);
6522 		else
6523 			plaintext = rte_pktmbuf_read(ut_params->ibuf,
6524 				0, ciphertext_len, buffer);
6525 
6526 		/* Validate obuf */
6527 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6528 
6529 		/* Validate obuf */
6530 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6531 			plaintext,
6532 			tdata->plaintext.data,
6533 			tdata->validCipherLenInBits.len,
6534 			"ZUC Plaintext data not as expected");
6535 		}
6536 
6537 	return 0;
6538 }
6539 
6540 static int
6541 test_zuc_authentication(const struct wireless_test_data *tdata,
6542 		enum rte_crypto_auth_operation auth_op)
6543 {
6544 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6545 	struct crypto_unittest_params *ut_params = &unittest_params;
6546 
6547 	int retval;
6548 	unsigned plaintext_pad_len;
6549 	unsigned plaintext_len;
6550 	uint8_t *plaintext;
6551 
6552 	struct rte_cryptodev_info dev_info;
6553 
6554 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6555 	uint64_t feat_flags = dev_info.feature_flags;
6556 
6557 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6558 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6559 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6560 		return TEST_SKIPPED;
6561 	}
6562 
6563 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6564 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6565 		printf("Device doesn't support RAW data-path APIs.\n");
6566 		return TEST_SKIPPED;
6567 	}
6568 
6569 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6570 		return TEST_SKIPPED;
6571 
6572 	/* Check if device supports ZUC EIA3 */
6573 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6574 			tdata->key.len, tdata->auth_iv.len,
6575 			tdata->digest.len) < 0)
6576 		return TEST_SKIPPED;
6577 
6578 	/* Create ZUC session */
6579 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6580 			tdata->key.data, tdata->key.len,
6581 			tdata->auth_iv.len, tdata->digest.len,
6582 			auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6583 	if (retval != 0)
6584 		return retval;
6585 
6586 	/* alloc mbuf and set payload */
6587 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6588 
6589 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6590 	rte_pktmbuf_tailroom(ut_params->ibuf));
6591 
6592 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6593 	/* Append data which is padded to a multiple of */
6594 	/* the algorithms block size */
6595 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6596 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6597 				plaintext_pad_len);
6598 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6599 
6600 	/* Create ZUC operation */
6601 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
6602 			tdata->digest.len,
6603 			tdata->auth_iv.data, tdata->auth_iv.len,
6604 			plaintext_pad_len,
6605 			auth_op, tdata->validAuthLenInBits.len, 0);
6606 	if (retval < 0)
6607 		return retval;
6608 
6609 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6610 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6611 					       0);
6612 		if (retval != TEST_SUCCESS)
6613 			return retval;
6614 	} else
6615 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6616 				ut_params->op);
6617 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6618 	ut_params->obuf = ut_params->op->sym->m_src;
6619 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6620 						    uint8_t *,
6621 						    plaintext_pad_len);
6622 
6623 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6624 		/* Validate obuf */
6625 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6626 				ut_params->digest,
6627 				tdata->digest.data,
6628 				tdata->digest.len,
6629 				"ZUC Generated auth tag not as expected");
6630 		return 0;
6631 	}
6632 
6633 	/* Validate obuf */
6634 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6635 		return 0;
6636 	else
6637 		return -1;
6638 
6639 	return 0;
6640 }
6641 
6642 static int
6643 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6644 	uint8_t op_mode, uint8_t verify)
6645 {
6646 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6647 	struct crypto_unittest_params *ut_params = &unittest_params;
6648 
6649 	int retval;
6650 
6651 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6652 	unsigned int plaintext_pad_len;
6653 	unsigned int plaintext_len;
6654 	unsigned int ciphertext_pad_len;
6655 	unsigned int ciphertext_len;
6656 	unsigned int digest_offset;
6657 
6658 	struct rte_cryptodev_info dev_info;
6659 
6660 	/* Check if device supports ZUC EEA3 */
6661 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6662 			tdata->key.len, tdata->cipher_iv.len) < 0)
6663 		return TEST_SKIPPED;
6664 
6665 	/* Check if device supports ZUC EIA3 */
6666 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6667 			tdata->key.len, tdata->auth_iv.len,
6668 			tdata->digest.len) < 0)
6669 		return TEST_SKIPPED;
6670 
6671 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6672 		return TEST_SKIPPED;
6673 
6674 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6675 
6676 	uint64_t feat_flags = dev_info.feature_flags;
6677 
6678 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6679 		printf("Device doesn't support digest encrypted.\n");
6680 		return TEST_SKIPPED;
6681 	}
6682 	if (op_mode == IN_PLACE) {
6683 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6684 			printf("Device doesn't support in-place scatter-gather "
6685 					"in both input and output mbufs.\n");
6686 			return TEST_SKIPPED;
6687 		}
6688 
6689 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6690 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6691 			printf("Device doesn't support RAW data-path APIs.\n");
6692 			return TEST_SKIPPED;
6693 		}
6694 	} else {
6695 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6696 			return TEST_SKIPPED;
6697 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6698 			printf("Device doesn't support out-of-place scatter-gather "
6699 					"in both input and output mbufs.\n");
6700 			return TEST_SKIPPED;
6701 		}
6702 	}
6703 
6704 	/* Create ZUC session */
6705 	retval = create_wireless_algo_auth_cipher_session(
6706 			ts_params->valid_devs[0],
6707 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6708 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6709 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6710 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6711 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6712 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6713 			tdata->key.data, tdata->key.len,
6714 			tdata->key.data, tdata->key.len,
6715 			tdata->auth_iv.len, tdata->digest.len,
6716 			tdata->cipher_iv.len);
6717 
6718 	if (retval != 0)
6719 		return retval;
6720 
6721 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6722 	if (op_mode == OUT_OF_PLACE)
6723 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6724 
6725 	/* clear mbuf payload */
6726 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6727 		rte_pktmbuf_tailroom(ut_params->ibuf));
6728 	if (op_mode == OUT_OF_PLACE)
6729 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6730 			rte_pktmbuf_tailroom(ut_params->obuf));
6731 
6732 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6733 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6734 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6735 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6736 
6737 	if (verify) {
6738 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6739 					ciphertext_pad_len);
6740 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6741 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6742 			ciphertext_len);
6743 	} else {
6744 		/* make sure enough space to cover partial digest verify case */
6745 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6746 					ciphertext_pad_len);
6747 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6748 		debug_hexdump(stdout, "plaintext:", plaintext,
6749 			plaintext_len);
6750 	}
6751 
6752 	if (op_mode == OUT_OF_PLACE)
6753 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6754 
6755 	/* Create ZUC operation */
6756 	retval = create_wireless_algo_auth_cipher_operation(
6757 		tdata->digest.data, tdata->digest.len,
6758 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6759 		tdata->auth_iv.data, tdata->auth_iv.len,
6760 		(tdata->digest.offset_bytes == 0 ?
6761 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6762 			: tdata->digest.offset_bytes),
6763 		tdata->validCipherLenInBits.len,
6764 		tdata->validCipherOffsetInBits.len,
6765 		tdata->validAuthLenInBits.len,
6766 		0,
6767 		op_mode, 0, verify);
6768 
6769 	if (retval < 0)
6770 		return retval;
6771 
6772 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6773 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6774 					       tdata->cipher_iv.len);
6775 		if (retval != TEST_SUCCESS)
6776 			return retval;
6777 	} else
6778 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6779 			ut_params->op);
6780 
6781 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6782 
6783 	ut_params->obuf = (op_mode == IN_PLACE ?
6784 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6785 
6786 
6787 	if (verify) {
6788 		if (ut_params->obuf)
6789 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6790 							uint8_t *);
6791 		else
6792 			plaintext = ciphertext;
6793 
6794 		debug_hexdump(stdout, "plaintext:", plaintext,
6795 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6796 		debug_hexdump(stdout, "plaintext expected:",
6797 			tdata->plaintext.data,
6798 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6799 	} else {
6800 		if (ut_params->obuf)
6801 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6802 							uint8_t *);
6803 		else
6804 			ciphertext = plaintext;
6805 
6806 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6807 			ciphertext_len);
6808 		debug_hexdump(stdout, "ciphertext expected:",
6809 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6810 
6811 		if (tdata->digest.offset_bytes == 0)
6812 			digest_offset = plaintext_pad_len;
6813 		else
6814 			digest_offset =  tdata->digest.offset_bytes;
6815 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6816 					    uint8_t *, digest_offset);
6817 
6818 		debug_hexdump(stdout, "digest:", ut_params->digest,
6819 			tdata->digest.len);
6820 		debug_hexdump(stdout, "digest expected:",
6821 			tdata->digest.data, tdata->digest.len);
6822 	}
6823 
6824 	/* Validate obuf */
6825 	if (verify) {
6826 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6827 			plaintext,
6828 			tdata->plaintext.data,
6829 			tdata->plaintext.len >> 3,
6830 			"ZUC Plaintext data not as expected");
6831 	} else {
6832 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6833 			ciphertext,
6834 			tdata->ciphertext.data,
6835 			tdata->ciphertext.len >> 3,
6836 			"ZUC Ciphertext data not as expected");
6837 
6838 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6839 			ut_params->digest,
6840 			tdata->digest.data,
6841 			tdata->digest.len,
6842 			"ZUC Generated auth tag not as expected");
6843 	}
6844 	return 0;
6845 }
6846 
6847 static int
6848 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6849 	uint8_t op_mode, uint8_t verify)
6850 {
6851 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6852 	struct crypto_unittest_params *ut_params = &unittest_params;
6853 
6854 	int retval;
6855 
6856 	const uint8_t *plaintext = NULL;
6857 	const uint8_t *ciphertext = NULL;
6858 	const uint8_t *digest = NULL;
6859 	unsigned int plaintext_pad_len;
6860 	unsigned int plaintext_len;
6861 	unsigned int ciphertext_pad_len;
6862 	unsigned int ciphertext_len;
6863 	uint8_t buffer[10000];
6864 	uint8_t digest_buffer[10000];
6865 
6866 	struct rte_cryptodev_info dev_info;
6867 
6868 	/* Check if device supports ZUC EEA3 */
6869 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6870 			tdata->key.len, tdata->cipher_iv.len) < 0)
6871 		return TEST_SKIPPED;
6872 
6873 	/* Check if device supports ZUC EIA3 */
6874 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6875 			tdata->key.len, tdata->auth_iv.len,
6876 			tdata->digest.len) < 0)
6877 		return TEST_SKIPPED;
6878 
6879 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6880 		return TEST_SKIPPED;
6881 
6882 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6883 
6884 	uint64_t feat_flags = dev_info.feature_flags;
6885 
6886 	if (op_mode == IN_PLACE) {
6887 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6888 			printf("Device doesn't support in-place scatter-gather "
6889 					"in both input and output mbufs.\n");
6890 			return TEST_SKIPPED;
6891 		}
6892 
6893 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6894 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6895 			printf("Device doesn't support RAW data-path APIs.\n");
6896 			return TEST_SKIPPED;
6897 		}
6898 	} else {
6899 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6900 			return TEST_SKIPPED;
6901 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6902 			printf("Device doesn't support out-of-place scatter-gather "
6903 					"in both input and output mbufs.\n");
6904 			return TEST_SKIPPED;
6905 		}
6906 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6907 			printf("Device doesn't support digest encrypted.\n");
6908 			return TEST_SKIPPED;
6909 		}
6910 	}
6911 
6912 	/* Create ZUC session */
6913 	retval = create_wireless_algo_auth_cipher_session(
6914 			ts_params->valid_devs[0],
6915 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6916 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6917 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6918 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6919 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6920 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6921 			tdata->key.data, tdata->key.len,
6922 			tdata->key.data, tdata->key.len,
6923 			tdata->auth_iv.len, tdata->digest.len,
6924 			tdata->cipher_iv.len);
6925 
6926 	if (retval != 0)
6927 		return retval;
6928 
6929 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6930 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6931 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6932 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6933 
6934 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6935 			plaintext_pad_len, 15, 0);
6936 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6937 			"Failed to allocate input buffer in mempool");
6938 
6939 	if (op_mode == OUT_OF_PLACE) {
6940 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6941 				plaintext_pad_len, 15, 0);
6942 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6943 				"Failed to allocate output buffer in mempool");
6944 	}
6945 
6946 	if (verify) {
6947 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6948 			tdata->ciphertext.data);
6949 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6950 					ciphertext_len, buffer);
6951 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6952 			ciphertext_len);
6953 	} else {
6954 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6955 			tdata->plaintext.data);
6956 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6957 					plaintext_len, buffer);
6958 		debug_hexdump(stdout, "plaintext:", plaintext,
6959 			plaintext_len);
6960 	}
6961 	memset(buffer, 0, sizeof(buffer));
6962 
6963 	/* Create ZUC operation */
6964 	retval = create_wireless_algo_auth_cipher_operation(
6965 		tdata->digest.data, tdata->digest.len,
6966 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6967 		tdata->auth_iv.data, tdata->auth_iv.len,
6968 		(tdata->digest.offset_bytes == 0 ?
6969 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6970 			: tdata->digest.offset_bytes),
6971 		tdata->validCipherLenInBits.len,
6972 		tdata->validCipherOffsetInBits.len,
6973 		tdata->validAuthLenInBits.len,
6974 		0,
6975 		op_mode, 1, verify);
6976 
6977 	if (retval < 0)
6978 		return retval;
6979 
6980 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6981 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6982 					       tdata->cipher_iv.len);
6983 		if (retval != TEST_SUCCESS)
6984 			return retval;
6985 	} else
6986 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6987 			ut_params->op);
6988 
6989 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6990 
6991 	ut_params->obuf = (op_mode == IN_PLACE ?
6992 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6993 
6994 	if (verify) {
6995 		if (ut_params->obuf)
6996 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6997 					plaintext_len, buffer);
6998 		else
6999 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7000 					plaintext_len, buffer);
7001 
7002 		debug_hexdump(stdout, "plaintext:", plaintext,
7003 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7004 		debug_hexdump(stdout, "plaintext expected:",
7005 			tdata->plaintext.data,
7006 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7007 	} else {
7008 		if (ut_params->obuf)
7009 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7010 					ciphertext_len, buffer);
7011 		else
7012 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7013 					ciphertext_len, buffer);
7014 
7015 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7016 			ciphertext_len);
7017 		debug_hexdump(stdout, "ciphertext expected:",
7018 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7019 
7020 		if (ut_params->obuf)
7021 			digest = rte_pktmbuf_read(ut_params->obuf,
7022 				(tdata->digest.offset_bytes == 0 ?
7023 				plaintext_pad_len : tdata->digest.offset_bytes),
7024 				tdata->digest.len, digest_buffer);
7025 		else
7026 			digest = rte_pktmbuf_read(ut_params->ibuf,
7027 				(tdata->digest.offset_bytes == 0 ?
7028 				plaintext_pad_len : tdata->digest.offset_bytes),
7029 				tdata->digest.len, digest_buffer);
7030 
7031 		debug_hexdump(stdout, "digest:", digest,
7032 			tdata->digest.len);
7033 		debug_hexdump(stdout, "digest expected:",
7034 			tdata->digest.data, tdata->digest.len);
7035 	}
7036 
7037 	/* Validate obuf */
7038 	if (verify) {
7039 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7040 			plaintext,
7041 			tdata->plaintext.data,
7042 			tdata->plaintext.len >> 3,
7043 			"ZUC Plaintext data not as expected");
7044 	} else {
7045 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7046 			ciphertext,
7047 			tdata->ciphertext.data,
7048 			tdata->validDataLenInBits.len,
7049 			"ZUC Ciphertext data not as expected");
7050 
7051 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7052 			digest,
7053 			tdata->digest.data,
7054 			tdata->digest.len,
7055 			"ZUC Generated auth tag not as expected");
7056 	}
7057 	return 0;
7058 }
7059 
7060 static int
7061 test_kasumi_encryption_test_case_1(void)
7062 {
7063 	return test_kasumi_encryption(&kasumi_test_case_1);
7064 }
7065 
7066 static int
7067 test_kasumi_encryption_test_case_1_sgl(void)
7068 {
7069 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7070 }
7071 
7072 static int
7073 test_kasumi_encryption_test_case_1_oop(void)
7074 {
7075 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
7076 }
7077 
7078 static int
7079 test_kasumi_encryption_test_case_1_oop_sgl(void)
7080 {
7081 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7082 }
7083 
7084 static int
7085 test_kasumi_encryption_test_case_2(void)
7086 {
7087 	return test_kasumi_encryption(&kasumi_test_case_2);
7088 }
7089 
7090 static int
7091 test_kasumi_encryption_test_case_3(void)
7092 {
7093 	return test_kasumi_encryption(&kasumi_test_case_3);
7094 }
7095 
7096 static int
7097 test_kasumi_encryption_test_case_4(void)
7098 {
7099 	return test_kasumi_encryption(&kasumi_test_case_4);
7100 }
7101 
7102 static int
7103 test_kasumi_encryption_test_case_5(void)
7104 {
7105 	return test_kasumi_encryption(&kasumi_test_case_5);
7106 }
7107 
7108 static int
7109 test_kasumi_decryption_test_case_1(void)
7110 {
7111 	return test_kasumi_decryption(&kasumi_test_case_1);
7112 }
7113 
7114 static int
7115 test_kasumi_decryption_test_case_1_oop(void)
7116 {
7117 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
7118 }
7119 
7120 static int
7121 test_kasumi_decryption_test_case_2(void)
7122 {
7123 	return test_kasumi_decryption(&kasumi_test_case_2);
7124 }
7125 
7126 static int
7127 test_kasumi_decryption_test_case_3(void)
7128 {
7129 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7130 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7131 		return TEST_SKIPPED;
7132 	return test_kasumi_decryption(&kasumi_test_case_3);
7133 }
7134 
7135 static int
7136 test_kasumi_decryption_test_case_4(void)
7137 {
7138 	return test_kasumi_decryption(&kasumi_test_case_4);
7139 }
7140 
7141 static int
7142 test_kasumi_decryption_test_case_5(void)
7143 {
7144 	return test_kasumi_decryption(&kasumi_test_case_5);
7145 }
7146 static int
7147 test_snow3g_encryption_test_case_1(void)
7148 {
7149 	return test_snow3g_encryption(&snow3g_test_case_1);
7150 }
7151 
7152 static int
7153 test_snow3g_encryption_test_case_1_oop(void)
7154 {
7155 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
7156 }
7157 
7158 static int
7159 test_snow3g_encryption_test_case_1_oop_sgl(void)
7160 {
7161 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7162 }
7163 
7164 static int
7165 test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7166 {
7167 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7168 }
7169 
7170 static int
7171 test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7172 {
7173 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7174 }
7175 
7176 static int
7177 test_snow3g_encryption_test_case_1_offset_oop(void)
7178 {
7179 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7180 }
7181 
7182 static int
7183 test_snow3g_encryption_test_case_2(void)
7184 {
7185 	return test_snow3g_encryption(&snow3g_test_case_2);
7186 }
7187 
7188 static int
7189 test_snow3g_encryption_test_case_3(void)
7190 {
7191 	return test_snow3g_encryption(&snow3g_test_case_3);
7192 }
7193 
7194 static int
7195 test_snow3g_encryption_test_case_4(void)
7196 {
7197 	return test_snow3g_encryption(&snow3g_test_case_4);
7198 }
7199 
7200 static int
7201 test_snow3g_encryption_test_case_5(void)
7202 {
7203 	return test_snow3g_encryption(&snow3g_test_case_5);
7204 }
7205 
7206 static int
7207 test_snow3g_decryption_test_case_1(void)
7208 {
7209 	return test_snow3g_decryption(&snow3g_test_case_1);
7210 }
7211 
7212 static int
7213 test_snow3g_decryption_test_case_1_oop(void)
7214 {
7215 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
7216 }
7217 
7218 static int
7219 test_snow3g_decryption_test_case_2(void)
7220 {
7221 	return test_snow3g_decryption(&snow3g_test_case_2);
7222 }
7223 
7224 static int
7225 test_snow3g_decryption_test_case_3(void)
7226 {
7227 	return test_snow3g_decryption(&snow3g_test_case_3);
7228 }
7229 
7230 static int
7231 test_snow3g_decryption_test_case_4(void)
7232 {
7233 	return test_snow3g_decryption(&snow3g_test_case_4);
7234 }
7235 
7236 static int
7237 test_snow3g_decryption_test_case_5(void)
7238 {
7239 	return test_snow3g_decryption(&snow3g_test_case_5);
7240 }
7241 
7242 /*
7243  * Function prepares snow3g_hash_test_data from snow3g_test_data.
7244  * Pattern digest from snow3g_test_data must be allocated as
7245  * 4 last bytes in plaintext.
7246  */
7247 static void
7248 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7249 		struct snow3g_hash_test_data *output)
7250 {
7251 	if ((pattern != NULL) && (output != NULL)) {
7252 		output->key.len = pattern->key.len;
7253 
7254 		memcpy(output->key.data,
7255 		pattern->key.data, pattern->key.len);
7256 
7257 		output->auth_iv.len = pattern->auth_iv.len;
7258 
7259 		memcpy(output->auth_iv.data,
7260 		pattern->auth_iv.data, pattern->auth_iv.len);
7261 
7262 		output->plaintext.len = pattern->plaintext.len;
7263 
7264 		memcpy(output->plaintext.data,
7265 		pattern->plaintext.data, pattern->plaintext.len >> 3);
7266 
7267 		output->digest.len = pattern->digest.len;
7268 
7269 		memcpy(output->digest.data,
7270 		&pattern->plaintext.data[pattern->digest.offset_bytes],
7271 		pattern->digest.len);
7272 
7273 		output->validAuthLenInBits.len =
7274 		pattern->validAuthLenInBits.len;
7275 	}
7276 }
7277 
7278 /*
7279  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7280  */
7281 static int
7282 test_snow3g_decryption_with_digest_test_case_1(void)
7283 {
7284 	int ret;
7285 	struct snow3g_hash_test_data snow3g_hash_data;
7286 	struct rte_cryptodev_info dev_info;
7287 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7288 
7289 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7290 	uint64_t feat_flags = dev_info.feature_flags;
7291 
7292 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7293 		printf("Device doesn't support encrypted digest operations.\n");
7294 		return TEST_SKIPPED;
7295 	}
7296 
7297 	/*
7298 	 * Function prepare data for hash verification test case.
7299 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
7300 	 */
7301 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7302 
7303 	ret = test_snow3g_decryption(&snow3g_test_case_7);
7304 	if (ret != 0)
7305 		return ret;
7306 
7307 	return test_snow3g_authentication_verify(&snow3g_hash_data);
7308 }
7309 
7310 static int
7311 test_snow3g_cipher_auth_test_case_1(void)
7312 {
7313 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
7314 }
7315 
7316 static int
7317 test_snow3g_auth_cipher_test_case_1(void)
7318 {
7319 	return test_snow3g_auth_cipher(
7320 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7321 }
7322 
7323 static int
7324 test_snow3g_auth_cipher_test_case_2(void)
7325 {
7326 	return test_snow3g_auth_cipher(
7327 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7328 }
7329 
7330 static int
7331 test_snow3g_auth_cipher_test_case_2_oop(void)
7332 {
7333 	return test_snow3g_auth_cipher(
7334 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7335 }
7336 
7337 static int
7338 test_snow3g_auth_cipher_part_digest_enc(void)
7339 {
7340 	return test_snow3g_auth_cipher(
7341 		&snow3g_auth_cipher_partial_digest_encryption,
7342 			IN_PLACE, 0);
7343 }
7344 
7345 static int
7346 test_snow3g_auth_cipher_part_digest_enc_oop(void)
7347 {
7348 	return test_snow3g_auth_cipher(
7349 		&snow3g_auth_cipher_partial_digest_encryption,
7350 			OUT_OF_PLACE, 0);
7351 }
7352 
7353 static int
7354 test_snow3g_auth_cipher_test_case_3_sgl(void)
7355 {
7356 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7357 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7358 		return TEST_SKIPPED;
7359 	return test_snow3g_auth_cipher_sgl(
7360 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7361 }
7362 
7363 static int
7364 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7365 {
7366 	return test_snow3g_auth_cipher_sgl(
7367 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7368 }
7369 
7370 static int
7371 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7372 {
7373 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7374 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7375 		return TEST_SKIPPED;
7376 	return test_snow3g_auth_cipher_sgl(
7377 		&snow3g_auth_cipher_partial_digest_encryption,
7378 			IN_PLACE, 0);
7379 }
7380 
7381 static int
7382 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7383 {
7384 	return test_snow3g_auth_cipher_sgl(
7385 		&snow3g_auth_cipher_partial_digest_encryption,
7386 			OUT_OF_PLACE, 0);
7387 }
7388 
7389 static int
7390 test_snow3g_auth_cipher_total_digest_enc_1(void)
7391 {
7392 	return test_snow3g_auth_cipher(
7393 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7394 }
7395 
7396 static int
7397 test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7398 {
7399 	return test_snow3g_auth_cipher(
7400 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7401 }
7402 
7403 static int
7404 test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7405 {
7406 	return test_snow3g_auth_cipher_sgl(
7407 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7408 }
7409 
7410 static int
7411 test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7412 {
7413 	return test_snow3g_auth_cipher_sgl(
7414 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7415 }
7416 
7417 static int
7418 test_snow3g_auth_cipher_verify_test_case_1(void)
7419 {
7420 	return test_snow3g_auth_cipher(
7421 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7422 }
7423 
7424 static int
7425 test_snow3g_auth_cipher_verify_test_case_2(void)
7426 {
7427 	return test_snow3g_auth_cipher(
7428 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7429 }
7430 
7431 static int
7432 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7433 {
7434 	return test_snow3g_auth_cipher(
7435 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7436 }
7437 
7438 static int
7439 test_snow3g_auth_cipher_verify_part_digest_enc(void)
7440 {
7441 	return test_snow3g_auth_cipher(
7442 		&snow3g_auth_cipher_partial_digest_encryption,
7443 			IN_PLACE, 1);
7444 }
7445 
7446 static int
7447 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7448 {
7449 	return test_snow3g_auth_cipher(
7450 		&snow3g_auth_cipher_partial_digest_encryption,
7451 			OUT_OF_PLACE, 1);
7452 }
7453 
7454 static int
7455 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7456 {
7457 	return test_snow3g_auth_cipher_sgl(
7458 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7459 }
7460 
7461 static int
7462 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7463 {
7464 	return test_snow3g_auth_cipher_sgl(
7465 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7466 }
7467 
7468 static int
7469 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7470 {
7471 	return test_snow3g_auth_cipher_sgl(
7472 		&snow3g_auth_cipher_partial_digest_encryption,
7473 			IN_PLACE, 1);
7474 }
7475 
7476 static int
7477 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7478 {
7479 	return test_snow3g_auth_cipher_sgl(
7480 		&snow3g_auth_cipher_partial_digest_encryption,
7481 			OUT_OF_PLACE, 1);
7482 }
7483 
7484 static int
7485 test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7486 {
7487 	return test_snow3g_auth_cipher(
7488 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7489 }
7490 
7491 static int
7492 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7493 {
7494 	return test_snow3g_auth_cipher(
7495 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7496 }
7497 
7498 static int
7499 test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7500 {
7501 	return test_snow3g_auth_cipher_sgl(
7502 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7503 }
7504 
7505 static int
7506 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7507 {
7508 	return test_snow3g_auth_cipher_sgl(
7509 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7510 }
7511 
7512 static int
7513 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7514 {
7515 	return test_snow3g_auth_cipher(
7516 		&snow3g_test_case_7, IN_PLACE, 0);
7517 }
7518 
7519 static int
7520 test_kasumi_auth_cipher_test_case_1(void)
7521 {
7522 	return test_kasumi_auth_cipher(
7523 		&kasumi_test_case_3, IN_PLACE, 0);
7524 }
7525 
7526 static int
7527 test_kasumi_auth_cipher_test_case_2(void)
7528 {
7529 	return test_kasumi_auth_cipher(
7530 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7531 }
7532 
7533 static int
7534 test_kasumi_auth_cipher_test_case_2_oop(void)
7535 {
7536 	return test_kasumi_auth_cipher(
7537 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7538 }
7539 
7540 static int
7541 test_kasumi_auth_cipher_test_case_2_sgl(void)
7542 {
7543 	return test_kasumi_auth_cipher_sgl(
7544 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7545 }
7546 
7547 static int
7548 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7549 {
7550 	return test_kasumi_auth_cipher_sgl(
7551 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7552 }
7553 
7554 static int
7555 test_kasumi_auth_cipher_verify_test_case_1(void)
7556 {
7557 	return test_kasumi_auth_cipher(
7558 		&kasumi_test_case_3, IN_PLACE, 1);
7559 }
7560 
7561 static int
7562 test_kasumi_auth_cipher_verify_test_case_2(void)
7563 {
7564 	return test_kasumi_auth_cipher(
7565 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7566 }
7567 
7568 static int
7569 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7570 {
7571 	return test_kasumi_auth_cipher(
7572 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7573 }
7574 
7575 static int
7576 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7577 {
7578 	return test_kasumi_auth_cipher_sgl(
7579 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7580 }
7581 
7582 static int
7583 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7584 {
7585 	return test_kasumi_auth_cipher_sgl(
7586 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7587 }
7588 
7589 static int
7590 test_kasumi_cipher_auth_test_case_1(void)
7591 {
7592 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7593 }
7594 
7595 static int
7596 test_zuc_encryption_test_case_1(void)
7597 {
7598 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7599 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7600 }
7601 
7602 static int
7603 test_zuc_encryption_test_case_2(void)
7604 {
7605 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7606 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7607 }
7608 
7609 static int
7610 test_zuc_encryption_test_case_3(void)
7611 {
7612 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7613 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7614 }
7615 
7616 static int
7617 test_zuc_encryption_test_case_4(void)
7618 {
7619 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7620 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7621 }
7622 
7623 static int
7624 test_zuc_encryption_test_case_5(void)
7625 {
7626 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7627 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7628 }
7629 
7630 static int
7631 test_zuc_encryption_test_case_6_sgl(void)
7632 {
7633 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7634 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7635 }
7636 
7637 static int
7638 test_zuc_decryption_test_case_1(void)
7639 {
7640 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7641 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7642 }
7643 
7644 static int
7645 test_zuc_decryption_test_case_2(void)
7646 {
7647 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7648 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7649 }
7650 
7651 static int
7652 test_zuc_decryption_test_case_3(void)
7653 {
7654 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7655 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7656 }
7657 
7658 static int
7659 test_zuc_decryption_test_case_4(void)
7660 {
7661 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7662 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7663 }
7664 
7665 static int
7666 test_zuc_decryption_test_case_5(void)
7667 {
7668 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7669 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7670 }
7671 
7672 static int
7673 test_zuc_decryption_test_case_6_sgl(void)
7674 {
7675 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7676 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7677 }
7678 
7679 static int
7680 test_zuc_hash_generate_test_case_1(void)
7681 {
7682 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7683 			RTE_CRYPTO_AUTH_OP_GENERATE);
7684 }
7685 
7686 static int
7687 test_zuc_hash_generate_test_case_2(void)
7688 {
7689 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7690 			RTE_CRYPTO_AUTH_OP_GENERATE);
7691 }
7692 
7693 static int
7694 test_zuc_hash_generate_test_case_3(void)
7695 {
7696 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7697 			RTE_CRYPTO_AUTH_OP_GENERATE);
7698 }
7699 
7700 static int
7701 test_zuc_hash_generate_test_case_4(void)
7702 {
7703 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7704 			RTE_CRYPTO_AUTH_OP_GENERATE);
7705 }
7706 
7707 static int
7708 test_zuc_hash_generate_test_case_5(void)
7709 {
7710 	return test_zuc_authentication(&zuc_test_auth_5670b,
7711 			RTE_CRYPTO_AUTH_OP_GENERATE);
7712 }
7713 
7714 static int
7715 test_zuc_hash_generate_test_case_6(void)
7716 {
7717 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7718 			RTE_CRYPTO_AUTH_OP_GENERATE);
7719 }
7720 
7721 static int
7722 test_zuc_hash_generate_test_case_7(void)
7723 {
7724 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7725 			RTE_CRYPTO_AUTH_OP_GENERATE);
7726 }
7727 
7728 static int
7729 test_zuc_hash_generate_test_case_8(void)
7730 {
7731 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7732 			RTE_CRYPTO_AUTH_OP_GENERATE);
7733 }
7734 
7735 static int
7736 test_zuc_hash_verify_test_case_1(void)
7737 {
7738 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7739 			RTE_CRYPTO_AUTH_OP_VERIFY);
7740 }
7741 
7742 static int
7743 test_zuc_hash_verify_test_case_2(void)
7744 {
7745 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7746 			RTE_CRYPTO_AUTH_OP_VERIFY);
7747 }
7748 
7749 static int
7750 test_zuc_hash_verify_test_case_3(void)
7751 {
7752 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7753 			RTE_CRYPTO_AUTH_OP_VERIFY);
7754 }
7755 
7756 static int
7757 test_zuc_hash_verify_test_case_4(void)
7758 {
7759 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7760 			RTE_CRYPTO_AUTH_OP_VERIFY);
7761 }
7762 
7763 static int
7764 test_zuc_hash_verify_test_case_5(void)
7765 {
7766 	return test_zuc_authentication(&zuc_test_auth_5670b,
7767 			RTE_CRYPTO_AUTH_OP_VERIFY);
7768 }
7769 
7770 static int
7771 test_zuc_hash_verify_test_case_6(void)
7772 {
7773 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7774 			RTE_CRYPTO_AUTH_OP_VERIFY);
7775 }
7776 
7777 static int
7778 test_zuc_hash_verify_test_case_7(void)
7779 {
7780 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7781 			RTE_CRYPTO_AUTH_OP_VERIFY);
7782 }
7783 
7784 static int
7785 test_zuc_hash_verify_test_case_8(void)
7786 {
7787 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7788 			RTE_CRYPTO_AUTH_OP_VERIFY);
7789 }
7790 
7791 static int
7792 test_zuc_cipher_auth_test_case_1(void)
7793 {
7794 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7795 }
7796 
7797 static int
7798 test_zuc_cipher_auth_test_case_2(void)
7799 {
7800 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7801 }
7802 
7803 static int
7804 test_zuc_auth_cipher_test_case_1(void)
7805 {
7806 	return test_zuc_auth_cipher(
7807 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7808 }
7809 
7810 static int
7811 test_zuc_auth_cipher_test_case_1_oop(void)
7812 {
7813 	return test_zuc_auth_cipher(
7814 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7815 }
7816 
7817 static int
7818 test_zuc_auth_cipher_test_case_1_sgl(void)
7819 {
7820 	return test_zuc_auth_cipher_sgl(
7821 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7822 }
7823 
7824 static int
7825 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7826 {
7827 	return test_zuc_auth_cipher_sgl(
7828 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7829 }
7830 
7831 static int
7832 test_zuc_auth_cipher_test_case_2(void)
7833 {
7834 	return test_zuc_auth_cipher(
7835 		&zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7836 }
7837 
7838 static int
7839 test_zuc_auth_cipher_test_case_2_oop(void)
7840 {
7841 	return test_zuc_auth_cipher(
7842 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7843 }
7844 
7845 static int
7846 test_zuc_auth_cipher_verify_test_case_1(void)
7847 {
7848 	return test_zuc_auth_cipher(
7849 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7850 }
7851 
7852 static int
7853 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7854 {
7855 	return test_zuc_auth_cipher(
7856 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7857 }
7858 
7859 static int
7860 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7861 {
7862 	return test_zuc_auth_cipher_sgl(
7863 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7864 }
7865 
7866 static int
7867 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7868 {
7869 	return test_zuc_auth_cipher_sgl(
7870 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7871 }
7872 
7873 static int
7874 test_zuc_auth_cipher_verify_test_case_2(void)
7875 {
7876 	return test_zuc_auth_cipher(
7877 		&zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7878 }
7879 
7880 static int
7881 test_zuc_auth_cipher_verify_test_case_2_oop(void)
7882 {
7883 	return test_zuc_auth_cipher(
7884 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7885 }
7886 
7887 static int
7888 test_zuc256_encryption_test_case_1(void)
7889 {
7890 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7891 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7892 }
7893 
7894 static int
7895 test_zuc256_encryption_test_case_2(void)
7896 {
7897 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7898 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7899 }
7900 
7901 static int
7902 test_zuc256_decryption_test_case_1(void)
7903 {
7904 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7905 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7906 }
7907 
7908 static int
7909 test_zuc256_decryption_test_case_2(void)
7910 {
7911 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7912 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7913 }
7914 
7915 static int
7916 test_zuc256_hash_generate_4b_tag_test_case_1(void)
7917 {
7918 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7919 			RTE_CRYPTO_AUTH_OP_GENERATE);
7920 }
7921 
7922 static int
7923 test_zuc256_hash_generate_4b_tag_test_case_2(void)
7924 {
7925 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7926 			RTE_CRYPTO_AUTH_OP_GENERATE);
7927 }
7928 
7929 static int
7930 test_zuc256_hash_generate_4b_tag_test_case_3(void)
7931 {
7932 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7933 			RTE_CRYPTO_AUTH_OP_GENERATE);
7934 }
7935 
7936 static int
7937 test_zuc256_hash_generate_8b_tag_test_case_1(void)
7938 {
7939 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7940 			RTE_CRYPTO_AUTH_OP_GENERATE);
7941 }
7942 
7943 static int
7944 test_zuc256_hash_generate_16b_tag_test_case_1(void)
7945 {
7946 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7947 			RTE_CRYPTO_AUTH_OP_GENERATE);
7948 }
7949 
7950 static int
7951 test_zuc256_hash_verify_4b_tag_test_case_1(void)
7952 {
7953 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7954 			RTE_CRYPTO_AUTH_OP_VERIFY);
7955 }
7956 
7957 static int
7958 test_zuc256_hash_verify_4b_tag_test_case_2(void)
7959 {
7960 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7961 			RTE_CRYPTO_AUTH_OP_VERIFY);
7962 }
7963 
7964 static int
7965 test_zuc256_hash_verify_4b_tag_test_case_3(void)
7966 {
7967 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7968 			RTE_CRYPTO_AUTH_OP_VERIFY);
7969 }
7970 
7971 static int
7972 test_zuc256_hash_verify_8b_tag_test_case_1(void)
7973 {
7974 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7975 			RTE_CRYPTO_AUTH_OP_VERIFY);
7976 }
7977 
7978 static int
7979 test_zuc256_hash_verify_16b_tag_test_case_1(void)
7980 {
7981 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7982 			RTE_CRYPTO_AUTH_OP_VERIFY);
7983 }
7984 
7985 static int
7986 test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7987 {
7988 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7989 }
7990 
7991 static int
7992 test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7993 {
7994 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7995 }
7996 
7997 static int
7998 test_zuc256_cipher_auth_8b_tag_test_case_1(void)
7999 {
8000 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8001 }
8002 
8003 static int
8004 test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8005 {
8006 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8007 }
8008 
8009 static int
8010 test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8011 {
8012 	return test_zuc_auth_cipher(
8013 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8014 }
8015 
8016 static int
8017 test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8018 {
8019 	return test_zuc_auth_cipher(
8020 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8021 }
8022 
8023 static int
8024 test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8025 {
8026 	return test_zuc_auth_cipher(
8027 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8028 }
8029 
8030 static int
8031 test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8032 {
8033 	return test_zuc_auth_cipher(
8034 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8035 }
8036 
8037 static int
8038 test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8039 {
8040 	return test_zuc_auth_cipher(
8041 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8042 }
8043 
8044 static int
8045 test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8046 {
8047 	return test_zuc_auth_cipher(
8048 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8049 }
8050 
8051 static int
8052 test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8053 {
8054 	return test_zuc_auth_cipher(
8055 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8056 }
8057 
8058 static int
8059 test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8060 {
8061 	return test_zuc_auth_cipher(
8062 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8063 }
8064 
8065 static int
8066 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8067 {
8068 	uint8_t dev_id = testsuite_params.valid_devs[0];
8069 
8070 	struct rte_cryptodev_sym_capability_idx cap_idx;
8071 
8072 	/* Check if device supports particular cipher algorithm */
8073 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8074 	cap_idx.algo.cipher = tdata->cipher_algo;
8075 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8076 		return TEST_SKIPPED;
8077 
8078 	/* Check if device supports particular hash algorithm */
8079 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8080 	cap_idx.algo.auth = tdata->auth_algo;
8081 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8082 		return TEST_SKIPPED;
8083 
8084 	return 0;
8085 }
8086 
8087 static int
8088 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8089 	uint8_t op_mode, uint8_t verify)
8090 {
8091 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8092 	struct crypto_unittest_params *ut_params = &unittest_params;
8093 
8094 	int retval;
8095 
8096 	uint8_t *plaintext = NULL, *ciphertext = NULL;
8097 	unsigned int plaintext_pad_len;
8098 	unsigned int plaintext_len;
8099 	unsigned int ciphertext_pad_len;
8100 	unsigned int ciphertext_len;
8101 	unsigned int digest_offset;
8102 
8103 	struct rte_cryptodev_info dev_info;
8104 	struct rte_crypto_op *op;
8105 
8106 	/* Check if device supports particular algorithms separately */
8107 	if (test_mixed_check_if_unsupported(tdata))
8108 		return TEST_SKIPPED;
8109 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8110 		return TEST_SKIPPED;
8111 
8112 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8113 		return TEST_SKIPPED;
8114 
8115 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8116 
8117 	uint64_t feat_flags = dev_info.feature_flags;
8118 
8119 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8120 		printf("Device doesn't support digest encrypted.\n");
8121 		return TEST_SKIPPED;
8122 	}
8123 
8124 	/* Create the session */
8125 	if (verify)
8126 		retval = create_wireless_algo_cipher_auth_session(
8127 				ts_params->valid_devs[0],
8128 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8129 				RTE_CRYPTO_AUTH_OP_VERIFY,
8130 				tdata->auth_algo,
8131 				tdata->cipher_algo,
8132 				tdata->auth_key.data, tdata->auth_key.len,
8133 				tdata->cipher_key.data, tdata->cipher_key.len,
8134 				tdata->auth_iv.len, tdata->digest_enc.len,
8135 				tdata->cipher_iv.len);
8136 	else
8137 		retval = create_wireless_algo_auth_cipher_session(
8138 				ts_params->valid_devs[0],
8139 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8140 				RTE_CRYPTO_AUTH_OP_GENERATE,
8141 				tdata->auth_algo,
8142 				tdata->cipher_algo,
8143 				tdata->auth_key.data, tdata->auth_key.len,
8144 				tdata->cipher_key.data, tdata->cipher_key.len,
8145 				tdata->auth_iv.len, tdata->digest_enc.len,
8146 				tdata->cipher_iv.len);
8147 	if (retval != 0)
8148 		return retval;
8149 
8150 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8151 	if (op_mode == OUT_OF_PLACE)
8152 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8153 
8154 	/* clear mbuf payload */
8155 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8156 		rte_pktmbuf_tailroom(ut_params->ibuf));
8157 	if (op_mode == OUT_OF_PLACE) {
8158 
8159 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8160 				rte_pktmbuf_tailroom(ut_params->obuf));
8161 	}
8162 
8163 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8164 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8165 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8166 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8167 
8168 	if (verify) {
8169 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8170 				ciphertext_pad_len);
8171 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8172 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8173 				ciphertext_len);
8174 	} else {
8175 		/* make sure enough space to cover partial digest verify case */
8176 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8177 				ciphertext_pad_len);
8178 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8179 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8180 	}
8181 
8182 	if (op_mode == OUT_OF_PLACE)
8183 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8184 
8185 	/* Create the operation */
8186 	retval = create_wireless_algo_auth_cipher_operation(
8187 			tdata->digest_enc.data, tdata->digest_enc.len,
8188 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8189 			tdata->auth_iv.data, tdata->auth_iv.len,
8190 			(tdata->digest_enc.offset == 0 ?
8191 				plaintext_pad_len
8192 				: tdata->digest_enc.offset),
8193 			tdata->validCipherLen.len_bits,
8194 			tdata->cipher.offset_bits,
8195 			tdata->validAuthLen.len_bits,
8196 			tdata->auth.offset_bits,
8197 			op_mode, 0, verify);
8198 
8199 	if (retval < 0)
8200 		return retval;
8201 
8202 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8203 
8204 	/* Check if the op failed because the device doesn't */
8205 	/* support this particular combination of algorithms */
8206 	if (op == NULL && ut_params->op->status ==
8207 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8208 		printf("Device doesn't support this mixed combination. "
8209 				"Test Skipped.\n");
8210 		return TEST_SKIPPED;
8211 	}
8212 	ut_params->op = op;
8213 
8214 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8215 
8216 	ut_params->obuf = (op_mode == IN_PLACE ?
8217 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8218 
8219 	if (verify) {
8220 		if (ut_params->obuf)
8221 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8222 							uint8_t *);
8223 		else
8224 			plaintext = ciphertext +
8225 					(tdata->cipher.offset_bits >> 3);
8226 
8227 		debug_hexdump(stdout, "plaintext:", plaintext,
8228 				tdata->plaintext.len_bits >> 3);
8229 		debug_hexdump(stdout, "plaintext expected:",
8230 				tdata->plaintext.data,
8231 				tdata->plaintext.len_bits >> 3);
8232 	} else {
8233 		if (ut_params->obuf)
8234 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8235 					uint8_t *);
8236 		else
8237 			ciphertext = plaintext;
8238 
8239 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8240 				ciphertext_len);
8241 		debug_hexdump(stdout, "ciphertext expected:",
8242 				tdata->ciphertext.data,
8243 				tdata->ciphertext.len_bits >> 3);
8244 
8245 		if (tdata->digest_enc.offset == 0)
8246 			digest_offset = plaintext_pad_len;
8247 		else
8248 			digest_offset = tdata->digest_enc.offset;
8249 
8250 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8251 					    uint8_t *, digest_offset);
8252 
8253 		debug_hexdump(stdout, "digest:", ut_params->digest,
8254 				tdata->digest_enc.len);
8255 		debug_hexdump(stdout, "digest expected:",
8256 				tdata->digest_enc.data,
8257 				tdata->digest_enc.len);
8258 	}
8259 
8260 	if (!verify) {
8261 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8262 				ut_params->digest,
8263 				tdata->digest_enc.data,
8264 				tdata->digest_enc.len,
8265 				"Generated auth tag not as expected");
8266 	}
8267 
8268 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8269 		if (verify) {
8270 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8271 					plaintext,
8272 					tdata->plaintext.data,
8273 					tdata->plaintext.len_bits >> 3,
8274 					"Plaintext data not as expected");
8275 		} else {
8276 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8277 					ciphertext,
8278 					tdata->ciphertext.data,
8279 					tdata->validDataLen.len_bits,
8280 					"Ciphertext data not as expected");
8281 		}
8282 	}
8283 
8284 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8285 			"crypto op processing failed");
8286 
8287 	return 0;
8288 }
8289 
8290 static int
8291 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8292 	uint8_t op_mode, uint8_t verify)
8293 {
8294 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8295 	struct crypto_unittest_params *ut_params = &unittest_params;
8296 
8297 	int retval;
8298 
8299 	const uint8_t *plaintext = NULL;
8300 	const uint8_t *ciphertext = NULL;
8301 	const uint8_t *digest = NULL;
8302 	unsigned int plaintext_pad_len;
8303 	unsigned int plaintext_len;
8304 	unsigned int ciphertext_pad_len;
8305 	unsigned int ciphertext_len;
8306 	uint8_t buffer[10000];
8307 	uint8_t digest_buffer[10000];
8308 
8309 	struct rte_cryptodev_info dev_info;
8310 	struct rte_crypto_op *op;
8311 
8312 	/* Check if device supports particular algorithms */
8313 	if (test_mixed_check_if_unsupported(tdata))
8314 		return TEST_SKIPPED;
8315 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8316 		return TEST_SKIPPED;
8317 
8318 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8319 
8320 	uint64_t feat_flags = dev_info.feature_flags;
8321 
8322 	if (op_mode == IN_PLACE) {
8323 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8324 			printf("Device doesn't support in-place scatter-gather "
8325 					"in both input and output mbufs.\n");
8326 			return TEST_SKIPPED;
8327 		}
8328 	} else {
8329 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8330 			printf("Device doesn't support out-of-place scatter-gather "
8331 					"in both input and output mbufs.\n");
8332 			return TEST_SKIPPED;
8333 		}
8334 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8335 			printf("Device doesn't support digest encrypted.\n");
8336 			return TEST_SKIPPED;
8337 		}
8338 	}
8339 
8340 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8341 		return TEST_SKIPPED;
8342 
8343 	/* Create the session */
8344 	if (verify)
8345 		retval = create_wireless_algo_cipher_auth_session(
8346 				ts_params->valid_devs[0],
8347 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8348 				RTE_CRYPTO_AUTH_OP_VERIFY,
8349 				tdata->auth_algo,
8350 				tdata->cipher_algo,
8351 				tdata->auth_key.data, tdata->auth_key.len,
8352 				tdata->cipher_key.data, tdata->cipher_key.len,
8353 				tdata->auth_iv.len, tdata->digest_enc.len,
8354 				tdata->cipher_iv.len);
8355 	else
8356 		retval = create_wireless_algo_auth_cipher_session(
8357 				ts_params->valid_devs[0],
8358 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8359 				RTE_CRYPTO_AUTH_OP_GENERATE,
8360 				tdata->auth_algo,
8361 				tdata->cipher_algo,
8362 				tdata->auth_key.data, tdata->auth_key.len,
8363 				tdata->cipher_key.data, tdata->cipher_key.len,
8364 				tdata->auth_iv.len, tdata->digest_enc.len,
8365 				tdata->cipher_iv.len);
8366 	if (retval != 0)
8367 		return retval;
8368 
8369 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8370 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8371 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8372 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8373 
8374 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8375 			ciphertext_pad_len, 15, 0);
8376 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8377 			"Failed to allocate input buffer in mempool");
8378 
8379 	if (op_mode == OUT_OF_PLACE) {
8380 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8381 				plaintext_pad_len, 15, 0);
8382 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
8383 				"Failed to allocate output buffer in mempool");
8384 	}
8385 
8386 	if (verify) {
8387 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8388 			tdata->ciphertext.data);
8389 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8390 					ciphertext_len, buffer);
8391 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8392 			ciphertext_len);
8393 	} else {
8394 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8395 			tdata->plaintext.data);
8396 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8397 					plaintext_len, buffer);
8398 		debug_hexdump(stdout, "plaintext:", plaintext,
8399 			plaintext_len);
8400 	}
8401 	memset(buffer, 0, sizeof(buffer));
8402 
8403 	/* Create the operation */
8404 	retval = create_wireless_algo_auth_cipher_operation(
8405 			tdata->digest_enc.data, tdata->digest_enc.len,
8406 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8407 			tdata->auth_iv.data, tdata->auth_iv.len,
8408 			(tdata->digest_enc.offset == 0 ?
8409 				plaintext_pad_len
8410 				: tdata->digest_enc.offset),
8411 			tdata->validCipherLen.len_bits,
8412 			tdata->cipher.offset_bits,
8413 			tdata->validAuthLen.len_bits,
8414 			tdata->auth.offset_bits,
8415 			op_mode, 1, verify);
8416 
8417 	if (retval < 0)
8418 		return retval;
8419 
8420 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8421 
8422 	/* Check if the op failed because the device doesn't */
8423 	/* support this particular combination of algorithms */
8424 	if (op == NULL && ut_params->op->status ==
8425 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8426 		printf("Device doesn't support this mixed combination. "
8427 				"Test Skipped.\n");
8428 		return TEST_SKIPPED;
8429 	}
8430 	ut_params->op = op;
8431 
8432 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8433 
8434 	ut_params->obuf = (op_mode == IN_PLACE ?
8435 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8436 
8437 	if (verify) {
8438 		if (ut_params->obuf)
8439 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8440 					plaintext_len, buffer);
8441 		else
8442 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8443 					plaintext_len, buffer);
8444 
8445 		debug_hexdump(stdout, "plaintext:", plaintext,
8446 				(tdata->plaintext.len_bits >> 3) -
8447 				tdata->digest_enc.len);
8448 		debug_hexdump(stdout, "plaintext expected:",
8449 				tdata->plaintext.data,
8450 				(tdata->plaintext.len_bits >> 3) -
8451 				tdata->digest_enc.len);
8452 	} else {
8453 		if (ut_params->obuf)
8454 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8455 					ciphertext_len, buffer);
8456 		else
8457 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8458 					ciphertext_len, buffer);
8459 
8460 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8461 			ciphertext_len);
8462 		debug_hexdump(stdout, "ciphertext expected:",
8463 			tdata->ciphertext.data,
8464 			tdata->ciphertext.len_bits >> 3);
8465 
8466 		if (ut_params->obuf)
8467 			digest = rte_pktmbuf_read(ut_params->obuf,
8468 					(tdata->digest_enc.offset == 0 ?
8469 						plaintext_pad_len :
8470 						tdata->digest_enc.offset),
8471 					tdata->digest_enc.len, digest_buffer);
8472 		else
8473 			digest = rte_pktmbuf_read(ut_params->ibuf,
8474 					(tdata->digest_enc.offset == 0 ?
8475 						plaintext_pad_len :
8476 						tdata->digest_enc.offset),
8477 					tdata->digest_enc.len, digest_buffer);
8478 
8479 		debug_hexdump(stdout, "digest:", digest,
8480 				tdata->digest_enc.len);
8481 		debug_hexdump(stdout, "digest expected:",
8482 				tdata->digest_enc.data, tdata->digest_enc.len);
8483 	}
8484 
8485 	if (!verify) {
8486 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8487 				digest,
8488 				tdata->digest_enc.data,
8489 				tdata->digest_enc.len,
8490 				"Generated auth tag not as expected");
8491 	}
8492 
8493 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8494 		if (verify) {
8495 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8496 					plaintext,
8497 					tdata->plaintext.data,
8498 					tdata->plaintext.len_bits >> 3,
8499 					"Plaintext data not as expected");
8500 		} else {
8501 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8502 					ciphertext,
8503 					tdata->ciphertext.data,
8504 					tdata->validDataLen.len_bits,
8505 					"Ciphertext data not as expected");
8506 		}
8507 	}
8508 
8509 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8510 			"crypto op processing failed");
8511 
8512 	return 0;
8513 }
8514 
8515 /** AUTH AES CMAC + CIPHER AES CTR */
8516 
8517 static int
8518 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8519 {
8520 	return test_mixed_auth_cipher(
8521 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8522 }
8523 
8524 static int
8525 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8526 {
8527 	return test_mixed_auth_cipher(
8528 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8529 }
8530 
8531 static int
8532 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8533 {
8534 	return test_mixed_auth_cipher_sgl(
8535 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8536 }
8537 
8538 static int
8539 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8540 {
8541 	return test_mixed_auth_cipher_sgl(
8542 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8543 }
8544 
8545 static int
8546 test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8547 {
8548 	return test_mixed_auth_cipher(
8549 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8550 }
8551 
8552 static int
8553 test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8554 {
8555 	return test_mixed_auth_cipher(
8556 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8557 }
8558 
8559 static int
8560 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8561 {
8562 	return test_mixed_auth_cipher(
8563 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8564 }
8565 
8566 static int
8567 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8568 {
8569 	return test_mixed_auth_cipher(
8570 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8571 }
8572 
8573 static int
8574 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8575 {
8576 	return test_mixed_auth_cipher(
8577 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8578 }
8579 
8580 static int
8581 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8582 {
8583 	return test_mixed_auth_cipher_sgl(
8584 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8585 }
8586 
8587 static int
8588 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8589 {
8590 	return test_mixed_auth_cipher_sgl(
8591 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8592 }
8593 
8594 static int
8595 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8596 {
8597 	return test_mixed_auth_cipher(
8598 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8599 }
8600 
8601 /** MIXED AUTH + CIPHER */
8602 
8603 static int
8604 test_auth_zuc_cipher_snow_test_case_1(void)
8605 {
8606 	return test_mixed_auth_cipher(
8607 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8608 }
8609 
8610 static int
8611 test_verify_auth_zuc_cipher_snow_test_case_1(void)
8612 {
8613 	return test_mixed_auth_cipher(
8614 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8615 }
8616 
8617 static int
8618 test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8619 {
8620 	return test_mixed_auth_cipher(
8621 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8622 }
8623 
8624 static int
8625 test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8626 {
8627 	return test_mixed_auth_cipher(
8628 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8629 }
8630 
8631 
8632 static int
8633 test_auth_aes_cmac_cipher_snow_test_case_1(void)
8634 {
8635 	return test_mixed_auth_cipher(
8636 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8637 }
8638 
8639 static int
8640 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8641 {
8642 	return test_mixed_auth_cipher(
8643 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8644 }
8645 
8646 static int
8647 test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8648 {
8649 	return test_mixed_auth_cipher(
8650 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8651 }
8652 
8653 static int
8654 test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8655 {
8656 	return test_mixed_auth_cipher(
8657 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8658 }
8659 
8660 static int
8661 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8662 {
8663 	return test_mixed_auth_cipher(
8664 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8665 }
8666 
8667 static int
8668 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8669 {
8670 	return test_mixed_auth_cipher(
8671 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8672 }
8673 
8674 static int
8675 test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8676 {
8677 	return test_mixed_auth_cipher(
8678 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8679 }
8680 
8681 static int
8682 test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8683 {
8684 	return test_mixed_auth_cipher(
8685 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8686 }
8687 
8688 static int
8689 test_auth_snow_cipher_aes_ctr_test_case_1(void)
8690 {
8691 	return test_mixed_auth_cipher(
8692 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8693 }
8694 
8695 static int
8696 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8697 {
8698 	return test_mixed_auth_cipher(
8699 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8700 }
8701 
8702 static int
8703 test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8704 {
8705 	return test_mixed_auth_cipher_sgl(
8706 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8707 }
8708 
8709 static int
8710 test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8711 {
8712 	return test_mixed_auth_cipher(
8713 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8714 }
8715 
8716 static int
8717 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8718 {
8719 	return test_mixed_auth_cipher_sgl(
8720 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8721 }
8722 
8723 static int
8724 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8725 {
8726 	return test_mixed_auth_cipher(
8727 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8728 }
8729 
8730 static int
8731 test_auth_snow_cipher_zuc_test_case_1(void)
8732 {
8733 	return test_mixed_auth_cipher(
8734 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8735 }
8736 
8737 static int
8738 test_verify_auth_snow_cipher_zuc_test_case_1(void)
8739 {
8740 	return test_mixed_auth_cipher(
8741 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8742 }
8743 
8744 static int
8745 test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8746 {
8747 	return test_mixed_auth_cipher(
8748 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8749 }
8750 
8751 static int
8752 test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8753 {
8754 	return test_mixed_auth_cipher(
8755 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8756 }
8757 
8758 static int
8759 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8760 {
8761 	return test_mixed_auth_cipher(
8762 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8763 }
8764 
8765 static int
8766 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8767 {
8768 	return test_mixed_auth_cipher(
8769 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8770 }
8771 static int
8772 test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8773 {
8774 	return test_mixed_auth_cipher(
8775 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8776 }
8777 
8778 static int
8779 test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8780 {
8781 	return test_mixed_auth_cipher(
8782 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8783 }
8784 
8785 static int
8786 test_auth_null_cipher_snow_test_case_1(void)
8787 {
8788 	return test_mixed_auth_cipher(
8789 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8790 }
8791 
8792 static int
8793 test_verify_auth_null_cipher_snow_test_case_1(void)
8794 {
8795 	return test_mixed_auth_cipher(
8796 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8797 }
8798 
8799 static int
8800 test_auth_null_cipher_zuc_test_case_1(void)
8801 {
8802 	return test_mixed_auth_cipher(
8803 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8804 }
8805 
8806 static int
8807 test_verify_auth_null_cipher_zuc_test_case_1(void)
8808 {
8809 	return test_mixed_auth_cipher(
8810 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8811 }
8812 
8813 static int
8814 test_auth_snow_cipher_null_test_case_1(void)
8815 {
8816 	return test_mixed_auth_cipher(
8817 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8818 }
8819 
8820 static int
8821 test_verify_auth_snow_cipher_null_test_case_1(void)
8822 {
8823 	return test_mixed_auth_cipher(
8824 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8825 }
8826 
8827 static int
8828 test_auth_zuc_cipher_null_test_case_1(void)
8829 {
8830 	return test_mixed_auth_cipher(
8831 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8832 }
8833 
8834 static int
8835 test_verify_auth_zuc_cipher_null_test_case_1(void)
8836 {
8837 	return test_mixed_auth_cipher(
8838 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8839 }
8840 
8841 static int
8842 test_auth_null_cipher_aes_ctr_test_case_1(void)
8843 {
8844 	return test_mixed_auth_cipher(
8845 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8846 }
8847 
8848 static int
8849 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8850 {
8851 	return test_mixed_auth_cipher(
8852 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8853 }
8854 
8855 static int
8856 test_auth_aes_cmac_cipher_null_test_case_1(void)
8857 {
8858 	return test_mixed_auth_cipher(
8859 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8860 }
8861 
8862 static int
8863 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8864 {
8865 	return test_mixed_auth_cipher(
8866 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8867 }
8868 
8869 /* ***** AEAD algorithm Tests ***** */
8870 
8871 static int
8872 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8873 		enum rte_crypto_aead_operation op,
8874 		const uint8_t *key, const uint8_t key_len,
8875 		const uint16_t aad_len, const uint8_t auth_len,
8876 		uint8_t iv_len)
8877 {
8878 	uint8_t aead_key[key_len];
8879 
8880 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8881 	struct crypto_unittest_params *ut_params = &unittest_params;
8882 
8883 	memcpy(aead_key, key, key_len);
8884 
8885 	/* Setup AEAD Parameters */
8886 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8887 	ut_params->aead_xform.next = NULL;
8888 	ut_params->aead_xform.aead.algo = algo;
8889 	ut_params->aead_xform.aead.op = op;
8890 	ut_params->aead_xform.aead.key.data = aead_key;
8891 	ut_params->aead_xform.aead.key.length = key_len;
8892 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8893 	ut_params->aead_xform.aead.iv.length = iv_len;
8894 	ut_params->aead_xform.aead.digest_length = auth_len;
8895 	ut_params->aead_xform.aead.aad_length = aad_len;
8896 
8897 	debug_hexdump(stdout, "key:", key, key_len);
8898 
8899 	/* Create Crypto session*/
8900 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8901 			&ut_params->aead_xform, ts_params->session_mpool);
8902 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8903 		return TEST_SKIPPED;
8904 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8905 	return 0;
8906 }
8907 
8908 static int
8909 create_aead_xform(struct rte_crypto_op *op,
8910 		enum rte_crypto_aead_algorithm algo,
8911 		enum rte_crypto_aead_operation aead_op,
8912 		uint8_t *key, const uint8_t key_len,
8913 		const uint8_t aad_len, const uint8_t auth_len,
8914 		uint8_t iv_len)
8915 {
8916 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8917 			"failed to allocate space for crypto transform");
8918 
8919 	struct rte_crypto_sym_op *sym_op = op->sym;
8920 
8921 	/* Setup AEAD Parameters */
8922 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8923 	sym_op->xform->next = NULL;
8924 	sym_op->xform->aead.algo = algo;
8925 	sym_op->xform->aead.op = aead_op;
8926 	sym_op->xform->aead.key.data = key;
8927 	sym_op->xform->aead.key.length = key_len;
8928 	sym_op->xform->aead.iv.offset = IV_OFFSET;
8929 	sym_op->xform->aead.iv.length = iv_len;
8930 	sym_op->xform->aead.digest_length = auth_len;
8931 	sym_op->xform->aead.aad_length = aad_len;
8932 
8933 	debug_hexdump(stdout, "key:", key, key_len);
8934 
8935 	return 0;
8936 }
8937 
8938 static int
8939 create_aead_operation(enum rte_crypto_aead_operation op,
8940 		const struct aead_test_data *tdata)
8941 {
8942 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8943 	struct crypto_unittest_params *ut_params = &unittest_params;
8944 
8945 	uint8_t *plaintext, *ciphertext;
8946 	unsigned int aad_pad_len, plaintext_pad_len;
8947 
8948 	/* Generate Crypto op data structure */
8949 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8950 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8951 	TEST_ASSERT_NOT_NULL(ut_params->op,
8952 			"Failed to allocate symmetric crypto operation struct");
8953 
8954 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8955 
8956 	/* Append aad data */
8957 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8958 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8959 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8960 				aad_pad_len);
8961 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8962 				"no room to append aad");
8963 
8964 		sym_op->aead.aad.phys_addr =
8965 				rte_pktmbuf_iova(ut_params->ibuf);
8966 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
8967 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8968 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8969 			tdata->aad.len);
8970 
8971 		/* Append IV at the end of the crypto operation*/
8972 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8973 				uint8_t *, IV_OFFSET);
8974 
8975 		/* Copy IV 1 byte after the IV pointer, according to the API */
8976 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8977 		debug_hexdump(stdout, "iv:", iv_ptr + 1,
8978 			tdata->iv.len);
8979 	} else {
8980 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8981 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8982 				aad_pad_len);
8983 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8984 				"no room to append aad");
8985 
8986 		sym_op->aead.aad.phys_addr =
8987 				rte_pktmbuf_iova(ut_params->ibuf);
8988 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8989 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8990 			tdata->aad.len);
8991 
8992 		/* Append IV at the end of the crypto operation*/
8993 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8994 				uint8_t *, IV_OFFSET);
8995 
8996 		if (tdata->iv.len == 0) {
8997 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8998 			debug_hexdump(stdout, "iv:", iv_ptr,
8999 				AES_GCM_J0_LENGTH);
9000 		} else {
9001 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9002 			debug_hexdump(stdout, "iv:", iv_ptr,
9003 				tdata->iv.len);
9004 		}
9005 	}
9006 
9007 	/* Append plaintext/ciphertext */
9008 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9009 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9010 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9011 				plaintext_pad_len);
9012 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9013 
9014 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9015 		debug_hexdump(stdout, "plaintext:", plaintext,
9016 				tdata->plaintext.len);
9017 
9018 		if (ut_params->obuf) {
9019 			ciphertext = (uint8_t *)rte_pktmbuf_append(
9020 					ut_params->obuf,
9021 					plaintext_pad_len + aad_pad_len);
9022 			TEST_ASSERT_NOT_NULL(ciphertext,
9023 					"no room to append ciphertext");
9024 
9025 			memset(ciphertext + aad_pad_len, 0,
9026 					tdata->ciphertext.len);
9027 		}
9028 	} else {
9029 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9030 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9031 				plaintext_pad_len);
9032 		TEST_ASSERT_NOT_NULL(ciphertext,
9033 				"no room to append ciphertext");
9034 
9035 		memcpy(ciphertext, tdata->ciphertext.data,
9036 				tdata->ciphertext.len);
9037 		debug_hexdump(stdout, "ciphertext:", ciphertext,
9038 				tdata->ciphertext.len);
9039 
9040 		if (ut_params->obuf) {
9041 			plaintext = (uint8_t *)rte_pktmbuf_append(
9042 					ut_params->obuf,
9043 					plaintext_pad_len + aad_pad_len);
9044 			TEST_ASSERT_NOT_NULL(plaintext,
9045 					"no room to append plaintext");
9046 
9047 			memset(plaintext + aad_pad_len, 0,
9048 					tdata->plaintext.len);
9049 		}
9050 	}
9051 
9052 	/* Append digest data */
9053 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9054 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9055 				ut_params->obuf ? ut_params->obuf :
9056 						ut_params->ibuf,
9057 						tdata->auth_tag.len);
9058 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9059 				"no room to append digest");
9060 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9061 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9062 				ut_params->obuf ? ut_params->obuf :
9063 						ut_params->ibuf,
9064 						plaintext_pad_len +
9065 						aad_pad_len);
9066 	} else {
9067 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9068 				ut_params->ibuf, tdata->auth_tag.len);
9069 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9070 				"no room to append digest");
9071 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9072 				ut_params->ibuf,
9073 				plaintext_pad_len + aad_pad_len);
9074 
9075 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9076 			tdata->auth_tag.len);
9077 		debug_hexdump(stdout, "digest:",
9078 			sym_op->aead.digest.data,
9079 			tdata->auth_tag.len);
9080 	}
9081 
9082 	sym_op->aead.data.length = tdata->plaintext.len;
9083 	sym_op->aead.data.offset = aad_pad_len;
9084 
9085 	return 0;
9086 }
9087 
9088 static int
9089 test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9090 {
9091 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9092 	struct crypto_unittest_params *ut_params = &unittest_params;
9093 
9094 	int retval;
9095 	uint8_t *ciphertext, *auth_tag;
9096 	uint16_t plaintext_pad_len;
9097 	uint32_t i;
9098 	struct rte_cryptodev_info dev_info;
9099 
9100 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9101 	uint64_t feat_flags = dev_info.feature_flags;
9102 
9103 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9104 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9105 		printf("Device doesn't support RAW data-path APIs.\n");
9106 		return TEST_SKIPPED;
9107 	}
9108 
9109 	/* Verify the capabilities */
9110 	struct rte_cryptodev_sym_capability_idx cap_idx;
9111 	const struct rte_cryptodev_symmetric_capability *capability;
9112 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9113 	cap_idx.algo.aead = tdata->algo;
9114 	capability = rte_cryptodev_sym_capability_get(
9115 			ts_params->valid_devs[0], &cap_idx);
9116 	if (capability == NULL)
9117 		return TEST_SKIPPED;
9118 	if (rte_cryptodev_sym_capability_check_aead(
9119 			capability, tdata->key.len, tdata->auth_tag.len,
9120 			tdata->aad.len, tdata->iv.len))
9121 		return TEST_SKIPPED;
9122 
9123 	/* Create AEAD session */
9124 	retval = create_aead_session(ts_params->valid_devs[0],
9125 			tdata->algo,
9126 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9127 			tdata->key.data, tdata->key.len,
9128 			tdata->aad.len, tdata->auth_tag.len,
9129 			tdata->iv.len);
9130 	if (retval != TEST_SUCCESS)
9131 		return retval;
9132 
9133 	if (tdata->aad.len > MBUF_SIZE) {
9134 		if (use_ext_mbuf) {
9135 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9136 							  AEAD_TEXT_MAX_LENGTH,
9137 							  1 /* nb_segs */,
9138 							  NULL);
9139 		} else {
9140 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9141 		}
9142 		/* Populate full size of add data */
9143 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9144 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9145 	} else {
9146 		if (use_ext_mbuf) {
9147 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9148 							  AEAD_TEXT_MAX_LENGTH,
9149 							  1 /* nb_segs */,
9150 							  NULL);
9151 		} else {
9152 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9153 		}
9154 	}
9155 
9156 	/* clear mbuf payload */
9157 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9158 			rte_pktmbuf_tailroom(ut_params->ibuf));
9159 
9160 	/* Create AEAD operation */
9161 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9162 	if (retval < 0)
9163 		return retval;
9164 
9165 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9166 
9167 	ut_params->op->sym->m_src = ut_params->ibuf;
9168 
9169 	/* Process crypto operation */
9170 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9171 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9172 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9173 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9174 					       0);
9175 		if (retval != TEST_SUCCESS)
9176 			return retval;
9177 	} else
9178 		TEST_ASSERT_NOT_NULL(
9179 			process_crypto_request(ts_params->valid_devs[0],
9180 			ut_params->op), "failed to process sym crypto op");
9181 
9182 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9183 			"crypto op processing failed");
9184 
9185 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9186 
9187 	if (ut_params->op->sym->m_dst) {
9188 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9189 				uint8_t *);
9190 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9191 				uint8_t *, plaintext_pad_len);
9192 	} else {
9193 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9194 				uint8_t *,
9195 				ut_params->op->sym->cipher.data.offset);
9196 		auth_tag = ciphertext + plaintext_pad_len;
9197 	}
9198 
9199 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9200 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9201 
9202 	/* Validate obuf */
9203 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9204 			ciphertext,
9205 			tdata->ciphertext.data,
9206 			tdata->ciphertext.len,
9207 			"Ciphertext data not as expected");
9208 
9209 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9210 			auth_tag,
9211 			tdata->auth_tag.data,
9212 			tdata->auth_tag.len,
9213 			"Generated auth tag not as expected");
9214 
9215 	return 0;
9216 
9217 }
9218 
9219 static int
9220 test_authenticated_encryption(const struct aead_test_data *tdata)
9221 {
9222 	return test_authenticated_encryption_helper(tdata, false);
9223 }
9224 
9225 #ifdef RTE_LIB_SECURITY
9226 static int
9227 security_proto_supported(enum rte_security_session_action_type action,
9228 	enum rte_security_session_protocol proto)
9229 {
9230 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9231 
9232 	const struct rte_security_capability *capabilities;
9233 	const struct rte_security_capability *capability;
9234 	uint16_t i = 0;
9235 
9236 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9237 
9238 
9239 	capabilities = rte_security_capabilities_get(ctx);
9240 
9241 	if (capabilities == NULL)
9242 		return -ENOTSUP;
9243 
9244 	while ((capability = &capabilities[i++])->action !=
9245 			RTE_SECURITY_ACTION_TYPE_NONE) {
9246 		if (capability->action == action &&
9247 				capability->protocol == proto)
9248 			return 0;
9249 	}
9250 
9251 	return -ENOTSUP;
9252 }
9253 
9254 /* Basic algorithm run function for async inplace mode.
9255  * Creates a session from input parameters and runs one operation
9256  * on input_vec. Checks the output of the crypto operation against
9257  * output_vec.
9258  */
9259 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9260 			   enum rte_crypto_auth_operation opa,
9261 			   const uint8_t *input_vec, unsigned int input_vec_len,
9262 			   const uint8_t *output_vec,
9263 			   unsigned int output_vec_len,
9264 			   enum rte_crypto_cipher_algorithm cipher_alg,
9265 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
9266 			   enum rte_crypto_auth_algorithm auth_alg,
9267 			   const uint8_t *auth_key, uint32_t auth_key_len,
9268 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
9269 			   uint8_t packet_direction, uint8_t sn_size,
9270 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9271 {
9272 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9273 	struct crypto_unittest_params *ut_params = &unittest_params;
9274 	uint8_t *plaintext;
9275 	int ret = TEST_SUCCESS;
9276 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9277 	struct rte_cryptodev_info dev_info;
9278 	uint64_t feat_flags;
9279 
9280 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9281 	feat_flags = dev_info.feature_flags;
9282 
9283 	/* Verify the capabilities */
9284 	struct rte_security_capability_idx sec_cap_idx;
9285 
9286 	sec_cap_idx.action = ut_params->type;
9287 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9288 	sec_cap_idx.pdcp.domain = domain;
9289 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9290 		return TEST_SKIPPED;
9291 
9292 	/* Generate test mbuf data */
9293 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9294 
9295 	/* clear mbuf payload */
9296 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9297 			rte_pktmbuf_tailroom(ut_params->ibuf));
9298 
9299 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9300 						  input_vec_len);
9301 	memcpy(plaintext, input_vec, input_vec_len);
9302 
9303 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9304 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9305 		printf("Device does not support RAW data-path APIs.\n");
9306 		return TEST_SKIPPED;
9307 	}
9308 	/* Out of place support */
9309 	if (oop) {
9310 		/*
9311 		 * For out-op-place we need to alloc another mbuf
9312 		 */
9313 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9314 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9315 	}
9316 
9317 	/* Setup Cipher Parameters */
9318 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9319 	ut_params->cipher_xform.cipher.algo = cipher_alg;
9320 	ut_params->cipher_xform.cipher.op = opc;
9321 	ut_params->cipher_xform.cipher.key.data = cipher_key;
9322 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9323 	ut_params->cipher_xform.cipher.iv.length =
9324 				packet_direction ? 4 : 0;
9325 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9326 
9327 	/* Setup HMAC Parameters if ICV header is required */
9328 	if (auth_alg != 0) {
9329 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9330 		ut_params->auth_xform.next = NULL;
9331 		ut_params->auth_xform.auth.algo = auth_alg;
9332 		ut_params->auth_xform.auth.op = opa;
9333 		ut_params->auth_xform.auth.key.data = auth_key;
9334 		ut_params->auth_xform.auth.key.length = auth_key_len;
9335 
9336 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9337 	} else {
9338 		ut_params->cipher_xform.next = NULL;
9339 	}
9340 
9341 	struct rte_security_session_conf sess_conf = {
9342 		.action_type = ut_params->type,
9343 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9344 		{.pdcp = {
9345 			.bearer = bearer,
9346 			.domain = domain,
9347 			.pkt_dir = packet_direction,
9348 			.sn_size = sn_size,
9349 			.hfn = packet_direction ? 0 : hfn,
9350 			/**
9351 			 * hfn can be set as pdcp_test_hfn[i]
9352 			 * if hfn_ovrd is not set. Here, PDCP
9353 			 * packet direction is just used to
9354 			 * run half of the cases with session
9355 			 * HFN and other half with per packet
9356 			 * HFN.
9357 			 */
9358 			.hfn_threshold = hfn_threshold,
9359 			.hfn_ovrd = packet_direction ? 1 : 0,
9360 			.sdap_enabled = sdap,
9361 		} },
9362 		.crypto_xform = &ut_params->cipher_xform
9363 	};
9364 
9365 	/* Create security session */
9366 	ut_params->sec_session = rte_security_session_create(ctx,
9367 				&sess_conf, ts_params->session_mpool);
9368 
9369 	if (!ut_params->sec_session) {
9370 		printf("TestCase %s()-%d line %d failed %s: ",
9371 			__func__, i, __LINE__, "Failed to allocate session");
9372 		ret = TEST_FAILED;
9373 		goto on_err;
9374 	}
9375 
9376 	/* Generate crypto op data structure */
9377 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9378 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9379 	if (!ut_params->op) {
9380 		printf("TestCase %s()-%d line %d failed %s: ",
9381 			__func__, i, __LINE__,
9382 			"Failed to allocate symmetric crypto operation struct");
9383 		ret = TEST_FAILED;
9384 		goto on_err;
9385 	}
9386 
9387 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9388 					uint32_t *, IV_OFFSET);
9389 	*per_pkt_hfn = packet_direction ? hfn : 0;
9390 
9391 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9392 
9393 	/* set crypto operation source mbuf */
9394 	ut_params->op->sym->m_src = ut_params->ibuf;
9395 	if (oop)
9396 		ut_params->op->sym->m_dst = ut_params->obuf;
9397 
9398 	/* Process crypto operation */
9399 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9400 		/* filling lengths */
9401 		ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9402 		ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9403 
9404 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9405 		if (ret != TEST_SUCCESS)
9406 			return ret;
9407 	} else {
9408 		ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9409 	}
9410 	if (ut_params->op == NULL) {
9411 		printf("TestCase %s()-%d line %d failed %s: ",
9412 			__func__, i, __LINE__,
9413 			"failed to process sym crypto op");
9414 		ret = TEST_FAILED;
9415 		goto on_err;
9416 	}
9417 
9418 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9419 		printf("TestCase %s()-%d line %d failed %s: ",
9420 			__func__, i, __LINE__, "crypto op processing failed");
9421 		ret = TEST_FAILED;
9422 		goto on_err;
9423 	}
9424 
9425 	/* Validate obuf */
9426 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9427 			uint8_t *);
9428 	if (oop) {
9429 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9430 				uint8_t *);
9431 	}
9432 
9433 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
9434 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9435 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9436 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9437 		ret = TEST_FAILED;
9438 		goto on_err;
9439 	}
9440 
9441 on_err:
9442 	rte_crypto_op_free(ut_params->op);
9443 	ut_params->op = NULL;
9444 
9445 	if (ut_params->sec_session)
9446 		rte_security_session_destroy(ctx, ut_params->sec_session);
9447 	ut_params->sec_session = NULL;
9448 
9449 	rte_pktmbuf_free(ut_params->ibuf);
9450 	ut_params->ibuf = NULL;
9451 	if (oop) {
9452 		rte_pktmbuf_free(ut_params->obuf);
9453 		ut_params->obuf = NULL;
9454 	}
9455 
9456 	return ret;
9457 }
9458 
9459 static int
9460 test_pdcp_proto_SGL(int i, int oop,
9461 	enum rte_crypto_cipher_operation opc,
9462 	enum rte_crypto_auth_operation opa,
9463 	uint8_t *input_vec,
9464 	unsigned int input_vec_len,
9465 	uint8_t *output_vec,
9466 	unsigned int output_vec_len,
9467 	uint32_t fragsz,
9468 	uint32_t fragsz_oop)
9469 {
9470 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9471 	struct crypto_unittest_params *ut_params = &unittest_params;
9472 	uint8_t *plaintext;
9473 	struct rte_mbuf *buf, *buf_oop = NULL;
9474 	int ret = TEST_SUCCESS;
9475 	int to_trn = 0;
9476 	int to_trn_tbl[16];
9477 	int segs = 1;
9478 	unsigned int trn_data = 0;
9479 	struct rte_cryptodev_info dev_info;
9480 	uint64_t feat_flags;
9481 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9482 	struct rte_mbuf *temp_mbuf;
9483 
9484 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9485 	feat_flags = dev_info.feature_flags;
9486 
9487 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9488 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9489 		printf("Device does not support RAW data-path APIs.\n");
9490 		return -ENOTSUP;
9491 	}
9492 	/* Verify the capabilities */
9493 	struct rte_security_capability_idx sec_cap_idx;
9494 
9495 	sec_cap_idx.action = ut_params->type;
9496 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9497 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9498 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9499 		return TEST_SKIPPED;
9500 
9501 	if (fragsz > input_vec_len)
9502 		fragsz = input_vec_len;
9503 
9504 	uint16_t plaintext_len = fragsz;
9505 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9506 
9507 	if (fragsz_oop > output_vec_len)
9508 		frag_size_oop = output_vec_len;
9509 
9510 	int ecx = 0;
9511 	if (input_vec_len % fragsz != 0) {
9512 		if (input_vec_len / fragsz + 1 > 16)
9513 			return 1;
9514 	} else if (input_vec_len / fragsz > 16)
9515 		return 1;
9516 
9517 	/* Out of place support */
9518 	if (oop) {
9519 		/*
9520 		 * For out-op-place we need to alloc another mbuf
9521 		 */
9522 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9523 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9524 		buf_oop = ut_params->obuf;
9525 	}
9526 
9527 	/* Generate test mbuf data */
9528 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9529 
9530 	/* clear mbuf payload */
9531 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9532 			rte_pktmbuf_tailroom(ut_params->ibuf));
9533 
9534 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9535 						  plaintext_len);
9536 	memcpy(plaintext, input_vec, plaintext_len);
9537 	trn_data += plaintext_len;
9538 
9539 	buf = ut_params->ibuf;
9540 
9541 	/*
9542 	 * Loop until no more fragments
9543 	 */
9544 
9545 	while (trn_data < input_vec_len) {
9546 		++segs;
9547 		to_trn = (input_vec_len - trn_data < fragsz) ?
9548 				(input_vec_len - trn_data) : fragsz;
9549 
9550 		to_trn_tbl[ecx++] = to_trn;
9551 
9552 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9553 		buf = buf->next;
9554 
9555 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9556 				rte_pktmbuf_tailroom(buf));
9557 
9558 		/* OOP */
9559 		if (oop && !fragsz_oop) {
9560 			buf_oop->next =
9561 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
9562 			buf_oop = buf_oop->next;
9563 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9564 					0, rte_pktmbuf_tailroom(buf_oop));
9565 			rte_pktmbuf_append(buf_oop, to_trn);
9566 		}
9567 
9568 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9569 				to_trn);
9570 
9571 		memcpy(plaintext, input_vec + trn_data, to_trn);
9572 		trn_data += to_trn;
9573 	}
9574 
9575 	ut_params->ibuf->nb_segs = segs;
9576 
9577 	segs = 1;
9578 	if (fragsz_oop && oop) {
9579 		to_trn = 0;
9580 		ecx = 0;
9581 
9582 		trn_data = frag_size_oop;
9583 		while (trn_data < output_vec_len) {
9584 			++segs;
9585 			to_trn =
9586 				(output_vec_len - trn_data <
9587 						frag_size_oop) ?
9588 				(output_vec_len - trn_data) :
9589 						frag_size_oop;
9590 
9591 			to_trn_tbl[ecx++] = to_trn;
9592 
9593 			buf_oop->next =
9594 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
9595 			buf_oop = buf_oop->next;
9596 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9597 					0, rte_pktmbuf_tailroom(buf_oop));
9598 			rte_pktmbuf_append(buf_oop, to_trn);
9599 
9600 			trn_data += to_trn;
9601 		}
9602 		ut_params->obuf->nb_segs = segs;
9603 	}
9604 
9605 	/* Setup Cipher Parameters */
9606 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9607 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9608 	ut_params->cipher_xform.cipher.op = opc;
9609 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9610 	ut_params->cipher_xform.cipher.key.length =
9611 					pdcp_test_params[i].cipher_key_len;
9612 	ut_params->cipher_xform.cipher.iv.length = 0;
9613 
9614 	/* Setup HMAC Parameters if ICV header is required */
9615 	if (pdcp_test_params[i].auth_alg != 0) {
9616 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9617 		ut_params->auth_xform.next = NULL;
9618 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9619 		ut_params->auth_xform.auth.op = opa;
9620 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9621 		ut_params->auth_xform.auth.key.length =
9622 					pdcp_test_params[i].auth_key_len;
9623 
9624 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9625 	} else {
9626 		ut_params->cipher_xform.next = NULL;
9627 	}
9628 
9629 	struct rte_security_session_conf sess_conf = {
9630 		.action_type = ut_params->type,
9631 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9632 		{.pdcp = {
9633 			.bearer = pdcp_test_bearer[i],
9634 			.domain = pdcp_test_params[i].domain,
9635 			.pkt_dir = pdcp_test_packet_direction[i],
9636 			.sn_size = pdcp_test_data_sn_size[i],
9637 			.hfn = pdcp_test_hfn[i],
9638 			.hfn_threshold = pdcp_test_hfn_threshold[i],
9639 			.hfn_ovrd = 0,
9640 		} },
9641 		.crypto_xform = &ut_params->cipher_xform
9642 	};
9643 
9644 	/* Create security session */
9645 	ut_params->sec_session = rte_security_session_create(ctx,
9646 				&sess_conf, ts_params->session_mpool);
9647 
9648 	if (!ut_params->sec_session) {
9649 		printf("TestCase %s()-%d line %d failed %s: ",
9650 			__func__, i, __LINE__, "Failed to allocate session");
9651 		ret = TEST_FAILED;
9652 		goto on_err;
9653 	}
9654 
9655 	/* Generate crypto op data structure */
9656 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9657 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9658 	if (!ut_params->op) {
9659 		printf("TestCase %s()-%d line %d failed %s: ",
9660 			__func__, i, __LINE__,
9661 			"Failed to allocate symmetric crypto operation struct");
9662 		ret = TEST_FAILED;
9663 		goto on_err;
9664 	}
9665 
9666 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9667 
9668 	/* set crypto operation source mbuf */
9669 	ut_params->op->sym->m_src = ut_params->ibuf;
9670 	if (oop)
9671 		ut_params->op->sym->m_dst = ut_params->obuf;
9672 
9673 	/* Process crypto operation */
9674 	temp_mbuf = ut_params->op->sym->m_src;
9675 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9676 		/* filling lengths */
9677 		while (temp_mbuf) {
9678 			ut_params->op->sym->cipher.data.length
9679 				+= temp_mbuf->pkt_len;
9680 			ut_params->op->sym->auth.data.length
9681 				+= temp_mbuf->pkt_len;
9682 			temp_mbuf = temp_mbuf->next;
9683 		}
9684 
9685 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9686 		if (ret != TEST_SUCCESS)
9687 			return ret;
9688 	} else {
9689 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9690 							ut_params->op);
9691 	}
9692 	if (ut_params->op == NULL) {
9693 		printf("TestCase %s()-%d line %d failed %s: ",
9694 			__func__, i, __LINE__,
9695 			"failed to process sym crypto op");
9696 		ret = TEST_FAILED;
9697 		goto on_err;
9698 	}
9699 
9700 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9701 		printf("TestCase %s()-%d line %d failed %s: ",
9702 			__func__, i, __LINE__, "crypto op processing failed");
9703 		ret = TEST_FAILED;
9704 		goto on_err;
9705 	}
9706 
9707 	/* Validate obuf */
9708 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9709 			uint8_t *);
9710 	if (oop) {
9711 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9712 				uint8_t *);
9713 	}
9714 	if (fragsz_oop)
9715 		fragsz = frag_size_oop;
9716 	if (memcmp(ciphertext, output_vec, fragsz)) {
9717 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9718 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9719 		rte_hexdump(stdout, "reference", output_vec, fragsz);
9720 		ret = TEST_FAILED;
9721 		goto on_err;
9722 	}
9723 
9724 	buf = ut_params->op->sym->m_src->next;
9725 	if (oop)
9726 		buf = ut_params->op->sym->m_dst->next;
9727 
9728 	unsigned int off = fragsz;
9729 
9730 	ecx = 0;
9731 	while (buf) {
9732 		ciphertext = rte_pktmbuf_mtod(buf,
9733 				uint8_t *);
9734 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9735 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9736 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9737 			rte_hexdump(stdout, "reference", output_vec + off,
9738 					to_trn_tbl[ecx]);
9739 			ret = TEST_FAILED;
9740 			goto on_err;
9741 		}
9742 		off += to_trn_tbl[ecx++];
9743 		buf = buf->next;
9744 	}
9745 on_err:
9746 	rte_crypto_op_free(ut_params->op);
9747 	ut_params->op = NULL;
9748 
9749 	if (ut_params->sec_session)
9750 		rte_security_session_destroy(ctx, ut_params->sec_session);
9751 	ut_params->sec_session = NULL;
9752 
9753 	rte_pktmbuf_free(ut_params->ibuf);
9754 	ut_params->ibuf = NULL;
9755 	if (oop) {
9756 		rte_pktmbuf_free(ut_params->obuf);
9757 		ut_params->obuf = NULL;
9758 	}
9759 
9760 	return ret;
9761 }
9762 
9763 int
9764 test_pdcp_proto_cplane_encap(int i)
9765 {
9766 	return test_pdcp_proto(
9767 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9768 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9769 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9770 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9771 		pdcp_test_params[i].cipher_key_len,
9772 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9773 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9774 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9775 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9776 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9777 }
9778 
9779 int
9780 test_pdcp_proto_uplane_encap(int i)
9781 {
9782 	return test_pdcp_proto(
9783 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9784 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9785 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9786 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9787 		pdcp_test_params[i].cipher_key_len,
9788 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9789 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9790 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9791 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9792 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9793 }
9794 
9795 int
9796 test_pdcp_proto_uplane_encap_with_int(int i)
9797 {
9798 	return test_pdcp_proto(
9799 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9800 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9801 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9802 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9803 		pdcp_test_params[i].cipher_key_len,
9804 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9805 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9806 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9807 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9808 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9809 }
9810 
9811 int
9812 test_pdcp_proto_cplane_decap(int i)
9813 {
9814 	return test_pdcp_proto(
9815 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9816 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9817 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9818 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9819 		pdcp_test_params[i].cipher_key_len,
9820 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9821 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9822 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9823 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9824 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9825 }
9826 
9827 int
9828 test_pdcp_proto_uplane_decap(int i)
9829 {
9830 	return test_pdcp_proto(
9831 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9832 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9833 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9834 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9835 		pdcp_test_params[i].cipher_key_len,
9836 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9837 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9838 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9839 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9840 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9841 }
9842 
9843 int
9844 test_pdcp_proto_uplane_decap_with_int(int i)
9845 {
9846 	return test_pdcp_proto(
9847 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9848 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9849 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9850 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9851 		pdcp_test_params[i].cipher_key_len,
9852 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9853 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9854 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9855 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9856 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9857 }
9858 
9859 static int
9860 test_PDCP_PROTO_SGL_in_place_32B(void)
9861 {
9862 	/* i can be used for running any PDCP case
9863 	 * In this case it is uplane 12-bit AES-SNOW DL encap
9864 	 */
9865 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9866 	return test_pdcp_proto_SGL(i, IN_PLACE,
9867 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9868 			RTE_CRYPTO_AUTH_OP_GENERATE,
9869 			pdcp_test_data_in[i],
9870 			pdcp_test_data_in_len[i],
9871 			pdcp_test_data_out[i],
9872 			pdcp_test_data_in_len[i]+4,
9873 			32, 0);
9874 }
9875 static int
9876 test_PDCP_PROTO_SGL_oop_32B_128B(void)
9877 {
9878 	/* i can be used for running any PDCP case
9879 	 * In this case it is uplane 18-bit NULL-NULL DL encap
9880 	 */
9881 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9882 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9883 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9884 			RTE_CRYPTO_AUTH_OP_GENERATE,
9885 			pdcp_test_data_in[i],
9886 			pdcp_test_data_in_len[i],
9887 			pdcp_test_data_out[i],
9888 			pdcp_test_data_in_len[i]+4,
9889 			32, 128);
9890 }
9891 static int
9892 test_PDCP_PROTO_SGL_oop_32B_40B(void)
9893 {
9894 	/* i can be used for running any PDCP case
9895 	 * In this case it is uplane 18-bit AES DL encap
9896 	 */
9897 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9898 			+ DOWNLINK;
9899 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9900 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9901 			RTE_CRYPTO_AUTH_OP_GENERATE,
9902 			pdcp_test_data_in[i],
9903 			pdcp_test_data_in_len[i],
9904 			pdcp_test_data_out[i],
9905 			pdcp_test_data_in_len[i],
9906 			32, 40);
9907 }
9908 static int
9909 test_PDCP_PROTO_SGL_oop_128B_32B(void)
9910 {
9911 	/* i can be used for running any PDCP case
9912 	 * In this case it is cplane 12-bit AES-ZUC DL encap
9913 	 */
9914 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9915 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9916 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9917 			RTE_CRYPTO_AUTH_OP_GENERATE,
9918 			pdcp_test_data_in[i],
9919 			pdcp_test_data_in_len[i],
9920 			pdcp_test_data_out[i],
9921 			pdcp_test_data_in_len[i]+4,
9922 			128, 32);
9923 }
9924 
9925 static int
9926 test_PDCP_SDAP_PROTO_encap_all(void)
9927 {
9928 	int i = 0, size = 0;
9929 	int err, all_err = TEST_SUCCESS;
9930 	const struct pdcp_sdap_test *cur_test;
9931 
9932 	size = RTE_DIM(list_pdcp_sdap_tests);
9933 
9934 	for (i = 0; i < size; i++) {
9935 		cur_test = &list_pdcp_sdap_tests[i];
9936 		err = test_pdcp_proto(
9937 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9938 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9939 			cur_test->in_len, cur_test->data_out,
9940 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9941 			cur_test->param.cipher_alg, cur_test->cipher_key,
9942 			cur_test->param.cipher_key_len,
9943 			cur_test->param.auth_alg,
9944 			cur_test->auth_key, cur_test->param.auth_key_len,
9945 			cur_test->bearer, cur_test->param.domain,
9946 			cur_test->packet_direction, cur_test->sn_size,
9947 			cur_test->hfn,
9948 			cur_test->hfn_threshold, SDAP_ENABLED);
9949 		if (err) {
9950 			printf("\t%d) %s: Encapsulation failed\n",
9951 					cur_test->test_idx,
9952 					cur_test->param.name);
9953 			err = TEST_FAILED;
9954 		} else {
9955 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9956 					cur_test->param.name);
9957 			err = TEST_SUCCESS;
9958 		}
9959 		all_err += err;
9960 	}
9961 
9962 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9963 
9964 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9965 }
9966 
9967 static int
9968 test_PDCP_PROTO_short_mac(void)
9969 {
9970 	int i = 0, size = 0;
9971 	int err, all_err = TEST_SUCCESS;
9972 	const struct pdcp_short_mac_test *cur_test;
9973 
9974 	size = RTE_DIM(list_pdcp_smac_tests);
9975 
9976 	for (i = 0; i < size; i++) {
9977 		cur_test = &list_pdcp_smac_tests[i];
9978 		err = test_pdcp_proto(
9979 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9980 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9981 			cur_test->in_len, cur_test->data_out,
9982 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9983 			RTE_CRYPTO_CIPHER_NULL, NULL,
9984 			0, cur_test->param.auth_alg,
9985 			cur_test->auth_key, cur_test->param.auth_key_len,
9986 			0, cur_test->param.domain, 0, 0,
9987 			0, 0, 0);
9988 		if (err) {
9989 			printf("\t%d) %s: Short MAC test failed\n",
9990 					cur_test->test_idx,
9991 					cur_test->param.name);
9992 			err = TEST_FAILED;
9993 		} else {
9994 			printf("\t%d) %s: Short MAC test PASS\n",
9995 					cur_test->test_idx,
9996 					cur_test->param.name);
9997 			rte_hexdump(stdout, "MAC I",
9998 				    cur_test->data_out + cur_test->in_len + 2,
9999 				    2);
10000 			err = TEST_SUCCESS;
10001 		}
10002 		all_err += err;
10003 	}
10004 
10005 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10006 
10007 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10008 
10009 }
10010 
10011 static int
10012 test_PDCP_SDAP_PROTO_decap_all(void)
10013 {
10014 	int i = 0, size = 0;
10015 	int err, all_err = TEST_SUCCESS;
10016 	const struct pdcp_sdap_test *cur_test;
10017 
10018 	size = RTE_DIM(list_pdcp_sdap_tests);
10019 
10020 	for (i = 0; i < size; i++) {
10021 		cur_test = &list_pdcp_sdap_tests[i];
10022 		err = test_pdcp_proto(
10023 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10024 			RTE_CRYPTO_AUTH_OP_VERIFY,
10025 			cur_test->data_out,
10026 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10027 			cur_test->data_in, cur_test->in_len,
10028 			cur_test->param.cipher_alg,
10029 			cur_test->cipher_key, cur_test->param.cipher_key_len,
10030 			cur_test->param.auth_alg, cur_test->auth_key,
10031 			cur_test->param.auth_key_len, cur_test->bearer,
10032 			cur_test->param.domain, cur_test->packet_direction,
10033 			cur_test->sn_size, cur_test->hfn,
10034 			cur_test->hfn_threshold, SDAP_ENABLED);
10035 		if (err) {
10036 			printf("\t%d) %s: Decapsulation failed\n",
10037 					cur_test->test_idx,
10038 					cur_test->param.name);
10039 			err = TEST_FAILED;
10040 		} else {
10041 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10042 					cur_test->param.name);
10043 			err = TEST_SUCCESS;
10044 		}
10045 		all_err += err;
10046 	}
10047 
10048 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10049 
10050 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10051 }
10052 
10053 static int
10054 test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10055 			       struct crypto_unittest_params *ut_params,
10056 			       struct rte_security_ipsec_xform *ipsec_xform,
10057 			       const struct ipsec_test_data *td,
10058 			       const struct ipsec_test_flags *flags,
10059 			       int pkt_num)
10060 {
10061 	uint8_t dev_id = ts_params->valid_devs[0];
10062 	enum rte_security_ipsec_sa_direction dir;
10063 	int ret;
10064 
10065 	dir = ipsec_xform->direction;
10066 
10067 	/* Generate crypto op data structure */
10068 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10069 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10070 	if (!ut_params->op) {
10071 		printf("Could not allocate crypto op");
10072 		return TEST_FAILED;
10073 	}
10074 
10075 	/* Attach session to operation */
10076 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10077 
10078 	/* Set crypto operation mbufs */
10079 	ut_params->op->sym->m_src = ut_params->ibuf;
10080 	ut_params->op->sym->m_dst = NULL;
10081 
10082 	/* Copy IV in crypto operation when IV generation is disabled */
10083 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10084 	    ipsec_xform->options.iv_gen_disable == 1) {
10085 		uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10086 							uint8_t *,
10087 							IV_OFFSET);
10088 		int len;
10089 
10090 		if (td->aead)
10091 			len = td->xform.aead.aead.iv.length;
10092 		else if (td->aes_gmac)
10093 			len = td->xform.chain.auth.auth.iv.length;
10094 		else
10095 			len = td->xform.chain.cipher.cipher.iv.length;
10096 
10097 		memcpy(iv, td->iv.data, len);
10098 	}
10099 
10100 	/* Process crypto operation */
10101 	process_crypto_request(dev_id, ut_params->op);
10102 
10103 	ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10104 
10105 	rte_crypto_op_free(ut_params->op);
10106 	ut_params->op = NULL;
10107 
10108 	return ret;
10109 }
10110 
10111 static int
10112 test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10113 			  struct crypto_unittest_params *ut_params,
10114 			  void *ctx)
10115 {
10116 	uint64_t timeout, userdata;
10117 	struct rte_ether_hdr *hdr;
10118 	struct rte_mbuf *m;
10119 	void **sec_sess;
10120 	int ret;
10121 
10122 	RTE_SET_USED(ts_params);
10123 
10124 	hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10125 	hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10126 
10127 	ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10128 	ut_params->ibuf->port = 0;
10129 
10130 	sec_sess = &ut_params->sec_session;
10131 	ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10132 
10133 	if (ret != 1)
10134 		return TEST_FAILED;
10135 
10136 	ut_params->ibuf = NULL;
10137 
10138 	/* Add a timeout for 1 s */
10139 	timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10140 
10141 	do {
10142 		/* Get packet from port 0, queue 0 */
10143 		ret = rte_eth_rx_burst(0, 0, &m, 1);
10144 	} while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10145 
10146 	if (ret == 0) {
10147 		printf("Could not receive packets from ethdev\n");
10148 		return TEST_FAILED;
10149 	}
10150 
10151 	if (m == NULL) {
10152 		printf("Received mbuf is NULL\n");
10153 		return TEST_FAILED;
10154 	}
10155 
10156 	ut_params->ibuf = m;
10157 
10158 	if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10159 		printf("Received packet is not Rx security processed\n");
10160 		return TEST_FAILED;
10161 	}
10162 
10163 	if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10164 		printf("Received packet has failed Rx security processing\n");
10165 		return TEST_FAILED;
10166 	}
10167 
10168 	/*
10169 	 * 'ut_params' is set as userdata. Verify that the field is returned
10170 	 * correctly.
10171 	 */
10172 	userdata = *(uint64_t *)rte_security_dynfield(m);
10173 	if (userdata != (uint64_t)ut_params) {
10174 		printf("Userdata retrieved not matching expected\n");
10175 		return TEST_FAILED;
10176 	}
10177 
10178 	/* Trim L2 header */
10179 	rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10180 
10181 	return TEST_SUCCESS;
10182 }
10183 
10184 static int
10185 test_ipsec_proto_process(const struct ipsec_test_data td[],
10186 			 struct ipsec_test_data res_d[],
10187 			 int nb_td,
10188 			 bool silent,
10189 			 const struct ipsec_test_flags *flags)
10190 {
10191 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10192 				0x0000, 0x001a};
10193 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10194 				0xe82c, 0x4887};
10195 	const struct rte_ipv4_hdr *ipv4 =
10196 			(const struct rte_ipv4_hdr *)td[0].output_text.data;
10197 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10198 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10199 	struct crypto_unittest_params *ut_params = &unittest_params;
10200 	struct rte_security_capability_idx sec_cap_idx;
10201 	const struct rte_security_capability *sec_cap;
10202 	struct rte_security_ipsec_xform ipsec_xform;
10203 	uint8_t dev_id = ts_params->valid_devs[0];
10204 	enum rte_security_ipsec_sa_direction dir;
10205 	struct ipsec_test_data *res_d_tmp = NULL;
10206 	uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10207 	int salt_len, i, ret = TEST_SUCCESS;
10208 	void *ctx;
10209 	uint32_t src, dst;
10210 	uint32_t verify;
10211 
10212 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10213 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10214 
10215 	/* Use first test data to create session */
10216 
10217 	/* Copy IPsec xform */
10218 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10219 
10220 	dir = ipsec_xform.direction;
10221 	verify = flags->tunnel_hdr_verify;
10222 
10223 	memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10224 	memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10225 
10226 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10227 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10228 			src += 1;
10229 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10230 			dst += 1;
10231 	}
10232 
10233 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10234 		if (td->ipsec_xform.tunnel.type ==
10235 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10236 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10237 			       sizeof(src));
10238 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10239 			       sizeof(dst));
10240 
10241 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10242 				ipsec_xform.tunnel.ipv4.df = 0;
10243 
10244 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10245 				ipsec_xform.tunnel.ipv4.df = 1;
10246 
10247 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10248 				ipsec_xform.tunnel.ipv4.dscp = 0;
10249 
10250 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10251 				ipsec_xform.tunnel.ipv4.dscp =
10252 						TEST_IPSEC_DSCP_VAL;
10253 
10254 		} else {
10255 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10256 				ipsec_xform.tunnel.ipv6.dscp = 0;
10257 
10258 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10259 				ipsec_xform.tunnel.ipv6.dscp =
10260 						TEST_IPSEC_DSCP_VAL;
10261 
10262 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10263 			       sizeof(v6_src));
10264 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10265 			       sizeof(v6_dst));
10266 		}
10267 	}
10268 
10269 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
10270 
10271 	sec_cap_idx.action = ut_params->type;
10272 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10273 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10274 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10275 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10276 
10277 	if (flags->udp_encap)
10278 		ipsec_xform.options.udp_encap = 1;
10279 
10280 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10281 	if (sec_cap == NULL)
10282 		return TEST_SKIPPED;
10283 
10284 	/* Copy cipher session parameters */
10285 	if (td[0].aead) {
10286 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10287 		       sizeof(ut_params->aead_xform));
10288 		ut_params->aead_xform.aead.key.data = td[0].key.data;
10289 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10290 
10291 		/* Verify crypto capabilities */
10292 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10293 			if (!silent)
10294 				RTE_LOG(INFO, USER1,
10295 					"Crypto capabilities not supported\n");
10296 			return TEST_SKIPPED;
10297 		}
10298 	} else if (td[0].auth_only) {
10299 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10300 		       sizeof(ut_params->auth_xform));
10301 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10302 
10303 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10304 			if (!silent)
10305 				RTE_LOG(INFO, USER1,
10306 					"Auth crypto capabilities not supported\n");
10307 			return TEST_SKIPPED;
10308 		}
10309 	} else {
10310 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10311 		       sizeof(ut_params->cipher_xform));
10312 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10313 		       sizeof(ut_params->auth_xform));
10314 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10315 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10316 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10317 
10318 		/* Verify crypto capabilities */
10319 
10320 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10321 			if (!silent)
10322 				RTE_LOG(INFO, USER1,
10323 					"Cipher crypto capabilities not supported\n");
10324 			return TEST_SKIPPED;
10325 		}
10326 
10327 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10328 			if (!silent)
10329 				RTE_LOG(INFO, USER1,
10330 					"Auth crypto capabilities not supported\n");
10331 			return TEST_SKIPPED;
10332 		}
10333 	}
10334 
10335 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10336 		return TEST_SKIPPED;
10337 
10338 	struct rte_security_session_conf sess_conf = {
10339 		.action_type = ut_params->type,
10340 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10341 	};
10342 
10343 	if (td[0].aead || td[0].aes_gmac) {
10344 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10345 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10346 	}
10347 
10348 	if (td[0].aead) {
10349 		sess_conf.ipsec = ipsec_xform;
10350 		sess_conf.crypto_xform = &ut_params->aead_xform;
10351 	} else if (td[0].auth_only) {
10352 		sess_conf.ipsec = ipsec_xform;
10353 		sess_conf.crypto_xform = &ut_params->auth_xform;
10354 	} else {
10355 		sess_conf.ipsec = ipsec_xform;
10356 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10357 			sess_conf.crypto_xform = &ut_params->cipher_xform;
10358 			ut_params->cipher_xform.next = &ut_params->auth_xform;
10359 		} else {
10360 			sess_conf.crypto_xform = &ut_params->auth_xform;
10361 			ut_params->auth_xform.next = &ut_params->cipher_xform;
10362 		}
10363 	}
10364 
10365 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10366 		sess_conf.userdata = ut_params;
10367 
10368 	/* Create security session */
10369 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10370 					ts_params->session_mpool);
10371 
10372 	if (ut_params->sec_session == NULL)
10373 		return TEST_SKIPPED;
10374 
10375 	for (i = 0; i < nb_td; i++) {
10376 		if (flags->antireplay &&
10377 		    (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10378 			sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10379 			ret = rte_security_session_update(ctx,
10380 				ut_params->sec_session, &sess_conf);
10381 			if (ret) {
10382 				printf("Could not update sequence number in "
10383 				       "session\n");
10384 				return TEST_SKIPPED;
10385 			}
10386 		}
10387 
10388 		/* Copy test data before modification */
10389 		memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10390 		if (test_ipsec_pkt_update(input_text, flags)) {
10391 			ret = TEST_FAILED;
10392 			goto mbuf_free;
10393 		}
10394 
10395 		/* Setup source mbuf payload */
10396 		if (flags->use_ext_mbuf) {
10397 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10398 					td[i].input_text.len, nb_segs, input_text);
10399 		} else {
10400 			ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10401 					td[i].input_text.len, nb_segs, 0);
10402 			pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10403 		}
10404 
10405 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10406 			ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10407 							ctx);
10408 		else
10409 			ret = test_ipsec_proto_crypto_op_enq(ts_params,
10410 							     ut_params,
10411 							     &ipsec_xform,
10412 							     &td[i], flags,
10413 							     i + 1);
10414 
10415 		if (ret != TEST_SUCCESS)
10416 			goto mbuf_free;
10417 
10418 		if (res_d != NULL)
10419 			res_d_tmp = &res_d[i];
10420 
10421 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10422 					      res_d_tmp, silent, flags);
10423 		if (ret != TEST_SUCCESS)
10424 			goto mbuf_free;
10425 
10426 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10427 					      flags, dir);
10428 		if (ret != TEST_SUCCESS)
10429 			goto mbuf_free;
10430 
10431 		rte_pktmbuf_free(ut_params->ibuf);
10432 		ut_params->ibuf = NULL;
10433 	}
10434 
10435 mbuf_free:
10436 	if (flags->use_ext_mbuf)
10437 		ext_mbuf_memzone_free(nb_segs);
10438 
10439 	rte_pktmbuf_free(ut_params->ibuf);
10440 	ut_params->ibuf = NULL;
10441 
10442 	if (ut_params->sec_session)
10443 		rte_security_session_destroy(ctx, ut_params->sec_session);
10444 	ut_params->sec_session = NULL;
10445 
10446 	return ret;
10447 }
10448 
10449 static int
10450 test_ipsec_proto_known_vec(const void *test_data)
10451 {
10452 	struct ipsec_test_data td_outb;
10453 	struct ipsec_test_flags flags;
10454 
10455 	memset(&flags, 0, sizeof(flags));
10456 
10457 	memcpy(&td_outb, test_data, sizeof(td_outb));
10458 
10459 	if (td_outb.aes_gmac || td_outb.aead ||
10460 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10461 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10462 		/* Disable IV gen to be able to test with known vectors */
10463 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10464 	}
10465 
10466 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10467 }
10468 
10469 static int
10470 test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10471 {
10472 	struct ipsec_test_data td_outb;
10473 	struct ipsec_test_flags flags;
10474 
10475 	memset(&flags, 0, sizeof(flags));
10476 	flags.use_ext_mbuf = true;
10477 
10478 	memcpy(&td_outb, test_data, sizeof(td_outb));
10479 
10480 	if (td_outb.aes_gmac || td_outb.aead ||
10481 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10482 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10483 		/* Disable IV gen to be able to test with known vectors */
10484 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10485 	}
10486 
10487 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10488 }
10489 
10490 static int
10491 test_ipsec_proto_known_vec_inb(const void *test_data)
10492 {
10493 	const struct ipsec_test_data *td = test_data;
10494 	struct ipsec_test_flags flags;
10495 	struct ipsec_test_data td_inb;
10496 
10497 	memset(&flags, 0, sizeof(flags));
10498 
10499 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10500 		test_ipsec_td_in_from_out(td, &td_inb);
10501 	else
10502 		memcpy(&td_inb, td, sizeof(td_inb));
10503 
10504 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10505 }
10506 
10507 static int
10508 test_ipsec_proto_known_vec_fragmented(const void *test_data)
10509 {
10510 	struct ipsec_test_data td_outb;
10511 	struct ipsec_test_flags flags;
10512 
10513 	memset(&flags, 0, sizeof(flags));
10514 	flags.fragment = true;
10515 
10516 	memcpy(&td_outb, test_data, sizeof(td_outb));
10517 
10518 	/* Disable IV gen to be able to test with known vectors */
10519 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
10520 
10521 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10522 }
10523 
10524 static int
10525 test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10526 {
10527 	const struct ipsec_test_data *td = test_data;
10528 	struct ipsec_test_flags flags;
10529 	struct ipsec_test_data td_inb;
10530 
10531 	memset(&flags, 0, sizeof(flags));
10532 	flags.rx_inject = true;
10533 
10534 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10535 		test_ipsec_td_in_from_out(td, &td_inb);
10536 	else
10537 		memcpy(&td_inb, td, sizeof(td_inb));
10538 
10539 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10540 }
10541 
10542 static int
10543 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10544 {
10545 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10546 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10547 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10548 	int ret;
10549 
10550 	if (flags->iv_gen ||
10551 	    flags->sa_expiry_pkts_soft ||
10552 	    flags->sa_expiry_pkts_hard)
10553 		nb_pkts = TEST_SEC_PKTS_MAX;
10554 
10555 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10556 		test_ipsec_td_prepare(sec_alg_list[i].param1,
10557 				      sec_alg_list[i].param2,
10558 				      flags,
10559 				      td_outb,
10560 				      nb_pkts);
10561 
10562 		if (!td_outb->aead) {
10563 			enum rte_crypto_cipher_algorithm cipher_alg;
10564 			enum rte_crypto_auth_algorithm auth_alg;
10565 
10566 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10567 			auth_alg = td_outb->xform.chain.auth.auth.algo;
10568 
10569 			if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10570 				continue;
10571 
10572 			/* ICV is not applicable for NULL auth */
10573 			if (flags->icv_corrupt &&
10574 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
10575 				continue;
10576 
10577 			/* IV is not applicable for NULL cipher */
10578 			if (flags->iv_gen &&
10579 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10580 				continue;
10581 		}
10582 
10583 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10584 					       flags);
10585 		if (ret == TEST_SKIPPED)
10586 			continue;
10587 
10588 		if (ret == TEST_FAILED)
10589 			return TEST_FAILED;
10590 
10591 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10592 
10593 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10594 					       flags);
10595 		if (ret == TEST_SKIPPED)
10596 			continue;
10597 
10598 		if (ret == TEST_FAILED)
10599 			return TEST_FAILED;
10600 
10601 		if (flags->display_alg)
10602 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10603 
10604 		pass_cnt++;
10605 	}
10606 
10607 	if (pass_cnt > 0)
10608 		return TEST_SUCCESS;
10609 	else
10610 		return TEST_SKIPPED;
10611 }
10612 
10613 static int
10614 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10615 {
10616 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10617 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10618 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10619 	int ret;
10620 
10621 	for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10622 		test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10623 				      sec_auth_only_alg_list[i].param2,
10624 				      flags,
10625 				      td_outb,
10626 				      nb_pkts);
10627 
10628 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10629 					       flags);
10630 		if (ret == TEST_SKIPPED)
10631 			continue;
10632 
10633 		if (ret == TEST_FAILED)
10634 			return TEST_FAILED;
10635 
10636 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10637 
10638 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10639 					       flags);
10640 		if (ret == TEST_SKIPPED)
10641 			continue;
10642 
10643 		if (ret == TEST_FAILED)
10644 			return TEST_FAILED;
10645 
10646 		if (flags->display_alg)
10647 			test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10648 					     sec_auth_only_alg_list[i].param2);
10649 
10650 		pass_cnt++;
10651 	}
10652 
10653 	if (pass_cnt > 0)
10654 		return TEST_SUCCESS;
10655 	else
10656 		return TEST_SKIPPED;
10657 }
10658 
10659 static int
10660 test_ipsec_proto_display_list(void)
10661 {
10662 	struct ipsec_test_flags flags;
10663 
10664 	memset(&flags, 0, sizeof(flags));
10665 
10666 	flags.display_alg = true;
10667 
10668 	return test_ipsec_proto_all(&flags);
10669 }
10670 
10671 static int
10672 test_ipsec_proto_ah_tunnel_ipv4(void)
10673 {
10674 	struct ipsec_test_flags flags;
10675 
10676 	memset(&flags, 0, sizeof(flags));
10677 
10678 	flags.ah = true;
10679 	flags.display_alg = true;
10680 
10681 	return test_ipsec_ah_proto_all(&flags);
10682 }
10683 
10684 static int
10685 test_ipsec_proto_ah_transport_ipv4(void)
10686 {
10687 	struct ipsec_test_flags flags;
10688 
10689 	memset(&flags, 0, sizeof(flags));
10690 
10691 	flags.ah = true;
10692 	flags.transport = true;
10693 
10694 	return test_ipsec_ah_proto_all(&flags);
10695 }
10696 
10697 static int
10698 test_ipsec_proto_iv_gen(void)
10699 {
10700 	struct ipsec_test_flags flags;
10701 
10702 	memset(&flags, 0, sizeof(flags));
10703 
10704 	flags.iv_gen = true;
10705 
10706 	return test_ipsec_proto_all(&flags);
10707 }
10708 
10709 static int
10710 test_ipsec_proto_sa_exp_pkts_soft(void)
10711 {
10712 	struct ipsec_test_flags flags;
10713 
10714 	memset(&flags, 0, sizeof(flags));
10715 
10716 	flags.sa_expiry_pkts_soft = true;
10717 
10718 	return test_ipsec_proto_all(&flags);
10719 }
10720 
10721 static int
10722 test_ipsec_proto_sa_exp_pkts_hard(void)
10723 {
10724 	struct ipsec_test_flags flags;
10725 
10726 	memset(&flags, 0, sizeof(flags));
10727 
10728 	flags.sa_expiry_pkts_hard = true;
10729 
10730 	return test_ipsec_proto_all(&flags);
10731 }
10732 
10733 static int
10734 test_ipsec_proto_err_icv_corrupt(void)
10735 {
10736 	struct ipsec_test_flags flags;
10737 
10738 	memset(&flags, 0, sizeof(flags));
10739 
10740 	flags.icv_corrupt = true;
10741 
10742 	return test_ipsec_proto_all(&flags);
10743 }
10744 
10745 static int
10746 test_ipsec_proto_udp_encap_custom_ports(void)
10747 {
10748 	struct ipsec_test_flags flags;
10749 
10750 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10751 			RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10752 		return TEST_SKIPPED;
10753 
10754 	memset(&flags, 0, sizeof(flags));
10755 
10756 	flags.udp_encap = true;
10757 	flags.udp_encap_custom_ports = true;
10758 
10759 	return test_ipsec_proto_all(&flags);
10760 }
10761 
10762 static int
10763 test_ipsec_proto_udp_encap(void)
10764 {
10765 	struct ipsec_test_flags flags;
10766 
10767 	memset(&flags, 0, sizeof(flags));
10768 
10769 	flags.udp_encap = true;
10770 
10771 	return test_ipsec_proto_all(&flags);
10772 }
10773 
10774 static int
10775 test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10776 {
10777 	struct ipsec_test_flags flags;
10778 
10779 	memset(&flags, 0, sizeof(flags));
10780 
10781 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10782 
10783 	return test_ipsec_proto_all(&flags);
10784 }
10785 
10786 static int
10787 test_ipsec_proto_tunnel_dst_addr_verify(void)
10788 {
10789 	struct ipsec_test_flags flags;
10790 
10791 	memset(&flags, 0, sizeof(flags));
10792 
10793 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10794 
10795 	return test_ipsec_proto_all(&flags);
10796 }
10797 
10798 static int
10799 test_ipsec_proto_udp_ports_verify(void)
10800 {
10801 	struct ipsec_test_flags flags;
10802 
10803 	memset(&flags, 0, sizeof(flags));
10804 
10805 	flags.udp_encap = true;
10806 	flags.udp_ports_verify = true;
10807 
10808 	return test_ipsec_proto_all(&flags);
10809 }
10810 
10811 static int
10812 test_ipsec_proto_inner_ip_csum(void)
10813 {
10814 	struct ipsec_test_flags flags;
10815 
10816 	memset(&flags, 0, sizeof(flags));
10817 
10818 	flags.ip_csum = true;
10819 
10820 	return test_ipsec_proto_all(&flags);
10821 }
10822 
10823 static int
10824 test_ipsec_proto_inner_l4_csum(void)
10825 {
10826 	struct ipsec_test_flags flags;
10827 
10828 	memset(&flags, 0, sizeof(flags));
10829 
10830 	flags.l4_csum = true;
10831 
10832 	return test_ipsec_proto_all(&flags);
10833 }
10834 
10835 static int
10836 test_ipsec_proto_tunnel_v4_in_v4(void)
10837 {
10838 	struct ipsec_test_flags flags;
10839 
10840 	memset(&flags, 0, sizeof(flags));
10841 
10842 	flags.ipv6 = false;
10843 	flags.tunnel_ipv6 = false;
10844 
10845 	return test_ipsec_proto_all(&flags);
10846 }
10847 
10848 static int
10849 test_ipsec_proto_tunnel_v6_in_v6(void)
10850 {
10851 	struct ipsec_test_flags flags;
10852 
10853 	memset(&flags, 0, sizeof(flags));
10854 
10855 	flags.ipv6 = true;
10856 	flags.tunnel_ipv6 = true;
10857 
10858 	return test_ipsec_proto_all(&flags);
10859 }
10860 
10861 static int
10862 test_ipsec_proto_tunnel_v4_in_v6(void)
10863 {
10864 	struct ipsec_test_flags flags;
10865 
10866 	memset(&flags, 0, sizeof(flags));
10867 
10868 	flags.ipv6 = false;
10869 	flags.tunnel_ipv6 = true;
10870 
10871 	return test_ipsec_proto_all(&flags);
10872 }
10873 
10874 static int
10875 test_ipsec_proto_tunnel_v6_in_v4(void)
10876 {
10877 	struct ipsec_test_flags flags;
10878 
10879 	memset(&flags, 0, sizeof(flags));
10880 
10881 	flags.ipv6 = true;
10882 	flags.tunnel_ipv6 = false;
10883 
10884 	return test_ipsec_proto_all(&flags);
10885 }
10886 
10887 static int
10888 test_ipsec_proto_transport_v4(void)
10889 {
10890 	struct ipsec_test_flags flags;
10891 
10892 	memset(&flags, 0, sizeof(flags));
10893 
10894 	flags.ipv6 = false;
10895 	flags.transport = true;
10896 
10897 	return test_ipsec_proto_all(&flags);
10898 }
10899 
10900 static int
10901 test_ipsec_proto_transport_l4_csum(void)
10902 {
10903 	struct ipsec_test_flags flags = {
10904 		.l4_csum = true,
10905 		.transport = true,
10906 	};
10907 
10908 	return test_ipsec_proto_all(&flags);
10909 }
10910 
10911 static int
10912 test_ipsec_proto_stats(void)
10913 {
10914 	struct ipsec_test_flags flags;
10915 
10916 	memset(&flags, 0, sizeof(flags));
10917 
10918 	flags.stats_success = true;
10919 
10920 	return test_ipsec_proto_all(&flags);
10921 }
10922 
10923 static int
10924 test_ipsec_proto_pkt_fragment(void)
10925 {
10926 	struct ipsec_test_flags flags;
10927 
10928 	memset(&flags, 0, sizeof(flags));
10929 
10930 	flags.fragment = true;
10931 
10932 	return test_ipsec_proto_all(&flags);
10933 
10934 }
10935 
10936 static int
10937 test_ipsec_proto_copy_df_inner_0(void)
10938 {
10939 	struct ipsec_test_flags flags;
10940 
10941 	memset(&flags, 0, sizeof(flags));
10942 
10943 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10944 
10945 	return test_ipsec_proto_all(&flags);
10946 }
10947 
10948 static int
10949 test_ipsec_proto_copy_df_inner_1(void)
10950 {
10951 	struct ipsec_test_flags flags;
10952 
10953 	memset(&flags, 0, sizeof(flags));
10954 
10955 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10956 
10957 	return test_ipsec_proto_all(&flags);
10958 }
10959 
10960 static int
10961 test_ipsec_proto_set_df_0_inner_1(void)
10962 {
10963 	struct ipsec_test_flags flags;
10964 
10965 	memset(&flags, 0, sizeof(flags));
10966 
10967 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10968 
10969 	return test_ipsec_proto_all(&flags);
10970 }
10971 
10972 static int
10973 test_ipsec_proto_set_df_1_inner_0(void)
10974 {
10975 	struct ipsec_test_flags flags;
10976 
10977 	memset(&flags, 0, sizeof(flags));
10978 
10979 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10980 
10981 	return test_ipsec_proto_all(&flags);
10982 }
10983 
10984 static int
10985 test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10986 {
10987 	struct ipsec_test_flags flags;
10988 
10989 	memset(&flags, 0, sizeof(flags));
10990 
10991 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10992 
10993 	return test_ipsec_proto_all(&flags);
10994 }
10995 
10996 static int
10997 test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
10998 {
10999 	struct ipsec_test_flags flags;
11000 
11001 	memset(&flags, 0, sizeof(flags));
11002 
11003 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11004 
11005 	return test_ipsec_proto_all(&flags);
11006 }
11007 
11008 static int
11009 test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11010 {
11011 	struct ipsec_test_flags flags;
11012 
11013 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11014 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11015 		return TEST_SKIPPED;
11016 
11017 	memset(&flags, 0, sizeof(flags));
11018 
11019 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11020 
11021 	return test_ipsec_proto_all(&flags);
11022 }
11023 
11024 static int
11025 test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11026 {
11027 	struct ipsec_test_flags flags;
11028 
11029 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11030 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11031 		return TEST_SKIPPED;
11032 
11033 	memset(&flags, 0, sizeof(flags));
11034 
11035 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11036 
11037 	return test_ipsec_proto_all(&flags);
11038 }
11039 
11040 static int
11041 test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11042 {
11043 	struct ipsec_test_flags flags;
11044 
11045 	memset(&flags, 0, sizeof(flags));
11046 
11047 	flags.ipv6 = true;
11048 	flags.tunnel_ipv6 = true;
11049 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11050 
11051 	return test_ipsec_proto_all(&flags);
11052 }
11053 
11054 static int
11055 test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11056 {
11057 	struct ipsec_test_flags flags;
11058 
11059 	memset(&flags, 0, sizeof(flags));
11060 
11061 	flags.ipv6 = true;
11062 	flags.tunnel_ipv6 = true;
11063 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11064 
11065 	return test_ipsec_proto_all(&flags);
11066 }
11067 
11068 static int
11069 test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11070 {
11071 	struct ipsec_test_flags flags;
11072 
11073 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11074 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11075 		return TEST_SKIPPED;
11076 
11077 	memset(&flags, 0, sizeof(flags));
11078 
11079 	flags.ipv6 = true;
11080 	flags.tunnel_ipv6 = true;
11081 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11082 
11083 	return test_ipsec_proto_all(&flags);
11084 }
11085 
11086 static int
11087 test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11088 {
11089 	struct ipsec_test_flags flags;
11090 
11091 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11092 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11093 		return TEST_SKIPPED;
11094 
11095 	memset(&flags, 0, sizeof(flags));
11096 
11097 	flags.ipv6 = true;
11098 	flags.tunnel_ipv6 = true;
11099 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11100 
11101 	return test_ipsec_proto_all(&flags);
11102 }
11103 
11104 static int
11105 test_ipsec_proto_sgl(void)
11106 {
11107 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11108 	struct rte_cryptodev_info dev_info;
11109 
11110 	struct ipsec_test_flags flags = {
11111 		.nb_segs_in_mbuf = 5
11112 	};
11113 
11114 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11115 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11116 		printf("Device doesn't support in-place scatter-gather. "
11117 				"Test Skipped.\n");
11118 		return TEST_SKIPPED;
11119 	}
11120 
11121 	return test_ipsec_proto_all(&flags);
11122 }
11123 
11124 static int
11125 test_ipsec_proto_sgl_ext_mbuf(void)
11126 {
11127 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11128 	struct rte_cryptodev_info dev_info;
11129 
11130 	struct ipsec_test_flags flags = {
11131 		.nb_segs_in_mbuf = 5,
11132 		.use_ext_mbuf = 1
11133 	};
11134 
11135 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11136 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11137 		printf("Device doesn't support in-place scatter-gather. "
11138 				"Test Skipped.\n");
11139 		return TEST_SKIPPED;
11140 	}
11141 
11142 	return test_ipsec_proto_all(&flags);
11143 }
11144 
11145 static int
11146 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11147 		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11148 		      uint64_t winsz)
11149 {
11150 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11151 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11152 	struct ipsec_test_flags flags;
11153 	uint32_t i = 0, ret = 0;
11154 
11155 	if (nb_pkts == 0)
11156 		return TEST_FAILED;
11157 
11158 	memset(&flags, 0, sizeof(flags));
11159 	flags.antireplay = true;
11160 
11161 	for (i = 0; i < nb_pkts; i++) {
11162 		memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11163 		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11164 		td_outb[i].ipsec_xform.replay_win_sz = winsz;
11165 		td_outb[i].ipsec_xform.options.esn = esn_en;
11166 	}
11167 
11168 	for (i = 0; i < nb_pkts; i++)
11169 		td_outb[i].ipsec_xform.esn.value = esn[i];
11170 
11171 	ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11172 				       &flags);
11173 	if (ret != TEST_SUCCESS)
11174 		return ret;
11175 
11176 	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11177 
11178 	for (i = 0; i < nb_pkts; i++) {
11179 		td_inb[i].ipsec_xform.options.esn = esn_en;
11180 		/* Set antireplay flag for packets to be dropped */
11181 		td_inb[i].ar_packet = replayed_pkt[i];
11182 	}
11183 
11184 	ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11185 				       &flags);
11186 
11187 	return ret;
11188 }
11189 
11190 static int
11191 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11192 {
11193 
11194 	uint32_t nb_pkts = 5;
11195 	bool replayed_pkt[5];
11196 	uint64_t esn[5];
11197 
11198 	/* 1. Advance the TOP of the window to WS * 2 */
11199 	esn[0] = winsz * 2;
11200 	/* 2. Test sequence number within the new window(WS + 1) */
11201 	esn[1] = winsz + 1;
11202 	/* 3. Test sequence number less than the window BOTTOM */
11203 	esn[2] = winsz;
11204 	/* 4. Test sequence number in the middle of the window */
11205 	esn[3] = winsz + (winsz / 2);
11206 	/* 5. Test replay of the packet in the middle of the window */
11207 	esn[4] = winsz + (winsz / 2);
11208 
11209 	replayed_pkt[0] = false;
11210 	replayed_pkt[1] = false;
11211 	replayed_pkt[2] = true;
11212 	replayed_pkt[3] = false;
11213 	replayed_pkt[4] = true;
11214 
11215 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11216 				     false, winsz);
11217 }
11218 
11219 static int
11220 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11221 {
11222 	return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11223 }
11224 
11225 static int
11226 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11227 {
11228 	return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11229 }
11230 
11231 static int
11232 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11233 {
11234 	return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11235 }
11236 
11237 static int
11238 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11239 {
11240 
11241 	uint32_t nb_pkts = 7;
11242 	bool replayed_pkt[7];
11243 	uint64_t esn[7];
11244 
11245 	/* Set the initial sequence number */
11246 	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11247 	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11248 	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11249 	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11250 	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11251 	/* 3. Test with sequence number within window (1<<32 - 1) */
11252 	esn[3] = (uint64_t)((1ULL << 32) - 1);
11253 	/* 4. Test with sequence number within window (1<<32 - 1) */
11254 	esn[4] = (uint64_t)(1ULL << 32);
11255 	/* 5. Test with duplicate sequence number within
11256 	 * new window (1<<32 - 1)
11257 	 */
11258 	esn[5] = (uint64_t)((1ULL << 32) - 1);
11259 	/* 6. Test with duplicate sequence number within new window (1<<32) */
11260 	esn[6] = (uint64_t)(1ULL << 32);
11261 
11262 	replayed_pkt[0] = false;
11263 	replayed_pkt[1] = false;
11264 	replayed_pkt[2] = false;
11265 	replayed_pkt[3] = false;
11266 	replayed_pkt[4] = false;
11267 	replayed_pkt[5] = true;
11268 	replayed_pkt[6] = true;
11269 
11270 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11271 				     true, winsz);
11272 }
11273 
11274 static int
11275 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11276 {
11277 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11278 }
11279 
11280 static int
11281 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11282 {
11283 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11284 }
11285 
11286 static int
11287 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11288 {
11289 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11290 }
11291 
11292 static int
11293 test_PDCP_PROTO_all(void)
11294 {
11295 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11296 	struct crypto_unittest_params *ut_params = &unittest_params;
11297 	struct rte_cryptodev_info dev_info;
11298 	int status;
11299 
11300 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11301 	uint64_t feat_flags = dev_info.feature_flags;
11302 
11303 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11304 		return TEST_SKIPPED;
11305 
11306 	/* Set action type */
11307 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11308 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11309 		gbl_action_type;
11310 
11311 	if (security_proto_supported(ut_params->type,
11312 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
11313 		return TEST_SKIPPED;
11314 
11315 	status = test_PDCP_PROTO_cplane_encap_all();
11316 	status += test_PDCP_PROTO_cplane_decap_all();
11317 	status += test_PDCP_PROTO_uplane_encap_all();
11318 	status += test_PDCP_PROTO_uplane_decap_all();
11319 	status += test_PDCP_PROTO_SGL_in_place_32B();
11320 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
11321 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
11322 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
11323 	status += test_PDCP_SDAP_PROTO_encap_all();
11324 	status += test_PDCP_SDAP_PROTO_decap_all();
11325 	status += test_PDCP_PROTO_short_mac();
11326 
11327 	if (status)
11328 		return TEST_FAILED;
11329 	else
11330 		return TEST_SUCCESS;
11331 }
11332 
11333 static int
11334 test_ipsec_proto_ipv4_ttl_decrement(void)
11335 {
11336 	struct ipsec_test_flags flags = {
11337 		.dec_ttl_or_hop_limit = true
11338 	};
11339 
11340 	return test_ipsec_proto_all(&flags);
11341 }
11342 
11343 static int
11344 test_ipsec_proto_ipv6_hop_limit_decrement(void)
11345 {
11346 	struct ipsec_test_flags flags = {
11347 		.ipv6 = true,
11348 		.dec_ttl_or_hop_limit = true
11349 	};
11350 
11351 	return test_ipsec_proto_all(&flags);
11352 }
11353 
11354 static int
11355 test_docsis_proto_uplink(const void *data)
11356 {
11357 	const struct docsis_test_data *d_td = data;
11358 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11359 	struct crypto_unittest_params *ut_params = &unittest_params;
11360 	uint8_t *plaintext = NULL;
11361 	uint8_t *ciphertext = NULL;
11362 	uint8_t *iv_ptr;
11363 	int32_t cipher_len, crc_len;
11364 	uint32_t crc_data_len;
11365 	int ret = TEST_SUCCESS;
11366 
11367 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11368 
11369 	/* Verify the capabilities */
11370 	struct rte_security_capability_idx sec_cap_idx;
11371 	const struct rte_security_capability *sec_cap;
11372 	const struct rte_cryptodev_capabilities *crypto_cap;
11373 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11374 	int j = 0;
11375 
11376 	/* Set action type */
11377 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11378 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11379 		gbl_action_type;
11380 
11381 	if (security_proto_supported(ut_params->type,
11382 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11383 		return TEST_SKIPPED;
11384 
11385 	sec_cap_idx.action = ut_params->type;
11386 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11387 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11388 
11389 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11390 	if (sec_cap == NULL)
11391 		return TEST_SKIPPED;
11392 
11393 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11394 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11395 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11396 				crypto_cap->sym.xform_type ==
11397 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11398 				crypto_cap->sym.cipher.algo ==
11399 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11400 			sym_cap = &crypto_cap->sym;
11401 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11402 						d_td->key.len,
11403 						d_td->iv.len) == 0)
11404 				break;
11405 		}
11406 	}
11407 
11408 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11409 		return TEST_SKIPPED;
11410 
11411 	/* Setup source mbuf payload */
11412 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11413 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11414 			rte_pktmbuf_tailroom(ut_params->ibuf));
11415 
11416 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11417 			d_td->ciphertext.len);
11418 
11419 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11420 
11421 	/* Setup cipher session parameters */
11422 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11423 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11424 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11425 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11426 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11427 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11428 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11429 	ut_params->cipher_xform.next = NULL;
11430 
11431 	/* Setup DOCSIS session parameters */
11432 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11433 
11434 	struct rte_security_session_conf sess_conf = {
11435 		.action_type = ut_params->type,
11436 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11437 		.docsis = ut_params->docsis_xform,
11438 		.crypto_xform = &ut_params->cipher_xform,
11439 	};
11440 
11441 	/* Create security session */
11442 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11443 					ts_params->session_mpool);
11444 
11445 	if (!ut_params->sec_session) {
11446 		printf("Test function %s line %u: failed to allocate session\n",
11447 			__func__, __LINE__);
11448 		ret = TEST_FAILED;
11449 		goto on_err;
11450 	}
11451 
11452 	/* Generate crypto op data structure */
11453 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11454 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11455 	if (!ut_params->op) {
11456 		printf("Test function %s line %u: failed to allocate symmetric "
11457 			"crypto operation\n", __func__, __LINE__);
11458 		ret = TEST_FAILED;
11459 		goto on_err;
11460 	}
11461 
11462 	/* Setup CRC operation parameters */
11463 	crc_len = d_td->ciphertext.no_crc == false ?
11464 			(d_td->ciphertext.len -
11465 				d_td->ciphertext.crc_offset -
11466 				RTE_ETHER_CRC_LEN) :
11467 			0;
11468 	crc_len = crc_len > 0 ? crc_len : 0;
11469 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11470 	ut_params->op->sym->auth.data.length = crc_len;
11471 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11472 
11473 	/* Setup cipher operation parameters */
11474 	cipher_len = d_td->ciphertext.no_cipher == false ?
11475 			(d_td->ciphertext.len -
11476 				d_td->ciphertext.cipher_offset) :
11477 			0;
11478 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11479 	ut_params->op->sym->cipher.data.length = cipher_len;
11480 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11481 
11482 	/* Setup cipher IV */
11483 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11484 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11485 
11486 	/* Attach session to operation */
11487 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11488 
11489 	/* Set crypto operation mbufs */
11490 	ut_params->op->sym->m_src = ut_params->ibuf;
11491 	ut_params->op->sym->m_dst = NULL;
11492 
11493 	/* Process crypto operation */
11494 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11495 			NULL) {
11496 		printf("Test function %s line %u: failed to process security "
11497 			"crypto op\n", __func__, __LINE__);
11498 		ret = TEST_FAILED;
11499 		goto on_err;
11500 	}
11501 
11502 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11503 		printf("Test function %s line %u: failed to process crypto op\n",
11504 			__func__, __LINE__);
11505 		ret = TEST_FAILED;
11506 		goto on_err;
11507 	}
11508 
11509 	/* Validate plaintext */
11510 	plaintext = ciphertext;
11511 
11512 	if (memcmp(plaintext, d_td->plaintext.data,
11513 			d_td->plaintext.len - crc_data_len)) {
11514 		printf("Test function %s line %u: plaintext not as expected\n",
11515 			__func__, __LINE__);
11516 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
11517 				d_td->plaintext.len);
11518 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11519 		ret = TEST_FAILED;
11520 		goto on_err;
11521 	}
11522 
11523 on_err:
11524 	rte_crypto_op_free(ut_params->op);
11525 	ut_params->op = NULL;
11526 
11527 	if (ut_params->sec_session)
11528 		rte_security_session_destroy(ctx, ut_params->sec_session);
11529 	ut_params->sec_session = NULL;
11530 
11531 	rte_pktmbuf_free(ut_params->ibuf);
11532 	ut_params->ibuf = NULL;
11533 
11534 	return ret;
11535 }
11536 
11537 static int
11538 test_docsis_proto_downlink(const void *data)
11539 {
11540 	const struct docsis_test_data *d_td = data;
11541 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11542 	struct crypto_unittest_params *ut_params = &unittest_params;
11543 	uint8_t *plaintext = NULL;
11544 	uint8_t *ciphertext = NULL;
11545 	uint8_t *iv_ptr;
11546 	int32_t cipher_len, crc_len;
11547 	int ret = TEST_SUCCESS;
11548 
11549 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11550 
11551 	/* Verify the capabilities */
11552 	struct rte_security_capability_idx sec_cap_idx;
11553 	const struct rte_security_capability *sec_cap;
11554 	const struct rte_cryptodev_capabilities *crypto_cap;
11555 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11556 	int j = 0;
11557 
11558 	/* Set action type */
11559 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11560 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11561 		gbl_action_type;
11562 
11563 	if (security_proto_supported(ut_params->type,
11564 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11565 		return TEST_SKIPPED;
11566 
11567 	sec_cap_idx.action = ut_params->type;
11568 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11569 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11570 
11571 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11572 	if (sec_cap == NULL)
11573 		return TEST_SKIPPED;
11574 
11575 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11576 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11577 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11578 				crypto_cap->sym.xform_type ==
11579 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11580 				crypto_cap->sym.cipher.algo ==
11581 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11582 			sym_cap = &crypto_cap->sym;
11583 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11584 						d_td->key.len,
11585 						d_td->iv.len) == 0)
11586 				break;
11587 		}
11588 	}
11589 
11590 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11591 		return TEST_SKIPPED;
11592 
11593 	/* Setup source mbuf payload */
11594 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11595 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11596 			rte_pktmbuf_tailroom(ut_params->ibuf));
11597 
11598 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11599 			d_td->plaintext.len);
11600 
11601 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11602 
11603 	/* Setup cipher session parameters */
11604 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11605 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11606 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11607 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11608 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11609 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11610 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11611 	ut_params->cipher_xform.next = NULL;
11612 
11613 	/* Setup DOCSIS session parameters */
11614 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11615 
11616 	struct rte_security_session_conf sess_conf = {
11617 		.action_type = ut_params->type,
11618 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11619 		.docsis = ut_params->docsis_xform,
11620 		.crypto_xform = &ut_params->cipher_xform,
11621 	};
11622 
11623 	/* Create security session */
11624 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11625 					ts_params->session_mpool);
11626 
11627 	if (!ut_params->sec_session) {
11628 		printf("Test function %s line %u: failed to allocate session\n",
11629 			__func__, __LINE__);
11630 		ret = TEST_FAILED;
11631 		goto on_err;
11632 	}
11633 
11634 	/* Generate crypto op data structure */
11635 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11636 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11637 	if (!ut_params->op) {
11638 		printf("Test function %s line %u: failed to allocate symmetric "
11639 			"crypto operation\n", __func__, __LINE__);
11640 		ret = TEST_FAILED;
11641 		goto on_err;
11642 	}
11643 
11644 	/* Setup CRC operation parameters */
11645 	crc_len = d_td->plaintext.no_crc == false ?
11646 			(d_td->plaintext.len -
11647 				d_td->plaintext.crc_offset -
11648 				RTE_ETHER_CRC_LEN) :
11649 			0;
11650 	crc_len = crc_len > 0 ? crc_len : 0;
11651 	ut_params->op->sym->auth.data.length = crc_len;
11652 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11653 
11654 	/* Setup cipher operation parameters */
11655 	cipher_len = d_td->plaintext.no_cipher == false ?
11656 			(d_td->plaintext.len -
11657 				d_td->plaintext.cipher_offset) :
11658 			0;
11659 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11660 	ut_params->op->sym->cipher.data.length = cipher_len;
11661 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11662 
11663 	/* Setup cipher IV */
11664 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11665 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11666 
11667 	/* Attach session to operation */
11668 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11669 
11670 	/* Set crypto operation mbufs */
11671 	ut_params->op->sym->m_src = ut_params->ibuf;
11672 	ut_params->op->sym->m_dst = NULL;
11673 
11674 	/* Process crypto operation */
11675 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11676 			NULL) {
11677 		printf("Test function %s line %u: failed to process crypto op\n",
11678 			__func__, __LINE__);
11679 		ret = TEST_FAILED;
11680 		goto on_err;
11681 	}
11682 
11683 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11684 		printf("Test function %s line %u: crypto op processing failed\n",
11685 			__func__, __LINE__);
11686 		ret = TEST_FAILED;
11687 		goto on_err;
11688 	}
11689 
11690 	/* Validate ciphertext */
11691 	ciphertext = plaintext;
11692 
11693 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11694 		printf("Test function %s line %u: plaintext not as expected\n",
11695 			__func__, __LINE__);
11696 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11697 				d_td->ciphertext.len);
11698 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11699 		ret = TEST_FAILED;
11700 		goto on_err;
11701 	}
11702 
11703 on_err:
11704 	rte_crypto_op_free(ut_params->op);
11705 	ut_params->op = NULL;
11706 
11707 	if (ut_params->sec_session)
11708 		rte_security_session_destroy(ctx, ut_params->sec_session);
11709 	ut_params->sec_session = NULL;
11710 
11711 	rte_pktmbuf_free(ut_params->ibuf);
11712 	ut_params->ibuf = NULL;
11713 
11714 	return ret;
11715 }
11716 
11717 static void
11718 test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11719 				 struct rte_security_tls_record_xform *tls_record_xform)
11720 {
11721 	unsigned int imp_nonce_len;
11722 	uint8_t *imp_nonce;
11723 
11724 	switch (tls_record_xform->ver) {
11725 	case RTE_SECURITY_VERSION_TLS_1_2:
11726 		imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11727 		imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11728 		break;
11729 	case RTE_SECURITY_VERSION_DTLS_1_2:
11730 		imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11731 		imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11732 		break;
11733 	case RTE_SECURITY_VERSION_TLS_1_3:
11734 		imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11735 		imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11736 		break;
11737 	default:
11738 		return;
11739 	}
11740 
11741 	imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11742 	memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11743 }
11744 
11745 static int
11746 test_tls_record_proto_process(const struct tls_record_test_data td[],
11747 			      struct tls_record_test_data res_d[], int nb_td, bool silent,
11748 			      const struct tls_record_test_flags *flags)
11749 {
11750 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11751 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11752 	struct crypto_unittest_params *ut_params = &unittest_params;
11753 	struct rte_security_tls_record_xform tls_record_xform;
11754 	struct rte_security_capability_idx sec_cap_idx;
11755 	const struct rte_security_capability *sec_cap;
11756 	struct tls_record_test_data *res_d_tmp = NULL;
11757 	enum rte_security_tls_sess_type sess_type;
11758 	uint8_t dev_id = ts_params->valid_devs[0];
11759 	struct rte_security_ctx *ctx;
11760 	int i, ret = TEST_SUCCESS;
11761 
11762 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11763 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11764 
11765 	/* Use first test data to create session */
11766 
11767 	/* Copy TLS record xform */
11768 	memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11769 
11770 	sess_type = tls_record_xform.type;
11771 
11772 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
11773 
11774 	sec_cap_idx.action = ut_params->type;
11775 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11776 	sec_cap_idx.tls_record.type = tls_record_xform.type;
11777 	sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11778 
11779 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11780 	if (sec_cap == NULL)
11781 		return TEST_SKIPPED;
11782 
11783 	/* Copy cipher session parameters */
11784 	if (td[0].aead) {
11785 		memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11786 		ut_params->aead_xform.aead.key.data = td[0].key.data;
11787 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11788 
11789 		/* Verify crypto capabilities */
11790 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11791 			if (!silent)
11792 				RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11793 			return TEST_SKIPPED;
11794 		}
11795 	} else {
11796 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
11797 		       sizeof(ut_params->cipher_xform));
11798 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
11799 		       sizeof(ut_params->auth_xform));
11800 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
11801 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11802 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
11803 
11804 		/* Verify crypto capabilities */
11805 
11806 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
11807 			if (!silent)
11808 				RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
11809 			return TEST_SKIPPED;
11810 		}
11811 
11812 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
11813 			if (!silent)
11814 				RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
11815 			return TEST_SKIPPED;
11816 		}
11817 	}
11818 
11819 	if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
11820 		return TEST_SKIPPED;
11821 
11822 	struct rte_security_session_conf sess_conf = {
11823 		.action_type = ut_params->type,
11824 		.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
11825 	};
11826 
11827 	if (td[0].aead)
11828 		test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
11829 
11830 	sess_conf.tls_record = tls_record_xform;
11831 
11832 	if (td[0].aead) {
11833 		sess_conf.crypto_xform = &ut_params->aead_xform;
11834 	} else {
11835 		if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
11836 			sess_conf.crypto_xform = &ut_params->cipher_xform;
11837 			ut_params->cipher_xform.next = &ut_params->auth_xform;
11838 		} else {
11839 			sess_conf.crypto_xform = &ut_params->auth_xform;
11840 			ut_params->auth_xform.next = &ut_params->cipher_xform;
11841 		}
11842 	}
11843 
11844 	/* Create security session */
11845 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11846 					ts_params->session_mpool);
11847 	if (ut_params->sec_session == NULL)
11848 		return TEST_SKIPPED;
11849 
11850 	for (i = 0; i < nb_td; i++) {
11851 		/* Setup source mbuf payload */
11852 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, td[i].input_text.len,
11853 				nb_segs, 0);
11854 		pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
11855 
11856 		/* Generate crypto op data structure */
11857 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11858 						    RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11859 		if (ut_params->op == NULL) {
11860 			printf("Could not allocate crypto op");
11861 			ret = TEST_FAILED;
11862 			goto crypto_op_free;
11863 		}
11864 
11865 		/* Attach session to operation */
11866 		rte_security_attach_session(ut_params->op, ut_params->sec_session);
11867 
11868 		/* Set crypto operation mbufs */
11869 		ut_params->op->sym->m_src = ut_params->ibuf;
11870 		ut_params->op->sym->m_dst = NULL;
11871 		ut_params->op->param1.tls_record.content_type = td[i].app_type;
11872 
11873 		/* Copy IV in crypto operation when IV generation is disabled */
11874 		if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE &&
11875 		    tls_record_xform.options.iv_gen_disable == 1) {
11876 			uint8_t *iv;
11877 			int len;
11878 
11879 			iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
11880 			if (td[i].aead)
11881 				len = td[i].xform.aead.aead.iv.length - 4;
11882 			else
11883 				len = td[i].xform.chain.cipher.cipher.iv.length;
11884 			memcpy(iv, td[i].iv.data, len);
11885 		}
11886 
11887 		/* Process crypto operation */
11888 		process_crypto_request(dev_id, ut_params->op);
11889 
11890 		ret = test_tls_record_status_check(ut_params->op);
11891 		if (ret != TEST_SUCCESS)
11892 			goto crypto_op_free;
11893 
11894 		if (res_d != NULL)
11895 			res_d_tmp = &res_d[i];
11896 
11897 		ret = test_tls_record_post_process(ut_params->ibuf, &td[i], res_d_tmp, silent);
11898 		if (ret != TEST_SUCCESS)
11899 			goto crypto_op_free;
11900 
11901 
11902 		rte_crypto_op_free(ut_params->op);
11903 		ut_params->op = NULL;
11904 
11905 		rte_pktmbuf_free(ut_params->ibuf);
11906 		ut_params->ibuf = NULL;
11907 	}
11908 
11909 crypto_op_free:
11910 	rte_crypto_op_free(ut_params->op);
11911 	ut_params->op = NULL;
11912 
11913 	rte_pktmbuf_free(ut_params->ibuf);
11914 	ut_params->ibuf = NULL;
11915 
11916 	if (ut_params->sec_session)
11917 		rte_security_session_destroy(ctx, ut_params->sec_session);
11918 	ut_params->sec_session = NULL;
11919 
11920 	RTE_SET_USED(flags);
11921 
11922 	return ret;
11923 }
11924 
11925 static int
11926 test_tls_record_proto_known_vec(const void *test_data)
11927 {
11928 	struct tls_record_test_data td_write;
11929 	struct tls_record_test_flags flags;
11930 
11931 	memset(&flags, 0, sizeof(flags));
11932 
11933 	memcpy(&td_write, test_data, sizeof(td_write));
11934 
11935 	/* Disable IV gen to be able to test with known vectors */
11936 	td_write.tls_record_xform.options.iv_gen_disable = 1;
11937 
11938 	return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
11939 }
11940 
11941 static int
11942 test_tls_record_proto_known_vec_read(const void *test_data)
11943 {
11944 	const struct tls_record_test_data *td = test_data;
11945 	struct tls_record_test_flags flags;
11946 	struct tls_record_test_data td_inb;
11947 
11948 	memset(&flags, 0, sizeof(flags));
11949 
11950 	if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
11951 		test_tls_record_td_read_from_write(td, &td_inb);
11952 	else
11953 		memcpy(&td_inb, td, sizeof(td_inb));
11954 
11955 	return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
11956 }
11957 
11958 static int
11959 test_tls_record_proto_all(const struct tls_record_test_flags *flags)
11960 {
11961 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
11962 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
11963 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
11964 	int ret;
11965 
11966 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
11967 		test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2, flags,
11968 					   td_outb, nb_pkts);
11969 
11970 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
11971 		if (ret == TEST_SKIPPED)
11972 			continue;
11973 
11974 		if (ret == TEST_FAILED)
11975 			return TEST_FAILED;
11976 
11977 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
11978 
11979 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
11980 		if (ret == TEST_SKIPPED)
11981 			continue;
11982 
11983 		if (ret == TEST_FAILED)
11984 			return TEST_FAILED;
11985 
11986 		if (flags->display_alg)
11987 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
11988 
11989 		pass_cnt++;
11990 	}
11991 
11992 	if (pass_cnt > 0)
11993 		return TEST_SUCCESS;
11994 	else
11995 		return TEST_SKIPPED;
11996 }
11997 
11998 static int
11999 test_tls_record_proto_display_list(void)
12000 {
12001 	struct tls_record_test_flags flags;
12002 
12003 	memset(&flags, 0, sizeof(flags));
12004 
12005 	flags.display_alg = true;
12006 
12007 	return test_tls_record_proto_all(&flags);
12008 }
12009 
12010 static int
12011 test_tls_record_proto_sgl(void)
12012 {
12013 	struct tls_record_test_flags flags = {
12014 		.nb_segs_in_mbuf = 5
12015 	};
12016 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12017 	struct rte_cryptodev_info dev_info;
12018 
12019 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12020 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12021 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12022 		return TEST_SKIPPED;
12023 	}
12024 
12025 	return test_tls_record_proto_all(&flags);
12026 }
12027 
12028 #endif
12029 
12030 static int
12031 test_AES_GCM_authenticated_encryption_test_case_1(void)
12032 {
12033 	return test_authenticated_encryption(&gcm_test_case_1);
12034 }
12035 
12036 static int
12037 test_AES_GCM_authenticated_encryption_test_case_2(void)
12038 {
12039 	return test_authenticated_encryption(&gcm_test_case_2);
12040 }
12041 
12042 static int
12043 test_AES_GCM_authenticated_encryption_test_case_3(void)
12044 {
12045 	return test_authenticated_encryption(&gcm_test_case_3);
12046 }
12047 
12048 static int
12049 test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
12050 {
12051 	return test_authenticated_encryption_helper(&gcm_test_case_3, true);
12052 }
12053 
12054 static int
12055 test_AES_GCM_authenticated_encryption_test_case_4(void)
12056 {
12057 	return test_authenticated_encryption(&gcm_test_case_4);
12058 }
12059 
12060 static int
12061 test_AES_GCM_authenticated_encryption_test_case_5(void)
12062 {
12063 	return test_authenticated_encryption(&gcm_test_case_5);
12064 }
12065 
12066 static int
12067 test_AES_GCM_authenticated_encryption_test_case_6(void)
12068 {
12069 	return test_authenticated_encryption(&gcm_test_case_6);
12070 }
12071 
12072 static int
12073 test_AES_GCM_authenticated_encryption_test_case_7(void)
12074 {
12075 	return test_authenticated_encryption(&gcm_test_case_7);
12076 }
12077 
12078 static int
12079 test_AES_GCM_authenticated_encryption_test_case_8(void)
12080 {
12081 	return test_authenticated_encryption(&gcm_test_case_8);
12082 }
12083 
12084 static int
12085 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
12086 {
12087 	return test_authenticated_encryption(&gcm_J0_test_case_1);
12088 }
12089 
12090 static int
12091 test_AES_GCM_auth_encryption_test_case_192_1(void)
12092 {
12093 	return test_authenticated_encryption(&gcm_test_case_192_1);
12094 }
12095 
12096 static int
12097 test_AES_GCM_auth_encryption_test_case_192_2(void)
12098 {
12099 	return test_authenticated_encryption(&gcm_test_case_192_2);
12100 }
12101 
12102 static int
12103 test_AES_GCM_auth_encryption_test_case_192_3(void)
12104 {
12105 	return test_authenticated_encryption(&gcm_test_case_192_3);
12106 }
12107 
12108 static int
12109 test_AES_GCM_auth_encryption_test_case_192_4(void)
12110 {
12111 	return test_authenticated_encryption(&gcm_test_case_192_4);
12112 }
12113 
12114 static int
12115 test_AES_GCM_auth_encryption_test_case_192_5(void)
12116 {
12117 	return test_authenticated_encryption(&gcm_test_case_192_5);
12118 }
12119 
12120 static int
12121 test_AES_GCM_auth_encryption_test_case_192_6(void)
12122 {
12123 	return test_authenticated_encryption(&gcm_test_case_192_6);
12124 }
12125 
12126 static int
12127 test_AES_GCM_auth_encryption_test_case_192_7(void)
12128 {
12129 	return test_authenticated_encryption(&gcm_test_case_192_7);
12130 }
12131 
12132 static int
12133 test_AES_GCM_auth_encryption_test_case_256_1(void)
12134 {
12135 	return test_authenticated_encryption(&gcm_test_case_256_1);
12136 }
12137 
12138 static int
12139 test_AES_GCM_auth_encryption_test_case_256_2(void)
12140 {
12141 	return test_authenticated_encryption(&gcm_test_case_256_2);
12142 }
12143 
12144 static int
12145 test_AES_GCM_auth_encryption_test_case_256_3(void)
12146 {
12147 	return test_authenticated_encryption(&gcm_test_case_256_3);
12148 }
12149 
12150 static int
12151 test_AES_GCM_auth_encryption_test_case_256_4(void)
12152 {
12153 	return test_authenticated_encryption(&gcm_test_case_256_4);
12154 }
12155 
12156 static int
12157 test_AES_GCM_auth_encryption_test_case_256_5(void)
12158 {
12159 	return test_authenticated_encryption(&gcm_test_case_256_5);
12160 }
12161 
12162 static int
12163 test_AES_GCM_auth_encryption_test_case_256_6(void)
12164 {
12165 	return test_authenticated_encryption(&gcm_test_case_256_6);
12166 }
12167 
12168 static int
12169 test_AES_GCM_auth_encryption_test_case_256_7(void)
12170 {
12171 	return test_authenticated_encryption(&gcm_test_case_256_7);
12172 }
12173 
12174 static int
12175 test_AES_GCM_auth_encryption_test_case_aad_1(void)
12176 {
12177 	return test_authenticated_encryption(&gcm_test_case_aad_1);
12178 }
12179 
12180 static int
12181 test_AES_GCM_auth_encryption_test_case_aad_2(void)
12182 {
12183 	return test_authenticated_encryption(&gcm_test_case_aad_2);
12184 }
12185 
12186 static int
12187 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
12188 {
12189 	struct aead_test_data tdata;
12190 	int res;
12191 
12192 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12193 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12194 	tdata.iv.data[0] += 1;
12195 	res = test_authenticated_encryption(&tdata);
12196 	if (res == TEST_SKIPPED)
12197 		return res;
12198 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12199 	return TEST_SUCCESS;
12200 }
12201 
12202 static int
12203 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
12204 {
12205 	struct aead_test_data tdata;
12206 	int res;
12207 
12208 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12209 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12210 	tdata.plaintext.data[0] += 1;
12211 	res = test_authenticated_encryption(&tdata);
12212 	if (res == TEST_SKIPPED)
12213 		return res;
12214 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12215 	return TEST_SUCCESS;
12216 }
12217 
12218 static int
12219 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
12220 {
12221 	struct aead_test_data tdata;
12222 	int res;
12223 
12224 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12225 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12226 	tdata.ciphertext.data[0] += 1;
12227 	res = test_authenticated_encryption(&tdata);
12228 	if (res == TEST_SKIPPED)
12229 		return res;
12230 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12231 	return TEST_SUCCESS;
12232 }
12233 
12234 static int
12235 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
12236 {
12237 	struct aead_test_data tdata;
12238 	int res;
12239 
12240 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12241 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12242 	tdata.aad.len += 1;
12243 	res = test_authenticated_encryption(&tdata);
12244 	if (res == TEST_SKIPPED)
12245 		return res;
12246 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12247 	return TEST_SUCCESS;
12248 }
12249 
12250 static int
12251 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
12252 {
12253 	struct aead_test_data tdata;
12254 	uint8_t aad[gcm_test_case_7.aad.len];
12255 	int res;
12256 
12257 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12258 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12259 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12260 	aad[0] += 1;
12261 	tdata.aad.data = aad;
12262 	res = test_authenticated_encryption(&tdata);
12263 	if (res == TEST_SKIPPED)
12264 		return res;
12265 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12266 	return TEST_SUCCESS;
12267 }
12268 
12269 static int
12270 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
12271 {
12272 	struct aead_test_data tdata;
12273 	int res;
12274 
12275 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12276 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12277 	tdata.auth_tag.data[0] += 1;
12278 	res = test_authenticated_encryption(&tdata);
12279 	if (res == TEST_SKIPPED)
12280 		return res;
12281 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12282 	return TEST_SUCCESS;
12283 }
12284 
12285 static int
12286 test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
12287 {
12288 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12289 	struct crypto_unittest_params *ut_params = &unittest_params;
12290 
12291 	int retval;
12292 	uint8_t *plaintext;
12293 	uint32_t i;
12294 	struct rte_cryptodev_info dev_info;
12295 
12296 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12297 	uint64_t feat_flags = dev_info.feature_flags;
12298 
12299 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12300 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12301 		printf("Device doesn't support RAW data-path APIs.\n");
12302 		return TEST_SKIPPED;
12303 	}
12304 
12305 	/* Verify the capabilities */
12306 	struct rte_cryptodev_sym_capability_idx cap_idx;
12307 	const struct rte_cryptodev_symmetric_capability *capability;
12308 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12309 	cap_idx.algo.aead = tdata->algo;
12310 	capability = rte_cryptodev_sym_capability_get(
12311 			ts_params->valid_devs[0], &cap_idx);
12312 	if (capability == NULL)
12313 		return TEST_SKIPPED;
12314 	if (rte_cryptodev_sym_capability_check_aead(
12315 			capability, tdata->key.len, tdata->auth_tag.len,
12316 			tdata->aad.len, tdata->iv.len))
12317 		return TEST_SKIPPED;
12318 
12319 	/* Create AEAD session */
12320 	retval = create_aead_session(ts_params->valid_devs[0],
12321 			tdata->algo,
12322 			RTE_CRYPTO_AEAD_OP_DECRYPT,
12323 			tdata->key.data, tdata->key.len,
12324 			tdata->aad.len, tdata->auth_tag.len,
12325 			tdata->iv.len);
12326 	if (retval != TEST_SUCCESS)
12327 		return retval;
12328 
12329 	/* alloc mbuf and set payload */
12330 	if (tdata->aad.len > MBUF_SIZE) {
12331 		if (use_ext_mbuf) {
12332 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
12333 							  AEAD_TEXT_MAX_LENGTH,
12334 							  1 /* nb_segs */,
12335 							  NULL);
12336 		} else {
12337 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12338 		}
12339 		/* Populate full size of add data */
12340 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
12341 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
12342 	} else {
12343 		if (use_ext_mbuf) {
12344 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
12345 							  AEAD_TEXT_MAX_LENGTH,
12346 							  1 /* nb_segs */,
12347 							  NULL);
12348 		} else {
12349 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12350 		}
12351 	}
12352 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12353 			rte_pktmbuf_tailroom(ut_params->ibuf));
12354 
12355 	/* Create AEAD operation */
12356 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12357 	if (retval < 0)
12358 		return retval;
12359 
12360 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12361 
12362 	ut_params->op->sym->m_src = ut_params->ibuf;
12363 
12364 	/* Process crypto operation */
12365 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12366 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12367 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12368 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12369 					       0);
12370 		if (retval != TEST_SUCCESS)
12371 			return retval;
12372 	} else
12373 		TEST_ASSERT_NOT_NULL(
12374 			process_crypto_request(ts_params->valid_devs[0],
12375 			ut_params->op), "failed to process sym crypto op");
12376 
12377 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12378 			"crypto op processing failed");
12379 
12380 	if (ut_params->op->sym->m_dst)
12381 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
12382 				uint8_t *);
12383 	else
12384 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12385 				uint8_t *,
12386 				ut_params->op->sym->cipher.data.offset);
12387 
12388 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12389 
12390 	/* Validate obuf */
12391 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12392 			plaintext,
12393 			tdata->plaintext.data,
12394 			tdata->plaintext.len,
12395 			"Plaintext data not as expected");
12396 
12397 	TEST_ASSERT_EQUAL(ut_params->op->status,
12398 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12399 			"Authentication failed");
12400 
12401 	return 0;
12402 }
12403 
12404 static int
12405 test_authenticated_decryption(const struct aead_test_data *tdata)
12406 {
12407 	return test_authenticated_decryption_helper(tdata, false);
12408 }
12409 
12410 static int
12411 test_AES_GCM_authenticated_decryption_test_case_1(void)
12412 {
12413 	return test_authenticated_decryption(&gcm_test_case_1);
12414 }
12415 
12416 static int
12417 test_AES_GCM_authenticated_decryption_test_case_2(void)
12418 {
12419 	return test_authenticated_decryption(&gcm_test_case_2);
12420 }
12421 
12422 static int
12423 test_AES_GCM_authenticated_decryption_test_case_3(void)
12424 {
12425 	return test_authenticated_decryption(&gcm_test_case_3);
12426 }
12427 
12428 static int
12429 test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
12430 {
12431 	return test_authenticated_decryption_helper(&gcm_test_case_3, true);
12432 }
12433 
12434 static int
12435 test_AES_GCM_authenticated_decryption_test_case_4(void)
12436 {
12437 	return test_authenticated_decryption(&gcm_test_case_4);
12438 }
12439 
12440 static int
12441 test_AES_GCM_authenticated_decryption_test_case_5(void)
12442 {
12443 	return test_authenticated_decryption(&gcm_test_case_5);
12444 }
12445 
12446 static int
12447 test_AES_GCM_authenticated_decryption_test_case_6(void)
12448 {
12449 	return test_authenticated_decryption(&gcm_test_case_6);
12450 }
12451 
12452 static int
12453 test_AES_GCM_authenticated_decryption_test_case_7(void)
12454 {
12455 	return test_authenticated_decryption(&gcm_test_case_7);
12456 }
12457 
12458 static int
12459 test_AES_GCM_authenticated_decryption_test_case_8(void)
12460 {
12461 	return test_authenticated_decryption(&gcm_test_case_8);
12462 }
12463 
12464 static int
12465 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
12466 {
12467 	return test_authenticated_decryption(&gcm_J0_test_case_1);
12468 }
12469 
12470 static int
12471 test_AES_GCM_auth_decryption_test_case_192_1(void)
12472 {
12473 	return test_authenticated_decryption(&gcm_test_case_192_1);
12474 }
12475 
12476 static int
12477 test_AES_GCM_auth_decryption_test_case_192_2(void)
12478 {
12479 	return test_authenticated_decryption(&gcm_test_case_192_2);
12480 }
12481 
12482 static int
12483 test_AES_GCM_auth_decryption_test_case_192_3(void)
12484 {
12485 	return test_authenticated_decryption(&gcm_test_case_192_3);
12486 }
12487 
12488 static int
12489 test_AES_GCM_auth_decryption_test_case_192_4(void)
12490 {
12491 	return test_authenticated_decryption(&gcm_test_case_192_4);
12492 }
12493 
12494 static int
12495 test_AES_GCM_auth_decryption_test_case_192_5(void)
12496 {
12497 	return test_authenticated_decryption(&gcm_test_case_192_5);
12498 }
12499 
12500 static int
12501 test_AES_GCM_auth_decryption_test_case_192_6(void)
12502 {
12503 	return test_authenticated_decryption(&gcm_test_case_192_6);
12504 }
12505 
12506 static int
12507 test_AES_GCM_auth_decryption_test_case_192_7(void)
12508 {
12509 	return test_authenticated_decryption(&gcm_test_case_192_7);
12510 }
12511 
12512 static int
12513 test_AES_GCM_auth_decryption_test_case_256_1(void)
12514 {
12515 	return test_authenticated_decryption(&gcm_test_case_256_1);
12516 }
12517 
12518 static int
12519 test_AES_GCM_auth_decryption_test_case_256_2(void)
12520 {
12521 	return test_authenticated_decryption(&gcm_test_case_256_2);
12522 }
12523 
12524 static int
12525 test_AES_GCM_auth_decryption_test_case_256_3(void)
12526 {
12527 	return test_authenticated_decryption(&gcm_test_case_256_3);
12528 }
12529 
12530 static int
12531 test_AES_GCM_auth_decryption_test_case_256_4(void)
12532 {
12533 	return test_authenticated_decryption(&gcm_test_case_256_4);
12534 }
12535 
12536 static int
12537 test_AES_GCM_auth_decryption_test_case_256_5(void)
12538 {
12539 	return test_authenticated_decryption(&gcm_test_case_256_5);
12540 }
12541 
12542 static int
12543 test_AES_GCM_auth_decryption_test_case_256_6(void)
12544 {
12545 	return test_authenticated_decryption(&gcm_test_case_256_6);
12546 }
12547 
12548 static int
12549 test_AES_GCM_auth_decryption_test_case_256_7(void)
12550 {
12551 	return test_authenticated_decryption(&gcm_test_case_256_7);
12552 }
12553 
12554 static int
12555 test_AES_GCM_auth_decryption_test_case_aad_1(void)
12556 {
12557 	return test_authenticated_decryption(&gcm_test_case_aad_1);
12558 }
12559 
12560 static int
12561 test_AES_GCM_auth_decryption_test_case_aad_2(void)
12562 {
12563 	return test_authenticated_decryption(&gcm_test_case_aad_2);
12564 }
12565 
12566 static int
12567 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
12568 {
12569 	struct aead_test_data tdata;
12570 	int res;
12571 
12572 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12573 	tdata.iv.data[0] += 1;
12574 	res = test_authenticated_decryption(&tdata);
12575 	if (res == TEST_SKIPPED)
12576 		return res;
12577 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12578 	return TEST_SUCCESS;
12579 }
12580 
12581 static int
12582 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
12583 {
12584 	struct aead_test_data tdata;
12585 	int res;
12586 
12587 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12588 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12589 	tdata.plaintext.data[0] += 1;
12590 	res = test_authenticated_decryption(&tdata);
12591 	if (res == TEST_SKIPPED)
12592 		return res;
12593 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12594 	return TEST_SUCCESS;
12595 }
12596 
12597 static int
12598 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
12599 {
12600 	struct aead_test_data tdata;
12601 	int res;
12602 
12603 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12604 	tdata.ciphertext.data[0] += 1;
12605 	res = test_authenticated_decryption(&tdata);
12606 	if (res == TEST_SKIPPED)
12607 		return res;
12608 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12609 	return TEST_SUCCESS;
12610 }
12611 
12612 static int
12613 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
12614 {
12615 	struct aead_test_data tdata;
12616 	int res;
12617 
12618 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12619 	tdata.aad.len += 1;
12620 	res = test_authenticated_decryption(&tdata);
12621 	if (res == TEST_SKIPPED)
12622 		return res;
12623 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12624 	return TEST_SUCCESS;
12625 }
12626 
12627 static int
12628 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
12629 {
12630 	struct aead_test_data tdata;
12631 	uint8_t aad[gcm_test_case_7.aad.len];
12632 	int res;
12633 
12634 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12635 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12636 	aad[0] += 1;
12637 	tdata.aad.data = aad;
12638 	res = test_authenticated_decryption(&tdata);
12639 	if (res == TEST_SKIPPED)
12640 		return res;
12641 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12642 	return TEST_SUCCESS;
12643 }
12644 
12645 static int
12646 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
12647 {
12648 	struct aead_test_data tdata;
12649 	int res;
12650 
12651 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12652 	tdata.auth_tag.data[0] += 1;
12653 	res = test_authenticated_decryption(&tdata);
12654 	if (res == TEST_SKIPPED)
12655 		return res;
12656 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
12657 	return TEST_SUCCESS;
12658 }
12659 
12660 static int
12661 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
12662 {
12663 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12664 	struct crypto_unittest_params *ut_params = &unittest_params;
12665 
12666 	int retval;
12667 	uint8_t *ciphertext, *auth_tag;
12668 	uint16_t plaintext_pad_len;
12669 	struct rte_cryptodev_info dev_info;
12670 
12671 	/* Verify the capabilities */
12672 	struct rte_cryptodev_sym_capability_idx cap_idx;
12673 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12674 	cap_idx.algo.aead = tdata->algo;
12675 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12676 			&cap_idx) == NULL)
12677 		return TEST_SKIPPED;
12678 
12679 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12680 	uint64_t feat_flags = dev_info.feature_flags;
12681 
12682 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12683 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
12684 		return TEST_SKIPPED;
12685 
12686 	/* not supported with CPU crypto */
12687 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12688 		return TEST_SKIPPED;
12689 
12690 	/* Create AEAD session */
12691 	retval = create_aead_session(ts_params->valid_devs[0],
12692 			tdata->algo,
12693 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
12694 			tdata->key.data, tdata->key.len,
12695 			tdata->aad.len, tdata->auth_tag.len,
12696 			tdata->iv.len);
12697 	if (retval < 0)
12698 		return retval;
12699 
12700 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12701 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12702 
12703 	/* clear mbuf payload */
12704 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12705 			rte_pktmbuf_tailroom(ut_params->ibuf));
12706 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12707 			rte_pktmbuf_tailroom(ut_params->obuf));
12708 
12709 	/* Create AEAD operation */
12710 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12711 	if (retval < 0)
12712 		return retval;
12713 
12714 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12715 
12716 	ut_params->op->sym->m_src = ut_params->ibuf;
12717 	ut_params->op->sym->m_dst = ut_params->obuf;
12718 
12719 	/* Process crypto operation */
12720 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12721 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12722 					       0);
12723 		if (retval != TEST_SUCCESS)
12724 			return retval;
12725 	} else
12726 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12727 			ut_params->op), "failed to process sym crypto op");
12728 
12729 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12730 			"crypto op processing failed");
12731 
12732 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12733 
12734 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12735 			ut_params->op->sym->cipher.data.offset);
12736 	auth_tag = ciphertext + plaintext_pad_len;
12737 
12738 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12739 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12740 
12741 	/* Validate obuf */
12742 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12743 			ciphertext,
12744 			tdata->ciphertext.data,
12745 			tdata->ciphertext.len,
12746 			"Ciphertext data not as expected");
12747 
12748 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12749 			auth_tag,
12750 			tdata->auth_tag.data,
12751 			tdata->auth_tag.len,
12752 			"Generated auth tag not as expected");
12753 
12754 	return 0;
12755 
12756 }
12757 
12758 static int
12759 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
12760 {
12761 	return test_authenticated_encryption_oop(&gcm_test_case_5);
12762 }
12763 
12764 static int
12765 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
12766 {
12767 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12768 	struct crypto_unittest_params *ut_params = &unittest_params;
12769 
12770 	int retval;
12771 	uint8_t *plaintext;
12772 	struct rte_cryptodev_info dev_info;
12773 
12774 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12775 	uint64_t feat_flags = dev_info.feature_flags;
12776 
12777 	/* Verify the capabilities */
12778 	struct rte_cryptodev_sym_capability_idx cap_idx;
12779 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12780 	cap_idx.algo.aead = tdata->algo;
12781 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12782 			&cap_idx) == NULL)
12783 		return TEST_SKIPPED;
12784 
12785 	/* not supported with CPU crypto and raw data-path APIs*/
12786 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
12787 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
12788 		return TEST_SKIPPED;
12789 
12790 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12791 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12792 		printf("Device does not support RAW data-path APIs.\n");
12793 		return TEST_SKIPPED;
12794 	}
12795 
12796 	/* Create AEAD session */
12797 	retval = create_aead_session(ts_params->valid_devs[0],
12798 			tdata->algo,
12799 			RTE_CRYPTO_AEAD_OP_DECRYPT,
12800 			tdata->key.data, tdata->key.len,
12801 			tdata->aad.len, tdata->auth_tag.len,
12802 			tdata->iv.len);
12803 	if (retval < 0)
12804 		return retval;
12805 
12806 	/* alloc mbuf and set payload */
12807 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12808 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12809 
12810 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12811 			rte_pktmbuf_tailroom(ut_params->ibuf));
12812 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
12813 			rte_pktmbuf_tailroom(ut_params->obuf));
12814 
12815 	/* Create AEAD operation */
12816 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12817 	if (retval < 0)
12818 		return retval;
12819 
12820 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12821 
12822 	ut_params->op->sym->m_src = ut_params->ibuf;
12823 	ut_params->op->sym->m_dst = ut_params->obuf;
12824 
12825 	/* Process crypto operation */
12826 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12827 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12828 					       0);
12829 		if (retval != TEST_SUCCESS)
12830 			return retval;
12831 	} else
12832 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12833 			ut_params->op), "failed to process sym crypto op");
12834 
12835 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12836 			"crypto op processing failed");
12837 
12838 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
12839 			ut_params->op->sym->cipher.data.offset);
12840 
12841 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12842 
12843 	/* Validate obuf */
12844 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12845 			plaintext,
12846 			tdata->plaintext.data,
12847 			tdata->plaintext.len,
12848 			"Plaintext data not as expected");
12849 
12850 	TEST_ASSERT_EQUAL(ut_params->op->status,
12851 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12852 			"Authentication failed");
12853 	return 0;
12854 }
12855 
12856 static int
12857 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
12858 {
12859 	return test_authenticated_decryption_oop(&gcm_test_case_5);
12860 }
12861 
12862 static int
12863 test_authenticated_encryption_sessionless(
12864 		const struct aead_test_data *tdata)
12865 {
12866 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12867 	struct crypto_unittest_params *ut_params = &unittest_params;
12868 
12869 	int retval;
12870 	uint8_t *ciphertext, *auth_tag;
12871 	uint16_t plaintext_pad_len;
12872 	uint8_t key[tdata->key.len + 1];
12873 	struct rte_cryptodev_info dev_info;
12874 
12875 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12876 	uint64_t feat_flags = dev_info.feature_flags;
12877 
12878 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12879 		printf("Device doesn't support Sessionless ops.\n");
12880 		return TEST_SKIPPED;
12881 	}
12882 
12883 	/* not supported with CPU crypto */
12884 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12885 		return TEST_SKIPPED;
12886 
12887 	/* Verify the capabilities */
12888 	struct rte_cryptodev_sym_capability_idx cap_idx;
12889 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12890 	cap_idx.algo.aead = tdata->algo;
12891 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12892 			&cap_idx) == NULL)
12893 		return TEST_SKIPPED;
12894 
12895 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12896 
12897 	/* clear mbuf payload */
12898 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12899 			rte_pktmbuf_tailroom(ut_params->ibuf));
12900 
12901 	/* Create AEAD operation */
12902 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
12903 	if (retval < 0)
12904 		return retval;
12905 
12906 	/* Create GCM xform */
12907 	memcpy(key, tdata->key.data, tdata->key.len);
12908 	retval = create_aead_xform(ut_params->op,
12909 			tdata->algo,
12910 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
12911 			key, tdata->key.len,
12912 			tdata->aad.len, tdata->auth_tag.len,
12913 			tdata->iv.len);
12914 	if (retval < 0)
12915 		return retval;
12916 
12917 	ut_params->op->sym->m_src = ut_params->ibuf;
12918 
12919 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
12920 			RTE_CRYPTO_OP_SESSIONLESS,
12921 			"crypto op session type not sessionless");
12922 
12923 	/* Process crypto operation */
12924 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
12925 			ut_params->op), "failed to process sym crypto op");
12926 
12927 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12928 
12929 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12930 			"crypto op status not success");
12931 
12932 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12933 
12934 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12935 			ut_params->op->sym->cipher.data.offset);
12936 	auth_tag = ciphertext + plaintext_pad_len;
12937 
12938 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
12939 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
12940 
12941 	/* Validate obuf */
12942 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12943 			ciphertext,
12944 			tdata->ciphertext.data,
12945 			tdata->ciphertext.len,
12946 			"Ciphertext data not as expected");
12947 
12948 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12949 			auth_tag,
12950 			tdata->auth_tag.data,
12951 			tdata->auth_tag.len,
12952 			"Generated auth tag not as expected");
12953 
12954 	return 0;
12955 
12956 }
12957 
12958 static int
12959 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
12960 {
12961 	return test_authenticated_encryption_sessionless(
12962 			&gcm_test_case_5);
12963 }
12964 
12965 static int
12966 test_authenticated_decryption_sessionless(
12967 		const struct aead_test_data *tdata)
12968 {
12969 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12970 	struct crypto_unittest_params *ut_params = &unittest_params;
12971 
12972 	int retval;
12973 	uint8_t *plaintext;
12974 	uint8_t key[tdata->key.len + 1];
12975 	struct rte_cryptodev_info dev_info;
12976 
12977 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12978 	uint64_t feat_flags = dev_info.feature_flags;
12979 
12980 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
12981 		printf("Device doesn't support Sessionless ops.\n");
12982 		return TEST_SKIPPED;
12983 	}
12984 
12985 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12986 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12987 		printf("Device doesn't support RAW data-path APIs.\n");
12988 		return TEST_SKIPPED;
12989 	}
12990 
12991 	/* not supported with CPU crypto */
12992 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12993 		return TEST_SKIPPED;
12994 
12995 	/* Verify the capabilities */
12996 	struct rte_cryptodev_sym_capability_idx cap_idx;
12997 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12998 	cap_idx.algo.aead = tdata->algo;
12999 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13000 			&cap_idx) == NULL)
13001 		return TEST_SKIPPED;
13002 
13003 	/* alloc mbuf and set payload */
13004 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13005 
13006 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13007 			rte_pktmbuf_tailroom(ut_params->ibuf));
13008 
13009 	/* Create AEAD operation */
13010 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13011 	if (retval < 0)
13012 		return retval;
13013 
13014 	/* Create AEAD xform */
13015 	memcpy(key, tdata->key.data, tdata->key.len);
13016 	retval = create_aead_xform(ut_params->op,
13017 			tdata->algo,
13018 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13019 			key, tdata->key.len,
13020 			tdata->aad.len, tdata->auth_tag.len,
13021 			tdata->iv.len);
13022 	if (retval < 0)
13023 		return retval;
13024 
13025 	ut_params->op->sym->m_src = ut_params->ibuf;
13026 
13027 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13028 			RTE_CRYPTO_OP_SESSIONLESS,
13029 			"crypto op session type not sessionless");
13030 
13031 	/* Process crypto operation */
13032 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13033 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13034 					       0);
13035 		if (retval != TEST_SUCCESS)
13036 			return retval;
13037 	} else
13038 		TEST_ASSERT_NOT_NULL(process_crypto_request(
13039 			ts_params->valid_devs[0], ut_params->op),
13040 				"failed to process sym crypto op");
13041 
13042 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13043 
13044 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13045 			"crypto op status not success");
13046 
13047 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13048 			ut_params->op->sym->cipher.data.offset);
13049 
13050 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13051 
13052 	/* Validate obuf */
13053 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13054 			plaintext,
13055 			tdata->plaintext.data,
13056 			tdata->plaintext.len,
13057 			"Plaintext data not as expected");
13058 
13059 	TEST_ASSERT_EQUAL(ut_params->op->status,
13060 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13061 			"Authentication failed");
13062 	return 0;
13063 }
13064 
13065 static int
13066 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
13067 {
13068 	return test_authenticated_decryption_sessionless(
13069 			&gcm_test_case_5);
13070 }
13071 
13072 static int
13073 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
13074 {
13075 	return test_authenticated_encryption(&ccm_test_case_128_1);
13076 }
13077 
13078 static int
13079 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
13080 {
13081 	return test_authenticated_encryption(&ccm_test_case_128_2);
13082 }
13083 
13084 static int
13085 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
13086 {
13087 	return test_authenticated_encryption(&ccm_test_case_128_3);
13088 }
13089 
13090 static int
13091 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
13092 {
13093 	return test_authenticated_decryption(&ccm_test_case_128_1);
13094 }
13095 
13096 static int
13097 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
13098 {
13099 	return test_authenticated_decryption(&ccm_test_case_128_2);
13100 }
13101 
13102 static int
13103 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
13104 {
13105 	return test_authenticated_decryption(&ccm_test_case_128_3);
13106 }
13107 
13108 static int
13109 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
13110 {
13111 	return test_authenticated_encryption(&ccm_test_case_192_1);
13112 }
13113 
13114 static int
13115 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
13116 {
13117 	return test_authenticated_encryption(&ccm_test_case_192_2);
13118 }
13119 
13120 static int
13121 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
13122 {
13123 	return test_authenticated_encryption(&ccm_test_case_192_3);
13124 }
13125 
13126 static int
13127 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
13128 {
13129 	return test_authenticated_decryption(&ccm_test_case_192_1);
13130 }
13131 
13132 static int
13133 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
13134 {
13135 	return test_authenticated_decryption(&ccm_test_case_192_2);
13136 }
13137 
13138 static int
13139 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
13140 {
13141 	return test_authenticated_decryption(&ccm_test_case_192_3);
13142 }
13143 
13144 static int
13145 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
13146 {
13147 	return test_authenticated_encryption(&ccm_test_case_256_1);
13148 }
13149 
13150 static int
13151 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
13152 {
13153 	return test_authenticated_encryption(&ccm_test_case_256_2);
13154 }
13155 
13156 static int
13157 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
13158 {
13159 	return test_authenticated_encryption(&ccm_test_case_256_3);
13160 }
13161 
13162 static int
13163 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
13164 {
13165 	return test_authenticated_decryption(&ccm_test_case_256_1);
13166 }
13167 
13168 static int
13169 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
13170 {
13171 	return test_authenticated_decryption(&ccm_test_case_256_2);
13172 }
13173 
13174 static int
13175 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
13176 {
13177 	return test_authenticated_decryption(&ccm_test_case_256_3);
13178 }
13179 
13180 static int
13181 test_stats(void)
13182 {
13183 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13184 	struct rte_cryptodev_stats stats;
13185 
13186 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13187 		return TEST_SKIPPED;
13188 
13189 	/* Verify the capabilities */
13190 	struct rte_cryptodev_sym_capability_idx cap_idx;
13191 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13192 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
13193 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13194 			&cap_idx) == NULL)
13195 		return TEST_SKIPPED;
13196 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13197 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13198 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13199 			&cap_idx) == NULL)
13200 		return TEST_SKIPPED;
13201 
13202 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
13203 			== -ENOTSUP)
13204 		return TEST_SKIPPED;
13205 
13206 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13207 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
13208 			&stats) == -ENODEV),
13209 		"rte_cryptodev_stats_get invalid dev failed");
13210 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
13211 		"rte_cryptodev_stats_get invalid Param failed");
13212 
13213 	/* Test expected values */
13214 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
13215 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13216 			&stats),
13217 		"rte_cryptodev_stats_get failed");
13218 	TEST_ASSERT((stats.enqueued_count == 1),
13219 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
13220 	TEST_ASSERT((stats.dequeued_count == 1),
13221 		"rte_cryptodev_stats_get returned unexpected dequeued stat");
13222 	TEST_ASSERT((stats.enqueue_err_count == 0),
13223 		"rte_cryptodev_stats_get returned unexpected enqueued error count stat");
13224 	TEST_ASSERT((stats.dequeue_err_count == 0),
13225 		"rte_cryptodev_stats_get returned unexpected dequeued error count stat");
13226 
13227 	/* invalid device but should ignore and not reset device stats*/
13228 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
13229 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13230 			&stats),
13231 		"rte_cryptodev_stats_get failed");
13232 	TEST_ASSERT((stats.enqueued_count == 1),
13233 		"rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
13234 
13235 	/* check that a valid reset clears stats */
13236 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13237 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13238 			&stats),
13239 					  "rte_cryptodev_stats_get failed");
13240 	TEST_ASSERT((stats.enqueued_count == 0),
13241 		"rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
13242 	TEST_ASSERT((stats.dequeued_count == 0),
13243 		"rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
13244 
13245 	return TEST_SUCCESS;
13246 }
13247 
13248 static int
13249 test_device_reconfigure(void)
13250 {
13251 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13252 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
13253 	struct rte_cryptodev_qp_conf qp_conf = {
13254 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT,
13255 		.mp_session = ts_params->session_mpool
13256 	};
13257 	uint16_t qp_id, dev_id, num_devs = 0;
13258 
13259 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
13260 			"Need at least %d devices for test", 1);
13261 
13262 	dev_id = ts_params->valid_devs[0];
13263 
13264 	/* Stop the device in case it's started so it can be configured */
13265 	rte_cryptodev_stop(dev_id);
13266 
13267 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13268 			"Failed test for rte_cryptodev_configure: "
13269 			"dev_num %u", dev_id);
13270 
13271 	/* Reconfigure with same configure params */
13272 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13273 			"Failed test for rte_cryptodev_configure: "
13274 			"dev_num %u", dev_id);
13275 
13276 	/* Reconfigure with just one queue pair */
13277 	ts_params->conf.nb_queue_pairs = 1;
13278 
13279 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13280 			&ts_params->conf),
13281 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
13282 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13283 
13284 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13285 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13286 				ts_params->valid_devs[0], qp_id, &qp_conf,
13287 				rte_cryptodev_socket_id(
13288 						ts_params->valid_devs[0])),
13289 				"Failed test for "
13290 				"rte_cryptodev_queue_pair_setup: num_inflights "
13291 				"%u on qp %u on cryptodev %u",
13292 				qp_conf.nb_descriptors, qp_id,
13293 				ts_params->valid_devs[0]);
13294 	}
13295 
13296 	/* Reconfigure with max number of queue pairs */
13297 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
13298 
13299 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13300 			&ts_params->conf),
13301 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
13302 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13303 
13304 	qp_conf.mp_session = ts_params->session_mpool;
13305 
13306 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13307 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13308 				ts_params->valid_devs[0], qp_id, &qp_conf,
13309 				rte_cryptodev_socket_id(
13310 						ts_params->valid_devs[0])),
13311 				"Failed test for "
13312 				"rte_cryptodev_queue_pair_setup: num_inflights "
13313 				"%u on qp %u on cryptodev %u",
13314 				qp_conf.nb_descriptors, qp_id,
13315 				ts_params->valid_devs[0]);
13316 	}
13317 
13318 	/* Start the device */
13319 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
13320 			"Failed to start cryptodev %u",
13321 			ts_params->valid_devs[0]);
13322 
13323 	/* Test expected values */
13324 	return test_AES_CBC_HMAC_SHA1_encrypt_digest();
13325 }
13326 
13327 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
13328 				   struct crypto_unittest_params *ut_params,
13329 				   enum rte_crypto_auth_operation op,
13330 				   const struct HMAC_MD5_vector *test_case)
13331 {
13332 	uint8_t key[64];
13333 
13334 	memcpy(key, test_case->key.data, test_case->key.len);
13335 
13336 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13337 	ut_params->auth_xform.next = NULL;
13338 	ut_params->auth_xform.auth.op = op;
13339 
13340 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
13341 
13342 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
13343 	ut_params->auth_xform.auth.key.length = test_case->key.len;
13344 	ut_params->auth_xform.auth.key.data = key;
13345 
13346 	ut_params->sess = rte_cryptodev_sym_session_create(
13347 		ts_params->valid_devs[0], &ut_params->auth_xform,
13348 			ts_params->session_mpool);
13349 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13350 		return TEST_SKIPPED;
13351 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13352 
13353 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13354 
13355 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13356 			rte_pktmbuf_tailroom(ut_params->ibuf));
13357 
13358 	return 0;
13359 }
13360 
13361 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
13362 			      const struct HMAC_MD5_vector *test_case,
13363 			      uint8_t **plaintext)
13364 {
13365 	uint16_t plaintext_pad_len;
13366 
13367 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13368 
13369 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13370 				16);
13371 
13372 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13373 			plaintext_pad_len);
13374 	memcpy(*plaintext, test_case->plaintext.data,
13375 			test_case->plaintext.len);
13376 
13377 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13378 			ut_params->ibuf, MD5_DIGEST_LEN);
13379 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13380 			"no room to append digest");
13381 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13382 			ut_params->ibuf, plaintext_pad_len);
13383 
13384 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13385 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
13386 			   test_case->auth_tag.len);
13387 	}
13388 
13389 	sym_op->auth.data.offset = 0;
13390 	sym_op->auth.data.length = test_case->plaintext.len;
13391 
13392 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13393 	ut_params->op->sym->m_src = ut_params->ibuf;
13394 
13395 	return 0;
13396 }
13397 
13398 static int
13399 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
13400 {
13401 	uint16_t plaintext_pad_len;
13402 	uint8_t *plaintext, *auth_tag;
13403 	int ret;
13404 
13405 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13406 	struct crypto_unittest_params *ut_params = &unittest_params;
13407 	struct rte_cryptodev_info dev_info;
13408 
13409 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13410 	uint64_t feat_flags = dev_info.feature_flags;
13411 
13412 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13413 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13414 		printf("Device doesn't support RAW data-path APIs.\n");
13415 		return TEST_SKIPPED;
13416 	}
13417 
13418 	/* Verify the capabilities */
13419 	struct rte_cryptodev_sym_capability_idx cap_idx;
13420 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13421 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13422 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13423 			&cap_idx) == NULL)
13424 		return TEST_SKIPPED;
13425 
13426 	if (MD5_HMAC_create_session(ts_params, ut_params,
13427 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
13428 		return TEST_FAILED;
13429 
13430 	/* Generate Crypto op data structure */
13431 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13432 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13433 	TEST_ASSERT_NOT_NULL(ut_params->op,
13434 			"Failed to allocate symmetric crypto operation struct");
13435 
13436 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13437 				16);
13438 
13439 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13440 		return TEST_FAILED;
13441 
13442 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13443 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13444 			ut_params->op);
13445 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13446 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13447 		if (ret != TEST_SUCCESS)
13448 			return ret;
13449 	} else
13450 		TEST_ASSERT_NOT_NULL(
13451 			process_crypto_request(ts_params->valid_devs[0],
13452 				ut_params->op),
13453 				"failed to process sym crypto op");
13454 
13455 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13456 			"crypto op processing failed");
13457 
13458 	if (ut_params->op->sym->m_dst) {
13459 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13460 				uint8_t *, plaintext_pad_len);
13461 	} else {
13462 		auth_tag = plaintext + plaintext_pad_len;
13463 	}
13464 
13465 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13466 			auth_tag,
13467 			test_case->auth_tag.data,
13468 			test_case->auth_tag.len,
13469 			"HMAC_MD5 generated tag not as expected");
13470 
13471 	return TEST_SUCCESS;
13472 }
13473 
13474 static int
13475 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
13476 {
13477 	uint8_t *plaintext;
13478 	int ret;
13479 
13480 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13481 	struct crypto_unittest_params *ut_params = &unittest_params;
13482 	struct rte_cryptodev_info dev_info;
13483 
13484 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13485 	uint64_t feat_flags = dev_info.feature_flags;
13486 
13487 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13488 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13489 		printf("Device doesn't support RAW data-path APIs.\n");
13490 		return TEST_SKIPPED;
13491 	}
13492 
13493 	/* Verify the capabilities */
13494 	struct rte_cryptodev_sym_capability_idx cap_idx;
13495 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13496 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13497 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13498 			&cap_idx) == NULL)
13499 		return TEST_SKIPPED;
13500 
13501 	if (MD5_HMAC_create_session(ts_params, ut_params,
13502 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
13503 		return TEST_FAILED;
13504 	}
13505 
13506 	/* Generate Crypto op data structure */
13507 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13508 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13509 	TEST_ASSERT_NOT_NULL(ut_params->op,
13510 			"Failed to allocate symmetric crypto operation struct");
13511 
13512 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13513 		return TEST_FAILED;
13514 
13515 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13516 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13517 			ut_params->op);
13518 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13519 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13520 		if (ret != TEST_SUCCESS)
13521 			return ret;
13522 	} else
13523 		TEST_ASSERT_NOT_NULL(
13524 			process_crypto_request(ts_params->valid_devs[0],
13525 				ut_params->op),
13526 				"failed to process sym crypto op");
13527 
13528 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13529 			"HMAC_MD5 crypto op processing failed");
13530 
13531 	return TEST_SUCCESS;
13532 }
13533 
13534 static int
13535 test_MD5_HMAC_generate_case_1(void)
13536 {
13537 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
13538 }
13539 
13540 static int
13541 test_MD5_HMAC_verify_case_1(void)
13542 {
13543 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
13544 }
13545 
13546 static int
13547 test_MD5_HMAC_generate_case_2(void)
13548 {
13549 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
13550 }
13551 
13552 static int
13553 test_MD5_HMAC_verify_case_2(void)
13554 {
13555 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
13556 }
13557 
13558 static int
13559 test_multi_session(void)
13560 {
13561 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13562 	struct crypto_unittest_params *ut_params = &unittest_params;
13563 	struct rte_cryptodev_info dev_info;
13564 	int i, nb_sess, ret = TEST_SUCCESS;
13565 	void **sessions;
13566 
13567 	/* Verify the capabilities */
13568 	struct rte_cryptodev_sym_capability_idx cap_idx;
13569 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13570 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13571 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13572 			&cap_idx) == NULL)
13573 		return TEST_SKIPPED;
13574 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13575 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13576 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13577 			&cap_idx) == NULL)
13578 		return TEST_SKIPPED;
13579 
13580 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
13581 			aes_cbc_key, hmac_sha512_key);
13582 
13583 
13584 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13585 
13586 	sessions = rte_malloc(NULL,
13587 			sizeof(void *) *
13588 			(MAX_NB_SESSIONS + 1), 0);
13589 
13590 	/* Create multiple crypto sessions*/
13591 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
13592 		sessions[i] = rte_cryptodev_sym_session_create(
13593 			ts_params->valid_devs[0], &ut_params->auth_xform,
13594 				ts_params->session_mpool);
13595 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13596 			nb_sess = i;
13597 			ret = TEST_SKIPPED;
13598 			break;
13599 		}
13600 
13601 		TEST_ASSERT_NOT_NULL(sessions[i],
13602 				"Session creation failed at session number %u",
13603 				i);
13604 
13605 		/* Attempt to send a request on each session */
13606 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13607 			sessions[i],
13608 			ut_params,
13609 			ts_params,
13610 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
13611 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
13612 			aes_cbc_iv);
13613 
13614 		/* free crypto operation structure */
13615 		rte_crypto_op_free(ut_params->op);
13616 
13617 		/*
13618 		 * free mbuf - both obuf and ibuf are usually the same,
13619 		 * so check if they point at the same address is necessary,
13620 		 * to avoid freeing the mbuf twice.
13621 		 */
13622 		if (ut_params->obuf) {
13623 			rte_pktmbuf_free(ut_params->obuf);
13624 			if (ut_params->ibuf == ut_params->obuf)
13625 				ut_params->ibuf = 0;
13626 			ut_params->obuf = 0;
13627 		}
13628 		if (ut_params->ibuf) {
13629 			rte_pktmbuf_free(ut_params->ibuf);
13630 			ut_params->ibuf = 0;
13631 		}
13632 
13633 		if (ret != TEST_SUCCESS) {
13634 			i++;
13635 			break;
13636 		}
13637 	}
13638 
13639 	nb_sess = i;
13640 
13641 	for (i = 0; i < nb_sess; i++) {
13642 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13643 				sessions[i]);
13644 	}
13645 
13646 	rte_free(sessions);
13647 
13648 	if (ret != TEST_SKIPPED)
13649 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
13650 
13651 	return ret;
13652 }
13653 
13654 struct multi_session_params {
13655 	struct crypto_unittest_params ut_params;
13656 	uint8_t *cipher_key;
13657 	uint8_t *hmac_key;
13658 	const uint8_t *cipher;
13659 	const uint8_t *digest;
13660 	uint8_t *iv;
13661 };
13662 
13663 #define MB_SESSION_NUMBER 3
13664 
13665 static int
13666 test_multi_session_random_usage(void)
13667 {
13668 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13669 	struct rte_cryptodev_info dev_info;
13670 	int index = 0, ret = TEST_SUCCESS;
13671 	uint32_t nb_sess, i, j;
13672 	void **sessions;
13673 	struct multi_session_params ut_paramz[] = {
13674 
13675 		{
13676 			.cipher_key = ms_aes_cbc_key0,
13677 			.hmac_key = ms_hmac_key0,
13678 			.cipher = ms_aes_cbc_cipher0,
13679 			.digest = ms_hmac_digest0,
13680 			.iv = ms_aes_cbc_iv0
13681 		},
13682 		{
13683 			.cipher_key = ms_aes_cbc_key1,
13684 			.hmac_key = ms_hmac_key1,
13685 			.cipher = ms_aes_cbc_cipher1,
13686 			.digest = ms_hmac_digest1,
13687 			.iv = ms_aes_cbc_iv1
13688 		},
13689 		{
13690 			.cipher_key = ms_aes_cbc_key2,
13691 			.hmac_key = ms_hmac_key2,
13692 			.cipher = ms_aes_cbc_cipher2,
13693 			.digest = ms_hmac_digest2,
13694 			.iv = ms_aes_cbc_iv2
13695 		},
13696 
13697 	};
13698 
13699 	/* Verify the capabilities */
13700 	struct rte_cryptodev_sym_capability_idx cap_idx;
13701 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13702 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13703 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13704 			&cap_idx) == NULL)
13705 		return TEST_SKIPPED;
13706 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13707 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13708 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13709 			&cap_idx) == NULL)
13710 		return TEST_SKIPPED;
13711 
13712 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13713 
13714 	sessions = rte_malloc(NULL, (sizeof(void *)
13715 					* MAX_NB_SESSIONS) + 1, 0);
13716 
13717 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
13718 
13719 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
13720 				sizeof(struct crypto_unittest_params));
13721 
13722 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
13723 				&ut_paramz[i].ut_params,
13724 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
13725 
13726 		/* Create multiple crypto sessions*/
13727 		sessions[i] = rte_cryptodev_sym_session_create(
13728 				ts_params->valid_devs[0],
13729 				&ut_paramz[i].ut_params.auth_xform,
13730 				ts_params->session_mpool);
13731 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
13732 			nb_sess = i;
13733 			ret = TEST_SKIPPED;
13734 			goto session_clear;
13735 		}
13736 
13737 		TEST_ASSERT_NOT_NULL(sessions[i],
13738 				"Session creation failed at session number %u",
13739 				i);
13740 	}
13741 
13742 	nb_sess = i;
13743 
13744 	srand(time(NULL));
13745 	for (i = 0; i < 40000; i++) {
13746 
13747 		j = rand() % MB_SESSION_NUMBER;
13748 
13749 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
13750 					sessions[j],
13751 					&ut_paramz[j].ut_params,
13752 					ts_params, ut_paramz[j].cipher,
13753 					ut_paramz[j].digest,
13754 					ut_paramz[j].iv);
13755 
13756 		rte_crypto_op_free(ut_paramz[j].ut_params.op);
13757 
13758 		/*
13759 		 * free mbuf - both obuf and ibuf are usually the same,
13760 		 * so check if they point at the same address is necessary,
13761 		 * to avoid freeing the mbuf twice.
13762 		 */
13763 		if (ut_paramz[j].ut_params.obuf) {
13764 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
13765 			if (ut_paramz[j].ut_params.ibuf
13766 					== ut_paramz[j].ut_params.obuf)
13767 				ut_paramz[j].ut_params.ibuf = 0;
13768 			ut_paramz[j].ut_params.obuf = 0;
13769 		}
13770 		if (ut_paramz[j].ut_params.ibuf) {
13771 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
13772 			ut_paramz[j].ut_params.ibuf = 0;
13773 		}
13774 
13775 		if (ret != TEST_SKIPPED) {
13776 			index = i;
13777 			break;
13778 		}
13779 	}
13780 
13781 session_clear:
13782 	for (i = 0; i < nb_sess; i++) {
13783 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
13784 				sessions[i]);
13785 	}
13786 
13787 	rte_free(sessions);
13788 
13789 	if (ret != TEST_SKIPPED)
13790 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
13791 
13792 	return TEST_SUCCESS;
13793 }
13794 
13795 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
13796 			0xab, 0xab, 0xab, 0xab,
13797 			0xab, 0xab, 0xab, 0xab,
13798 			0xab, 0xab, 0xab, 0xab};
13799 
13800 static int
13801 test_null_invalid_operation(void)
13802 {
13803 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13804 	struct crypto_unittest_params *ut_params = &unittest_params;
13805 
13806 	/* This test is for NULL PMD only */
13807 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
13808 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13809 		return TEST_SKIPPED;
13810 
13811 	/* Setup Cipher Parameters */
13812 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13813 	ut_params->cipher_xform.next = NULL;
13814 
13815 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
13816 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13817 
13818 	/* Create Crypto session*/
13819 	ut_params->sess = rte_cryptodev_sym_session_create(
13820 			ts_params->valid_devs[0], &ut_params->cipher_xform,
13821 			ts_params->session_mpool);
13822 	TEST_ASSERT(ut_params->sess == NULL,
13823 			"Session creation succeeded unexpectedly");
13824 
13825 	/* Setup HMAC Parameters */
13826 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13827 	ut_params->auth_xform.next = NULL;
13828 
13829 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
13830 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13831 
13832 	/* Create Crypto session*/
13833 	ut_params->sess = rte_cryptodev_sym_session_create(
13834 			ts_params->valid_devs[0], &ut_params->auth_xform,
13835 			ts_params->session_mpool);
13836 	TEST_ASSERT(ut_params->sess == NULL,
13837 			"Session creation succeeded unexpectedly");
13838 
13839 	return TEST_SUCCESS;
13840 }
13841 
13842 
13843 #define NULL_BURST_LENGTH (32)
13844 
13845 static int
13846 test_null_burst_operation(void)
13847 {
13848 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13849 	struct crypto_unittest_params *ut_params = &unittest_params;
13850 
13851 	unsigned i, burst_len = NULL_BURST_LENGTH;
13852 
13853 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
13854 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
13855 
13856 	/* This test is for NULL PMD only */
13857 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
13858 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
13859 		return TEST_SKIPPED;
13860 
13861 	/* Setup Cipher Parameters */
13862 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13863 	ut_params->cipher_xform.next = &ut_params->auth_xform;
13864 
13865 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
13866 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13867 
13868 	/* Setup HMAC Parameters */
13869 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13870 	ut_params->auth_xform.next = NULL;
13871 
13872 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
13873 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13874 
13875 	/* Create Crypto session*/
13876 	ut_params->sess = rte_cryptodev_sym_session_create(
13877 				ts_params->valid_devs[0],
13878 				&ut_params->auth_xform,
13879 				ts_params->session_mpool);
13880 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13881 		return TEST_SKIPPED;
13882 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13883 
13884 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
13885 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
13886 			burst_len, "failed to generate burst of crypto ops");
13887 
13888 	/* Generate an operation for each mbuf in burst */
13889 	for (i = 0; i < burst_len; i++) {
13890 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13891 
13892 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
13893 
13894 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
13895 				sizeof(unsigned));
13896 		*data = i;
13897 
13898 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
13899 
13900 		burst[i]->sym->m_src = m;
13901 	}
13902 
13903 	/* Process crypto operation */
13904 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
13905 			0, burst, burst_len),
13906 			burst_len,
13907 			"Error enqueuing burst");
13908 
13909 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
13910 			0, burst_dequeued, burst_len),
13911 			burst_len,
13912 			"Error dequeuing burst");
13913 
13914 
13915 	for (i = 0; i < burst_len; i++) {
13916 		TEST_ASSERT_EQUAL(
13917 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
13918 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
13919 					uint32_t *),
13920 			"data not as expected");
13921 
13922 		rte_pktmbuf_free(burst[i]->sym->m_src);
13923 		rte_crypto_op_free(burst[i]);
13924 	}
13925 
13926 	return TEST_SUCCESS;
13927 }
13928 
13929 static uint16_t
13930 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13931 		  uint16_t nb_ops, void *user_param)
13932 {
13933 	RTE_SET_USED(dev_id);
13934 	RTE_SET_USED(qp_id);
13935 	RTE_SET_USED(ops);
13936 	RTE_SET_USED(user_param);
13937 
13938 	printf("crypto enqueue callback called\n");
13939 	return nb_ops;
13940 }
13941 
13942 static uint16_t
13943 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
13944 		  uint16_t nb_ops, void *user_param)
13945 {
13946 	RTE_SET_USED(dev_id);
13947 	RTE_SET_USED(qp_id);
13948 	RTE_SET_USED(ops);
13949 	RTE_SET_USED(user_param);
13950 
13951 	printf("crypto dequeue callback called\n");
13952 	return nb_ops;
13953 }
13954 
13955 /*
13956  * Thread using enqueue/dequeue callback with RCU.
13957  */
13958 static int
13959 test_enqdeq_callback_thread(void *arg)
13960 {
13961 	RTE_SET_USED(arg);
13962 	/* DP thread calls rte_cryptodev_enqueue_burst()/
13963 	 * rte_cryptodev_dequeue_burst() and invokes callback.
13964 	 */
13965 	test_null_burst_operation();
13966 	return 0;
13967 }
13968 
13969 static int
13970 test_enq_callback_setup(void)
13971 {
13972 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13973 	struct rte_cryptodev_info dev_info;
13974 	struct rte_cryptodev_qp_conf qp_conf = {
13975 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
13976 	};
13977 
13978 	struct rte_cryptodev_cb *cb;
13979 	uint16_t qp_id = 0;
13980 
13981 	/* Stop the device in case it's started so it can be configured */
13982 	rte_cryptodev_stop(ts_params->valid_devs[0]);
13983 
13984 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13985 
13986 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13987 			&ts_params->conf),
13988 			"Failed to configure cryptodev %u",
13989 			ts_params->valid_devs[0]);
13990 
13991 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
13992 	qp_conf.mp_session = ts_params->session_mpool;
13993 
13994 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13995 			ts_params->valid_devs[0], qp_id, &qp_conf,
13996 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
13997 			"Failed test for "
13998 			"rte_cryptodev_queue_pair_setup: num_inflights "
13999 			"%u on qp %u on cryptodev %u",
14000 			qp_conf.nb_descriptors, qp_id,
14001 			ts_params->valid_devs[0]);
14002 
14003 	/* Test with invalid crypto device */
14004 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
14005 			qp_id, test_enq_callback, NULL);
14006 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14007 			"cryptodev %u did not fail",
14008 			qp_id, RTE_CRYPTO_MAX_DEVS);
14009 
14010 	/* Test with invalid queue pair */
14011 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14012 			dev_info.max_nb_queue_pairs + 1,
14013 			test_enq_callback, NULL);
14014 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14015 			"cryptodev %u did not fail",
14016 			dev_info.max_nb_queue_pairs + 1,
14017 			ts_params->valid_devs[0]);
14018 
14019 	/* Test with NULL callback */
14020 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14021 			qp_id, NULL, NULL);
14022 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14023 			"cryptodev %u did not fail",
14024 			qp_id, ts_params->valid_devs[0]);
14025 
14026 	/* Test with valid configuration */
14027 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14028 			qp_id, test_enq_callback, NULL);
14029 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14030 			"qp %u on cryptodev %u",
14031 			qp_id, ts_params->valid_devs[0]);
14032 
14033 	rte_cryptodev_start(ts_params->valid_devs[0]);
14034 
14035 	/* Launch a thread */
14036 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14037 				rte_get_next_lcore(-1, 1, 0));
14038 
14039 	/* Wait until reader exited. */
14040 	rte_eal_mp_wait_lcore();
14041 
14042 	/* Test with invalid crypto device */
14043 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14044 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14045 			"Expected call to fail as crypto device is invalid");
14046 
14047 	/* Test with invalid queue pair */
14048 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14049 			ts_params->valid_devs[0],
14050 			dev_info.max_nb_queue_pairs + 1, cb),
14051 			"Expected call to fail as queue pair is invalid");
14052 
14053 	/* Test with NULL callback */
14054 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14055 			ts_params->valid_devs[0], qp_id, NULL),
14056 			"Expected call to fail as callback is NULL");
14057 
14058 	/* Test with valid configuration */
14059 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
14060 			ts_params->valid_devs[0], qp_id, cb),
14061 			"Failed test to remove callback on "
14062 			"qp %u on cryptodev %u",
14063 			qp_id, ts_params->valid_devs[0]);
14064 
14065 	return TEST_SUCCESS;
14066 }
14067 
14068 static int
14069 test_deq_callback_setup(void)
14070 {
14071 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14072 	struct rte_cryptodev_info dev_info;
14073 	struct rte_cryptodev_qp_conf qp_conf = {
14074 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
14075 	};
14076 
14077 	struct rte_cryptodev_cb *cb;
14078 	uint16_t qp_id = 0;
14079 
14080 	/* Stop the device in case it's started so it can be configured */
14081 	rte_cryptodev_stop(ts_params->valid_devs[0]);
14082 
14083 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14084 
14085 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14086 			&ts_params->conf),
14087 			"Failed to configure cryptodev %u",
14088 			ts_params->valid_devs[0]);
14089 
14090 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14091 	qp_conf.mp_session = ts_params->session_mpool;
14092 
14093 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14094 			ts_params->valid_devs[0], qp_id, &qp_conf,
14095 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14096 			"Failed test for "
14097 			"rte_cryptodev_queue_pair_setup: num_inflights "
14098 			"%u on qp %u on cryptodev %u",
14099 			qp_conf.nb_descriptors, qp_id,
14100 			ts_params->valid_devs[0]);
14101 
14102 	/* Test with invalid crypto device */
14103 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
14104 			qp_id, test_deq_callback, NULL);
14105 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14106 			"cryptodev %u did not fail",
14107 			qp_id, RTE_CRYPTO_MAX_DEVS);
14108 
14109 	/* Test with invalid queue pair */
14110 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14111 			dev_info.max_nb_queue_pairs + 1,
14112 			test_deq_callback, NULL);
14113 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14114 			"cryptodev %u did not fail",
14115 			dev_info.max_nb_queue_pairs + 1,
14116 			ts_params->valid_devs[0]);
14117 
14118 	/* Test with NULL callback */
14119 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14120 			qp_id, NULL, NULL);
14121 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14122 			"cryptodev %u did not fail",
14123 			qp_id, ts_params->valid_devs[0]);
14124 
14125 	/* Test with valid configuration */
14126 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14127 			qp_id, test_deq_callback, NULL);
14128 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14129 			"qp %u on cryptodev %u",
14130 			qp_id, ts_params->valid_devs[0]);
14131 
14132 	rte_cryptodev_start(ts_params->valid_devs[0]);
14133 
14134 	/* Launch a thread */
14135 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14136 				rte_get_next_lcore(-1, 1, 0));
14137 
14138 	/* Wait until reader exited. */
14139 	rte_eal_mp_wait_lcore();
14140 
14141 	/* Test with invalid crypto device */
14142 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14143 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14144 			"Expected call to fail as crypto device is invalid");
14145 
14146 	/* Test with invalid queue pair */
14147 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14148 			ts_params->valid_devs[0],
14149 			dev_info.max_nb_queue_pairs + 1, cb),
14150 			"Expected call to fail as queue pair is invalid");
14151 
14152 	/* Test with NULL callback */
14153 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14154 			ts_params->valid_devs[0], qp_id, NULL),
14155 			"Expected call to fail as callback is NULL");
14156 
14157 	/* Test with valid configuration */
14158 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
14159 			ts_params->valid_devs[0], qp_id, cb),
14160 			"Failed test to remove callback on "
14161 			"qp %u on cryptodev %u",
14162 			qp_id, ts_params->valid_devs[0]);
14163 
14164 	return TEST_SUCCESS;
14165 }
14166 
14167 static void
14168 generate_gmac_large_plaintext(uint8_t *data)
14169 {
14170 	uint16_t i;
14171 
14172 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
14173 		memcpy(&data[i], &data[0], 32);
14174 }
14175 
14176 static int
14177 create_gmac_operation(enum rte_crypto_auth_operation op,
14178 		const struct gmac_test_data *tdata)
14179 {
14180 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14181 	struct crypto_unittest_params *ut_params = &unittest_params;
14182 	struct rte_crypto_sym_op *sym_op;
14183 
14184 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14185 
14186 	/* Generate Crypto op data structure */
14187 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14188 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14189 	TEST_ASSERT_NOT_NULL(ut_params->op,
14190 			"Failed to allocate symmetric crypto operation struct");
14191 
14192 	sym_op = ut_params->op->sym;
14193 
14194 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14195 			ut_params->ibuf, tdata->gmac_tag.len);
14196 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14197 			"no room to append digest");
14198 
14199 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14200 			ut_params->ibuf, plaintext_pad_len);
14201 
14202 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14203 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14204 				tdata->gmac_tag.len);
14205 		debug_hexdump(stdout, "digest:",
14206 				sym_op->auth.digest.data,
14207 				tdata->gmac_tag.len);
14208 	}
14209 
14210 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14211 			uint8_t *, IV_OFFSET);
14212 
14213 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14214 
14215 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14216 
14217 	sym_op->cipher.data.length = 0;
14218 	sym_op->cipher.data.offset = 0;
14219 
14220 	sym_op->auth.data.offset = 0;
14221 	sym_op->auth.data.length = tdata->plaintext.len;
14222 
14223 	return 0;
14224 }
14225 
14226 static int
14227 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
14228 		const struct gmac_test_data *tdata,
14229 		void *digest_mem, uint64_t digest_phys)
14230 {
14231 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14232 	struct crypto_unittest_params *ut_params = &unittest_params;
14233 	struct rte_crypto_sym_op *sym_op;
14234 
14235 	/* Generate Crypto op data structure */
14236 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14237 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14238 	TEST_ASSERT_NOT_NULL(ut_params->op,
14239 			"Failed to allocate symmetric crypto operation struct");
14240 
14241 	sym_op = ut_params->op->sym;
14242 
14243 	sym_op->auth.digest.data = digest_mem;
14244 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14245 			"no room to append digest");
14246 
14247 	sym_op->auth.digest.phys_addr = digest_phys;
14248 
14249 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14250 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14251 				tdata->gmac_tag.len);
14252 		debug_hexdump(stdout, "digest:",
14253 				sym_op->auth.digest.data,
14254 				tdata->gmac_tag.len);
14255 	}
14256 
14257 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14258 			uint8_t *, IV_OFFSET);
14259 
14260 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14261 
14262 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14263 
14264 	sym_op->cipher.data.length = 0;
14265 	sym_op->cipher.data.offset = 0;
14266 
14267 	sym_op->auth.data.offset = 0;
14268 	sym_op->auth.data.length = tdata->plaintext.len;
14269 
14270 	return 0;
14271 }
14272 
14273 static int create_gmac_session(uint8_t dev_id,
14274 		const struct gmac_test_data *tdata,
14275 		enum rte_crypto_auth_operation auth_op)
14276 {
14277 	uint8_t auth_key[tdata->key.len];
14278 
14279 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14280 	struct crypto_unittest_params *ut_params = &unittest_params;
14281 
14282 	memcpy(auth_key, tdata->key.data, tdata->key.len);
14283 
14284 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14285 	ut_params->auth_xform.next = NULL;
14286 
14287 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
14288 	ut_params->auth_xform.auth.op = auth_op;
14289 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
14290 	ut_params->auth_xform.auth.key.length = tdata->key.len;
14291 	ut_params->auth_xform.auth.key.data = auth_key;
14292 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14293 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
14294 
14295 
14296 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14297 			&ut_params->auth_xform, ts_params->session_mpool);
14298 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14299 		return TEST_SKIPPED;
14300 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14301 
14302 	return 0;
14303 }
14304 
14305 static int
14306 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
14307 {
14308 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14309 	struct crypto_unittest_params *ut_params = &unittest_params;
14310 	struct rte_cryptodev_info dev_info;
14311 
14312 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14313 	uint64_t feat_flags = dev_info.feature_flags;
14314 
14315 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14316 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14317 		printf("Device doesn't support RAW data-path APIs.\n");
14318 		return TEST_SKIPPED;
14319 	}
14320 
14321 	int retval;
14322 
14323 	uint8_t *auth_tag, *plaintext;
14324 	uint16_t plaintext_pad_len;
14325 
14326 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14327 			      "No GMAC length in the source data");
14328 
14329 	/* Verify the capabilities */
14330 	struct rte_cryptodev_sym_capability_idx cap_idx;
14331 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14332 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14333 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14334 			&cap_idx) == NULL)
14335 		return TEST_SKIPPED;
14336 
14337 	retval = create_gmac_session(ts_params->valid_devs[0],
14338 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14339 
14340 	if (retval == TEST_SKIPPED)
14341 		return TEST_SKIPPED;
14342 	if (retval < 0)
14343 		return retval;
14344 
14345 	if (tdata->plaintext.len > MBUF_SIZE)
14346 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14347 	else
14348 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14349 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14350 			"Failed to allocate input buffer in mempool");
14351 
14352 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14353 			rte_pktmbuf_tailroom(ut_params->ibuf));
14354 
14355 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14356 	/*
14357 	 * Runtime generate the large plain text instead of use hard code
14358 	 * plain text vector. It is done to avoid create huge source file
14359 	 * with the test vector.
14360 	 */
14361 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14362 		generate_gmac_large_plaintext(tdata->plaintext.data);
14363 
14364 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14365 				plaintext_pad_len);
14366 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14367 
14368 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14369 	debug_hexdump(stdout, "plaintext:", plaintext,
14370 			tdata->plaintext.len);
14371 
14372 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
14373 			tdata);
14374 
14375 	if (retval < 0)
14376 		return retval;
14377 
14378 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14379 
14380 	ut_params->op->sym->m_src = ut_params->ibuf;
14381 
14382 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14383 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14384 			ut_params->op);
14385 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14386 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14387 					       0);
14388 		if (retval != TEST_SUCCESS)
14389 			return retval;
14390 	} else
14391 		TEST_ASSERT_NOT_NULL(
14392 			process_crypto_request(ts_params->valid_devs[0],
14393 			ut_params->op), "failed to process sym crypto op");
14394 
14395 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14396 			"crypto op processing failed");
14397 
14398 	if (ut_params->op->sym->m_dst) {
14399 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14400 				uint8_t *, plaintext_pad_len);
14401 	} else {
14402 		auth_tag = plaintext + plaintext_pad_len;
14403 	}
14404 
14405 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14406 
14407 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14408 			auth_tag,
14409 			tdata->gmac_tag.data,
14410 			tdata->gmac_tag.len,
14411 			"GMAC Generated auth tag not as expected");
14412 
14413 	return 0;
14414 }
14415 
14416 static int
14417 test_AES_GMAC_authentication_test_case_1(void)
14418 {
14419 	return test_AES_GMAC_authentication(&gmac_test_case_1);
14420 }
14421 
14422 static int
14423 test_AES_GMAC_authentication_test_case_2(void)
14424 {
14425 	return test_AES_GMAC_authentication(&gmac_test_case_2);
14426 }
14427 
14428 static int
14429 test_AES_GMAC_authentication_test_case_3(void)
14430 {
14431 	return test_AES_GMAC_authentication(&gmac_test_case_3);
14432 }
14433 
14434 static int
14435 test_AES_GMAC_authentication_test_case_4(void)
14436 {
14437 	return test_AES_GMAC_authentication(&gmac_test_case_4);
14438 }
14439 
14440 static int
14441 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
14442 {
14443 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14444 	struct crypto_unittest_params *ut_params = &unittest_params;
14445 	int retval;
14446 	uint32_t plaintext_pad_len;
14447 	uint8_t *plaintext;
14448 	struct rte_cryptodev_info dev_info;
14449 
14450 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14451 	uint64_t feat_flags = dev_info.feature_flags;
14452 
14453 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14454 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14455 		printf("Device doesn't support RAW data-path APIs.\n");
14456 		return TEST_SKIPPED;
14457 	}
14458 
14459 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14460 			      "No GMAC length in the source data");
14461 
14462 	/* Verify the capabilities */
14463 	struct rte_cryptodev_sym_capability_idx cap_idx;
14464 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14465 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14466 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14467 			&cap_idx) == NULL)
14468 		return TEST_SKIPPED;
14469 
14470 	retval = create_gmac_session(ts_params->valid_devs[0],
14471 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
14472 
14473 	if (retval == TEST_SKIPPED)
14474 		return TEST_SKIPPED;
14475 	if (retval < 0)
14476 		return retval;
14477 
14478 	if (tdata->plaintext.len > MBUF_SIZE)
14479 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14480 	else
14481 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14482 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14483 			"Failed to allocate input buffer in mempool");
14484 
14485 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14486 			rte_pktmbuf_tailroom(ut_params->ibuf));
14487 
14488 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14489 
14490 	/*
14491 	 * Runtime generate the large plain text instead of use hard code
14492 	 * plain text vector. It is done to avoid create huge source file
14493 	 * with the test vector.
14494 	 */
14495 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14496 		generate_gmac_large_plaintext(tdata->plaintext.data);
14497 
14498 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14499 				plaintext_pad_len);
14500 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14501 
14502 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14503 	debug_hexdump(stdout, "plaintext:", plaintext,
14504 			tdata->plaintext.len);
14505 
14506 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
14507 			tdata);
14508 
14509 	if (retval < 0)
14510 		return retval;
14511 
14512 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14513 
14514 	ut_params->op->sym->m_src = ut_params->ibuf;
14515 
14516 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14517 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14518 			ut_params->op);
14519 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14520 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14521 					       0);
14522 		if (retval != TEST_SUCCESS)
14523 			return retval;
14524 	} else
14525 		TEST_ASSERT_NOT_NULL(
14526 			process_crypto_request(ts_params->valid_devs[0],
14527 			ut_params->op), "failed to process sym crypto op");
14528 
14529 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14530 			"crypto op processing failed");
14531 
14532 	return 0;
14533 
14534 }
14535 
14536 static int
14537 test_AES_GMAC_authentication_verify_test_case_1(void)
14538 {
14539 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
14540 }
14541 
14542 static int
14543 test_AES_GMAC_authentication_verify_test_case_2(void)
14544 {
14545 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
14546 }
14547 
14548 static int
14549 test_AES_GMAC_authentication_verify_test_case_3(void)
14550 {
14551 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
14552 }
14553 
14554 static int
14555 test_AES_GMAC_authentication_verify_test_case_4(void)
14556 {
14557 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
14558 }
14559 
14560 static int
14561 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
14562 				uint32_t fragsz)
14563 {
14564 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14565 	struct crypto_unittest_params *ut_params = &unittest_params;
14566 	struct rte_cryptodev_info dev_info;
14567 	uint64_t feature_flags;
14568 	unsigned int trn_data = 0;
14569 	void *digest_mem = NULL;
14570 	uint32_t segs = 1;
14571 	unsigned int to_trn = 0;
14572 	struct rte_mbuf *buf = NULL;
14573 	uint8_t *auth_tag, *plaintext;
14574 	int retval;
14575 
14576 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14577 			      "No GMAC length in the source data");
14578 
14579 	/* Verify the capabilities */
14580 	struct rte_cryptodev_sym_capability_idx cap_idx;
14581 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14582 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14583 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14584 			&cap_idx) == NULL)
14585 		return TEST_SKIPPED;
14586 
14587 	/* Check for any input SGL support */
14588 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14589 	feature_flags = dev_info.feature_flags;
14590 
14591 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
14592 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
14593 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
14594 		return TEST_SKIPPED;
14595 
14596 	if (fragsz > tdata->plaintext.len)
14597 		fragsz = tdata->plaintext.len;
14598 
14599 	uint16_t plaintext_len = fragsz;
14600 
14601 	retval = create_gmac_session(ts_params->valid_devs[0],
14602 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14603 
14604 	if (retval == TEST_SKIPPED)
14605 		return TEST_SKIPPED;
14606 	if (retval < 0)
14607 		return retval;
14608 
14609 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14610 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14611 			"Failed to allocate input buffer in mempool");
14612 
14613 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14614 			rte_pktmbuf_tailroom(ut_params->ibuf));
14615 
14616 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14617 				plaintext_len);
14618 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14619 
14620 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14621 
14622 	trn_data += plaintext_len;
14623 
14624 	buf = ut_params->ibuf;
14625 
14626 	/*
14627 	 * Loop until no more fragments
14628 	 */
14629 
14630 	while (trn_data < tdata->plaintext.len) {
14631 		++segs;
14632 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14633 				(tdata->plaintext.len - trn_data) : fragsz;
14634 
14635 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14636 		buf = buf->next;
14637 
14638 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14639 				rte_pktmbuf_tailroom(buf));
14640 
14641 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14642 				to_trn);
14643 
14644 		memcpy(plaintext, tdata->plaintext.data + trn_data,
14645 				to_trn);
14646 		trn_data += to_trn;
14647 		if (trn_data  == tdata->plaintext.len)
14648 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14649 					tdata->gmac_tag.len);
14650 	}
14651 	ut_params->ibuf->nb_segs = segs;
14652 
14653 	/*
14654 	 * Place digest at the end of the last buffer
14655 	 */
14656 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14657 
14658 	if (!digest_mem) {
14659 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14660 				+ tdata->gmac_tag.len);
14661 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14662 				tdata->plaintext.len);
14663 	}
14664 
14665 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
14666 			tdata, digest_mem, digest_phys);
14667 
14668 	if (retval < 0)
14669 		return retval;
14670 
14671 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14672 
14673 	ut_params->op->sym->m_src = ut_params->ibuf;
14674 
14675 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14676 		return TEST_SKIPPED;
14677 
14678 	TEST_ASSERT_NOT_NULL(
14679 		process_crypto_request(ts_params->valid_devs[0],
14680 		ut_params->op), "failed to process sym crypto op");
14681 
14682 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14683 			"crypto op processing failed");
14684 
14685 	auth_tag = digest_mem;
14686 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14687 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14688 			auth_tag,
14689 			tdata->gmac_tag.data,
14690 			tdata->gmac_tag.len,
14691 			"GMAC Generated auth tag not as expected");
14692 
14693 	return 0;
14694 }
14695 
14696 /* Segment size not multiple of block size (16B) */
14697 static int
14698 test_AES_GMAC_authentication_SGL_40B(void)
14699 {
14700 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
14701 }
14702 
14703 static int
14704 test_AES_GMAC_authentication_SGL_80B(void)
14705 {
14706 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
14707 }
14708 
14709 static int
14710 test_AES_GMAC_authentication_SGL_2048B(void)
14711 {
14712 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
14713 }
14714 
14715 /* Segment size not multiple of block size (16B) */
14716 static int
14717 test_AES_GMAC_authentication_SGL_2047B(void)
14718 {
14719 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
14720 }
14721 
14722 struct test_crypto_vector {
14723 	enum rte_crypto_cipher_algorithm crypto_algo;
14724 	unsigned int cipher_offset;
14725 	unsigned int cipher_len;
14726 
14727 	struct {
14728 		uint8_t data[64];
14729 		unsigned int len;
14730 	} cipher_key;
14731 
14732 	struct {
14733 		uint8_t data[64];
14734 		unsigned int len;
14735 	} iv;
14736 
14737 	struct {
14738 		const uint8_t *data;
14739 		unsigned int len;
14740 	} plaintext;
14741 
14742 	struct {
14743 		const uint8_t *data;
14744 		unsigned int len;
14745 	} ciphertext;
14746 
14747 	enum rte_crypto_auth_algorithm auth_algo;
14748 	unsigned int auth_offset;
14749 
14750 	struct {
14751 		uint8_t data[128];
14752 		unsigned int len;
14753 	} auth_key;
14754 
14755 	struct {
14756 		const uint8_t *data;
14757 		unsigned int len;
14758 	} aad;
14759 
14760 	struct {
14761 		uint8_t data[128];
14762 		unsigned int len;
14763 	} digest;
14764 };
14765 
14766 static const struct test_crypto_vector
14767 hmac_sha1_test_crypto_vector = {
14768 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14769 	.plaintext = {
14770 		.data = plaintext_hash,
14771 		.len = 512
14772 	},
14773 	.auth_key = {
14774 		.data = {
14775 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14776 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14777 			0xDE, 0xF4, 0xDE, 0xAD
14778 		},
14779 		.len = 20
14780 	},
14781 	.digest = {
14782 		.data = {
14783 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
14784 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
14785 			0x3F, 0x91, 0x64, 0x59
14786 		},
14787 		.len = 20
14788 	}
14789 };
14790 
14791 static const struct test_crypto_vector
14792 aes128_gmac_test_vector = {
14793 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
14794 	.plaintext = {
14795 		.data = plaintext_hash,
14796 		.len = 512
14797 	},
14798 	.iv = {
14799 		.data = {
14800 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14801 			0x08, 0x09, 0x0A, 0x0B
14802 		},
14803 		.len = 12
14804 	},
14805 	.auth_key = {
14806 		.data = {
14807 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14808 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
14809 		},
14810 		.len = 16
14811 	},
14812 	.digest = {
14813 		.data = {
14814 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
14815 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
14816 		},
14817 		.len = 16
14818 	}
14819 };
14820 
14821 static const struct test_crypto_vector
14822 aes128cbc_hmac_sha1_test_vector = {
14823 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14824 	.cipher_offset = 0,
14825 	.cipher_len = 512,
14826 	.cipher_key = {
14827 		.data = {
14828 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14829 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14830 		},
14831 		.len = 16
14832 	},
14833 	.iv = {
14834 		.data = {
14835 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14836 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14837 		},
14838 		.len = 16
14839 	},
14840 	.plaintext = {
14841 		.data = plaintext_hash,
14842 		.len = 512
14843 	},
14844 	.ciphertext = {
14845 		.data = ciphertext512_aes128cbc,
14846 		.len = 512
14847 	},
14848 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14849 	.auth_offset = 0,
14850 	.auth_key = {
14851 		.data = {
14852 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14853 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14854 			0xDE, 0xF4, 0xDE, 0xAD
14855 		},
14856 		.len = 20
14857 	},
14858 	.digest = {
14859 		.data = {
14860 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
14861 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
14862 			0x18, 0x8C, 0x1D, 0x32
14863 		},
14864 		.len = 20
14865 	}
14866 };
14867 
14868 static const struct test_crypto_vector
14869 aes128cbc_hmac_sha1_aad_test_vector = {
14870 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
14871 	.cipher_offset = 8,
14872 	.cipher_len = 496,
14873 	.cipher_key = {
14874 		.data = {
14875 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
14876 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
14877 		},
14878 		.len = 16
14879 	},
14880 	.iv = {
14881 		.data = {
14882 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
14883 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
14884 		},
14885 		.len = 16
14886 	},
14887 	.plaintext = {
14888 		.data = plaintext_hash,
14889 		.len = 512
14890 	},
14891 	.ciphertext = {
14892 		.data = ciphertext512_aes128cbc_aad,
14893 		.len = 512
14894 	},
14895 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
14896 	.auth_offset = 0,
14897 	.auth_key = {
14898 		.data = {
14899 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
14900 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
14901 			0xDE, 0xF4, 0xDE, 0xAD
14902 		},
14903 		.len = 20
14904 	},
14905 	.digest = {
14906 		.data = {
14907 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
14908 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
14909 			0x62, 0x0F, 0xFB, 0x10
14910 		},
14911 		.len = 20
14912 	}
14913 };
14914 
14915 static void
14916 data_corruption(uint8_t *data)
14917 {
14918 	data[0] += 1;
14919 }
14920 
14921 static void
14922 tag_corruption(uint8_t *data, unsigned int tag_offset)
14923 {
14924 	data[tag_offset] += 1;
14925 }
14926 
14927 static int
14928 create_auth_session(struct crypto_unittest_params *ut_params,
14929 		uint8_t dev_id,
14930 		const struct test_crypto_vector *reference,
14931 		enum rte_crypto_auth_operation auth_op)
14932 {
14933 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14934 	uint8_t auth_key[reference->auth_key.len + 1];
14935 
14936 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14937 
14938 	/* Setup Authentication Parameters */
14939 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14940 	ut_params->auth_xform.auth.op = auth_op;
14941 	ut_params->auth_xform.next = NULL;
14942 	ut_params->auth_xform.auth.algo = reference->auth_algo;
14943 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14944 	ut_params->auth_xform.auth.key.data = auth_key;
14945 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
14946 
14947 	/* Create Crypto session*/
14948 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14949 				&ut_params->auth_xform,
14950 				ts_params->session_mpool);
14951 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14952 		return TEST_SKIPPED;
14953 
14954 	return 0;
14955 }
14956 
14957 static int
14958 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
14959 		uint8_t dev_id,
14960 		const struct test_crypto_vector *reference,
14961 		enum rte_crypto_auth_operation auth_op,
14962 		enum rte_crypto_cipher_operation cipher_op)
14963 {
14964 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14965 	uint8_t cipher_key[reference->cipher_key.len + 1];
14966 	uint8_t auth_key[reference->auth_key.len + 1];
14967 
14968 	memcpy(cipher_key, reference->cipher_key.data,
14969 			reference->cipher_key.len);
14970 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14971 
14972 	/* Setup Authentication Parameters */
14973 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14974 	ut_params->auth_xform.auth.op = auth_op;
14975 	ut_params->auth_xform.auth.algo = reference->auth_algo;
14976 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14977 	ut_params->auth_xform.auth.key.data = auth_key;
14978 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
14979 
14980 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
14981 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14982 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
14983 	} else {
14984 		ut_params->auth_xform.next = &ut_params->cipher_xform;
14985 
14986 		/* Setup Cipher Parameters */
14987 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14988 		ut_params->cipher_xform.next = NULL;
14989 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14990 		ut_params->cipher_xform.cipher.op = cipher_op;
14991 		ut_params->cipher_xform.cipher.key.data = cipher_key;
14992 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14993 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14994 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14995 	}
14996 
14997 	/* Create Crypto session*/
14998 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14999 				&ut_params->auth_xform,
15000 				ts_params->session_mpool);
15001 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15002 		return TEST_SKIPPED;
15003 
15004 	return 0;
15005 }
15006 
15007 static int
15008 create_auth_operation(struct crypto_testsuite_params *ts_params,
15009 		struct crypto_unittest_params *ut_params,
15010 		const struct test_crypto_vector *reference,
15011 		unsigned int auth_generate)
15012 {
15013 	/* Generate Crypto op data structure */
15014 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15015 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15016 	TEST_ASSERT_NOT_NULL(ut_params->op,
15017 			"Failed to allocate pktmbuf offload");
15018 
15019 	/* Set crypto operation data parameters */
15020 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15021 
15022 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15023 
15024 	/* set crypto operation source mbuf */
15025 	sym_op->m_src = ut_params->ibuf;
15026 
15027 	/* digest */
15028 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15029 			ut_params->ibuf, reference->digest.len);
15030 
15031 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15032 			"no room to append auth tag");
15033 
15034 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15035 			ut_params->ibuf, reference->plaintext.len);
15036 
15037 	if (auth_generate)
15038 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15039 	else
15040 		memcpy(sym_op->auth.digest.data,
15041 				reference->digest.data,
15042 				reference->digest.len);
15043 
15044 	debug_hexdump(stdout, "digest:",
15045 			sym_op->auth.digest.data,
15046 			reference->digest.len);
15047 
15048 	sym_op->auth.data.length = reference->plaintext.len;
15049 	sym_op->auth.data.offset = 0;
15050 
15051 	return 0;
15052 }
15053 
15054 static int
15055 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
15056 		struct crypto_unittest_params *ut_params,
15057 		const struct test_crypto_vector *reference,
15058 		unsigned int auth_generate)
15059 {
15060 	/* Generate Crypto op data structure */
15061 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15062 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15063 	TEST_ASSERT_NOT_NULL(ut_params->op,
15064 			"Failed to allocate pktmbuf offload");
15065 
15066 	/* Set crypto operation data parameters */
15067 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15068 
15069 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15070 
15071 	/* set crypto operation source mbuf */
15072 	sym_op->m_src = ut_params->ibuf;
15073 
15074 	/* digest */
15075 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15076 			ut_params->ibuf, reference->digest.len);
15077 
15078 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15079 			"no room to append auth tag");
15080 
15081 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15082 			ut_params->ibuf, reference->ciphertext.len);
15083 
15084 	if (auth_generate)
15085 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15086 	else
15087 		memcpy(sym_op->auth.digest.data,
15088 				reference->digest.data,
15089 				reference->digest.len);
15090 
15091 	debug_hexdump(stdout, "digest:",
15092 			sym_op->auth.digest.data,
15093 			reference->digest.len);
15094 
15095 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15096 			reference->iv.data, reference->iv.len);
15097 
15098 	sym_op->cipher.data.length = 0;
15099 	sym_op->cipher.data.offset = 0;
15100 
15101 	sym_op->auth.data.length = reference->plaintext.len;
15102 	sym_op->auth.data.offset = 0;
15103 
15104 	return 0;
15105 }
15106 
15107 static int
15108 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
15109 		struct crypto_unittest_params *ut_params,
15110 		const struct test_crypto_vector *reference,
15111 		unsigned int auth_generate)
15112 {
15113 	/* Generate Crypto op data structure */
15114 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15115 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15116 	TEST_ASSERT_NOT_NULL(ut_params->op,
15117 			"Failed to allocate pktmbuf offload");
15118 
15119 	/* Set crypto operation data parameters */
15120 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15121 
15122 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15123 
15124 	/* set crypto operation source mbuf */
15125 	sym_op->m_src = ut_params->ibuf;
15126 
15127 	/* digest */
15128 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15129 			ut_params->ibuf, reference->digest.len);
15130 
15131 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15132 			"no room to append auth tag");
15133 
15134 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15135 			ut_params->ibuf, reference->ciphertext.len);
15136 
15137 	if (auth_generate)
15138 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15139 	else
15140 		memcpy(sym_op->auth.digest.data,
15141 				reference->digest.data,
15142 				reference->digest.len);
15143 
15144 	debug_hexdump(stdout, "digest:",
15145 			sym_op->auth.digest.data,
15146 			reference->digest.len);
15147 
15148 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15149 			reference->iv.data, reference->iv.len);
15150 
15151 	sym_op->cipher.data.length = reference->cipher_len;
15152 	sym_op->cipher.data.offset = reference->cipher_offset;
15153 
15154 	sym_op->auth.data.length = reference->plaintext.len;
15155 	sym_op->auth.data.offset = reference->auth_offset;
15156 
15157 	return 0;
15158 }
15159 
15160 static int
15161 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15162 		struct crypto_unittest_params *ut_params,
15163 		const struct test_crypto_vector *reference)
15164 {
15165 	return create_auth_operation(ts_params, ut_params, reference, 0);
15166 }
15167 
15168 static int
15169 create_auth_verify_GMAC_operation(
15170 		struct crypto_testsuite_params *ts_params,
15171 		struct crypto_unittest_params *ut_params,
15172 		const struct test_crypto_vector *reference)
15173 {
15174 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
15175 }
15176 
15177 static int
15178 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15179 		struct crypto_unittest_params *ut_params,
15180 		const struct test_crypto_vector *reference)
15181 {
15182 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
15183 }
15184 
15185 static int
15186 test_authentication_verify_fail_when_data_corruption(
15187 		struct crypto_testsuite_params *ts_params,
15188 		struct crypto_unittest_params *ut_params,
15189 		const struct test_crypto_vector *reference,
15190 		unsigned int data_corrupted)
15191 {
15192 	int retval;
15193 
15194 	uint8_t *plaintext;
15195 	struct rte_cryptodev_info dev_info;
15196 
15197 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15198 	uint64_t feat_flags = dev_info.feature_flags;
15199 
15200 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15201 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15202 		printf("Device doesn't support RAW data-path APIs.\n");
15203 		return TEST_SKIPPED;
15204 	}
15205 
15206 	/* Verify the capabilities */
15207 	struct rte_cryptodev_sym_capability_idx cap_idx;
15208 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15209 	cap_idx.algo.auth = reference->auth_algo;
15210 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15211 			&cap_idx) == NULL)
15212 		return TEST_SKIPPED;
15213 
15214 
15215 	/* Create session */
15216 	retval = create_auth_session(ut_params,
15217 			ts_params->valid_devs[0],
15218 			reference,
15219 			RTE_CRYPTO_AUTH_OP_VERIFY);
15220 
15221 	if (retval == TEST_SKIPPED)
15222 		return TEST_SKIPPED;
15223 	if (retval < 0)
15224 		return retval;
15225 
15226 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15227 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15228 			"Failed to allocate input buffer in mempool");
15229 
15230 	/* clear mbuf payload */
15231 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15232 			rte_pktmbuf_tailroom(ut_params->ibuf));
15233 
15234 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15235 			reference->plaintext.len);
15236 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15237 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15238 
15239 	debug_hexdump(stdout, "plaintext:", plaintext,
15240 		reference->plaintext.len);
15241 
15242 	/* Create operation */
15243 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
15244 
15245 	if (retval < 0)
15246 		return retval;
15247 
15248 	if (data_corrupted)
15249 		data_corruption(plaintext);
15250 	else
15251 		tag_corruption(plaintext, reference->plaintext.len);
15252 
15253 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15254 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15255 			ut_params->op);
15256 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15257 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15258 			"authentication not failed");
15259 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15260 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15261 					       0);
15262 		if (retval != TEST_SUCCESS)
15263 			return retval;
15264 	} else {
15265 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15266 			ut_params->op);
15267 	}
15268 	if (ut_params->op == NULL)
15269 		return 0;
15270 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
15271 		return 0;
15272 
15273 	return -1;
15274 }
15275 
15276 static int
15277 test_authentication_verify_GMAC_fail_when_corruption(
15278 		struct crypto_testsuite_params *ts_params,
15279 		struct crypto_unittest_params *ut_params,
15280 		const struct test_crypto_vector *reference,
15281 		unsigned int data_corrupted)
15282 {
15283 	int retval;
15284 	uint8_t *plaintext;
15285 	struct rte_cryptodev_info dev_info;
15286 
15287 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15288 	uint64_t feat_flags = dev_info.feature_flags;
15289 
15290 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15291 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15292 		printf("Device doesn't support RAW data-path APIs.\n");
15293 		return TEST_SKIPPED;
15294 	}
15295 
15296 	/* Verify the capabilities */
15297 	struct rte_cryptodev_sym_capability_idx cap_idx;
15298 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15299 	cap_idx.algo.auth = reference->auth_algo;
15300 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15301 			&cap_idx) == NULL)
15302 		return TEST_SKIPPED;
15303 
15304 	/* Create session */
15305 	retval = create_auth_cipher_session(ut_params,
15306 			ts_params->valid_devs[0],
15307 			reference,
15308 			RTE_CRYPTO_AUTH_OP_VERIFY,
15309 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
15310 	if (retval == TEST_SKIPPED)
15311 		return TEST_SKIPPED;
15312 	if (retval < 0)
15313 		return retval;
15314 
15315 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15316 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15317 			"Failed to allocate input buffer in mempool");
15318 
15319 	/* clear mbuf payload */
15320 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15321 			rte_pktmbuf_tailroom(ut_params->ibuf));
15322 
15323 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15324 			reference->plaintext.len);
15325 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15326 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15327 
15328 	debug_hexdump(stdout, "plaintext:", plaintext,
15329 		reference->plaintext.len);
15330 
15331 	/* Create operation */
15332 	retval = create_auth_verify_GMAC_operation(ts_params,
15333 			ut_params,
15334 			reference);
15335 
15336 	if (retval < 0)
15337 		return retval;
15338 
15339 	if (data_corrupted)
15340 		data_corruption(plaintext);
15341 	else
15342 		tag_corruption(plaintext, reference->aad.len);
15343 
15344 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15345 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15346 			ut_params->op);
15347 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15348 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15349 			"authentication not failed");
15350 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15351 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15352 					       0);
15353 		if (retval != TEST_SUCCESS)
15354 			return retval;
15355 	} else {
15356 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15357 			ut_params->op);
15358 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15359 	}
15360 
15361 	return 0;
15362 }
15363 
15364 static int
15365 test_authenticated_decryption_fail_when_corruption(
15366 		struct crypto_testsuite_params *ts_params,
15367 		struct crypto_unittest_params *ut_params,
15368 		const struct test_crypto_vector *reference,
15369 		unsigned int data_corrupted)
15370 {
15371 	int retval;
15372 
15373 	uint8_t *ciphertext;
15374 	struct rte_cryptodev_info dev_info;
15375 
15376 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15377 	uint64_t feat_flags = dev_info.feature_flags;
15378 
15379 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15380 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15381 		printf("Device doesn't support RAW data-path APIs.\n");
15382 		return TEST_SKIPPED;
15383 	}
15384 
15385 	/* Verify the capabilities */
15386 	struct rte_cryptodev_sym_capability_idx cap_idx;
15387 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15388 	cap_idx.algo.auth = reference->auth_algo;
15389 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15390 			&cap_idx) == NULL)
15391 		return TEST_SKIPPED;
15392 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15393 	cap_idx.algo.cipher = reference->crypto_algo;
15394 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15395 			&cap_idx) == NULL)
15396 		return TEST_SKIPPED;
15397 
15398 	/* Create session */
15399 	retval = create_auth_cipher_session(ut_params,
15400 			ts_params->valid_devs[0],
15401 			reference,
15402 			RTE_CRYPTO_AUTH_OP_VERIFY,
15403 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
15404 	if (retval == TEST_SKIPPED)
15405 		return TEST_SKIPPED;
15406 	if (retval < 0)
15407 		return retval;
15408 
15409 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15410 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15411 			"Failed to allocate input buffer in mempool");
15412 
15413 	/* clear mbuf payload */
15414 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15415 			rte_pktmbuf_tailroom(ut_params->ibuf));
15416 
15417 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15418 			reference->ciphertext.len);
15419 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15420 	memcpy(ciphertext, reference->ciphertext.data,
15421 			reference->ciphertext.len);
15422 
15423 	/* Create operation */
15424 	retval = create_cipher_auth_verify_operation(ts_params,
15425 			ut_params,
15426 			reference);
15427 
15428 	if (retval < 0)
15429 		return retval;
15430 
15431 	if (data_corrupted)
15432 		data_corruption(ciphertext);
15433 	else
15434 		tag_corruption(ciphertext, reference->ciphertext.len);
15435 
15436 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15437 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15438 			ut_params->op);
15439 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15440 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15441 			"authentication not failed");
15442 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15443 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15444 					       0);
15445 		if (retval != TEST_SUCCESS)
15446 			return retval;
15447 	} else {
15448 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15449 			ut_params->op);
15450 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15451 	}
15452 
15453 	return 0;
15454 }
15455 
15456 static int
15457 test_authenticated_encrypt_with_esn(
15458 		struct crypto_testsuite_params *ts_params,
15459 		struct crypto_unittest_params *ut_params,
15460 		const struct test_crypto_vector *reference)
15461 {
15462 	int retval;
15463 
15464 	uint8_t *authciphertext, *plaintext, *auth_tag;
15465 	uint16_t plaintext_pad_len;
15466 	uint8_t cipher_key[reference->cipher_key.len + 1];
15467 	uint8_t auth_key[reference->auth_key.len + 1];
15468 	struct rte_cryptodev_info dev_info;
15469 
15470 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15471 	uint64_t feat_flags = dev_info.feature_flags;
15472 
15473 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15474 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15475 		printf("Device doesn't support RAW data-path APIs.\n");
15476 		return TEST_SKIPPED;
15477 	}
15478 
15479 	/* Verify the capabilities */
15480 	struct rte_cryptodev_sym_capability_idx cap_idx;
15481 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15482 	cap_idx.algo.auth = reference->auth_algo;
15483 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15484 			&cap_idx) == NULL)
15485 		return TEST_SKIPPED;
15486 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15487 	cap_idx.algo.cipher = reference->crypto_algo;
15488 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15489 			&cap_idx) == NULL)
15490 		return TEST_SKIPPED;
15491 
15492 	/* Create session */
15493 	memcpy(cipher_key, reference->cipher_key.data,
15494 			reference->cipher_key.len);
15495 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15496 
15497 	/* Setup Cipher Parameters */
15498 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15499 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15500 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15501 	ut_params->cipher_xform.cipher.key.data = cipher_key;
15502 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15503 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15504 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15505 
15506 	ut_params->cipher_xform.next = &ut_params->auth_xform;
15507 
15508 	/* Setup Authentication Parameters */
15509 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15510 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15511 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15512 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15513 	ut_params->auth_xform.auth.key.data = auth_key;
15514 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15515 	ut_params->auth_xform.next = NULL;
15516 
15517 	/* Create Crypto session*/
15518 	ut_params->sess = rte_cryptodev_sym_session_create(
15519 			ts_params->valid_devs[0], &ut_params->cipher_xform,
15520 			ts_params->session_mpool);
15521 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15522 		return TEST_SKIPPED;
15523 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15524 
15525 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15526 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15527 			"Failed to allocate input buffer in mempool");
15528 
15529 	/* clear mbuf payload */
15530 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15531 			rte_pktmbuf_tailroom(ut_params->ibuf));
15532 
15533 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15534 			reference->plaintext.len);
15535 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15536 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15537 
15538 	/* Create operation */
15539 	retval = create_cipher_auth_operation(ts_params,
15540 			ut_params,
15541 			reference, 0);
15542 
15543 	if (retval < 0)
15544 		return retval;
15545 
15546 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15547 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15548 			ut_params->op);
15549 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15550 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15551 					       0);
15552 		if (retval != TEST_SUCCESS)
15553 			return retval;
15554 	} else
15555 		ut_params->op = process_crypto_request(
15556 			ts_params->valid_devs[0], ut_params->op);
15557 
15558 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
15559 
15560 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15561 			"crypto op processing failed");
15562 
15563 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
15564 
15565 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
15566 			ut_params->op->sym->auth.data.offset);
15567 	auth_tag = authciphertext + plaintext_pad_len;
15568 	debug_hexdump(stdout, "ciphertext:", authciphertext,
15569 			reference->ciphertext.len);
15570 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
15571 
15572 	/* Validate obuf */
15573 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15574 			authciphertext,
15575 			reference->ciphertext.data,
15576 			reference->ciphertext.len,
15577 			"Ciphertext data not as expected");
15578 
15579 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15580 			auth_tag,
15581 			reference->digest.data,
15582 			reference->digest.len,
15583 			"Generated digest not as expected");
15584 
15585 	return TEST_SUCCESS;
15586 
15587 }
15588 
15589 static int
15590 test_authenticated_decrypt_with_esn(
15591 		struct crypto_testsuite_params *ts_params,
15592 		struct crypto_unittest_params *ut_params,
15593 		const struct test_crypto_vector *reference)
15594 {
15595 	int retval;
15596 
15597 	uint8_t *ciphertext;
15598 	uint8_t cipher_key[reference->cipher_key.len + 1];
15599 	uint8_t auth_key[reference->auth_key.len + 1];
15600 	struct rte_cryptodev_info dev_info;
15601 
15602 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15603 	uint64_t feat_flags = dev_info.feature_flags;
15604 
15605 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15606 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15607 		printf("Device doesn't support RAW data-path APIs.\n");
15608 		return TEST_SKIPPED;
15609 	}
15610 
15611 	/* Verify the capabilities */
15612 	struct rte_cryptodev_sym_capability_idx cap_idx;
15613 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15614 	cap_idx.algo.auth = reference->auth_algo;
15615 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15616 			&cap_idx) == NULL)
15617 		return TEST_SKIPPED;
15618 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15619 	cap_idx.algo.cipher = reference->crypto_algo;
15620 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15621 			&cap_idx) == NULL)
15622 		return TEST_SKIPPED;
15623 
15624 	/* Create session */
15625 	memcpy(cipher_key, reference->cipher_key.data,
15626 			reference->cipher_key.len);
15627 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15628 
15629 	/* Setup Authentication Parameters */
15630 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15631 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
15632 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15633 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15634 	ut_params->auth_xform.auth.key.data = auth_key;
15635 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15636 	ut_params->auth_xform.next = &ut_params->cipher_xform;
15637 
15638 	/* Setup Cipher Parameters */
15639 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15640 	ut_params->cipher_xform.next = NULL;
15641 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15642 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
15643 	ut_params->cipher_xform.cipher.key.data = cipher_key;
15644 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15645 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15646 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15647 
15648 	/* Create Crypto session*/
15649 	ut_params->sess = rte_cryptodev_sym_session_create(
15650 			ts_params->valid_devs[0], &ut_params->auth_xform,
15651 			ts_params->session_mpool);
15652 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15653 		return TEST_SKIPPED;
15654 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15655 
15656 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15657 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15658 			"Failed to allocate input buffer in mempool");
15659 
15660 	/* clear mbuf payload */
15661 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15662 			rte_pktmbuf_tailroom(ut_params->ibuf));
15663 
15664 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15665 			reference->ciphertext.len);
15666 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15667 	memcpy(ciphertext, reference->ciphertext.data,
15668 			reference->ciphertext.len);
15669 
15670 	/* Create operation */
15671 	retval = create_cipher_auth_verify_operation(ts_params,
15672 			ut_params,
15673 			reference);
15674 
15675 	if (retval < 0)
15676 		return retval;
15677 
15678 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15679 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15680 			ut_params->op);
15681 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15682 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15683 					       0);
15684 		if (retval != TEST_SUCCESS)
15685 			return retval;
15686 	} else
15687 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15688 			ut_params->op);
15689 
15690 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
15691 	TEST_ASSERT_EQUAL(ut_params->op->status,
15692 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15693 			"crypto op processing passed");
15694 
15695 	ut_params->obuf = ut_params->op->sym->m_src;
15696 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
15697 
15698 	return 0;
15699 }
15700 
15701 static int
15702 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
15703 		const struct aead_test_data *tdata,
15704 		void *digest_mem, uint64_t digest_phys)
15705 {
15706 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15707 	struct crypto_unittest_params *ut_params = &unittest_params;
15708 
15709 	const unsigned int auth_tag_len = tdata->auth_tag.len;
15710 	const unsigned int iv_len = tdata->iv.len;
15711 	unsigned int aad_len = tdata->aad.len;
15712 	unsigned int aad_len_pad = 0;
15713 
15714 	/* Generate Crypto op data structure */
15715 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15716 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15717 	TEST_ASSERT_NOT_NULL(ut_params->op,
15718 		"Failed to allocate symmetric crypto operation struct");
15719 
15720 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15721 
15722 	sym_op->aead.digest.data = digest_mem;
15723 
15724 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
15725 			"no room to append digest");
15726 
15727 	sym_op->aead.digest.phys_addr = digest_phys;
15728 
15729 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
15730 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
15731 				auth_tag_len);
15732 		debug_hexdump(stdout, "digest:",
15733 				sym_op->aead.digest.data,
15734 				auth_tag_len);
15735 	}
15736 
15737 	/* Append aad data */
15738 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
15739 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15740 				uint8_t *, IV_OFFSET);
15741 
15742 		/* Copy IV 1 byte after the IV pointer, according to the API */
15743 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
15744 
15745 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
15746 
15747 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15748 				ut_params->ibuf, aad_len);
15749 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15750 				"no room to prepend aad");
15751 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15752 				ut_params->ibuf);
15753 
15754 		memset(sym_op->aead.aad.data, 0, aad_len);
15755 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
15756 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15757 
15758 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15759 		debug_hexdump(stdout, "aad:",
15760 				sym_op->aead.aad.data, aad_len);
15761 	} else {
15762 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15763 				uint8_t *, IV_OFFSET);
15764 
15765 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
15766 
15767 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
15768 
15769 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
15770 				ut_params->ibuf, aad_len_pad);
15771 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
15772 				"no room to prepend aad");
15773 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
15774 				ut_params->ibuf);
15775 
15776 		memset(sym_op->aead.aad.data, 0, aad_len);
15777 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
15778 
15779 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
15780 		debug_hexdump(stdout, "aad:",
15781 				sym_op->aead.aad.data, aad_len);
15782 	}
15783 
15784 	sym_op->aead.data.length = tdata->plaintext.len;
15785 	sym_op->aead.data.offset = aad_len_pad;
15786 
15787 	return 0;
15788 }
15789 
15790 #define SGL_MAX_NO	16
15791 
15792 static int
15793 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
15794 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
15795 {
15796 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15797 	struct crypto_unittest_params *ut_params = &unittest_params;
15798 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
15799 	int retval;
15800 	int to_trn = 0;
15801 	int to_trn_tbl[SGL_MAX_NO];
15802 	int segs = 1;
15803 	unsigned int trn_data = 0;
15804 	uint8_t *plaintext, *ciphertext, *auth_tag;
15805 	struct rte_cryptodev_info dev_info;
15806 
15807 	/* Verify the capabilities */
15808 	struct rte_cryptodev_sym_capability_idx cap_idx;
15809 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
15810 	cap_idx.algo.aead = tdata->algo;
15811 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15812 			&cap_idx) == NULL)
15813 		return TEST_SKIPPED;
15814 
15815 	/*
15816 	 * SGL not supported on AESNI_MB PMD CPU crypto,
15817 	 * OOP not supported on AESNI_GCM CPU crypto
15818 	 */
15819 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
15820 			(gbl_driver_id == rte_cryptodev_driver_id_get(
15821 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
15822 		return TEST_SKIPPED;
15823 
15824 	/* Detailed check for the particular SGL support flag */
15825 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15826 	if (!oop) {
15827 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
15828 		if (sgl_in && (!(dev_info.feature_flags &
15829 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
15830 			return TEST_SKIPPED;
15831 
15832 		uint64_t feat_flags = dev_info.feature_flags;
15833 
15834 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15835 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15836 			printf("Device doesn't support RAW data-path APIs.\n");
15837 			return TEST_SKIPPED;
15838 		}
15839 	} else {
15840 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
15841 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
15842 				tdata->plaintext.len;
15843 		/* Raw data path API does not support OOP */
15844 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
15845 			return TEST_SKIPPED;
15846 		if (sgl_in && !sgl_out) {
15847 			if (!(dev_info.feature_flags &
15848 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
15849 				return TEST_SKIPPED;
15850 		} else if (!sgl_in && sgl_out) {
15851 			if (!(dev_info.feature_flags &
15852 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
15853 				return TEST_SKIPPED;
15854 		} else if (sgl_in && sgl_out) {
15855 			if (!(dev_info.feature_flags &
15856 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
15857 				return TEST_SKIPPED;
15858 		}
15859 	}
15860 
15861 	if (fragsz > tdata->plaintext.len)
15862 		fragsz = tdata->plaintext.len;
15863 
15864 	uint16_t plaintext_len = fragsz;
15865 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
15866 
15867 	if (fragsz_oop > tdata->plaintext.len)
15868 		frag_size_oop = tdata->plaintext.len;
15869 
15870 	int ecx = 0;
15871 	void *digest_mem = NULL;
15872 
15873 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
15874 
15875 	if (tdata->plaintext.len % fragsz != 0) {
15876 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
15877 			return 1;
15878 	}	else {
15879 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
15880 			return 1;
15881 	}
15882 
15883 	/*
15884 	 * For out-op-place we need to alloc another mbuf
15885 	 */
15886 	if (oop) {
15887 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15888 		rte_pktmbuf_append(ut_params->obuf,
15889 				frag_size_oop + prepend_len);
15890 		buf_oop = ut_params->obuf;
15891 	}
15892 
15893 	/* Create AEAD session */
15894 	retval = create_aead_session(ts_params->valid_devs[0],
15895 			tdata->algo,
15896 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
15897 			tdata->key.data, tdata->key.len,
15898 			tdata->aad.len, tdata->auth_tag.len,
15899 			tdata->iv.len);
15900 	if (retval < 0)
15901 		return retval;
15902 
15903 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15904 
15905 	/* clear mbuf payload */
15906 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15907 			rte_pktmbuf_tailroom(ut_params->ibuf));
15908 
15909 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15910 			plaintext_len);
15911 
15912 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15913 
15914 	trn_data += plaintext_len;
15915 
15916 	buf = ut_params->ibuf;
15917 
15918 	/*
15919 	 * Loop until no more fragments
15920 	 */
15921 
15922 	while (trn_data < tdata->plaintext.len) {
15923 		++segs;
15924 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15925 				(tdata->plaintext.len - trn_data) : fragsz;
15926 
15927 		to_trn_tbl[ecx++] = to_trn;
15928 
15929 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15930 		buf = buf->next;
15931 
15932 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15933 				rte_pktmbuf_tailroom(buf));
15934 
15935 		/* OOP */
15936 		if (oop && !fragsz_oop) {
15937 			buf_last_oop = buf_oop->next =
15938 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
15939 			buf_oop = buf_oop->next;
15940 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15941 					0, rte_pktmbuf_tailroom(buf_oop));
15942 			rte_pktmbuf_append(buf_oop, to_trn);
15943 		}
15944 
15945 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15946 				to_trn);
15947 
15948 		memcpy(plaintext, tdata->plaintext.data + trn_data,
15949 				to_trn);
15950 		trn_data += to_trn;
15951 		if (trn_data  == tdata->plaintext.len) {
15952 			if (oop) {
15953 				if (!fragsz_oop)
15954 					digest_mem = rte_pktmbuf_append(buf_oop,
15955 						tdata->auth_tag.len);
15956 			} else
15957 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15958 					tdata->auth_tag.len);
15959 		}
15960 	}
15961 
15962 	uint64_t digest_phys = 0;
15963 
15964 	ut_params->ibuf->nb_segs = segs;
15965 
15966 	segs = 1;
15967 	if (fragsz_oop && oop) {
15968 		to_trn = 0;
15969 		ecx = 0;
15970 
15971 		if (frag_size_oop == tdata->plaintext.len) {
15972 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
15973 				tdata->auth_tag.len);
15974 
15975 			digest_phys = rte_pktmbuf_iova_offset(
15976 					ut_params->obuf,
15977 					tdata->plaintext.len + prepend_len);
15978 		}
15979 
15980 		trn_data = frag_size_oop;
15981 		while (trn_data < tdata->plaintext.len) {
15982 			++segs;
15983 			to_trn =
15984 				(tdata->plaintext.len - trn_data <
15985 						frag_size_oop) ?
15986 				(tdata->plaintext.len - trn_data) :
15987 						frag_size_oop;
15988 
15989 			to_trn_tbl[ecx++] = to_trn;
15990 
15991 			buf_last_oop = buf_oop->next =
15992 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
15993 			buf_oop = buf_oop->next;
15994 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
15995 					0, rte_pktmbuf_tailroom(buf_oop));
15996 			rte_pktmbuf_append(buf_oop, to_trn);
15997 
15998 			trn_data += to_trn;
15999 
16000 			if (trn_data  == tdata->plaintext.len) {
16001 				digest_mem = rte_pktmbuf_append(buf_oop,
16002 					tdata->auth_tag.len);
16003 			}
16004 		}
16005 
16006 		ut_params->obuf->nb_segs = segs;
16007 	}
16008 
16009 	/*
16010 	 * Place digest at the end of the last buffer
16011 	 */
16012 	if (!digest_phys)
16013 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
16014 	if (oop && buf_last_oop)
16015 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
16016 
16017 	if (!digest_mem && !oop) {
16018 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16019 				+ tdata->auth_tag.len);
16020 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
16021 				tdata->plaintext.len);
16022 	}
16023 
16024 	/* Create AEAD operation */
16025 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
16026 			tdata, digest_mem, digest_phys);
16027 
16028 	if (retval < 0)
16029 		return retval;
16030 
16031 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16032 
16033 	ut_params->op->sym->m_src = ut_params->ibuf;
16034 	if (oop)
16035 		ut_params->op->sym->m_dst = ut_params->obuf;
16036 
16037 	/* Process crypto operation */
16038 	if (oop == IN_PLACE &&
16039 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16040 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
16041 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16042 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
16043 					       0);
16044 		if (retval != TEST_SUCCESS)
16045 			return retval;
16046 	} else
16047 		TEST_ASSERT_NOT_NULL(
16048 			process_crypto_request(ts_params->valid_devs[0],
16049 			ut_params->op), "failed to process sym crypto op");
16050 
16051 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16052 			"crypto op processing failed");
16053 
16054 
16055 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
16056 			uint8_t *, prepend_len);
16057 	if (oop) {
16058 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
16059 				uint8_t *, prepend_len);
16060 	}
16061 
16062 	if (fragsz_oop)
16063 		fragsz = fragsz_oop;
16064 
16065 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16066 			ciphertext,
16067 			tdata->ciphertext.data,
16068 			fragsz,
16069 			"Ciphertext data not as expected");
16070 
16071 	buf = ut_params->op->sym->m_src->next;
16072 	if (oop)
16073 		buf = ut_params->op->sym->m_dst->next;
16074 
16075 	unsigned int off = fragsz;
16076 
16077 	ecx = 0;
16078 	while (buf) {
16079 		ciphertext = rte_pktmbuf_mtod(buf,
16080 				uint8_t *);
16081 
16082 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
16083 				ciphertext,
16084 				tdata->ciphertext.data + off,
16085 				to_trn_tbl[ecx],
16086 				"Ciphertext data not as expected");
16087 
16088 		off += to_trn_tbl[ecx++];
16089 		buf = buf->next;
16090 	}
16091 
16092 	auth_tag = digest_mem;
16093 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16094 			auth_tag,
16095 			tdata->auth_tag.data,
16096 			tdata->auth_tag.len,
16097 			"Generated auth tag not as expected");
16098 
16099 	return 0;
16100 }
16101 
16102 static int
16103 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
16104 {
16105 	return test_authenticated_encryption_SGL(
16106 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
16107 }
16108 
16109 static int
16110 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
16111 {
16112 	return test_authenticated_encryption_SGL(
16113 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
16114 }
16115 
16116 static int
16117 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
16118 {
16119 	return test_authenticated_encryption_SGL(
16120 			&gcm_test_case_8, OUT_OF_PLACE, 400,
16121 			gcm_test_case_8.plaintext.len);
16122 }
16123 
16124 static int
16125 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
16126 {
16127 	/* This test is not for OPENSSL PMD */
16128 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
16129 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
16130 		return TEST_SKIPPED;
16131 
16132 	return test_authenticated_encryption_SGL(
16133 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
16134 }
16135 
16136 static int
16137 test_authentication_verify_fail_when_data_corrupted(
16138 		struct crypto_testsuite_params *ts_params,
16139 		struct crypto_unittest_params *ut_params,
16140 		const struct test_crypto_vector *reference)
16141 {
16142 	return test_authentication_verify_fail_when_data_corruption(
16143 			ts_params, ut_params, reference, 1);
16144 }
16145 
16146 static int
16147 test_authentication_verify_fail_when_tag_corrupted(
16148 		struct crypto_testsuite_params *ts_params,
16149 		struct crypto_unittest_params *ut_params,
16150 		const struct test_crypto_vector *reference)
16151 {
16152 	return test_authentication_verify_fail_when_data_corruption(
16153 			ts_params, ut_params, reference, 0);
16154 }
16155 
16156 static int
16157 test_authentication_verify_GMAC_fail_when_data_corrupted(
16158 		struct crypto_testsuite_params *ts_params,
16159 		struct crypto_unittest_params *ut_params,
16160 		const struct test_crypto_vector *reference)
16161 {
16162 	return test_authentication_verify_GMAC_fail_when_corruption(
16163 			ts_params, ut_params, reference, 1);
16164 }
16165 
16166 static int
16167 test_authentication_verify_GMAC_fail_when_tag_corrupted(
16168 		struct crypto_testsuite_params *ts_params,
16169 		struct crypto_unittest_params *ut_params,
16170 		const struct test_crypto_vector *reference)
16171 {
16172 	return test_authentication_verify_GMAC_fail_when_corruption(
16173 			ts_params, ut_params, reference, 0);
16174 }
16175 
16176 static int
16177 test_authenticated_decryption_fail_when_data_corrupted(
16178 		struct crypto_testsuite_params *ts_params,
16179 		struct crypto_unittest_params *ut_params,
16180 		const struct test_crypto_vector *reference)
16181 {
16182 	return test_authenticated_decryption_fail_when_corruption(
16183 			ts_params, ut_params, reference, 1);
16184 }
16185 
16186 static int
16187 test_authenticated_decryption_fail_when_tag_corrupted(
16188 		struct crypto_testsuite_params *ts_params,
16189 		struct crypto_unittest_params *ut_params,
16190 		const struct test_crypto_vector *reference)
16191 {
16192 	return test_authenticated_decryption_fail_when_corruption(
16193 			ts_params, ut_params, reference, 0);
16194 }
16195 
16196 static int
16197 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
16198 {
16199 	return test_authentication_verify_fail_when_data_corrupted(
16200 			&testsuite_params, &unittest_params,
16201 			&hmac_sha1_test_crypto_vector);
16202 }
16203 
16204 static int
16205 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
16206 {
16207 	return test_authentication_verify_fail_when_tag_corrupted(
16208 			&testsuite_params, &unittest_params,
16209 			&hmac_sha1_test_crypto_vector);
16210 }
16211 
16212 static int
16213 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
16214 {
16215 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
16216 			&testsuite_params, &unittest_params,
16217 			&aes128_gmac_test_vector);
16218 }
16219 
16220 static int
16221 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
16222 {
16223 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
16224 			&testsuite_params, &unittest_params,
16225 			&aes128_gmac_test_vector);
16226 }
16227 
16228 static int
16229 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
16230 {
16231 	return test_authenticated_decryption_fail_when_data_corrupted(
16232 			&testsuite_params,
16233 			&unittest_params,
16234 			&aes128cbc_hmac_sha1_test_vector);
16235 }
16236 
16237 static int
16238 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
16239 {
16240 	return test_authenticated_decryption_fail_when_tag_corrupted(
16241 			&testsuite_params,
16242 			&unittest_params,
16243 			&aes128cbc_hmac_sha1_test_vector);
16244 }
16245 
16246 static int
16247 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16248 {
16249 	return test_authenticated_encrypt_with_esn(
16250 			&testsuite_params,
16251 			&unittest_params,
16252 			&aes128cbc_hmac_sha1_aad_test_vector);
16253 }
16254 
16255 static int
16256 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16257 {
16258 	return test_authenticated_decrypt_with_esn(
16259 			&testsuite_params,
16260 			&unittest_params,
16261 			&aes128cbc_hmac_sha1_aad_test_vector);
16262 }
16263 
16264 static int
16265 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
16266 {
16267 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
16268 }
16269 
16270 static int
16271 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
16272 {
16273 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
16274 }
16275 
16276 static int
16277 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
16278 {
16279 	return test_authenticated_encryption_SGL(
16280 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
16281 		chacha20_poly1305_case_2.plaintext.len);
16282 }
16283 
16284 #ifdef RTE_CRYPTO_SCHEDULER
16285 
16286 /* global AESNI worker IDs for the scheduler test */
16287 uint8_t aesni_ids[2];
16288 
16289 static int
16290 scheduler_testsuite_setup(void)
16291 {
16292 	uint32_t i = 0;
16293 	int32_t nb_devs, ret;
16294 	char vdev_args[VDEV_ARGS_SIZE] = {""};
16295 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
16296 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
16297 	uint16_t worker_core_count = 0;
16298 	uint16_t socket_id = 0;
16299 
16300 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
16301 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
16302 
16303 		/* Identify the Worker Cores
16304 		 * Use 2 worker cores for the device args
16305 		 */
16306 		RTE_LCORE_FOREACH_WORKER(i) {
16307 			if (worker_core_count > 1)
16308 				break;
16309 			snprintf(vdev_args, sizeof(vdev_args),
16310 					"%s%d", temp_str, i);
16311 			strcpy(temp_str, vdev_args);
16312 			strlcat(temp_str, ";", sizeof(temp_str));
16313 			worker_core_count++;
16314 			socket_id = rte_lcore_to_socket_id(i);
16315 		}
16316 		if (worker_core_count != 2) {
16317 			RTE_LOG(ERR, USER1,
16318 				"Cryptodev scheduler test require at least "
16319 				"two worker cores to run. "
16320 				"Please use the correct coremask.\n");
16321 			return TEST_FAILED;
16322 		}
16323 		strcpy(temp_str, vdev_args);
16324 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
16325 				temp_str, socket_id);
16326 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
16327 		nb_devs = rte_cryptodev_device_count_by_driver(
16328 				rte_cryptodev_driver_id_get(
16329 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
16330 		if (nb_devs < 1) {
16331 			ret = rte_vdev_init(
16332 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
16333 					vdev_args);
16334 			TEST_ASSERT(ret == 0,
16335 				"Failed to create instance %u of pmd : %s",
16336 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16337 		}
16338 	}
16339 	return testsuite_setup();
16340 }
16341 
16342 static int
16343 test_scheduler_attach_worker_op(void)
16344 {
16345 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16346 	uint8_t sched_id = ts_params->valid_devs[0];
16347 	uint32_t i, nb_devs_attached = 0;
16348 	int ret;
16349 	char vdev_name[32];
16350 	unsigned int count = rte_cryptodev_count();
16351 
16352 	/* create 2 AESNI_MB vdevs on top of existing devices */
16353 	for (i = count; i < count + 2; i++) {
16354 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
16355 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
16356 				i);
16357 		ret = rte_vdev_init(vdev_name, NULL);
16358 
16359 		TEST_ASSERT(ret == 0,
16360 			"Failed to create instance %u of"
16361 			" pmd : %s",
16362 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16363 
16364 		if (ret < 0) {
16365 			RTE_LOG(ERR, USER1,
16366 				"Failed to create 2 AESNI MB PMDs.\n");
16367 			return TEST_SKIPPED;
16368 		}
16369 	}
16370 
16371 	/* attach 2 AESNI_MB cdevs */
16372 	for (i = count; i < count + 2; i++) {
16373 		struct rte_cryptodev_info info;
16374 		unsigned int session_size;
16375 
16376 		rte_cryptodev_info_get(i, &info);
16377 		if (info.driver_id != rte_cryptodev_driver_id_get(
16378 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
16379 			continue;
16380 
16381 		session_size = rte_cryptodev_sym_get_private_session_size(i);
16382 		/*
16383 		 * Create the session mempool again, since now there are new devices
16384 		 * to use the mempool.
16385 		 */
16386 		if (ts_params->session_mpool) {
16387 			rte_mempool_free(ts_params->session_mpool);
16388 			ts_params->session_mpool = NULL;
16389 		}
16390 
16391 		if (info.sym.max_nb_sessions != 0 &&
16392 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
16393 			RTE_LOG(ERR, USER1,
16394 					"Device does not support "
16395 					"at least %u sessions\n",
16396 					MAX_NB_SESSIONS);
16397 			return TEST_FAILED;
16398 		}
16399 		/*
16400 		 * Create mempool with maximum number of sessions,
16401 		 * to include the session headers
16402 		 */
16403 		if (ts_params->session_mpool == NULL) {
16404 			ts_params->session_mpool =
16405 				rte_cryptodev_sym_session_pool_create(
16406 						"test_sess_mp",
16407 						MAX_NB_SESSIONS, session_size,
16408 						0, 0, SOCKET_ID_ANY);
16409 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
16410 					"session mempool allocation failed");
16411 		}
16412 
16413 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
16414 
16415 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
16416 				(uint8_t)i);
16417 
16418 		TEST_ASSERT(ret == 0,
16419 			"Failed to attach device %u of pmd : %s", i,
16420 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16421 
16422 		aesni_ids[nb_devs_attached] = (uint8_t)i;
16423 
16424 		nb_devs_attached++;
16425 	}
16426 
16427 	return 0;
16428 }
16429 
16430 static int
16431 test_scheduler_detach_worker_op(void)
16432 {
16433 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16434 	uint8_t sched_id = ts_params->valid_devs[0];
16435 	uint32_t i;
16436 	int ret;
16437 
16438 	for (i = 0; i < 2; i++) {
16439 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
16440 				aesni_ids[i]);
16441 		TEST_ASSERT(ret == 0,
16442 			"Failed to detach device %u", aesni_ids[i]);
16443 	}
16444 
16445 	return 0;
16446 }
16447 
16448 static int
16449 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
16450 {
16451 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16452 	uint8_t sched_id = ts_params->valid_devs[0];
16453 	/* set mode */
16454 	return rte_cryptodev_scheduler_mode_set(sched_id,
16455 		scheduler_mode);
16456 }
16457 
16458 static int
16459 test_scheduler_mode_roundrobin_op(void)
16460 {
16461 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
16462 			0, "Failed to set roundrobin mode");
16463 	return 0;
16464 
16465 }
16466 
16467 static int
16468 test_scheduler_mode_multicore_op(void)
16469 {
16470 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
16471 			0, "Failed to set multicore mode");
16472 
16473 	return 0;
16474 }
16475 
16476 static int
16477 test_scheduler_mode_failover_op(void)
16478 {
16479 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
16480 			0, "Failed to set failover mode");
16481 
16482 	return 0;
16483 }
16484 
16485 static int
16486 test_scheduler_mode_pkt_size_distr_op(void)
16487 {
16488 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
16489 			0, "Failed to set pktsize mode");
16490 
16491 	return 0;
16492 }
16493 
16494 static int
16495 scheduler_multicore_testsuite_setup(void)
16496 {
16497 	if (test_scheduler_attach_worker_op() < 0)
16498 		return TEST_SKIPPED;
16499 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
16500 		return TEST_SKIPPED;
16501 	return 0;
16502 }
16503 
16504 static int
16505 scheduler_roundrobin_testsuite_setup(void)
16506 {
16507 	if (test_scheduler_attach_worker_op() < 0)
16508 		return TEST_SKIPPED;
16509 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
16510 		return TEST_SKIPPED;
16511 	return 0;
16512 }
16513 
16514 static int
16515 scheduler_failover_testsuite_setup(void)
16516 {
16517 	if (test_scheduler_attach_worker_op() < 0)
16518 		return TEST_SKIPPED;
16519 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
16520 		return TEST_SKIPPED;
16521 	return 0;
16522 }
16523 
16524 static int
16525 scheduler_pkt_size_distr_testsuite_setup(void)
16526 {
16527 	if (test_scheduler_attach_worker_op() < 0)
16528 		return TEST_SKIPPED;
16529 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
16530 		return TEST_SKIPPED;
16531 	return 0;
16532 }
16533 
16534 static void
16535 scheduler_mode_testsuite_teardown(void)
16536 {
16537 	test_scheduler_detach_worker_op();
16538 }
16539 
16540 #endif /* RTE_CRYPTO_SCHEDULER */
16541 
16542 static struct unit_test_suite end_testsuite = {
16543 	.suite_name = NULL,
16544 	.setup = NULL,
16545 	.teardown = NULL,
16546 	.unit_test_suites = NULL
16547 };
16548 
16549 #ifdef RTE_LIB_SECURITY
16550 static struct unit_test_suite ipsec_proto_testsuite  = {
16551 	.suite_name = "IPsec Proto Unit Test Suite",
16552 	.setup = ipsec_proto_testsuite_setup,
16553 	.unit_test_cases = {
16554 		TEST_CASE_NAMED_WITH_DATA(
16555 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16556 			ut_setup_security, ut_teardown,
16557 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
16558 		TEST_CASE_NAMED_WITH_DATA(
16559 			"Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
16560 			ut_setup_security, ut_teardown,
16561 			test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
16562 		TEST_CASE_NAMED_WITH_DATA(
16563 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16564 			ut_setup_security, ut_teardown,
16565 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
16566 		TEST_CASE_NAMED_WITH_DATA(
16567 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16568 			ut_setup_security, ut_teardown,
16569 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
16570 		TEST_CASE_NAMED_WITH_DATA(
16571 			"Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16572 			ut_setup_security, ut_teardown,
16573 			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
16574 		TEST_CASE_NAMED_WITH_DATA(
16575 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16576 			ut_setup_security, ut_teardown,
16577 			test_ipsec_proto_known_vec,
16578 			&pkt_aes_128_cbc_md5),
16579 		TEST_CASE_NAMED_WITH_DATA(
16580 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16581 			ut_setup_security, ut_teardown,
16582 			test_ipsec_proto_known_vec,
16583 			&pkt_aes_128_cbc_hmac_sha256),
16584 		TEST_CASE_NAMED_WITH_DATA(
16585 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16586 			ut_setup_security, ut_teardown,
16587 			test_ipsec_proto_known_vec,
16588 			&pkt_aes_128_cbc_hmac_sha384),
16589 		TEST_CASE_NAMED_WITH_DATA(
16590 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16591 			ut_setup_security, ut_teardown,
16592 			test_ipsec_proto_known_vec,
16593 			&pkt_aes_128_cbc_hmac_sha512),
16594 		TEST_CASE_NAMED_WITH_DATA(
16595 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16596 			ut_setup_security, ut_teardown,
16597 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
16598 		TEST_CASE_NAMED_WITH_DATA(
16599 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16600 			ut_setup_security, ut_teardown,
16601 			test_ipsec_proto_known_vec,
16602 			&pkt_aes_128_cbc_hmac_sha256_v6),
16603 		TEST_CASE_NAMED_WITH_DATA(
16604 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16605 			ut_setup_security, ut_teardown,
16606 			test_ipsec_proto_known_vec,
16607 			&pkt_null_aes_xcbc),
16608 		TEST_CASE_NAMED_WITH_DATA(
16609 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16610 			ut_setup_security, ut_teardown,
16611 			test_ipsec_proto_known_vec,
16612 			&pkt_des_cbc_hmac_sha256),
16613 		TEST_CASE_NAMED_WITH_DATA(
16614 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16615 			ut_setup_security, ut_teardown,
16616 			test_ipsec_proto_known_vec,
16617 			&pkt_des_cbc_hmac_sha384),
16618 		TEST_CASE_NAMED_WITH_DATA(
16619 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16620 			ut_setup_security, ut_teardown,
16621 			test_ipsec_proto_known_vec,
16622 			&pkt_des_cbc_hmac_sha512),
16623 		TEST_CASE_NAMED_WITH_DATA(
16624 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16625 			ut_setup_security, ut_teardown,
16626 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
16627 		TEST_CASE_NAMED_WITH_DATA(
16628 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16629 			ut_setup_security, ut_teardown,
16630 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
16631 		TEST_CASE_NAMED_WITH_DATA(
16632 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16633 			ut_setup_security, ut_teardown,
16634 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
16635 		TEST_CASE_NAMED_WITH_DATA(
16636 			"Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16637 			ut_setup_security, ut_teardown,
16638 			test_ipsec_proto_known_vec,
16639 			&pkt_des_cbc_hmac_sha256_v6),
16640 		TEST_CASE_NAMED_WITH_DATA(
16641 			"Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16642 			ut_setup_security, ut_teardown,
16643 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
16644 		TEST_CASE_NAMED_WITH_DATA(
16645 			"Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16646 			ut_setup_security, ut_teardown,
16647 			test_ipsec_proto_known_vec,
16648 			&pkt_ah_tunnel_sha256),
16649 		TEST_CASE_NAMED_WITH_DATA(
16650 			"Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16651 			ut_setup_security, ut_teardown,
16652 			test_ipsec_proto_known_vec,
16653 			&pkt_ah_transport_sha256),
16654 		TEST_CASE_NAMED_WITH_DATA(
16655 			"Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16656 			ut_setup_security, ut_teardown,
16657 			test_ipsec_proto_known_vec,
16658 			&pkt_ah_ipv4_aes_gmac_128),
16659 		TEST_CASE_NAMED_WITH_DATA(
16660 			"Outbound fragmented packet",
16661 			ut_setup_security, ut_teardown,
16662 			test_ipsec_proto_known_vec_fragmented,
16663 			&pkt_aes_128_gcm_frag),
16664 		TEST_CASE_NAMED_WITH_DATA(
16665 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16666 			ut_setup_security, ut_teardown,
16667 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
16668 		TEST_CASE_NAMED_WITH_DATA(
16669 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16670 			ut_setup_security, ut_teardown,
16671 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
16672 		TEST_CASE_NAMED_WITH_DATA(
16673 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16674 			ut_setup_security, ut_teardown,
16675 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
16676 		TEST_CASE_NAMED_WITH_DATA(
16677 			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16678 			ut_setup_security, ut_teardown,
16679 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
16680 		TEST_CASE_NAMED_WITH_DATA(
16681 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
16682 			ut_setup_security, ut_teardown,
16683 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
16684 		TEST_CASE_NAMED_WITH_DATA(
16685 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
16686 			ut_setup_security, ut_teardown,
16687 			test_ipsec_proto_known_vec_inb,
16688 			&pkt_aes_128_cbc_md5),
16689 		TEST_CASE_NAMED_WITH_DATA(
16690 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16691 			ut_setup_security, ut_teardown,
16692 			test_ipsec_proto_known_vec_inb,
16693 			&pkt_aes_128_cbc_hmac_sha256),
16694 		TEST_CASE_NAMED_WITH_DATA(
16695 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
16696 			ut_setup_security, ut_teardown,
16697 			test_ipsec_proto_known_vec_inb,
16698 			&pkt_aes_128_cbc_hmac_sha384),
16699 		TEST_CASE_NAMED_WITH_DATA(
16700 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
16701 			ut_setup_security, ut_teardown,
16702 			test_ipsec_proto_known_vec_inb,
16703 			&pkt_aes_128_cbc_hmac_sha512),
16704 		TEST_CASE_NAMED_WITH_DATA(
16705 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
16706 			ut_setup_security, ut_teardown,
16707 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
16708 		TEST_CASE_NAMED_WITH_DATA(
16709 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
16710 			ut_setup_security, ut_teardown,
16711 			test_ipsec_proto_known_vec_inb,
16712 			&pkt_aes_128_cbc_hmac_sha256_v6),
16713 		TEST_CASE_NAMED_WITH_DATA(
16714 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
16715 			ut_setup_security, ut_teardown,
16716 			test_ipsec_proto_known_vec_inb,
16717 			&pkt_null_aes_xcbc),
16718 		TEST_CASE_NAMED_WITH_DATA(
16719 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
16720 			ut_setup_security, ut_teardown,
16721 			test_ipsec_proto_known_vec_inb,
16722 			&pkt_des_cbc_hmac_sha256),
16723 		TEST_CASE_NAMED_WITH_DATA(
16724 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
16725 			ut_setup_security, ut_teardown,
16726 			test_ipsec_proto_known_vec_inb,
16727 			&pkt_des_cbc_hmac_sha384),
16728 		TEST_CASE_NAMED_WITH_DATA(
16729 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
16730 			ut_setup_security, ut_teardown,
16731 			test_ipsec_proto_known_vec_inb,
16732 			&pkt_des_cbc_hmac_sha512),
16733 		TEST_CASE_NAMED_WITH_DATA(
16734 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
16735 			ut_setup_security, ut_teardown,
16736 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
16737 		TEST_CASE_NAMED_WITH_DATA(
16738 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
16739 			ut_setup_security, ut_teardown,
16740 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
16741 		TEST_CASE_NAMED_WITH_DATA(
16742 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
16743 			ut_setup_security, ut_teardown,
16744 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
16745 		TEST_CASE_NAMED_WITH_DATA(
16746 			"Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
16747 			ut_setup_security, ut_teardown,
16748 			test_ipsec_proto_known_vec_inb,
16749 			&pkt_des_cbc_hmac_sha256_v6),
16750 		TEST_CASE_NAMED_WITH_DATA(
16751 			"Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
16752 			ut_setup_security, ut_teardown,
16753 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
16754 		TEST_CASE_NAMED_WITH_DATA(
16755 			"Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
16756 			ut_setup_security, ut_teardown,
16757 			test_ipsec_proto_known_vec_inb,
16758 			&pkt_ah_tunnel_sha256),
16759 		TEST_CASE_NAMED_WITH_DATA(
16760 			"Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
16761 			ut_setup_security, ut_teardown,
16762 			test_ipsec_proto_known_vec_inb,
16763 			&pkt_ah_transport_sha256),
16764 		TEST_CASE_NAMED_WITH_DATA(
16765 			"Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
16766 			ut_setup_security, ut_teardown,
16767 			test_ipsec_proto_known_vec_inb,
16768 			&pkt_ah_ipv4_aes_gmac_128),
16769 		TEST_CASE_NAMED_ST(
16770 			"Combined test alg list",
16771 			ut_setup_security, ut_teardown,
16772 			test_ipsec_proto_display_list),
16773 		TEST_CASE_NAMED_ST(
16774 			"Combined test alg list (AH)",
16775 			ut_setup_security, ut_teardown,
16776 			test_ipsec_proto_ah_tunnel_ipv4),
16777 		TEST_CASE_NAMED_ST(
16778 			"IV generation",
16779 			ut_setup_security, ut_teardown,
16780 			test_ipsec_proto_iv_gen),
16781 		TEST_CASE_NAMED_ST(
16782 			"UDP encapsulation",
16783 			ut_setup_security, ut_teardown,
16784 			test_ipsec_proto_udp_encap),
16785 		TEST_CASE_NAMED_ST(
16786 			"UDP encapsulation with custom ports",
16787 			ut_setup_security, ut_teardown,
16788 			test_ipsec_proto_udp_encap_custom_ports),
16789 		TEST_CASE_NAMED_ST(
16790 			"UDP encapsulation ports verification test",
16791 			ut_setup_security, ut_teardown,
16792 			test_ipsec_proto_udp_ports_verify),
16793 		TEST_CASE_NAMED_ST(
16794 			"SA expiry packets soft",
16795 			ut_setup_security, ut_teardown,
16796 			test_ipsec_proto_sa_exp_pkts_soft),
16797 		TEST_CASE_NAMED_ST(
16798 			"SA expiry packets hard",
16799 			ut_setup_security, ut_teardown,
16800 			test_ipsec_proto_sa_exp_pkts_hard),
16801 		TEST_CASE_NAMED_ST(
16802 			"Negative test: ICV corruption",
16803 			ut_setup_security, ut_teardown,
16804 			test_ipsec_proto_err_icv_corrupt),
16805 		TEST_CASE_NAMED_ST(
16806 			"Tunnel dst addr verification",
16807 			ut_setup_security, ut_teardown,
16808 			test_ipsec_proto_tunnel_dst_addr_verify),
16809 		TEST_CASE_NAMED_ST(
16810 			"Tunnel src and dst addr verification",
16811 			ut_setup_security, ut_teardown,
16812 			test_ipsec_proto_tunnel_src_dst_addr_verify),
16813 		TEST_CASE_NAMED_ST(
16814 			"Inner IP checksum",
16815 			ut_setup_security, ut_teardown,
16816 			test_ipsec_proto_inner_ip_csum),
16817 		TEST_CASE_NAMED_ST(
16818 			"Inner L4 checksum",
16819 			ut_setup_security, ut_teardown,
16820 			test_ipsec_proto_inner_l4_csum),
16821 		TEST_CASE_NAMED_ST(
16822 			"Tunnel IPv4 in IPv4",
16823 			ut_setup_security, ut_teardown,
16824 			test_ipsec_proto_tunnel_v4_in_v4),
16825 		TEST_CASE_NAMED_ST(
16826 			"Tunnel IPv6 in IPv6",
16827 			ut_setup_security, ut_teardown,
16828 			test_ipsec_proto_tunnel_v6_in_v6),
16829 		TEST_CASE_NAMED_ST(
16830 			"Tunnel IPv4 in IPv6",
16831 			ut_setup_security, ut_teardown,
16832 			test_ipsec_proto_tunnel_v4_in_v6),
16833 		TEST_CASE_NAMED_ST(
16834 			"Tunnel IPv6 in IPv4",
16835 			ut_setup_security, ut_teardown,
16836 			test_ipsec_proto_tunnel_v6_in_v4),
16837 		TEST_CASE_NAMED_ST(
16838 			"Transport IPv4",
16839 			ut_setup_security, ut_teardown,
16840 			test_ipsec_proto_transport_v4),
16841 		TEST_CASE_NAMED_ST(
16842 			"AH transport IPv4",
16843 			ut_setup_security, ut_teardown,
16844 			test_ipsec_proto_ah_transport_ipv4),
16845 		TEST_CASE_NAMED_ST(
16846 			"Transport l4 checksum",
16847 			ut_setup_security, ut_teardown,
16848 			test_ipsec_proto_transport_l4_csum),
16849 		TEST_CASE_NAMED_ST(
16850 			"Statistics: success",
16851 			ut_setup_security, ut_teardown,
16852 			test_ipsec_proto_stats),
16853 		TEST_CASE_NAMED_ST(
16854 			"Fragmented packet",
16855 			ut_setup_security, ut_teardown,
16856 			test_ipsec_proto_pkt_fragment),
16857 		TEST_CASE_NAMED_ST(
16858 			"Tunnel header copy DF (inner 0)",
16859 			ut_setup_security, ut_teardown,
16860 			test_ipsec_proto_copy_df_inner_0),
16861 		TEST_CASE_NAMED_ST(
16862 			"Tunnel header copy DF (inner 1)",
16863 			ut_setup_security, ut_teardown,
16864 			test_ipsec_proto_copy_df_inner_1),
16865 		TEST_CASE_NAMED_ST(
16866 			"Tunnel header set DF 0 (inner 1)",
16867 			ut_setup_security, ut_teardown,
16868 			test_ipsec_proto_set_df_0_inner_1),
16869 		TEST_CASE_NAMED_ST(
16870 			"Tunnel header set DF 1 (inner 0)",
16871 			ut_setup_security, ut_teardown,
16872 			test_ipsec_proto_set_df_1_inner_0),
16873 		TEST_CASE_NAMED_ST(
16874 			"Tunnel header IPv4 copy DSCP (inner 0)",
16875 			ut_setup_security, ut_teardown,
16876 			test_ipsec_proto_ipv4_copy_dscp_inner_0),
16877 		TEST_CASE_NAMED_ST(
16878 			"Tunnel header IPv4 copy DSCP (inner 1)",
16879 			ut_setup_security, ut_teardown,
16880 			test_ipsec_proto_ipv4_copy_dscp_inner_1),
16881 		TEST_CASE_NAMED_ST(
16882 			"Tunnel header IPv4 set DSCP 0 (inner 1)",
16883 			ut_setup_security, ut_teardown,
16884 			test_ipsec_proto_ipv4_set_dscp_0_inner_1),
16885 		TEST_CASE_NAMED_ST(
16886 			"Tunnel header IPv4 set DSCP 1 (inner 0)",
16887 			ut_setup_security, ut_teardown,
16888 			test_ipsec_proto_ipv4_set_dscp_1_inner_0),
16889 		TEST_CASE_NAMED_ST(
16890 			"Tunnel header IPv6 copy DSCP (inner 0)",
16891 			ut_setup_security, ut_teardown,
16892 			test_ipsec_proto_ipv6_copy_dscp_inner_0),
16893 		TEST_CASE_NAMED_ST(
16894 			"Tunnel header IPv6 copy DSCP (inner 1)",
16895 			ut_setup_security, ut_teardown,
16896 			test_ipsec_proto_ipv6_copy_dscp_inner_1),
16897 		TEST_CASE_NAMED_ST(
16898 			"Tunnel header IPv6 set DSCP 0 (inner 1)",
16899 			ut_setup_security, ut_teardown,
16900 			test_ipsec_proto_ipv6_set_dscp_0_inner_1),
16901 		TEST_CASE_NAMED_ST(
16902 			"Tunnel header IPv6 set DSCP 1 (inner 0)",
16903 			ut_setup_security, ut_teardown,
16904 			test_ipsec_proto_ipv6_set_dscp_1_inner_0),
16905 		TEST_CASE_NAMED_WITH_DATA(
16906 			"Antireplay with window size 1024",
16907 			ut_setup_security, ut_teardown,
16908 			test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
16909 		TEST_CASE_NAMED_WITH_DATA(
16910 			"Antireplay with window size 2048",
16911 			ut_setup_security, ut_teardown,
16912 			test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
16913 		TEST_CASE_NAMED_WITH_DATA(
16914 			"Antireplay with window size 4096",
16915 			ut_setup_security, ut_teardown,
16916 			test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
16917 		TEST_CASE_NAMED_WITH_DATA(
16918 			"ESN and Antireplay with window size 1024",
16919 			ut_setup_security, ut_teardown,
16920 			test_ipsec_proto_pkt_esn_antireplay1024,
16921 			&pkt_aes_128_gcm),
16922 		TEST_CASE_NAMED_WITH_DATA(
16923 			"ESN and Antireplay with window size 2048",
16924 			ut_setup_security, ut_teardown,
16925 			test_ipsec_proto_pkt_esn_antireplay2048,
16926 			&pkt_aes_128_gcm),
16927 		TEST_CASE_NAMED_WITH_DATA(
16928 			"ESN and Antireplay with window size 4096",
16929 			ut_setup_security, ut_teardown,
16930 			test_ipsec_proto_pkt_esn_antireplay4096,
16931 			&pkt_aes_128_gcm),
16932 		TEST_CASE_NAMED_ST(
16933 			"Tunnel header IPv4 decrement inner TTL",
16934 			ut_setup_security, ut_teardown,
16935 			test_ipsec_proto_ipv4_ttl_decrement),
16936 		TEST_CASE_NAMED_ST(
16937 			"Tunnel header IPv6 decrement inner hop limit",
16938 			ut_setup_security, ut_teardown,
16939 			test_ipsec_proto_ipv6_hop_limit_decrement),
16940 		TEST_CASE_NAMED_ST(
16941 			"Multi-segmented mode",
16942 			ut_setup_security, ut_teardown,
16943 			test_ipsec_proto_sgl),
16944 		TEST_CASE_NAMED_ST(
16945 			"Multi-segmented external mbuf mode",
16946 			ut_setup_security, ut_teardown,
16947 			test_ipsec_proto_sgl_ext_mbuf),
16948 		TEST_CASE_NAMED_WITH_DATA(
16949 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
16950 			ut_setup_security_rx_inject, ut_teardown_rx_inject,
16951 			test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
16952 		TEST_CASES_END() /**< NULL terminate unit test array */
16953 	}
16954 };
16955 
16956 static struct unit_test_suite pdcp_proto_testsuite  = {
16957 	.suite_name = "PDCP Proto Unit Test Suite",
16958 	.setup = pdcp_proto_testsuite_setup,
16959 	.unit_test_cases = {
16960 		TEST_CASE_ST(ut_setup_security, ut_teardown,
16961 			test_PDCP_PROTO_all),
16962 		TEST_CASES_END() /**< NULL terminate unit test array */
16963 	}
16964 };
16965 
16966 static struct unit_test_suite tls12_record_proto_testsuite  = {
16967 	.suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
16968 	.setup = tls_record_proto_testsuite_setup,
16969 	.unit_test_cases = {
16970 		TEST_CASE_NAMED_WITH_DATA(
16971 			"Write record known vector AES-GCM-128 (vector 1)",
16972 			ut_setup_security, ut_teardown,
16973 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
16974 		TEST_CASE_NAMED_WITH_DATA(
16975 			"Write record known vector AES-GCM-128 (vector 2)",
16976 			ut_setup_security, ut_teardown,
16977 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
16978 		TEST_CASE_NAMED_WITH_DATA(
16979 			"Write record known vector AES-GCM-256",
16980 			ut_setup_security, ut_teardown,
16981 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
16982 		TEST_CASE_NAMED_WITH_DATA(
16983 			"Write record known vector AES-CBC-128-SHA1",
16984 			ut_setup_security, ut_teardown,
16985 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
16986 		TEST_CASE_NAMED_WITH_DATA(
16987 			"Write record known vector AES-128-CBC-SHA256",
16988 			ut_setup_security, ut_teardown,
16989 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
16990 		TEST_CASE_NAMED_WITH_DATA(
16991 			"Write record known vector AES-256-CBC-SHA1",
16992 			ut_setup_security, ut_teardown,
16993 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
16994 		TEST_CASE_NAMED_WITH_DATA(
16995 			"Write record known vector AES-256-CBC-SHA256",
16996 			ut_setup_security, ut_teardown,
16997 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
16998 		TEST_CASE_NAMED_WITH_DATA(
16999 			"Write record known vector 3DES-CBC-SHA1-HMAC",
17000 			ut_setup_security, ut_teardown,
17001 			test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
17002 		TEST_CASE_NAMED_WITH_DATA(
17003 			"Write record known vector NULL-SHA1-HMAC",
17004 			ut_setup_security, ut_teardown,
17005 			test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
17006 		TEST_CASE_NAMED_WITH_DATA(
17007 			"Write record known vector CHACHA20-POLY1305",
17008 			ut_setup_security, ut_teardown,
17009 			test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
17010 
17011 		TEST_CASE_NAMED_WITH_DATA(
17012 			"Read record known vector AES-GCM-128 (vector 1)",
17013 			ut_setup_security, ut_teardown,
17014 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
17015 		TEST_CASE_NAMED_WITH_DATA(
17016 			"Read record known vector AES-GCM-128 (vector 2)",
17017 			ut_setup_security, ut_teardown,
17018 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
17019 		TEST_CASE_NAMED_WITH_DATA(
17020 			"Read record known vector AES-GCM-256",
17021 			ut_setup_security, ut_teardown,
17022 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
17023 		TEST_CASE_NAMED_WITH_DATA(
17024 			"Read record known vector AES-128-CBC-SHA1",
17025 			ut_setup_security, ut_teardown,
17026 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
17027 		TEST_CASE_NAMED_WITH_DATA(
17028 			"Read record known vector AES-128-CBC-SHA256",
17029 			ut_setup_security, ut_teardown,
17030 			test_tls_record_proto_known_vec_read,
17031 			&tls_test_data_aes_128_cbc_sha256_hmac),
17032 		TEST_CASE_NAMED_WITH_DATA(
17033 			"Read record known vector AES-256-CBC-SHA1",
17034 			ut_setup_security, ut_teardown,
17035 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
17036 		TEST_CASE_NAMED_WITH_DATA(
17037 			"Read record known vector AES-256-CBC-SHA256",
17038 			ut_setup_security, ut_teardown,
17039 			test_tls_record_proto_known_vec_read,
17040 			&tls_test_data_aes_256_cbc_sha256_hmac),
17041 		TEST_CASE_NAMED_WITH_DATA(
17042 			"Read record known vector 3DES-CBC-SHA1-HMAC",
17043 			ut_setup_security, ut_teardown,
17044 			test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
17045 		TEST_CASE_NAMED_WITH_DATA(
17046 			"Read record known vector NULL-SHA1-HMAC",
17047 			ut_setup_security, ut_teardown,
17048 			test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
17049 		TEST_CASE_NAMED_WITH_DATA(
17050 			"Read record known vector CHACHA20-POLY1305",
17051 			ut_setup_security, ut_teardown,
17052 			test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
17053 
17054 		TEST_CASE_NAMED_ST(
17055 			"Combined test alg list",
17056 			ut_setup_security, ut_teardown,
17057 			test_tls_record_proto_display_list),
17058 		TEST_CASE_NAMED_ST(
17059 			"Multi-segmented mode",
17060 			ut_setup_security, ut_teardown,
17061 			test_tls_record_proto_sgl),
17062 		TEST_CASES_END() /**< NULL terminate unit test array */
17063 	}
17064 };
17065 
17066 static struct unit_test_suite dtls12_record_proto_testsuite  = {
17067 	.suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
17068 	.setup = tls_record_proto_testsuite_setup,
17069 	.unit_test_cases = {
17070 		TEST_CASE_NAMED_WITH_DATA(
17071 			"Write record known vector AES-GCM-128",
17072 			ut_setup_security, ut_teardown,
17073 			test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
17074 		TEST_CASE_NAMED_WITH_DATA(
17075 			"Write record known vector AES-GCM-256",
17076 			ut_setup_security, ut_teardown,
17077 			test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
17078 		TEST_CASE_NAMED_WITH_DATA(
17079 			"Write record known vector AES-128-CBC-SHA1",
17080 			ut_setup_security, ut_teardown,
17081 			test_tls_record_proto_known_vec,
17082 			&dtls_test_data_aes_128_cbc_sha1_hmac),
17083 		TEST_CASE_NAMED_WITH_DATA(
17084 			"Write record known vector AES-128-CBC-SHA256",
17085 			ut_setup_security, ut_teardown,
17086 			test_tls_record_proto_known_vec,
17087 			&dtls_test_data_aes_128_cbc_sha256_hmac),
17088 		TEST_CASE_NAMED_WITH_DATA(
17089 			"Write record known vector AES-256-CBC-SHA1",
17090 			ut_setup_security, ut_teardown,
17091 			test_tls_record_proto_known_vec,
17092 			&dtls_test_data_aes_256_cbc_sha1_hmac),
17093 		TEST_CASE_NAMED_WITH_DATA(
17094 			"Write record known vector AES-256-CBC-SHA256",
17095 			ut_setup_security, ut_teardown,
17096 			test_tls_record_proto_known_vec,
17097 			&dtls_test_data_aes_256_cbc_sha256_hmac),
17098 		TEST_CASE_NAMED_WITH_DATA(
17099 			"Write record known vector 3DES-CBC-SHA1-HMAC",
17100 			ut_setup_security, ut_teardown,
17101 			test_tls_record_proto_known_vec,
17102 			&dtls_test_data_3des_cbc_sha1_hmac),
17103 		TEST_CASE_NAMED_WITH_DATA(
17104 			"Write record known vector NULL-SHA1-HMAC",
17105 			ut_setup_security, ut_teardown,
17106 			test_tls_record_proto_known_vec,
17107 			&dtls_test_data_null_cipher_sha1_hmac),
17108 		TEST_CASE_NAMED_WITH_DATA(
17109 			"Write record known vector CHACHA20-POLY1305",
17110 			ut_setup_security, ut_teardown,
17111 			test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
17112 		TEST_CASE_NAMED_WITH_DATA(
17113 			"Read record known vector AES-GCM-128",
17114 			ut_setup_security, ut_teardown,
17115 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
17116 		TEST_CASE_NAMED_WITH_DATA(
17117 			"Read record known vector AES-GCM-256",
17118 			ut_setup_security, ut_teardown,
17119 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
17120 		TEST_CASE_NAMED_WITH_DATA(
17121 			"Read record known vector AES-128-CBC-SHA1",
17122 			ut_setup_security, ut_teardown,
17123 			test_tls_record_proto_known_vec_read,
17124 			&dtls_test_data_aes_128_cbc_sha1_hmac),
17125 		TEST_CASE_NAMED_WITH_DATA(
17126 			"Read record known vector AES-128-CBC-SHA256",
17127 			ut_setup_security, ut_teardown,
17128 			test_tls_record_proto_known_vec_read,
17129 			&dtls_test_data_aes_128_cbc_sha256_hmac),
17130 		TEST_CASE_NAMED_WITH_DATA(
17131 			"Read record known vector AES-256-CBC-SHA1",
17132 			ut_setup_security, ut_teardown,
17133 			test_tls_record_proto_known_vec_read,
17134 			&dtls_test_data_aes_256_cbc_sha1_hmac),
17135 		TEST_CASE_NAMED_WITH_DATA(
17136 			"Read record known vector AES-256-CBC-SHA256",
17137 			ut_setup_security, ut_teardown,
17138 			test_tls_record_proto_known_vec_read,
17139 			&dtls_test_data_aes_256_cbc_sha256_hmac),
17140 		TEST_CASE_NAMED_WITH_DATA(
17141 			"Read record known vector 3DES-CBC-SHA1-HMAC",
17142 			ut_setup_security, ut_teardown,
17143 			test_tls_record_proto_known_vec_read,
17144 			&dtls_test_data_3des_cbc_sha1_hmac),
17145 		TEST_CASE_NAMED_WITH_DATA(
17146 			"Read record known vector NULL-SHA1-HMAC",
17147 			ut_setup_security, ut_teardown,
17148 			test_tls_record_proto_known_vec_read,
17149 			&dtls_test_data_null_cipher_sha1_hmac),
17150 		TEST_CASE_NAMED_WITH_DATA(
17151 			"Read record known vector CHACHA20-POLY1305",
17152 			ut_setup_security, ut_teardown,
17153 			test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
17154 
17155 		TEST_CASE_NAMED_ST(
17156 			"Combined test alg list",
17157 			ut_setup_security, ut_teardown,
17158 			test_tls_record_proto_display_list),
17159 		TEST_CASE_NAMED_ST(
17160 			"Multi-segmented mode",
17161 			ut_setup_security, ut_teardown,
17162 			test_tls_record_proto_sgl),
17163 		TEST_CASES_END() /**< NULL terminate unit test array */
17164 	}
17165 };
17166 
17167 #define ADD_UPLINK_TESTCASE(data)						\
17168 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
17169 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
17170 
17171 #define ADD_DOWNLINK_TESTCASE(data)						\
17172 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
17173 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
17174 
17175 static struct unit_test_suite docsis_proto_testsuite  = {
17176 	.suite_name = "DOCSIS Proto Unit Test Suite",
17177 	.setup = docsis_proto_testsuite_setup,
17178 	.unit_test_cases = {
17179 		/* Uplink */
17180 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
17181 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
17182 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
17183 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
17184 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
17185 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
17186 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
17187 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
17188 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
17189 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
17190 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
17191 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
17192 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
17193 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
17194 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
17195 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
17196 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
17197 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
17198 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
17199 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
17200 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
17201 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
17202 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
17203 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
17204 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
17205 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
17206 		/* Downlink */
17207 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
17208 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
17209 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
17210 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
17211 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
17212 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
17213 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
17214 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
17215 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
17216 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
17217 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
17218 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
17219 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
17220 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
17221 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
17222 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
17223 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
17224 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
17225 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
17226 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
17227 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
17228 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
17229 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
17230 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
17231 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
17232 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
17233 		TEST_CASES_END() /**< NULL terminate unit test array */
17234 	}
17235 };
17236 #endif
17237 
17238 static struct unit_test_suite cryptodev_gen_testsuite  = {
17239 	.suite_name = "Crypto General Unit Test Suite",
17240 	.setup = crypto_gen_testsuite_setup,
17241 	.unit_test_cases = {
17242 		TEST_CASE_ST(ut_setup, ut_teardown,
17243 				test_device_reconfigure),
17244 		TEST_CASE_ST(ut_setup, ut_teardown,
17245 				test_device_configure_invalid_dev_id),
17246 		TEST_CASE_ST(ut_setup, ut_teardown,
17247 				test_queue_pair_descriptor_setup),
17248 		TEST_CASE_ST(ut_setup, ut_teardown,
17249 				test_device_configure_invalid_queue_pair_ids),
17250 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
17251 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
17252 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
17253 		TEST_CASES_END() /**< NULL terminate unit test array */
17254 	}
17255 };
17256 
17257 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
17258 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
17259 	.setup = negative_hmac_sha1_testsuite_setup,
17260 	.unit_test_cases = {
17261 		/** Negative tests */
17262 		TEST_CASE_ST(ut_setup, ut_teardown,
17263 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
17264 		TEST_CASE_ST(ut_setup, ut_teardown,
17265 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
17266 		TEST_CASE_ST(ut_setup, ut_teardown,
17267 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
17268 		TEST_CASE_ST(ut_setup, ut_teardown,
17269 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
17270 
17271 		TEST_CASES_END() /**< NULL terminate unit test array */
17272 	}
17273 };
17274 
17275 static struct unit_test_suite cryptodev_multi_session_testsuite = {
17276 	.suite_name = "Multi Session Unit Test Suite",
17277 	.setup = multi_session_testsuite_setup,
17278 	.unit_test_cases = {
17279 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
17280 		TEST_CASE_ST(ut_setup, ut_teardown,
17281 				test_multi_session_random_usage),
17282 
17283 		TEST_CASES_END() /**< NULL terminate unit test array */
17284 	}
17285 };
17286 
17287 static struct unit_test_suite cryptodev_null_testsuite  = {
17288 	.suite_name = "NULL Test Suite",
17289 	.setup = null_testsuite_setup,
17290 	.unit_test_cases = {
17291 		TEST_CASE_ST(ut_setup, ut_teardown,
17292 			test_null_invalid_operation),
17293 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
17294 		TEST_CASES_END()
17295 	}
17296 };
17297 
17298 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
17299 	.suite_name = "AES CCM Authenticated Test Suite",
17300 	.setup = aes_ccm_auth_testsuite_setup,
17301 	.unit_test_cases = {
17302 		/** AES CCM Authenticated Encryption 128 bits key*/
17303 		TEST_CASE_ST(ut_setup, ut_teardown,
17304 			test_AES_CCM_authenticated_encryption_test_case_128_1),
17305 		TEST_CASE_ST(ut_setup, ut_teardown,
17306 			test_AES_CCM_authenticated_encryption_test_case_128_2),
17307 		TEST_CASE_ST(ut_setup, ut_teardown,
17308 			test_AES_CCM_authenticated_encryption_test_case_128_3),
17309 
17310 		/** AES CCM Authenticated Decryption 128 bits key*/
17311 		TEST_CASE_ST(ut_setup, ut_teardown,
17312 			test_AES_CCM_authenticated_decryption_test_case_128_1),
17313 		TEST_CASE_ST(ut_setup, ut_teardown,
17314 			test_AES_CCM_authenticated_decryption_test_case_128_2),
17315 		TEST_CASE_ST(ut_setup, ut_teardown,
17316 			test_AES_CCM_authenticated_decryption_test_case_128_3),
17317 
17318 		/** AES CCM Authenticated Encryption 192 bits key */
17319 		TEST_CASE_ST(ut_setup, ut_teardown,
17320 			test_AES_CCM_authenticated_encryption_test_case_192_1),
17321 		TEST_CASE_ST(ut_setup, ut_teardown,
17322 			test_AES_CCM_authenticated_encryption_test_case_192_2),
17323 		TEST_CASE_ST(ut_setup, ut_teardown,
17324 			test_AES_CCM_authenticated_encryption_test_case_192_3),
17325 
17326 		/** AES CCM Authenticated Decryption 192 bits key*/
17327 		TEST_CASE_ST(ut_setup, ut_teardown,
17328 			test_AES_CCM_authenticated_decryption_test_case_192_1),
17329 		TEST_CASE_ST(ut_setup, ut_teardown,
17330 			test_AES_CCM_authenticated_decryption_test_case_192_2),
17331 		TEST_CASE_ST(ut_setup, ut_teardown,
17332 			test_AES_CCM_authenticated_decryption_test_case_192_3),
17333 
17334 		/** AES CCM Authenticated Encryption 256 bits key */
17335 		TEST_CASE_ST(ut_setup, ut_teardown,
17336 			test_AES_CCM_authenticated_encryption_test_case_256_1),
17337 		TEST_CASE_ST(ut_setup, ut_teardown,
17338 			test_AES_CCM_authenticated_encryption_test_case_256_2),
17339 		TEST_CASE_ST(ut_setup, ut_teardown,
17340 			test_AES_CCM_authenticated_encryption_test_case_256_3),
17341 
17342 		/** AES CCM Authenticated Decryption 256 bits key*/
17343 		TEST_CASE_ST(ut_setup, ut_teardown,
17344 			test_AES_CCM_authenticated_decryption_test_case_256_1),
17345 		TEST_CASE_ST(ut_setup, ut_teardown,
17346 			test_AES_CCM_authenticated_decryption_test_case_256_2),
17347 		TEST_CASE_ST(ut_setup, ut_teardown,
17348 			test_AES_CCM_authenticated_decryption_test_case_256_3),
17349 		TEST_CASES_END()
17350 	}
17351 };
17352 
17353 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
17354 	.suite_name = "AES GCM Authenticated Test Suite",
17355 	.setup = aes_gcm_auth_testsuite_setup,
17356 	.unit_test_cases = {
17357 		/** AES GCM Authenticated Encryption */
17358 		TEST_CASE_ST(ut_setup, ut_teardown,
17359 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
17360 		TEST_CASE_ST(ut_setup, ut_teardown,
17361 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
17362 		TEST_CASE_ST(ut_setup, ut_teardown,
17363 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
17364 		TEST_CASE_ST(ut_setup, ut_teardown,
17365 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
17366 		TEST_CASE_ST(ut_setup, ut_teardown,
17367 			test_AES_GCM_authenticated_encryption_test_case_1),
17368 		TEST_CASE_ST(ut_setup, ut_teardown,
17369 			test_AES_GCM_authenticated_encryption_test_case_2),
17370 		TEST_CASE_ST(ut_setup, ut_teardown,
17371 			test_AES_GCM_authenticated_encryption_test_case_3),
17372 		TEST_CASE_ST(ut_setup, ut_teardown,
17373 			test_AES_GCM_authenticated_encryption_test_case_4),
17374 		TEST_CASE_ST(ut_setup, ut_teardown,
17375 			test_AES_GCM_authenticated_encryption_test_case_5),
17376 		TEST_CASE_ST(ut_setup, ut_teardown,
17377 			test_AES_GCM_authenticated_encryption_test_case_6),
17378 		TEST_CASE_ST(ut_setup, ut_teardown,
17379 			test_AES_GCM_authenticated_encryption_test_case_7),
17380 		TEST_CASE_ST(ut_setup, ut_teardown,
17381 			test_AES_GCM_authenticated_encryption_test_case_8),
17382 		TEST_CASE_ST(ut_setup, ut_teardown,
17383 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
17384 
17385 		/** AES GCM Authenticated Decryption */
17386 		TEST_CASE_ST(ut_setup, ut_teardown,
17387 			test_AES_GCM_authenticated_decryption_test_case_1),
17388 		TEST_CASE_ST(ut_setup, ut_teardown,
17389 			test_AES_GCM_authenticated_decryption_test_case_2),
17390 		TEST_CASE_ST(ut_setup, ut_teardown,
17391 			test_AES_GCM_authenticated_decryption_test_case_3),
17392 		TEST_CASE_ST(ut_setup, ut_teardown,
17393 			test_AES_GCM_authenticated_decryption_test_case_4),
17394 		TEST_CASE_ST(ut_setup, ut_teardown,
17395 			test_AES_GCM_authenticated_decryption_test_case_5),
17396 		TEST_CASE_ST(ut_setup, ut_teardown,
17397 			test_AES_GCM_authenticated_decryption_test_case_6),
17398 		TEST_CASE_ST(ut_setup, ut_teardown,
17399 			test_AES_GCM_authenticated_decryption_test_case_7),
17400 		TEST_CASE_ST(ut_setup, ut_teardown,
17401 			test_AES_GCM_authenticated_decryption_test_case_8),
17402 		TEST_CASE_ST(ut_setup, ut_teardown,
17403 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
17404 
17405 		/** AES GCM Authenticated Encryption 192 bits key */
17406 		TEST_CASE_ST(ut_setup, ut_teardown,
17407 			test_AES_GCM_auth_encryption_test_case_192_1),
17408 		TEST_CASE_ST(ut_setup, ut_teardown,
17409 			test_AES_GCM_auth_encryption_test_case_192_2),
17410 		TEST_CASE_ST(ut_setup, ut_teardown,
17411 			test_AES_GCM_auth_encryption_test_case_192_3),
17412 		TEST_CASE_ST(ut_setup, ut_teardown,
17413 			test_AES_GCM_auth_encryption_test_case_192_4),
17414 		TEST_CASE_ST(ut_setup, ut_teardown,
17415 			test_AES_GCM_auth_encryption_test_case_192_5),
17416 		TEST_CASE_ST(ut_setup, ut_teardown,
17417 			test_AES_GCM_auth_encryption_test_case_192_6),
17418 		TEST_CASE_ST(ut_setup, ut_teardown,
17419 			test_AES_GCM_auth_encryption_test_case_192_7),
17420 
17421 		/** AES GCM Authenticated Decryption 192 bits key */
17422 		TEST_CASE_ST(ut_setup, ut_teardown,
17423 			test_AES_GCM_auth_decryption_test_case_192_1),
17424 		TEST_CASE_ST(ut_setup, ut_teardown,
17425 			test_AES_GCM_auth_decryption_test_case_192_2),
17426 		TEST_CASE_ST(ut_setup, ut_teardown,
17427 			test_AES_GCM_auth_decryption_test_case_192_3),
17428 		TEST_CASE_ST(ut_setup, ut_teardown,
17429 			test_AES_GCM_auth_decryption_test_case_192_4),
17430 		TEST_CASE_ST(ut_setup, ut_teardown,
17431 			test_AES_GCM_auth_decryption_test_case_192_5),
17432 		TEST_CASE_ST(ut_setup, ut_teardown,
17433 			test_AES_GCM_auth_decryption_test_case_192_6),
17434 		TEST_CASE_ST(ut_setup, ut_teardown,
17435 			test_AES_GCM_auth_decryption_test_case_192_7),
17436 
17437 		/** AES GCM Authenticated Encryption 256 bits key */
17438 		TEST_CASE_ST(ut_setup, ut_teardown,
17439 			test_AES_GCM_auth_encryption_test_case_256_1),
17440 		TEST_CASE_ST(ut_setup, ut_teardown,
17441 			test_AES_GCM_auth_encryption_test_case_256_2),
17442 		TEST_CASE_ST(ut_setup, ut_teardown,
17443 			test_AES_GCM_auth_encryption_test_case_256_3),
17444 		TEST_CASE_ST(ut_setup, ut_teardown,
17445 			test_AES_GCM_auth_encryption_test_case_256_4),
17446 		TEST_CASE_ST(ut_setup, ut_teardown,
17447 			test_AES_GCM_auth_encryption_test_case_256_5),
17448 		TEST_CASE_ST(ut_setup, ut_teardown,
17449 			test_AES_GCM_auth_encryption_test_case_256_6),
17450 		TEST_CASE_ST(ut_setup, ut_teardown,
17451 			test_AES_GCM_auth_encryption_test_case_256_7),
17452 
17453 		/** AES GCM Authenticated Decryption 256 bits key */
17454 		TEST_CASE_ST(ut_setup, ut_teardown,
17455 			test_AES_GCM_auth_decryption_test_case_256_1),
17456 		TEST_CASE_ST(ut_setup, ut_teardown,
17457 			test_AES_GCM_auth_decryption_test_case_256_2),
17458 		TEST_CASE_ST(ut_setup, ut_teardown,
17459 			test_AES_GCM_auth_decryption_test_case_256_3),
17460 		TEST_CASE_ST(ut_setup, ut_teardown,
17461 			test_AES_GCM_auth_decryption_test_case_256_4),
17462 		TEST_CASE_ST(ut_setup, ut_teardown,
17463 			test_AES_GCM_auth_decryption_test_case_256_5),
17464 		TEST_CASE_ST(ut_setup, ut_teardown,
17465 			test_AES_GCM_auth_decryption_test_case_256_6),
17466 		TEST_CASE_ST(ut_setup, ut_teardown,
17467 			test_AES_GCM_auth_decryption_test_case_256_7),
17468 
17469 		/** AES GCM Authenticated Encryption big aad size */
17470 		TEST_CASE_ST(ut_setup, ut_teardown,
17471 			test_AES_GCM_auth_encryption_test_case_aad_1),
17472 		TEST_CASE_ST(ut_setup, ut_teardown,
17473 			test_AES_GCM_auth_encryption_test_case_aad_2),
17474 
17475 		/** AES GCM Authenticated Decryption big aad size */
17476 		TEST_CASE_ST(ut_setup, ut_teardown,
17477 			test_AES_GCM_auth_decryption_test_case_aad_1),
17478 		TEST_CASE_ST(ut_setup, ut_teardown,
17479 			test_AES_GCM_auth_decryption_test_case_aad_2),
17480 
17481 		/** Out of place tests */
17482 		TEST_CASE_ST(ut_setup, ut_teardown,
17483 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
17484 		TEST_CASE_ST(ut_setup, ut_teardown,
17485 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
17486 
17487 		/** Session-less tests */
17488 		TEST_CASE_ST(ut_setup, ut_teardown,
17489 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
17490 		TEST_CASE_ST(ut_setup, ut_teardown,
17491 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
17492 
17493 		/** AES GCM external mbuf tests */
17494 		TEST_CASE_ST(ut_setup, ut_teardown,
17495 			test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
17496 		TEST_CASE_ST(ut_setup, ut_teardown,
17497 			test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
17498 
17499 		TEST_CASES_END()
17500 	}
17501 };
17502 
17503 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
17504 	.suite_name = "AES GMAC Authentication Test Suite",
17505 	.setup = aes_gmac_auth_testsuite_setup,
17506 	.unit_test_cases = {
17507 		TEST_CASE_ST(ut_setup, ut_teardown,
17508 			test_AES_GMAC_authentication_test_case_1),
17509 		TEST_CASE_ST(ut_setup, ut_teardown,
17510 			test_AES_GMAC_authentication_verify_test_case_1),
17511 		TEST_CASE_ST(ut_setup, ut_teardown,
17512 			test_AES_GMAC_authentication_test_case_2),
17513 		TEST_CASE_ST(ut_setup, ut_teardown,
17514 			test_AES_GMAC_authentication_verify_test_case_2),
17515 		TEST_CASE_ST(ut_setup, ut_teardown,
17516 			test_AES_GMAC_authentication_test_case_3),
17517 		TEST_CASE_ST(ut_setup, ut_teardown,
17518 			test_AES_GMAC_authentication_verify_test_case_3),
17519 		TEST_CASE_ST(ut_setup, ut_teardown,
17520 			test_AES_GMAC_authentication_test_case_4),
17521 		TEST_CASE_ST(ut_setup, ut_teardown,
17522 			test_AES_GMAC_authentication_verify_test_case_4),
17523 		TEST_CASE_ST(ut_setup, ut_teardown,
17524 			test_AES_GMAC_authentication_SGL_40B),
17525 		TEST_CASE_ST(ut_setup, ut_teardown,
17526 			test_AES_GMAC_authentication_SGL_80B),
17527 		TEST_CASE_ST(ut_setup, ut_teardown,
17528 			test_AES_GMAC_authentication_SGL_2048B),
17529 		TEST_CASE_ST(ut_setup, ut_teardown,
17530 			test_AES_GMAC_authentication_SGL_2047B),
17531 
17532 		TEST_CASES_END()
17533 	}
17534 };
17535 
17536 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
17537 	.suite_name = "Chacha20-Poly1305 Test Suite",
17538 	.setup = chacha20_poly1305_testsuite_setup,
17539 	.unit_test_cases = {
17540 		TEST_CASE_ST(ut_setup, ut_teardown,
17541 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
17542 		TEST_CASE_ST(ut_setup, ut_teardown,
17543 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
17544 		TEST_CASE_ST(ut_setup, ut_teardown,
17545 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
17546 		TEST_CASES_END()
17547 	}
17548 };
17549 
17550 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
17551 	.suite_name = "SNOW 3G Test Suite",
17552 	.setup = snow3g_testsuite_setup,
17553 	.unit_test_cases = {
17554 		/** SNOW 3G encrypt only (UEA2) */
17555 		TEST_CASE_ST(ut_setup, ut_teardown,
17556 			test_snow3g_encryption_test_case_1),
17557 		TEST_CASE_ST(ut_setup, ut_teardown,
17558 			test_snow3g_encryption_test_case_2),
17559 		TEST_CASE_ST(ut_setup, ut_teardown,
17560 			test_snow3g_encryption_test_case_3),
17561 		TEST_CASE_ST(ut_setup, ut_teardown,
17562 			test_snow3g_encryption_test_case_4),
17563 		TEST_CASE_ST(ut_setup, ut_teardown,
17564 			test_snow3g_encryption_test_case_5),
17565 
17566 		TEST_CASE_ST(ut_setup, ut_teardown,
17567 			test_snow3g_encryption_test_case_1_oop),
17568 		TEST_CASE_ST(ut_setup, ut_teardown,
17569 			test_snow3g_encryption_test_case_1_oop_sgl),
17570 		TEST_CASE_ST(ut_setup, ut_teardown,
17571 			test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
17572 		TEST_CASE_ST(ut_setup, ut_teardown,
17573 			test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
17574 		TEST_CASE_ST(ut_setup, ut_teardown,
17575 			test_snow3g_encryption_test_case_1_offset_oop),
17576 		TEST_CASE_ST(ut_setup, ut_teardown,
17577 			test_snow3g_decryption_test_case_1_oop),
17578 
17579 		/** SNOW 3G generate auth, then encrypt (UEA2) */
17580 		TEST_CASE_ST(ut_setup, ut_teardown,
17581 			test_snow3g_auth_cipher_test_case_1),
17582 		TEST_CASE_ST(ut_setup, ut_teardown,
17583 			test_snow3g_auth_cipher_test_case_2),
17584 		TEST_CASE_ST(ut_setup, ut_teardown,
17585 			test_snow3g_auth_cipher_test_case_2_oop),
17586 		TEST_CASE_ST(ut_setup, ut_teardown,
17587 			test_snow3g_auth_cipher_part_digest_enc),
17588 		TEST_CASE_ST(ut_setup, ut_teardown,
17589 			test_snow3g_auth_cipher_part_digest_enc_oop),
17590 		TEST_CASE_ST(ut_setup, ut_teardown,
17591 			test_snow3g_auth_cipher_test_case_3_sgl),
17592 		TEST_CASE_ST(ut_setup, ut_teardown,
17593 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
17594 		TEST_CASE_ST(ut_setup, ut_teardown,
17595 			test_snow3g_auth_cipher_part_digest_enc_sgl),
17596 		TEST_CASE_ST(ut_setup, ut_teardown,
17597 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
17598 		TEST_CASE_ST(ut_setup, ut_teardown,
17599 			test_snow3g_auth_cipher_total_digest_enc_1),
17600 		TEST_CASE_ST(ut_setup, ut_teardown,
17601 			test_snow3g_auth_cipher_total_digest_enc_1_oop),
17602 		TEST_CASE_ST(ut_setup, ut_teardown,
17603 			test_snow3g_auth_cipher_total_digest_enc_1_sgl),
17604 		TEST_CASE_ST(ut_setup, ut_teardown,
17605 			test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
17606 
17607 		/** SNOW 3G decrypt (UEA2), then verify auth */
17608 		TEST_CASE_ST(ut_setup, ut_teardown,
17609 			test_snow3g_auth_cipher_verify_test_case_1),
17610 		TEST_CASE_ST(ut_setup, ut_teardown,
17611 			test_snow3g_auth_cipher_verify_test_case_2),
17612 		TEST_CASE_ST(ut_setup, ut_teardown,
17613 			test_snow3g_auth_cipher_verify_test_case_2_oop),
17614 		TEST_CASE_ST(ut_setup, ut_teardown,
17615 			test_snow3g_auth_cipher_verify_part_digest_enc),
17616 		TEST_CASE_ST(ut_setup, ut_teardown,
17617 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
17618 		TEST_CASE_ST(ut_setup, ut_teardown,
17619 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
17620 		TEST_CASE_ST(ut_setup, ut_teardown,
17621 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
17622 		TEST_CASE_ST(ut_setup, ut_teardown,
17623 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
17624 		TEST_CASE_ST(ut_setup, ut_teardown,
17625 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
17626 		TEST_CASE_ST(ut_setup, ut_teardown,
17627 			test_snow3g_auth_cipher_verify_total_digest_enc_1),
17628 		TEST_CASE_ST(ut_setup, ut_teardown,
17629 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
17630 		TEST_CASE_ST(ut_setup, ut_teardown,
17631 			test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
17632 		TEST_CASE_ST(ut_setup, ut_teardown,
17633 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
17634 
17635 		/** SNOW 3G decrypt only (UEA2) */
17636 		TEST_CASE_ST(ut_setup, ut_teardown,
17637 			test_snow3g_decryption_test_case_1),
17638 		TEST_CASE_ST(ut_setup, ut_teardown,
17639 			test_snow3g_decryption_test_case_2),
17640 		TEST_CASE_ST(ut_setup, ut_teardown,
17641 			test_snow3g_decryption_test_case_3),
17642 		TEST_CASE_ST(ut_setup, ut_teardown,
17643 			test_snow3g_decryption_test_case_4),
17644 		TEST_CASE_ST(ut_setup, ut_teardown,
17645 			test_snow3g_decryption_test_case_5),
17646 		TEST_CASE_ST(ut_setup, ut_teardown,
17647 			test_snow3g_decryption_with_digest_test_case_1),
17648 		TEST_CASE_ST(ut_setup, ut_teardown,
17649 			test_snow3g_hash_generate_test_case_1),
17650 		TEST_CASE_ST(ut_setup, ut_teardown,
17651 			test_snow3g_hash_generate_test_case_2),
17652 		TEST_CASE_ST(ut_setup, ut_teardown,
17653 			test_snow3g_hash_generate_test_case_3),
17654 
17655 		/* Tests with buffers which length is not byte-aligned */
17656 		TEST_CASE_ST(ut_setup, ut_teardown,
17657 			test_snow3g_hash_generate_test_case_4),
17658 		TEST_CASE_ST(ut_setup, ut_teardown,
17659 			test_snow3g_hash_generate_test_case_5),
17660 		TEST_CASE_ST(ut_setup, ut_teardown,
17661 			test_snow3g_hash_generate_test_case_6),
17662 		TEST_CASE_ST(ut_setup, ut_teardown,
17663 			test_snow3g_hash_verify_test_case_1),
17664 		TEST_CASE_ST(ut_setup, ut_teardown,
17665 			test_snow3g_hash_verify_test_case_2),
17666 		TEST_CASE_ST(ut_setup, ut_teardown,
17667 			test_snow3g_hash_verify_test_case_3),
17668 
17669 		/* Tests with buffers which length is not byte-aligned */
17670 		TEST_CASE_ST(ut_setup, ut_teardown,
17671 			test_snow3g_hash_verify_test_case_4),
17672 		TEST_CASE_ST(ut_setup, ut_teardown,
17673 			test_snow3g_hash_verify_test_case_5),
17674 		TEST_CASE_ST(ut_setup, ut_teardown,
17675 			test_snow3g_hash_verify_test_case_6),
17676 		TEST_CASE_ST(ut_setup, ut_teardown,
17677 			test_snow3g_cipher_auth_test_case_1),
17678 		TEST_CASE_ST(ut_setup, ut_teardown,
17679 			test_snow3g_auth_cipher_with_digest_test_case_1),
17680 		TEST_CASES_END()
17681 	}
17682 };
17683 
17684 static struct unit_test_suite cryptodev_zuc_testsuite  = {
17685 	.suite_name = "ZUC Test Suite",
17686 	.setup = zuc_testsuite_setup,
17687 	.unit_test_cases = {
17688 		/** ZUC encrypt only (EEA3) */
17689 		TEST_CASE_ST(ut_setup, ut_teardown,
17690 			test_zuc_encryption_test_case_1),
17691 		TEST_CASE_ST(ut_setup, ut_teardown,
17692 			test_zuc_encryption_test_case_2),
17693 		TEST_CASE_ST(ut_setup, ut_teardown,
17694 			test_zuc_encryption_test_case_3),
17695 		TEST_CASE_ST(ut_setup, ut_teardown,
17696 			test_zuc_encryption_test_case_4),
17697 		TEST_CASE_ST(ut_setup, ut_teardown,
17698 			test_zuc_encryption_test_case_5),
17699 		TEST_CASE_ST(ut_setup, ut_teardown,
17700 			test_zuc_encryption_test_case_6_sgl),
17701 
17702 		/** ZUC decrypt only (EEA3) */
17703 		TEST_CASE_ST(ut_setup, ut_teardown,
17704 			test_zuc_decryption_test_case_1),
17705 		TEST_CASE_ST(ut_setup, ut_teardown,
17706 			test_zuc_decryption_test_case_2),
17707 		TEST_CASE_ST(ut_setup, ut_teardown,
17708 			test_zuc_decryption_test_case_3),
17709 		TEST_CASE_ST(ut_setup, ut_teardown,
17710 			test_zuc_decryption_test_case_4),
17711 		TEST_CASE_ST(ut_setup, ut_teardown,
17712 			test_zuc_decryption_test_case_5),
17713 		TEST_CASE_ST(ut_setup, ut_teardown,
17714 			test_zuc_decryption_test_case_6_sgl),
17715 
17716 		/** ZUC authenticate (EIA3) */
17717 		TEST_CASE_ST(ut_setup, ut_teardown,
17718 			test_zuc_hash_generate_test_case_1),
17719 		TEST_CASE_ST(ut_setup, ut_teardown,
17720 			test_zuc_hash_generate_test_case_2),
17721 		TEST_CASE_ST(ut_setup, ut_teardown,
17722 			test_zuc_hash_generate_test_case_3),
17723 		TEST_CASE_ST(ut_setup, ut_teardown,
17724 			test_zuc_hash_generate_test_case_4),
17725 		TEST_CASE_ST(ut_setup, ut_teardown,
17726 			test_zuc_hash_generate_test_case_5),
17727 		TEST_CASE_ST(ut_setup, ut_teardown,
17728 			test_zuc_hash_generate_test_case_6),
17729 		TEST_CASE_ST(ut_setup, ut_teardown,
17730 			test_zuc_hash_generate_test_case_7),
17731 		TEST_CASE_ST(ut_setup, ut_teardown,
17732 			test_zuc_hash_generate_test_case_8),
17733 
17734 		/** ZUC verify (EIA3) */
17735 		TEST_CASE_ST(ut_setup, ut_teardown,
17736 			test_zuc_hash_verify_test_case_1),
17737 		TEST_CASE_ST(ut_setup, ut_teardown,
17738 			test_zuc_hash_verify_test_case_2),
17739 		TEST_CASE_ST(ut_setup, ut_teardown,
17740 			test_zuc_hash_verify_test_case_3),
17741 		TEST_CASE_ST(ut_setup, ut_teardown,
17742 			test_zuc_hash_verify_test_case_4),
17743 		TEST_CASE_ST(ut_setup, ut_teardown,
17744 			test_zuc_hash_verify_test_case_5),
17745 		TEST_CASE_ST(ut_setup, ut_teardown,
17746 			test_zuc_hash_verify_test_case_6),
17747 		TEST_CASE_ST(ut_setup, ut_teardown,
17748 			test_zuc_hash_verify_test_case_7),
17749 		TEST_CASE_ST(ut_setup, ut_teardown,
17750 			test_zuc_hash_verify_test_case_8),
17751 
17752 		/** ZUC alg-chain (EEA3/EIA3) */
17753 		TEST_CASE_ST(ut_setup, ut_teardown,
17754 			test_zuc_cipher_auth_test_case_1),
17755 		TEST_CASE_ST(ut_setup, ut_teardown,
17756 			test_zuc_cipher_auth_test_case_2),
17757 
17758 		/** ZUC generate auth, then encrypt (EEA3) */
17759 		TEST_CASE_ST(ut_setup, ut_teardown,
17760 			test_zuc_auth_cipher_test_case_1),
17761 		TEST_CASE_ST(ut_setup, ut_teardown,
17762 			test_zuc_auth_cipher_test_case_1_oop),
17763 		TEST_CASE_ST(ut_setup, ut_teardown,
17764 			test_zuc_auth_cipher_test_case_1_sgl),
17765 		TEST_CASE_ST(ut_setup, ut_teardown,
17766 			test_zuc_auth_cipher_test_case_1_oop_sgl),
17767 		TEST_CASE_ST(ut_setup, ut_teardown,
17768 			test_zuc_auth_cipher_test_case_2),
17769 		TEST_CASE_ST(ut_setup, ut_teardown,
17770 			test_zuc_auth_cipher_test_case_2_oop),
17771 
17772 		/** ZUC decrypt (EEA3), then verify auth */
17773 		TEST_CASE_ST(ut_setup, ut_teardown,
17774 			test_zuc_auth_cipher_verify_test_case_1),
17775 		TEST_CASE_ST(ut_setup, ut_teardown,
17776 			test_zuc_auth_cipher_verify_test_case_1_oop),
17777 		TEST_CASE_ST(ut_setup, ut_teardown,
17778 			test_zuc_auth_cipher_verify_test_case_1_sgl),
17779 		TEST_CASE_ST(ut_setup, ut_teardown,
17780 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
17781 		TEST_CASE_ST(ut_setup, ut_teardown,
17782 			test_zuc_auth_cipher_verify_test_case_2),
17783 		TEST_CASE_ST(ut_setup, ut_teardown,
17784 			test_zuc_auth_cipher_verify_test_case_2_oop),
17785 
17786 		/** ZUC-256 encrypt only **/
17787 		TEST_CASE_ST(ut_setup, ut_teardown,
17788 			test_zuc256_encryption_test_case_1),
17789 		TEST_CASE_ST(ut_setup, ut_teardown,
17790 			test_zuc256_encryption_test_case_2),
17791 
17792 		/** ZUC-256 decrypt only **/
17793 		TEST_CASE_ST(ut_setup, ut_teardown,
17794 			test_zuc256_decryption_test_case_1),
17795 		TEST_CASE_ST(ut_setup, ut_teardown,
17796 			test_zuc256_decryption_test_case_2),
17797 
17798 		/** ZUC-256 authentication only **/
17799 		TEST_CASE_ST(ut_setup, ut_teardown,
17800 			test_zuc256_hash_generate_4b_tag_test_case_1),
17801 		TEST_CASE_ST(ut_setup, ut_teardown,
17802 			test_zuc256_hash_generate_4b_tag_test_case_2),
17803 		TEST_CASE_ST(ut_setup, ut_teardown,
17804 			test_zuc256_hash_generate_4b_tag_test_case_3),
17805 		TEST_CASE_ST(ut_setup, ut_teardown,
17806 			test_zuc256_hash_generate_8b_tag_test_case_1),
17807 		TEST_CASE_ST(ut_setup, ut_teardown,
17808 			test_zuc256_hash_generate_16b_tag_test_case_1),
17809 
17810 		/** ZUC-256 authentication verify only **/
17811 		TEST_CASE_ST(ut_setup, ut_teardown,
17812 			test_zuc256_hash_verify_4b_tag_test_case_1),
17813 		TEST_CASE_ST(ut_setup, ut_teardown,
17814 			test_zuc256_hash_verify_4b_tag_test_case_2),
17815 		TEST_CASE_ST(ut_setup, ut_teardown,
17816 			test_zuc256_hash_verify_4b_tag_test_case_3),
17817 		TEST_CASE_ST(ut_setup, ut_teardown,
17818 			test_zuc256_hash_verify_8b_tag_test_case_1),
17819 		TEST_CASE_ST(ut_setup, ut_teardown,
17820 			test_zuc256_hash_verify_16b_tag_test_case_1),
17821 
17822 		/** ZUC-256 encrypt and authenticate **/
17823 		TEST_CASE_ST(ut_setup, ut_teardown,
17824 			test_zuc256_cipher_auth_4b_tag_test_case_1),
17825 		TEST_CASE_ST(ut_setup, ut_teardown,
17826 			test_zuc256_cipher_auth_4b_tag_test_case_2),
17827 		TEST_CASE_ST(ut_setup, ut_teardown,
17828 			test_zuc256_cipher_auth_8b_tag_test_case_1),
17829 		TEST_CASE_ST(ut_setup, ut_teardown,
17830 			test_zuc256_cipher_auth_16b_tag_test_case_1),
17831 
17832 		/** ZUC-256 generate auth, then encrypt */
17833 		TEST_CASE_ST(ut_setup, ut_teardown,
17834 			test_zuc256_auth_cipher_4b_tag_test_case_1),
17835 		TEST_CASE_ST(ut_setup, ut_teardown,
17836 			test_zuc256_auth_cipher_4b_tag_test_case_2),
17837 		TEST_CASE_ST(ut_setup, ut_teardown,
17838 			test_zuc256_auth_cipher_8b_tag_test_case_1),
17839 		TEST_CASE_ST(ut_setup, ut_teardown,
17840 			test_zuc256_auth_cipher_16b_tag_test_case_1),
17841 
17842 		/** ZUC-256 decrypt, then verify auth */
17843 		TEST_CASE_ST(ut_setup, ut_teardown,
17844 			test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
17845 		TEST_CASE_ST(ut_setup, ut_teardown,
17846 			test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
17847 		TEST_CASE_ST(ut_setup, ut_teardown,
17848 			test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
17849 		TEST_CASE_ST(ut_setup, ut_teardown,
17850 			test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
17851 
17852 		TEST_CASES_END()
17853 	}
17854 };
17855 
17856 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
17857 	.suite_name = "HMAC_MD5 Authentication Test Suite",
17858 	.setup = hmac_md5_auth_testsuite_setup,
17859 	.unit_test_cases = {
17860 		TEST_CASE_ST(ut_setup, ut_teardown,
17861 			test_MD5_HMAC_generate_case_1),
17862 		TEST_CASE_ST(ut_setup, ut_teardown,
17863 			test_MD5_HMAC_verify_case_1),
17864 		TEST_CASE_ST(ut_setup, ut_teardown,
17865 			test_MD5_HMAC_generate_case_2),
17866 		TEST_CASE_ST(ut_setup, ut_teardown,
17867 			test_MD5_HMAC_verify_case_2),
17868 		TEST_CASES_END()
17869 	}
17870 };
17871 
17872 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
17873 	.suite_name = "Kasumi Test Suite",
17874 	.setup = kasumi_testsuite_setup,
17875 	.unit_test_cases = {
17876 		/** KASUMI hash only (UIA1) */
17877 		TEST_CASE_ST(ut_setup, ut_teardown,
17878 			test_kasumi_hash_generate_test_case_1),
17879 		TEST_CASE_ST(ut_setup, ut_teardown,
17880 			test_kasumi_hash_generate_test_case_2),
17881 		TEST_CASE_ST(ut_setup, ut_teardown,
17882 			test_kasumi_hash_generate_test_case_3),
17883 		TEST_CASE_ST(ut_setup, ut_teardown,
17884 			test_kasumi_hash_generate_test_case_4),
17885 		TEST_CASE_ST(ut_setup, ut_teardown,
17886 			test_kasumi_hash_generate_test_case_5),
17887 		TEST_CASE_ST(ut_setup, ut_teardown,
17888 			test_kasumi_hash_generate_test_case_6),
17889 
17890 		TEST_CASE_ST(ut_setup, ut_teardown,
17891 			test_kasumi_hash_verify_test_case_1),
17892 		TEST_CASE_ST(ut_setup, ut_teardown,
17893 			test_kasumi_hash_verify_test_case_2),
17894 		TEST_CASE_ST(ut_setup, ut_teardown,
17895 			test_kasumi_hash_verify_test_case_3),
17896 		TEST_CASE_ST(ut_setup, ut_teardown,
17897 			test_kasumi_hash_verify_test_case_4),
17898 		TEST_CASE_ST(ut_setup, ut_teardown,
17899 			test_kasumi_hash_verify_test_case_5),
17900 
17901 		/** KASUMI encrypt only (UEA1) */
17902 		TEST_CASE_ST(ut_setup, ut_teardown,
17903 			test_kasumi_encryption_test_case_1),
17904 		TEST_CASE_ST(ut_setup, ut_teardown,
17905 			test_kasumi_encryption_test_case_1_sgl),
17906 		TEST_CASE_ST(ut_setup, ut_teardown,
17907 			test_kasumi_encryption_test_case_1_oop),
17908 		TEST_CASE_ST(ut_setup, ut_teardown,
17909 			test_kasumi_encryption_test_case_1_oop_sgl),
17910 		TEST_CASE_ST(ut_setup, ut_teardown,
17911 			test_kasumi_encryption_test_case_2),
17912 		TEST_CASE_ST(ut_setup, ut_teardown,
17913 			test_kasumi_encryption_test_case_3),
17914 		TEST_CASE_ST(ut_setup, ut_teardown,
17915 			test_kasumi_encryption_test_case_4),
17916 		TEST_CASE_ST(ut_setup, ut_teardown,
17917 			test_kasumi_encryption_test_case_5),
17918 
17919 		/** KASUMI decrypt only (UEA1) */
17920 		TEST_CASE_ST(ut_setup, ut_teardown,
17921 			test_kasumi_decryption_test_case_1),
17922 		TEST_CASE_ST(ut_setup, ut_teardown,
17923 			test_kasumi_decryption_test_case_2),
17924 		TEST_CASE_ST(ut_setup, ut_teardown,
17925 			test_kasumi_decryption_test_case_3),
17926 		TEST_CASE_ST(ut_setup, ut_teardown,
17927 			test_kasumi_decryption_test_case_4),
17928 		TEST_CASE_ST(ut_setup, ut_teardown,
17929 			test_kasumi_decryption_test_case_5),
17930 		TEST_CASE_ST(ut_setup, ut_teardown,
17931 			test_kasumi_decryption_test_case_1_oop),
17932 		TEST_CASE_ST(ut_setup, ut_teardown,
17933 			test_kasumi_cipher_auth_test_case_1),
17934 
17935 		/** KASUMI generate auth, then encrypt (F8) */
17936 		TEST_CASE_ST(ut_setup, ut_teardown,
17937 			test_kasumi_auth_cipher_test_case_1),
17938 		TEST_CASE_ST(ut_setup, ut_teardown,
17939 			test_kasumi_auth_cipher_test_case_2),
17940 		TEST_CASE_ST(ut_setup, ut_teardown,
17941 			test_kasumi_auth_cipher_test_case_2_oop),
17942 		TEST_CASE_ST(ut_setup, ut_teardown,
17943 			test_kasumi_auth_cipher_test_case_2_sgl),
17944 		TEST_CASE_ST(ut_setup, ut_teardown,
17945 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
17946 
17947 		/** KASUMI decrypt (F8), then verify auth */
17948 		TEST_CASE_ST(ut_setup, ut_teardown,
17949 			test_kasumi_auth_cipher_verify_test_case_1),
17950 		TEST_CASE_ST(ut_setup, ut_teardown,
17951 			test_kasumi_auth_cipher_verify_test_case_2),
17952 		TEST_CASE_ST(ut_setup, ut_teardown,
17953 			test_kasumi_auth_cipher_verify_test_case_2_oop),
17954 		TEST_CASE_ST(ut_setup, ut_teardown,
17955 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
17956 		TEST_CASE_ST(ut_setup, ut_teardown,
17957 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
17958 
17959 		TEST_CASES_END()
17960 	}
17961 };
17962 
17963 static struct unit_test_suite cryptodev_esn_testsuite  = {
17964 	.suite_name = "ESN Test Suite",
17965 	.setup = esn_testsuite_setup,
17966 	.unit_test_cases = {
17967 		TEST_CASE_ST(ut_setup, ut_teardown,
17968 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
17969 		TEST_CASE_ST(ut_setup, ut_teardown,
17970 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
17971 		TEST_CASES_END()
17972 	}
17973 };
17974 
17975 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
17976 	.suite_name = "Negative AES GCM Test Suite",
17977 	.setup = negative_aes_gcm_testsuite_setup,
17978 	.unit_test_cases = {
17979 		TEST_CASE_ST(ut_setup, ut_teardown,
17980 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
17981 		TEST_CASE_ST(ut_setup, ut_teardown,
17982 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
17983 		TEST_CASE_ST(ut_setup, ut_teardown,
17984 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
17985 		TEST_CASE_ST(ut_setup, ut_teardown,
17986 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
17987 		TEST_CASE_ST(ut_setup, ut_teardown,
17988 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
17989 		TEST_CASE_ST(ut_setup, ut_teardown,
17990 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
17991 		TEST_CASE_ST(ut_setup, ut_teardown,
17992 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
17993 		TEST_CASE_ST(ut_setup, ut_teardown,
17994 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
17995 		TEST_CASE_ST(ut_setup, ut_teardown,
17996 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
17997 		TEST_CASE_ST(ut_setup, ut_teardown,
17998 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
17999 		TEST_CASE_ST(ut_setup, ut_teardown,
18000 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
18001 		TEST_CASE_ST(ut_setup, ut_teardown,
18002 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
18003 
18004 		TEST_CASES_END()
18005 	}
18006 };
18007 
18008 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
18009 	.suite_name = "Negative AES GMAC Test Suite",
18010 	.setup = negative_aes_gmac_testsuite_setup,
18011 	.unit_test_cases = {
18012 		TEST_CASE_ST(ut_setup, ut_teardown,
18013 			authentication_verify_AES128_GMAC_fail_data_corrupt),
18014 		TEST_CASE_ST(ut_setup, ut_teardown,
18015 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
18016 
18017 		TEST_CASES_END()
18018 	}
18019 };
18020 
18021 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
18022 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
18023 	.setup = mixed_cipher_hash_testsuite_setup,
18024 	.unit_test_cases = {
18025 		/** AUTH AES CMAC + CIPHER AES CTR */
18026 		TEST_CASE_ST(ut_setup, ut_teardown,
18027 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
18028 		TEST_CASE_ST(ut_setup, ut_teardown,
18029 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18030 		TEST_CASE_ST(ut_setup, ut_teardown,
18031 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18032 		TEST_CASE_ST(ut_setup, ut_teardown,
18033 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18034 		TEST_CASE_ST(ut_setup, ut_teardown,
18035 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
18036 		TEST_CASE_ST(ut_setup, ut_teardown,
18037 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18038 		TEST_CASE_ST(ut_setup, ut_teardown,
18039 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18040 		TEST_CASE_ST(ut_setup, ut_teardown,
18041 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18042 		TEST_CASE_ST(ut_setup, ut_teardown,
18043 			test_aes_cmac_aes_ctr_digest_enc_test_case_2),
18044 		TEST_CASE_ST(ut_setup, ut_teardown,
18045 			test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18046 		TEST_CASE_ST(ut_setup, ut_teardown,
18047 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
18048 		TEST_CASE_ST(ut_setup, ut_teardown,
18049 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18050 
18051 		/** AUTH ZUC + CIPHER SNOW3G */
18052 		TEST_CASE_ST(ut_setup, ut_teardown,
18053 			test_auth_zuc_cipher_snow_test_case_1),
18054 		TEST_CASE_ST(ut_setup, ut_teardown,
18055 			test_verify_auth_zuc_cipher_snow_test_case_1),
18056 		TEST_CASE_ST(ut_setup, ut_teardown,
18057 			test_auth_zuc_cipher_snow_test_case_1_inplace),
18058 		TEST_CASE_ST(ut_setup, ut_teardown,
18059 			test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
18060 		/** AUTH AES CMAC + CIPHER SNOW3G */
18061 		TEST_CASE_ST(ut_setup, ut_teardown,
18062 			test_auth_aes_cmac_cipher_snow_test_case_1),
18063 		TEST_CASE_ST(ut_setup, ut_teardown,
18064 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
18065 		TEST_CASE_ST(ut_setup, ut_teardown,
18066 			test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18067 		TEST_CASE_ST(ut_setup, ut_teardown,
18068 			test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18069 		/** AUTH ZUC + CIPHER AES CTR */
18070 		TEST_CASE_ST(ut_setup, ut_teardown,
18071 			test_auth_zuc_cipher_aes_ctr_test_case_1),
18072 		TEST_CASE_ST(ut_setup, ut_teardown,
18073 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
18074 		TEST_CASE_ST(ut_setup, ut_teardown,
18075 			test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18076 		TEST_CASE_ST(ut_setup, ut_teardown,
18077 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18078 		/** AUTH SNOW3G + CIPHER AES CTR */
18079 		TEST_CASE_ST(ut_setup, ut_teardown,
18080 			test_auth_snow_cipher_aes_ctr_test_case_1),
18081 		TEST_CASE_ST(ut_setup, ut_teardown,
18082 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
18083 		TEST_CASE_ST(ut_setup, ut_teardown,
18084 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18085 		TEST_CASE_ST(ut_setup, ut_teardown,
18086 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18087 		TEST_CASE_ST(ut_setup, ut_teardown,
18088 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18089 		TEST_CASE_ST(ut_setup, ut_teardown,
18090 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18091 		/** AUTH SNOW3G + CIPHER ZUC */
18092 		TEST_CASE_ST(ut_setup, ut_teardown,
18093 			test_auth_snow_cipher_zuc_test_case_1),
18094 		TEST_CASE_ST(ut_setup, ut_teardown,
18095 			test_verify_auth_snow_cipher_zuc_test_case_1),
18096 		TEST_CASE_ST(ut_setup, ut_teardown,
18097 			test_auth_snow_cipher_zuc_test_case_1_inplace),
18098 		TEST_CASE_ST(ut_setup, ut_teardown,
18099 			test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
18100 		/** AUTH AES CMAC + CIPHER ZUC */
18101 		TEST_CASE_ST(ut_setup, ut_teardown,
18102 			test_auth_aes_cmac_cipher_zuc_test_case_1),
18103 		TEST_CASE_ST(ut_setup, ut_teardown,
18104 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
18105 		TEST_CASE_ST(ut_setup, ut_teardown,
18106 			test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18107 		TEST_CASE_ST(ut_setup, ut_teardown,
18108 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18109 
18110 		/** AUTH NULL + CIPHER SNOW3G */
18111 		TEST_CASE_ST(ut_setup, ut_teardown,
18112 			test_auth_null_cipher_snow_test_case_1),
18113 		TEST_CASE_ST(ut_setup, ut_teardown,
18114 			test_verify_auth_null_cipher_snow_test_case_1),
18115 		/** AUTH NULL + CIPHER ZUC */
18116 		TEST_CASE_ST(ut_setup, ut_teardown,
18117 			test_auth_null_cipher_zuc_test_case_1),
18118 		TEST_CASE_ST(ut_setup, ut_teardown,
18119 			test_verify_auth_null_cipher_zuc_test_case_1),
18120 		/** AUTH SNOW3G + CIPHER NULL */
18121 		TEST_CASE_ST(ut_setup, ut_teardown,
18122 			test_auth_snow_cipher_null_test_case_1),
18123 		TEST_CASE_ST(ut_setup, ut_teardown,
18124 			test_verify_auth_snow_cipher_null_test_case_1),
18125 		/** AUTH ZUC + CIPHER NULL */
18126 		TEST_CASE_ST(ut_setup, ut_teardown,
18127 			test_auth_zuc_cipher_null_test_case_1),
18128 		TEST_CASE_ST(ut_setup, ut_teardown,
18129 			test_verify_auth_zuc_cipher_null_test_case_1),
18130 		/** AUTH NULL + CIPHER AES CTR */
18131 		TEST_CASE_ST(ut_setup, ut_teardown,
18132 			test_auth_null_cipher_aes_ctr_test_case_1),
18133 		TEST_CASE_ST(ut_setup, ut_teardown,
18134 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
18135 		/** AUTH AES CMAC + CIPHER NULL */
18136 		TEST_CASE_ST(ut_setup, ut_teardown,
18137 			test_auth_aes_cmac_cipher_null_test_case_1),
18138 		TEST_CASE_ST(ut_setup, ut_teardown,
18139 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
18140 		TEST_CASES_END()
18141 	}
18142 };
18143 
18144 static int
18145 run_cryptodev_testsuite(const char *pmd_name)
18146 {
18147 	uint8_t ret, j, i = 0, blk_start_idx = 0;
18148 	const enum blockcipher_test_type blk_suites[] = {
18149 		BLKCIPHER_AES_CHAIN_TYPE,
18150 		BLKCIPHER_AES_CIPHERONLY_TYPE,
18151 		BLKCIPHER_AES_DOCSIS_TYPE,
18152 		BLKCIPHER_3DES_CHAIN_TYPE,
18153 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
18154 		BLKCIPHER_DES_CIPHERONLY_TYPE,
18155 		BLKCIPHER_DES_DOCSIS_TYPE,
18156 		BLKCIPHER_SM4_CHAIN_TYPE,
18157 		BLKCIPHER_SM4_CIPHERONLY_TYPE,
18158 		BLKCIPHER_AUTHONLY_TYPE};
18159 	struct unit_test_suite *static_suites[] = {
18160 		&cryptodev_multi_session_testsuite,
18161 		&cryptodev_null_testsuite,
18162 		&cryptodev_aes_ccm_auth_testsuite,
18163 		&cryptodev_aes_gcm_auth_testsuite,
18164 		&cryptodev_aes_gmac_auth_testsuite,
18165 		&cryptodev_snow3g_testsuite,
18166 		&cryptodev_chacha20_poly1305_testsuite,
18167 		&cryptodev_zuc_testsuite,
18168 		&cryptodev_hmac_md5_auth_testsuite,
18169 		&cryptodev_kasumi_testsuite,
18170 		&cryptodev_esn_testsuite,
18171 		&cryptodev_negative_aes_gcm_testsuite,
18172 		&cryptodev_negative_aes_gmac_testsuite,
18173 		&cryptodev_mixed_cipher_hash_testsuite,
18174 		&cryptodev_negative_hmac_sha1_testsuite,
18175 		&cryptodev_gen_testsuite,
18176 #ifdef RTE_LIB_SECURITY
18177 		&ipsec_proto_testsuite,
18178 		&pdcp_proto_testsuite,
18179 		&docsis_proto_testsuite,
18180 		&tls12_record_proto_testsuite,
18181 		&dtls12_record_proto_testsuite,
18182 #endif
18183 		&end_testsuite
18184 	};
18185 	static struct unit_test_suite ts = {
18186 		.suite_name = "Cryptodev Unit Test Suite",
18187 		.setup = testsuite_setup,
18188 		.teardown = testsuite_teardown,
18189 		.unit_test_cases = {TEST_CASES_END()}
18190 	};
18191 
18192 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
18193 
18194 	if (gbl_driver_id == -1) {
18195 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
18196 		return TEST_SKIPPED;
18197 	}
18198 
18199 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
18200 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
18201 
18202 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
18203 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
18204 	ret = unit_test_suite_runner(&ts);
18205 
18206 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
18207 	free(ts.unit_test_suites);
18208 	return ret;
18209 }
18210 
18211 static int
18212 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
18213 {
18214 	struct rte_cryptodev_info dev_info;
18215 	uint8_t i, nb_devs;
18216 	int driver_id;
18217 
18218 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
18219 	if (driver_id == -1) {
18220 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
18221 		return TEST_SKIPPED;
18222 	}
18223 
18224 	nb_devs = rte_cryptodev_count();
18225 	if (nb_devs < 1) {
18226 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
18227 		return TEST_SKIPPED;
18228 	}
18229 
18230 	for (i = 0; i < nb_devs; i++) {
18231 		rte_cryptodev_info_get(i, &dev_info);
18232 		if (dev_info.driver_id == driver_id) {
18233 			if (!(dev_info.feature_flags & flag)) {
18234 				RTE_LOG(INFO, USER1, "%s not supported\n",
18235 						flag_name);
18236 				return TEST_SKIPPED;
18237 			}
18238 			return 0; /* found */
18239 		}
18240 	}
18241 
18242 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
18243 	return TEST_SKIPPED;
18244 }
18245 
18246 static int
18247 test_cryptodev_qat(void)
18248 {
18249 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
18250 }
18251 
18252 static int
18253 test_cryptodev_uadk(void)
18254 {
18255 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
18256 }
18257 
18258 static int
18259 test_cryptodev_virtio(void)
18260 {
18261 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
18262 }
18263 
18264 static int
18265 test_cryptodev_aesni_mb(void)
18266 {
18267 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18268 }
18269 
18270 static int
18271 test_cryptodev_cpu_aesni_mb(void)
18272 {
18273 	int32_t rc;
18274 	enum rte_security_session_action_type at = gbl_action_type;
18275 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18276 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18277 	gbl_action_type = at;
18278 	return rc;
18279 }
18280 
18281 static int
18282 test_cryptodev_chacha_poly_mb(void)
18283 {
18284 	int32_t rc;
18285 	enum rte_security_session_action_type at = gbl_action_type;
18286 	rc = run_cryptodev_testsuite(
18287 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
18288 	gbl_action_type = at;
18289 	return rc;
18290 }
18291 
18292 static int
18293 test_cryptodev_openssl(void)
18294 {
18295 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
18296 }
18297 
18298 static int
18299 test_cryptodev_aesni_gcm(void)
18300 {
18301 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18302 }
18303 
18304 static int
18305 test_cryptodev_cpu_aesni_gcm(void)
18306 {
18307 	int32_t rc;
18308 	enum rte_security_session_action_type at = gbl_action_type;
18309 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18310 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18311 	gbl_action_type = at;
18312 	return rc;
18313 }
18314 
18315 static int
18316 test_cryptodev_mlx5(void)
18317 {
18318 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
18319 }
18320 
18321 static int
18322 test_cryptodev_null(void)
18323 {
18324 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
18325 }
18326 
18327 static int
18328 test_cryptodev_sw_snow3g(void)
18329 {
18330 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
18331 }
18332 
18333 static int
18334 test_cryptodev_sw_kasumi(void)
18335 {
18336 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
18337 }
18338 
18339 static int
18340 test_cryptodev_sw_zuc(void)
18341 {
18342 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
18343 }
18344 
18345 static int
18346 test_cryptodev_armv8(void)
18347 {
18348 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
18349 }
18350 
18351 static int
18352 test_cryptodev_mrvl(void)
18353 {
18354 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
18355 }
18356 
18357 #ifdef RTE_CRYPTO_SCHEDULER
18358 
18359 static int
18360 test_cryptodev_scheduler(void)
18361 {
18362 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
18363 	const enum blockcipher_test_type blk_suites[] = {
18364 		BLKCIPHER_AES_CHAIN_TYPE,
18365 		BLKCIPHER_AES_CIPHERONLY_TYPE,
18366 		BLKCIPHER_AUTHONLY_TYPE
18367 	};
18368 	static struct unit_test_suite scheduler_multicore = {
18369 		.suite_name = "Scheduler Multicore Unit Test Suite",
18370 		.setup = scheduler_multicore_testsuite_setup,
18371 		.teardown = scheduler_mode_testsuite_teardown,
18372 		.unit_test_cases = {TEST_CASES_END()}
18373 	};
18374 	static struct unit_test_suite scheduler_round_robin = {
18375 		.suite_name = "Scheduler Round Robin Unit Test Suite",
18376 		.setup = scheduler_roundrobin_testsuite_setup,
18377 		.teardown = scheduler_mode_testsuite_teardown,
18378 		.unit_test_cases = {TEST_CASES_END()}
18379 	};
18380 	static struct unit_test_suite scheduler_failover = {
18381 		.suite_name = "Scheduler Failover Unit Test Suite",
18382 		.setup = scheduler_failover_testsuite_setup,
18383 		.teardown = scheduler_mode_testsuite_teardown,
18384 		.unit_test_cases = {TEST_CASES_END()}
18385 	};
18386 	static struct unit_test_suite scheduler_pkt_size_distr = {
18387 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
18388 		.setup = scheduler_pkt_size_distr_testsuite_setup,
18389 		.teardown = scheduler_mode_testsuite_teardown,
18390 		.unit_test_cases = {TEST_CASES_END()}
18391 	};
18392 	struct unit_test_suite *sched_mode_suites[] = {
18393 		&scheduler_multicore,
18394 		&scheduler_round_robin,
18395 		&scheduler_failover,
18396 		&scheduler_pkt_size_distr
18397 	};
18398 	static struct unit_test_suite scheduler_config = {
18399 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
18400 		.unit_test_cases = {
18401 			TEST_CASE(test_scheduler_attach_worker_op),
18402 			TEST_CASE(test_scheduler_mode_multicore_op),
18403 			TEST_CASE(test_scheduler_mode_roundrobin_op),
18404 			TEST_CASE(test_scheduler_mode_failover_op),
18405 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
18406 			TEST_CASE(test_scheduler_detach_worker_op),
18407 
18408 			TEST_CASES_END() /**< NULL terminate array */
18409 		}
18410 	};
18411 	struct unit_test_suite *static_suites[] = {
18412 		&scheduler_config,
18413 		&end_testsuite
18414 	};
18415 	struct unit_test_suite *sched_mode_static_suites[] = {
18416 #ifdef RTE_LIB_SECURITY
18417 		&docsis_proto_testsuite,
18418 #endif
18419 		&end_testsuite
18420 	};
18421 	static struct unit_test_suite ts = {
18422 		.suite_name = "Scheduler Unit Test Suite",
18423 		.setup = scheduler_testsuite_setup,
18424 		.teardown = testsuite_teardown,
18425 		.unit_test_cases = {TEST_CASES_END()}
18426 	};
18427 
18428 	gbl_driver_id =	rte_cryptodev_driver_id_get(
18429 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
18430 
18431 	if (gbl_driver_id == -1) {
18432 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
18433 		return TEST_SKIPPED;
18434 	}
18435 
18436 	if (rte_cryptodev_driver_id_get(
18437 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
18438 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
18439 		return TEST_SKIPPED;
18440 	}
18441 
18442 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
18443 		uint8_t blk_i = 0;
18444 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
18445 				(struct unit_test_suite *) *
18446 				(RTE_DIM(blk_suites) +
18447 				RTE_DIM(sched_mode_static_suites) + 1));
18448 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
18449 				blk_suites, RTE_DIM(blk_suites));
18450 		ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
18451 				sched_mode_static_suites,
18452 				RTE_DIM(sched_mode_static_suites));
18453 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
18454 	}
18455 
18456 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
18457 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
18458 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
18459 			RTE_DIM(sched_mode_suites));
18460 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
18461 	ret = unit_test_suite_runner(&ts);
18462 
18463 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
18464 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
18465 				(*sched_mode_suites[sched_i]),
18466 				RTE_DIM(blk_suites));
18467 		free(sched_mode_suites[sched_i]->unit_test_suites);
18468 	}
18469 	free(ts.unit_test_suites);
18470 	return ret;
18471 }
18472 
18473 REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
18474 
18475 #endif
18476 
18477 static int
18478 test_cryptodev_dpaa2_sec(void)
18479 {
18480 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
18481 }
18482 
18483 static int
18484 test_cryptodev_dpaa_sec(void)
18485 {
18486 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
18487 }
18488 
18489 static int
18490 test_cryptodev_ccp(void)
18491 {
18492 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
18493 }
18494 
18495 static int
18496 test_cryptodev_octeontx(void)
18497 {
18498 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
18499 }
18500 
18501 static int
18502 test_cryptodev_caam_jr(void)
18503 {
18504 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
18505 }
18506 
18507 static int
18508 test_cryptodev_nitrox(void)
18509 {
18510 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
18511 }
18512 
18513 static int
18514 test_cryptodev_bcmfs(void)
18515 {
18516 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
18517 }
18518 
18519 static int
18520 run_cryptodev_raw_testsuite(const char *pmd_name)
18521 {
18522 	int ret;
18523 
18524 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
18525 	if (ret)
18526 		return ret;
18527 
18528 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
18529 	ret = run_cryptodev_testsuite(pmd_name);
18530 	global_api_test_type = CRYPTODEV_API_TEST;
18531 
18532 	return ret;
18533 }
18534 
18535 static int
18536 test_cryptodev_qat_raw_api(void)
18537 {
18538 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
18539 }
18540 
18541 static int
18542 test_cryptodev_cn9k(void)
18543 {
18544 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
18545 }
18546 
18547 static int
18548 test_cryptodev_cn10k(void)
18549 {
18550 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
18551 }
18552 
18553 static int
18554 test_cryptodev_cn10k_raw_api(void)
18555 {
18556 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
18557 }
18558 
18559 static int
18560 test_cryptodev_dpaa2_sec_raw_api(void)
18561 {
18562 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
18563 }
18564 
18565 static int
18566 test_cryptodev_dpaa_sec_raw_api(void)
18567 {
18568 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
18569 }
18570 
18571 REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
18572 		test_cryptodev_cn10k_raw_api);
18573 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
18574 		test_cryptodev_dpaa2_sec_raw_api);
18575 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
18576 		test_cryptodev_dpaa_sec_raw_api);
18577 REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
18578 		test_cryptodev_qat_raw_api);
18579 REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
18580 REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
18581 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
18582 	test_cryptodev_cpu_aesni_mb);
18583 REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
18584 	test_cryptodev_chacha_poly_mb);
18585 REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
18586 REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
18587 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
18588 	test_cryptodev_cpu_aesni_gcm);
18589 REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
18590 REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
18591 REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
18592 REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
18593 REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
18594 REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
18595 REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
18596 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
18597 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
18598 REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
18599 REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
18600 REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
18601 REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
18602 REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
18603 REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
18604 REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
18605 REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
18606 REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
18607