xref: /dpdk/app/test/test_cryptodev.c (revision d2379dd8f27f4ecb54b51b74529f2543b18cfd33)
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_tls.h>
25 #include <rte_udp.h>
26 
27 #ifdef RTE_CRYPTO_SCHEDULER
28 #include <rte_cryptodev_scheduler.h>
29 #include <rte_cryptodev_scheduler_operations.h>
30 #endif
31 
32 #include <rte_lcore.h>
33 
34 #include "test.h"
35 #include "test_cryptodev.h"
36 
37 #include "test_cryptodev_blockcipher.h"
38 #include "test_cryptodev_aes_test_vectors.h"
39 #include "test_cryptodev_des_test_vectors.h"
40 #include "test_cryptodev_hash_test_vectors.h"
41 #include "test_cryptodev_kasumi_test_vectors.h"
42 #include "test_cryptodev_kasumi_hash_test_vectors.h"
43 #include "test_cryptodev_snow3g_test_vectors.h"
44 #include "test_cryptodev_snow3g_hash_test_vectors.h"
45 #include "test_cryptodev_zuc_test_vectors.h"
46 #include "test_cryptodev_aead_test_vectors.h"
47 #include "test_cryptodev_hmac_test_vectors.h"
48 #include "test_cryptodev_mixed_test_vectors.h"
49 #include "test_cryptodev_sm4_test_vectors.h"
50 #ifdef RTE_LIB_SECURITY
51 #include "test_cryptodev_security_ipsec.h"
52 #include "test_cryptodev_security_ipsec_test_vectors.h"
53 #include "test_cryptodev_security_pdcp_test_vectors.h"
54 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
55 #include "test_cryptodev_security_pdcp_test_func.h"
56 #include "test_cryptodev_security_docsis_test_vectors.h"
57 #include "test_cryptodev_security_tls_record.h"
58 #include "test_security_proto.h"
59 
60 #define SDAP_DISABLED	0
61 #define SDAP_ENABLED	1
62 #endif
63 
64 #define VDEV_ARGS_SIZE 100
65 #define MAX_NB_SESSIONS 4
66 
67 #define MAX_DRV_SERVICE_CTX_SIZE 256
68 
69 #define MAX_RAW_DEQUEUE_COUNT	65535
70 
71 #define IN_PLACE 0
72 #define OUT_OF_PLACE 1
73 
74 static int gbl_driver_id;
75 
76 static enum rte_security_session_action_type gbl_action_type =
77 	RTE_SECURITY_ACTION_TYPE_NONE;
78 
79 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
80 
81 struct crypto_unittest_params {
82 	struct rte_crypto_sym_xform cipher_xform;
83 	struct rte_crypto_sym_xform auth_xform;
84 	struct rte_crypto_sym_xform aead_xform;
85 #ifdef RTE_LIB_SECURITY
86 	struct rte_security_docsis_xform docsis_xform;
87 #endif
88 
89 	union {
90 		void *sess;
91 #ifdef RTE_LIB_SECURITY
92 		void *sec_session;
93 #endif
94 	};
95 #ifdef RTE_LIB_SECURITY
96 	enum rte_security_session_action_type type;
97 #endif
98 	struct rte_crypto_op *op;
99 
100 	struct rte_mbuf *obuf, *ibuf;
101 
102 	uint8_t *digest;
103 };
104 
105 #define ALIGN_POW2_ROUNDUP(num, align) \
106 	(((num) + (align) - 1) & ~((align) - 1))
107 
108 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
109 	for (j = 0; j < num_child_ts; index++, j++)			\
110 		parent_ts.unit_test_suites[index] = child_ts[j]
111 
112 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
113 	for (j = 0; j < num_blk_types; index++, j++)				\
114 		parent_ts.unit_test_suites[index] =				\
115 				build_blockcipher_test_suite(blk_types[j])
116 
117 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
118 	for (j = index; j < index + num_blk_types; j++)				\
119 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
120 
121 /*
122  * Forward declarations.
123  */
124 static int
125 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
126 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
127 		uint8_t *hmac_key);
128 
129 static int
130 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
131 		struct crypto_unittest_params *ut_params,
132 		struct crypto_testsuite_params *ts_param,
133 		const uint8_t *cipher,
134 		const uint8_t *digest,
135 		const uint8_t *iv);
136 
137 static int
138 security_proto_supported(enum rte_security_session_action_type action,
139 	enum rte_security_session_protocol proto);
140 
141 static int
142 dev_configure_and_start(uint64_t ff_disable);
143 
144 static int
145 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
146 			const enum rte_crypto_cipher_algorithm cipher_algo,
147 			const uint16_t key_size, const uint16_t iv_size);
148 
149 static int
150 check_auth_capability(const struct crypto_testsuite_params *ts_params,
151 			const enum rte_crypto_auth_algorithm auth_algo,
152 			const uint16_t key_size, const uint16_t iv_size,
153 			const uint16_t tag_size);
154 
155 static struct rte_mbuf *
156 setup_test_string(struct rte_mempool *mpool,
157 		const char *string, size_t len, uint8_t blocksize)
158 {
159 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
160 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
161 
162 	if (m) {
163 		char *dst;
164 
165 		memset(m->buf_addr, 0, m->buf_len);
166 		dst = rte_pktmbuf_append(m, t_len);
167 		if (!dst) {
168 			rte_pktmbuf_free(m);
169 			return NULL;
170 		}
171 		if (string != NULL)
172 			rte_memcpy(dst, string, t_len);
173 		else
174 			memset(dst, 0, t_len);
175 	}
176 
177 	return m;
178 }
179 
180 /* Get number of bytes in X bits (rounding up) */
181 static uint32_t
182 ceil_byte_length(uint32_t num_bits)
183 {
184 	if (num_bits % 8)
185 		return ((num_bits >> 3) + 1);
186 	else
187 		return (num_bits >> 3);
188 }
189 
190 static void
191 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
192 		uint8_t is_op_success)
193 {
194 	struct rte_crypto_op *op = user_data;
195 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
196 			RTE_CRYPTO_OP_STATUS_ERROR;
197 }
198 
199 static struct crypto_testsuite_params testsuite_params = { NULL };
200 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
201 static struct crypto_unittest_params unittest_params;
202 
203 int
204 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
205 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
206 		uint8_t len_in_bits, uint8_t cipher_iv_len)
207 {
208 	struct rte_crypto_sym_op *sop = op->sym;
209 	struct rte_crypto_op *ret_op = NULL;
210 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
211 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
212 	union rte_crypto_sym_ofs ofs;
213 	struct rte_crypto_sym_vec vec;
214 	struct rte_crypto_sgl sgl, dest_sgl;
215 	uint32_t max_len;
216 	union rte_cryptodev_session_ctx sess;
217 	uint64_t auth_end_iova;
218 	uint32_t count = 0;
219 	struct rte_crypto_raw_dp_ctx *ctx;
220 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
221 			auth_len = 0;
222 	int32_t n;
223 	uint32_t n_success;
224 	int ctx_service_size;
225 	int32_t status = 0;
226 	int enqueue_status, dequeue_status;
227 	struct crypto_unittest_params *ut_params = &unittest_params;
228 	int is_sgl = sop->m_src->nb_segs > 1;
229 	int ret = TEST_SUCCESS, is_oop = 0;
230 
231 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
232 	if (ctx_service_size < 0)
233 		return TEST_SKIPPED;
234 
235 	ctx = malloc(ctx_service_size);
236 	if (ctx == NULL)
237 		return TEST_FAILED;
238 
239 	/* Both are enums, setting crypto_sess will suit any session type */
240 	sess.crypto_sess = op->sym->session;
241 
242 	ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
243 	if (ret == -ENOTSUP) {
244 		ret = TEST_SKIPPED;
245 		goto exit;
246 	} else if (ret) {
247 		ret = TEST_FAILED;
248 		goto exit;
249 	}
250 
251 	cipher_iv.iova = 0;
252 	cipher_iv.va = NULL;
253 	aad_auth_iv.iova = 0;
254 	aad_auth_iv.va = NULL;
255 	digest.iova = 0;
256 	digest.va = NULL;
257 	sgl.vec = data_vec;
258 	vec.num = 1;
259 	vec.src_sgl = &sgl;
260 	vec.iv = &cipher_iv;
261 	vec.digest = &digest;
262 	vec.aad = &aad_auth_iv;
263 	vec.status = &status;
264 
265 	ofs.raw = 0;
266 
267 	if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
268 		is_oop = 1;
269 
270 	if (is_cipher && is_auth) {
271 		cipher_offset = sop->cipher.data.offset;
272 		cipher_len = sop->cipher.data.length;
273 		auth_offset = sop->auth.data.offset;
274 		auth_len = sop->auth.data.length;
275 		max_len = RTE_MAX(cipher_offset + cipher_len,
276 				auth_offset + auth_len);
277 		if (len_in_bits) {
278 			max_len = max_len >> 3;
279 			cipher_offset = cipher_offset >> 3;
280 			auth_offset = auth_offset >> 3;
281 			cipher_len = cipher_len >> 3;
282 			auth_len = auth_len >> 3;
283 		}
284 		ofs.ofs.cipher.head = cipher_offset;
285 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
286 		ofs.ofs.auth.head = auth_offset;
287 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
288 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
289 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
290 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
291 				op, void *, IV_OFFSET + cipher_iv_len);
292 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
293 				cipher_iv_len);
294 		digest.va = (void *)sop->auth.digest.data;
295 		digest.iova = sop->auth.digest.phys_addr;
296 
297 		if (is_sgl) {
298 			uint32_t remaining_off = auth_offset + auth_len;
299 			struct rte_mbuf *sgl_buf = sop->m_src;
300 			if (is_oop)
301 				sgl_buf = sop->m_dst;
302 
303 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
304 					&& sgl_buf->next != NULL) {
305 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
306 				sgl_buf = sgl_buf->next;
307 			}
308 
309 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
310 				sgl_buf, remaining_off);
311 		} else {
312 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
313 							 auth_offset + auth_len;
314 		}
315 		/* Then check if digest-encrypted conditions are met */
316 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
317 				(digest.iova == auth_end_iova) && is_sgl)
318 			max_len = RTE_MAX(max_len,
319 				auth_offset + auth_len +
320 				ut_params->auth_xform.auth.digest_length);
321 
322 	} else if (is_cipher) {
323 		cipher_offset = sop->cipher.data.offset;
324 		cipher_len = sop->cipher.data.length;
325 		max_len = cipher_len + cipher_offset;
326 		if (len_in_bits) {
327 			max_len = max_len >> 3;
328 			cipher_offset = cipher_offset >> 3;
329 			cipher_len = cipher_len >> 3;
330 		}
331 		ofs.ofs.cipher.head = cipher_offset;
332 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
333 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
334 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
335 
336 	} else if (is_auth) {
337 		auth_offset = sop->auth.data.offset;
338 		auth_len = sop->auth.data.length;
339 		max_len = auth_len + auth_offset;
340 		if (len_in_bits) {
341 			max_len = max_len >> 3;
342 			auth_offset = auth_offset >> 3;
343 			auth_len = auth_len >> 3;
344 		}
345 		ofs.ofs.auth.head = auth_offset;
346 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
347 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
348 				op, void *, IV_OFFSET + cipher_iv_len);
349 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
350 				cipher_iv_len);
351 		digest.va = (void *)sop->auth.digest.data;
352 		digest.iova = sop->auth.digest.phys_addr;
353 
354 	} else { /* aead */
355 		cipher_offset = sop->aead.data.offset;
356 		cipher_len = sop->aead.data.length;
357 		max_len = cipher_len + cipher_offset;
358 		if (len_in_bits) {
359 			max_len = max_len >> 3;
360 			cipher_offset = cipher_offset >> 3;
361 			cipher_len = cipher_len >> 3;
362 		}
363 		ofs.ofs.cipher.head = cipher_offset;
364 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
365 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
366 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
367 		aad_auth_iv.va = (void *)sop->aead.aad.data;
368 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
369 		digest.va = (void *)sop->aead.digest.data;
370 		digest.iova = sop->aead.digest.phys_addr;
371 	}
372 
373 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
374 			data_vec, RTE_DIM(data_vec));
375 	if (n < 0 || n > sop->m_src->nb_segs) {
376 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
377 		goto exit;
378 	}
379 
380 	sgl.num = n;
381 	/* Out of place */
382 	if (is_oop) {
383 		dest_sgl.vec = dest_data_vec;
384 		vec.dest_sgl = &dest_sgl;
385 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
386 				dest_data_vec, RTE_DIM(dest_data_vec));
387 		if (n < 0 || n > sop->m_dst->nb_segs) {
388 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
389 			goto exit;
390 		}
391 		dest_sgl.num = n;
392 	} else
393 		vec.dest_sgl = NULL;
394 
395 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
396 			&enqueue_status) < 1) {
397 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
398 		goto exit;
399 	}
400 
401 	if (enqueue_status == 0) {
402 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
403 		if (status < 0) {
404 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
405 			goto exit;
406 		}
407 	} else if (enqueue_status < 0) {
408 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
409 		goto exit;
410 	}
411 
412 	n = n_success = 0;
413 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
414 		n = rte_cryptodev_raw_dequeue_burst(ctx,
415 			NULL, 1, post_process_raw_dp_op,
416 				(void **)&ret_op, 0, &n_success,
417 				&dequeue_status);
418 		if (dequeue_status < 0) {
419 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
420 			goto exit;
421 		}
422 		if (n == 0)
423 			rte_pause();
424 	}
425 
426 	if (n == 1 && dequeue_status == 0) {
427 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
428 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
429 			goto exit;
430 		}
431 	}
432 
433 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
434 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
435 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
436 					RTE_CRYPTO_OP_STATUS_SUCCESS;
437 
438 exit:
439 	free(ctx);
440 	return ret;
441 }
442 
443 static void
444 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
445 {
446 	int32_t n, st;
447 	struct rte_crypto_sym_op *sop;
448 	union rte_crypto_sym_ofs ofs;
449 	struct rte_crypto_sgl sgl;
450 	struct rte_crypto_sym_vec symvec;
451 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
452 	struct rte_crypto_vec vec[UINT8_MAX];
453 
454 	sop = op->sym;
455 
456 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
457 		sop->aead.data.length, vec, RTE_DIM(vec));
458 
459 	if (n < 0 || n != sop->m_src->nb_segs) {
460 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
461 		return;
462 	}
463 
464 	sgl.vec = vec;
465 	sgl.num = n;
466 	symvec.src_sgl = &sgl;
467 	symvec.iv = &iv_ptr;
468 	symvec.digest = &digest_ptr;
469 	symvec.aad = &aad_ptr;
470 	symvec.status = &st;
471 	symvec.num = 1;
472 
473 	/* for CPU crypto the IOVA address is not required */
474 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
475 	digest_ptr.va = (void *)sop->aead.digest.data;
476 	aad_ptr.va = (void *)sop->aead.aad.data;
477 
478 	ofs.raw = 0;
479 
480 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
481 		&symvec);
482 
483 	if (n != 1)
484 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
485 	else
486 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
487 }
488 
489 static void
490 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
491 {
492 	int32_t n, st;
493 	struct rte_crypto_sym_op *sop;
494 	union rte_crypto_sym_ofs ofs;
495 	struct rte_crypto_sgl sgl;
496 	struct rte_crypto_sym_vec symvec;
497 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
498 	struct rte_crypto_vec vec[UINT8_MAX];
499 
500 	sop = op->sym;
501 
502 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
503 		sop->auth.data.length, vec, RTE_DIM(vec));
504 
505 	if (n < 0 || n != sop->m_src->nb_segs) {
506 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
507 		return;
508 	}
509 
510 	sgl.vec = vec;
511 	sgl.num = n;
512 	symvec.src_sgl = &sgl;
513 	symvec.iv = &iv_ptr;
514 	symvec.digest = &digest_ptr;
515 	symvec.status = &st;
516 	symvec.num = 1;
517 
518 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
519 	digest_ptr.va = (void *)sop->auth.digest.data;
520 
521 	ofs.raw = 0;
522 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
523 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
524 		(sop->cipher.data.offset + sop->cipher.data.length);
525 
526 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
527 		&symvec);
528 
529 	if (n != 1)
530 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
531 	else
532 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
533 }
534 
535 static struct rte_crypto_op *
536 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
537 {
538 
539 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
540 
541 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
542 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
543 		return NULL;
544 	}
545 
546 	op = NULL;
547 
548 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
549 		rte_pause();
550 
551 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
552 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
553 		return NULL;
554 	}
555 
556 	return op;
557 }
558 
559 static int
560 testsuite_setup(void)
561 {
562 	struct crypto_testsuite_params *ts_params = &testsuite_params;
563 	struct rte_cryptodev_info info;
564 	uint32_t i = 0, nb_devs, dev_id;
565 	uint16_t qp_id;
566 
567 	memset(ts_params, 0, sizeof(*ts_params));
568 
569 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
570 	if (ts_params->mbuf_pool == NULL) {
571 		/* Not already created so create */
572 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
573 				"CRYPTO_MBUFPOOL",
574 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
575 				rte_socket_id());
576 		if (ts_params->mbuf_pool == NULL) {
577 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
578 			return TEST_FAILED;
579 		}
580 	}
581 
582 	ts_params->large_mbuf_pool = rte_mempool_lookup(
583 			"CRYPTO_LARGE_MBUFPOOL");
584 	if (ts_params->large_mbuf_pool == NULL) {
585 		/* Not already created so create */
586 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
587 				"CRYPTO_LARGE_MBUFPOOL",
588 				1, 0, 0, UINT16_MAX,
589 				rte_socket_id());
590 		if (ts_params->large_mbuf_pool == NULL) {
591 			RTE_LOG(ERR, USER1,
592 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
593 			return TEST_FAILED;
594 		}
595 	}
596 
597 	ts_params->op_mpool = rte_crypto_op_pool_create(
598 			"MBUF_CRYPTO_SYM_OP_POOL",
599 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
600 			NUM_MBUFS, MBUF_CACHE_SIZE,
601 			DEFAULT_NUM_XFORMS *
602 			sizeof(struct rte_crypto_sym_xform) +
603 			MAXIMUM_IV_LENGTH,
604 			rte_socket_id());
605 	if (ts_params->op_mpool == NULL) {
606 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
607 		return TEST_FAILED;
608 	}
609 
610 	nb_devs = rte_cryptodev_count();
611 	if (nb_devs < 1) {
612 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
613 		return TEST_SKIPPED;
614 	}
615 
616 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
617 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
618 				rte_cryptodev_driver_name_get(gbl_driver_id));
619 		return TEST_SKIPPED;
620 	}
621 
622 	/* Create list of valid crypto devs */
623 	for (i = 0; i < nb_devs; i++) {
624 		rte_cryptodev_info_get(i, &info);
625 		if (info.driver_id == gbl_driver_id)
626 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
627 	}
628 
629 	if (ts_params->valid_dev_count < 1)
630 		return TEST_FAILED;
631 
632 	/* Set up all the qps on the first of the valid devices found */
633 
634 	dev_id = ts_params->valid_devs[0];
635 
636 	rte_cryptodev_info_get(dev_id, &info);
637 
638 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
639 	ts_params->conf.socket_id = SOCKET_ID_ANY;
640 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
641 
642 	unsigned int session_size =
643 		rte_cryptodev_sym_get_private_session_size(dev_id);
644 
645 #ifdef RTE_LIB_SECURITY
646 	unsigned int security_session_size = rte_security_session_get_size(
647 			rte_cryptodev_get_sec_ctx(dev_id));
648 
649 	if (session_size < security_session_size)
650 		session_size = security_session_size;
651 #endif
652 	/*
653 	 * Create mempool with maximum number of sessions.
654 	 */
655 	if (info.sym.max_nb_sessions != 0 &&
656 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
657 		RTE_LOG(ERR, USER1, "Device does not support "
658 				"at least %u sessions\n",
659 				MAX_NB_SESSIONS);
660 		return TEST_FAILED;
661 	}
662 
663 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
664 			"test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
665 			SOCKET_ID_ANY);
666 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
667 			"session mempool allocation failed");
668 
669 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
670 			&ts_params->conf),
671 			"Failed to configure cryptodev %u with %u qps",
672 			dev_id, ts_params->conf.nb_queue_pairs);
673 
674 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
675 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
676 
677 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
678 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
679 			dev_id, qp_id, &ts_params->qp_conf,
680 			rte_cryptodev_socket_id(dev_id)),
681 			"Failed to setup queue pair %u on cryptodev %u",
682 			qp_id, dev_id);
683 	}
684 
685 	return TEST_SUCCESS;
686 }
687 
688 static void
689 testsuite_teardown(void)
690 {
691 	struct crypto_testsuite_params *ts_params = &testsuite_params;
692 	int res;
693 
694 	if (ts_params->mbuf_pool != NULL) {
695 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
696 		rte_mempool_avail_count(ts_params->mbuf_pool));
697 	}
698 
699 	if (ts_params->op_mpool != NULL) {
700 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
701 		rte_mempool_avail_count(ts_params->op_mpool));
702 	}
703 
704 	if (ts_params->session_mpool != NULL) {
705 		rte_mempool_free(ts_params->session_mpool);
706 		ts_params->session_mpool = NULL;
707 	}
708 
709 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
710 	if (res)
711 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
712 }
713 
714 static int
715 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
716 		const int *algs, uint16_t num_algs)
717 {
718 	uint8_t dev_id = testsuite_params.valid_devs[0];
719 	bool some_alg_supported = FALSE;
720 	uint16_t i;
721 
722 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
723 		struct rte_cryptodev_sym_capability_idx alg = {
724 			type, {algs[i]}
725 		};
726 		if (rte_cryptodev_sym_capability_get(dev_id,
727 				&alg) != NULL)
728 			some_alg_supported = TRUE;
729 	}
730 	if (!some_alg_supported)
731 		return TEST_SKIPPED;
732 
733 	return 0;
734 }
735 
736 int
737 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
738 		uint16_t num_ciphers)
739 {
740 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
741 			(const int *) ciphers, num_ciphers);
742 }
743 
744 int
745 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
746 		uint16_t num_auths)
747 {
748 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
749 			(const int *) auths, num_auths);
750 }
751 
752 int
753 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
754 		uint16_t num_aeads)
755 {
756 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
757 			(const int *) aeads, num_aeads);
758 }
759 
760 static int
761 null_testsuite_setup(void)
762 {
763 	struct crypto_testsuite_params *ts_params = &testsuite_params;
764 	uint8_t dev_id = ts_params->valid_devs[0];
765 	struct rte_cryptodev_info dev_info;
766 	const enum rte_crypto_cipher_algorithm ciphers[] = {
767 		RTE_CRYPTO_CIPHER_NULL
768 	};
769 	const enum rte_crypto_auth_algorithm auths[] = {
770 		RTE_CRYPTO_AUTH_NULL
771 	};
772 
773 	rte_cryptodev_info_get(dev_id, &dev_info);
774 
775 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
776 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
777 				"testsuite not met\n");
778 		return TEST_SKIPPED;
779 	}
780 
781 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
782 			&& check_auth_capabilities_supported(auths,
783 			RTE_DIM(auths)) != 0) {
784 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
785 				"testsuite not met\n");
786 		return TEST_SKIPPED;
787 	}
788 
789 	return 0;
790 }
791 
792 static int
793 crypto_gen_testsuite_setup(void)
794 {
795 	struct crypto_testsuite_params *ts_params = &testsuite_params;
796 	uint8_t dev_id = ts_params->valid_devs[0];
797 	struct rte_cryptodev_info dev_info;
798 
799 	rte_cryptodev_info_get(dev_id, &dev_info);
800 
801 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
802 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
803 				"testsuite not met\n");
804 		return TEST_SKIPPED;
805 	}
806 
807 	return 0;
808 }
809 
810 #ifdef RTE_LIB_SECURITY
811 static int
812 sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
813 {
814 	struct crypto_testsuite_params *ts_params = &testsuite_params;
815 	struct crypto_unittest_params *ut_params = &unittest_params;
816 	struct rte_cryptodev_info dev_info;
817 	int ret = 0;
818 
819 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
820 
821 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
822 		RTE_LOG(INFO, USER1,
823 			"Feature flag requirements for security protocol testsuite not met\n");
824 		return TEST_SKIPPED;
825 	}
826 
827 	/* Reconfigure to enable security */
828 	ret = dev_configure_and_start(0);
829 	if (ret != TEST_SUCCESS)
830 		return ret;
831 
832 	/* Set action type */
833 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
834 
835 	if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
836 		RTE_LOG(INFO, USER1,
837 			"Capability requirements for security protocol test not met\n");
838 		ret = TEST_SKIPPED;
839 	}
840 
841 	test_sec_alg_list_populate();
842 	test_sec_auth_only_alg_list_populate();
843 
844 	/*
845 	 * Stop the device. Device would be started again by individual test
846 	 * case setup routine.
847 	 */
848 	rte_cryptodev_stop(ts_params->valid_devs[0]);
849 
850 	return ret;
851 }
852 
853 static int
854 ipsec_proto_testsuite_setup(void)
855 {
856 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
857 }
858 
859 static int
860 tls_record_proto_testsuite_setup(void)
861 {
862 	test_sec_proto_pattern_generate();
863 
864 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
865 }
866 
867 static int
868 pdcp_proto_testsuite_setup(void)
869 {
870 	struct crypto_testsuite_params *ts_params = &testsuite_params;
871 	uint8_t dev_id = ts_params->valid_devs[0];
872 	struct rte_cryptodev_info dev_info;
873 	const enum rte_crypto_cipher_algorithm ciphers[] = {
874 		RTE_CRYPTO_CIPHER_NULL,
875 		RTE_CRYPTO_CIPHER_AES_CTR,
876 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
877 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
878 	};
879 	const enum rte_crypto_auth_algorithm auths[] = {
880 		RTE_CRYPTO_AUTH_NULL,
881 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
882 		RTE_CRYPTO_AUTH_AES_CMAC,
883 		RTE_CRYPTO_AUTH_ZUC_EIA3
884 	};
885 
886 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
887 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
888 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
889 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
890 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
891 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
892 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
893 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
894 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
895 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
896 
897 	rte_cryptodev_info_get(dev_id, &dev_info);
898 
899 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
900 			!(dev_info.feature_flags &
901 			RTE_CRYPTODEV_FF_SECURITY)) {
902 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
903 				"testsuite not met\n");
904 		return TEST_SKIPPED;
905 	}
906 
907 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
908 			&& check_auth_capabilities_supported(auths,
909 			RTE_DIM(auths)) != 0) {
910 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
911 				"testsuite not met\n");
912 		return TEST_SKIPPED;
913 	}
914 
915 	return 0;
916 }
917 
918 static int
919 docsis_proto_testsuite_setup(void)
920 {
921 	struct crypto_testsuite_params *ts_params = &testsuite_params;
922 	uint8_t dev_id = ts_params->valid_devs[0];
923 	struct rte_cryptodev_info dev_info;
924 	const enum rte_crypto_cipher_algorithm ciphers[] = {
925 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
926 	};
927 
928 	rte_cryptodev_info_get(dev_id, &dev_info);
929 
930 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
931 			!(dev_info.feature_flags &
932 			RTE_CRYPTODEV_FF_SECURITY)) {
933 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
934 				"Proto testsuite not met\n");
935 		return TEST_SKIPPED;
936 	}
937 
938 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
939 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
940 				"testsuite not met\n");
941 		return TEST_SKIPPED;
942 	}
943 
944 	return 0;
945 }
946 #endif
947 
948 static int
949 aes_ccm_auth_testsuite_setup(void)
950 {
951 	struct crypto_testsuite_params *ts_params = &testsuite_params;
952 	uint8_t dev_id = ts_params->valid_devs[0];
953 	struct rte_cryptodev_info dev_info;
954 	const enum rte_crypto_aead_algorithm aeads[] = {
955 		RTE_CRYPTO_AEAD_AES_CCM
956 	};
957 
958 	rte_cryptodev_info_get(dev_id, &dev_info);
959 
960 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
961 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
962 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
963 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
964 				"testsuite not met\n");
965 		return TEST_SKIPPED;
966 	}
967 
968 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
969 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
970 				"testsuite not met\n");
971 		return TEST_SKIPPED;
972 	}
973 
974 	return 0;
975 }
976 
977 static int
978 aes_gcm_auth_testsuite_setup(void)
979 {
980 	struct crypto_testsuite_params *ts_params = &testsuite_params;
981 	uint8_t dev_id = ts_params->valid_devs[0];
982 	struct rte_cryptodev_info dev_info;
983 	const enum rte_crypto_aead_algorithm aeads[] = {
984 		RTE_CRYPTO_AEAD_AES_GCM
985 	};
986 
987 	rte_cryptodev_info_get(dev_id, &dev_info);
988 
989 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
990 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
991 				"testsuite not met\n");
992 		return TEST_SKIPPED;
993 	}
994 
995 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
996 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
997 				"testsuite not met\n");
998 		return TEST_SKIPPED;
999 	}
1000 
1001 	return 0;
1002 }
1003 
1004 static int
1005 aes_gmac_auth_testsuite_setup(void)
1006 {
1007 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1008 	uint8_t dev_id = ts_params->valid_devs[0];
1009 	struct rte_cryptodev_info dev_info;
1010 	const enum rte_crypto_auth_algorithm auths[] = {
1011 		RTE_CRYPTO_AUTH_AES_GMAC
1012 	};
1013 
1014 	rte_cryptodev_info_get(dev_id, &dev_info);
1015 
1016 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1017 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1018 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1019 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1020 				"testsuite not met\n");
1021 		return TEST_SKIPPED;
1022 	}
1023 
1024 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1025 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1026 				"testsuite not met\n");
1027 		return TEST_SKIPPED;
1028 	}
1029 
1030 	return 0;
1031 }
1032 
1033 static int
1034 chacha20_poly1305_testsuite_setup(void)
1035 {
1036 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1037 	uint8_t dev_id = ts_params->valid_devs[0];
1038 	struct rte_cryptodev_info dev_info;
1039 	const enum rte_crypto_aead_algorithm aeads[] = {
1040 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1041 	};
1042 
1043 	rte_cryptodev_info_get(dev_id, &dev_info);
1044 
1045 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1046 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1047 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1048 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1049 				"Chacha20-Poly1305 testsuite not met\n");
1050 		return TEST_SKIPPED;
1051 	}
1052 
1053 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1054 		RTE_LOG(INFO, USER1, "Capability requirements for "
1055 				"Chacha20-Poly1305 testsuite not met\n");
1056 		return TEST_SKIPPED;
1057 	}
1058 
1059 	return 0;
1060 }
1061 
1062 static int
1063 snow3g_testsuite_setup(void)
1064 {
1065 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1066 	uint8_t dev_id = ts_params->valid_devs[0];
1067 	struct rte_cryptodev_info dev_info;
1068 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1069 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1070 
1071 	};
1072 	const enum rte_crypto_auth_algorithm auths[] = {
1073 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1074 	};
1075 
1076 	rte_cryptodev_info_get(dev_id, &dev_info);
1077 
1078 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1079 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1080 				"testsuite not met\n");
1081 		return TEST_SKIPPED;
1082 	}
1083 
1084 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1085 			&& check_auth_capabilities_supported(auths,
1086 			RTE_DIM(auths)) != 0) {
1087 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1088 				"testsuite not met\n");
1089 		return TEST_SKIPPED;
1090 	}
1091 
1092 	return 0;
1093 }
1094 
1095 static int
1096 zuc_testsuite_setup(void)
1097 {
1098 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1099 	uint8_t dev_id = ts_params->valid_devs[0];
1100 	struct rte_cryptodev_info dev_info;
1101 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1102 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1103 	};
1104 	const enum rte_crypto_auth_algorithm auths[] = {
1105 		RTE_CRYPTO_AUTH_ZUC_EIA3
1106 	};
1107 
1108 	rte_cryptodev_info_get(dev_id, &dev_info);
1109 
1110 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1111 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1112 				"testsuite not met\n");
1113 		return TEST_SKIPPED;
1114 	}
1115 
1116 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1117 			&& check_auth_capabilities_supported(auths,
1118 			RTE_DIM(auths)) != 0) {
1119 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1120 				"testsuite not met\n");
1121 		return TEST_SKIPPED;
1122 	}
1123 
1124 	return 0;
1125 }
1126 
1127 static int
1128 hmac_md5_auth_testsuite_setup(void)
1129 {
1130 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1131 	uint8_t dev_id = ts_params->valid_devs[0];
1132 	struct rte_cryptodev_info dev_info;
1133 	const enum rte_crypto_auth_algorithm auths[] = {
1134 		RTE_CRYPTO_AUTH_MD5_HMAC
1135 	};
1136 
1137 	rte_cryptodev_info_get(dev_id, &dev_info);
1138 
1139 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1140 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1141 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1142 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1143 				"Auth testsuite not met\n");
1144 		return TEST_SKIPPED;
1145 	}
1146 
1147 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1148 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1149 				"testsuite not met\n");
1150 		return TEST_SKIPPED;
1151 	}
1152 
1153 	return 0;
1154 }
1155 
1156 static int
1157 kasumi_testsuite_setup(void)
1158 {
1159 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1160 	uint8_t dev_id = ts_params->valid_devs[0];
1161 	struct rte_cryptodev_info dev_info;
1162 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1163 		RTE_CRYPTO_CIPHER_KASUMI_F8
1164 	};
1165 	const enum rte_crypto_auth_algorithm auths[] = {
1166 		RTE_CRYPTO_AUTH_KASUMI_F9
1167 	};
1168 
1169 	rte_cryptodev_info_get(dev_id, &dev_info);
1170 
1171 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1172 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1173 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1174 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1175 				"testsuite not met\n");
1176 		return TEST_SKIPPED;
1177 	}
1178 
1179 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1180 			&& check_auth_capabilities_supported(auths,
1181 			RTE_DIM(auths)) != 0) {
1182 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1183 				"testsuite not met\n");
1184 		return TEST_SKIPPED;
1185 	}
1186 
1187 	return 0;
1188 }
1189 
1190 static int
1191 negative_aes_gcm_testsuite_setup(void)
1192 {
1193 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1194 	uint8_t dev_id = ts_params->valid_devs[0];
1195 	struct rte_cryptodev_info dev_info;
1196 	const enum rte_crypto_aead_algorithm aeads[] = {
1197 		RTE_CRYPTO_AEAD_AES_GCM
1198 	};
1199 
1200 	rte_cryptodev_info_get(dev_id, &dev_info);
1201 
1202 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1203 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1204 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1205 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1206 				"AES GCM testsuite not met\n");
1207 		return TEST_SKIPPED;
1208 	}
1209 
1210 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1211 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1212 				"AES GCM testsuite not met\n");
1213 		return TEST_SKIPPED;
1214 	}
1215 
1216 	return 0;
1217 }
1218 
1219 static int
1220 negative_aes_gmac_testsuite_setup(void)
1221 {
1222 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1223 	uint8_t dev_id = ts_params->valid_devs[0];
1224 	struct rte_cryptodev_info dev_info;
1225 	const enum rte_crypto_auth_algorithm auths[] = {
1226 		RTE_CRYPTO_AUTH_AES_GMAC
1227 	};
1228 
1229 	rte_cryptodev_info_get(dev_id, &dev_info);
1230 
1231 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1232 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1233 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1234 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1235 				"AES GMAC testsuite not met\n");
1236 		return TEST_SKIPPED;
1237 	}
1238 
1239 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1240 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1241 				"AES GMAC testsuite not met\n");
1242 		return TEST_SKIPPED;
1243 	}
1244 
1245 	return 0;
1246 }
1247 
1248 static int
1249 mixed_cipher_hash_testsuite_setup(void)
1250 {
1251 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1252 	uint8_t dev_id = ts_params->valid_devs[0];
1253 	struct rte_cryptodev_info dev_info;
1254 	uint64_t feat_flags;
1255 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1256 		RTE_CRYPTO_CIPHER_NULL,
1257 		RTE_CRYPTO_CIPHER_AES_CTR,
1258 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1259 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1260 	};
1261 	const enum rte_crypto_auth_algorithm auths[] = {
1262 		RTE_CRYPTO_AUTH_NULL,
1263 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1264 		RTE_CRYPTO_AUTH_AES_CMAC,
1265 		RTE_CRYPTO_AUTH_ZUC_EIA3
1266 	};
1267 
1268 	rte_cryptodev_info_get(dev_id, &dev_info);
1269 	feat_flags = dev_info.feature_flags;
1270 
1271 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1272 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1273 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1274 				"Cipher Hash testsuite not met\n");
1275 		return TEST_SKIPPED;
1276 	}
1277 
1278 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1279 			&& check_auth_capabilities_supported(auths,
1280 			RTE_DIM(auths)) != 0) {
1281 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1282 				"Cipher Hash testsuite not met\n");
1283 		return TEST_SKIPPED;
1284 	}
1285 
1286 	return 0;
1287 }
1288 
1289 static int
1290 esn_testsuite_setup(void)
1291 {
1292 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1293 	uint8_t dev_id = ts_params->valid_devs[0];
1294 	struct rte_cryptodev_info dev_info;
1295 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1296 		RTE_CRYPTO_CIPHER_AES_CBC
1297 	};
1298 	const enum rte_crypto_auth_algorithm auths[] = {
1299 		RTE_CRYPTO_AUTH_SHA1_HMAC
1300 	};
1301 
1302 	rte_cryptodev_info_get(dev_id, &dev_info);
1303 
1304 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1305 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1306 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1307 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1308 				"testsuite not met\n");
1309 		return TEST_SKIPPED;
1310 	}
1311 
1312 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1313 			&& check_auth_capabilities_supported(auths,
1314 			RTE_DIM(auths)) != 0) {
1315 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1316 				"testsuite not met\n");
1317 		return TEST_SKIPPED;
1318 	}
1319 
1320 	return 0;
1321 }
1322 
1323 static int
1324 multi_session_testsuite_setup(void)
1325 {
1326 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1327 	uint8_t dev_id = ts_params->valid_devs[0];
1328 	struct rte_cryptodev_info dev_info;
1329 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1330 		RTE_CRYPTO_CIPHER_AES_CBC
1331 	};
1332 	const enum rte_crypto_auth_algorithm auths[] = {
1333 		RTE_CRYPTO_AUTH_SHA512_HMAC
1334 	};
1335 
1336 	rte_cryptodev_info_get(dev_id, &dev_info);
1337 
1338 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1339 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1340 				"Session testsuite not met\n");
1341 		return TEST_SKIPPED;
1342 	}
1343 
1344 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1345 			&& check_auth_capabilities_supported(auths,
1346 			RTE_DIM(auths)) != 0) {
1347 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1348 				"Session testsuite not met\n");
1349 		return TEST_SKIPPED;
1350 	}
1351 
1352 	return 0;
1353 }
1354 
1355 static int
1356 negative_hmac_sha1_testsuite_setup(void)
1357 {
1358 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1359 	uint8_t dev_id = ts_params->valid_devs[0];
1360 	struct rte_cryptodev_info dev_info;
1361 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1362 		RTE_CRYPTO_CIPHER_AES_CBC
1363 	};
1364 	const enum rte_crypto_auth_algorithm auths[] = {
1365 		RTE_CRYPTO_AUTH_SHA1_HMAC
1366 	};
1367 
1368 	rte_cryptodev_info_get(dev_id, &dev_info);
1369 
1370 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1371 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1372 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1373 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1374 				"HMAC SHA1 testsuite not met\n");
1375 		return TEST_SKIPPED;
1376 	}
1377 
1378 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1379 			&& check_auth_capabilities_supported(auths,
1380 			RTE_DIM(auths)) != 0) {
1381 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1382 				"HMAC SHA1 testsuite not met\n");
1383 		return TEST_SKIPPED;
1384 	}
1385 
1386 	return 0;
1387 }
1388 
1389 static int
1390 dev_configure_and_start(uint64_t ff_disable)
1391 {
1392 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1393 	struct crypto_unittest_params *ut_params = &unittest_params;
1394 
1395 	uint16_t qp_id;
1396 
1397 	/* Clear unit test parameters before running test */
1398 	memset(ut_params, 0, sizeof(*ut_params));
1399 
1400 	/* Reconfigure device to default parameters */
1401 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1402 	ts_params->conf.ff_disable = ff_disable;
1403 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1404 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1405 
1406 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1407 			&ts_params->conf),
1408 			"Failed to configure cryptodev %u",
1409 			ts_params->valid_devs[0]);
1410 
1411 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1412 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1413 			ts_params->valid_devs[0], qp_id,
1414 			&ts_params->qp_conf,
1415 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1416 			"Failed to setup queue pair %u on cryptodev %u",
1417 			qp_id, ts_params->valid_devs[0]);
1418 	}
1419 
1420 
1421 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1422 
1423 	/* Start the device */
1424 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1425 			"Failed to start cryptodev %u",
1426 			ts_params->valid_devs[0]);
1427 
1428 	return TEST_SUCCESS;
1429 }
1430 
1431 int
1432 ut_setup(void)
1433 {
1434 	/* Configure and start the device with security feature disabled */
1435 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1436 }
1437 
1438 static int
1439 ut_setup_security(void)
1440 {
1441 	/* Configure and start the device with no features disabled */
1442 	return dev_configure_and_start(0);
1443 }
1444 
1445 static int
1446 ut_setup_security_rx_inject(void)
1447 {
1448 	struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1449 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1450 	struct rte_eth_conf port_conf = {
1451 		.rxmode = {
1452 			.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1453 				    RTE_ETH_RX_OFFLOAD_SECURITY,
1454 		},
1455 		.txmode = {
1456 			.offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1457 		},
1458 		.lpbk_mode = 1,  /* Enable loopback */
1459 	};
1460 	struct rte_cryptodev_info dev_info;
1461 	struct rte_eth_rxconf rx_conf = {
1462 		.rx_thresh = {
1463 			.pthresh = 8,
1464 			.hthresh = 8,
1465 			.wthresh = 8,
1466 		},
1467 		.rx_free_thresh = 32,
1468 	};
1469 	uint16_t nb_ports;
1470 	void *sec_ctx;
1471 	int ret;
1472 
1473 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1474 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1475 	    !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1476 		RTE_LOG(INFO, USER1,
1477 			"Feature requirements for IPsec Rx inject test case not met\n");
1478 		return TEST_SKIPPED;
1479 	}
1480 
1481 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1482 	if (sec_ctx == NULL)
1483 		return TEST_SKIPPED;
1484 
1485 	nb_ports = rte_eth_dev_count_avail();
1486 	if (nb_ports == 0)
1487 		return TEST_SKIPPED;
1488 
1489 	ret = rte_eth_dev_configure(0 /* port_id */,
1490 				    1 /* nb_rx_queue */,
1491 				    0 /* nb_tx_queue */,
1492 				    &port_conf);
1493 	if (ret) {
1494 		printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1495 		return TEST_SKIPPED;
1496 	}
1497 
1498 	/* Rx queue setup */
1499 	ret = rte_eth_rx_queue_setup(0 /* port_id */,
1500 				     0 /* rx_queue_id */,
1501 				     1024 /* nb_rx_desc */,
1502 				     SOCKET_ID_ANY,
1503 				     &rx_conf,
1504 				     mbuf_pool);
1505 	if (ret) {
1506 		printf("Could not setup eth port 0 queue 0\n");
1507 		return TEST_SKIPPED;
1508 	}
1509 
1510 	ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1511 	if (ret) {
1512 		printf("Could not enable Rx inject offload");
1513 		return TEST_SKIPPED;
1514 	}
1515 
1516 	ret = rte_eth_dev_start(0);
1517 	if (ret) {
1518 		printf("Could not start ethdev");
1519 		return TEST_SKIPPED;
1520 	}
1521 
1522 	ret = rte_eth_promiscuous_enable(0);
1523 	if (ret) {
1524 		printf("Could not enable promiscuous mode");
1525 		return TEST_SKIPPED;
1526 	}
1527 
1528 	/* Configure and start cryptodev with no features disabled */
1529 	return dev_configure_and_start(0);
1530 }
1531 
1532 static inline void
1533 ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1534 {
1535 }
1536 
1537 static inline void
1538 ext_mbuf_memzone_free(int nb_segs)
1539 {
1540 	int i;
1541 
1542 	for (i = 0; i <= nb_segs; i++) {
1543 		char mz_name[RTE_MEMZONE_NAMESIZE];
1544 		const struct rte_memzone *memzone;
1545 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1546 		memzone = rte_memzone_lookup(mz_name);
1547 		if (memzone != NULL) {
1548 			rte_memzone_free(memzone);
1549 			memzone = NULL;
1550 		}
1551 	}
1552 }
1553 
1554 static inline struct rte_mbuf *
1555 ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1556 		int nb_segs, const void *input_text)
1557 {
1558 	struct rte_mbuf *m = NULL, *mbuf = NULL;
1559 	size_t data_off = 0;
1560 	uint8_t *dst;
1561 	int i, size;
1562 	int t_len;
1563 
1564 	if (pkt_len < 1) {
1565 		printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1566 		return NULL;
1567 	}
1568 
1569 	if (nb_segs < 1) {
1570 		printf("Number of segments must be 1 or more (is %d)\n",
1571 				nb_segs);
1572 		return NULL;
1573 	}
1574 
1575 	t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1576 	size = pkt_len;
1577 
1578 	/* Create chained mbuf_src with external buffer */
1579 	for (i = 0; size > 0; i++) {
1580 		struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1581 		uint16_t data_len = RTE_MIN(size, t_len);
1582 		char mz_name[RTE_MEMZONE_NAMESIZE];
1583 		const struct rte_memzone *memzone;
1584 		void *ext_buf_addr = NULL;
1585 		rte_iova_t buf_iova;
1586 		bool freed = false;
1587 		uint16_t buf_len;
1588 
1589 		buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1590 			sizeof(struct rte_mbuf_ext_shared_info), 8);
1591 
1592 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1593 		memzone = rte_memzone_lookup(mz_name);
1594 		if (memzone != NULL && memzone->len != buf_len) {
1595 			rte_memzone_free(memzone);
1596 			memzone = NULL;
1597 		}
1598 		if (memzone == NULL) {
1599 			memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1600 				RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1601 			if (memzone == NULL) {
1602 				printf("Can't allocate memory zone %s\n", mz_name);
1603 				return NULL;
1604 			}
1605 		}
1606 
1607 		ext_buf_addr = memzone->addr;
1608 		if (input_text)
1609 			memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1610 
1611 		/* Create buffer to hold rte_mbuf header */
1612 		m = rte_pktmbuf_alloc(mbuf_pool);
1613 		if (i == 0)
1614 			mbuf = m;
1615 
1616 		if (m == NULL) {
1617 			printf("Cannot create segment for source mbuf");
1618 			goto fail;
1619 		}
1620 
1621 		/* Save shared data (like callback function) in external buffer's end */
1622 		ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1623 			ext_mbuf_callback_fn_free, &freed);
1624 		if (ret_shinfo == NULL) {
1625 			printf("Shared mem initialization failed!\n");
1626 			goto fail;
1627 		}
1628 
1629 		buf_iova = rte_mem_virt2iova(ext_buf_addr);
1630 
1631 		/* Attach external buffer to mbuf */
1632 		rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1633 			ret_shinfo);
1634 		if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1635 			printf("External buffer is not attached to mbuf\n");
1636 			goto fail;
1637 		}
1638 
1639 		if (input_text) {
1640 			dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1641 			if (dst == NULL) {
1642 				printf("Cannot append %d bytes to the mbuf\n", data_len);
1643 				goto fail;
1644 			}
1645 		}
1646 
1647 		if (mbuf != m)
1648 			rte_pktmbuf_chain(mbuf, m);
1649 
1650 		size -= data_len;
1651 		data_off += data_len;
1652 	}
1653 
1654 	return mbuf;
1655 
1656 fail:
1657 	rte_pktmbuf_free(mbuf);
1658 	ext_mbuf_memzone_free(nb_segs);
1659 	return NULL;
1660 }
1661 
1662 void
1663 ut_teardown(void)
1664 {
1665 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 	struct crypto_unittest_params *ut_params = &unittest_params;
1667 
1668 	/* free crypto session structure */
1669 #ifdef RTE_LIB_SECURITY
1670 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1671 		if (ut_params->sec_session) {
1672 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1673 						(ts_params->valid_devs[0]),
1674 						ut_params->sec_session);
1675 			ut_params->sec_session = NULL;
1676 		}
1677 	} else
1678 #endif
1679 	{
1680 		if (ut_params->sess) {
1681 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1682 					ut_params->sess);
1683 			ut_params->sess = NULL;
1684 		}
1685 	}
1686 
1687 	/* free crypto operation structure */
1688 	rte_crypto_op_free(ut_params->op);
1689 
1690 	/*
1691 	 * free mbuf - both obuf and ibuf are usually the same,
1692 	 * so check if they point at the same address is necessary,
1693 	 * to avoid freeing the mbuf twice.
1694 	 */
1695 	if (ut_params->obuf) {
1696 		rte_pktmbuf_free(ut_params->obuf);
1697 		if (ut_params->ibuf == ut_params->obuf)
1698 			ut_params->ibuf = 0;
1699 		ut_params->obuf = 0;
1700 	}
1701 	if (ut_params->ibuf) {
1702 		ext_mbuf_memzone_free(1);
1703 		rte_pktmbuf_free(ut_params->ibuf);
1704 		ut_params->ibuf = 0;
1705 	}
1706 
1707 	if (ts_params->mbuf_pool != NULL)
1708 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1709 			rte_mempool_avail_count(ts_params->mbuf_pool));
1710 
1711 	/* Stop the device */
1712 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1713 }
1714 
1715 static void
1716 ut_teardown_rx_inject(void)
1717 {
1718 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1719 	void *sec_ctx;
1720 	int ret;
1721 
1722 	if  (rte_eth_dev_count_avail() != 0) {
1723 		ret = rte_eth_dev_reset(0);
1724 		if (ret)
1725 			printf("Could not reset eth port 0");
1726 
1727 	}
1728 
1729 	ut_teardown();
1730 
1731 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1732 	if (sec_ctx == NULL)
1733 		return;
1734 
1735 	ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1736 	if (ret) {
1737 		printf("Could not disable Rx inject offload");
1738 		return;
1739 	}
1740 }
1741 
1742 static int
1743 test_device_configure_invalid_dev_id(void)
1744 {
1745 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1746 	uint16_t dev_id, num_devs = 0;
1747 
1748 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1749 			"Need at least %d devices for test", 1);
1750 
1751 	/* valid dev_id values */
1752 	dev_id = ts_params->valid_devs[0];
1753 
1754 	/* Stop the device in case it's started so it can be configured */
1755 	rte_cryptodev_stop(dev_id);
1756 
1757 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1758 			"Failed test for rte_cryptodev_configure: "
1759 			"invalid dev_num %u", dev_id);
1760 
1761 	/* invalid dev_id values */
1762 	dev_id = num_devs;
1763 
1764 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1765 			"Failed test for rte_cryptodev_configure: "
1766 			"invalid dev_num %u", dev_id);
1767 
1768 	dev_id = 0xff;
1769 
1770 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1771 			"Failed test for rte_cryptodev_configure:"
1772 			"invalid dev_num %u", dev_id);
1773 
1774 	return TEST_SUCCESS;
1775 }
1776 
1777 static int
1778 test_device_configure_invalid_queue_pair_ids(void)
1779 {
1780 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1781 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1782 
1783 	/* Stop the device in case it's started so it can be configured */
1784 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1785 
1786 	/* valid - max value queue pairs */
1787 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1788 
1789 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1790 			&ts_params->conf),
1791 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1792 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1793 
1794 	/* valid - one queue pairs */
1795 	ts_params->conf.nb_queue_pairs = 1;
1796 
1797 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1798 			&ts_params->conf),
1799 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1800 			ts_params->valid_devs[0],
1801 			ts_params->conf.nb_queue_pairs);
1802 
1803 
1804 	/* invalid - zero queue pairs */
1805 	ts_params->conf.nb_queue_pairs = 0;
1806 
1807 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1808 			&ts_params->conf),
1809 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1810 			" invalid qps: %u",
1811 			ts_params->valid_devs[0],
1812 			ts_params->conf.nb_queue_pairs);
1813 
1814 
1815 	/* invalid - max value supported by field queue pairs */
1816 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1817 
1818 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1819 			&ts_params->conf),
1820 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1821 			" invalid qps: %u",
1822 			ts_params->valid_devs[0],
1823 			ts_params->conf.nb_queue_pairs);
1824 
1825 
1826 	/* invalid - max value + 1 queue pairs */
1827 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1828 
1829 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1830 			&ts_params->conf),
1831 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1832 			" invalid qps: %u",
1833 			ts_params->valid_devs[0],
1834 			ts_params->conf.nb_queue_pairs);
1835 
1836 	/* revert to original testsuite value */
1837 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1838 
1839 	return TEST_SUCCESS;
1840 }
1841 
1842 static int
1843 test_queue_pair_descriptor_setup(void)
1844 {
1845 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 	struct rte_cryptodev_qp_conf qp_conf = {
1847 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1848 	};
1849 	uint16_t qp_id;
1850 
1851 	/* Stop the device in case it's started so it can be configured */
1852 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1853 
1854 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1855 			&ts_params->conf),
1856 			"Failed to configure cryptodev %u",
1857 			ts_params->valid_devs[0]);
1858 
1859 	/*
1860 	 * Test various ring sizes on this device. memzones can't be
1861 	 * freed so are re-used if ring is released and re-created.
1862 	 */
1863 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1864 	qp_conf.mp_session = ts_params->session_mpool;
1865 
1866 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1867 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1868 				ts_params->valid_devs[0], qp_id, &qp_conf,
1869 				rte_cryptodev_socket_id(
1870 						ts_params->valid_devs[0])),
1871 				"Failed test for "
1872 				"rte_cryptodev_queue_pair_setup: num_inflights "
1873 				"%u on qp %u on cryptodev %u",
1874 				qp_conf.nb_descriptors, qp_id,
1875 				ts_params->valid_devs[0]);
1876 	}
1877 
1878 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1879 
1880 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1881 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1882 				ts_params->valid_devs[0], qp_id, &qp_conf,
1883 				rte_cryptodev_socket_id(
1884 						ts_params->valid_devs[0])),
1885 				"Failed test for"
1886 				" rte_cryptodev_queue_pair_setup: num_inflights"
1887 				" %u on qp %u on cryptodev %u",
1888 				qp_conf.nb_descriptors, qp_id,
1889 				ts_params->valid_devs[0]);
1890 	}
1891 
1892 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1893 
1894 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1895 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1896 				ts_params->valid_devs[0], qp_id, &qp_conf,
1897 				rte_cryptodev_socket_id(
1898 						ts_params->valid_devs[0])),
1899 				"Failed test for "
1900 				"rte_cryptodev_queue_pair_setup: num_inflights"
1901 				" %u on qp %u on cryptodev %u",
1902 				qp_conf.nb_descriptors, qp_id,
1903 				ts_params->valid_devs[0]);
1904 	}
1905 
1906 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1907 
1908 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1909 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1910 				ts_params->valid_devs[0], qp_id, &qp_conf,
1911 				rte_cryptodev_socket_id(
1912 						ts_params->valid_devs[0])),
1913 				"Failed test for"
1914 				" rte_cryptodev_queue_pair_setup:"
1915 				"num_inflights %u on qp %u on cryptodev %u",
1916 				qp_conf.nb_descriptors, qp_id,
1917 				ts_params->valid_devs[0]);
1918 	}
1919 
1920 	/* test invalid queue pair id */
1921 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1922 
1923 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1924 
1925 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1926 			ts_params->valid_devs[0],
1927 			qp_id, &qp_conf,
1928 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1929 			"Failed test for rte_cryptodev_queue_pair_setup:"
1930 			"invalid qp %u on cryptodev %u",
1931 			qp_id, ts_params->valid_devs[0]);
1932 
1933 	qp_id = 0xffff; /*invalid*/
1934 
1935 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1936 			ts_params->valid_devs[0],
1937 			qp_id, &qp_conf,
1938 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1939 			"Failed test for rte_cryptodev_queue_pair_setup:"
1940 			"invalid qp %u on cryptodev %u",
1941 			qp_id, ts_params->valid_devs[0]);
1942 
1943 	return TEST_SUCCESS;
1944 }
1945 
1946 /* ***** Plaintext data for tests ***** */
1947 
1948 const char catch_22_quote_1[] =
1949 		"There was only one catch and that was Catch-22, which "
1950 		"specified that a concern for one's safety in the face of "
1951 		"dangers that were real and immediate was the process of a "
1952 		"rational mind. Orr was crazy and could be grounded. All he "
1953 		"had to do was ask; and as soon as he did, he would no longer "
1954 		"be crazy and would have to fly more missions. Orr would be "
1955 		"crazy to fly more missions and sane if he didn't, but if he "
1956 		"was sane he had to fly them. If he flew them he was crazy "
1957 		"and didn't have to; but if he didn't want to he was sane and "
1958 		"had to. Yossarian was moved very deeply by the absolute "
1959 		"simplicity of this clause of Catch-22 and let out a "
1960 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1961 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1962 
1963 const char catch_22_quote[] =
1964 		"What a lousy earth! He wondered how many people were "
1965 		"destitute that same night even in his own prosperous country, "
1966 		"how many homes were shanties, how many husbands were drunk "
1967 		"and wives socked, and how many children were bullied, abused, "
1968 		"or abandoned. How many families hungered for food they could "
1969 		"not afford to buy? How many hearts were broken? How many "
1970 		"suicides would take place that same night, how many people "
1971 		"would go insane? How many cockroaches and landlords would "
1972 		"triumph? How many winners were losers, successes failures, "
1973 		"and rich men poor men? How many wise guys were stupid? How "
1974 		"many happy endings were unhappy endings? How many honest men "
1975 		"were liars, brave men cowards, loyal men traitors, how many "
1976 		"sainted men were corrupt, how many people in positions of "
1977 		"trust had sold their souls to bodyguards, how many had never "
1978 		"had souls? How many straight-and-narrow paths were crooked "
1979 		"paths? How many best families were worst families and how "
1980 		"many good people were bad people? When you added them all up "
1981 		"and then subtracted, you might be left with only the children, "
1982 		"and perhaps with Albert Einstein and an old violinist or "
1983 		"sculptor somewhere.";
1984 
1985 #define QUOTE_480_BYTES		(480)
1986 #define QUOTE_512_BYTES		(512)
1987 #define QUOTE_768_BYTES		(768)
1988 #define QUOTE_1024_BYTES	(1024)
1989 
1990 
1991 
1992 /* ***** SHA1 Hash Tests ***** */
1993 
1994 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1995 
1996 static uint8_t hmac_sha1_key[] = {
1997 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1998 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1999 	0xDE, 0xF4, 0xDE, 0xAD };
2000 
2001 /* ***** SHA224 Hash Tests ***** */
2002 
2003 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
2004 
2005 
2006 /* ***** AES-CBC Cipher Tests ***** */
2007 
2008 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
2009 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
2010 
2011 static uint8_t aes_cbc_key[] = {
2012 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2013 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2014 
2015 static uint8_t aes_cbc_iv[] = {
2016 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2017 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2018 
2019 
2020 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2021 
2022 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2023 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2024 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2025 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2026 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2027 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2028 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2029 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2030 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2031 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2032 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2033 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2034 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2035 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2036 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2037 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2038 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2039 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2040 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2041 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2042 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2043 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2044 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2045 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2046 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2047 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2048 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2049 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2050 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2051 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2052 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2053 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2054 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2055 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2056 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2057 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2058 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2059 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2060 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2061 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2062 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2063 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2064 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2065 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2066 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2067 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2068 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2069 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2070 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2071 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2072 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2073 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2074 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2075 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2076 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2077 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2078 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2079 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2080 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2081 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2082 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2083 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2084 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2085 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2086 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2087 };
2088 
2089 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2090 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2091 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2092 	0x18, 0x8c, 0x1d, 0x32
2093 };
2094 
2095 
2096 /* Multisession Vector context Test */
2097 /*Begin Session 0 */
2098 static uint8_t ms_aes_cbc_key0[] = {
2099 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2100 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2101 };
2102 
2103 static uint8_t ms_aes_cbc_iv0[] = {
2104 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2105 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2106 };
2107 
2108 static const uint8_t ms_aes_cbc_cipher0[] = {
2109 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2110 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2111 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2112 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2113 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2114 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2115 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2116 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2117 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2118 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2119 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2120 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2121 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2122 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2123 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2124 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2125 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2126 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2127 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2128 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2129 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2130 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2131 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2132 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2133 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2134 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2135 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2136 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2137 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2138 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2139 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2140 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2141 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2142 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2143 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2144 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2145 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2146 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2147 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2148 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2149 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2150 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2151 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2152 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2153 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2154 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2155 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2156 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2157 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2158 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2159 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2160 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2161 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2162 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2163 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2164 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2165 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2166 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2167 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2168 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2169 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2170 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2171 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2172 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2173 };
2174 
2175 
2176 static  uint8_t ms_hmac_key0[] = {
2177 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2178 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2179 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2180 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2181 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2182 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2183 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2184 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2185 };
2186 
2187 static const uint8_t ms_hmac_digest0[] = {
2188 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2189 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2190 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2191 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2192 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2193 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2194 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2195 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2196 		};
2197 
2198 /* End Session 0 */
2199 /* Begin session 1 */
2200 
2201 static  uint8_t ms_aes_cbc_key1[] = {
2202 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2203 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2204 };
2205 
2206 static  uint8_t ms_aes_cbc_iv1[] = {
2207 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2208 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2209 };
2210 
2211 static const uint8_t ms_aes_cbc_cipher1[] = {
2212 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2213 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2214 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2215 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2216 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2217 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2218 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2219 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2220 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2221 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2222 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2223 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2224 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2225 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2226 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2227 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2228 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2229 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2230 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2231 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2232 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2233 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2234 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2235 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2236 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2237 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2238 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2239 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2240 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2241 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2242 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2243 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2244 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2245 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2246 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2247 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2248 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2249 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2250 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2251 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2252 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2253 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2254 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2255 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2256 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2257 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2258 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2259 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2260 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2261 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2262 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2263 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2264 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2265 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2266 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2267 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2268 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2269 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2270 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2271 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2272 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2273 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2274 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2275 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2276 
2277 };
2278 
2279 static uint8_t ms_hmac_key1[] = {
2280 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2281 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2282 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2283 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2284 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2285 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2286 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2287 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2288 };
2289 
2290 static const uint8_t ms_hmac_digest1[] = {
2291 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2292 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2293 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2294 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2295 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2296 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2297 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2298 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2299 };
2300 /* End Session 1  */
2301 /* Begin Session 2 */
2302 static  uint8_t ms_aes_cbc_key2[] = {
2303 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2304 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2305 };
2306 
2307 static  uint8_t ms_aes_cbc_iv2[] = {
2308 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2309 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2310 };
2311 
2312 static const uint8_t ms_aes_cbc_cipher2[] = {
2313 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2314 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2315 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2316 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2317 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2318 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2319 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2320 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2321 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2322 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2323 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2324 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2325 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2326 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2327 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2328 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2329 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2330 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2331 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2332 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2333 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2334 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2335 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2336 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2337 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2338 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2339 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2340 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2341 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2342 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2343 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2344 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2345 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2346 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2347 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2348 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2349 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2350 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2351 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2352 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2353 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2354 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2355 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2356 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2357 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2358 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2359 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2360 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2361 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2362 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2363 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2364 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2365 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2366 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2367 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2368 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2369 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2370 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2371 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2372 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2373 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2374 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2375 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2376 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2377 };
2378 
2379 static  uint8_t ms_hmac_key2[] = {
2380 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2381 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2382 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2383 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2384 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2385 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2386 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2387 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2388 };
2389 
2390 static const uint8_t ms_hmac_digest2[] = {
2391 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2392 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2393 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2394 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2395 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2396 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2397 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2398 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2399 };
2400 
2401 /* End Session 2 */
2402 
2403 
2404 static int
2405 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2406 {
2407 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2408 	struct crypto_unittest_params *ut_params = &unittest_params;
2409 	/* Verify the capabilities */
2410 	struct rte_cryptodev_sym_capability_idx cap_idx;
2411 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2412 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2413 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2414 			&cap_idx) == NULL)
2415 		return TEST_SKIPPED;
2416 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2417 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2418 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2419 			&cap_idx) == NULL)
2420 		return TEST_SKIPPED;
2421 
2422 	/* Generate test mbuf data and space for digest */
2423 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2424 			catch_22_quote,	QUOTE_512_BYTES, 0);
2425 
2426 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2427 			DIGEST_BYTE_LENGTH_SHA1);
2428 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2429 
2430 	/* Setup Cipher Parameters */
2431 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2432 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2433 
2434 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2435 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2436 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2437 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2438 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2439 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2440 
2441 	/* Setup HMAC Parameters */
2442 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2443 
2444 	ut_params->auth_xform.next = NULL;
2445 
2446 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2447 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2448 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2449 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2450 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2451 
2452 	rte_errno = 0;
2453 	ut_params->sess = rte_cryptodev_sym_session_create(
2454 			ts_params->valid_devs[0], &ut_params->cipher_xform,
2455 			ts_params->session_mpool);
2456 	if (rte_errno == ENOTSUP)
2457 		return TEST_SKIPPED;
2458 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2459 
2460 	/* Generate crypto op data structure */
2461 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2462 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2463 	TEST_ASSERT_NOT_NULL(ut_params->op,
2464 			"Failed to allocate symmetric crypto operation struct");
2465 
2466 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2467 
2468 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2469 
2470 	/* set crypto operation source mbuf */
2471 	sym_op->m_src = ut_params->ibuf;
2472 
2473 	/* Set crypto operation authentication parameters */
2474 	sym_op->auth.digest.data = ut_params->digest;
2475 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2476 			ut_params->ibuf, QUOTE_512_BYTES);
2477 
2478 	sym_op->auth.data.offset = 0;
2479 	sym_op->auth.data.length = QUOTE_512_BYTES;
2480 
2481 	/* Copy IV at the end of the crypto operation */
2482 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2483 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2484 
2485 	/* Set crypto operation cipher parameters */
2486 	sym_op->cipher.data.offset = 0;
2487 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2488 
2489 	/* Process crypto operation */
2490 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2491 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2492 			ut_params->op);
2493 	else
2494 		TEST_ASSERT_NOT_NULL(
2495 			process_crypto_request(ts_params->valid_devs[0],
2496 				ut_params->op),
2497 				"failed to process sym crypto op");
2498 
2499 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2500 			"crypto op processing failed");
2501 
2502 	/* Validate obuf */
2503 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2504 			uint8_t *);
2505 
2506 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2507 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2508 			QUOTE_512_BYTES,
2509 			"ciphertext data not as expected");
2510 
2511 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2512 
2513 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2514 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2515 			gbl_driver_id == rte_cryptodev_driver_id_get(
2516 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2517 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2518 					DIGEST_BYTE_LENGTH_SHA1,
2519 			"Generated digest data not as expected");
2520 
2521 	return TEST_SUCCESS;
2522 }
2523 
2524 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2525 
2526 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2527 
2528 static uint8_t hmac_sha512_key[] = {
2529 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2530 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2531 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2532 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2533 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2534 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2535 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2536 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2537 
2538 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2539 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2540 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2541 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2542 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2543 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2544 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2545 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2546 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2547 
2548 
2549 
2550 static int
2551 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2552 		struct crypto_unittest_params *ut_params,
2553 		uint8_t *cipher_key,
2554 		uint8_t *hmac_key);
2555 
2556 static int
2557 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2558 		struct crypto_unittest_params *ut_params,
2559 		struct crypto_testsuite_params *ts_params,
2560 		const uint8_t *cipher,
2561 		const uint8_t *digest,
2562 		const uint8_t *iv);
2563 
2564 
2565 static int
2566 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2567 		struct crypto_unittest_params *ut_params,
2568 		uint8_t *cipher_key,
2569 		uint8_t *hmac_key)
2570 {
2571 
2572 	/* Setup Cipher Parameters */
2573 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2574 	ut_params->cipher_xform.next = NULL;
2575 
2576 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2577 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2578 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2579 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2580 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2581 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2582 
2583 	/* Setup HMAC Parameters */
2584 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2585 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2586 
2587 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2588 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2589 	ut_params->auth_xform.auth.key.data = hmac_key;
2590 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2591 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2592 
2593 	return TEST_SUCCESS;
2594 }
2595 
2596 
2597 static int
2598 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2599 		struct crypto_unittest_params *ut_params,
2600 		struct crypto_testsuite_params *ts_params,
2601 		const uint8_t *cipher,
2602 		const uint8_t *digest,
2603 		const uint8_t *iv)
2604 {
2605 	int ret;
2606 
2607 	/* Generate test mbuf data and digest */
2608 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2609 			(const char *)
2610 			cipher,
2611 			QUOTE_512_BYTES, 0);
2612 
2613 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2614 			DIGEST_BYTE_LENGTH_SHA512);
2615 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2616 
2617 	rte_memcpy(ut_params->digest,
2618 			digest,
2619 			DIGEST_BYTE_LENGTH_SHA512);
2620 
2621 	/* Generate Crypto op data structure */
2622 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2623 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2624 	TEST_ASSERT_NOT_NULL(ut_params->op,
2625 			"Failed to allocate symmetric crypto operation struct");
2626 
2627 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2628 
2629 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2630 
2631 	/* set crypto operation source mbuf */
2632 	sym_op->m_src = ut_params->ibuf;
2633 
2634 	sym_op->auth.digest.data = ut_params->digest;
2635 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2636 			ut_params->ibuf, QUOTE_512_BYTES);
2637 
2638 	sym_op->auth.data.offset = 0;
2639 	sym_op->auth.data.length = QUOTE_512_BYTES;
2640 
2641 	/* Copy IV at the end of the crypto operation */
2642 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2643 			iv, CIPHER_IV_LENGTH_AES_CBC);
2644 
2645 	sym_op->cipher.data.offset = 0;
2646 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2647 
2648 	/* Process crypto operation */
2649 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2650 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2651 			ut_params->op);
2652 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2653 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2654 		if (ret != TEST_SUCCESS)
2655 			return ret;
2656 	} else
2657 		TEST_ASSERT_NOT_NULL(
2658 				process_crypto_request(ts_params->valid_devs[0],
2659 					ut_params->op),
2660 					"failed to process sym crypto op");
2661 
2662 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2663 			"crypto op processing failed");
2664 
2665 	ut_params->obuf = ut_params->op->sym->m_src;
2666 
2667 	/* Validate obuf */
2668 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2669 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2670 			catch_22_quote,
2671 			QUOTE_512_BYTES,
2672 			"Plaintext data not as expected");
2673 
2674 	/* Validate obuf */
2675 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2676 			"Digest verification failed");
2677 
2678 	return TEST_SUCCESS;
2679 }
2680 
2681 /* ***** SNOW 3G Tests ***** */
2682 static int
2683 create_wireless_algo_hash_session(uint8_t dev_id,
2684 	const uint8_t *key, const uint8_t key_len,
2685 	const uint8_t iv_len, const uint8_t auth_len,
2686 	enum rte_crypto_auth_operation op,
2687 	enum rte_crypto_auth_algorithm algo)
2688 {
2689 	uint8_t hash_key[key_len];
2690 
2691 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2692 	struct crypto_unittest_params *ut_params = &unittest_params;
2693 
2694 	memcpy(hash_key, key, key_len);
2695 
2696 	debug_hexdump(stdout, "key:", key, key_len);
2697 
2698 	/* Setup Authentication Parameters */
2699 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2700 	ut_params->auth_xform.next = NULL;
2701 
2702 	ut_params->auth_xform.auth.op = op;
2703 	ut_params->auth_xform.auth.algo = algo;
2704 	ut_params->auth_xform.auth.key.length = key_len;
2705 	ut_params->auth_xform.auth.key.data = hash_key;
2706 	ut_params->auth_xform.auth.digest_length = auth_len;
2707 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2708 	ut_params->auth_xform.auth.iv.length = iv_len;
2709 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2710 			&ut_params->auth_xform, ts_params->session_mpool);
2711 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2712 		return TEST_SKIPPED;
2713 
2714 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2715 	return 0;
2716 }
2717 
2718 static int
2719 create_wireless_algo_cipher_session(uint8_t dev_id,
2720 			enum rte_crypto_cipher_operation op,
2721 			enum rte_crypto_cipher_algorithm algo,
2722 			const uint8_t *key, const uint8_t key_len,
2723 			uint8_t iv_len)
2724 {
2725 	uint8_t cipher_key[key_len];
2726 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2727 	struct crypto_unittest_params *ut_params = &unittest_params;
2728 
2729 	memcpy(cipher_key, key, key_len);
2730 
2731 	/* Setup Cipher Parameters */
2732 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2733 	ut_params->cipher_xform.next = NULL;
2734 
2735 	ut_params->cipher_xform.cipher.algo = algo;
2736 	ut_params->cipher_xform.cipher.op = op;
2737 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2738 	ut_params->cipher_xform.cipher.key.length = key_len;
2739 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2740 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2741 
2742 	debug_hexdump(stdout, "key:", key, key_len);
2743 
2744 	/* Create Crypto session */
2745 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2746 			&ut_params->cipher_xform, ts_params->session_mpool);
2747 
2748 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2749 		return TEST_SKIPPED;
2750 
2751 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2752 	return 0;
2753 }
2754 
2755 static int
2756 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2757 			unsigned int cipher_len,
2758 			unsigned int cipher_offset)
2759 {
2760 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2761 	struct crypto_unittest_params *ut_params = &unittest_params;
2762 
2763 	/* Generate Crypto op data structure */
2764 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2765 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2766 	TEST_ASSERT_NOT_NULL(ut_params->op,
2767 				"Failed to allocate pktmbuf offload");
2768 
2769 	/* Set crypto operation data parameters */
2770 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2771 
2772 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2773 
2774 	/* set crypto operation source mbuf */
2775 	sym_op->m_src = ut_params->ibuf;
2776 
2777 	/* iv */
2778 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2779 			iv, iv_len);
2780 	sym_op->cipher.data.length = cipher_len;
2781 	sym_op->cipher.data.offset = cipher_offset;
2782 	return 0;
2783 }
2784 
2785 static int
2786 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2787 			unsigned int cipher_len,
2788 			unsigned int cipher_offset)
2789 {
2790 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2791 	struct crypto_unittest_params *ut_params = &unittest_params;
2792 
2793 	/* Generate Crypto op data structure */
2794 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2795 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2796 	TEST_ASSERT_NOT_NULL(ut_params->op,
2797 				"Failed to allocate pktmbuf offload");
2798 
2799 	/* Set crypto operation data parameters */
2800 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2801 
2802 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2803 
2804 	/* set crypto operation source mbuf */
2805 	sym_op->m_src = ut_params->ibuf;
2806 	sym_op->m_dst = ut_params->obuf;
2807 
2808 	/* iv */
2809 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2810 			iv, iv_len);
2811 	sym_op->cipher.data.length = cipher_len;
2812 	sym_op->cipher.data.offset = cipher_offset;
2813 	return 0;
2814 }
2815 
2816 static int
2817 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2818 		enum rte_crypto_cipher_operation cipher_op,
2819 		enum rte_crypto_auth_operation auth_op,
2820 		enum rte_crypto_auth_algorithm auth_algo,
2821 		enum rte_crypto_cipher_algorithm cipher_algo,
2822 		const uint8_t *a_key, uint8_t a_key_len,
2823 		const uint8_t *c_key, uint8_t c_key_len,
2824 		uint8_t auth_iv_len, uint8_t auth_len,
2825 		uint8_t cipher_iv_len)
2826 
2827 {
2828 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2829 	struct crypto_unittest_params *ut_params = &unittest_params;
2830 
2831 	/* Setup Authentication Parameters */
2832 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2833 	ut_params->auth_xform.next = NULL;
2834 
2835 	ut_params->auth_xform.auth.op = auth_op;
2836 	ut_params->auth_xform.auth.algo = auth_algo;
2837 	ut_params->auth_xform.auth.key.length = a_key_len;
2838 	ut_params->auth_xform.auth.key.data = a_key;
2839 	ut_params->auth_xform.auth.digest_length = auth_len;
2840 	/* Auth IV will be after cipher IV */
2841 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2842 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2843 
2844 	/* Setup Cipher Parameters */
2845 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2846 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2847 
2848 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2849 	ut_params->cipher_xform.cipher.op = cipher_op;
2850 	ut_params->cipher_xform.cipher.key.data = c_key;
2851 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2852 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2853 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2854 
2855 	debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
2856 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2857 
2858 	/* Create Crypto session*/
2859 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2860 			&ut_params->cipher_xform, ts_params->session_mpool);
2861 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2862 		return TEST_SKIPPED;
2863 
2864 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2865 	return 0;
2866 }
2867 
2868 static int
2869 create_wireless_cipher_auth_session(uint8_t dev_id,
2870 		enum rte_crypto_cipher_operation cipher_op,
2871 		enum rte_crypto_auth_operation auth_op,
2872 		enum rte_crypto_auth_algorithm auth_algo,
2873 		enum rte_crypto_cipher_algorithm cipher_algo,
2874 		const struct wireless_test_data *tdata)
2875 {
2876 	const uint8_t key_len = tdata->key.len;
2877 	uint8_t cipher_auth_key[key_len];
2878 
2879 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2880 	struct crypto_unittest_params *ut_params = &unittest_params;
2881 	const uint8_t *key = tdata->key.data;
2882 	const uint8_t auth_len = tdata->digest.len;
2883 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2884 	uint8_t auth_iv_len = tdata->auth_iv.len;
2885 
2886 	memcpy(cipher_auth_key, key, key_len);
2887 
2888 	/* Setup Authentication Parameters */
2889 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2890 	ut_params->auth_xform.next = NULL;
2891 
2892 	ut_params->auth_xform.auth.op = auth_op;
2893 	ut_params->auth_xform.auth.algo = auth_algo;
2894 	ut_params->auth_xform.auth.key.length = key_len;
2895 	/* Hash key = cipher key */
2896 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2897 	ut_params->auth_xform.auth.digest_length = auth_len;
2898 	/* Auth IV will be after cipher IV */
2899 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2900 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2901 
2902 	/* Setup Cipher Parameters */
2903 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2904 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2905 
2906 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2907 	ut_params->cipher_xform.cipher.op = cipher_op;
2908 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2909 	ut_params->cipher_xform.cipher.key.length = key_len;
2910 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2911 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2912 
2913 
2914 	debug_hexdump(stdout, "key:", key, key_len);
2915 
2916 	/* Create Crypto session*/
2917 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2918 			&ut_params->cipher_xform, ts_params->session_mpool);
2919 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2920 		return TEST_SKIPPED;
2921 
2922 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2923 	return 0;
2924 }
2925 
2926 static int
2927 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2928 		const struct wireless_test_data *tdata)
2929 {
2930 	return create_wireless_cipher_auth_session(dev_id,
2931 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2932 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2933 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2934 }
2935 
2936 static int
2937 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2938 		enum rte_crypto_cipher_operation cipher_op,
2939 		enum rte_crypto_auth_operation auth_op,
2940 		enum rte_crypto_auth_algorithm auth_algo,
2941 		enum rte_crypto_cipher_algorithm cipher_algo,
2942 		const uint8_t *a_key, const uint8_t a_key_len,
2943 		const uint8_t *c_key, const uint8_t c_key_len,
2944 		uint8_t auth_iv_len, uint8_t auth_len,
2945 		uint8_t cipher_iv_len)
2946 {
2947 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2948 	struct crypto_unittest_params *ut_params = &unittest_params;
2949 
2950 	/* Setup Authentication Parameters */
2951 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2952 	ut_params->auth_xform.auth.op = auth_op;
2953 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2954 	ut_params->auth_xform.auth.algo = auth_algo;
2955 	ut_params->auth_xform.auth.key.length = a_key_len;
2956 	ut_params->auth_xform.auth.key.data = a_key;
2957 	ut_params->auth_xform.auth.digest_length = auth_len;
2958 	/* Auth IV will be after cipher IV */
2959 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2960 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2961 
2962 	/* Setup Cipher Parameters */
2963 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2964 	ut_params->cipher_xform.next = NULL;
2965 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2966 	ut_params->cipher_xform.cipher.op = cipher_op;
2967 	ut_params->cipher_xform.cipher.key.data = c_key;
2968 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2969 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2970 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2971 
2972 	debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
2973 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2974 
2975 	/* Create Crypto session*/
2976 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2977 		ut_params->auth_xform.next = NULL;
2978 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2979 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2980 			&ut_params->cipher_xform, ts_params->session_mpool);
2981 	} else
2982 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2983 			&ut_params->auth_xform, ts_params->session_mpool);
2984 
2985 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2986 		return TEST_SKIPPED;
2987 
2988 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2989 
2990 	return 0;
2991 }
2992 
2993 static int
2994 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2995 		unsigned int auth_tag_len,
2996 		const uint8_t *iv, unsigned int iv_len,
2997 		unsigned int data_pad_len,
2998 		enum rte_crypto_auth_operation op,
2999 		unsigned int auth_len, unsigned int auth_offset)
3000 {
3001 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3002 
3003 	struct crypto_unittest_params *ut_params = &unittest_params;
3004 
3005 	/* Generate Crypto op data structure */
3006 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3007 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3008 	TEST_ASSERT_NOT_NULL(ut_params->op,
3009 		"Failed to allocate pktmbuf offload");
3010 
3011 	/* Set crypto operation data parameters */
3012 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3013 
3014 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3015 
3016 	/* set crypto operation source mbuf */
3017 	sym_op->m_src = ut_params->ibuf;
3018 
3019 	/* iv */
3020 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3021 			iv, iv_len);
3022 	/* digest */
3023 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3024 					ut_params->ibuf, auth_tag_len);
3025 
3026 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3027 				"no room to append auth tag");
3028 	ut_params->digest = sym_op->auth.digest.data;
3029 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3030 			ut_params->ibuf, data_pad_len);
3031 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3032 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3033 	else
3034 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3035 
3036 	debug_hexdump(stdout, "digest:",
3037 		sym_op->auth.digest.data,
3038 		auth_tag_len);
3039 
3040 	sym_op->auth.data.length = auth_len;
3041 	sym_op->auth.data.offset = auth_offset;
3042 
3043 	return 0;
3044 }
3045 
3046 static int
3047 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3048 	enum rte_crypto_auth_operation op)
3049 {
3050 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3051 	struct crypto_unittest_params *ut_params = &unittest_params;
3052 
3053 	const uint8_t *auth_tag = tdata->digest.data;
3054 	const unsigned int auth_tag_len = tdata->digest.len;
3055 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3056 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3057 
3058 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
3059 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3060 	const uint8_t *auth_iv = tdata->auth_iv.data;
3061 	const uint8_t auth_iv_len = tdata->auth_iv.len;
3062 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3063 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
3064 
3065 	/* Generate Crypto op data structure */
3066 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3067 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3068 	TEST_ASSERT_NOT_NULL(ut_params->op,
3069 			"Failed to allocate pktmbuf offload");
3070 	/* Set crypto operation data parameters */
3071 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3072 
3073 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3074 
3075 	/* set crypto operation source mbuf */
3076 	sym_op->m_src = ut_params->ibuf;
3077 
3078 	/* digest */
3079 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3080 			ut_params->ibuf, auth_tag_len);
3081 
3082 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3083 			"no room to append auth tag");
3084 	ut_params->digest = sym_op->auth.digest.data;
3085 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3086 			ut_params->ibuf, data_pad_len);
3087 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3088 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3089 	else
3090 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3091 
3092 	debug_hexdump(stdout, "digest:",
3093 		sym_op->auth.digest.data,
3094 		auth_tag_len);
3095 
3096 	/* Copy cipher and auth IVs at the end of the crypto operation */
3097 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3098 						IV_OFFSET);
3099 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3100 	iv_ptr += cipher_iv_len;
3101 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3102 
3103 	sym_op->cipher.data.length = cipher_len;
3104 	sym_op->cipher.data.offset = 0;
3105 	sym_op->auth.data.length = auth_len;
3106 	sym_op->auth.data.offset = 0;
3107 
3108 	return 0;
3109 }
3110 
3111 static int
3112 create_zuc_cipher_hash_generate_operation(
3113 		const struct wireless_test_data *tdata)
3114 {
3115 	return create_wireless_cipher_hash_operation(tdata,
3116 		RTE_CRYPTO_AUTH_OP_GENERATE);
3117 }
3118 
3119 static int
3120 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3121 		const unsigned auth_tag_len,
3122 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3123 		unsigned data_pad_len,
3124 		enum rte_crypto_auth_operation op,
3125 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3126 		const unsigned cipher_len, const unsigned cipher_offset,
3127 		const unsigned auth_len, const unsigned auth_offset)
3128 {
3129 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3130 	struct crypto_unittest_params *ut_params = &unittest_params;
3131 
3132 	enum rte_crypto_cipher_algorithm cipher_algo =
3133 			ut_params->cipher_xform.cipher.algo;
3134 	enum rte_crypto_auth_algorithm auth_algo =
3135 			ut_params->auth_xform.auth.algo;
3136 
3137 	/* Generate Crypto op data structure */
3138 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3139 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3140 	TEST_ASSERT_NOT_NULL(ut_params->op,
3141 			"Failed to allocate pktmbuf offload");
3142 	/* Set crypto operation data parameters */
3143 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3144 
3145 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3146 
3147 	/* set crypto operation source mbuf */
3148 	sym_op->m_src = ut_params->ibuf;
3149 
3150 	/* digest */
3151 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3152 			ut_params->ibuf, auth_tag_len);
3153 
3154 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3155 			"no room to append auth tag");
3156 	ut_params->digest = sym_op->auth.digest.data;
3157 
3158 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3159 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3160 				ut_params->ibuf, data_pad_len);
3161 	} else {
3162 		struct rte_mbuf *m = ut_params->ibuf;
3163 		unsigned int offset = data_pad_len;
3164 
3165 		while (offset > m->data_len && m->next != NULL) {
3166 			offset -= m->data_len;
3167 			m = m->next;
3168 		}
3169 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3170 			m, offset);
3171 	}
3172 
3173 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3174 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3175 	else
3176 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3177 
3178 	debug_hexdump(stdout, "digest:",
3179 		sym_op->auth.digest.data,
3180 		auth_tag_len);
3181 
3182 	/* Copy cipher and auth IVs at the end of the crypto operation */
3183 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3184 						IV_OFFSET);
3185 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3186 	iv_ptr += cipher_iv_len;
3187 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3188 
3189 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3190 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3191 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3192 		sym_op->cipher.data.length = cipher_len;
3193 		sym_op->cipher.data.offset = cipher_offset;
3194 	} else {
3195 		sym_op->cipher.data.length = cipher_len >> 3;
3196 		sym_op->cipher.data.offset = cipher_offset >> 3;
3197 	}
3198 
3199 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3200 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3201 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3202 		sym_op->auth.data.length = auth_len;
3203 		sym_op->auth.data.offset = auth_offset;
3204 	} else {
3205 		sym_op->auth.data.length = auth_len >> 3;
3206 		sym_op->auth.data.offset = auth_offset >> 3;
3207 	}
3208 
3209 	return 0;
3210 }
3211 
3212 static int
3213 create_wireless_algo_auth_cipher_operation(
3214 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3215 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3216 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3217 		unsigned int data_pad_len,
3218 		unsigned int cipher_len, unsigned int cipher_offset,
3219 		unsigned int auth_len, unsigned int auth_offset,
3220 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3221 {
3222 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3223 	struct crypto_unittest_params *ut_params = &unittest_params;
3224 
3225 	enum rte_crypto_cipher_algorithm cipher_algo =
3226 			ut_params->cipher_xform.cipher.algo;
3227 	enum rte_crypto_auth_algorithm auth_algo =
3228 			ut_params->auth_xform.auth.algo;
3229 
3230 	/* Generate Crypto op data structure */
3231 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3232 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3233 	TEST_ASSERT_NOT_NULL(ut_params->op,
3234 			"Failed to allocate pktmbuf offload");
3235 
3236 	/* Set crypto operation data parameters */
3237 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3238 
3239 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3240 
3241 	/* set crypto operation mbufs */
3242 	sym_op->m_src = ut_params->ibuf;
3243 	if (op_mode == OUT_OF_PLACE)
3244 		sym_op->m_dst = ut_params->obuf;
3245 
3246 	/* digest */
3247 	if (!do_sgl) {
3248 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3249 			(op_mode == IN_PLACE ?
3250 				ut_params->ibuf : ut_params->obuf),
3251 			uint8_t *, data_pad_len);
3252 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3253 			(op_mode == IN_PLACE ?
3254 				ut_params->ibuf : ut_params->obuf),
3255 			data_pad_len);
3256 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3257 	} else {
3258 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3259 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3260 				sym_op->m_src : sym_op->m_dst);
3261 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3262 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3263 			sgl_buf = sgl_buf->next;
3264 		}
3265 
3266 		/* The last segment should be large enough to hold full digest */
3267 		if (sgl_buf->data_len < auth_tag_len) {
3268 			rte_pktmbuf_free(sgl_buf->next);
3269 			sgl_buf->next = NULL;
3270 			TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3271 					auth_tag_len - sgl_buf->data_len),
3272 					"No room to append auth tag");
3273 		}
3274 
3275 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3276 				uint8_t *, remaining_off);
3277 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3278 				remaining_off);
3279 		memset(sym_op->auth.digest.data, 0, remaining_off);
3280 		while (sgl_buf->next != NULL) {
3281 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3282 				0, rte_pktmbuf_data_len(sgl_buf));
3283 			sgl_buf = sgl_buf->next;
3284 		}
3285 	}
3286 
3287 	/* Copy digest for the verification */
3288 	if (verify)
3289 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3290 
3291 	/* Copy cipher and auth IVs at the end of the crypto operation */
3292 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3293 			ut_params->op, uint8_t *, IV_OFFSET);
3294 
3295 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3296 	iv_ptr += cipher_iv_len;
3297 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3298 
3299 	/* Only copy over the offset data needed from src to dst in OOP,
3300 	 * if the auth and cipher offsets are not aligned
3301 	 */
3302 	if (op_mode == OUT_OF_PLACE) {
3303 		if (cipher_offset > auth_offset)
3304 			rte_memcpy(
3305 				rte_pktmbuf_mtod_offset(
3306 					sym_op->m_dst,
3307 					uint8_t *, auth_offset >> 3),
3308 				rte_pktmbuf_mtod_offset(
3309 					sym_op->m_src,
3310 					uint8_t *, auth_offset >> 3),
3311 				((cipher_offset >> 3) - (auth_offset >> 3)));
3312 	}
3313 
3314 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3315 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3316 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3317 		sym_op->cipher.data.length = cipher_len;
3318 		sym_op->cipher.data.offset = cipher_offset;
3319 	} else {
3320 		sym_op->cipher.data.length = cipher_len >> 3;
3321 		sym_op->cipher.data.offset = cipher_offset >> 3;
3322 	}
3323 
3324 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3325 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3326 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3327 		sym_op->auth.data.length = auth_len;
3328 		sym_op->auth.data.offset = auth_offset;
3329 	} else {
3330 		sym_op->auth.data.length = auth_len >> 3;
3331 		sym_op->auth.data.offset = auth_offset >> 3;
3332 	}
3333 
3334 	return 0;
3335 }
3336 
3337 static int
3338 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3339 {
3340 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3341 	struct crypto_unittest_params *ut_params = &unittest_params;
3342 
3343 	int retval;
3344 	unsigned plaintext_pad_len;
3345 	unsigned plaintext_len;
3346 	uint8_t *plaintext;
3347 	struct rte_cryptodev_info dev_info;
3348 
3349 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3350 	uint64_t feat_flags = dev_info.feature_flags;
3351 
3352 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3353 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3354 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3355 		return TEST_SKIPPED;
3356 	}
3357 
3358 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3359 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3360 		printf("Device doesn't support RAW data-path APIs.\n");
3361 		return TEST_SKIPPED;
3362 	}
3363 
3364 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3365 		return TEST_SKIPPED;
3366 
3367 	/* Verify the capabilities */
3368 	struct rte_cryptodev_sym_capability_idx cap_idx;
3369 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3370 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3371 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3372 			&cap_idx) == NULL)
3373 		return TEST_SKIPPED;
3374 
3375 	/* Create SNOW 3G session */
3376 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3377 			tdata->key.data, tdata->key.len,
3378 			tdata->auth_iv.len, tdata->digest.len,
3379 			RTE_CRYPTO_AUTH_OP_GENERATE,
3380 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3381 	if (retval < 0)
3382 		return retval;
3383 
3384 	/* alloc mbuf and set payload */
3385 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3386 
3387 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3388 	rte_pktmbuf_tailroom(ut_params->ibuf));
3389 
3390 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3391 	/* Append data which is padded to a multiple of */
3392 	/* the algorithms block size */
3393 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3394 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3395 				plaintext_pad_len);
3396 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3397 
3398 	/* Create SNOW 3G operation */
3399 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3400 			tdata->auth_iv.data, tdata->auth_iv.len,
3401 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3402 			tdata->validAuthLenInBits.len,
3403 			0);
3404 	if (retval < 0)
3405 		return retval;
3406 
3407 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3408 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3409 					       0);
3410 		if (retval != TEST_SUCCESS)
3411 			return retval;
3412 	} else
3413 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3414 				ut_params->op);
3415 	ut_params->obuf = ut_params->op->sym->m_src;
3416 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3417 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3418 						    uint8_t *,
3419 						    plaintext_pad_len);
3420 
3421 	/* Validate obuf */
3422 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3423 	ut_params->digest,
3424 	tdata->digest.data,
3425 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3426 	"SNOW 3G Generated auth tag not as expected");
3427 
3428 	return 0;
3429 }
3430 
3431 static int
3432 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3433 {
3434 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3435 	struct crypto_unittest_params *ut_params = &unittest_params;
3436 
3437 	int retval;
3438 	unsigned plaintext_pad_len;
3439 	unsigned plaintext_len;
3440 	uint8_t *plaintext;
3441 	struct rte_cryptodev_info dev_info;
3442 
3443 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3444 	uint64_t feat_flags = dev_info.feature_flags;
3445 
3446 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3447 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3448 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3449 		return TEST_SKIPPED;
3450 	}
3451 
3452 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3453 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3454 		printf("Device doesn't support RAW data-path APIs.\n");
3455 		return TEST_SKIPPED;
3456 	}
3457 
3458 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3459 		return TEST_SKIPPED;
3460 
3461 	/* Verify the capabilities */
3462 	struct rte_cryptodev_sym_capability_idx cap_idx;
3463 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3464 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3465 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3466 			&cap_idx) == NULL)
3467 		return TEST_SKIPPED;
3468 
3469 	/* Create SNOW 3G session */
3470 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3471 				tdata->key.data, tdata->key.len,
3472 				tdata->auth_iv.len, tdata->digest.len,
3473 				RTE_CRYPTO_AUTH_OP_VERIFY,
3474 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3475 	if (retval < 0)
3476 		return retval;
3477 	/* alloc mbuf and set payload */
3478 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 
3480 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3481 	rte_pktmbuf_tailroom(ut_params->ibuf));
3482 
3483 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3484 	/* Append data which is padded to a multiple of */
3485 	/* the algorithms block size */
3486 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3487 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3488 				plaintext_pad_len);
3489 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3490 
3491 	/* Create SNOW 3G operation */
3492 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3493 			tdata->digest.len,
3494 			tdata->auth_iv.data, tdata->auth_iv.len,
3495 			plaintext_pad_len,
3496 			RTE_CRYPTO_AUTH_OP_VERIFY,
3497 			tdata->validAuthLenInBits.len,
3498 			0);
3499 	if (retval < 0)
3500 		return retval;
3501 
3502 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3503 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3504 					       0);
3505 		if (retval != TEST_SUCCESS)
3506 			return retval;
3507 	} else
3508 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3509 				ut_params->op);
3510 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3511 	ut_params->obuf = ut_params->op->sym->m_src;
3512 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3513 						    uint8_t *,
3514 						    plaintext_pad_len);
3515 
3516 	/* Validate obuf */
3517 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3518 		return 0;
3519 	else
3520 		return -1;
3521 
3522 	return 0;
3523 }
3524 
3525 static int
3526 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3527 {
3528 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3529 	struct crypto_unittest_params *ut_params = &unittest_params;
3530 
3531 	int retval;
3532 	unsigned plaintext_pad_len;
3533 	unsigned plaintext_len;
3534 	uint8_t *plaintext;
3535 	struct rte_cryptodev_info dev_info;
3536 
3537 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3538 	uint64_t feat_flags = dev_info.feature_flags;
3539 
3540 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3541 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3542 		printf("Device doesn't support RAW data-path APIs.\n");
3543 		return TEST_SKIPPED;
3544 	}
3545 
3546 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3547 		return TEST_SKIPPED;
3548 
3549 	/* Verify the capabilities */
3550 	struct rte_cryptodev_sym_capability_idx cap_idx;
3551 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3552 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3553 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3554 			&cap_idx) == NULL)
3555 		return TEST_SKIPPED;
3556 
3557 	/* Create KASUMI session */
3558 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3559 			tdata->key.data, tdata->key.len,
3560 			0, tdata->digest.len,
3561 			RTE_CRYPTO_AUTH_OP_GENERATE,
3562 			RTE_CRYPTO_AUTH_KASUMI_F9);
3563 	if (retval < 0)
3564 		return retval;
3565 
3566 	/* alloc mbuf and set payload */
3567 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3568 
3569 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3570 	rte_pktmbuf_tailroom(ut_params->ibuf));
3571 
3572 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3573 	/* Append data which is padded to a multiple of */
3574 	/* the algorithms block size */
3575 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3576 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3577 				plaintext_pad_len);
3578 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3579 
3580 	/* Create KASUMI operation */
3581 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3582 			NULL, 0,
3583 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3584 			tdata->plaintext.len,
3585 			0);
3586 	if (retval < 0)
3587 		return retval;
3588 
3589 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3590 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3591 			ut_params->op);
3592 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3593 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3594 					       0);
3595 		if (retval != TEST_SUCCESS)
3596 			return retval;
3597 	} else
3598 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3599 			ut_params->op);
3600 
3601 	ut_params->obuf = ut_params->op->sym->m_src;
3602 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3603 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3604 						    uint8_t *,
3605 						    plaintext_pad_len);
3606 
3607 	/* Validate obuf */
3608 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3609 	ut_params->digest,
3610 	tdata->digest.data,
3611 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3612 	"KASUMI Generated auth tag not as expected");
3613 
3614 	return 0;
3615 }
3616 
3617 static int
3618 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3619 {
3620 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3621 	struct crypto_unittest_params *ut_params = &unittest_params;
3622 
3623 	int retval;
3624 	unsigned plaintext_pad_len;
3625 	unsigned plaintext_len;
3626 	uint8_t *plaintext;
3627 	struct rte_cryptodev_info dev_info;
3628 
3629 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3630 	uint64_t feat_flags = dev_info.feature_flags;
3631 
3632 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3633 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3634 		printf("Device doesn't support RAW data-path APIs.\n");
3635 		return TEST_SKIPPED;
3636 	}
3637 
3638 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3639 		return TEST_SKIPPED;
3640 
3641 	/* Verify the capabilities */
3642 	struct rte_cryptodev_sym_capability_idx cap_idx;
3643 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3644 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3645 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3646 			&cap_idx) == NULL)
3647 		return TEST_SKIPPED;
3648 
3649 	/* Create KASUMI session */
3650 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3651 				tdata->key.data, tdata->key.len,
3652 				0, tdata->digest.len,
3653 				RTE_CRYPTO_AUTH_OP_VERIFY,
3654 				RTE_CRYPTO_AUTH_KASUMI_F9);
3655 	if (retval < 0)
3656 		return retval;
3657 	/* alloc mbuf and set payload */
3658 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3659 
3660 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3661 	rte_pktmbuf_tailroom(ut_params->ibuf));
3662 
3663 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3664 	/* Append data which is padded to a multiple */
3665 	/* of the algorithms block size */
3666 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3667 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3668 				plaintext_pad_len);
3669 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3670 
3671 	/* Create KASUMI operation */
3672 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3673 			tdata->digest.len,
3674 			NULL, 0,
3675 			plaintext_pad_len,
3676 			RTE_CRYPTO_AUTH_OP_VERIFY,
3677 			tdata->plaintext.len,
3678 			0);
3679 	if (retval < 0)
3680 		return retval;
3681 
3682 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3683 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3684 					       0);
3685 		if (retval != TEST_SUCCESS)
3686 			return retval;
3687 	} else
3688 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3689 				ut_params->op);
3690 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3691 	ut_params->obuf = ut_params->op->sym->m_src;
3692 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3693 						    uint8_t *,
3694 						    plaintext_pad_len);
3695 
3696 	/* Validate obuf */
3697 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3698 		return 0;
3699 	else
3700 		return -1;
3701 
3702 	return 0;
3703 }
3704 
3705 static int
3706 test_snow3g_hash_generate_test_case_1(void)
3707 {
3708 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3709 }
3710 
3711 static int
3712 test_snow3g_hash_generate_test_case_2(void)
3713 {
3714 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3715 }
3716 
3717 static int
3718 test_snow3g_hash_generate_test_case_3(void)
3719 {
3720 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3721 }
3722 
3723 static int
3724 test_snow3g_hash_generate_test_case_4(void)
3725 {
3726 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3727 }
3728 
3729 static int
3730 test_snow3g_hash_generate_test_case_5(void)
3731 {
3732 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3733 }
3734 
3735 static int
3736 test_snow3g_hash_generate_test_case_6(void)
3737 {
3738 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3739 }
3740 
3741 static int
3742 test_snow3g_hash_verify_test_case_1(void)
3743 {
3744 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3745 
3746 }
3747 
3748 static int
3749 test_snow3g_hash_verify_test_case_2(void)
3750 {
3751 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3752 }
3753 
3754 static int
3755 test_snow3g_hash_verify_test_case_3(void)
3756 {
3757 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3758 }
3759 
3760 static int
3761 test_snow3g_hash_verify_test_case_4(void)
3762 {
3763 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3764 }
3765 
3766 static int
3767 test_snow3g_hash_verify_test_case_5(void)
3768 {
3769 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3770 }
3771 
3772 static int
3773 test_snow3g_hash_verify_test_case_6(void)
3774 {
3775 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3776 }
3777 
3778 static int
3779 test_kasumi_hash_generate_test_case_1(void)
3780 {
3781 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3782 }
3783 
3784 static int
3785 test_kasumi_hash_generate_test_case_2(void)
3786 {
3787 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3788 }
3789 
3790 static int
3791 test_kasumi_hash_generate_test_case_3(void)
3792 {
3793 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3794 }
3795 
3796 static int
3797 test_kasumi_hash_generate_test_case_4(void)
3798 {
3799 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3800 }
3801 
3802 static int
3803 test_kasumi_hash_generate_test_case_5(void)
3804 {
3805 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3806 }
3807 
3808 static int
3809 test_kasumi_hash_generate_test_case_6(void)
3810 {
3811 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3812 }
3813 
3814 static int
3815 test_kasumi_hash_verify_test_case_1(void)
3816 {
3817 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3818 }
3819 
3820 static int
3821 test_kasumi_hash_verify_test_case_2(void)
3822 {
3823 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3824 }
3825 
3826 static int
3827 test_kasumi_hash_verify_test_case_3(void)
3828 {
3829 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3830 }
3831 
3832 static int
3833 test_kasumi_hash_verify_test_case_4(void)
3834 {
3835 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3836 }
3837 
3838 static int
3839 test_kasumi_hash_verify_test_case_5(void)
3840 {
3841 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3842 }
3843 
3844 static int
3845 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3846 {
3847 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3848 	struct crypto_unittest_params *ut_params = &unittest_params;
3849 
3850 	int retval;
3851 	uint8_t *plaintext, *ciphertext;
3852 	unsigned plaintext_pad_len;
3853 	unsigned plaintext_len;
3854 	struct rte_cryptodev_info dev_info;
3855 
3856 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3857 	uint64_t feat_flags = dev_info.feature_flags;
3858 
3859 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3860 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3861 		printf("Device doesn't support RAW data-path APIs.\n");
3862 		return TEST_SKIPPED;
3863 	}
3864 
3865 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3866 		return TEST_SKIPPED;
3867 
3868 	/* Verify the capabilities */
3869 	struct rte_cryptodev_sym_capability_idx cap_idx;
3870 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3871 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3872 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3873 			&cap_idx) == NULL)
3874 		return TEST_SKIPPED;
3875 
3876 	/* Create KASUMI session */
3877 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3878 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3879 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3880 					tdata->key.data, tdata->key.len,
3881 					tdata->cipher_iv.len);
3882 	if (retval < 0)
3883 		return retval;
3884 
3885 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3886 
3887 	/* Clear mbuf payload */
3888 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3889 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3890 
3891 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3892 	/* Append data which is padded to a multiple */
3893 	/* of the algorithms block size */
3894 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3895 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3896 				plaintext_pad_len);
3897 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3898 
3899 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3900 
3901 	/* Create KASUMI operation */
3902 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3903 				tdata->cipher_iv.len,
3904 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3905 				tdata->validCipherOffsetInBits.len);
3906 	if (retval < 0)
3907 		return retval;
3908 
3909 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3910 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3911 					       tdata->cipher_iv.len);
3912 		if (retval != TEST_SUCCESS)
3913 			return retval;
3914 	} else
3915 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3916 				ut_params->op);
3917 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3918 
3919 	ut_params->obuf = ut_params->op->sym->m_dst;
3920 	if (ut_params->obuf)
3921 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3922 	else
3923 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3924 
3925 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3926 
3927 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3928 				(tdata->validCipherOffsetInBits.len >> 3);
3929 	/* Validate obuf */
3930 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3931 		ciphertext,
3932 		reference_ciphertext,
3933 		tdata->validCipherLenInBits.len,
3934 		"KASUMI Ciphertext data not as expected");
3935 	return 0;
3936 }
3937 
3938 static int
3939 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3940 {
3941 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3942 	struct crypto_unittest_params *ut_params = &unittest_params;
3943 
3944 	int retval;
3945 
3946 	unsigned int plaintext_pad_len;
3947 	unsigned int plaintext_len;
3948 
3949 	uint8_t buffer[10000];
3950 	const uint8_t *ciphertext;
3951 
3952 	struct rte_cryptodev_info dev_info;
3953 
3954 	/* Verify the capabilities */
3955 	struct rte_cryptodev_sym_capability_idx cap_idx;
3956 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3957 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3958 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3959 			&cap_idx) == NULL)
3960 		return TEST_SKIPPED;
3961 
3962 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3963 
3964 	uint64_t feat_flags = dev_info.feature_flags;
3965 
3966 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3967 		printf("Device doesn't support in-place scatter-gather. "
3968 				"Test Skipped.\n");
3969 		return TEST_SKIPPED;
3970 	}
3971 
3972 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3973 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3974 		printf("Device doesn't support RAW data-path APIs.\n");
3975 		return TEST_SKIPPED;
3976 	}
3977 
3978 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3979 		return TEST_SKIPPED;
3980 
3981 	/* Create KASUMI session */
3982 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3983 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3984 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3985 					tdata->key.data, tdata->key.len,
3986 					tdata->cipher_iv.len);
3987 	if (retval < 0)
3988 		return retval;
3989 
3990 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3991 
3992 
3993 	/* Append data which is padded to a multiple */
3994 	/* of the algorithms block size */
3995 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3996 
3997 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3998 			plaintext_pad_len, 10, 0);
3999 
4000 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4001 
4002 	/* Create KASUMI operation */
4003 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4004 				tdata->cipher_iv.len,
4005 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4006 				tdata->validCipherOffsetInBits.len);
4007 	if (retval < 0)
4008 		return retval;
4009 
4010 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4011 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4012 					       tdata->cipher_iv.len);
4013 		if (retval != TEST_SUCCESS)
4014 			return retval;
4015 	} else
4016 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4017 						ut_params->op);
4018 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4019 
4020 	ut_params->obuf = ut_params->op->sym->m_dst;
4021 
4022 	if (ut_params->obuf)
4023 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4024 				plaintext_len, buffer);
4025 	else
4026 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4027 				tdata->validCipherOffsetInBits.len >> 3,
4028 				plaintext_len, buffer);
4029 
4030 	/* Validate obuf */
4031 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4032 
4033 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4034 				(tdata->validCipherOffsetInBits.len >> 3);
4035 	/* Validate obuf */
4036 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4037 		ciphertext,
4038 		reference_ciphertext,
4039 		tdata->validCipherLenInBits.len,
4040 		"KASUMI Ciphertext data not as expected");
4041 	return 0;
4042 }
4043 
4044 static int
4045 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4046 {
4047 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4048 	struct crypto_unittest_params *ut_params = &unittest_params;
4049 
4050 	int retval;
4051 	uint8_t *plaintext, *ciphertext;
4052 	unsigned plaintext_pad_len;
4053 	unsigned plaintext_len;
4054 
4055 	/* Verify the capabilities */
4056 	struct rte_cryptodev_sym_capability_idx cap_idx;
4057 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4058 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4059 	/* Data-path service does not support OOP */
4060 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4061 			&cap_idx) == NULL)
4062 		return TEST_SKIPPED;
4063 
4064 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4065 		return TEST_SKIPPED;
4066 
4067 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4068 		return TEST_SKIPPED;
4069 
4070 	/* Create KASUMI session */
4071 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4072 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4073 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4074 					tdata->key.data, tdata->key.len,
4075 					tdata->cipher_iv.len);
4076 	if (retval < 0)
4077 		return retval;
4078 
4079 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4080 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4081 
4082 	/* Clear mbuf payload */
4083 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4084 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4085 
4086 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4087 	/* Append data which is padded to a multiple */
4088 	/* of the algorithms block size */
4089 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4090 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4091 				plaintext_pad_len);
4092 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4094 
4095 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4096 
4097 	/* Create KASUMI operation */
4098 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4099 				tdata->cipher_iv.len,
4100 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4101 				tdata->validCipherOffsetInBits.len);
4102 	if (retval < 0)
4103 		return retval;
4104 
4105 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4106 						ut_params->op);
4107 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4108 
4109 	ut_params->obuf = ut_params->op->sym->m_dst;
4110 	if (ut_params->obuf)
4111 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4112 	else
4113 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4114 
4115 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4116 
4117 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4118 				(tdata->validCipherOffsetInBits.len >> 3);
4119 	/* Validate obuf */
4120 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4121 		ciphertext,
4122 		reference_ciphertext,
4123 		tdata->validCipherLenInBits.len,
4124 		"KASUMI Ciphertext data not as expected");
4125 	return 0;
4126 }
4127 
4128 static int
4129 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4130 {
4131 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4132 	struct crypto_unittest_params *ut_params = &unittest_params;
4133 
4134 	int retval;
4135 	unsigned int plaintext_pad_len;
4136 	unsigned int plaintext_len;
4137 
4138 	const uint8_t *ciphertext;
4139 	uint8_t buffer[2048];
4140 
4141 	struct rte_cryptodev_info dev_info;
4142 
4143 	/* Verify the capabilities */
4144 	struct rte_cryptodev_sym_capability_idx cap_idx;
4145 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4146 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4147 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4148 			&cap_idx) == NULL)
4149 		return TEST_SKIPPED;
4150 
4151 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4152 		return TEST_SKIPPED;
4153 
4154 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4155 		return TEST_SKIPPED;
4156 
4157 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4158 
4159 	uint64_t feat_flags = dev_info.feature_flags;
4160 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4161 		printf("Device doesn't support out-of-place scatter-gather "
4162 				"in both input and output mbufs. "
4163 				"Test Skipped.\n");
4164 		return TEST_SKIPPED;
4165 	}
4166 
4167 	/* Create KASUMI session */
4168 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4169 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4170 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4171 					tdata->key.data, tdata->key.len,
4172 					tdata->cipher_iv.len);
4173 	if (retval < 0)
4174 		return retval;
4175 
4176 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4177 	/* Append data which is padded to a multiple */
4178 	/* of the algorithms block size */
4179 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4180 
4181 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4182 			plaintext_pad_len, 10, 0);
4183 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4184 			plaintext_pad_len, 3, 0);
4185 
4186 	/* Append data which is padded to a multiple */
4187 	/* of the algorithms block size */
4188 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4189 
4190 	/* Create KASUMI operation */
4191 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4192 				tdata->cipher_iv.len,
4193 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4194 				tdata->validCipherOffsetInBits.len);
4195 	if (retval < 0)
4196 		return retval;
4197 
4198 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4199 						ut_params->op);
4200 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4201 
4202 	ut_params->obuf = ut_params->op->sym->m_dst;
4203 	if (ut_params->obuf)
4204 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4205 				plaintext_pad_len, buffer);
4206 	else
4207 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4208 				tdata->validCipherOffsetInBits.len >> 3,
4209 				plaintext_pad_len, buffer);
4210 
4211 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4212 				(tdata->validCipherOffsetInBits.len >> 3);
4213 	/* Validate obuf */
4214 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4215 		ciphertext,
4216 		reference_ciphertext,
4217 		tdata->validCipherLenInBits.len,
4218 		"KASUMI Ciphertext data not as expected");
4219 	return 0;
4220 }
4221 
4222 
4223 static int
4224 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4225 {
4226 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4227 	struct crypto_unittest_params *ut_params = &unittest_params;
4228 
4229 	int retval;
4230 	uint8_t *ciphertext, *plaintext;
4231 	unsigned ciphertext_pad_len;
4232 	unsigned ciphertext_len;
4233 
4234 	/* Verify the capabilities */
4235 	struct rte_cryptodev_sym_capability_idx cap_idx;
4236 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4237 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4238 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4239 			&cap_idx) == NULL)
4240 		return TEST_SKIPPED;
4241 
4242 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4243 		return TEST_SKIPPED;
4244 
4245 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4246 		return TEST_SKIPPED;
4247 
4248 	/* Create KASUMI session */
4249 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4250 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4251 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4252 					tdata->key.data, tdata->key.len,
4253 					tdata->cipher_iv.len);
4254 	if (retval < 0)
4255 		return retval;
4256 
4257 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4258 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4259 
4260 	/* Clear mbuf payload */
4261 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4262 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4263 
4264 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4265 	/* Append data which is padded to a multiple */
4266 	/* of the algorithms block size */
4267 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4268 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4269 				ciphertext_pad_len);
4270 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4271 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4272 
4273 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4274 
4275 	/* Create KASUMI operation */
4276 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4277 				tdata->cipher_iv.len,
4278 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4279 				tdata->validCipherOffsetInBits.len);
4280 	if (retval < 0)
4281 		return retval;
4282 
4283 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4284 						ut_params->op);
4285 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4286 
4287 	ut_params->obuf = ut_params->op->sym->m_dst;
4288 	if (ut_params->obuf)
4289 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4290 	else
4291 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4292 
4293 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4294 
4295 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4296 				(tdata->validCipherOffsetInBits.len >> 3);
4297 	/* Validate obuf */
4298 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4299 		plaintext,
4300 		reference_plaintext,
4301 		tdata->validCipherLenInBits.len,
4302 		"KASUMI Plaintext data not as expected");
4303 	return 0;
4304 }
4305 
4306 static int
4307 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4308 {
4309 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4310 	struct crypto_unittest_params *ut_params = &unittest_params;
4311 
4312 	int retval;
4313 	uint8_t *ciphertext, *plaintext;
4314 	unsigned ciphertext_pad_len;
4315 	unsigned ciphertext_len;
4316 	struct rte_cryptodev_info dev_info;
4317 
4318 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4319 	uint64_t feat_flags = dev_info.feature_flags;
4320 
4321 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4322 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4323 		printf("Device doesn't support RAW data-path APIs.\n");
4324 		return TEST_SKIPPED;
4325 	}
4326 
4327 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4328 		return TEST_SKIPPED;
4329 
4330 	/* Verify the capabilities */
4331 	struct rte_cryptodev_sym_capability_idx cap_idx;
4332 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4333 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4334 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4335 			&cap_idx) == NULL)
4336 		return TEST_SKIPPED;
4337 
4338 	/* Create KASUMI session */
4339 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4340 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4341 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4342 					tdata->key.data, tdata->key.len,
4343 					tdata->cipher_iv.len);
4344 	if (retval < 0)
4345 		return retval;
4346 
4347 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4348 
4349 	/* Clear mbuf payload */
4350 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4351 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4352 
4353 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4354 	/* Append data which is padded to a multiple */
4355 	/* of the algorithms block size */
4356 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4357 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4358 				ciphertext_pad_len);
4359 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4360 
4361 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4362 
4363 	/* Create KASUMI operation */
4364 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4365 			tdata->cipher_iv.len,
4366 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4367 			tdata->validCipherOffsetInBits.len);
4368 	if (retval < 0)
4369 		return retval;
4370 
4371 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4372 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4373 					       0);
4374 		if (retval != TEST_SUCCESS)
4375 			return retval;
4376 	} else
4377 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4378 						ut_params->op);
4379 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4380 
4381 	ut_params->obuf = ut_params->op->sym->m_dst;
4382 	if (ut_params->obuf)
4383 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4384 	else
4385 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4386 
4387 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4388 
4389 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4390 				(tdata->validCipherOffsetInBits.len >> 3);
4391 	/* Validate obuf */
4392 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4393 		plaintext,
4394 		reference_plaintext,
4395 		tdata->validCipherLenInBits.len,
4396 		"KASUMI Plaintext data not as expected");
4397 	return 0;
4398 }
4399 
4400 static int
4401 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4402 {
4403 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4404 	struct crypto_unittest_params *ut_params = &unittest_params;
4405 
4406 	int retval;
4407 	uint8_t *plaintext, *ciphertext;
4408 	unsigned plaintext_pad_len;
4409 	unsigned plaintext_len;
4410 	struct rte_cryptodev_info dev_info;
4411 
4412 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4413 	uint64_t feat_flags = dev_info.feature_flags;
4414 
4415 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4416 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4417 		printf("Device doesn't support RAW data-path APIs.\n");
4418 		return TEST_SKIPPED;
4419 	}
4420 
4421 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4422 		return TEST_SKIPPED;
4423 
4424 	/* Verify the capabilities */
4425 	struct rte_cryptodev_sym_capability_idx cap_idx;
4426 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4427 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4428 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4429 			&cap_idx) == NULL)
4430 		return TEST_SKIPPED;
4431 
4432 	/* Create SNOW 3G session */
4433 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4434 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4435 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4436 					tdata->key.data, tdata->key.len,
4437 					tdata->cipher_iv.len);
4438 	if (retval < 0)
4439 		return retval;
4440 
4441 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4442 
4443 	/* Clear mbuf payload */
4444 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4445 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4446 
4447 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4448 	/* Append data which is padded to a multiple of */
4449 	/* the algorithms block size */
4450 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4451 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4452 				plaintext_pad_len);
4453 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4454 
4455 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4456 
4457 	/* Create SNOW 3G operation */
4458 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4459 					tdata->cipher_iv.len,
4460 					tdata->validCipherLenInBits.len,
4461 					0);
4462 	if (retval < 0)
4463 		return retval;
4464 
4465 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4466 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4467 					       tdata->cipher_iv.len);
4468 		if (retval != TEST_SUCCESS)
4469 			return retval;
4470 	} else
4471 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4472 						ut_params->op);
4473 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4474 
4475 	ut_params->obuf = ut_params->op->sym->m_dst;
4476 	if (ut_params->obuf)
4477 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4478 	else
4479 		ciphertext = plaintext;
4480 
4481 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4482 
4483 	/* Validate obuf */
4484 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4485 		ciphertext,
4486 		tdata->ciphertext.data,
4487 		tdata->validDataLenInBits.len,
4488 		"SNOW 3G Ciphertext data not as expected");
4489 	return 0;
4490 }
4491 
4492 
4493 static int
4494 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4495 {
4496 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4497 	struct crypto_unittest_params *ut_params = &unittest_params;
4498 	uint8_t *plaintext, *ciphertext;
4499 
4500 	int retval;
4501 	unsigned plaintext_pad_len;
4502 	unsigned plaintext_len;
4503 	struct rte_cryptodev_info dev_info;
4504 
4505 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4506 	uint64_t feat_flags = dev_info.feature_flags;
4507 
4508 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4509 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4510 		printf("Device does not support RAW data-path APIs.\n");
4511 		return -ENOTSUP;
4512 	}
4513 
4514 	/* Verify the capabilities */
4515 	struct rte_cryptodev_sym_capability_idx cap_idx;
4516 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4517 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4518 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4519 			&cap_idx) == NULL)
4520 		return TEST_SKIPPED;
4521 
4522 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4523 		return TEST_SKIPPED;
4524 
4525 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4526 		return TEST_SKIPPED;
4527 
4528 	/* Create SNOW 3G session */
4529 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4530 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4531 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4532 					tdata->key.data, tdata->key.len,
4533 					tdata->cipher_iv.len);
4534 	if (retval < 0)
4535 		return retval;
4536 
4537 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4538 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4539 
4540 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4541 			"Failed to allocate input buffer in mempool");
4542 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4543 			"Failed to allocate output buffer in mempool");
4544 
4545 	/* Clear mbuf payload */
4546 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4547 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4548 
4549 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4550 	/* Append data which is padded to a multiple of */
4551 	/* the algorithms block size */
4552 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4553 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4554 				plaintext_pad_len);
4555 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4556 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4557 
4558 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4559 
4560 	/* Create SNOW 3G operation */
4561 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4562 					tdata->cipher_iv.len,
4563 					tdata->validCipherLenInBits.len,
4564 					0);
4565 	if (retval < 0)
4566 		return retval;
4567 
4568 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4569 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4570 					       tdata->cipher_iv.len);
4571 		if (retval != TEST_SUCCESS)
4572 			return retval;
4573 	} else
4574 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4575 						ut_params->op);
4576 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4577 
4578 	ut_params->obuf = ut_params->op->sym->m_dst;
4579 	if (ut_params->obuf)
4580 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4581 	else
4582 		ciphertext = plaintext;
4583 
4584 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4585 
4586 	/* Validate obuf */
4587 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4588 		ciphertext,
4589 		tdata->ciphertext.data,
4590 		tdata->validDataLenInBits.len,
4591 		"SNOW 3G Ciphertext data not as expected");
4592 	return 0;
4593 }
4594 
4595 static int
4596 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4597 		uint8_t sgl_in, uint8_t sgl_out)
4598 {
4599 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4600 	struct crypto_unittest_params *ut_params = &unittest_params;
4601 
4602 	int retval;
4603 	unsigned int plaintext_pad_len;
4604 	unsigned int plaintext_len;
4605 	uint8_t buffer[10000];
4606 	const uint8_t *ciphertext;
4607 
4608 	struct rte_cryptodev_info dev_info;
4609 
4610 	/* Verify the capabilities */
4611 	struct rte_cryptodev_sym_capability_idx cap_idx;
4612 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4613 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4614 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4615 			&cap_idx) == NULL)
4616 		return TEST_SKIPPED;
4617 
4618 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4619 		return TEST_SKIPPED;
4620 
4621 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4622 		return TEST_SKIPPED;
4623 
4624 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4625 
4626 	uint64_t feat_flags = dev_info.feature_flags;
4627 
4628 	if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4629 			|| ((!sgl_in && sgl_out) &&
4630 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4631 			|| ((sgl_in && !sgl_out) &&
4632 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4633 		printf("Device doesn't support out-of-place scatter gather type. "
4634 				"Test Skipped.\n");
4635 		return TEST_SKIPPED;
4636 	}
4637 
4638 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4639 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4640 		printf("Device does not support RAW data-path APIs.\n");
4641 		return -ENOTSUP;
4642 	}
4643 
4644 	/* Create SNOW 3G session */
4645 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4646 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4647 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4648 					tdata->key.data, tdata->key.len,
4649 					tdata->cipher_iv.len);
4650 	if (retval < 0)
4651 		return retval;
4652 
4653 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4654 	/* Append data which is padded to a multiple of */
4655 	/* the algorithms block size */
4656 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4657 
4658 	if (sgl_in)
4659 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4660 				plaintext_pad_len, 10, 0);
4661 	else {
4662 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4663 		rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4664 	}
4665 
4666 	if (sgl_out)
4667 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4668 				plaintext_pad_len, 3, 0);
4669 	else {
4670 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4671 		rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4672 	}
4673 
4674 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4675 			"Failed to allocate input buffer in mempool");
4676 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4677 			"Failed to allocate output buffer in mempool");
4678 
4679 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4680 
4681 	/* Create SNOW 3G operation */
4682 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4683 					tdata->cipher_iv.len,
4684 					tdata->validCipherLenInBits.len,
4685 					0);
4686 	if (retval < 0)
4687 		return retval;
4688 
4689 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4690 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4691 					       tdata->cipher_iv.len);
4692 		if (retval != TEST_SUCCESS)
4693 			return retval;
4694 	} else
4695 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4696 						ut_params->op);
4697 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4698 
4699 	ut_params->obuf = ut_params->op->sym->m_dst;
4700 	if (ut_params->obuf)
4701 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4702 				plaintext_len, buffer);
4703 	else
4704 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4705 				plaintext_len, buffer);
4706 
4707 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4708 
4709 	/* Validate obuf */
4710 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4711 		ciphertext,
4712 		tdata->ciphertext.data,
4713 		tdata->validDataLenInBits.len,
4714 		"SNOW 3G Ciphertext data not as expected");
4715 
4716 	return 0;
4717 }
4718 
4719 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4720 static void
4721 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4722 {
4723 	uint8_t curr_byte, prev_byte;
4724 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4725 	uint8_t lower_byte_mask = (1 << offset) - 1;
4726 	unsigned i;
4727 
4728 	prev_byte = buffer[0];
4729 	buffer[0] >>= offset;
4730 
4731 	for (i = 1; i < length_in_bytes; i++) {
4732 		curr_byte = buffer[i];
4733 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4734 				(curr_byte >> offset);
4735 		prev_byte = curr_byte;
4736 	}
4737 }
4738 
4739 static int
4740 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4741 {
4742 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 	struct crypto_unittest_params *ut_params = &unittest_params;
4744 	uint8_t *plaintext, *ciphertext;
4745 	int retval;
4746 	uint32_t plaintext_len;
4747 	uint32_t plaintext_pad_len;
4748 	uint8_t extra_offset = 4;
4749 	uint8_t *expected_ciphertext_shifted;
4750 	struct rte_cryptodev_info dev_info;
4751 
4752 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4753 	uint64_t feat_flags = dev_info.feature_flags;
4754 
4755 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4756 			((tdata->validDataLenInBits.len % 8) != 0)) {
4757 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4758 		return TEST_SKIPPED;
4759 	}
4760 
4761 	/* Verify the capabilities */
4762 	struct rte_cryptodev_sym_capability_idx cap_idx;
4763 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4764 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4765 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4766 			&cap_idx) == NULL)
4767 		return TEST_SKIPPED;
4768 
4769 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4770 		return TEST_SKIPPED;
4771 
4772 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4773 		return TEST_SKIPPED;
4774 
4775 	/* Create SNOW 3G session */
4776 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4777 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4778 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4779 					tdata->key.data, tdata->key.len,
4780 					tdata->cipher_iv.len);
4781 	if (retval < 0)
4782 		return retval;
4783 
4784 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4785 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4786 
4787 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4788 			"Failed to allocate input buffer in mempool");
4789 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4790 			"Failed to allocate output buffer in mempool");
4791 
4792 	/* Clear mbuf payload */
4793 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4794 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4795 
4796 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4797 	/*
4798 	 * Append data which is padded to a
4799 	 * multiple of the algorithms block size
4800 	 */
4801 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4802 
4803 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4804 						plaintext_pad_len);
4805 
4806 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4807 
4808 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4809 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4810 
4811 #ifdef RTE_APP_TEST_DEBUG
4812 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4813 #endif
4814 	/* Create SNOW 3G operation */
4815 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4816 					tdata->cipher_iv.len,
4817 					tdata->validCipherLenInBits.len,
4818 					extra_offset);
4819 	if (retval < 0)
4820 		return retval;
4821 
4822 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4823 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4824 					       tdata->cipher_iv.len);
4825 		if (retval != TEST_SUCCESS)
4826 			return retval;
4827 	} else
4828 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4829 						ut_params->op);
4830 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4831 
4832 	ut_params->obuf = ut_params->op->sym->m_dst;
4833 	if (ut_params->obuf)
4834 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4835 	else
4836 		ciphertext = plaintext;
4837 
4838 #ifdef RTE_APP_TEST_DEBUG
4839 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4840 #endif
4841 
4842 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4843 
4844 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4845 			"failed to reserve memory for ciphertext shifted\n");
4846 
4847 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4848 			ceil_byte_length(tdata->ciphertext.len));
4849 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4850 			extra_offset);
4851 	/* Validate obuf */
4852 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4853 		ciphertext,
4854 		expected_ciphertext_shifted,
4855 		tdata->validDataLenInBits.len,
4856 		extra_offset,
4857 		"SNOW 3G Ciphertext data not as expected");
4858 	return 0;
4859 }
4860 
4861 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4862 {
4863 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4864 	struct crypto_unittest_params *ut_params = &unittest_params;
4865 
4866 	int retval;
4867 
4868 	uint8_t *plaintext, *ciphertext;
4869 	unsigned ciphertext_pad_len;
4870 	unsigned ciphertext_len;
4871 	struct rte_cryptodev_info dev_info;
4872 
4873 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4874 	uint64_t feat_flags = dev_info.feature_flags;
4875 
4876 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4877 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4878 		printf("Device doesn't support RAW data-path APIs.\n");
4879 		return TEST_SKIPPED;
4880 	}
4881 
4882 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4883 		return TEST_SKIPPED;
4884 
4885 	/* Verify the capabilities */
4886 	struct rte_cryptodev_sym_capability_idx cap_idx;
4887 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4888 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4889 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4890 			&cap_idx) == NULL)
4891 		return TEST_SKIPPED;
4892 
4893 	/* Create SNOW 3G session */
4894 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4895 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4896 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4897 					tdata->key.data, tdata->key.len,
4898 					tdata->cipher_iv.len);
4899 	if (retval < 0)
4900 		return retval;
4901 
4902 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4903 
4904 	/* Clear mbuf payload */
4905 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4906 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4907 
4908 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4909 	/* Append data which is padded to a multiple of */
4910 	/* the algorithms block size */
4911 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4912 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4913 				ciphertext_pad_len);
4914 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4915 
4916 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4917 
4918 	/* Create SNOW 3G operation */
4919 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4920 					tdata->cipher_iv.len,
4921 					tdata->validCipherLenInBits.len,
4922 					tdata->cipher.offset_bits);
4923 	if (retval < 0)
4924 		return retval;
4925 
4926 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4927 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4928 					       tdata->cipher_iv.len);
4929 		if (retval != TEST_SUCCESS)
4930 			return retval;
4931 	} else
4932 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4933 						ut_params->op);
4934 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4935 	ut_params->obuf = ut_params->op->sym->m_dst;
4936 	if (ut_params->obuf)
4937 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4938 	else
4939 		plaintext = ciphertext;
4940 
4941 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4942 
4943 	/* Validate obuf */
4944 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4945 				tdata->plaintext.data,
4946 				tdata->validDataLenInBits.len,
4947 				"SNOW 3G Plaintext data not as expected");
4948 	return 0;
4949 }
4950 
4951 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4952 {
4953 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4954 	struct crypto_unittest_params *ut_params = &unittest_params;
4955 
4956 	int retval;
4957 
4958 	uint8_t *plaintext, *ciphertext;
4959 	unsigned ciphertext_pad_len;
4960 	unsigned ciphertext_len;
4961 	struct rte_cryptodev_info dev_info;
4962 
4963 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4964 	uint64_t feat_flags = dev_info.feature_flags;
4965 
4966 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4967 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4968 		printf("Device does not support RAW data-path APIs.\n");
4969 		return -ENOTSUP;
4970 	}
4971 	/* Verify the capabilities */
4972 	struct rte_cryptodev_sym_capability_idx cap_idx;
4973 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4974 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4975 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4976 			&cap_idx) == NULL)
4977 		return TEST_SKIPPED;
4978 
4979 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4980 		return TEST_SKIPPED;
4981 
4982 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4983 		return TEST_SKIPPED;
4984 
4985 	/* Create SNOW 3G session */
4986 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4987 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4988 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4989 					tdata->key.data, tdata->key.len,
4990 					tdata->cipher_iv.len);
4991 	if (retval < 0)
4992 		return retval;
4993 
4994 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4995 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4996 
4997 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4998 			"Failed to allocate input buffer");
4999 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
5000 			"Failed to allocate output buffer");
5001 
5002 	/* Clear mbuf payload */
5003 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5004 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5005 
5006 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5007 		       rte_pktmbuf_tailroom(ut_params->obuf));
5008 
5009 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5010 	/* Append data which is padded to a multiple of */
5011 	/* the algorithms block size */
5012 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5013 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5014 				ciphertext_pad_len);
5015 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5016 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5017 
5018 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5019 
5020 	/* Create SNOW 3G operation */
5021 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5022 					tdata->cipher_iv.len,
5023 					tdata->validCipherLenInBits.len,
5024 					0);
5025 	if (retval < 0)
5026 		return retval;
5027 
5028 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5029 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5030 					       tdata->cipher_iv.len);
5031 		if (retval != TEST_SUCCESS)
5032 			return retval;
5033 	} else
5034 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5035 						ut_params->op);
5036 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5037 	ut_params->obuf = ut_params->op->sym->m_dst;
5038 	if (ut_params->obuf)
5039 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5040 	else
5041 		plaintext = ciphertext;
5042 
5043 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5044 
5045 	/* Validate obuf */
5046 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5047 				tdata->plaintext.data,
5048 				tdata->validDataLenInBits.len,
5049 				"SNOW 3G Plaintext data not as expected");
5050 	return 0;
5051 }
5052 
5053 static int
5054 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5055 {
5056 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5057 	struct crypto_unittest_params *ut_params = &unittest_params;
5058 
5059 	int retval;
5060 
5061 	uint8_t *plaintext, *ciphertext;
5062 	unsigned int plaintext_pad_len;
5063 	unsigned int plaintext_len;
5064 
5065 	struct rte_cryptodev_info dev_info;
5066 
5067 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5068 	uint64_t feat_flags = dev_info.feature_flags;
5069 
5070 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5071 			((tdata->validAuthLenInBits.len % 8 != 0) ||
5072 			(tdata->validDataLenInBits.len % 8 != 0))) {
5073 		printf("Device doesn't support NON-Byte Aligned Data.\n");
5074 		return TEST_SKIPPED;
5075 	}
5076 
5077 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5078 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5079 		printf("Device doesn't support RAW data-path APIs.\n");
5080 		return TEST_SKIPPED;
5081 	}
5082 
5083 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5084 		return TEST_SKIPPED;
5085 
5086 	/* Check if device supports ZUC EEA3 */
5087 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5088 			tdata->key.len, tdata->cipher_iv.len) < 0)
5089 		return TEST_SKIPPED;
5090 
5091 	/* Check if device supports ZUC EIA3 */
5092 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5093 			tdata->key.len, tdata->auth_iv.len,
5094 			tdata->digest.len) < 0)
5095 		return TEST_SKIPPED;
5096 
5097 	/* Create ZUC session */
5098 	retval = create_zuc_cipher_auth_encrypt_generate_session(
5099 			ts_params->valid_devs[0],
5100 			tdata);
5101 	if (retval != 0)
5102 		return retval;
5103 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5104 
5105 	/* clear mbuf payload */
5106 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5107 			rte_pktmbuf_tailroom(ut_params->ibuf));
5108 
5109 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5110 	/* Append data which is padded to a multiple of */
5111 	/* the algorithms block size */
5112 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5113 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5114 				plaintext_pad_len);
5115 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5116 
5117 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5118 
5119 	/* Create ZUC operation */
5120 	retval = create_zuc_cipher_hash_generate_operation(tdata);
5121 	if (retval < 0)
5122 		return retval;
5123 
5124 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5125 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5126 					       tdata->cipher_iv.len);
5127 		if (retval != TEST_SUCCESS)
5128 			return retval;
5129 	} else
5130 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5131 			ut_params->op);
5132 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5133 	ut_params->obuf = ut_params->op->sym->m_src;
5134 	if (ut_params->obuf)
5135 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5136 	else
5137 		ciphertext = plaintext;
5138 
5139 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5140 	/* Validate obuf */
5141 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5142 			ciphertext,
5143 			tdata->ciphertext.data,
5144 			tdata->validDataLenInBits.len,
5145 			"ZUC Ciphertext data not as expected");
5146 
5147 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5148 						    uint8_t *,
5149 						    plaintext_pad_len);
5150 
5151 	/* Validate obuf */
5152 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5153 			ut_params->digest,
5154 			tdata->digest.data,
5155 			tdata->digest.len,
5156 			"ZUC Generated auth tag not as expected");
5157 	return 0;
5158 }
5159 
5160 static int
5161 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5162 {
5163 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5164 	struct crypto_unittest_params *ut_params = &unittest_params;
5165 
5166 	int retval;
5167 
5168 	uint8_t *plaintext, *ciphertext;
5169 	unsigned plaintext_pad_len;
5170 	unsigned plaintext_len;
5171 	struct rte_cryptodev_info dev_info;
5172 
5173 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5174 	uint64_t feat_flags = dev_info.feature_flags;
5175 
5176 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5177 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5178 		printf("Device doesn't support RAW data-path APIs.\n");
5179 		return TEST_SKIPPED;
5180 	}
5181 
5182 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5183 		return TEST_SKIPPED;
5184 
5185 	/* Verify the capabilities */
5186 	struct rte_cryptodev_sym_capability_idx cap_idx;
5187 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5188 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5189 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5190 			&cap_idx) == NULL)
5191 		return TEST_SKIPPED;
5192 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5193 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5194 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5195 			&cap_idx) == NULL)
5196 		return TEST_SKIPPED;
5197 
5198 	/* Create SNOW 3G session */
5199 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5200 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5201 			RTE_CRYPTO_AUTH_OP_GENERATE,
5202 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5203 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5204 			tdata->key.data, tdata->key.len,
5205 			tdata->key.data, tdata->key.len,
5206 			tdata->auth_iv.len, tdata->digest.len,
5207 			tdata->cipher_iv.len);
5208 	if (retval != 0)
5209 		return retval;
5210 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5211 
5212 	/* clear mbuf payload */
5213 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5214 			rte_pktmbuf_tailroom(ut_params->ibuf));
5215 
5216 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5217 	/* Append data which is padded to a multiple of */
5218 	/* the algorithms block size */
5219 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5220 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5221 				plaintext_pad_len);
5222 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5223 
5224 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5225 
5226 	/* Create SNOW 3G operation */
5227 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5228 			tdata->digest.len, tdata->auth_iv.data,
5229 			tdata->auth_iv.len,
5230 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5231 			tdata->cipher_iv.data, tdata->cipher_iv.len,
5232 			tdata->validCipherLenInBits.len,
5233 			0,
5234 			tdata->validAuthLenInBits.len,
5235 			0
5236 			);
5237 	if (retval < 0)
5238 		return retval;
5239 
5240 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5241 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5242 					       tdata->cipher_iv.len);
5243 		if (retval != TEST_SUCCESS)
5244 			return retval;
5245 	} else
5246 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5247 			ut_params->op);
5248 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5249 	ut_params->obuf = ut_params->op->sym->m_src;
5250 	if (ut_params->obuf)
5251 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5252 	else
5253 		ciphertext = plaintext;
5254 
5255 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5256 	/* Validate obuf */
5257 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5258 			ciphertext,
5259 			tdata->ciphertext.data,
5260 			tdata->validDataLenInBits.len,
5261 			"SNOW 3G Ciphertext data not as expected");
5262 
5263 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5264 						    uint8_t *,
5265 						    plaintext_pad_len);
5266 
5267 	/* Validate obuf */
5268 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5269 			ut_params->digest,
5270 			tdata->digest.data,
5271 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5272 			"SNOW 3G Generated auth tag not as expected");
5273 	return 0;
5274 }
5275 
5276 static int
5277 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5278 	uint8_t op_mode, uint8_t verify)
5279 {
5280 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5281 	struct crypto_unittest_params *ut_params = &unittest_params;
5282 
5283 	int retval;
5284 
5285 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5286 	unsigned int plaintext_pad_len;
5287 	unsigned int plaintext_len;
5288 	unsigned int ciphertext_pad_len;
5289 	unsigned int ciphertext_len;
5290 	unsigned int digest_offset;
5291 
5292 	struct rte_cryptodev_info dev_info;
5293 
5294 	/* Verify the capabilities */
5295 	struct rte_cryptodev_sym_capability_idx cap_idx;
5296 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5297 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5298 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5299 			&cap_idx) == NULL)
5300 		return TEST_SKIPPED;
5301 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5302 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5303 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5304 			&cap_idx) == NULL)
5305 		return TEST_SKIPPED;
5306 
5307 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5308 		return TEST_SKIPPED;
5309 
5310 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5311 
5312 	uint64_t feat_flags = dev_info.feature_flags;
5313 
5314 	if (op_mode == OUT_OF_PLACE) {
5315 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5316 			printf("Device doesn't support digest encrypted.\n");
5317 			return TEST_SKIPPED;
5318 		}
5319 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5320 			return TEST_SKIPPED;
5321 	}
5322 
5323 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5324 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5325 		printf("Device doesn't support RAW data-path APIs.\n");
5326 		return TEST_SKIPPED;
5327 	}
5328 
5329 	/* Create SNOW 3G session */
5330 	retval = create_wireless_algo_auth_cipher_session(
5331 			ts_params->valid_devs[0],
5332 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5333 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5334 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5335 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5336 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5337 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5338 			tdata->key.data, tdata->key.len,
5339 			tdata->key.data, tdata->key.len,
5340 			tdata->auth_iv.len, tdata->digest.len,
5341 			tdata->cipher_iv.len);
5342 	if (retval != 0)
5343 		return retval;
5344 
5345 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5346 	if (op_mode == OUT_OF_PLACE)
5347 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5348 
5349 	/* clear mbuf payload */
5350 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5351 		rte_pktmbuf_tailroom(ut_params->ibuf));
5352 	if (op_mode == OUT_OF_PLACE)
5353 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5354 			rte_pktmbuf_tailroom(ut_params->obuf));
5355 
5356 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5357 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5358 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5359 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5360 
5361 	if (verify) {
5362 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5363 					ciphertext_pad_len);
5364 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5365 		if (op_mode == OUT_OF_PLACE)
5366 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5367 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5368 			ciphertext_len);
5369 	} else {
5370 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5371 					plaintext_pad_len);
5372 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5373 		if (op_mode == OUT_OF_PLACE)
5374 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5375 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5376 	}
5377 
5378 	/* Create SNOW 3G operation */
5379 	retval = create_wireless_algo_auth_cipher_operation(
5380 		tdata->digest.data, tdata->digest.len,
5381 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5382 		tdata->auth_iv.data, tdata->auth_iv.len,
5383 		(tdata->digest.offset_bytes == 0 ?
5384 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5385 			: tdata->digest.offset_bytes),
5386 		tdata->validCipherLenInBits.len,
5387 		tdata->cipher.offset_bits,
5388 		tdata->validAuthLenInBits.len,
5389 		tdata->auth.offset_bits,
5390 		op_mode, 0, verify);
5391 
5392 	if (retval < 0)
5393 		return retval;
5394 
5395 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5396 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5397 					       tdata->cipher_iv.len);
5398 		if (retval != TEST_SUCCESS)
5399 			return retval;
5400 	} else
5401 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5402 			ut_params->op);
5403 
5404 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5405 
5406 	ut_params->obuf = (op_mode == IN_PLACE ?
5407 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5408 
5409 	if (verify) {
5410 		if (ut_params->obuf)
5411 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5412 							uint8_t *);
5413 		else
5414 			plaintext = ciphertext +
5415 				(tdata->cipher.offset_bits >> 3);
5416 
5417 		debug_hexdump(stdout, "plaintext:", plaintext,
5418 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5419 		debug_hexdump(stdout, "plaintext expected:",
5420 			tdata->plaintext.data,
5421 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5422 	} else {
5423 		if (ut_params->obuf)
5424 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5425 							uint8_t *);
5426 		else
5427 			ciphertext = plaintext;
5428 
5429 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5430 			ciphertext_len);
5431 		debug_hexdump(stdout, "ciphertext expected:",
5432 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5433 
5434 		if (tdata->digest.offset_bytes == 0)
5435 			digest_offset = plaintext_pad_len;
5436 		else
5437 			digest_offset = tdata->digest.offset_bytes;
5438 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5439 						    uint8_t *, digest_offset);
5440 
5441 		debug_hexdump(stdout, "digest:", ut_params->digest,
5442 			tdata->digest.len);
5443 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5444 				tdata->digest.len);
5445 	}
5446 
5447 	/* Validate obuf */
5448 	if (verify) {
5449 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5450 			plaintext,
5451 			tdata->plaintext.data,
5452 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5453 			 (tdata->digest.len << 3)),
5454 			tdata->cipher.offset_bits,
5455 			"SNOW 3G Plaintext data not as expected");
5456 	} else {
5457 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5458 			ciphertext,
5459 			tdata->ciphertext.data,
5460 			(tdata->validDataLenInBits.len -
5461 			 tdata->cipher.offset_bits),
5462 			tdata->cipher.offset_bits,
5463 			"SNOW 3G Ciphertext data not as expected");
5464 
5465 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5466 			ut_params->digest,
5467 			tdata->digest.data,
5468 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5469 			"SNOW 3G Generated auth tag not as expected");
5470 	}
5471 	return 0;
5472 }
5473 
5474 static int
5475 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5476 	uint8_t op_mode, uint8_t verify)
5477 {
5478 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5479 	struct crypto_unittest_params *ut_params = &unittest_params;
5480 
5481 	int retval;
5482 
5483 	const uint8_t *plaintext = NULL;
5484 	const uint8_t *ciphertext = NULL;
5485 	const uint8_t *digest = NULL;
5486 	unsigned int plaintext_pad_len;
5487 	unsigned int plaintext_len;
5488 	unsigned int ciphertext_pad_len;
5489 	unsigned int ciphertext_len;
5490 	uint8_t buffer[10000];
5491 	uint8_t digest_buffer[10000];
5492 
5493 	struct rte_cryptodev_info dev_info;
5494 
5495 	/* Verify the capabilities */
5496 	struct rte_cryptodev_sym_capability_idx cap_idx;
5497 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5498 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5499 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5500 			&cap_idx) == NULL)
5501 		return TEST_SKIPPED;
5502 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5503 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5504 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5505 			&cap_idx) == NULL)
5506 		return TEST_SKIPPED;
5507 
5508 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5509 		return TEST_SKIPPED;
5510 
5511 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5512 
5513 	uint64_t feat_flags = dev_info.feature_flags;
5514 
5515 	if (op_mode == IN_PLACE) {
5516 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5517 			printf("Device doesn't support in-place scatter-gather "
5518 					"in both input and output mbufs.\n");
5519 			return TEST_SKIPPED;
5520 		}
5521 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5522 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5523 			printf("Device doesn't support RAW data-path APIs.\n");
5524 			return TEST_SKIPPED;
5525 		}
5526 	} else {
5527 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5528 			return TEST_SKIPPED;
5529 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5530 			printf("Device doesn't support out-of-place scatter-gather "
5531 					"in both input and output mbufs.\n");
5532 			return TEST_SKIPPED;
5533 		}
5534 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5535 			printf("Device doesn't support digest encrypted.\n");
5536 			return TEST_SKIPPED;
5537 		}
5538 	}
5539 
5540 	/* Create SNOW 3G session */
5541 	retval = create_wireless_algo_auth_cipher_session(
5542 			ts_params->valid_devs[0],
5543 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5544 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5545 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5546 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5547 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5548 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5549 			tdata->key.data, tdata->key.len,
5550 			tdata->key.data, tdata->key.len,
5551 			tdata->auth_iv.len, tdata->digest.len,
5552 			tdata->cipher_iv.len);
5553 
5554 	if (retval != 0)
5555 		return retval;
5556 
5557 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5558 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5559 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5560 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5561 
5562 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5563 			plaintext_pad_len, 15, 0);
5564 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5565 			"Failed to allocate input buffer in mempool");
5566 
5567 	if (op_mode == OUT_OF_PLACE) {
5568 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5569 				plaintext_pad_len, 15, 0);
5570 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5571 				"Failed to allocate output buffer in mempool");
5572 	}
5573 
5574 	if (verify) {
5575 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5576 			tdata->ciphertext.data);
5577 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5578 					ciphertext_len, buffer);
5579 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5580 			ciphertext_len);
5581 	} else {
5582 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5583 			tdata->plaintext.data);
5584 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5585 					plaintext_len, buffer);
5586 		debug_hexdump(stdout, "plaintext:", plaintext,
5587 			plaintext_len);
5588 	}
5589 	memset(buffer, 0, sizeof(buffer));
5590 
5591 	/* Create SNOW 3G operation */
5592 	retval = create_wireless_algo_auth_cipher_operation(
5593 		tdata->digest.data, tdata->digest.len,
5594 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5595 		tdata->auth_iv.data, tdata->auth_iv.len,
5596 		(tdata->digest.offset_bytes == 0 ?
5597 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5598 			: tdata->digest.offset_bytes),
5599 		tdata->validCipherLenInBits.len,
5600 		tdata->cipher.offset_bits,
5601 		tdata->validAuthLenInBits.len,
5602 		tdata->auth.offset_bits,
5603 		op_mode, 1, verify);
5604 
5605 	if (retval < 0)
5606 		return retval;
5607 
5608 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5609 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5610 					       tdata->cipher_iv.len);
5611 		if (retval != TEST_SUCCESS)
5612 			return retval;
5613 	} else
5614 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5615 			ut_params->op);
5616 
5617 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5618 
5619 	ut_params->obuf = (op_mode == IN_PLACE ?
5620 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5621 
5622 	if (verify) {
5623 		if (ut_params->obuf)
5624 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5625 					plaintext_len, buffer);
5626 		else
5627 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5628 					plaintext_len, buffer);
5629 
5630 		debug_hexdump(stdout, "plaintext:", plaintext,
5631 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5632 		debug_hexdump(stdout, "plaintext expected:",
5633 			tdata->plaintext.data,
5634 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5635 	} else {
5636 		if (ut_params->obuf)
5637 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5638 					ciphertext_len, buffer);
5639 		else
5640 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5641 					ciphertext_len, buffer);
5642 
5643 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5644 			ciphertext_len);
5645 		debug_hexdump(stdout, "ciphertext expected:",
5646 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5647 
5648 		if (ut_params->obuf)
5649 			digest = rte_pktmbuf_read(ut_params->obuf,
5650 				(tdata->digest.offset_bytes == 0 ?
5651 				plaintext_pad_len : tdata->digest.offset_bytes),
5652 				tdata->digest.len, digest_buffer);
5653 		else
5654 			digest = rte_pktmbuf_read(ut_params->ibuf,
5655 				(tdata->digest.offset_bytes == 0 ?
5656 				plaintext_pad_len : tdata->digest.offset_bytes),
5657 				tdata->digest.len, digest_buffer);
5658 
5659 		debug_hexdump(stdout, "digest:", digest,
5660 			tdata->digest.len);
5661 		debug_hexdump(stdout, "digest expected:",
5662 			tdata->digest.data, tdata->digest.len);
5663 	}
5664 
5665 	/* Validate obuf */
5666 	if (verify) {
5667 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5668 			plaintext,
5669 			tdata->plaintext.data,
5670 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5671 			 (tdata->digest.len << 3)),
5672 			tdata->cipher.offset_bits,
5673 			"SNOW 3G Plaintext data not as expected");
5674 	} else {
5675 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5676 			ciphertext,
5677 			tdata->ciphertext.data,
5678 			(tdata->validDataLenInBits.len -
5679 			 tdata->cipher.offset_bits),
5680 			tdata->cipher.offset_bits,
5681 			"SNOW 3G Ciphertext data not as expected");
5682 
5683 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5684 			digest,
5685 			tdata->digest.data,
5686 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5687 			"SNOW 3G Generated auth tag not as expected");
5688 	}
5689 	return 0;
5690 }
5691 
5692 static int
5693 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5694 	uint8_t op_mode, uint8_t verify)
5695 {
5696 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5697 	struct crypto_unittest_params *ut_params = &unittest_params;
5698 
5699 	int retval;
5700 
5701 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5702 	unsigned int plaintext_pad_len;
5703 	unsigned int plaintext_len;
5704 	unsigned int ciphertext_pad_len;
5705 	unsigned int ciphertext_len;
5706 	unsigned int digest_offset;
5707 
5708 	struct rte_cryptodev_info dev_info;
5709 
5710 	/* Verify the capabilities */
5711 	struct rte_cryptodev_sym_capability_idx cap_idx;
5712 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5713 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5714 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5715 			&cap_idx) == NULL)
5716 		return TEST_SKIPPED;
5717 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5718 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5719 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5720 			&cap_idx) == NULL)
5721 		return TEST_SKIPPED;
5722 
5723 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5724 
5725 	uint64_t feat_flags = dev_info.feature_flags;
5726 
5727 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5728 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5729 		printf("Device doesn't support RAW data-path APIs.\n");
5730 		return TEST_SKIPPED;
5731 	}
5732 
5733 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5734 		return TEST_SKIPPED;
5735 
5736 	if (op_mode == OUT_OF_PLACE) {
5737 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5738 			return TEST_SKIPPED;
5739 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5740 			printf("Device doesn't support digest encrypted.\n");
5741 			return TEST_SKIPPED;
5742 		}
5743 	}
5744 
5745 	/* Create KASUMI session */
5746 	retval = create_wireless_algo_auth_cipher_session(
5747 			ts_params->valid_devs[0],
5748 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5749 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5750 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5751 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5752 			RTE_CRYPTO_AUTH_KASUMI_F9,
5753 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5754 			tdata->key.data, tdata->key.len,
5755 			tdata->key.data, tdata->key.len,
5756 			0, tdata->digest.len,
5757 			tdata->cipher_iv.len);
5758 
5759 	if (retval != 0)
5760 		return retval;
5761 
5762 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5763 	if (op_mode == OUT_OF_PLACE)
5764 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5765 
5766 	/* clear mbuf payload */
5767 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5768 		rte_pktmbuf_tailroom(ut_params->ibuf));
5769 	if (op_mode == OUT_OF_PLACE)
5770 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5771 			rte_pktmbuf_tailroom(ut_params->obuf));
5772 
5773 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5774 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5775 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5776 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5777 
5778 	if (verify) {
5779 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5780 					ciphertext_pad_len);
5781 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5782 		if (op_mode == OUT_OF_PLACE)
5783 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5784 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5785 			ciphertext_len);
5786 	} else {
5787 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5788 					plaintext_pad_len);
5789 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5790 		if (op_mode == OUT_OF_PLACE)
5791 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5792 		debug_hexdump(stdout, "plaintext:", plaintext,
5793 			plaintext_len);
5794 	}
5795 
5796 	/* Create KASUMI operation */
5797 	retval = create_wireless_algo_auth_cipher_operation(
5798 		tdata->digest.data, tdata->digest.len,
5799 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5800 		NULL, 0,
5801 		(tdata->digest.offset_bytes == 0 ?
5802 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5803 			: tdata->digest.offset_bytes),
5804 		tdata->validCipherLenInBits.len,
5805 		tdata->validCipherOffsetInBits.len,
5806 		tdata->validAuthLenInBits.len,
5807 		0,
5808 		op_mode, 0, verify);
5809 
5810 	if (retval < 0)
5811 		return retval;
5812 
5813 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5814 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5815 					       tdata->cipher_iv.len);
5816 		if (retval != TEST_SUCCESS)
5817 			return retval;
5818 	} else
5819 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5820 			ut_params->op);
5821 
5822 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5823 
5824 	ut_params->obuf = (op_mode == IN_PLACE ?
5825 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5826 
5827 
5828 	if (verify) {
5829 		if (ut_params->obuf)
5830 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5831 							uint8_t *);
5832 		else
5833 			plaintext = ciphertext;
5834 
5835 		debug_hexdump(stdout, "plaintext:", plaintext,
5836 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5837 		debug_hexdump(stdout, "plaintext expected:",
5838 			tdata->plaintext.data,
5839 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5840 	} else {
5841 		if (ut_params->obuf)
5842 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5843 							uint8_t *);
5844 		else
5845 			ciphertext = plaintext;
5846 
5847 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5848 			ciphertext_len);
5849 		debug_hexdump(stdout, "ciphertext expected:",
5850 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5851 
5852 		if (tdata->digest.offset_bytes == 0)
5853 			digest_offset = plaintext_pad_len;
5854 		else
5855 			digest_offset = tdata->digest.offset_bytes;
5856 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5857 						    uint8_t *, digest_offset);
5858 
5859 		debug_hexdump(stdout, "digest:", ut_params->digest,
5860 			tdata->digest.len);
5861 		debug_hexdump(stdout, "digest expected:",
5862 			tdata->digest.data, tdata->digest.len);
5863 	}
5864 
5865 	/* Validate obuf */
5866 	if (verify) {
5867 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5868 			plaintext,
5869 			tdata->plaintext.data,
5870 			tdata->plaintext.len >> 3,
5871 			"KASUMI Plaintext data not as expected");
5872 	} else {
5873 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5874 			ciphertext,
5875 			tdata->ciphertext.data,
5876 			tdata->ciphertext.len >> 3,
5877 			"KASUMI Ciphertext data not as expected");
5878 
5879 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5880 			ut_params->digest,
5881 			tdata->digest.data,
5882 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5883 			"KASUMI Generated auth tag not as expected");
5884 	}
5885 	return 0;
5886 }
5887 
5888 static int
5889 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5890 	uint8_t op_mode, uint8_t verify)
5891 {
5892 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5893 	struct crypto_unittest_params *ut_params = &unittest_params;
5894 
5895 	int retval;
5896 
5897 	const uint8_t *plaintext = NULL;
5898 	const uint8_t *ciphertext = NULL;
5899 	const uint8_t *digest = NULL;
5900 	unsigned int plaintext_pad_len;
5901 	unsigned int plaintext_len;
5902 	unsigned int ciphertext_pad_len;
5903 	unsigned int ciphertext_len;
5904 	uint8_t buffer[10000];
5905 	uint8_t digest_buffer[10000];
5906 
5907 	struct rte_cryptodev_info dev_info;
5908 
5909 	/* Verify the capabilities */
5910 	struct rte_cryptodev_sym_capability_idx cap_idx;
5911 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5912 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5913 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5914 			&cap_idx) == NULL)
5915 		return TEST_SKIPPED;
5916 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5917 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5918 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5919 			&cap_idx) == NULL)
5920 		return TEST_SKIPPED;
5921 
5922 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5923 		return TEST_SKIPPED;
5924 
5925 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5926 
5927 	uint64_t feat_flags = dev_info.feature_flags;
5928 
5929 	if (op_mode == IN_PLACE) {
5930 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5931 			printf("Device doesn't support in-place scatter-gather "
5932 					"in both input and output mbufs.\n");
5933 			return TEST_SKIPPED;
5934 		}
5935 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5936 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5937 			printf("Device doesn't support RAW data-path APIs.\n");
5938 			return TEST_SKIPPED;
5939 		}
5940 	} else {
5941 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5942 			return TEST_SKIPPED;
5943 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5944 			printf("Device doesn't support out-of-place scatter-gather "
5945 					"in both input and output mbufs.\n");
5946 			return TEST_SKIPPED;
5947 		}
5948 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5949 			printf("Device doesn't support digest encrypted.\n");
5950 			return TEST_SKIPPED;
5951 		}
5952 	}
5953 
5954 	/* Create KASUMI session */
5955 	retval = create_wireless_algo_auth_cipher_session(
5956 			ts_params->valid_devs[0],
5957 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5958 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5959 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5960 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5961 			RTE_CRYPTO_AUTH_KASUMI_F9,
5962 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5963 			tdata->key.data, tdata->key.len,
5964 			tdata->key.data, tdata->key.len,
5965 			0, tdata->digest.len,
5966 			tdata->cipher_iv.len);
5967 
5968 	if (retval != 0)
5969 		return retval;
5970 
5971 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5972 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5973 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5974 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5975 
5976 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5977 			plaintext_pad_len, 15, 0);
5978 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5979 			"Failed to allocate input buffer in mempool");
5980 
5981 	if (op_mode == OUT_OF_PLACE) {
5982 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5983 				plaintext_pad_len, 15, 0);
5984 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5985 				"Failed to allocate output buffer in mempool");
5986 	}
5987 
5988 	if (verify) {
5989 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5990 			tdata->ciphertext.data);
5991 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5992 					ciphertext_len, buffer);
5993 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5994 			ciphertext_len);
5995 	} else {
5996 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5997 			tdata->plaintext.data);
5998 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5999 					plaintext_len, buffer);
6000 		debug_hexdump(stdout, "plaintext:", plaintext,
6001 			plaintext_len);
6002 	}
6003 	memset(buffer, 0, sizeof(buffer));
6004 
6005 	/* Create KASUMI operation */
6006 	retval = create_wireless_algo_auth_cipher_operation(
6007 		tdata->digest.data, tdata->digest.len,
6008 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6009 		NULL, 0,
6010 		(tdata->digest.offset_bytes == 0 ?
6011 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6012 			: tdata->digest.offset_bytes),
6013 		tdata->validCipherLenInBits.len,
6014 		tdata->validCipherOffsetInBits.len,
6015 		tdata->validAuthLenInBits.len,
6016 		0,
6017 		op_mode, 1, verify);
6018 
6019 	if (retval < 0)
6020 		return retval;
6021 
6022 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6023 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6024 					       tdata->cipher_iv.len);
6025 		if (retval != TEST_SUCCESS)
6026 			return retval;
6027 	} else
6028 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6029 			ut_params->op);
6030 
6031 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6032 
6033 	ut_params->obuf = (op_mode == IN_PLACE ?
6034 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6035 
6036 	if (verify) {
6037 		if (ut_params->obuf)
6038 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6039 					plaintext_len, buffer);
6040 		else
6041 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6042 					plaintext_len, buffer);
6043 
6044 		debug_hexdump(stdout, "plaintext:", plaintext,
6045 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6046 		debug_hexdump(stdout, "plaintext expected:",
6047 			tdata->plaintext.data,
6048 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6049 	} else {
6050 		if (ut_params->obuf)
6051 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6052 					ciphertext_len, buffer);
6053 		else
6054 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6055 					ciphertext_len, buffer);
6056 
6057 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6058 			ciphertext_len);
6059 		debug_hexdump(stdout, "ciphertext expected:",
6060 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6061 
6062 		if (ut_params->obuf)
6063 			digest = rte_pktmbuf_read(ut_params->obuf,
6064 				(tdata->digest.offset_bytes == 0 ?
6065 				plaintext_pad_len : tdata->digest.offset_bytes),
6066 				tdata->digest.len, digest_buffer);
6067 		else
6068 			digest = rte_pktmbuf_read(ut_params->ibuf,
6069 				(tdata->digest.offset_bytes == 0 ?
6070 				plaintext_pad_len : tdata->digest.offset_bytes),
6071 				tdata->digest.len, digest_buffer);
6072 
6073 		debug_hexdump(stdout, "digest:", digest,
6074 			tdata->digest.len);
6075 		debug_hexdump(stdout, "digest expected:",
6076 			tdata->digest.data, tdata->digest.len);
6077 	}
6078 
6079 	/* Validate obuf */
6080 	if (verify) {
6081 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6082 			plaintext,
6083 			tdata->plaintext.data,
6084 			tdata->plaintext.len >> 3,
6085 			"KASUMI Plaintext data not as expected");
6086 	} else {
6087 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6088 			ciphertext,
6089 			tdata->ciphertext.data,
6090 			tdata->validDataLenInBits.len,
6091 			"KASUMI Ciphertext data not as expected");
6092 
6093 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6094 			digest,
6095 			tdata->digest.data,
6096 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6097 			"KASUMI Generated auth tag not as expected");
6098 	}
6099 	return 0;
6100 }
6101 
6102 static int
6103 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6104 {
6105 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6106 	struct crypto_unittest_params *ut_params = &unittest_params;
6107 
6108 	int retval;
6109 
6110 	uint8_t *plaintext, *ciphertext;
6111 	unsigned plaintext_pad_len;
6112 	unsigned plaintext_len;
6113 	struct rte_cryptodev_info dev_info;
6114 
6115 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6116 	uint64_t feat_flags = dev_info.feature_flags;
6117 
6118 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6119 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6120 		printf("Device doesn't support RAW data-path APIs.\n");
6121 		return TEST_SKIPPED;
6122 	}
6123 
6124 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6125 		return TEST_SKIPPED;
6126 
6127 	/* Verify the capabilities */
6128 	struct rte_cryptodev_sym_capability_idx cap_idx;
6129 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6130 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6131 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6132 			&cap_idx) == NULL)
6133 		return TEST_SKIPPED;
6134 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6135 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6136 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6137 			&cap_idx) == NULL)
6138 		return TEST_SKIPPED;
6139 
6140 	/* Create KASUMI session */
6141 	retval = create_wireless_algo_cipher_auth_session(
6142 			ts_params->valid_devs[0],
6143 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6144 			RTE_CRYPTO_AUTH_OP_GENERATE,
6145 			RTE_CRYPTO_AUTH_KASUMI_F9,
6146 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6147 			tdata->key.data, tdata->key.len,
6148 			tdata->key.data, tdata->key.len,
6149 			0, tdata->digest.len,
6150 			tdata->cipher_iv.len);
6151 	if (retval != 0)
6152 		return retval;
6153 
6154 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6155 
6156 	/* clear mbuf payload */
6157 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6158 			rte_pktmbuf_tailroom(ut_params->ibuf));
6159 
6160 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6161 	/* Append data which is padded to a multiple of */
6162 	/* the algorithms block size */
6163 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6164 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6165 				plaintext_pad_len);
6166 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6167 
6168 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6169 
6170 	/* Create KASUMI operation */
6171 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6172 				tdata->digest.len, NULL, 0,
6173 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6174 				tdata->cipher_iv.data, tdata->cipher_iv.len,
6175 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6176 				tdata->validCipherOffsetInBits.len,
6177 				tdata->validAuthLenInBits.len,
6178 				0
6179 				);
6180 	if (retval < 0)
6181 		return retval;
6182 
6183 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6184 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6185 					       tdata->cipher_iv.len);
6186 		if (retval != TEST_SUCCESS)
6187 			return retval;
6188 	} else
6189 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6190 			ut_params->op);
6191 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6192 
6193 	if (ut_params->op->sym->m_dst)
6194 		ut_params->obuf = ut_params->op->sym->m_dst;
6195 	else
6196 		ut_params->obuf = ut_params->op->sym->m_src;
6197 
6198 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6199 				tdata->validCipherOffsetInBits.len >> 3);
6200 
6201 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6202 						    uint8_t *,
6203 						    plaintext_pad_len);
6204 
6205 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6206 				(tdata->validCipherOffsetInBits.len >> 3);
6207 	/* Validate obuf */
6208 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6209 		ciphertext,
6210 		reference_ciphertext,
6211 		tdata->validCipherLenInBits.len,
6212 		"KASUMI Ciphertext data not as expected");
6213 
6214 	/* Validate obuf */
6215 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6216 		ut_params->digest,
6217 		tdata->digest.data,
6218 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6219 		"KASUMI Generated auth tag not as expected");
6220 	return 0;
6221 }
6222 
6223 static int
6224 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6225 			const enum rte_crypto_cipher_algorithm cipher_algo,
6226 			const uint16_t key_size, const uint16_t iv_size)
6227 {
6228 	struct rte_cryptodev_sym_capability_idx cap_idx;
6229 	const struct rte_cryptodev_symmetric_capability *cap;
6230 
6231 	/* Check if device supports the algorithm */
6232 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6233 	cap_idx.algo.cipher = cipher_algo;
6234 
6235 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6236 			&cap_idx);
6237 
6238 	if (cap == NULL)
6239 		return -1;
6240 
6241 	/* Check if device supports key size and IV size */
6242 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6243 			iv_size) < 0) {
6244 		return -1;
6245 	}
6246 
6247 	return 0;
6248 }
6249 
6250 static int
6251 check_auth_capability(const struct crypto_testsuite_params *ts_params,
6252 			const enum rte_crypto_auth_algorithm auth_algo,
6253 			const uint16_t key_size, const uint16_t iv_size,
6254 			const uint16_t tag_size)
6255 {
6256 	struct rte_cryptodev_sym_capability_idx cap_idx;
6257 	const struct rte_cryptodev_symmetric_capability *cap;
6258 
6259 	/* Check if device supports the algorithm */
6260 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6261 	cap_idx.algo.auth = auth_algo;
6262 
6263 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6264 			&cap_idx);
6265 
6266 	if (cap == NULL)
6267 		return -1;
6268 
6269 	/* Check if device supports key size and IV size */
6270 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6271 			tag_size, iv_size) < 0) {
6272 		return -1;
6273 	}
6274 
6275 	return 0;
6276 }
6277 
6278 static int
6279 test_zuc_cipher(const struct wireless_test_data *tdata,
6280 		enum rte_crypto_cipher_operation direction)
6281 {
6282 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6283 	struct crypto_unittest_params *ut_params = &unittest_params;
6284 
6285 	int retval;
6286 	uint8_t *plaintext = NULL;
6287 	uint8_t *ciphertext = NULL;
6288 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6289 	unsigned int plaintext_len = 0;
6290 	unsigned int ciphertext_len = 0;
6291 	struct rte_cryptodev_info dev_info;
6292 
6293 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6294 	uint64_t feat_flags = dev_info.feature_flags;
6295 
6296 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6297 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6298 		printf("Device doesn't support RAW data-path APIs.\n");
6299 		return TEST_SKIPPED;
6300 	}
6301 
6302 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6303 		return TEST_SKIPPED;
6304 
6305 	/* Check if device supports ZUC EEA3 */
6306 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6307 			tdata->key.len, tdata->cipher_iv.len) < 0)
6308 		return TEST_SKIPPED;
6309 
6310 	/* Create ZUC session */
6311 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6312 					direction,
6313 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
6314 					tdata->key.data, tdata->key.len,
6315 					tdata->cipher_iv.len);
6316 	if (retval != 0)
6317 		return retval;
6318 
6319 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6320 
6321 	/* Clear mbuf payload */
6322 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6323 	       rte_pktmbuf_tailroom(ut_params->ibuf));
6324 
6325 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6326 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6327 		/* Append data which is padded to a multiple */
6328 		/* of the algorithms block size */
6329 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6330 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6331 				plaintext_pad_len);
6332 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6333 
6334 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6335 	} else {
6336 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6337 		/* Append data which is padded to a multiple */
6338 		/* of the algorithms block size */
6339 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6340 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6341 				ciphertext_pad_len);
6342 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6343 
6344 		debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6345 	}
6346 
6347 	/* Create ZUC operation */
6348 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6349 					tdata->cipher_iv.len,
6350 					tdata->plaintext.len,
6351 					tdata->validCipherOffsetInBits.len);
6352 	if (retval < 0)
6353 		return retval;
6354 
6355 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6356 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6357 					       tdata->cipher_iv.len);
6358 		if (retval != TEST_SUCCESS)
6359 			return retval;
6360 	} else
6361 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6362 						ut_params->op);
6363 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6364 
6365 	ut_params->obuf = ut_params->op->sym->m_dst;
6366 
6367 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6368 		if (ut_params->obuf)
6369 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6370 		else
6371 			ciphertext = plaintext;
6372 
6373 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6374 
6375 		/* Validate obuf */
6376 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6377 				ciphertext,
6378 				tdata->ciphertext.data,
6379 				tdata->validCipherLenInBits.len,
6380 				"ZUC Ciphertext data not as expected");
6381 	} else {
6382 		if (ut_params->obuf)
6383 			plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6384 		else
6385 			plaintext = ciphertext;
6386 
6387 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6388 
6389 		const uint8_t *reference_plaintext = tdata->plaintext.data +
6390 				(tdata->validCipherOffsetInBits.len >> 3);
6391 
6392 		/* Validate obuf */
6393 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6394 				plaintext,
6395 				reference_plaintext,
6396 				tdata->validCipherLenInBits.len,
6397 				"ZUC Plaintext data not as expected");
6398 	}
6399 
6400 	return 0;
6401 }
6402 
6403 static int
6404 test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6405 		enum rte_crypto_cipher_operation direction)
6406 {
6407 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6408 	struct crypto_unittest_params *ut_params = &unittest_params;
6409 
6410 	int retval;
6411 
6412 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6413 	unsigned int plaintext_len = 0;
6414 	unsigned int ciphertext_len = 0;
6415 	const uint8_t *ciphertext, *plaintext;
6416 	uint8_t buffer[2048];
6417 	struct rte_cryptodev_info dev_info;
6418 
6419 	/* Check if device supports ZUC EEA3 */
6420 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6421 			tdata->key.len, tdata->cipher_iv.len) < 0)
6422 		return TEST_SKIPPED;
6423 
6424 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6425 		return TEST_SKIPPED;
6426 
6427 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6428 
6429 	uint64_t feat_flags = dev_info.feature_flags;
6430 
6431 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6432 		printf("Device doesn't support in-place scatter-gather. "
6433 				"Test Skipped.\n");
6434 		return TEST_SKIPPED;
6435 	}
6436 
6437 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6438 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6439 		printf("Device doesn't support RAW data-path APIs.\n");
6440 		return TEST_SKIPPED;
6441 	}
6442 
6443 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6444 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6445 
6446 		/* Append data which is padded to a multiple */
6447 		/* of the algorithms block size */
6448 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6449 
6450 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6451 				plaintext_pad_len, 10, 0);
6452 
6453 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6454 				tdata->plaintext.data);
6455 	} else {
6456 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6457 
6458 		/* Append data which is padded to a multiple */
6459 		/* of the algorithms block size */
6460 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6461 
6462 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6463 				ciphertext_pad_len, 10, 0);
6464 
6465 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6466 				tdata->ciphertext.data);
6467 
6468 	}
6469 
6470 	/* Create ZUC session */
6471 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6472 			direction,
6473 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6474 			tdata->key.data, tdata->key.len,
6475 			tdata->cipher_iv.len);
6476 	if (retval < 0)
6477 		return retval;
6478 
6479 	/* Clear mbuf payload */
6480 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6481 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6482 	else
6483 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6484 
6485 	/* Create ZUC operation */
6486 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6487 			tdata->cipher_iv.len, tdata->plaintext.len,
6488 			tdata->validCipherOffsetInBits.len);
6489 	if (retval < 0)
6490 		return retval;
6491 
6492 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6493 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6494 					       tdata->cipher_iv.len);
6495 		if (retval != TEST_SUCCESS)
6496 			return retval;
6497 	} else
6498 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6499 						ut_params->op);
6500 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6501 
6502 	ut_params->obuf = ut_params->op->sym->m_dst;
6503 
6504 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6505 		if (ut_params->obuf)
6506 			ciphertext = rte_pktmbuf_read(ut_params->obuf,
6507 				0, plaintext_len, buffer);
6508 		else
6509 			ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6510 				0, plaintext_len, buffer);
6511 
6512 		/* Validate obuf */
6513 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6514 
6515 		/* Validate obuf */
6516 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6517 			ciphertext,
6518 			tdata->ciphertext.data,
6519 			tdata->validCipherLenInBits.len,
6520 			"ZUC Ciphertext data not as expected");
6521 	} else {
6522 		if (ut_params->obuf)
6523 			plaintext = rte_pktmbuf_read(ut_params->obuf,
6524 				0, ciphertext_len, buffer);
6525 		else
6526 			plaintext = rte_pktmbuf_read(ut_params->ibuf,
6527 				0, ciphertext_len, buffer);
6528 
6529 		/* Validate obuf */
6530 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6531 
6532 		/* Validate obuf */
6533 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6534 			plaintext,
6535 			tdata->plaintext.data,
6536 			tdata->validCipherLenInBits.len,
6537 			"ZUC Plaintext data not as expected");
6538 		}
6539 
6540 	return 0;
6541 }
6542 
6543 static int
6544 test_zuc_authentication(const struct wireless_test_data *tdata,
6545 		enum rte_crypto_auth_operation auth_op)
6546 {
6547 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6548 	struct crypto_unittest_params *ut_params = &unittest_params;
6549 
6550 	int retval;
6551 	unsigned plaintext_pad_len;
6552 	unsigned plaintext_len;
6553 	uint8_t *plaintext;
6554 
6555 	struct rte_cryptodev_info dev_info;
6556 
6557 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6558 	uint64_t feat_flags = dev_info.feature_flags;
6559 
6560 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6561 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6562 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6563 		return TEST_SKIPPED;
6564 	}
6565 
6566 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6567 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6568 		printf("Device doesn't support RAW data-path APIs.\n");
6569 		return TEST_SKIPPED;
6570 	}
6571 
6572 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6573 		return TEST_SKIPPED;
6574 
6575 	/* Check if device supports ZUC EIA3 */
6576 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6577 			tdata->key.len, tdata->auth_iv.len,
6578 			tdata->digest.len) < 0)
6579 		return TEST_SKIPPED;
6580 
6581 	/* Create ZUC session */
6582 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6583 			tdata->key.data, tdata->key.len,
6584 			tdata->auth_iv.len, tdata->digest.len,
6585 			auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6586 	if (retval != 0)
6587 		return retval;
6588 
6589 	/* alloc mbuf and set payload */
6590 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6591 
6592 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6593 	rte_pktmbuf_tailroom(ut_params->ibuf));
6594 
6595 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6596 	/* Append data which is padded to a multiple of */
6597 	/* the algorithms block size */
6598 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6599 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6600 				plaintext_pad_len);
6601 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6602 
6603 	/* Create ZUC operation */
6604 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
6605 			tdata->digest.len,
6606 			tdata->auth_iv.data, tdata->auth_iv.len,
6607 			plaintext_pad_len,
6608 			auth_op, tdata->validAuthLenInBits.len, 0);
6609 	if (retval < 0)
6610 		return retval;
6611 
6612 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6613 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6614 					       0);
6615 		if (retval != TEST_SUCCESS)
6616 			return retval;
6617 	} else
6618 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6619 				ut_params->op);
6620 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6621 	ut_params->obuf = ut_params->op->sym->m_src;
6622 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6623 						    uint8_t *,
6624 						    plaintext_pad_len);
6625 
6626 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6627 		/* Validate obuf */
6628 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6629 				ut_params->digest,
6630 				tdata->digest.data,
6631 				tdata->digest.len,
6632 				"ZUC Generated auth tag not as expected");
6633 		return 0;
6634 	}
6635 
6636 	/* Validate obuf */
6637 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6638 		return 0;
6639 	else
6640 		return -1;
6641 
6642 	return 0;
6643 }
6644 
6645 static int
6646 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6647 	uint8_t op_mode, uint8_t verify)
6648 {
6649 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6650 	struct crypto_unittest_params *ut_params = &unittest_params;
6651 
6652 	int retval;
6653 
6654 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6655 	unsigned int plaintext_pad_len;
6656 	unsigned int plaintext_len;
6657 	unsigned int ciphertext_pad_len;
6658 	unsigned int ciphertext_len;
6659 	unsigned int digest_offset;
6660 
6661 	struct rte_cryptodev_info dev_info;
6662 
6663 	/* Check if device supports ZUC EEA3 */
6664 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6665 			tdata->key.len, tdata->cipher_iv.len) < 0)
6666 		return TEST_SKIPPED;
6667 
6668 	/* Check if device supports ZUC EIA3 */
6669 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6670 			tdata->key.len, tdata->auth_iv.len,
6671 			tdata->digest.len) < 0)
6672 		return TEST_SKIPPED;
6673 
6674 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6675 		return TEST_SKIPPED;
6676 
6677 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6678 
6679 	uint64_t feat_flags = dev_info.feature_flags;
6680 
6681 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6682 		printf("Device doesn't support digest encrypted.\n");
6683 		return TEST_SKIPPED;
6684 	}
6685 	if (op_mode == IN_PLACE) {
6686 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6687 			printf("Device doesn't support in-place scatter-gather "
6688 					"in both input and output mbufs.\n");
6689 			return TEST_SKIPPED;
6690 		}
6691 
6692 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6693 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6694 			printf("Device doesn't support RAW data-path APIs.\n");
6695 			return TEST_SKIPPED;
6696 		}
6697 	} else {
6698 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6699 			return TEST_SKIPPED;
6700 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6701 			printf("Device doesn't support out-of-place scatter-gather "
6702 					"in both input and output mbufs.\n");
6703 			return TEST_SKIPPED;
6704 		}
6705 	}
6706 
6707 	/* Create ZUC session */
6708 	retval = create_wireless_algo_auth_cipher_session(
6709 			ts_params->valid_devs[0],
6710 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6711 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6712 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6713 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6714 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6715 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6716 			tdata->key.data, tdata->key.len,
6717 			tdata->key.data, tdata->key.len,
6718 			tdata->auth_iv.len, tdata->digest.len,
6719 			tdata->cipher_iv.len);
6720 
6721 	if (retval != 0)
6722 		return retval;
6723 
6724 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6725 	if (op_mode == OUT_OF_PLACE)
6726 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6727 
6728 	/* clear mbuf payload */
6729 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6730 		rte_pktmbuf_tailroom(ut_params->ibuf));
6731 	if (op_mode == OUT_OF_PLACE)
6732 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6733 			rte_pktmbuf_tailroom(ut_params->obuf));
6734 
6735 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6736 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6737 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6738 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6739 
6740 	if (verify) {
6741 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6742 					ciphertext_pad_len);
6743 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6744 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6745 			ciphertext_len);
6746 	} else {
6747 		/* make sure enough space to cover partial digest verify case */
6748 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6749 					ciphertext_pad_len);
6750 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6751 		debug_hexdump(stdout, "plaintext:", plaintext,
6752 			plaintext_len);
6753 	}
6754 
6755 	if (op_mode == OUT_OF_PLACE)
6756 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6757 
6758 	/* Create ZUC operation */
6759 	retval = create_wireless_algo_auth_cipher_operation(
6760 		tdata->digest.data, tdata->digest.len,
6761 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6762 		tdata->auth_iv.data, tdata->auth_iv.len,
6763 		(tdata->digest.offset_bytes == 0 ?
6764 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6765 			: tdata->digest.offset_bytes),
6766 		tdata->validCipherLenInBits.len,
6767 		tdata->validCipherOffsetInBits.len,
6768 		tdata->validAuthLenInBits.len,
6769 		0,
6770 		op_mode, 0, verify);
6771 
6772 	if (retval < 0)
6773 		return retval;
6774 
6775 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6776 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6777 					       tdata->cipher_iv.len);
6778 		if (retval != TEST_SUCCESS)
6779 			return retval;
6780 	} else
6781 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6782 			ut_params->op);
6783 
6784 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6785 
6786 	ut_params->obuf = (op_mode == IN_PLACE ?
6787 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6788 
6789 
6790 	if (verify) {
6791 		if (ut_params->obuf)
6792 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6793 							uint8_t *);
6794 		else
6795 			plaintext = ciphertext;
6796 
6797 		debug_hexdump(stdout, "plaintext:", plaintext,
6798 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6799 		debug_hexdump(stdout, "plaintext expected:",
6800 			tdata->plaintext.data,
6801 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6802 	} else {
6803 		if (ut_params->obuf)
6804 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6805 							uint8_t *);
6806 		else
6807 			ciphertext = plaintext;
6808 
6809 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6810 			ciphertext_len);
6811 		debug_hexdump(stdout, "ciphertext expected:",
6812 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6813 
6814 		if (tdata->digest.offset_bytes == 0)
6815 			digest_offset = plaintext_pad_len;
6816 		else
6817 			digest_offset =  tdata->digest.offset_bytes;
6818 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6819 					    uint8_t *, digest_offset);
6820 
6821 		debug_hexdump(stdout, "digest:", ut_params->digest,
6822 			tdata->digest.len);
6823 		debug_hexdump(stdout, "digest expected:",
6824 			tdata->digest.data, tdata->digest.len);
6825 	}
6826 
6827 	/* Validate obuf */
6828 	if (verify) {
6829 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6830 			plaintext,
6831 			tdata->plaintext.data,
6832 			tdata->plaintext.len >> 3,
6833 			"ZUC Plaintext data not as expected");
6834 	} else {
6835 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6836 			ciphertext,
6837 			tdata->ciphertext.data,
6838 			tdata->ciphertext.len >> 3,
6839 			"ZUC Ciphertext data not as expected");
6840 
6841 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6842 			ut_params->digest,
6843 			tdata->digest.data,
6844 			tdata->digest.len,
6845 			"ZUC Generated auth tag not as expected");
6846 	}
6847 	return 0;
6848 }
6849 
6850 static int
6851 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6852 	uint8_t op_mode, uint8_t verify)
6853 {
6854 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6855 	struct crypto_unittest_params *ut_params = &unittest_params;
6856 
6857 	int retval;
6858 
6859 	const uint8_t *plaintext = NULL;
6860 	const uint8_t *ciphertext = NULL;
6861 	const uint8_t *digest = NULL;
6862 	unsigned int plaintext_pad_len;
6863 	unsigned int plaintext_len;
6864 	unsigned int ciphertext_pad_len;
6865 	unsigned int ciphertext_len;
6866 	uint8_t buffer[10000];
6867 	uint8_t digest_buffer[10000];
6868 
6869 	struct rte_cryptodev_info dev_info;
6870 
6871 	/* Check if device supports ZUC EEA3 */
6872 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6873 			tdata->key.len, tdata->cipher_iv.len) < 0)
6874 		return TEST_SKIPPED;
6875 
6876 	/* Check if device supports ZUC EIA3 */
6877 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6878 			tdata->key.len, tdata->auth_iv.len,
6879 			tdata->digest.len) < 0)
6880 		return TEST_SKIPPED;
6881 
6882 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6883 		return TEST_SKIPPED;
6884 
6885 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6886 
6887 	uint64_t feat_flags = dev_info.feature_flags;
6888 
6889 	if (op_mode == IN_PLACE) {
6890 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6891 			printf("Device doesn't support in-place scatter-gather "
6892 					"in both input and output mbufs.\n");
6893 			return TEST_SKIPPED;
6894 		}
6895 
6896 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6897 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6898 			printf("Device doesn't support RAW data-path APIs.\n");
6899 			return TEST_SKIPPED;
6900 		}
6901 	} else {
6902 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6903 			return TEST_SKIPPED;
6904 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6905 			printf("Device doesn't support out-of-place scatter-gather "
6906 					"in both input and output mbufs.\n");
6907 			return TEST_SKIPPED;
6908 		}
6909 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6910 			printf("Device doesn't support digest encrypted.\n");
6911 			return TEST_SKIPPED;
6912 		}
6913 	}
6914 
6915 	/* Create ZUC session */
6916 	retval = create_wireless_algo_auth_cipher_session(
6917 			ts_params->valid_devs[0],
6918 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6919 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6920 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6921 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6922 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6923 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6924 			tdata->key.data, tdata->key.len,
6925 			tdata->key.data, tdata->key.len,
6926 			tdata->auth_iv.len, tdata->digest.len,
6927 			tdata->cipher_iv.len);
6928 
6929 	if (retval != 0)
6930 		return retval;
6931 
6932 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6933 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6934 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6935 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6936 
6937 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6938 			plaintext_pad_len, 15, 0);
6939 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6940 			"Failed to allocate input buffer in mempool");
6941 
6942 	if (op_mode == OUT_OF_PLACE) {
6943 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6944 				plaintext_pad_len, 15, 0);
6945 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6946 				"Failed to allocate output buffer in mempool");
6947 	}
6948 
6949 	if (verify) {
6950 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6951 			tdata->ciphertext.data);
6952 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6953 					ciphertext_len, buffer);
6954 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6955 			ciphertext_len);
6956 	} else {
6957 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6958 			tdata->plaintext.data);
6959 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6960 					plaintext_len, buffer);
6961 		debug_hexdump(stdout, "plaintext:", plaintext,
6962 			plaintext_len);
6963 	}
6964 	memset(buffer, 0, sizeof(buffer));
6965 
6966 	/* Create ZUC operation */
6967 	retval = create_wireless_algo_auth_cipher_operation(
6968 		tdata->digest.data, tdata->digest.len,
6969 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6970 		tdata->auth_iv.data, tdata->auth_iv.len,
6971 		(tdata->digest.offset_bytes == 0 ?
6972 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6973 			: tdata->digest.offset_bytes),
6974 		tdata->validCipherLenInBits.len,
6975 		tdata->validCipherOffsetInBits.len,
6976 		tdata->validAuthLenInBits.len,
6977 		0,
6978 		op_mode, 1, verify);
6979 
6980 	if (retval < 0)
6981 		return retval;
6982 
6983 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6984 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6985 					       tdata->cipher_iv.len);
6986 		if (retval != TEST_SUCCESS)
6987 			return retval;
6988 	} else
6989 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6990 			ut_params->op);
6991 
6992 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6993 
6994 	ut_params->obuf = (op_mode == IN_PLACE ?
6995 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6996 
6997 	if (verify) {
6998 		if (ut_params->obuf)
6999 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7000 					plaintext_len, buffer);
7001 		else
7002 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7003 					plaintext_len, buffer);
7004 
7005 		debug_hexdump(stdout, "plaintext:", plaintext,
7006 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7007 		debug_hexdump(stdout, "plaintext expected:",
7008 			tdata->plaintext.data,
7009 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7010 	} else {
7011 		if (ut_params->obuf)
7012 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7013 					ciphertext_len, buffer);
7014 		else
7015 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7016 					ciphertext_len, buffer);
7017 
7018 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7019 			ciphertext_len);
7020 		debug_hexdump(stdout, "ciphertext expected:",
7021 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7022 
7023 		if (ut_params->obuf)
7024 			digest = rte_pktmbuf_read(ut_params->obuf,
7025 				(tdata->digest.offset_bytes == 0 ?
7026 				plaintext_pad_len : tdata->digest.offset_bytes),
7027 				tdata->digest.len, digest_buffer);
7028 		else
7029 			digest = rte_pktmbuf_read(ut_params->ibuf,
7030 				(tdata->digest.offset_bytes == 0 ?
7031 				plaintext_pad_len : tdata->digest.offset_bytes),
7032 				tdata->digest.len, digest_buffer);
7033 
7034 		debug_hexdump(stdout, "digest:", digest,
7035 			tdata->digest.len);
7036 		debug_hexdump(stdout, "digest expected:",
7037 			tdata->digest.data, tdata->digest.len);
7038 	}
7039 
7040 	/* Validate obuf */
7041 	if (verify) {
7042 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7043 			plaintext,
7044 			tdata->plaintext.data,
7045 			tdata->plaintext.len >> 3,
7046 			"ZUC Plaintext data not as expected");
7047 	} else {
7048 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7049 			ciphertext,
7050 			tdata->ciphertext.data,
7051 			tdata->validDataLenInBits.len,
7052 			"ZUC Ciphertext data not as expected");
7053 
7054 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7055 			digest,
7056 			tdata->digest.data,
7057 			tdata->digest.len,
7058 			"ZUC Generated auth tag not as expected");
7059 	}
7060 	return 0;
7061 }
7062 
7063 static int
7064 test_kasumi_encryption_test_case_1(void)
7065 {
7066 	return test_kasumi_encryption(&kasumi_test_case_1);
7067 }
7068 
7069 static int
7070 test_kasumi_encryption_test_case_1_sgl(void)
7071 {
7072 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7073 }
7074 
7075 static int
7076 test_kasumi_encryption_test_case_1_oop(void)
7077 {
7078 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
7079 }
7080 
7081 static int
7082 test_kasumi_encryption_test_case_1_oop_sgl(void)
7083 {
7084 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7085 }
7086 
7087 static int
7088 test_kasumi_encryption_test_case_2(void)
7089 {
7090 	return test_kasumi_encryption(&kasumi_test_case_2);
7091 }
7092 
7093 static int
7094 test_kasumi_encryption_test_case_3(void)
7095 {
7096 	return test_kasumi_encryption(&kasumi_test_case_3);
7097 }
7098 
7099 static int
7100 test_kasumi_encryption_test_case_4(void)
7101 {
7102 	return test_kasumi_encryption(&kasumi_test_case_4);
7103 }
7104 
7105 static int
7106 test_kasumi_encryption_test_case_5(void)
7107 {
7108 	return test_kasumi_encryption(&kasumi_test_case_5);
7109 }
7110 
7111 static int
7112 test_kasumi_decryption_test_case_1(void)
7113 {
7114 	return test_kasumi_decryption(&kasumi_test_case_1);
7115 }
7116 
7117 static int
7118 test_kasumi_decryption_test_case_1_oop(void)
7119 {
7120 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
7121 }
7122 
7123 static int
7124 test_kasumi_decryption_test_case_2(void)
7125 {
7126 	return test_kasumi_decryption(&kasumi_test_case_2);
7127 }
7128 
7129 static int
7130 test_kasumi_decryption_test_case_3(void)
7131 {
7132 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7133 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7134 		return TEST_SKIPPED;
7135 	return test_kasumi_decryption(&kasumi_test_case_3);
7136 }
7137 
7138 static int
7139 test_kasumi_decryption_test_case_4(void)
7140 {
7141 	return test_kasumi_decryption(&kasumi_test_case_4);
7142 }
7143 
7144 static int
7145 test_kasumi_decryption_test_case_5(void)
7146 {
7147 	return test_kasumi_decryption(&kasumi_test_case_5);
7148 }
7149 static int
7150 test_snow3g_encryption_test_case_1(void)
7151 {
7152 	return test_snow3g_encryption(&snow3g_test_case_1);
7153 }
7154 
7155 static int
7156 test_snow3g_encryption_test_case_1_oop(void)
7157 {
7158 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
7159 }
7160 
7161 static int
7162 test_snow3g_encryption_test_case_1_oop_sgl(void)
7163 {
7164 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7165 }
7166 
7167 static int
7168 test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7169 {
7170 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7171 }
7172 
7173 static int
7174 test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7175 {
7176 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7177 }
7178 
7179 static int
7180 test_snow3g_encryption_test_case_1_offset_oop(void)
7181 {
7182 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7183 }
7184 
7185 static int
7186 test_snow3g_encryption_test_case_2(void)
7187 {
7188 	return test_snow3g_encryption(&snow3g_test_case_2);
7189 }
7190 
7191 static int
7192 test_snow3g_encryption_test_case_3(void)
7193 {
7194 	return test_snow3g_encryption(&snow3g_test_case_3);
7195 }
7196 
7197 static int
7198 test_snow3g_encryption_test_case_4(void)
7199 {
7200 	return test_snow3g_encryption(&snow3g_test_case_4);
7201 }
7202 
7203 static int
7204 test_snow3g_encryption_test_case_5(void)
7205 {
7206 	return test_snow3g_encryption(&snow3g_test_case_5);
7207 }
7208 
7209 static int
7210 test_snow3g_decryption_test_case_1(void)
7211 {
7212 	return test_snow3g_decryption(&snow3g_test_case_1);
7213 }
7214 
7215 static int
7216 test_snow3g_decryption_test_case_1_oop(void)
7217 {
7218 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
7219 }
7220 
7221 static int
7222 test_snow3g_decryption_test_case_2(void)
7223 {
7224 	return test_snow3g_decryption(&snow3g_test_case_2);
7225 }
7226 
7227 static int
7228 test_snow3g_decryption_test_case_3(void)
7229 {
7230 	return test_snow3g_decryption(&snow3g_test_case_3);
7231 }
7232 
7233 static int
7234 test_snow3g_decryption_test_case_4(void)
7235 {
7236 	return test_snow3g_decryption(&snow3g_test_case_4);
7237 }
7238 
7239 static int
7240 test_snow3g_decryption_test_case_5(void)
7241 {
7242 	return test_snow3g_decryption(&snow3g_test_case_5);
7243 }
7244 
7245 /*
7246  * Function prepares snow3g_hash_test_data from snow3g_test_data.
7247  * Pattern digest from snow3g_test_data must be allocated as
7248  * 4 last bytes in plaintext.
7249  */
7250 static void
7251 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7252 		struct snow3g_hash_test_data *output)
7253 {
7254 	if ((pattern != NULL) && (output != NULL)) {
7255 		output->key.len = pattern->key.len;
7256 
7257 		memcpy(output->key.data,
7258 		pattern->key.data, pattern->key.len);
7259 
7260 		output->auth_iv.len = pattern->auth_iv.len;
7261 
7262 		memcpy(output->auth_iv.data,
7263 		pattern->auth_iv.data, pattern->auth_iv.len);
7264 
7265 		output->plaintext.len = pattern->plaintext.len;
7266 
7267 		memcpy(output->plaintext.data,
7268 		pattern->plaintext.data, pattern->plaintext.len >> 3);
7269 
7270 		output->digest.len = pattern->digest.len;
7271 
7272 		memcpy(output->digest.data,
7273 		&pattern->plaintext.data[pattern->digest.offset_bytes],
7274 		pattern->digest.len);
7275 
7276 		output->validAuthLenInBits.len =
7277 		pattern->validAuthLenInBits.len;
7278 	}
7279 }
7280 
7281 /*
7282  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7283  */
7284 static int
7285 test_snow3g_decryption_with_digest_test_case_1(void)
7286 {
7287 	int ret;
7288 	struct snow3g_hash_test_data snow3g_hash_data;
7289 	struct rte_cryptodev_info dev_info;
7290 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7291 
7292 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7293 	uint64_t feat_flags = dev_info.feature_flags;
7294 
7295 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7296 		printf("Device doesn't support encrypted digest operations.\n");
7297 		return TEST_SKIPPED;
7298 	}
7299 
7300 	/*
7301 	 * Function prepare data for hash verification test case.
7302 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
7303 	 */
7304 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7305 
7306 	ret = test_snow3g_decryption(&snow3g_test_case_7);
7307 	if (ret != 0)
7308 		return ret;
7309 
7310 	return test_snow3g_authentication_verify(&snow3g_hash_data);
7311 }
7312 
7313 static int
7314 test_snow3g_cipher_auth_test_case_1(void)
7315 {
7316 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
7317 }
7318 
7319 static int
7320 test_snow3g_auth_cipher_test_case_1(void)
7321 {
7322 	return test_snow3g_auth_cipher(
7323 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7324 }
7325 
7326 static int
7327 test_snow3g_auth_cipher_test_case_2(void)
7328 {
7329 	return test_snow3g_auth_cipher(
7330 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7331 }
7332 
7333 static int
7334 test_snow3g_auth_cipher_test_case_2_oop(void)
7335 {
7336 	return test_snow3g_auth_cipher(
7337 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7338 }
7339 
7340 static int
7341 test_snow3g_auth_cipher_part_digest_enc(void)
7342 {
7343 	return test_snow3g_auth_cipher(
7344 		&snow3g_auth_cipher_partial_digest_encryption,
7345 			IN_PLACE, 0);
7346 }
7347 
7348 static int
7349 test_snow3g_auth_cipher_part_digest_enc_oop(void)
7350 {
7351 	return test_snow3g_auth_cipher(
7352 		&snow3g_auth_cipher_partial_digest_encryption,
7353 			OUT_OF_PLACE, 0);
7354 }
7355 
7356 static int
7357 test_snow3g_auth_cipher_test_case_3_sgl(void)
7358 {
7359 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7360 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7361 		return TEST_SKIPPED;
7362 	return test_snow3g_auth_cipher_sgl(
7363 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7364 }
7365 
7366 static int
7367 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7368 {
7369 	return test_snow3g_auth_cipher_sgl(
7370 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7371 }
7372 
7373 static int
7374 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7375 {
7376 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7377 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7378 		return TEST_SKIPPED;
7379 	return test_snow3g_auth_cipher_sgl(
7380 		&snow3g_auth_cipher_partial_digest_encryption,
7381 			IN_PLACE, 0);
7382 }
7383 
7384 static int
7385 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7386 {
7387 	return test_snow3g_auth_cipher_sgl(
7388 		&snow3g_auth_cipher_partial_digest_encryption,
7389 			OUT_OF_PLACE, 0);
7390 }
7391 
7392 static int
7393 test_snow3g_auth_cipher_total_digest_enc_1(void)
7394 {
7395 	return test_snow3g_auth_cipher(
7396 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7397 }
7398 
7399 static int
7400 test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7401 {
7402 	return test_snow3g_auth_cipher(
7403 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7404 }
7405 
7406 static int
7407 test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7408 {
7409 	return test_snow3g_auth_cipher_sgl(
7410 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7411 }
7412 
7413 static int
7414 test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7415 {
7416 	return test_snow3g_auth_cipher_sgl(
7417 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7418 }
7419 
7420 static int
7421 test_snow3g_auth_cipher_verify_test_case_1(void)
7422 {
7423 	return test_snow3g_auth_cipher(
7424 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7425 }
7426 
7427 static int
7428 test_snow3g_auth_cipher_verify_test_case_2(void)
7429 {
7430 	return test_snow3g_auth_cipher(
7431 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7432 }
7433 
7434 static int
7435 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7436 {
7437 	return test_snow3g_auth_cipher(
7438 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7439 }
7440 
7441 static int
7442 test_snow3g_auth_cipher_verify_part_digest_enc(void)
7443 {
7444 	return test_snow3g_auth_cipher(
7445 		&snow3g_auth_cipher_partial_digest_encryption,
7446 			IN_PLACE, 1);
7447 }
7448 
7449 static int
7450 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7451 {
7452 	return test_snow3g_auth_cipher(
7453 		&snow3g_auth_cipher_partial_digest_encryption,
7454 			OUT_OF_PLACE, 1);
7455 }
7456 
7457 static int
7458 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7459 {
7460 	return test_snow3g_auth_cipher_sgl(
7461 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7462 }
7463 
7464 static int
7465 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7466 {
7467 	return test_snow3g_auth_cipher_sgl(
7468 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7469 }
7470 
7471 static int
7472 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7473 {
7474 	return test_snow3g_auth_cipher_sgl(
7475 		&snow3g_auth_cipher_partial_digest_encryption,
7476 			IN_PLACE, 1);
7477 }
7478 
7479 static int
7480 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7481 {
7482 	return test_snow3g_auth_cipher_sgl(
7483 		&snow3g_auth_cipher_partial_digest_encryption,
7484 			OUT_OF_PLACE, 1);
7485 }
7486 
7487 static int
7488 test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7489 {
7490 	return test_snow3g_auth_cipher(
7491 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7492 }
7493 
7494 static int
7495 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7496 {
7497 	return test_snow3g_auth_cipher(
7498 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7499 }
7500 
7501 static int
7502 test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7503 {
7504 	return test_snow3g_auth_cipher_sgl(
7505 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7506 }
7507 
7508 static int
7509 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7510 {
7511 	return test_snow3g_auth_cipher_sgl(
7512 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7513 }
7514 
7515 static int
7516 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7517 {
7518 	return test_snow3g_auth_cipher(
7519 		&snow3g_test_case_7, IN_PLACE, 0);
7520 }
7521 
7522 static int
7523 test_kasumi_auth_cipher_test_case_1(void)
7524 {
7525 	return test_kasumi_auth_cipher(
7526 		&kasumi_test_case_3, IN_PLACE, 0);
7527 }
7528 
7529 static int
7530 test_kasumi_auth_cipher_test_case_2(void)
7531 {
7532 	return test_kasumi_auth_cipher(
7533 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7534 }
7535 
7536 static int
7537 test_kasumi_auth_cipher_test_case_2_oop(void)
7538 {
7539 	return test_kasumi_auth_cipher(
7540 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7541 }
7542 
7543 static int
7544 test_kasumi_auth_cipher_test_case_2_sgl(void)
7545 {
7546 	return test_kasumi_auth_cipher_sgl(
7547 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7548 }
7549 
7550 static int
7551 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7552 {
7553 	return test_kasumi_auth_cipher_sgl(
7554 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7555 }
7556 
7557 static int
7558 test_kasumi_auth_cipher_verify_test_case_1(void)
7559 {
7560 	return test_kasumi_auth_cipher(
7561 		&kasumi_test_case_3, IN_PLACE, 1);
7562 }
7563 
7564 static int
7565 test_kasumi_auth_cipher_verify_test_case_2(void)
7566 {
7567 	return test_kasumi_auth_cipher(
7568 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7569 }
7570 
7571 static int
7572 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7573 {
7574 	return test_kasumi_auth_cipher(
7575 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7576 }
7577 
7578 static int
7579 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7580 {
7581 	return test_kasumi_auth_cipher_sgl(
7582 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7583 }
7584 
7585 static int
7586 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7587 {
7588 	return test_kasumi_auth_cipher_sgl(
7589 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7590 }
7591 
7592 static int
7593 test_kasumi_cipher_auth_test_case_1(void)
7594 {
7595 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7596 }
7597 
7598 static int
7599 test_zuc_encryption_test_case_1(void)
7600 {
7601 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7602 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7603 }
7604 
7605 static int
7606 test_zuc_encryption_test_case_2(void)
7607 {
7608 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7609 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7610 }
7611 
7612 static int
7613 test_zuc_encryption_test_case_3(void)
7614 {
7615 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7616 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7617 }
7618 
7619 static int
7620 test_zuc_encryption_test_case_4(void)
7621 {
7622 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7623 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7624 }
7625 
7626 static int
7627 test_zuc_encryption_test_case_5(void)
7628 {
7629 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7630 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7631 }
7632 
7633 static int
7634 test_zuc_encryption_test_case_6_sgl(void)
7635 {
7636 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7637 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7638 }
7639 
7640 static int
7641 test_zuc_decryption_test_case_1(void)
7642 {
7643 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7644 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7645 }
7646 
7647 static int
7648 test_zuc_decryption_test_case_2(void)
7649 {
7650 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7651 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7652 }
7653 
7654 static int
7655 test_zuc_decryption_test_case_3(void)
7656 {
7657 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7658 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7659 }
7660 
7661 static int
7662 test_zuc_decryption_test_case_4(void)
7663 {
7664 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7665 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7666 }
7667 
7668 static int
7669 test_zuc_decryption_test_case_5(void)
7670 {
7671 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7672 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7673 }
7674 
7675 static int
7676 test_zuc_decryption_test_case_6_sgl(void)
7677 {
7678 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7679 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7680 }
7681 
7682 static int
7683 test_zuc_hash_generate_test_case_1(void)
7684 {
7685 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7686 			RTE_CRYPTO_AUTH_OP_GENERATE);
7687 }
7688 
7689 static int
7690 test_zuc_hash_generate_test_case_2(void)
7691 {
7692 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7693 			RTE_CRYPTO_AUTH_OP_GENERATE);
7694 }
7695 
7696 static int
7697 test_zuc_hash_generate_test_case_3(void)
7698 {
7699 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7700 			RTE_CRYPTO_AUTH_OP_GENERATE);
7701 }
7702 
7703 static int
7704 test_zuc_hash_generate_test_case_4(void)
7705 {
7706 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7707 			RTE_CRYPTO_AUTH_OP_GENERATE);
7708 }
7709 
7710 static int
7711 test_zuc_hash_generate_test_case_5(void)
7712 {
7713 	return test_zuc_authentication(&zuc_test_auth_5670b,
7714 			RTE_CRYPTO_AUTH_OP_GENERATE);
7715 }
7716 
7717 static int
7718 test_zuc_hash_generate_test_case_6(void)
7719 {
7720 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7721 			RTE_CRYPTO_AUTH_OP_GENERATE);
7722 }
7723 
7724 static int
7725 test_zuc_hash_generate_test_case_7(void)
7726 {
7727 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7728 			RTE_CRYPTO_AUTH_OP_GENERATE);
7729 }
7730 
7731 static int
7732 test_zuc_hash_generate_test_case_8(void)
7733 {
7734 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7735 			RTE_CRYPTO_AUTH_OP_GENERATE);
7736 }
7737 
7738 static int
7739 test_zuc_hash_verify_test_case_1(void)
7740 {
7741 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7742 			RTE_CRYPTO_AUTH_OP_VERIFY);
7743 }
7744 
7745 static int
7746 test_zuc_hash_verify_test_case_2(void)
7747 {
7748 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7749 			RTE_CRYPTO_AUTH_OP_VERIFY);
7750 }
7751 
7752 static int
7753 test_zuc_hash_verify_test_case_3(void)
7754 {
7755 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7756 			RTE_CRYPTO_AUTH_OP_VERIFY);
7757 }
7758 
7759 static int
7760 test_zuc_hash_verify_test_case_4(void)
7761 {
7762 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7763 			RTE_CRYPTO_AUTH_OP_VERIFY);
7764 }
7765 
7766 static int
7767 test_zuc_hash_verify_test_case_5(void)
7768 {
7769 	return test_zuc_authentication(&zuc_test_auth_5670b,
7770 			RTE_CRYPTO_AUTH_OP_VERIFY);
7771 }
7772 
7773 static int
7774 test_zuc_hash_verify_test_case_6(void)
7775 {
7776 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7777 			RTE_CRYPTO_AUTH_OP_VERIFY);
7778 }
7779 
7780 static int
7781 test_zuc_hash_verify_test_case_7(void)
7782 {
7783 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7784 			RTE_CRYPTO_AUTH_OP_VERIFY);
7785 }
7786 
7787 static int
7788 test_zuc_hash_verify_test_case_8(void)
7789 {
7790 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7791 			RTE_CRYPTO_AUTH_OP_VERIFY);
7792 }
7793 
7794 static int
7795 test_zuc_cipher_auth_test_case_1(void)
7796 {
7797 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7798 }
7799 
7800 static int
7801 test_zuc_cipher_auth_test_case_2(void)
7802 {
7803 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7804 }
7805 
7806 static int
7807 test_zuc_auth_cipher_test_case_1(void)
7808 {
7809 	return test_zuc_auth_cipher(
7810 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7811 }
7812 
7813 static int
7814 test_zuc_auth_cipher_test_case_1_oop(void)
7815 {
7816 	return test_zuc_auth_cipher(
7817 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7818 }
7819 
7820 static int
7821 test_zuc_auth_cipher_test_case_1_sgl(void)
7822 {
7823 	return test_zuc_auth_cipher_sgl(
7824 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7825 }
7826 
7827 static int
7828 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7829 {
7830 	return test_zuc_auth_cipher_sgl(
7831 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7832 }
7833 
7834 static int
7835 test_zuc_auth_cipher_test_case_2(void)
7836 {
7837 	return test_zuc_auth_cipher(
7838 		&zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7839 }
7840 
7841 static int
7842 test_zuc_auth_cipher_test_case_2_oop(void)
7843 {
7844 	return test_zuc_auth_cipher(
7845 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7846 }
7847 
7848 static int
7849 test_zuc_auth_cipher_verify_test_case_1(void)
7850 {
7851 	return test_zuc_auth_cipher(
7852 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7853 }
7854 
7855 static int
7856 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7857 {
7858 	return test_zuc_auth_cipher(
7859 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7860 }
7861 
7862 static int
7863 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7864 {
7865 	return test_zuc_auth_cipher_sgl(
7866 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7867 }
7868 
7869 static int
7870 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7871 {
7872 	return test_zuc_auth_cipher_sgl(
7873 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7874 }
7875 
7876 static int
7877 test_zuc_auth_cipher_verify_test_case_2(void)
7878 {
7879 	return test_zuc_auth_cipher(
7880 		&zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7881 }
7882 
7883 static int
7884 test_zuc_auth_cipher_verify_test_case_2_oop(void)
7885 {
7886 	return test_zuc_auth_cipher(
7887 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7888 }
7889 
7890 static int
7891 test_zuc256_encryption_test_case_1(void)
7892 {
7893 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7894 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7895 }
7896 
7897 static int
7898 test_zuc256_encryption_test_case_2(void)
7899 {
7900 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7901 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7902 }
7903 
7904 static int
7905 test_zuc256_decryption_test_case_1(void)
7906 {
7907 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7908 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7909 }
7910 
7911 static int
7912 test_zuc256_decryption_test_case_2(void)
7913 {
7914 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7915 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7916 }
7917 
7918 static int
7919 test_zuc256_hash_generate_4b_tag_test_case_1(void)
7920 {
7921 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7922 			RTE_CRYPTO_AUTH_OP_GENERATE);
7923 }
7924 
7925 static int
7926 test_zuc256_hash_generate_4b_tag_test_case_2(void)
7927 {
7928 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7929 			RTE_CRYPTO_AUTH_OP_GENERATE);
7930 }
7931 
7932 static int
7933 test_zuc256_hash_generate_4b_tag_test_case_3(void)
7934 {
7935 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7936 			RTE_CRYPTO_AUTH_OP_GENERATE);
7937 }
7938 
7939 static int
7940 test_zuc256_hash_generate_8b_tag_test_case_1(void)
7941 {
7942 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7943 			RTE_CRYPTO_AUTH_OP_GENERATE);
7944 }
7945 
7946 static int
7947 test_zuc256_hash_generate_16b_tag_test_case_1(void)
7948 {
7949 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7950 			RTE_CRYPTO_AUTH_OP_GENERATE);
7951 }
7952 
7953 static int
7954 test_zuc256_hash_verify_4b_tag_test_case_1(void)
7955 {
7956 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7957 			RTE_CRYPTO_AUTH_OP_VERIFY);
7958 }
7959 
7960 static int
7961 test_zuc256_hash_verify_4b_tag_test_case_2(void)
7962 {
7963 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7964 			RTE_CRYPTO_AUTH_OP_VERIFY);
7965 }
7966 
7967 static int
7968 test_zuc256_hash_verify_4b_tag_test_case_3(void)
7969 {
7970 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7971 			RTE_CRYPTO_AUTH_OP_VERIFY);
7972 }
7973 
7974 static int
7975 test_zuc256_hash_verify_8b_tag_test_case_1(void)
7976 {
7977 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7978 			RTE_CRYPTO_AUTH_OP_VERIFY);
7979 }
7980 
7981 static int
7982 test_zuc256_hash_verify_16b_tag_test_case_1(void)
7983 {
7984 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7985 			RTE_CRYPTO_AUTH_OP_VERIFY);
7986 }
7987 
7988 static int
7989 test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7990 {
7991 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7992 }
7993 
7994 static int
7995 test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7996 {
7997 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7998 }
7999 
8000 static int
8001 test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8002 {
8003 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8004 }
8005 
8006 static int
8007 test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8008 {
8009 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8010 }
8011 
8012 static int
8013 test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8014 {
8015 	return test_zuc_auth_cipher(
8016 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8017 }
8018 
8019 static int
8020 test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8021 {
8022 	return test_zuc_auth_cipher(
8023 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8024 }
8025 
8026 static int
8027 test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8028 {
8029 	return test_zuc_auth_cipher(
8030 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8031 }
8032 
8033 static int
8034 test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8035 {
8036 	return test_zuc_auth_cipher(
8037 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8038 }
8039 
8040 static int
8041 test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8042 {
8043 	return test_zuc_auth_cipher(
8044 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8045 }
8046 
8047 static int
8048 test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8049 {
8050 	return test_zuc_auth_cipher(
8051 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8052 }
8053 
8054 static int
8055 test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8056 {
8057 	return test_zuc_auth_cipher(
8058 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8059 }
8060 
8061 static int
8062 test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8063 {
8064 	return test_zuc_auth_cipher(
8065 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8066 }
8067 
8068 static int
8069 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8070 {
8071 	uint8_t dev_id = testsuite_params.valid_devs[0];
8072 
8073 	struct rte_cryptodev_sym_capability_idx cap_idx;
8074 
8075 	/* Check if device supports particular cipher algorithm */
8076 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8077 	cap_idx.algo.cipher = tdata->cipher_algo;
8078 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8079 		return TEST_SKIPPED;
8080 
8081 	/* Check if device supports particular hash algorithm */
8082 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8083 	cap_idx.algo.auth = tdata->auth_algo;
8084 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8085 		return TEST_SKIPPED;
8086 
8087 	return 0;
8088 }
8089 
8090 static int
8091 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8092 	uint8_t op_mode, uint8_t verify)
8093 {
8094 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8095 	struct crypto_unittest_params *ut_params = &unittest_params;
8096 
8097 	int retval;
8098 
8099 	uint8_t *plaintext = NULL, *ciphertext = NULL;
8100 	unsigned int plaintext_pad_len;
8101 	unsigned int plaintext_len;
8102 	unsigned int ciphertext_pad_len;
8103 	unsigned int ciphertext_len;
8104 	unsigned int digest_offset;
8105 
8106 	struct rte_cryptodev_info dev_info;
8107 	struct rte_crypto_op *op;
8108 
8109 	/* Check if device supports particular algorithms separately */
8110 	if (test_mixed_check_if_unsupported(tdata))
8111 		return TEST_SKIPPED;
8112 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8113 		return TEST_SKIPPED;
8114 
8115 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8116 		return TEST_SKIPPED;
8117 
8118 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8119 
8120 	uint64_t feat_flags = dev_info.feature_flags;
8121 
8122 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8123 		printf("Device doesn't support digest encrypted.\n");
8124 		return TEST_SKIPPED;
8125 	}
8126 
8127 	/* Create the session */
8128 	if (verify)
8129 		retval = create_wireless_algo_cipher_auth_session(
8130 				ts_params->valid_devs[0],
8131 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8132 				RTE_CRYPTO_AUTH_OP_VERIFY,
8133 				tdata->auth_algo,
8134 				tdata->cipher_algo,
8135 				tdata->auth_key.data, tdata->auth_key.len,
8136 				tdata->cipher_key.data, tdata->cipher_key.len,
8137 				tdata->auth_iv.len, tdata->digest_enc.len,
8138 				tdata->cipher_iv.len);
8139 	else
8140 		retval = create_wireless_algo_auth_cipher_session(
8141 				ts_params->valid_devs[0],
8142 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8143 				RTE_CRYPTO_AUTH_OP_GENERATE,
8144 				tdata->auth_algo,
8145 				tdata->cipher_algo,
8146 				tdata->auth_key.data, tdata->auth_key.len,
8147 				tdata->cipher_key.data, tdata->cipher_key.len,
8148 				tdata->auth_iv.len, tdata->digest_enc.len,
8149 				tdata->cipher_iv.len);
8150 	if (retval != 0)
8151 		return retval;
8152 
8153 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8154 	if (op_mode == OUT_OF_PLACE)
8155 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8156 
8157 	/* clear mbuf payload */
8158 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8159 		rte_pktmbuf_tailroom(ut_params->ibuf));
8160 	if (op_mode == OUT_OF_PLACE) {
8161 
8162 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8163 				rte_pktmbuf_tailroom(ut_params->obuf));
8164 	}
8165 
8166 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8167 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8168 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8169 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8170 
8171 	if (verify) {
8172 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8173 				ciphertext_pad_len);
8174 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8175 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8176 				ciphertext_len);
8177 	} else {
8178 		/* make sure enough space to cover partial digest verify case */
8179 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8180 				ciphertext_pad_len);
8181 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8182 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8183 	}
8184 
8185 	if (op_mode == OUT_OF_PLACE)
8186 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8187 
8188 	/* Create the operation */
8189 	retval = create_wireless_algo_auth_cipher_operation(
8190 			tdata->digest_enc.data, tdata->digest_enc.len,
8191 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8192 			tdata->auth_iv.data, tdata->auth_iv.len,
8193 			(tdata->digest_enc.offset == 0 ?
8194 				plaintext_pad_len
8195 				: tdata->digest_enc.offset),
8196 			tdata->validCipherLen.len_bits,
8197 			tdata->cipher.offset_bits,
8198 			tdata->validAuthLen.len_bits,
8199 			tdata->auth.offset_bits,
8200 			op_mode, 0, verify);
8201 
8202 	if (retval < 0)
8203 		return retval;
8204 
8205 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8206 
8207 	/* Check if the op failed because the device doesn't */
8208 	/* support this particular combination of algorithms */
8209 	if (op == NULL && ut_params->op->status ==
8210 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8211 		printf("Device doesn't support this mixed combination. "
8212 				"Test Skipped.\n");
8213 		return TEST_SKIPPED;
8214 	}
8215 	ut_params->op = op;
8216 
8217 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8218 
8219 	ut_params->obuf = (op_mode == IN_PLACE ?
8220 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8221 
8222 	if (verify) {
8223 		if (ut_params->obuf)
8224 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8225 							uint8_t *);
8226 		else
8227 			plaintext = ciphertext +
8228 					(tdata->cipher.offset_bits >> 3);
8229 
8230 		debug_hexdump(stdout, "plaintext:", plaintext,
8231 				tdata->plaintext.len_bits >> 3);
8232 		debug_hexdump(stdout, "plaintext expected:",
8233 				tdata->plaintext.data,
8234 				tdata->plaintext.len_bits >> 3);
8235 	} else {
8236 		if (ut_params->obuf)
8237 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8238 					uint8_t *);
8239 		else
8240 			ciphertext = plaintext;
8241 
8242 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8243 				ciphertext_len);
8244 		debug_hexdump(stdout, "ciphertext expected:",
8245 				tdata->ciphertext.data,
8246 				tdata->ciphertext.len_bits >> 3);
8247 
8248 		if (tdata->digest_enc.offset == 0)
8249 			digest_offset = plaintext_pad_len;
8250 		else
8251 			digest_offset = tdata->digest_enc.offset;
8252 
8253 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8254 					    uint8_t *, digest_offset);
8255 
8256 		debug_hexdump(stdout, "digest:", ut_params->digest,
8257 				tdata->digest_enc.len);
8258 		debug_hexdump(stdout, "digest expected:",
8259 				tdata->digest_enc.data,
8260 				tdata->digest_enc.len);
8261 	}
8262 
8263 	if (!verify) {
8264 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8265 				ut_params->digest,
8266 				tdata->digest_enc.data,
8267 				tdata->digest_enc.len,
8268 				"Generated auth tag not as expected");
8269 	}
8270 
8271 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8272 		if (verify) {
8273 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8274 					plaintext,
8275 					tdata->plaintext.data,
8276 					tdata->plaintext.len_bits >> 3,
8277 					"Plaintext data not as expected");
8278 		} else {
8279 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8280 					ciphertext,
8281 					tdata->ciphertext.data,
8282 					tdata->validDataLen.len_bits,
8283 					"Ciphertext data not as expected");
8284 		}
8285 	}
8286 
8287 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8288 			"crypto op processing failed");
8289 
8290 	return 0;
8291 }
8292 
8293 static int
8294 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8295 	uint8_t op_mode, uint8_t verify)
8296 {
8297 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8298 	struct crypto_unittest_params *ut_params = &unittest_params;
8299 
8300 	int retval;
8301 
8302 	const uint8_t *plaintext = NULL;
8303 	const uint8_t *ciphertext = NULL;
8304 	const uint8_t *digest = NULL;
8305 	unsigned int plaintext_pad_len;
8306 	unsigned int plaintext_len;
8307 	unsigned int ciphertext_pad_len;
8308 	unsigned int ciphertext_len;
8309 	uint8_t buffer[10000];
8310 	uint8_t digest_buffer[10000];
8311 
8312 	struct rte_cryptodev_info dev_info;
8313 	struct rte_crypto_op *op;
8314 
8315 	/* Check if device supports particular algorithms */
8316 	if (test_mixed_check_if_unsupported(tdata))
8317 		return TEST_SKIPPED;
8318 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8319 		return TEST_SKIPPED;
8320 
8321 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8322 
8323 	uint64_t feat_flags = dev_info.feature_flags;
8324 
8325 	if (op_mode == IN_PLACE) {
8326 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8327 			printf("Device doesn't support in-place scatter-gather "
8328 					"in both input and output mbufs.\n");
8329 			return TEST_SKIPPED;
8330 		}
8331 	} else {
8332 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8333 			printf("Device doesn't support out-of-place scatter-gather "
8334 					"in both input and output mbufs.\n");
8335 			return TEST_SKIPPED;
8336 		}
8337 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8338 			printf("Device doesn't support digest encrypted.\n");
8339 			return TEST_SKIPPED;
8340 		}
8341 	}
8342 
8343 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8344 		return TEST_SKIPPED;
8345 
8346 	/* Create the session */
8347 	if (verify)
8348 		retval = create_wireless_algo_cipher_auth_session(
8349 				ts_params->valid_devs[0],
8350 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8351 				RTE_CRYPTO_AUTH_OP_VERIFY,
8352 				tdata->auth_algo,
8353 				tdata->cipher_algo,
8354 				tdata->auth_key.data, tdata->auth_key.len,
8355 				tdata->cipher_key.data, tdata->cipher_key.len,
8356 				tdata->auth_iv.len, tdata->digest_enc.len,
8357 				tdata->cipher_iv.len);
8358 	else
8359 		retval = create_wireless_algo_auth_cipher_session(
8360 				ts_params->valid_devs[0],
8361 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8362 				RTE_CRYPTO_AUTH_OP_GENERATE,
8363 				tdata->auth_algo,
8364 				tdata->cipher_algo,
8365 				tdata->auth_key.data, tdata->auth_key.len,
8366 				tdata->cipher_key.data, tdata->cipher_key.len,
8367 				tdata->auth_iv.len, tdata->digest_enc.len,
8368 				tdata->cipher_iv.len);
8369 	if (retval != 0)
8370 		return retval;
8371 
8372 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8373 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8374 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8375 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8376 
8377 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8378 			ciphertext_pad_len, 15, 0);
8379 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8380 			"Failed to allocate input buffer in mempool");
8381 
8382 	if (op_mode == OUT_OF_PLACE) {
8383 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8384 				plaintext_pad_len, 15, 0);
8385 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
8386 				"Failed to allocate output buffer in mempool");
8387 	}
8388 
8389 	if (verify) {
8390 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8391 			tdata->ciphertext.data);
8392 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8393 					ciphertext_len, buffer);
8394 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8395 			ciphertext_len);
8396 	} else {
8397 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8398 			tdata->plaintext.data);
8399 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8400 					plaintext_len, buffer);
8401 		debug_hexdump(stdout, "plaintext:", plaintext,
8402 			plaintext_len);
8403 	}
8404 	memset(buffer, 0, sizeof(buffer));
8405 
8406 	/* Create the operation */
8407 	retval = create_wireless_algo_auth_cipher_operation(
8408 			tdata->digest_enc.data, tdata->digest_enc.len,
8409 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8410 			tdata->auth_iv.data, tdata->auth_iv.len,
8411 			(tdata->digest_enc.offset == 0 ?
8412 				plaintext_pad_len
8413 				: tdata->digest_enc.offset),
8414 			tdata->validCipherLen.len_bits,
8415 			tdata->cipher.offset_bits,
8416 			tdata->validAuthLen.len_bits,
8417 			tdata->auth.offset_bits,
8418 			op_mode, 1, verify);
8419 
8420 	if (retval < 0)
8421 		return retval;
8422 
8423 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8424 
8425 	/* Check if the op failed because the device doesn't */
8426 	/* support this particular combination of algorithms */
8427 	if (op == NULL && ut_params->op->status ==
8428 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8429 		printf("Device doesn't support this mixed combination. "
8430 				"Test Skipped.\n");
8431 		return TEST_SKIPPED;
8432 	}
8433 	ut_params->op = op;
8434 
8435 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8436 
8437 	ut_params->obuf = (op_mode == IN_PLACE ?
8438 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8439 
8440 	if (verify) {
8441 		if (ut_params->obuf)
8442 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8443 					plaintext_len, buffer);
8444 		else
8445 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8446 					plaintext_len, buffer);
8447 
8448 		debug_hexdump(stdout, "plaintext:", plaintext,
8449 				(tdata->plaintext.len_bits >> 3) -
8450 				tdata->digest_enc.len);
8451 		debug_hexdump(stdout, "plaintext expected:",
8452 				tdata->plaintext.data,
8453 				(tdata->plaintext.len_bits >> 3) -
8454 				tdata->digest_enc.len);
8455 	} else {
8456 		if (ut_params->obuf)
8457 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8458 					ciphertext_len, buffer);
8459 		else
8460 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8461 					ciphertext_len, buffer);
8462 
8463 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8464 			ciphertext_len);
8465 		debug_hexdump(stdout, "ciphertext expected:",
8466 			tdata->ciphertext.data,
8467 			tdata->ciphertext.len_bits >> 3);
8468 
8469 		if (ut_params->obuf)
8470 			digest = rte_pktmbuf_read(ut_params->obuf,
8471 					(tdata->digest_enc.offset == 0 ?
8472 						plaintext_pad_len :
8473 						tdata->digest_enc.offset),
8474 					tdata->digest_enc.len, digest_buffer);
8475 		else
8476 			digest = rte_pktmbuf_read(ut_params->ibuf,
8477 					(tdata->digest_enc.offset == 0 ?
8478 						plaintext_pad_len :
8479 						tdata->digest_enc.offset),
8480 					tdata->digest_enc.len, digest_buffer);
8481 
8482 		debug_hexdump(stdout, "digest:", digest,
8483 				tdata->digest_enc.len);
8484 		debug_hexdump(stdout, "digest expected:",
8485 				tdata->digest_enc.data, tdata->digest_enc.len);
8486 	}
8487 
8488 	if (!verify) {
8489 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8490 				digest,
8491 				tdata->digest_enc.data,
8492 				tdata->digest_enc.len,
8493 				"Generated auth tag not as expected");
8494 	}
8495 
8496 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8497 		if (verify) {
8498 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8499 					plaintext,
8500 					tdata->plaintext.data,
8501 					tdata->plaintext.len_bits >> 3,
8502 					"Plaintext data not as expected");
8503 		} else {
8504 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8505 					ciphertext,
8506 					tdata->ciphertext.data,
8507 					tdata->validDataLen.len_bits,
8508 					"Ciphertext data not as expected");
8509 		}
8510 	}
8511 
8512 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8513 			"crypto op processing failed");
8514 
8515 	return 0;
8516 }
8517 
8518 /** AUTH AES CMAC + CIPHER AES CTR */
8519 
8520 static int
8521 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8522 {
8523 	return test_mixed_auth_cipher(
8524 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8525 }
8526 
8527 static int
8528 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8529 {
8530 	return test_mixed_auth_cipher(
8531 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8532 }
8533 
8534 static int
8535 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8536 {
8537 	return test_mixed_auth_cipher_sgl(
8538 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8539 }
8540 
8541 static int
8542 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8543 {
8544 	return test_mixed_auth_cipher_sgl(
8545 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8546 }
8547 
8548 static int
8549 test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8550 {
8551 	return test_mixed_auth_cipher(
8552 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8553 }
8554 
8555 static int
8556 test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8557 {
8558 	return test_mixed_auth_cipher(
8559 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8560 }
8561 
8562 static int
8563 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8564 {
8565 	return test_mixed_auth_cipher(
8566 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8567 }
8568 
8569 static int
8570 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8571 {
8572 	return test_mixed_auth_cipher(
8573 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8574 }
8575 
8576 static int
8577 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8578 {
8579 	return test_mixed_auth_cipher(
8580 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8581 }
8582 
8583 static int
8584 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8585 {
8586 	return test_mixed_auth_cipher_sgl(
8587 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8588 }
8589 
8590 static int
8591 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8592 {
8593 	return test_mixed_auth_cipher_sgl(
8594 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8595 }
8596 
8597 static int
8598 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8599 {
8600 	return test_mixed_auth_cipher(
8601 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8602 }
8603 
8604 /** MIXED AUTH + CIPHER */
8605 
8606 static int
8607 test_auth_zuc_cipher_snow_test_case_1(void)
8608 {
8609 	return test_mixed_auth_cipher(
8610 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8611 }
8612 
8613 static int
8614 test_verify_auth_zuc_cipher_snow_test_case_1(void)
8615 {
8616 	return test_mixed_auth_cipher(
8617 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8618 }
8619 
8620 static int
8621 test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8622 {
8623 	return test_mixed_auth_cipher(
8624 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8625 }
8626 
8627 static int
8628 test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8629 {
8630 	return test_mixed_auth_cipher(
8631 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8632 }
8633 
8634 
8635 static int
8636 test_auth_aes_cmac_cipher_snow_test_case_1(void)
8637 {
8638 	return test_mixed_auth_cipher(
8639 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8640 }
8641 
8642 static int
8643 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8644 {
8645 	return test_mixed_auth_cipher(
8646 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8647 }
8648 
8649 static int
8650 test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8651 {
8652 	return test_mixed_auth_cipher(
8653 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8654 }
8655 
8656 static int
8657 test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8658 {
8659 	return test_mixed_auth_cipher(
8660 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8661 }
8662 
8663 static int
8664 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8665 {
8666 	return test_mixed_auth_cipher(
8667 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8668 }
8669 
8670 static int
8671 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8672 {
8673 	return test_mixed_auth_cipher(
8674 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8675 }
8676 
8677 static int
8678 test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8679 {
8680 	return test_mixed_auth_cipher(
8681 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8682 }
8683 
8684 static int
8685 test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8686 {
8687 	return test_mixed_auth_cipher(
8688 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8689 }
8690 
8691 static int
8692 test_auth_snow_cipher_aes_ctr_test_case_1(void)
8693 {
8694 	return test_mixed_auth_cipher(
8695 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8696 }
8697 
8698 static int
8699 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8700 {
8701 	return test_mixed_auth_cipher(
8702 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8703 }
8704 
8705 static int
8706 test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8707 {
8708 	return test_mixed_auth_cipher_sgl(
8709 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8710 }
8711 
8712 static int
8713 test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8714 {
8715 	return test_mixed_auth_cipher(
8716 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8717 }
8718 
8719 static int
8720 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8721 {
8722 	return test_mixed_auth_cipher_sgl(
8723 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8724 }
8725 
8726 static int
8727 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8728 {
8729 	return test_mixed_auth_cipher(
8730 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8731 }
8732 
8733 static int
8734 test_auth_snow_cipher_zuc_test_case_1(void)
8735 {
8736 	return test_mixed_auth_cipher(
8737 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8738 }
8739 
8740 static int
8741 test_verify_auth_snow_cipher_zuc_test_case_1(void)
8742 {
8743 	return test_mixed_auth_cipher(
8744 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8745 }
8746 
8747 static int
8748 test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8749 {
8750 	return test_mixed_auth_cipher(
8751 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8752 }
8753 
8754 static int
8755 test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8756 {
8757 	return test_mixed_auth_cipher(
8758 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8759 }
8760 
8761 static int
8762 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8763 {
8764 	return test_mixed_auth_cipher(
8765 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8766 }
8767 
8768 static int
8769 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8770 {
8771 	return test_mixed_auth_cipher(
8772 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8773 }
8774 static int
8775 test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8776 {
8777 	return test_mixed_auth_cipher(
8778 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8779 }
8780 
8781 static int
8782 test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8783 {
8784 	return test_mixed_auth_cipher(
8785 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8786 }
8787 
8788 static int
8789 test_auth_null_cipher_snow_test_case_1(void)
8790 {
8791 	return test_mixed_auth_cipher(
8792 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8793 }
8794 
8795 static int
8796 test_verify_auth_null_cipher_snow_test_case_1(void)
8797 {
8798 	return test_mixed_auth_cipher(
8799 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8800 }
8801 
8802 static int
8803 test_auth_null_cipher_zuc_test_case_1(void)
8804 {
8805 	return test_mixed_auth_cipher(
8806 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8807 }
8808 
8809 static int
8810 test_verify_auth_null_cipher_zuc_test_case_1(void)
8811 {
8812 	return test_mixed_auth_cipher(
8813 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8814 }
8815 
8816 static int
8817 test_auth_snow_cipher_null_test_case_1(void)
8818 {
8819 	return test_mixed_auth_cipher(
8820 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8821 }
8822 
8823 static int
8824 test_verify_auth_snow_cipher_null_test_case_1(void)
8825 {
8826 	return test_mixed_auth_cipher(
8827 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8828 }
8829 
8830 static int
8831 test_auth_zuc_cipher_null_test_case_1(void)
8832 {
8833 	return test_mixed_auth_cipher(
8834 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8835 }
8836 
8837 static int
8838 test_verify_auth_zuc_cipher_null_test_case_1(void)
8839 {
8840 	return test_mixed_auth_cipher(
8841 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8842 }
8843 
8844 static int
8845 test_auth_null_cipher_aes_ctr_test_case_1(void)
8846 {
8847 	return test_mixed_auth_cipher(
8848 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8849 }
8850 
8851 static int
8852 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8853 {
8854 	return test_mixed_auth_cipher(
8855 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8856 }
8857 
8858 static int
8859 test_auth_aes_cmac_cipher_null_test_case_1(void)
8860 {
8861 	return test_mixed_auth_cipher(
8862 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8863 }
8864 
8865 static int
8866 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8867 {
8868 	return test_mixed_auth_cipher(
8869 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8870 }
8871 
8872 /* ***** AEAD algorithm Tests ***** */
8873 
8874 static int
8875 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8876 		enum rte_crypto_aead_operation op,
8877 		const uint8_t *key, const uint8_t key_len,
8878 		const uint16_t aad_len, const uint8_t auth_len,
8879 		uint8_t iv_len)
8880 {
8881 	uint8_t aead_key[key_len];
8882 
8883 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8884 	struct crypto_unittest_params *ut_params = &unittest_params;
8885 
8886 	memcpy(aead_key, key, key_len);
8887 
8888 	/* Setup AEAD Parameters */
8889 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8890 	ut_params->aead_xform.next = NULL;
8891 	ut_params->aead_xform.aead.algo = algo;
8892 	ut_params->aead_xform.aead.op = op;
8893 	ut_params->aead_xform.aead.key.data = aead_key;
8894 	ut_params->aead_xform.aead.key.length = key_len;
8895 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8896 	ut_params->aead_xform.aead.iv.length = iv_len;
8897 	ut_params->aead_xform.aead.digest_length = auth_len;
8898 	ut_params->aead_xform.aead.aad_length = aad_len;
8899 
8900 	debug_hexdump(stdout, "key:", key, key_len);
8901 
8902 	/* Create Crypto session*/
8903 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8904 			&ut_params->aead_xform, ts_params->session_mpool);
8905 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8906 		return TEST_SKIPPED;
8907 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8908 	return 0;
8909 }
8910 
8911 static int
8912 create_aead_xform(struct rte_crypto_op *op,
8913 		enum rte_crypto_aead_algorithm algo,
8914 		enum rte_crypto_aead_operation aead_op,
8915 		uint8_t *key, const uint8_t key_len,
8916 		const uint8_t aad_len, const uint8_t auth_len,
8917 		uint8_t iv_len)
8918 {
8919 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8920 			"failed to allocate space for crypto transform");
8921 
8922 	struct rte_crypto_sym_op *sym_op = op->sym;
8923 
8924 	/* Setup AEAD Parameters */
8925 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8926 	sym_op->xform->next = NULL;
8927 	sym_op->xform->aead.algo = algo;
8928 	sym_op->xform->aead.op = aead_op;
8929 	sym_op->xform->aead.key.data = key;
8930 	sym_op->xform->aead.key.length = key_len;
8931 	sym_op->xform->aead.iv.offset = IV_OFFSET;
8932 	sym_op->xform->aead.iv.length = iv_len;
8933 	sym_op->xform->aead.digest_length = auth_len;
8934 	sym_op->xform->aead.aad_length = aad_len;
8935 
8936 	debug_hexdump(stdout, "key:", key, key_len);
8937 
8938 	return 0;
8939 }
8940 
8941 static int
8942 create_aead_operation(enum rte_crypto_aead_operation op,
8943 		const struct aead_test_data *tdata)
8944 {
8945 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8946 	struct crypto_unittest_params *ut_params = &unittest_params;
8947 
8948 	uint8_t *plaintext, *ciphertext;
8949 	unsigned int aad_pad_len, plaintext_pad_len;
8950 
8951 	/* Generate Crypto op data structure */
8952 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8953 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8954 	TEST_ASSERT_NOT_NULL(ut_params->op,
8955 			"Failed to allocate symmetric crypto operation struct");
8956 
8957 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8958 
8959 	/* Append aad data */
8960 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8961 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8962 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8963 				aad_pad_len);
8964 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8965 				"no room to append aad");
8966 
8967 		sym_op->aead.aad.phys_addr =
8968 				rte_pktmbuf_iova(ut_params->ibuf);
8969 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
8970 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8971 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8972 			tdata->aad.len);
8973 
8974 		/* Append IV at the end of the crypto operation*/
8975 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8976 				uint8_t *, IV_OFFSET);
8977 
8978 		/* Copy IV 1 byte after the IV pointer, according to the API */
8979 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8980 		debug_hexdump(stdout, "iv:", iv_ptr + 1,
8981 			tdata->iv.len);
8982 	} else {
8983 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8984 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8985 				aad_pad_len);
8986 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8987 				"no room to append aad");
8988 
8989 		sym_op->aead.aad.phys_addr =
8990 				rte_pktmbuf_iova(ut_params->ibuf);
8991 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8992 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8993 			tdata->aad.len);
8994 
8995 		/* Append IV at the end of the crypto operation*/
8996 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8997 				uint8_t *, IV_OFFSET);
8998 
8999 		if (tdata->iv.len == 0) {
9000 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9001 			debug_hexdump(stdout, "iv:", iv_ptr,
9002 				AES_GCM_J0_LENGTH);
9003 		} else {
9004 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9005 			debug_hexdump(stdout, "iv:", iv_ptr,
9006 				tdata->iv.len);
9007 		}
9008 	}
9009 
9010 	/* Append plaintext/ciphertext */
9011 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9012 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9013 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9014 				plaintext_pad_len);
9015 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9016 
9017 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9018 		debug_hexdump(stdout, "plaintext:", plaintext,
9019 				tdata->plaintext.len);
9020 
9021 		if (ut_params->obuf) {
9022 			ciphertext = (uint8_t *)rte_pktmbuf_append(
9023 					ut_params->obuf,
9024 					plaintext_pad_len + aad_pad_len);
9025 			TEST_ASSERT_NOT_NULL(ciphertext,
9026 					"no room to append ciphertext");
9027 
9028 			memset(ciphertext + aad_pad_len, 0,
9029 					tdata->ciphertext.len);
9030 		}
9031 	} else {
9032 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9033 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9034 				plaintext_pad_len);
9035 		TEST_ASSERT_NOT_NULL(ciphertext,
9036 				"no room to append ciphertext");
9037 
9038 		memcpy(ciphertext, tdata->ciphertext.data,
9039 				tdata->ciphertext.len);
9040 		debug_hexdump(stdout, "ciphertext:", ciphertext,
9041 				tdata->ciphertext.len);
9042 
9043 		if (ut_params->obuf) {
9044 			plaintext = (uint8_t *)rte_pktmbuf_append(
9045 					ut_params->obuf,
9046 					plaintext_pad_len + aad_pad_len);
9047 			TEST_ASSERT_NOT_NULL(plaintext,
9048 					"no room to append plaintext");
9049 
9050 			memset(plaintext + aad_pad_len, 0,
9051 					tdata->plaintext.len);
9052 		}
9053 	}
9054 
9055 	/* Append digest data */
9056 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9057 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9058 				ut_params->obuf ? ut_params->obuf :
9059 						ut_params->ibuf,
9060 						tdata->auth_tag.len);
9061 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9062 				"no room to append digest");
9063 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9064 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9065 				ut_params->obuf ? ut_params->obuf :
9066 						ut_params->ibuf,
9067 						plaintext_pad_len +
9068 						aad_pad_len);
9069 	} else {
9070 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9071 				ut_params->ibuf, tdata->auth_tag.len);
9072 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9073 				"no room to append digest");
9074 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9075 				ut_params->ibuf,
9076 				plaintext_pad_len + aad_pad_len);
9077 
9078 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9079 			tdata->auth_tag.len);
9080 		debug_hexdump(stdout, "digest:",
9081 			sym_op->aead.digest.data,
9082 			tdata->auth_tag.len);
9083 	}
9084 
9085 	sym_op->aead.data.length = tdata->plaintext.len;
9086 	sym_op->aead.data.offset = aad_pad_len;
9087 
9088 	return 0;
9089 }
9090 
9091 static int
9092 test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9093 {
9094 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9095 	struct crypto_unittest_params *ut_params = &unittest_params;
9096 
9097 	int retval;
9098 	uint8_t *ciphertext, *auth_tag;
9099 	uint16_t plaintext_pad_len;
9100 	uint32_t i;
9101 	struct rte_cryptodev_info dev_info;
9102 
9103 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9104 	uint64_t feat_flags = dev_info.feature_flags;
9105 
9106 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9107 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9108 		printf("Device doesn't support RAW data-path APIs.\n");
9109 		return TEST_SKIPPED;
9110 	}
9111 
9112 	/* Verify the capabilities */
9113 	struct rte_cryptodev_sym_capability_idx cap_idx;
9114 	const struct rte_cryptodev_symmetric_capability *capability;
9115 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9116 	cap_idx.algo.aead = tdata->algo;
9117 	capability = rte_cryptodev_sym_capability_get(
9118 			ts_params->valid_devs[0], &cap_idx);
9119 	if (capability == NULL)
9120 		return TEST_SKIPPED;
9121 	if (rte_cryptodev_sym_capability_check_aead(
9122 			capability, tdata->key.len, tdata->auth_tag.len,
9123 			tdata->aad.len, tdata->iv.len))
9124 		return TEST_SKIPPED;
9125 
9126 	/* Create AEAD session */
9127 	retval = create_aead_session(ts_params->valid_devs[0],
9128 			tdata->algo,
9129 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9130 			tdata->key.data, tdata->key.len,
9131 			tdata->aad.len, tdata->auth_tag.len,
9132 			tdata->iv.len);
9133 	if (retval != TEST_SUCCESS)
9134 		return retval;
9135 
9136 	if (tdata->aad.len > MBUF_SIZE) {
9137 		if (use_ext_mbuf) {
9138 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9139 							  AEAD_TEXT_MAX_LENGTH,
9140 							  1 /* nb_segs */,
9141 							  NULL);
9142 		} else {
9143 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9144 		}
9145 		/* Populate full size of add data */
9146 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9147 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9148 	} else {
9149 		if (use_ext_mbuf) {
9150 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9151 							  AEAD_TEXT_MAX_LENGTH,
9152 							  1 /* nb_segs */,
9153 							  NULL);
9154 		} else {
9155 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9156 		}
9157 	}
9158 
9159 	/* clear mbuf payload */
9160 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9161 			rte_pktmbuf_tailroom(ut_params->ibuf));
9162 
9163 	/* Create AEAD operation */
9164 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9165 	if (retval < 0)
9166 		return retval;
9167 
9168 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9169 
9170 	ut_params->op->sym->m_src = ut_params->ibuf;
9171 
9172 	/* Process crypto operation */
9173 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9174 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9175 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9176 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9177 					       0);
9178 		if (retval != TEST_SUCCESS)
9179 			return retval;
9180 	} else
9181 		TEST_ASSERT_NOT_NULL(
9182 			process_crypto_request(ts_params->valid_devs[0],
9183 			ut_params->op), "failed to process sym crypto op");
9184 
9185 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9186 			"crypto op processing failed");
9187 
9188 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9189 
9190 	if (ut_params->op->sym->m_dst) {
9191 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9192 				uint8_t *);
9193 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9194 				uint8_t *, plaintext_pad_len);
9195 	} else {
9196 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9197 				uint8_t *,
9198 				ut_params->op->sym->cipher.data.offset);
9199 		auth_tag = ciphertext + plaintext_pad_len;
9200 	}
9201 
9202 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9203 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9204 
9205 	/* Validate obuf */
9206 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9207 			ciphertext,
9208 			tdata->ciphertext.data,
9209 			tdata->ciphertext.len,
9210 			"Ciphertext data not as expected");
9211 
9212 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9213 			auth_tag,
9214 			tdata->auth_tag.data,
9215 			tdata->auth_tag.len,
9216 			"Generated auth tag not as expected");
9217 
9218 	return 0;
9219 
9220 }
9221 
9222 static int
9223 test_authenticated_encryption(const struct aead_test_data *tdata)
9224 {
9225 	return test_authenticated_encryption_helper(tdata, false);
9226 }
9227 
9228 #ifdef RTE_LIB_SECURITY
9229 static int
9230 security_proto_supported(enum rte_security_session_action_type action,
9231 	enum rte_security_session_protocol proto)
9232 {
9233 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9234 
9235 	const struct rte_security_capability *capabilities;
9236 	const struct rte_security_capability *capability;
9237 	uint16_t i = 0;
9238 
9239 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9240 
9241 
9242 	capabilities = rte_security_capabilities_get(ctx);
9243 
9244 	if (capabilities == NULL)
9245 		return -ENOTSUP;
9246 
9247 	while ((capability = &capabilities[i++])->action !=
9248 			RTE_SECURITY_ACTION_TYPE_NONE) {
9249 		if (capability->action == action &&
9250 				capability->protocol == proto)
9251 			return 0;
9252 	}
9253 
9254 	return -ENOTSUP;
9255 }
9256 
9257 /* Basic algorithm run function for async inplace mode.
9258  * Creates a session from input parameters and runs one operation
9259  * on input_vec. Checks the output of the crypto operation against
9260  * output_vec.
9261  */
9262 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9263 			   enum rte_crypto_auth_operation opa,
9264 			   const uint8_t *input_vec, unsigned int input_vec_len,
9265 			   const uint8_t *output_vec,
9266 			   unsigned int output_vec_len,
9267 			   enum rte_crypto_cipher_algorithm cipher_alg,
9268 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
9269 			   enum rte_crypto_auth_algorithm auth_alg,
9270 			   const uint8_t *auth_key, uint32_t auth_key_len,
9271 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
9272 			   uint8_t packet_direction, uint8_t sn_size,
9273 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9274 {
9275 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9276 	struct crypto_unittest_params *ut_params = &unittest_params;
9277 	uint8_t *plaintext;
9278 	int ret = TEST_SUCCESS;
9279 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9280 	struct rte_cryptodev_info dev_info;
9281 	uint64_t feat_flags;
9282 
9283 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9284 	feat_flags = dev_info.feature_flags;
9285 
9286 	/* Verify the capabilities */
9287 	struct rte_security_capability_idx sec_cap_idx;
9288 
9289 	sec_cap_idx.action = ut_params->type;
9290 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9291 	sec_cap_idx.pdcp.domain = domain;
9292 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9293 		return TEST_SKIPPED;
9294 
9295 	/* Generate test mbuf data */
9296 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9297 
9298 	/* clear mbuf payload */
9299 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9300 			rte_pktmbuf_tailroom(ut_params->ibuf));
9301 
9302 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9303 						  input_vec_len);
9304 	memcpy(plaintext, input_vec, input_vec_len);
9305 
9306 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9307 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9308 		printf("Device does not support RAW data-path APIs.\n");
9309 		return TEST_SKIPPED;
9310 	}
9311 	/* Out of place support */
9312 	if (oop) {
9313 		/*
9314 		 * For out-op-place we need to alloc another mbuf
9315 		 */
9316 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9317 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9318 	}
9319 
9320 	/* Setup Cipher Parameters */
9321 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9322 	ut_params->cipher_xform.cipher.algo = cipher_alg;
9323 	ut_params->cipher_xform.cipher.op = opc;
9324 	ut_params->cipher_xform.cipher.key.data = cipher_key;
9325 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9326 	ut_params->cipher_xform.cipher.iv.length =
9327 				packet_direction ? 4 : 0;
9328 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9329 
9330 	/* Setup HMAC Parameters if ICV header is required */
9331 	if (auth_alg != 0) {
9332 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9333 		ut_params->auth_xform.next = NULL;
9334 		ut_params->auth_xform.auth.algo = auth_alg;
9335 		ut_params->auth_xform.auth.op = opa;
9336 		ut_params->auth_xform.auth.key.data = auth_key;
9337 		ut_params->auth_xform.auth.key.length = auth_key_len;
9338 
9339 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9340 	} else {
9341 		ut_params->cipher_xform.next = NULL;
9342 	}
9343 
9344 	struct rte_security_session_conf sess_conf = {
9345 		.action_type = ut_params->type,
9346 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9347 		{.pdcp = {
9348 			.bearer = bearer,
9349 			.domain = domain,
9350 			.pkt_dir = packet_direction,
9351 			.sn_size = sn_size,
9352 			.hfn = packet_direction ? 0 : hfn,
9353 			/**
9354 			 * hfn can be set as pdcp_test_hfn[i]
9355 			 * if hfn_ovrd is not set. Here, PDCP
9356 			 * packet direction is just used to
9357 			 * run half of the cases with session
9358 			 * HFN and other half with per packet
9359 			 * HFN.
9360 			 */
9361 			.hfn_threshold = hfn_threshold,
9362 			.hfn_ovrd = packet_direction ? 1 : 0,
9363 			.sdap_enabled = sdap,
9364 		} },
9365 		.crypto_xform = &ut_params->cipher_xform
9366 	};
9367 
9368 	/* Create security session */
9369 	ut_params->sec_session = rte_security_session_create(ctx,
9370 				&sess_conf, ts_params->session_mpool);
9371 
9372 	if (!ut_params->sec_session) {
9373 		printf("TestCase %s()-%d line %d failed %s: ",
9374 			__func__, i, __LINE__, "Failed to allocate session");
9375 		ret = TEST_FAILED;
9376 		goto on_err;
9377 	}
9378 
9379 	/* Generate crypto op data structure */
9380 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9381 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9382 	if (!ut_params->op) {
9383 		printf("TestCase %s()-%d line %d failed %s: ",
9384 			__func__, i, __LINE__,
9385 			"Failed to allocate symmetric crypto operation struct");
9386 		ret = TEST_FAILED;
9387 		goto on_err;
9388 	}
9389 
9390 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9391 					uint32_t *, IV_OFFSET);
9392 	*per_pkt_hfn = packet_direction ? hfn : 0;
9393 
9394 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9395 
9396 	/* set crypto operation source mbuf */
9397 	ut_params->op->sym->m_src = ut_params->ibuf;
9398 	if (oop)
9399 		ut_params->op->sym->m_dst = ut_params->obuf;
9400 
9401 	/* Process crypto operation */
9402 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9403 		/* filling lengths */
9404 		ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9405 		ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9406 
9407 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9408 		if (ret != TEST_SUCCESS)
9409 			return ret;
9410 	} else {
9411 		ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9412 	}
9413 	if (ut_params->op == NULL) {
9414 		printf("TestCase %s()-%d line %d failed %s: ",
9415 			__func__, i, __LINE__,
9416 			"failed to process sym crypto op");
9417 		ret = TEST_FAILED;
9418 		goto on_err;
9419 	}
9420 
9421 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9422 		printf("TestCase %s()-%d line %d failed %s: ",
9423 			__func__, i, __LINE__, "crypto op processing failed");
9424 		ret = TEST_FAILED;
9425 		goto on_err;
9426 	}
9427 
9428 	/* Validate obuf */
9429 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9430 			uint8_t *);
9431 	if (oop) {
9432 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9433 				uint8_t *);
9434 	}
9435 
9436 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
9437 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9438 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9439 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9440 		ret = TEST_FAILED;
9441 		goto on_err;
9442 	}
9443 
9444 on_err:
9445 	rte_crypto_op_free(ut_params->op);
9446 	ut_params->op = NULL;
9447 
9448 	if (ut_params->sec_session)
9449 		rte_security_session_destroy(ctx, ut_params->sec_session);
9450 	ut_params->sec_session = NULL;
9451 
9452 	rte_pktmbuf_free(ut_params->ibuf);
9453 	ut_params->ibuf = NULL;
9454 	if (oop) {
9455 		rte_pktmbuf_free(ut_params->obuf);
9456 		ut_params->obuf = NULL;
9457 	}
9458 
9459 	return ret;
9460 }
9461 
9462 static int
9463 test_pdcp_proto_SGL(int i, int oop,
9464 	enum rte_crypto_cipher_operation opc,
9465 	enum rte_crypto_auth_operation opa,
9466 	uint8_t *input_vec,
9467 	unsigned int input_vec_len,
9468 	uint8_t *output_vec,
9469 	unsigned int output_vec_len,
9470 	uint32_t fragsz,
9471 	uint32_t fragsz_oop)
9472 {
9473 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9474 	struct crypto_unittest_params *ut_params = &unittest_params;
9475 	uint8_t *plaintext;
9476 	struct rte_mbuf *buf, *buf_oop = NULL;
9477 	int ret = TEST_SUCCESS;
9478 	int to_trn = 0;
9479 	int to_trn_tbl[16];
9480 	int segs = 1;
9481 	unsigned int trn_data = 0;
9482 	struct rte_cryptodev_info dev_info;
9483 	uint64_t feat_flags;
9484 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9485 	struct rte_mbuf *temp_mbuf;
9486 
9487 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9488 	feat_flags = dev_info.feature_flags;
9489 
9490 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9491 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9492 		printf("Device does not support RAW data-path APIs.\n");
9493 		return -ENOTSUP;
9494 	}
9495 	/* Verify the capabilities */
9496 	struct rte_security_capability_idx sec_cap_idx;
9497 
9498 	sec_cap_idx.action = ut_params->type;
9499 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9500 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9501 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9502 		return TEST_SKIPPED;
9503 
9504 	if (fragsz > input_vec_len)
9505 		fragsz = input_vec_len;
9506 
9507 	uint16_t plaintext_len = fragsz;
9508 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9509 
9510 	if (fragsz_oop > output_vec_len)
9511 		frag_size_oop = output_vec_len;
9512 
9513 	int ecx = 0;
9514 	if (input_vec_len % fragsz != 0) {
9515 		if (input_vec_len / fragsz + 1 > 16)
9516 			return 1;
9517 	} else if (input_vec_len / fragsz > 16)
9518 		return 1;
9519 
9520 	/* Out of place support */
9521 	if (oop) {
9522 		/*
9523 		 * For out-op-place we need to alloc another mbuf
9524 		 */
9525 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9526 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9527 		buf_oop = ut_params->obuf;
9528 	}
9529 
9530 	/* Generate test mbuf data */
9531 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9532 
9533 	/* clear mbuf payload */
9534 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9535 			rte_pktmbuf_tailroom(ut_params->ibuf));
9536 
9537 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9538 						  plaintext_len);
9539 	memcpy(plaintext, input_vec, plaintext_len);
9540 	trn_data += plaintext_len;
9541 
9542 	buf = ut_params->ibuf;
9543 
9544 	/*
9545 	 * Loop until no more fragments
9546 	 */
9547 
9548 	while (trn_data < input_vec_len) {
9549 		++segs;
9550 		to_trn = (input_vec_len - trn_data < fragsz) ?
9551 				(input_vec_len - trn_data) : fragsz;
9552 
9553 		to_trn_tbl[ecx++] = to_trn;
9554 
9555 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9556 		buf = buf->next;
9557 
9558 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9559 				rte_pktmbuf_tailroom(buf));
9560 
9561 		/* OOP */
9562 		if (oop && !fragsz_oop) {
9563 			buf_oop->next =
9564 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
9565 			buf_oop = buf_oop->next;
9566 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9567 					0, rte_pktmbuf_tailroom(buf_oop));
9568 			rte_pktmbuf_append(buf_oop, to_trn);
9569 		}
9570 
9571 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9572 				to_trn);
9573 
9574 		memcpy(plaintext, input_vec + trn_data, to_trn);
9575 		trn_data += to_trn;
9576 	}
9577 
9578 	ut_params->ibuf->nb_segs = segs;
9579 
9580 	segs = 1;
9581 	if (fragsz_oop && oop) {
9582 		to_trn = 0;
9583 		ecx = 0;
9584 
9585 		trn_data = frag_size_oop;
9586 		while (trn_data < output_vec_len) {
9587 			++segs;
9588 			to_trn =
9589 				(output_vec_len - trn_data <
9590 						frag_size_oop) ?
9591 				(output_vec_len - trn_data) :
9592 						frag_size_oop;
9593 
9594 			to_trn_tbl[ecx++] = to_trn;
9595 
9596 			buf_oop->next =
9597 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
9598 			buf_oop = buf_oop->next;
9599 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9600 					0, rte_pktmbuf_tailroom(buf_oop));
9601 			rte_pktmbuf_append(buf_oop, to_trn);
9602 
9603 			trn_data += to_trn;
9604 		}
9605 		ut_params->obuf->nb_segs = segs;
9606 	}
9607 
9608 	/* Setup Cipher Parameters */
9609 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9610 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9611 	ut_params->cipher_xform.cipher.op = opc;
9612 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9613 	ut_params->cipher_xform.cipher.key.length =
9614 					pdcp_test_params[i].cipher_key_len;
9615 	ut_params->cipher_xform.cipher.iv.length = 0;
9616 
9617 	/* Setup HMAC Parameters if ICV header is required */
9618 	if (pdcp_test_params[i].auth_alg != 0) {
9619 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9620 		ut_params->auth_xform.next = NULL;
9621 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9622 		ut_params->auth_xform.auth.op = opa;
9623 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9624 		ut_params->auth_xform.auth.key.length =
9625 					pdcp_test_params[i].auth_key_len;
9626 
9627 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9628 	} else {
9629 		ut_params->cipher_xform.next = NULL;
9630 	}
9631 
9632 	struct rte_security_session_conf sess_conf = {
9633 		.action_type = ut_params->type,
9634 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9635 		{.pdcp = {
9636 			.bearer = pdcp_test_bearer[i],
9637 			.domain = pdcp_test_params[i].domain,
9638 			.pkt_dir = pdcp_test_packet_direction[i],
9639 			.sn_size = pdcp_test_data_sn_size[i],
9640 			.hfn = pdcp_test_hfn[i],
9641 			.hfn_threshold = pdcp_test_hfn_threshold[i],
9642 			.hfn_ovrd = 0,
9643 		} },
9644 		.crypto_xform = &ut_params->cipher_xform
9645 	};
9646 
9647 	/* Create security session */
9648 	ut_params->sec_session = rte_security_session_create(ctx,
9649 				&sess_conf, ts_params->session_mpool);
9650 
9651 	if (!ut_params->sec_session) {
9652 		printf("TestCase %s()-%d line %d failed %s: ",
9653 			__func__, i, __LINE__, "Failed to allocate session");
9654 		ret = TEST_FAILED;
9655 		goto on_err;
9656 	}
9657 
9658 	/* Generate crypto op data structure */
9659 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9660 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9661 	if (!ut_params->op) {
9662 		printf("TestCase %s()-%d line %d failed %s: ",
9663 			__func__, i, __LINE__,
9664 			"Failed to allocate symmetric crypto operation struct");
9665 		ret = TEST_FAILED;
9666 		goto on_err;
9667 	}
9668 
9669 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9670 
9671 	/* set crypto operation source mbuf */
9672 	ut_params->op->sym->m_src = ut_params->ibuf;
9673 	if (oop)
9674 		ut_params->op->sym->m_dst = ut_params->obuf;
9675 
9676 	/* Process crypto operation */
9677 	temp_mbuf = ut_params->op->sym->m_src;
9678 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9679 		/* filling lengths */
9680 		while (temp_mbuf) {
9681 			ut_params->op->sym->cipher.data.length
9682 				+= temp_mbuf->pkt_len;
9683 			ut_params->op->sym->auth.data.length
9684 				+= temp_mbuf->pkt_len;
9685 			temp_mbuf = temp_mbuf->next;
9686 		}
9687 
9688 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9689 		if (ret != TEST_SUCCESS)
9690 			return ret;
9691 	} else {
9692 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9693 							ut_params->op);
9694 	}
9695 	if (ut_params->op == NULL) {
9696 		printf("TestCase %s()-%d line %d failed %s: ",
9697 			__func__, i, __LINE__,
9698 			"failed to process sym crypto op");
9699 		ret = TEST_FAILED;
9700 		goto on_err;
9701 	}
9702 
9703 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9704 		printf("TestCase %s()-%d line %d failed %s: ",
9705 			__func__, i, __LINE__, "crypto op processing failed");
9706 		ret = TEST_FAILED;
9707 		goto on_err;
9708 	}
9709 
9710 	/* Validate obuf */
9711 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9712 			uint8_t *);
9713 	if (oop) {
9714 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9715 				uint8_t *);
9716 	}
9717 	if (fragsz_oop)
9718 		fragsz = frag_size_oop;
9719 	if (memcmp(ciphertext, output_vec, fragsz)) {
9720 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9721 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9722 		rte_hexdump(stdout, "reference", output_vec, fragsz);
9723 		ret = TEST_FAILED;
9724 		goto on_err;
9725 	}
9726 
9727 	buf = ut_params->op->sym->m_src->next;
9728 	if (oop)
9729 		buf = ut_params->op->sym->m_dst->next;
9730 
9731 	unsigned int off = fragsz;
9732 
9733 	ecx = 0;
9734 	while (buf) {
9735 		ciphertext = rte_pktmbuf_mtod(buf,
9736 				uint8_t *);
9737 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9738 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9739 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9740 			rte_hexdump(stdout, "reference", output_vec + off,
9741 					to_trn_tbl[ecx]);
9742 			ret = TEST_FAILED;
9743 			goto on_err;
9744 		}
9745 		off += to_trn_tbl[ecx++];
9746 		buf = buf->next;
9747 	}
9748 on_err:
9749 	rte_crypto_op_free(ut_params->op);
9750 	ut_params->op = NULL;
9751 
9752 	if (ut_params->sec_session)
9753 		rte_security_session_destroy(ctx, ut_params->sec_session);
9754 	ut_params->sec_session = NULL;
9755 
9756 	rte_pktmbuf_free(ut_params->ibuf);
9757 	ut_params->ibuf = NULL;
9758 	if (oop) {
9759 		rte_pktmbuf_free(ut_params->obuf);
9760 		ut_params->obuf = NULL;
9761 	}
9762 
9763 	return ret;
9764 }
9765 
9766 int
9767 test_pdcp_proto_cplane_encap(int i)
9768 {
9769 	return test_pdcp_proto(
9770 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9771 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9772 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9773 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9774 		pdcp_test_params[i].cipher_key_len,
9775 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9776 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9777 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9778 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9779 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9780 }
9781 
9782 int
9783 test_pdcp_proto_uplane_encap(int i)
9784 {
9785 	return test_pdcp_proto(
9786 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9787 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9788 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9789 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9790 		pdcp_test_params[i].cipher_key_len,
9791 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9792 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9793 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9794 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9795 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9796 }
9797 
9798 int
9799 test_pdcp_proto_uplane_encap_with_int(int i)
9800 {
9801 	return test_pdcp_proto(
9802 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9803 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9804 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9805 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9806 		pdcp_test_params[i].cipher_key_len,
9807 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9808 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9809 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9810 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9811 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9812 }
9813 
9814 int
9815 test_pdcp_proto_cplane_decap(int i)
9816 {
9817 	return test_pdcp_proto(
9818 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9819 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9820 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9821 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9822 		pdcp_test_params[i].cipher_key_len,
9823 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9824 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9825 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9826 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9827 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9828 }
9829 
9830 int
9831 test_pdcp_proto_uplane_decap(int i)
9832 {
9833 	return test_pdcp_proto(
9834 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9835 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9836 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9837 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9838 		pdcp_test_params[i].cipher_key_len,
9839 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9840 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9841 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9842 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9843 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9844 }
9845 
9846 int
9847 test_pdcp_proto_uplane_decap_with_int(int i)
9848 {
9849 	return test_pdcp_proto(
9850 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9851 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9852 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9853 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9854 		pdcp_test_params[i].cipher_key_len,
9855 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9856 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9857 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9858 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9859 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9860 }
9861 
9862 static int
9863 test_PDCP_PROTO_SGL_in_place_32B(void)
9864 {
9865 	/* i can be used for running any PDCP case
9866 	 * In this case it is uplane 12-bit AES-SNOW DL encap
9867 	 */
9868 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9869 	return test_pdcp_proto_SGL(i, IN_PLACE,
9870 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9871 			RTE_CRYPTO_AUTH_OP_GENERATE,
9872 			pdcp_test_data_in[i],
9873 			pdcp_test_data_in_len[i],
9874 			pdcp_test_data_out[i],
9875 			pdcp_test_data_in_len[i]+4,
9876 			32, 0);
9877 }
9878 static int
9879 test_PDCP_PROTO_SGL_oop_32B_128B(void)
9880 {
9881 	/* i can be used for running any PDCP case
9882 	 * In this case it is uplane 18-bit NULL-NULL DL encap
9883 	 */
9884 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9885 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9886 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9887 			RTE_CRYPTO_AUTH_OP_GENERATE,
9888 			pdcp_test_data_in[i],
9889 			pdcp_test_data_in_len[i],
9890 			pdcp_test_data_out[i],
9891 			pdcp_test_data_in_len[i]+4,
9892 			32, 128);
9893 }
9894 static int
9895 test_PDCP_PROTO_SGL_oop_32B_40B(void)
9896 {
9897 	/* i can be used for running any PDCP case
9898 	 * In this case it is uplane 18-bit AES DL encap
9899 	 */
9900 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9901 			+ DOWNLINK;
9902 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9903 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9904 			RTE_CRYPTO_AUTH_OP_GENERATE,
9905 			pdcp_test_data_in[i],
9906 			pdcp_test_data_in_len[i],
9907 			pdcp_test_data_out[i],
9908 			pdcp_test_data_in_len[i],
9909 			32, 40);
9910 }
9911 static int
9912 test_PDCP_PROTO_SGL_oop_128B_32B(void)
9913 {
9914 	/* i can be used for running any PDCP case
9915 	 * In this case it is cplane 12-bit AES-ZUC DL encap
9916 	 */
9917 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9918 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9919 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9920 			RTE_CRYPTO_AUTH_OP_GENERATE,
9921 			pdcp_test_data_in[i],
9922 			pdcp_test_data_in_len[i],
9923 			pdcp_test_data_out[i],
9924 			pdcp_test_data_in_len[i]+4,
9925 			128, 32);
9926 }
9927 
9928 static int
9929 test_PDCP_SDAP_PROTO_encap_all(void)
9930 {
9931 	int i = 0, size = 0;
9932 	int err, all_err = TEST_SUCCESS;
9933 	const struct pdcp_sdap_test *cur_test;
9934 
9935 	size = RTE_DIM(list_pdcp_sdap_tests);
9936 
9937 	for (i = 0; i < size; i++) {
9938 		cur_test = &list_pdcp_sdap_tests[i];
9939 		err = test_pdcp_proto(
9940 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9941 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9942 			cur_test->in_len, cur_test->data_out,
9943 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9944 			cur_test->param.cipher_alg, cur_test->cipher_key,
9945 			cur_test->param.cipher_key_len,
9946 			cur_test->param.auth_alg,
9947 			cur_test->auth_key, cur_test->param.auth_key_len,
9948 			cur_test->bearer, cur_test->param.domain,
9949 			cur_test->packet_direction, cur_test->sn_size,
9950 			cur_test->hfn,
9951 			cur_test->hfn_threshold, SDAP_ENABLED);
9952 		if (err) {
9953 			printf("\t%d) %s: Encapsulation failed\n",
9954 					cur_test->test_idx,
9955 					cur_test->param.name);
9956 			err = TEST_FAILED;
9957 		} else {
9958 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9959 					cur_test->param.name);
9960 			err = TEST_SUCCESS;
9961 		}
9962 		all_err += err;
9963 	}
9964 
9965 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9966 
9967 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9968 }
9969 
9970 static int
9971 test_PDCP_PROTO_short_mac(void)
9972 {
9973 	int i = 0, size = 0;
9974 	int err, all_err = TEST_SUCCESS;
9975 	const struct pdcp_short_mac_test *cur_test;
9976 
9977 	size = RTE_DIM(list_pdcp_smac_tests);
9978 
9979 	for (i = 0; i < size; i++) {
9980 		cur_test = &list_pdcp_smac_tests[i];
9981 		err = test_pdcp_proto(
9982 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9983 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9984 			cur_test->in_len, cur_test->data_out,
9985 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9986 			RTE_CRYPTO_CIPHER_NULL, NULL,
9987 			0, cur_test->param.auth_alg,
9988 			cur_test->auth_key, cur_test->param.auth_key_len,
9989 			0, cur_test->param.domain, 0, 0,
9990 			0, 0, 0);
9991 		if (err) {
9992 			printf("\t%d) %s: Short MAC test failed\n",
9993 					cur_test->test_idx,
9994 					cur_test->param.name);
9995 			err = TEST_FAILED;
9996 		} else {
9997 			printf("\t%d) %s: Short MAC test PASS\n",
9998 					cur_test->test_idx,
9999 					cur_test->param.name);
10000 			rte_hexdump(stdout, "MAC I",
10001 				    cur_test->data_out + cur_test->in_len + 2,
10002 				    2);
10003 			err = TEST_SUCCESS;
10004 		}
10005 		all_err += err;
10006 	}
10007 
10008 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10009 
10010 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10011 
10012 }
10013 
10014 static int
10015 test_PDCP_SDAP_PROTO_decap_all(void)
10016 {
10017 	int i = 0, size = 0;
10018 	int err, all_err = TEST_SUCCESS;
10019 	const struct pdcp_sdap_test *cur_test;
10020 
10021 	size = RTE_DIM(list_pdcp_sdap_tests);
10022 
10023 	for (i = 0; i < size; i++) {
10024 		cur_test = &list_pdcp_sdap_tests[i];
10025 		err = test_pdcp_proto(
10026 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10027 			RTE_CRYPTO_AUTH_OP_VERIFY,
10028 			cur_test->data_out,
10029 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10030 			cur_test->data_in, cur_test->in_len,
10031 			cur_test->param.cipher_alg,
10032 			cur_test->cipher_key, cur_test->param.cipher_key_len,
10033 			cur_test->param.auth_alg, cur_test->auth_key,
10034 			cur_test->param.auth_key_len, cur_test->bearer,
10035 			cur_test->param.domain, cur_test->packet_direction,
10036 			cur_test->sn_size, cur_test->hfn,
10037 			cur_test->hfn_threshold, SDAP_ENABLED);
10038 		if (err) {
10039 			printf("\t%d) %s: Decapsulation failed\n",
10040 					cur_test->test_idx,
10041 					cur_test->param.name);
10042 			err = TEST_FAILED;
10043 		} else {
10044 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10045 					cur_test->param.name);
10046 			err = TEST_SUCCESS;
10047 		}
10048 		all_err += err;
10049 	}
10050 
10051 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10052 
10053 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10054 }
10055 
10056 static int
10057 test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10058 			       struct crypto_unittest_params *ut_params,
10059 			       struct rte_security_ipsec_xform *ipsec_xform,
10060 			       const struct ipsec_test_data *td,
10061 			       const struct ipsec_test_flags *flags,
10062 			       int pkt_num)
10063 {
10064 	uint8_t dev_id = ts_params->valid_devs[0];
10065 	enum rte_security_ipsec_sa_direction dir;
10066 	int ret;
10067 
10068 	dir = ipsec_xform->direction;
10069 
10070 	/* Generate crypto op data structure */
10071 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10072 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10073 	if (!ut_params->op) {
10074 		printf("Could not allocate crypto op");
10075 		return TEST_FAILED;
10076 	}
10077 
10078 	/* Attach session to operation */
10079 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10080 
10081 	/* Set crypto operation mbufs */
10082 	ut_params->op->sym->m_src = ut_params->ibuf;
10083 	ut_params->op->sym->m_dst = NULL;
10084 
10085 	/* Copy IV in crypto operation when IV generation is disabled */
10086 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10087 	    ipsec_xform->options.iv_gen_disable == 1) {
10088 		uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10089 							uint8_t *,
10090 							IV_OFFSET);
10091 		int len;
10092 
10093 		if (td->aead)
10094 			len = td->xform.aead.aead.iv.length;
10095 		else if (td->aes_gmac)
10096 			len = td->xform.chain.auth.auth.iv.length;
10097 		else
10098 			len = td->xform.chain.cipher.cipher.iv.length;
10099 
10100 		memcpy(iv, td->iv.data, len);
10101 	}
10102 
10103 	/* Process crypto operation */
10104 	process_crypto_request(dev_id, ut_params->op);
10105 
10106 	ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10107 
10108 	rte_crypto_op_free(ut_params->op);
10109 	ut_params->op = NULL;
10110 
10111 	return ret;
10112 }
10113 
10114 static int
10115 test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10116 			  struct crypto_unittest_params *ut_params,
10117 			  void *ctx)
10118 {
10119 	uint64_t timeout, userdata;
10120 	struct rte_ether_hdr *hdr;
10121 	struct rte_mbuf *m;
10122 	void **sec_sess;
10123 	int ret;
10124 
10125 	RTE_SET_USED(ts_params);
10126 
10127 	hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10128 	hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10129 
10130 	ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10131 	ut_params->ibuf->port = 0;
10132 
10133 	sec_sess = &ut_params->sec_session;
10134 	ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10135 
10136 	if (ret != 1)
10137 		return TEST_FAILED;
10138 
10139 	ut_params->ibuf = NULL;
10140 
10141 	/* Add a timeout for 1 s */
10142 	timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10143 
10144 	do {
10145 		/* Get packet from port 0, queue 0 */
10146 		ret = rte_eth_rx_burst(0, 0, &m, 1);
10147 	} while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10148 
10149 	if (ret == 0) {
10150 		printf("Could not receive packets from ethdev\n");
10151 		return TEST_FAILED;
10152 	}
10153 
10154 	if (m == NULL) {
10155 		printf("Received mbuf is NULL\n");
10156 		return TEST_FAILED;
10157 	}
10158 
10159 	ut_params->ibuf = m;
10160 
10161 	if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10162 		printf("Received packet is not Rx security processed\n");
10163 		return TEST_FAILED;
10164 	}
10165 
10166 	if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10167 		printf("Received packet has failed Rx security processing\n");
10168 		return TEST_FAILED;
10169 	}
10170 
10171 	/*
10172 	 * 'ut_params' is set as userdata. Verify that the field is returned
10173 	 * correctly.
10174 	 */
10175 	userdata = *(uint64_t *)rte_security_dynfield(m);
10176 	if (userdata != (uint64_t)ut_params) {
10177 		printf("Userdata retrieved not matching expected\n");
10178 		return TEST_FAILED;
10179 	}
10180 
10181 	/* Trim L2 header */
10182 	rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10183 
10184 	return TEST_SUCCESS;
10185 }
10186 
10187 static int
10188 test_ipsec_proto_process(const struct ipsec_test_data td[],
10189 			 struct ipsec_test_data res_d[],
10190 			 int nb_td,
10191 			 bool silent,
10192 			 const struct ipsec_test_flags *flags)
10193 {
10194 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10195 				0x0000, 0x001a};
10196 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10197 				0xe82c, 0x4887};
10198 	const struct rte_ipv4_hdr *ipv4 =
10199 			(const struct rte_ipv4_hdr *)td[0].output_text.data;
10200 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10201 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10202 	struct crypto_unittest_params *ut_params = &unittest_params;
10203 	struct rte_security_capability_idx sec_cap_idx;
10204 	const struct rte_security_capability *sec_cap;
10205 	struct rte_security_ipsec_xform ipsec_xform;
10206 	uint8_t dev_id = ts_params->valid_devs[0];
10207 	enum rte_security_ipsec_sa_direction dir;
10208 	struct ipsec_test_data *res_d_tmp = NULL;
10209 	uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10210 	int salt_len, i, ret = TEST_SUCCESS;
10211 	void *ctx;
10212 	uint32_t src, dst;
10213 	uint32_t verify;
10214 
10215 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10216 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10217 
10218 	/* Use first test data to create session */
10219 
10220 	/* Copy IPsec xform */
10221 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10222 
10223 	dir = ipsec_xform.direction;
10224 	verify = flags->tunnel_hdr_verify;
10225 
10226 	memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10227 	memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10228 
10229 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10230 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10231 			src += 1;
10232 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10233 			dst += 1;
10234 	}
10235 
10236 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10237 		if (td->ipsec_xform.tunnel.type ==
10238 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10239 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10240 			       sizeof(src));
10241 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10242 			       sizeof(dst));
10243 
10244 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10245 				ipsec_xform.tunnel.ipv4.df = 0;
10246 
10247 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10248 				ipsec_xform.tunnel.ipv4.df = 1;
10249 
10250 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10251 				ipsec_xform.tunnel.ipv4.dscp = 0;
10252 
10253 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10254 				ipsec_xform.tunnel.ipv4.dscp =
10255 						TEST_IPSEC_DSCP_VAL;
10256 
10257 		} else {
10258 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10259 				ipsec_xform.tunnel.ipv6.dscp = 0;
10260 
10261 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10262 				ipsec_xform.tunnel.ipv6.dscp =
10263 						TEST_IPSEC_DSCP_VAL;
10264 
10265 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10266 			       sizeof(v6_src));
10267 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10268 			       sizeof(v6_dst));
10269 		}
10270 	}
10271 
10272 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
10273 
10274 	sec_cap_idx.action = ut_params->type;
10275 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10276 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10277 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10278 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10279 
10280 	if (flags->udp_encap)
10281 		ipsec_xform.options.udp_encap = 1;
10282 
10283 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10284 	if (sec_cap == NULL)
10285 		return TEST_SKIPPED;
10286 
10287 	/* Copy cipher session parameters */
10288 	if (td[0].aead) {
10289 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10290 		       sizeof(ut_params->aead_xform));
10291 		ut_params->aead_xform.aead.key.data = td[0].key.data;
10292 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10293 
10294 		/* Verify crypto capabilities */
10295 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10296 			if (!silent)
10297 				RTE_LOG(INFO, USER1,
10298 					"Crypto capabilities not supported\n");
10299 			return TEST_SKIPPED;
10300 		}
10301 	} else if (td[0].auth_only) {
10302 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10303 		       sizeof(ut_params->auth_xform));
10304 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10305 
10306 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10307 			if (!silent)
10308 				RTE_LOG(INFO, USER1,
10309 					"Auth crypto capabilities not supported\n");
10310 			return TEST_SKIPPED;
10311 		}
10312 	} else {
10313 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10314 		       sizeof(ut_params->cipher_xform));
10315 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10316 		       sizeof(ut_params->auth_xform));
10317 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10318 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10319 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10320 
10321 		/* Verify crypto capabilities */
10322 
10323 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10324 			if (!silent)
10325 				RTE_LOG(INFO, USER1,
10326 					"Cipher crypto capabilities not supported\n");
10327 			return TEST_SKIPPED;
10328 		}
10329 
10330 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10331 			if (!silent)
10332 				RTE_LOG(INFO, USER1,
10333 					"Auth crypto capabilities not supported\n");
10334 			return TEST_SKIPPED;
10335 		}
10336 	}
10337 
10338 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10339 		return TEST_SKIPPED;
10340 
10341 	struct rte_security_session_conf sess_conf = {
10342 		.action_type = ut_params->type,
10343 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10344 	};
10345 
10346 	if (td[0].aead || td[0].aes_gmac) {
10347 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10348 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10349 	}
10350 
10351 	if (td[0].aead) {
10352 		sess_conf.ipsec = ipsec_xform;
10353 		sess_conf.crypto_xform = &ut_params->aead_xform;
10354 	} else if (td[0].auth_only) {
10355 		sess_conf.ipsec = ipsec_xform;
10356 		sess_conf.crypto_xform = &ut_params->auth_xform;
10357 	} else {
10358 		sess_conf.ipsec = ipsec_xform;
10359 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10360 			sess_conf.crypto_xform = &ut_params->cipher_xform;
10361 			ut_params->cipher_xform.next = &ut_params->auth_xform;
10362 		} else {
10363 			sess_conf.crypto_xform = &ut_params->auth_xform;
10364 			ut_params->auth_xform.next = &ut_params->cipher_xform;
10365 		}
10366 	}
10367 
10368 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10369 		sess_conf.userdata = ut_params;
10370 
10371 	/* Create security session */
10372 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10373 					ts_params->session_mpool);
10374 
10375 	if (ut_params->sec_session == NULL)
10376 		return TEST_SKIPPED;
10377 
10378 	for (i = 0; i < nb_td; i++) {
10379 		if (flags->antireplay &&
10380 		    (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10381 			sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10382 			ret = rte_security_session_update(ctx,
10383 				ut_params->sec_session, &sess_conf);
10384 			if (ret) {
10385 				printf("Could not update sequence number in "
10386 				       "session\n");
10387 				return TEST_SKIPPED;
10388 			}
10389 		}
10390 
10391 		/* Copy test data before modification */
10392 		memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10393 		if (test_ipsec_pkt_update(input_text, flags)) {
10394 			ret = TEST_FAILED;
10395 			goto mbuf_free;
10396 		}
10397 
10398 		/* Setup source mbuf payload */
10399 		if (flags->use_ext_mbuf) {
10400 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10401 					td[i].input_text.len, nb_segs, input_text);
10402 		} else {
10403 			ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10404 					td[i].input_text.len, nb_segs, 0);
10405 			pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10406 		}
10407 
10408 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10409 			ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10410 							ctx);
10411 		else
10412 			ret = test_ipsec_proto_crypto_op_enq(ts_params,
10413 							     ut_params,
10414 							     &ipsec_xform,
10415 							     &td[i], flags,
10416 							     i + 1);
10417 
10418 		if (ret != TEST_SUCCESS)
10419 			goto mbuf_free;
10420 
10421 		if (res_d != NULL)
10422 			res_d_tmp = &res_d[i];
10423 
10424 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10425 					      res_d_tmp, silent, flags);
10426 		if (ret != TEST_SUCCESS)
10427 			goto mbuf_free;
10428 
10429 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10430 					      flags, dir);
10431 		if (ret != TEST_SUCCESS)
10432 			goto mbuf_free;
10433 
10434 		rte_pktmbuf_free(ut_params->ibuf);
10435 		ut_params->ibuf = NULL;
10436 	}
10437 
10438 mbuf_free:
10439 	if (flags->use_ext_mbuf)
10440 		ext_mbuf_memzone_free(nb_segs);
10441 
10442 	rte_pktmbuf_free(ut_params->ibuf);
10443 	ut_params->ibuf = NULL;
10444 
10445 	if (ut_params->sec_session)
10446 		rte_security_session_destroy(ctx, ut_params->sec_session);
10447 	ut_params->sec_session = NULL;
10448 
10449 	return ret;
10450 }
10451 
10452 static int
10453 test_ipsec_proto_known_vec(const void *test_data)
10454 {
10455 	struct ipsec_test_data td_outb;
10456 	struct ipsec_test_flags flags;
10457 
10458 	memset(&flags, 0, sizeof(flags));
10459 
10460 	memcpy(&td_outb, test_data, sizeof(td_outb));
10461 
10462 	if (td_outb.aes_gmac || td_outb.aead ||
10463 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10464 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10465 		/* Disable IV gen to be able to test with known vectors */
10466 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10467 	}
10468 
10469 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10470 }
10471 
10472 static int
10473 test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10474 {
10475 	struct ipsec_test_data td_outb;
10476 	struct ipsec_test_flags flags;
10477 
10478 	memset(&flags, 0, sizeof(flags));
10479 	flags.use_ext_mbuf = true;
10480 
10481 	memcpy(&td_outb, test_data, sizeof(td_outb));
10482 
10483 	if (td_outb.aes_gmac || td_outb.aead ||
10484 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10485 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10486 		/* Disable IV gen to be able to test with known vectors */
10487 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10488 	}
10489 
10490 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10491 }
10492 
10493 static int
10494 test_ipsec_proto_known_vec_inb(const void *test_data)
10495 {
10496 	const struct ipsec_test_data *td = test_data;
10497 	struct ipsec_test_flags flags;
10498 	struct ipsec_test_data td_inb;
10499 
10500 	memset(&flags, 0, sizeof(flags));
10501 
10502 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10503 		test_ipsec_td_in_from_out(td, &td_inb);
10504 	else
10505 		memcpy(&td_inb, td, sizeof(td_inb));
10506 
10507 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10508 }
10509 
10510 static int
10511 test_ipsec_proto_known_vec_fragmented(const void *test_data)
10512 {
10513 	struct ipsec_test_data td_outb;
10514 	struct ipsec_test_flags flags;
10515 
10516 	memset(&flags, 0, sizeof(flags));
10517 	flags.fragment = true;
10518 
10519 	memcpy(&td_outb, test_data, sizeof(td_outb));
10520 
10521 	/* Disable IV gen to be able to test with known vectors */
10522 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
10523 
10524 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10525 }
10526 
10527 static int
10528 test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10529 {
10530 	const struct ipsec_test_data *td = test_data;
10531 	struct ipsec_test_flags flags;
10532 	struct ipsec_test_data td_inb;
10533 
10534 	memset(&flags, 0, sizeof(flags));
10535 	flags.rx_inject = true;
10536 
10537 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10538 		test_ipsec_td_in_from_out(td, &td_inb);
10539 	else
10540 		memcpy(&td_inb, td, sizeof(td_inb));
10541 
10542 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10543 }
10544 
10545 static int
10546 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10547 {
10548 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10549 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10550 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10551 	int ret;
10552 
10553 	if (flags->iv_gen ||
10554 	    flags->sa_expiry_pkts_soft ||
10555 	    flags->sa_expiry_pkts_hard)
10556 		nb_pkts = TEST_SEC_PKTS_MAX;
10557 
10558 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10559 		test_ipsec_td_prepare(sec_alg_list[i].param1,
10560 				      sec_alg_list[i].param2,
10561 				      flags,
10562 				      td_outb,
10563 				      nb_pkts);
10564 
10565 		if (!td_outb->aead) {
10566 			enum rte_crypto_cipher_algorithm cipher_alg;
10567 			enum rte_crypto_auth_algorithm auth_alg;
10568 
10569 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10570 			auth_alg = td_outb->xform.chain.auth.auth.algo;
10571 
10572 			if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10573 				continue;
10574 
10575 			/* ICV is not applicable for NULL auth */
10576 			if (flags->icv_corrupt &&
10577 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
10578 				continue;
10579 
10580 			/* IV is not applicable for NULL cipher */
10581 			if (flags->iv_gen &&
10582 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10583 				continue;
10584 		}
10585 
10586 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10587 					       flags);
10588 		if (ret == TEST_SKIPPED)
10589 			continue;
10590 
10591 		if (ret == TEST_FAILED)
10592 			return TEST_FAILED;
10593 
10594 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10595 
10596 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10597 					       flags);
10598 		if (ret == TEST_SKIPPED)
10599 			continue;
10600 
10601 		if (ret == TEST_FAILED)
10602 			return TEST_FAILED;
10603 
10604 		if (flags->display_alg)
10605 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10606 
10607 		pass_cnt++;
10608 	}
10609 
10610 	if (pass_cnt > 0)
10611 		return TEST_SUCCESS;
10612 	else
10613 		return TEST_SKIPPED;
10614 }
10615 
10616 static int
10617 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10618 {
10619 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10620 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10621 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10622 	int ret;
10623 
10624 	for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10625 		test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10626 				      sec_auth_only_alg_list[i].param2,
10627 				      flags,
10628 				      td_outb,
10629 				      nb_pkts);
10630 
10631 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10632 					       flags);
10633 		if (ret == TEST_SKIPPED)
10634 			continue;
10635 
10636 		if (ret == TEST_FAILED)
10637 			return TEST_FAILED;
10638 
10639 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10640 
10641 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10642 					       flags);
10643 		if (ret == TEST_SKIPPED)
10644 			continue;
10645 
10646 		if (ret == TEST_FAILED)
10647 			return TEST_FAILED;
10648 
10649 		if (flags->display_alg)
10650 			test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10651 					     sec_auth_only_alg_list[i].param2);
10652 
10653 		pass_cnt++;
10654 	}
10655 
10656 	if (pass_cnt > 0)
10657 		return TEST_SUCCESS;
10658 	else
10659 		return TEST_SKIPPED;
10660 }
10661 
10662 static int
10663 test_ipsec_proto_display_list(void)
10664 {
10665 	struct ipsec_test_flags flags;
10666 
10667 	memset(&flags, 0, sizeof(flags));
10668 
10669 	flags.display_alg = true;
10670 
10671 	return test_ipsec_proto_all(&flags);
10672 }
10673 
10674 static int
10675 test_ipsec_proto_ah_tunnel_ipv4(void)
10676 {
10677 	struct ipsec_test_flags flags;
10678 
10679 	memset(&flags, 0, sizeof(flags));
10680 
10681 	flags.ah = true;
10682 	flags.display_alg = true;
10683 
10684 	return test_ipsec_ah_proto_all(&flags);
10685 }
10686 
10687 static int
10688 test_ipsec_proto_ah_transport_ipv4(void)
10689 {
10690 	struct ipsec_test_flags flags;
10691 
10692 	memset(&flags, 0, sizeof(flags));
10693 
10694 	flags.ah = true;
10695 	flags.transport = true;
10696 
10697 	return test_ipsec_ah_proto_all(&flags);
10698 }
10699 
10700 static int
10701 test_ipsec_proto_iv_gen(void)
10702 {
10703 	struct ipsec_test_flags flags;
10704 
10705 	memset(&flags, 0, sizeof(flags));
10706 
10707 	flags.iv_gen = true;
10708 
10709 	return test_ipsec_proto_all(&flags);
10710 }
10711 
10712 static int
10713 test_ipsec_proto_sa_exp_pkts_soft(void)
10714 {
10715 	struct ipsec_test_flags flags;
10716 
10717 	memset(&flags, 0, sizeof(flags));
10718 
10719 	flags.sa_expiry_pkts_soft = true;
10720 
10721 	return test_ipsec_proto_all(&flags);
10722 }
10723 
10724 static int
10725 test_ipsec_proto_sa_exp_pkts_hard(void)
10726 {
10727 	struct ipsec_test_flags flags;
10728 
10729 	memset(&flags, 0, sizeof(flags));
10730 
10731 	flags.sa_expiry_pkts_hard = true;
10732 
10733 	return test_ipsec_proto_all(&flags);
10734 }
10735 
10736 static int
10737 test_ipsec_proto_err_icv_corrupt(void)
10738 {
10739 	struct ipsec_test_flags flags;
10740 
10741 	memset(&flags, 0, sizeof(flags));
10742 
10743 	flags.icv_corrupt = true;
10744 
10745 	return test_ipsec_proto_all(&flags);
10746 }
10747 
10748 static int
10749 test_ipsec_proto_udp_encap_custom_ports(void)
10750 {
10751 	struct ipsec_test_flags flags;
10752 
10753 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10754 			RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10755 		return TEST_SKIPPED;
10756 
10757 	memset(&flags, 0, sizeof(flags));
10758 
10759 	flags.udp_encap = true;
10760 	flags.udp_encap_custom_ports = true;
10761 
10762 	return test_ipsec_proto_all(&flags);
10763 }
10764 
10765 static int
10766 test_ipsec_proto_udp_encap(void)
10767 {
10768 	struct ipsec_test_flags flags;
10769 
10770 	memset(&flags, 0, sizeof(flags));
10771 
10772 	flags.udp_encap = true;
10773 
10774 	return test_ipsec_proto_all(&flags);
10775 }
10776 
10777 static int
10778 test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10779 {
10780 	struct ipsec_test_flags flags;
10781 
10782 	memset(&flags, 0, sizeof(flags));
10783 
10784 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10785 
10786 	return test_ipsec_proto_all(&flags);
10787 }
10788 
10789 static int
10790 test_ipsec_proto_tunnel_dst_addr_verify(void)
10791 {
10792 	struct ipsec_test_flags flags;
10793 
10794 	memset(&flags, 0, sizeof(flags));
10795 
10796 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10797 
10798 	return test_ipsec_proto_all(&flags);
10799 }
10800 
10801 static int
10802 test_ipsec_proto_udp_ports_verify(void)
10803 {
10804 	struct ipsec_test_flags flags;
10805 
10806 	memset(&flags, 0, sizeof(flags));
10807 
10808 	flags.udp_encap = true;
10809 	flags.udp_ports_verify = true;
10810 
10811 	return test_ipsec_proto_all(&flags);
10812 }
10813 
10814 static int
10815 test_ipsec_proto_inner_ip_csum(void)
10816 {
10817 	struct ipsec_test_flags flags;
10818 
10819 	memset(&flags, 0, sizeof(flags));
10820 
10821 	flags.ip_csum = true;
10822 
10823 	return test_ipsec_proto_all(&flags);
10824 }
10825 
10826 static int
10827 test_ipsec_proto_inner_l4_csum(void)
10828 {
10829 	struct ipsec_test_flags flags;
10830 
10831 	memset(&flags, 0, sizeof(flags));
10832 
10833 	flags.l4_csum = true;
10834 
10835 	return test_ipsec_proto_all(&flags);
10836 }
10837 
10838 static int
10839 test_ipsec_proto_tunnel_v4_in_v4(void)
10840 {
10841 	struct ipsec_test_flags flags;
10842 
10843 	memset(&flags, 0, sizeof(flags));
10844 
10845 	flags.ipv6 = false;
10846 	flags.tunnel_ipv6 = false;
10847 
10848 	return test_ipsec_proto_all(&flags);
10849 }
10850 
10851 static int
10852 test_ipsec_proto_tunnel_v6_in_v6(void)
10853 {
10854 	struct ipsec_test_flags flags;
10855 
10856 	memset(&flags, 0, sizeof(flags));
10857 
10858 	flags.ipv6 = true;
10859 	flags.tunnel_ipv6 = true;
10860 
10861 	return test_ipsec_proto_all(&flags);
10862 }
10863 
10864 static int
10865 test_ipsec_proto_tunnel_v4_in_v6(void)
10866 {
10867 	struct ipsec_test_flags flags;
10868 
10869 	memset(&flags, 0, sizeof(flags));
10870 
10871 	flags.ipv6 = false;
10872 	flags.tunnel_ipv6 = true;
10873 
10874 	return test_ipsec_proto_all(&flags);
10875 }
10876 
10877 static int
10878 test_ipsec_proto_tunnel_v6_in_v4(void)
10879 {
10880 	struct ipsec_test_flags flags;
10881 
10882 	memset(&flags, 0, sizeof(flags));
10883 
10884 	flags.ipv6 = true;
10885 	flags.tunnel_ipv6 = false;
10886 
10887 	return test_ipsec_proto_all(&flags);
10888 }
10889 
10890 static int
10891 test_ipsec_proto_transport_v4(void)
10892 {
10893 	struct ipsec_test_flags flags;
10894 
10895 	memset(&flags, 0, sizeof(flags));
10896 
10897 	flags.ipv6 = false;
10898 	flags.transport = true;
10899 
10900 	return test_ipsec_proto_all(&flags);
10901 }
10902 
10903 static int
10904 test_ipsec_proto_transport_l4_csum(void)
10905 {
10906 	struct ipsec_test_flags flags = {
10907 		.l4_csum = true,
10908 		.transport = true,
10909 	};
10910 
10911 	return test_ipsec_proto_all(&flags);
10912 }
10913 
10914 static int
10915 test_ipsec_proto_stats(void)
10916 {
10917 	struct ipsec_test_flags flags;
10918 
10919 	memset(&flags, 0, sizeof(flags));
10920 
10921 	flags.stats_success = true;
10922 
10923 	return test_ipsec_proto_all(&flags);
10924 }
10925 
10926 static int
10927 test_ipsec_proto_pkt_fragment(void)
10928 {
10929 	struct ipsec_test_flags flags;
10930 
10931 	memset(&flags, 0, sizeof(flags));
10932 
10933 	flags.fragment = true;
10934 
10935 	return test_ipsec_proto_all(&flags);
10936 
10937 }
10938 
10939 static int
10940 test_ipsec_proto_copy_df_inner_0(void)
10941 {
10942 	struct ipsec_test_flags flags;
10943 
10944 	memset(&flags, 0, sizeof(flags));
10945 
10946 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10947 
10948 	return test_ipsec_proto_all(&flags);
10949 }
10950 
10951 static int
10952 test_ipsec_proto_copy_df_inner_1(void)
10953 {
10954 	struct ipsec_test_flags flags;
10955 
10956 	memset(&flags, 0, sizeof(flags));
10957 
10958 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10959 
10960 	return test_ipsec_proto_all(&flags);
10961 }
10962 
10963 static int
10964 test_ipsec_proto_set_df_0_inner_1(void)
10965 {
10966 	struct ipsec_test_flags flags;
10967 
10968 	memset(&flags, 0, sizeof(flags));
10969 
10970 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10971 
10972 	return test_ipsec_proto_all(&flags);
10973 }
10974 
10975 static int
10976 test_ipsec_proto_set_df_1_inner_0(void)
10977 {
10978 	struct ipsec_test_flags flags;
10979 
10980 	memset(&flags, 0, sizeof(flags));
10981 
10982 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10983 
10984 	return test_ipsec_proto_all(&flags);
10985 }
10986 
10987 static int
10988 test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10989 {
10990 	struct ipsec_test_flags flags;
10991 
10992 	memset(&flags, 0, sizeof(flags));
10993 
10994 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10995 
10996 	return test_ipsec_proto_all(&flags);
10997 }
10998 
10999 static int
11000 test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11001 {
11002 	struct ipsec_test_flags flags;
11003 
11004 	memset(&flags, 0, sizeof(flags));
11005 
11006 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11007 
11008 	return test_ipsec_proto_all(&flags);
11009 }
11010 
11011 static int
11012 test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11013 {
11014 	struct ipsec_test_flags flags;
11015 
11016 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11017 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11018 		return TEST_SKIPPED;
11019 
11020 	memset(&flags, 0, sizeof(flags));
11021 
11022 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11023 
11024 	return test_ipsec_proto_all(&flags);
11025 }
11026 
11027 static int
11028 test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11029 {
11030 	struct ipsec_test_flags flags;
11031 
11032 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11033 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11034 		return TEST_SKIPPED;
11035 
11036 	memset(&flags, 0, sizeof(flags));
11037 
11038 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11039 
11040 	return test_ipsec_proto_all(&flags);
11041 }
11042 
11043 static int
11044 test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11045 {
11046 	struct ipsec_test_flags flags;
11047 
11048 	memset(&flags, 0, sizeof(flags));
11049 
11050 	flags.ipv6 = true;
11051 	flags.tunnel_ipv6 = true;
11052 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11053 
11054 	return test_ipsec_proto_all(&flags);
11055 }
11056 
11057 static int
11058 test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11059 {
11060 	struct ipsec_test_flags flags;
11061 
11062 	memset(&flags, 0, sizeof(flags));
11063 
11064 	flags.ipv6 = true;
11065 	flags.tunnel_ipv6 = true;
11066 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11067 
11068 	return test_ipsec_proto_all(&flags);
11069 }
11070 
11071 static int
11072 test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11073 {
11074 	struct ipsec_test_flags flags;
11075 
11076 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11077 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11078 		return TEST_SKIPPED;
11079 
11080 	memset(&flags, 0, sizeof(flags));
11081 
11082 	flags.ipv6 = true;
11083 	flags.tunnel_ipv6 = true;
11084 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11085 
11086 	return test_ipsec_proto_all(&flags);
11087 }
11088 
11089 static int
11090 test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11091 {
11092 	struct ipsec_test_flags flags;
11093 
11094 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11095 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11096 		return TEST_SKIPPED;
11097 
11098 	memset(&flags, 0, sizeof(flags));
11099 
11100 	flags.ipv6 = true;
11101 	flags.tunnel_ipv6 = true;
11102 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11103 
11104 	return test_ipsec_proto_all(&flags);
11105 }
11106 
11107 static int
11108 test_ipsec_proto_sgl(void)
11109 {
11110 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11111 	struct rte_cryptodev_info dev_info;
11112 
11113 	struct ipsec_test_flags flags = {
11114 		.nb_segs_in_mbuf = 5
11115 	};
11116 
11117 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11118 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11119 		printf("Device doesn't support in-place scatter-gather. "
11120 				"Test Skipped.\n");
11121 		return TEST_SKIPPED;
11122 	}
11123 
11124 	return test_ipsec_proto_all(&flags);
11125 }
11126 
11127 static int
11128 test_ipsec_proto_sgl_ext_mbuf(void)
11129 {
11130 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11131 	struct rte_cryptodev_info dev_info;
11132 
11133 	struct ipsec_test_flags flags = {
11134 		.nb_segs_in_mbuf = 5,
11135 		.use_ext_mbuf = 1
11136 	};
11137 
11138 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11139 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11140 		printf("Device doesn't support in-place scatter-gather. "
11141 				"Test Skipped.\n");
11142 		return TEST_SKIPPED;
11143 	}
11144 
11145 	return test_ipsec_proto_all(&flags);
11146 }
11147 
11148 static int
11149 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11150 		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11151 		      uint64_t winsz)
11152 {
11153 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11154 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11155 	struct ipsec_test_flags flags;
11156 	uint32_t i = 0, ret = 0;
11157 
11158 	if (nb_pkts == 0)
11159 		return TEST_FAILED;
11160 
11161 	memset(&flags, 0, sizeof(flags));
11162 	flags.antireplay = true;
11163 
11164 	for (i = 0; i < nb_pkts; i++) {
11165 		memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11166 		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11167 		td_outb[i].ipsec_xform.replay_win_sz = winsz;
11168 		td_outb[i].ipsec_xform.options.esn = esn_en;
11169 	}
11170 
11171 	for (i = 0; i < nb_pkts; i++)
11172 		td_outb[i].ipsec_xform.esn.value = esn[i];
11173 
11174 	ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11175 				       &flags);
11176 	if (ret != TEST_SUCCESS)
11177 		return ret;
11178 
11179 	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11180 
11181 	for (i = 0; i < nb_pkts; i++) {
11182 		td_inb[i].ipsec_xform.options.esn = esn_en;
11183 		/* Set antireplay flag for packets to be dropped */
11184 		td_inb[i].ar_packet = replayed_pkt[i];
11185 	}
11186 
11187 	ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11188 				       &flags);
11189 
11190 	return ret;
11191 }
11192 
11193 static int
11194 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11195 {
11196 
11197 	uint32_t nb_pkts = 5;
11198 	bool replayed_pkt[5];
11199 	uint64_t esn[5];
11200 
11201 	/* 1. Advance the TOP of the window to WS * 2 */
11202 	esn[0] = winsz * 2;
11203 	/* 2. Test sequence number within the new window(WS + 1) */
11204 	esn[1] = winsz + 1;
11205 	/* 3. Test sequence number less than the window BOTTOM */
11206 	esn[2] = winsz;
11207 	/* 4. Test sequence number in the middle of the window */
11208 	esn[3] = winsz + (winsz / 2);
11209 	/* 5. Test replay of the packet in the middle of the window */
11210 	esn[4] = winsz + (winsz / 2);
11211 
11212 	replayed_pkt[0] = false;
11213 	replayed_pkt[1] = false;
11214 	replayed_pkt[2] = true;
11215 	replayed_pkt[3] = false;
11216 	replayed_pkt[4] = true;
11217 
11218 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11219 				     false, winsz);
11220 }
11221 
11222 static int
11223 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11224 {
11225 	return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11226 }
11227 
11228 static int
11229 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11230 {
11231 	return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11232 }
11233 
11234 static int
11235 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11236 {
11237 	return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11238 }
11239 
11240 static int
11241 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11242 {
11243 
11244 	uint32_t nb_pkts = 7;
11245 	bool replayed_pkt[7];
11246 	uint64_t esn[7];
11247 
11248 	/* Set the initial sequence number */
11249 	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11250 	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11251 	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11252 	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11253 	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11254 	/* 3. Test with sequence number within window (1<<32 - 1) */
11255 	esn[3] = (uint64_t)((1ULL << 32) - 1);
11256 	/* 4. Test with sequence number within window (1<<32 - 1) */
11257 	esn[4] = (uint64_t)(1ULL << 32);
11258 	/* 5. Test with duplicate sequence number within
11259 	 * new window (1<<32 - 1)
11260 	 */
11261 	esn[5] = (uint64_t)((1ULL << 32) - 1);
11262 	/* 6. Test with duplicate sequence number within new window (1<<32) */
11263 	esn[6] = (uint64_t)(1ULL << 32);
11264 
11265 	replayed_pkt[0] = false;
11266 	replayed_pkt[1] = false;
11267 	replayed_pkt[2] = false;
11268 	replayed_pkt[3] = false;
11269 	replayed_pkt[4] = false;
11270 	replayed_pkt[5] = true;
11271 	replayed_pkt[6] = true;
11272 
11273 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11274 				     true, winsz);
11275 }
11276 
11277 static int
11278 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11279 {
11280 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11281 }
11282 
11283 static int
11284 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11285 {
11286 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11287 }
11288 
11289 static int
11290 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11291 {
11292 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11293 }
11294 
11295 static int
11296 test_PDCP_PROTO_all(void)
11297 {
11298 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11299 	struct crypto_unittest_params *ut_params = &unittest_params;
11300 	struct rte_cryptodev_info dev_info;
11301 	int status;
11302 
11303 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11304 	uint64_t feat_flags = dev_info.feature_flags;
11305 
11306 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11307 		return TEST_SKIPPED;
11308 
11309 	/* Set action type */
11310 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11311 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11312 		gbl_action_type;
11313 
11314 	if (security_proto_supported(ut_params->type,
11315 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
11316 		return TEST_SKIPPED;
11317 
11318 	status = test_PDCP_PROTO_cplane_encap_all();
11319 	status += test_PDCP_PROTO_cplane_decap_all();
11320 	status += test_PDCP_PROTO_uplane_encap_all();
11321 	status += test_PDCP_PROTO_uplane_decap_all();
11322 	status += test_PDCP_PROTO_SGL_in_place_32B();
11323 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
11324 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
11325 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
11326 	status += test_PDCP_SDAP_PROTO_encap_all();
11327 	status += test_PDCP_SDAP_PROTO_decap_all();
11328 	status += test_PDCP_PROTO_short_mac();
11329 
11330 	if (status)
11331 		return TEST_FAILED;
11332 	else
11333 		return TEST_SUCCESS;
11334 }
11335 
11336 static int
11337 test_ipsec_proto_ipv4_ttl_decrement(void)
11338 {
11339 	struct ipsec_test_flags flags = {
11340 		.dec_ttl_or_hop_limit = true
11341 	};
11342 
11343 	return test_ipsec_proto_all(&flags);
11344 }
11345 
11346 static int
11347 test_ipsec_proto_ipv6_hop_limit_decrement(void)
11348 {
11349 	struct ipsec_test_flags flags = {
11350 		.ipv6 = true,
11351 		.dec_ttl_or_hop_limit = true
11352 	};
11353 
11354 	return test_ipsec_proto_all(&flags);
11355 }
11356 
11357 static int
11358 test_docsis_proto_uplink(const void *data)
11359 {
11360 	const struct docsis_test_data *d_td = data;
11361 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11362 	struct crypto_unittest_params *ut_params = &unittest_params;
11363 	uint8_t *plaintext = NULL;
11364 	uint8_t *ciphertext = NULL;
11365 	uint8_t *iv_ptr;
11366 	int32_t cipher_len, crc_len;
11367 	uint32_t crc_data_len;
11368 	int ret = TEST_SUCCESS;
11369 
11370 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11371 
11372 	/* Verify the capabilities */
11373 	struct rte_security_capability_idx sec_cap_idx;
11374 	const struct rte_security_capability *sec_cap;
11375 	const struct rte_cryptodev_capabilities *crypto_cap;
11376 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11377 	int j = 0;
11378 
11379 	/* Set action type */
11380 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11381 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11382 		gbl_action_type;
11383 
11384 	if (security_proto_supported(ut_params->type,
11385 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11386 		return TEST_SKIPPED;
11387 
11388 	sec_cap_idx.action = ut_params->type;
11389 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11390 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11391 
11392 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11393 	if (sec_cap == NULL)
11394 		return TEST_SKIPPED;
11395 
11396 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11397 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11398 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11399 				crypto_cap->sym.xform_type ==
11400 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11401 				crypto_cap->sym.cipher.algo ==
11402 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11403 			sym_cap = &crypto_cap->sym;
11404 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11405 						d_td->key.len,
11406 						d_td->iv.len) == 0)
11407 				break;
11408 		}
11409 	}
11410 
11411 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11412 		return TEST_SKIPPED;
11413 
11414 	/* Setup source mbuf payload */
11415 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11416 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11417 			rte_pktmbuf_tailroom(ut_params->ibuf));
11418 
11419 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11420 			d_td->ciphertext.len);
11421 
11422 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11423 
11424 	/* Setup cipher session parameters */
11425 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11426 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11427 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11428 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11429 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11430 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11431 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11432 	ut_params->cipher_xform.next = NULL;
11433 
11434 	/* Setup DOCSIS session parameters */
11435 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11436 
11437 	struct rte_security_session_conf sess_conf = {
11438 		.action_type = ut_params->type,
11439 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11440 		.docsis = ut_params->docsis_xform,
11441 		.crypto_xform = &ut_params->cipher_xform,
11442 	};
11443 
11444 	/* Create security session */
11445 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11446 					ts_params->session_mpool);
11447 
11448 	if (!ut_params->sec_session) {
11449 		printf("Test function %s line %u: failed to allocate session\n",
11450 			__func__, __LINE__);
11451 		ret = TEST_FAILED;
11452 		goto on_err;
11453 	}
11454 
11455 	/* Generate crypto op data structure */
11456 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11457 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11458 	if (!ut_params->op) {
11459 		printf("Test function %s line %u: failed to allocate symmetric "
11460 			"crypto operation\n", __func__, __LINE__);
11461 		ret = TEST_FAILED;
11462 		goto on_err;
11463 	}
11464 
11465 	/* Setup CRC operation parameters */
11466 	crc_len = d_td->ciphertext.no_crc == false ?
11467 			(d_td->ciphertext.len -
11468 				d_td->ciphertext.crc_offset -
11469 				RTE_ETHER_CRC_LEN) :
11470 			0;
11471 	crc_len = crc_len > 0 ? crc_len : 0;
11472 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11473 	ut_params->op->sym->auth.data.length = crc_len;
11474 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11475 
11476 	/* Setup cipher operation parameters */
11477 	cipher_len = d_td->ciphertext.no_cipher == false ?
11478 			(d_td->ciphertext.len -
11479 				d_td->ciphertext.cipher_offset) :
11480 			0;
11481 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11482 	ut_params->op->sym->cipher.data.length = cipher_len;
11483 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11484 
11485 	/* Setup cipher IV */
11486 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11487 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11488 
11489 	/* Attach session to operation */
11490 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11491 
11492 	/* Set crypto operation mbufs */
11493 	ut_params->op->sym->m_src = ut_params->ibuf;
11494 	ut_params->op->sym->m_dst = NULL;
11495 
11496 	/* Process crypto operation */
11497 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11498 			NULL) {
11499 		printf("Test function %s line %u: failed to process security "
11500 			"crypto op\n", __func__, __LINE__);
11501 		ret = TEST_FAILED;
11502 		goto on_err;
11503 	}
11504 
11505 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11506 		printf("Test function %s line %u: failed to process crypto op\n",
11507 			__func__, __LINE__);
11508 		ret = TEST_FAILED;
11509 		goto on_err;
11510 	}
11511 
11512 	/* Validate plaintext */
11513 	plaintext = ciphertext;
11514 
11515 	if (memcmp(plaintext, d_td->plaintext.data,
11516 			d_td->plaintext.len - crc_data_len)) {
11517 		printf("Test function %s line %u: plaintext not as expected\n",
11518 			__func__, __LINE__);
11519 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
11520 				d_td->plaintext.len);
11521 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11522 		ret = TEST_FAILED;
11523 		goto on_err;
11524 	}
11525 
11526 on_err:
11527 	rte_crypto_op_free(ut_params->op);
11528 	ut_params->op = NULL;
11529 
11530 	if (ut_params->sec_session)
11531 		rte_security_session_destroy(ctx, ut_params->sec_session);
11532 	ut_params->sec_session = NULL;
11533 
11534 	rte_pktmbuf_free(ut_params->ibuf);
11535 	ut_params->ibuf = NULL;
11536 
11537 	return ret;
11538 }
11539 
11540 static int
11541 test_docsis_proto_downlink(const void *data)
11542 {
11543 	const struct docsis_test_data *d_td = data;
11544 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11545 	struct crypto_unittest_params *ut_params = &unittest_params;
11546 	uint8_t *plaintext = NULL;
11547 	uint8_t *ciphertext = NULL;
11548 	uint8_t *iv_ptr;
11549 	int32_t cipher_len, crc_len;
11550 	int ret = TEST_SUCCESS;
11551 
11552 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11553 
11554 	/* Verify the capabilities */
11555 	struct rte_security_capability_idx sec_cap_idx;
11556 	const struct rte_security_capability *sec_cap;
11557 	const struct rte_cryptodev_capabilities *crypto_cap;
11558 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11559 	int j = 0;
11560 
11561 	/* Set action type */
11562 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11563 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11564 		gbl_action_type;
11565 
11566 	if (security_proto_supported(ut_params->type,
11567 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11568 		return TEST_SKIPPED;
11569 
11570 	sec_cap_idx.action = ut_params->type;
11571 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11572 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11573 
11574 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11575 	if (sec_cap == NULL)
11576 		return TEST_SKIPPED;
11577 
11578 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11579 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11580 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11581 				crypto_cap->sym.xform_type ==
11582 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11583 				crypto_cap->sym.cipher.algo ==
11584 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11585 			sym_cap = &crypto_cap->sym;
11586 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11587 						d_td->key.len,
11588 						d_td->iv.len) == 0)
11589 				break;
11590 		}
11591 	}
11592 
11593 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11594 		return TEST_SKIPPED;
11595 
11596 	/* Setup source mbuf payload */
11597 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11598 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11599 			rte_pktmbuf_tailroom(ut_params->ibuf));
11600 
11601 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11602 			d_td->plaintext.len);
11603 
11604 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11605 
11606 	/* Setup cipher session parameters */
11607 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11608 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11609 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11610 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11611 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11612 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11613 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11614 	ut_params->cipher_xform.next = NULL;
11615 
11616 	/* Setup DOCSIS session parameters */
11617 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11618 
11619 	struct rte_security_session_conf sess_conf = {
11620 		.action_type = ut_params->type,
11621 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11622 		.docsis = ut_params->docsis_xform,
11623 		.crypto_xform = &ut_params->cipher_xform,
11624 	};
11625 
11626 	/* Create security session */
11627 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11628 					ts_params->session_mpool);
11629 
11630 	if (!ut_params->sec_session) {
11631 		printf("Test function %s line %u: failed to allocate session\n",
11632 			__func__, __LINE__);
11633 		ret = TEST_FAILED;
11634 		goto on_err;
11635 	}
11636 
11637 	/* Generate crypto op data structure */
11638 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11639 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11640 	if (!ut_params->op) {
11641 		printf("Test function %s line %u: failed to allocate symmetric "
11642 			"crypto operation\n", __func__, __LINE__);
11643 		ret = TEST_FAILED;
11644 		goto on_err;
11645 	}
11646 
11647 	/* Setup CRC operation parameters */
11648 	crc_len = d_td->plaintext.no_crc == false ?
11649 			(d_td->plaintext.len -
11650 				d_td->plaintext.crc_offset -
11651 				RTE_ETHER_CRC_LEN) :
11652 			0;
11653 	crc_len = crc_len > 0 ? crc_len : 0;
11654 	ut_params->op->sym->auth.data.length = crc_len;
11655 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11656 
11657 	/* Setup cipher operation parameters */
11658 	cipher_len = d_td->plaintext.no_cipher == false ?
11659 			(d_td->plaintext.len -
11660 				d_td->plaintext.cipher_offset) :
11661 			0;
11662 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11663 	ut_params->op->sym->cipher.data.length = cipher_len;
11664 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11665 
11666 	/* Setup cipher IV */
11667 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11668 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11669 
11670 	/* Attach session to operation */
11671 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11672 
11673 	/* Set crypto operation mbufs */
11674 	ut_params->op->sym->m_src = ut_params->ibuf;
11675 	ut_params->op->sym->m_dst = NULL;
11676 
11677 	/* Process crypto operation */
11678 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11679 			NULL) {
11680 		printf("Test function %s line %u: failed to process crypto op\n",
11681 			__func__, __LINE__);
11682 		ret = TEST_FAILED;
11683 		goto on_err;
11684 	}
11685 
11686 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11687 		printf("Test function %s line %u: crypto op processing failed\n",
11688 			__func__, __LINE__);
11689 		ret = TEST_FAILED;
11690 		goto on_err;
11691 	}
11692 
11693 	/* Validate ciphertext */
11694 	ciphertext = plaintext;
11695 
11696 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11697 		printf("Test function %s line %u: plaintext not as expected\n",
11698 			__func__, __LINE__);
11699 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11700 				d_td->ciphertext.len);
11701 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11702 		ret = TEST_FAILED;
11703 		goto on_err;
11704 	}
11705 
11706 on_err:
11707 	rte_crypto_op_free(ut_params->op);
11708 	ut_params->op = NULL;
11709 
11710 	if (ut_params->sec_session)
11711 		rte_security_session_destroy(ctx, ut_params->sec_session);
11712 	ut_params->sec_session = NULL;
11713 
11714 	rte_pktmbuf_free(ut_params->ibuf);
11715 	ut_params->ibuf = NULL;
11716 
11717 	return ret;
11718 }
11719 
11720 static void
11721 test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11722 				 struct rte_security_tls_record_xform *tls_record_xform)
11723 {
11724 	unsigned int imp_nonce_len;
11725 	uint8_t *imp_nonce;
11726 
11727 	switch (tls_record_xform->ver) {
11728 	case RTE_SECURITY_VERSION_TLS_1_2:
11729 		imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11730 		imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11731 		break;
11732 	case RTE_SECURITY_VERSION_DTLS_1_2:
11733 		imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11734 		imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11735 		break;
11736 	case RTE_SECURITY_VERSION_TLS_1_3:
11737 		imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11738 		imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11739 		break;
11740 	default:
11741 		return;
11742 	}
11743 
11744 	imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11745 	memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11746 }
11747 
11748 static int
11749 test_tls_record_proto_process(const struct tls_record_test_data td[],
11750 			      struct tls_record_test_data res_d[], int nb_td, bool silent,
11751 			      const struct tls_record_test_flags *flags)
11752 {
11753 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11754 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11755 	struct crypto_unittest_params *ut_params = &unittest_params;
11756 	struct rte_security_tls_record_xform tls_record_xform;
11757 	struct rte_security_capability_idx sec_cap_idx;
11758 	const struct rte_security_capability *sec_cap;
11759 	struct tls_record_test_data *res_d_tmp = NULL;
11760 	enum rte_security_tls_sess_type sess_type;
11761 	uint8_t dev_id = ts_params->valid_devs[0];
11762 	struct rte_security_ctx *ctx;
11763 	int i, ret = TEST_SUCCESS;
11764 
11765 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11766 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11767 
11768 	/* Use first test data to create session */
11769 
11770 	/* Copy TLS record xform */
11771 	memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11772 
11773 	sess_type = tls_record_xform.type;
11774 
11775 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
11776 
11777 	sec_cap_idx.action = ut_params->type;
11778 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11779 	sec_cap_idx.tls_record.type = tls_record_xform.type;
11780 	sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11781 
11782 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11783 	if (sec_cap == NULL)
11784 		return TEST_SKIPPED;
11785 
11786 	/* Copy cipher session parameters */
11787 	if (td[0].aead) {
11788 		memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11789 		ut_params->aead_xform.aead.key.data = td[0].key.data;
11790 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11791 
11792 		/* Verify crypto capabilities */
11793 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11794 			if (!silent)
11795 				RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11796 			return TEST_SKIPPED;
11797 		}
11798 	} else {
11799 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
11800 		       sizeof(ut_params->cipher_xform));
11801 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
11802 		       sizeof(ut_params->auth_xform));
11803 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
11804 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11805 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
11806 
11807 		/* Verify crypto capabilities */
11808 
11809 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
11810 			if (!silent)
11811 				RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
11812 			return TEST_SKIPPED;
11813 		}
11814 
11815 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
11816 			if (!silent)
11817 				RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
11818 			return TEST_SKIPPED;
11819 		}
11820 	}
11821 
11822 	if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
11823 		return TEST_SKIPPED;
11824 
11825 	struct rte_security_session_conf sess_conf = {
11826 		.action_type = ut_params->type,
11827 		.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
11828 	};
11829 
11830 	if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
11831 	    (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
11832 		sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
11833 
11834 	if (td[0].aead)
11835 		test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
11836 
11837 	sess_conf.tls_record = tls_record_xform;
11838 
11839 	if (td[0].aead) {
11840 		sess_conf.crypto_xform = &ut_params->aead_xform;
11841 	} else {
11842 		if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
11843 			sess_conf.crypto_xform = &ut_params->cipher_xform;
11844 			ut_params->cipher_xform.next = &ut_params->auth_xform;
11845 		} else {
11846 			sess_conf.crypto_xform = &ut_params->auth_xform;
11847 			ut_params->auth_xform.next = &ut_params->cipher_xform;
11848 		}
11849 	}
11850 
11851 	/* Create security session */
11852 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11853 					ts_params->session_mpool);
11854 	if (ut_params->sec_session == NULL)
11855 		return TEST_SKIPPED;
11856 
11857 	for (i = 0; i < nb_td; i++) {
11858 		if (flags->ar_win_size &&
11859 			(sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
11860 			sess_conf.tls_record.dtls_1_2.seq_no =
11861 				td[i].tls_record_xform.dtls_1_2.seq_no;
11862 			ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
11863 			if (ret) {
11864 				printf("Could not update sequence number in session\n");
11865 				return TEST_SKIPPED;
11866 			}
11867 		}
11868 
11869 		/* Setup source mbuf payload */
11870 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, td[i].input_text.len,
11871 				nb_segs, 0);
11872 		pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
11873 
11874 		/* Generate crypto op data structure */
11875 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11876 						    RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11877 		if (ut_params->op == NULL) {
11878 			printf("Could not allocate crypto op");
11879 			ret = TEST_FAILED;
11880 			goto crypto_op_free;
11881 		}
11882 
11883 		/* Attach session to operation */
11884 		rte_security_attach_session(ut_params->op, ut_params->sec_session);
11885 
11886 		/* Set crypto operation mbufs */
11887 		ut_params->op->sym->m_src = ut_params->ibuf;
11888 		ut_params->op->sym->m_dst = NULL;
11889 		ut_params->op->param1.tls_record.content_type = td[i].app_type;
11890 
11891 		/* Copy IV in crypto operation when IV generation is disabled */
11892 		if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
11893 		    (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
11894 		    (tls_record_xform.options.iv_gen_disable == 1)) {
11895 			uint8_t *iv;
11896 			int len;
11897 
11898 			iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
11899 			if (td[i].aead)
11900 				len = td[i].xform.aead.aead.iv.length - 4;
11901 			else
11902 				len = td[i].xform.chain.cipher.cipher.iv.length;
11903 			memcpy(iv, td[i].iv.data, len);
11904 		}
11905 
11906 		/* Process crypto operation */
11907 		process_crypto_request(dev_id, ut_params->op);
11908 
11909 		ret = test_tls_record_status_check(ut_params->op, &td[i]);
11910 		if (ret != TEST_SUCCESS)
11911 			goto crypto_op_free;
11912 
11913 		if (res_d != NULL)
11914 			res_d_tmp = &res_d[i];
11915 
11916 		if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
11917 			ret = test_tls_record_post_process(ut_params->ibuf, &td[i], res_d_tmp,
11918 							   silent);
11919 			if (ret != TEST_SUCCESS)
11920 				goto crypto_op_free;
11921 		}
11922 
11923 		rte_crypto_op_free(ut_params->op);
11924 		ut_params->op = NULL;
11925 
11926 		rte_pktmbuf_free(ut_params->ibuf);
11927 		ut_params->ibuf = NULL;
11928 	}
11929 
11930 crypto_op_free:
11931 	rte_crypto_op_free(ut_params->op);
11932 	ut_params->op = NULL;
11933 
11934 	rte_pktmbuf_free(ut_params->ibuf);
11935 	ut_params->ibuf = NULL;
11936 
11937 	if (ut_params->sec_session)
11938 		rte_security_session_destroy(ctx, ut_params->sec_session);
11939 	ut_params->sec_session = NULL;
11940 
11941 	RTE_SET_USED(flags);
11942 
11943 	return ret;
11944 }
11945 
11946 static int
11947 test_tls_record_proto_known_vec(const void *test_data)
11948 {
11949 	struct tls_record_test_data td_write;
11950 	struct tls_record_test_flags flags;
11951 
11952 	memset(&flags, 0, sizeof(flags));
11953 
11954 	memcpy(&td_write, test_data, sizeof(td_write));
11955 
11956 	/* Disable IV gen to be able to test with known vectors */
11957 	td_write.tls_record_xform.options.iv_gen_disable = 1;
11958 
11959 	return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
11960 }
11961 
11962 static int
11963 test_tls_record_proto_known_vec_read(const void *test_data)
11964 {
11965 	const struct tls_record_test_data *td = test_data;
11966 	struct tls_record_test_flags flags;
11967 	struct tls_record_test_data td_inb;
11968 
11969 	memset(&flags, 0, sizeof(flags));
11970 
11971 	if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
11972 		test_tls_record_td_read_from_write(td, &td_inb);
11973 	else
11974 		memcpy(&td_inb, td, sizeof(td_inb));
11975 
11976 	return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
11977 }
11978 
11979 static int
11980 test_tls_record_proto_all(const struct tls_record_test_flags *flags)
11981 {
11982 	unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
11983 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
11984 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
11985 	int ret;
11986 
11987 	switch (flags->tls_version) {
11988 	case RTE_SECURITY_VERSION_TLS_1_2:
11989 		max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
11990 		break;
11991 	case RTE_SECURITY_VERSION_TLS_1_3:
11992 		max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
11993 		break;
11994 	case RTE_SECURITY_VERSION_DTLS_1_2:
11995 		max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
11996 		break;
11997 	default:
11998 		max_payload_len = 0;
11999 	}
12000 
12001 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12002 		payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12003 		if (flags->nb_segs_in_mbuf)
12004 			payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12005 
12006 		if (flags->zero_len)
12007 			payload_len = 0;
12008 again:
12009 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12010 						 flags, td_outb, nb_pkts, payload_len);
12011 		if (ret == TEST_SKIPPED)
12012 			continue;
12013 
12014 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12015 		if (ret == TEST_SKIPPED)
12016 			continue;
12017 
12018 		if (flags->zero_len &&
12019 		    ((flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12020 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12021 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE))) {
12022 			if (ret == TEST_SUCCESS)
12023 				return TEST_FAILED;
12024 			goto skip_decrypt;
12025 		} else if (ret == TEST_FAILED) {
12026 			return TEST_FAILED;
12027 		}
12028 
12029 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12030 
12031 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12032 		if (ret == TEST_SKIPPED)
12033 			continue;
12034 
12035 		if (flags->pkt_corruption) {
12036 			if (ret == TEST_SUCCESS)
12037 				return TEST_FAILED;
12038 		} else {
12039 			if (ret == TEST_FAILED)
12040 				return TEST_FAILED;
12041 		}
12042 
12043 skip_decrypt:
12044 		if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12045 			goto again;
12046 
12047 		if (flags->display_alg)
12048 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12049 
12050 		pass_cnt++;
12051 	}
12052 
12053 	if (pass_cnt > 0)
12054 		return TEST_SUCCESS;
12055 	else
12056 		return TEST_SKIPPED;
12057 }
12058 
12059 static int
12060 test_tls_1_2_record_proto_data_walkthrough(void)
12061 {
12062 	struct tls_record_test_flags flags;
12063 
12064 	memset(&flags, 0, sizeof(flags));
12065 
12066 	flags.data_walkthrough = true;
12067 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12068 
12069 	return test_tls_record_proto_all(&flags);
12070 }
12071 
12072 static int
12073 test_tls_1_2_record_proto_display_list(void)
12074 {
12075 	struct tls_record_test_flags flags;
12076 
12077 	memset(&flags, 0, sizeof(flags));
12078 
12079 	flags.display_alg = true;
12080 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12081 
12082 	return test_tls_record_proto_all(&flags);
12083 }
12084 
12085 static int
12086 test_tls_1_2_record_proto_sgl(void)
12087 {
12088 	struct tls_record_test_flags flags = {
12089 		.nb_segs_in_mbuf = 5,
12090 		.tls_version = RTE_SECURITY_VERSION_TLS_1_2
12091 	};
12092 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12093 	struct rte_cryptodev_info dev_info;
12094 
12095 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12096 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12097 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12098 		return TEST_SKIPPED;
12099 	}
12100 
12101 	return test_tls_record_proto_all(&flags);
12102 }
12103 
12104 static int
12105 test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12106 {
12107 	struct tls_record_test_flags flags = {
12108 		.nb_segs_in_mbuf = 5,
12109 		.tls_version = tls_version,
12110 		.data_walkthrough = true
12111 	};
12112 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12113 	struct rte_cryptodev_info dev_info;
12114 
12115 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12116 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12117 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12118 		return TEST_SKIPPED;
12119 	}
12120 
12121 	return test_tls_record_proto_all(&flags);
12122 }
12123 
12124 static int
12125 test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12126 {
12127 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12128 }
12129 
12130 static int
12131 test_tls_record_proto_corrupt_pkt(void)
12132 {
12133 	struct tls_record_test_flags flags = {
12134 		.pkt_corruption = 1
12135 	};
12136 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12137 	struct rte_cryptodev_info dev_info;
12138 
12139 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12140 
12141 	return test_tls_record_proto_all(&flags);
12142 }
12143 
12144 static int
12145 test_tls_record_proto_custom_content_type(void)
12146 {
12147 	struct tls_record_test_flags flags = {
12148 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12149 	};
12150 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12151 	struct rte_cryptodev_info dev_info;
12152 
12153 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12154 
12155 	return test_tls_record_proto_all(&flags);
12156 }
12157 
12158 static int
12159 test_tls_record_proto_zero_len(void)
12160 {
12161 	struct tls_record_test_flags flags = {
12162 		.zero_len = 1
12163 	};
12164 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12165 	struct rte_cryptodev_info dev_info;
12166 
12167 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12168 
12169 	return test_tls_record_proto_all(&flags);
12170 }
12171 
12172 static int
12173 test_tls_record_proto_zero_len_non_app(void)
12174 {
12175 	struct tls_record_test_flags flags = {
12176 		.zero_len = 1,
12177 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12178 	};
12179 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12180 	struct rte_cryptodev_info dev_info;
12181 
12182 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12183 
12184 	return test_tls_record_proto_all(&flags);
12185 }
12186 
12187 static int
12188 test_dtls_1_2_record_proto_data_walkthrough(void)
12189 {
12190 	struct tls_record_test_flags flags;
12191 
12192 	memset(&flags, 0, sizeof(flags));
12193 
12194 	flags.data_walkthrough = true;
12195 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12196 
12197 	return test_tls_record_proto_all(&flags);
12198 }
12199 
12200 static int
12201 test_dtls_1_2_record_proto_display_list(void)
12202 {
12203 	struct tls_record_test_flags flags;
12204 
12205 	memset(&flags, 0, sizeof(flags));
12206 
12207 	flags.display_alg = true;
12208 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12209 
12210 	return test_tls_record_proto_all(&flags);
12211 }
12212 
12213 static int
12214 test_dtls_pkt_replay(const uint64_t seq_no[],
12215 		      bool replayed_pkt[], uint32_t nb_pkts,
12216 		      struct tls_record_test_flags *flags)
12217 {
12218 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12219 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12220 	unsigned int i, idx, pass_cnt = 0;
12221 	int ret;
12222 
12223 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12224 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12225 						 flags, td_outb, nb_pkts, 0);
12226 		if (ret == TEST_SKIPPED)
12227 			continue;
12228 
12229 		for (idx = 0; idx < nb_pkts; idx++)
12230 			td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12231 
12232 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12233 		if (ret == TEST_SKIPPED)
12234 			continue;
12235 
12236 		if (ret == TEST_FAILED)
12237 			return TEST_FAILED;
12238 
12239 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12240 
12241 		for (idx = 0; idx < nb_pkts; idx++) {
12242 			td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12243 			/* Set antireplay flag for packets to be dropped */
12244 			td_inb[idx].ar_packet = replayed_pkt[idx];
12245 		}
12246 
12247 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12248 		if (ret == TEST_SKIPPED)
12249 			continue;
12250 
12251 		if (ret == TEST_FAILED)
12252 			return TEST_FAILED;
12253 
12254 		if (flags->display_alg)
12255 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12256 
12257 		pass_cnt++;
12258 	}
12259 
12260 	if (pass_cnt > 0)
12261 		return TEST_SUCCESS;
12262 	else
12263 		return TEST_SKIPPED;
12264 }
12265 
12266 static int
12267 test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12268 {
12269 	struct tls_record_test_flags flags;
12270 	uint32_t nb_pkts = 5;
12271 	bool replayed_pkt[5];
12272 	uint64_t seq_no[5];
12273 
12274 	memset(&flags, 0, sizeof(flags));
12275 
12276 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12277 	flags.ar_win_size = winsz;
12278 
12279 	/* 1. Advance the TOP of the window to WS * 2 */
12280 	seq_no[0] = winsz * 2;
12281 	/* 2. Test sequence number within the new window(WS + 1) */
12282 	seq_no[1] = winsz + 1;
12283 	/* 3. Test sequence number less than the window BOTTOM */
12284 	seq_no[2] = winsz;
12285 	/* 4. Test sequence number in the middle of the window */
12286 	seq_no[3] = winsz + (winsz / 2);
12287 	/* 5. Test replay of the packet in the middle of the window */
12288 	seq_no[4] = winsz + (winsz / 2);
12289 
12290 	replayed_pkt[0] = false;
12291 	replayed_pkt[1] = false;
12292 	replayed_pkt[2] = true;
12293 	replayed_pkt[3] = false;
12294 	replayed_pkt[4] = true;
12295 
12296 	return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12297 }
12298 
12299 static int
12300 test_dtls_1_2_record_proto_antireplay64(void)
12301 {
12302 	return test_dtls_1_2_record_proto_antireplay(64);
12303 }
12304 
12305 static int
12306 test_dtls_1_2_record_proto_antireplay128(void)
12307 {
12308 	return test_dtls_1_2_record_proto_antireplay(128);
12309 }
12310 
12311 static int
12312 test_dtls_1_2_record_proto_antireplay256(void)
12313 {
12314 	return test_dtls_1_2_record_proto_antireplay(256);
12315 }
12316 
12317 static int
12318 test_dtls_1_2_record_proto_antireplay512(void)
12319 {
12320 	return test_dtls_1_2_record_proto_antireplay(512);
12321 }
12322 
12323 static int
12324 test_dtls_1_2_record_proto_antireplay1024(void)
12325 {
12326 	return test_dtls_1_2_record_proto_antireplay(1024);
12327 }
12328 
12329 static int
12330 test_dtls_1_2_record_proto_antireplay2048(void)
12331 {
12332 	return test_dtls_1_2_record_proto_antireplay(2048);
12333 }
12334 
12335 static int
12336 test_dtls_1_2_record_proto_antireplay4096(void)
12337 {
12338 	return test_dtls_1_2_record_proto_antireplay(4096);
12339 }
12340 
12341 static int
12342 test_dtls_1_2_record_proto_sgl(void)
12343 {
12344 	struct tls_record_test_flags flags = {
12345 		.nb_segs_in_mbuf = 5,
12346 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12347 	};
12348 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12349 	struct rte_cryptodev_info dev_info;
12350 
12351 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12352 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12353 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12354 		return TEST_SKIPPED;
12355 	}
12356 
12357 	return test_tls_record_proto_all(&flags);
12358 }
12359 
12360 static int
12361 test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12362 {
12363 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12364 }
12365 
12366 static int
12367 test_dtls_1_2_record_proto_corrupt_pkt(void)
12368 {
12369 	struct tls_record_test_flags flags = {
12370 		.pkt_corruption = 1,
12371 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12372 	};
12373 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12374 	struct rte_cryptodev_info dev_info;
12375 
12376 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12377 
12378 	return test_tls_record_proto_all(&flags);
12379 }
12380 
12381 static int
12382 test_dtls_1_2_record_proto_custom_content_type(void)
12383 {
12384 	struct tls_record_test_flags flags = {
12385 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12386 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12387 	};
12388 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12389 	struct rte_cryptodev_info dev_info;
12390 
12391 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12392 
12393 	return test_tls_record_proto_all(&flags);
12394 }
12395 
12396 static int
12397 test_dtls_1_2_record_proto_zero_len(void)
12398 {
12399 	struct tls_record_test_flags flags = {
12400 		.zero_len = 1,
12401 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12402 	};
12403 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12404 	struct rte_cryptodev_info dev_info;
12405 
12406 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12407 
12408 	return test_tls_record_proto_all(&flags);
12409 }
12410 
12411 static int
12412 test_dtls_1_2_record_proto_zero_len_non_app(void)
12413 {
12414 	struct tls_record_test_flags flags = {
12415 		.zero_len = 1,
12416 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12417 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12418 	};
12419 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12420 	struct rte_cryptodev_info dev_info;
12421 
12422 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12423 
12424 	return test_tls_record_proto_all(&flags);
12425 }
12426 
12427 #endif
12428 
12429 static int
12430 test_AES_GCM_authenticated_encryption_test_case_1(void)
12431 {
12432 	return test_authenticated_encryption(&gcm_test_case_1);
12433 }
12434 
12435 static int
12436 test_AES_GCM_authenticated_encryption_test_case_2(void)
12437 {
12438 	return test_authenticated_encryption(&gcm_test_case_2);
12439 }
12440 
12441 static int
12442 test_AES_GCM_authenticated_encryption_test_case_3(void)
12443 {
12444 	return test_authenticated_encryption(&gcm_test_case_3);
12445 }
12446 
12447 static int
12448 test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
12449 {
12450 	return test_authenticated_encryption_helper(&gcm_test_case_3, true);
12451 }
12452 
12453 static int
12454 test_AES_GCM_authenticated_encryption_test_case_4(void)
12455 {
12456 	return test_authenticated_encryption(&gcm_test_case_4);
12457 }
12458 
12459 static int
12460 test_AES_GCM_authenticated_encryption_test_case_5(void)
12461 {
12462 	return test_authenticated_encryption(&gcm_test_case_5);
12463 }
12464 
12465 static int
12466 test_AES_GCM_authenticated_encryption_test_case_6(void)
12467 {
12468 	return test_authenticated_encryption(&gcm_test_case_6);
12469 }
12470 
12471 static int
12472 test_AES_GCM_authenticated_encryption_test_case_7(void)
12473 {
12474 	return test_authenticated_encryption(&gcm_test_case_7);
12475 }
12476 
12477 static int
12478 test_AES_GCM_authenticated_encryption_test_case_8(void)
12479 {
12480 	return test_authenticated_encryption(&gcm_test_case_8);
12481 }
12482 
12483 static int
12484 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
12485 {
12486 	return test_authenticated_encryption(&gcm_J0_test_case_1);
12487 }
12488 
12489 static int
12490 test_AES_GCM_auth_encryption_test_case_192_1(void)
12491 {
12492 	return test_authenticated_encryption(&gcm_test_case_192_1);
12493 }
12494 
12495 static int
12496 test_AES_GCM_auth_encryption_test_case_192_2(void)
12497 {
12498 	return test_authenticated_encryption(&gcm_test_case_192_2);
12499 }
12500 
12501 static int
12502 test_AES_GCM_auth_encryption_test_case_192_3(void)
12503 {
12504 	return test_authenticated_encryption(&gcm_test_case_192_3);
12505 }
12506 
12507 static int
12508 test_AES_GCM_auth_encryption_test_case_192_4(void)
12509 {
12510 	return test_authenticated_encryption(&gcm_test_case_192_4);
12511 }
12512 
12513 static int
12514 test_AES_GCM_auth_encryption_test_case_192_5(void)
12515 {
12516 	return test_authenticated_encryption(&gcm_test_case_192_5);
12517 }
12518 
12519 static int
12520 test_AES_GCM_auth_encryption_test_case_192_6(void)
12521 {
12522 	return test_authenticated_encryption(&gcm_test_case_192_6);
12523 }
12524 
12525 static int
12526 test_AES_GCM_auth_encryption_test_case_192_7(void)
12527 {
12528 	return test_authenticated_encryption(&gcm_test_case_192_7);
12529 }
12530 
12531 static int
12532 test_AES_GCM_auth_encryption_test_case_256_1(void)
12533 {
12534 	return test_authenticated_encryption(&gcm_test_case_256_1);
12535 }
12536 
12537 static int
12538 test_AES_GCM_auth_encryption_test_case_256_2(void)
12539 {
12540 	return test_authenticated_encryption(&gcm_test_case_256_2);
12541 }
12542 
12543 static int
12544 test_AES_GCM_auth_encryption_test_case_256_3(void)
12545 {
12546 	return test_authenticated_encryption(&gcm_test_case_256_3);
12547 }
12548 
12549 static int
12550 test_AES_GCM_auth_encryption_test_case_256_4(void)
12551 {
12552 	return test_authenticated_encryption(&gcm_test_case_256_4);
12553 }
12554 
12555 static int
12556 test_AES_GCM_auth_encryption_test_case_256_5(void)
12557 {
12558 	return test_authenticated_encryption(&gcm_test_case_256_5);
12559 }
12560 
12561 static int
12562 test_AES_GCM_auth_encryption_test_case_256_6(void)
12563 {
12564 	return test_authenticated_encryption(&gcm_test_case_256_6);
12565 }
12566 
12567 static int
12568 test_AES_GCM_auth_encryption_test_case_256_7(void)
12569 {
12570 	return test_authenticated_encryption(&gcm_test_case_256_7);
12571 }
12572 
12573 static int
12574 test_AES_GCM_auth_encryption_test_case_aad_1(void)
12575 {
12576 	return test_authenticated_encryption(&gcm_test_case_aad_1);
12577 }
12578 
12579 static int
12580 test_AES_GCM_auth_encryption_test_case_aad_2(void)
12581 {
12582 	return test_authenticated_encryption(&gcm_test_case_aad_2);
12583 }
12584 
12585 static int
12586 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
12587 {
12588 	struct aead_test_data tdata;
12589 	int res;
12590 
12591 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12592 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12593 	tdata.iv.data[0] += 1;
12594 	res = test_authenticated_encryption(&tdata);
12595 	if (res == TEST_SKIPPED)
12596 		return res;
12597 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12598 	return TEST_SUCCESS;
12599 }
12600 
12601 static int
12602 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
12603 {
12604 	struct aead_test_data tdata;
12605 	int res;
12606 
12607 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12608 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12609 	tdata.plaintext.data[0] += 1;
12610 	res = test_authenticated_encryption(&tdata);
12611 	if (res == TEST_SKIPPED)
12612 		return res;
12613 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12614 	return TEST_SUCCESS;
12615 }
12616 
12617 static int
12618 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
12619 {
12620 	struct aead_test_data tdata;
12621 	int res;
12622 
12623 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12624 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12625 	tdata.ciphertext.data[0] += 1;
12626 	res = test_authenticated_encryption(&tdata);
12627 	if (res == TEST_SKIPPED)
12628 		return res;
12629 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12630 	return TEST_SUCCESS;
12631 }
12632 
12633 static int
12634 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
12635 {
12636 	struct aead_test_data tdata;
12637 	int res;
12638 
12639 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12640 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12641 	tdata.aad.len += 1;
12642 	res = test_authenticated_encryption(&tdata);
12643 	if (res == TEST_SKIPPED)
12644 		return res;
12645 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12646 	return TEST_SUCCESS;
12647 }
12648 
12649 static int
12650 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
12651 {
12652 	struct aead_test_data tdata;
12653 	uint8_t aad[gcm_test_case_7.aad.len];
12654 	int res;
12655 
12656 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12657 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12658 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12659 	aad[0] += 1;
12660 	tdata.aad.data = aad;
12661 	res = test_authenticated_encryption(&tdata);
12662 	if (res == TEST_SKIPPED)
12663 		return res;
12664 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12665 	return TEST_SUCCESS;
12666 }
12667 
12668 static int
12669 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
12670 {
12671 	struct aead_test_data tdata;
12672 	int res;
12673 
12674 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12675 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12676 	tdata.auth_tag.data[0] += 1;
12677 	res = test_authenticated_encryption(&tdata);
12678 	if (res == TEST_SKIPPED)
12679 		return res;
12680 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12681 	return TEST_SUCCESS;
12682 }
12683 
12684 static int
12685 test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
12686 {
12687 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12688 	struct crypto_unittest_params *ut_params = &unittest_params;
12689 
12690 	int retval;
12691 	uint8_t *plaintext;
12692 	uint32_t i;
12693 	struct rte_cryptodev_info dev_info;
12694 
12695 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12696 	uint64_t feat_flags = dev_info.feature_flags;
12697 
12698 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12699 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12700 		printf("Device doesn't support RAW data-path APIs.\n");
12701 		return TEST_SKIPPED;
12702 	}
12703 
12704 	/* Verify the capabilities */
12705 	struct rte_cryptodev_sym_capability_idx cap_idx;
12706 	const struct rte_cryptodev_symmetric_capability *capability;
12707 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12708 	cap_idx.algo.aead = tdata->algo;
12709 	capability = rte_cryptodev_sym_capability_get(
12710 			ts_params->valid_devs[0], &cap_idx);
12711 	if (capability == NULL)
12712 		return TEST_SKIPPED;
12713 	if (rte_cryptodev_sym_capability_check_aead(
12714 			capability, tdata->key.len, tdata->auth_tag.len,
12715 			tdata->aad.len, tdata->iv.len))
12716 		return TEST_SKIPPED;
12717 
12718 	/* Create AEAD session */
12719 	retval = create_aead_session(ts_params->valid_devs[0],
12720 			tdata->algo,
12721 			RTE_CRYPTO_AEAD_OP_DECRYPT,
12722 			tdata->key.data, tdata->key.len,
12723 			tdata->aad.len, tdata->auth_tag.len,
12724 			tdata->iv.len);
12725 	if (retval != TEST_SUCCESS)
12726 		return retval;
12727 
12728 	/* alloc mbuf and set payload */
12729 	if (tdata->aad.len > MBUF_SIZE) {
12730 		if (use_ext_mbuf) {
12731 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
12732 							  AEAD_TEXT_MAX_LENGTH,
12733 							  1 /* nb_segs */,
12734 							  NULL);
12735 		} else {
12736 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12737 		}
12738 		/* Populate full size of add data */
12739 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
12740 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
12741 	} else {
12742 		if (use_ext_mbuf) {
12743 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
12744 							  AEAD_TEXT_MAX_LENGTH,
12745 							  1 /* nb_segs */,
12746 							  NULL);
12747 		} else {
12748 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12749 		}
12750 	}
12751 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12752 			rte_pktmbuf_tailroom(ut_params->ibuf));
12753 
12754 	/* Create AEAD operation */
12755 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12756 	if (retval < 0)
12757 		return retval;
12758 
12759 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12760 
12761 	ut_params->op->sym->m_src = ut_params->ibuf;
12762 
12763 	/* Process crypto operation */
12764 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12765 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12766 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12767 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12768 					       0);
12769 		if (retval != TEST_SUCCESS)
12770 			return retval;
12771 	} else
12772 		TEST_ASSERT_NOT_NULL(
12773 			process_crypto_request(ts_params->valid_devs[0],
12774 			ut_params->op), "failed to process sym crypto op");
12775 
12776 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12777 			"crypto op processing failed");
12778 
12779 	if (ut_params->op->sym->m_dst)
12780 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
12781 				uint8_t *);
12782 	else
12783 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12784 				uint8_t *,
12785 				ut_params->op->sym->cipher.data.offset);
12786 
12787 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12788 
12789 	/* Validate obuf */
12790 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12791 			plaintext,
12792 			tdata->plaintext.data,
12793 			tdata->plaintext.len,
12794 			"Plaintext data not as expected");
12795 
12796 	TEST_ASSERT_EQUAL(ut_params->op->status,
12797 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12798 			"Authentication failed");
12799 
12800 	return 0;
12801 }
12802 
12803 static int
12804 test_authenticated_decryption(const struct aead_test_data *tdata)
12805 {
12806 	return test_authenticated_decryption_helper(tdata, false);
12807 }
12808 
12809 static int
12810 test_AES_GCM_authenticated_decryption_test_case_1(void)
12811 {
12812 	return test_authenticated_decryption(&gcm_test_case_1);
12813 }
12814 
12815 static int
12816 test_AES_GCM_authenticated_decryption_test_case_2(void)
12817 {
12818 	return test_authenticated_decryption(&gcm_test_case_2);
12819 }
12820 
12821 static int
12822 test_AES_GCM_authenticated_decryption_test_case_3(void)
12823 {
12824 	return test_authenticated_decryption(&gcm_test_case_3);
12825 }
12826 
12827 static int
12828 test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
12829 {
12830 	return test_authenticated_decryption_helper(&gcm_test_case_3, true);
12831 }
12832 
12833 static int
12834 test_AES_GCM_authenticated_decryption_test_case_4(void)
12835 {
12836 	return test_authenticated_decryption(&gcm_test_case_4);
12837 }
12838 
12839 static int
12840 test_AES_GCM_authenticated_decryption_test_case_5(void)
12841 {
12842 	return test_authenticated_decryption(&gcm_test_case_5);
12843 }
12844 
12845 static int
12846 test_AES_GCM_authenticated_decryption_test_case_6(void)
12847 {
12848 	return test_authenticated_decryption(&gcm_test_case_6);
12849 }
12850 
12851 static int
12852 test_AES_GCM_authenticated_decryption_test_case_7(void)
12853 {
12854 	return test_authenticated_decryption(&gcm_test_case_7);
12855 }
12856 
12857 static int
12858 test_AES_GCM_authenticated_decryption_test_case_8(void)
12859 {
12860 	return test_authenticated_decryption(&gcm_test_case_8);
12861 }
12862 
12863 static int
12864 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
12865 {
12866 	return test_authenticated_decryption(&gcm_J0_test_case_1);
12867 }
12868 
12869 static int
12870 test_AES_GCM_auth_decryption_test_case_192_1(void)
12871 {
12872 	return test_authenticated_decryption(&gcm_test_case_192_1);
12873 }
12874 
12875 static int
12876 test_AES_GCM_auth_decryption_test_case_192_2(void)
12877 {
12878 	return test_authenticated_decryption(&gcm_test_case_192_2);
12879 }
12880 
12881 static int
12882 test_AES_GCM_auth_decryption_test_case_192_3(void)
12883 {
12884 	return test_authenticated_decryption(&gcm_test_case_192_3);
12885 }
12886 
12887 static int
12888 test_AES_GCM_auth_decryption_test_case_192_4(void)
12889 {
12890 	return test_authenticated_decryption(&gcm_test_case_192_4);
12891 }
12892 
12893 static int
12894 test_AES_GCM_auth_decryption_test_case_192_5(void)
12895 {
12896 	return test_authenticated_decryption(&gcm_test_case_192_5);
12897 }
12898 
12899 static int
12900 test_AES_GCM_auth_decryption_test_case_192_6(void)
12901 {
12902 	return test_authenticated_decryption(&gcm_test_case_192_6);
12903 }
12904 
12905 static int
12906 test_AES_GCM_auth_decryption_test_case_192_7(void)
12907 {
12908 	return test_authenticated_decryption(&gcm_test_case_192_7);
12909 }
12910 
12911 static int
12912 test_AES_GCM_auth_decryption_test_case_256_1(void)
12913 {
12914 	return test_authenticated_decryption(&gcm_test_case_256_1);
12915 }
12916 
12917 static int
12918 test_AES_GCM_auth_decryption_test_case_256_2(void)
12919 {
12920 	return test_authenticated_decryption(&gcm_test_case_256_2);
12921 }
12922 
12923 static int
12924 test_AES_GCM_auth_decryption_test_case_256_3(void)
12925 {
12926 	return test_authenticated_decryption(&gcm_test_case_256_3);
12927 }
12928 
12929 static int
12930 test_AES_GCM_auth_decryption_test_case_256_4(void)
12931 {
12932 	return test_authenticated_decryption(&gcm_test_case_256_4);
12933 }
12934 
12935 static int
12936 test_AES_GCM_auth_decryption_test_case_256_5(void)
12937 {
12938 	return test_authenticated_decryption(&gcm_test_case_256_5);
12939 }
12940 
12941 static int
12942 test_AES_GCM_auth_decryption_test_case_256_6(void)
12943 {
12944 	return test_authenticated_decryption(&gcm_test_case_256_6);
12945 }
12946 
12947 static int
12948 test_AES_GCM_auth_decryption_test_case_256_7(void)
12949 {
12950 	return test_authenticated_decryption(&gcm_test_case_256_7);
12951 }
12952 
12953 static int
12954 test_AES_GCM_auth_decryption_test_case_256_8(void)
12955 {
12956 	return test_authenticated_decryption(&gcm_test_case_256_8);
12957 }
12958 
12959 static int
12960 test_AES_GCM_auth_encryption_test_case_256_8(void)
12961 {
12962 	return test_authenticated_encryption(&gcm_test_case_256_8);
12963 }
12964 
12965 static int
12966 test_AES_GCM_auth_decryption_test_case_aad_1(void)
12967 {
12968 	return test_authenticated_decryption(&gcm_test_case_aad_1);
12969 }
12970 
12971 static int
12972 test_AES_GCM_auth_decryption_test_case_aad_2(void)
12973 {
12974 	return test_authenticated_decryption(&gcm_test_case_aad_2);
12975 }
12976 
12977 static int
12978 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
12979 {
12980 	struct aead_test_data tdata;
12981 	int res;
12982 
12983 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12984 	tdata.iv.data[0] += 1;
12985 	res = test_authenticated_decryption(&tdata);
12986 	if (res == TEST_SKIPPED)
12987 		return res;
12988 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
12989 	return TEST_SUCCESS;
12990 }
12991 
12992 static int
12993 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
12994 {
12995 	struct aead_test_data tdata;
12996 	int res;
12997 
12998 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12999 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13000 	tdata.plaintext.data[0] += 1;
13001 	res = test_authenticated_decryption(&tdata);
13002 	if (res == TEST_SKIPPED)
13003 		return res;
13004 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13005 	return TEST_SUCCESS;
13006 }
13007 
13008 static int
13009 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13010 {
13011 	struct aead_test_data tdata;
13012 	int res;
13013 
13014 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13015 	tdata.ciphertext.data[0] += 1;
13016 	res = test_authenticated_decryption(&tdata);
13017 	if (res == TEST_SKIPPED)
13018 		return res;
13019 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13020 	return TEST_SUCCESS;
13021 }
13022 
13023 static int
13024 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13025 {
13026 	struct aead_test_data tdata;
13027 	int res;
13028 
13029 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13030 	tdata.aad.len += 1;
13031 	res = test_authenticated_decryption(&tdata);
13032 	if (res == TEST_SKIPPED)
13033 		return res;
13034 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13035 	return TEST_SUCCESS;
13036 }
13037 
13038 static int
13039 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13040 {
13041 	struct aead_test_data tdata;
13042 	uint8_t aad[gcm_test_case_7.aad.len];
13043 	int res;
13044 
13045 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13046 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13047 	aad[0] += 1;
13048 	tdata.aad.data = aad;
13049 	res = test_authenticated_decryption(&tdata);
13050 	if (res == TEST_SKIPPED)
13051 		return res;
13052 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13053 	return TEST_SUCCESS;
13054 }
13055 
13056 static int
13057 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13058 {
13059 	struct aead_test_data tdata;
13060 	int res;
13061 
13062 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13063 	tdata.auth_tag.data[0] += 1;
13064 	res = test_authenticated_decryption(&tdata);
13065 	if (res == TEST_SKIPPED)
13066 		return res;
13067 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13068 	return TEST_SUCCESS;
13069 }
13070 
13071 static int
13072 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13073 {
13074 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13075 	struct crypto_unittest_params *ut_params = &unittest_params;
13076 
13077 	int retval;
13078 	uint8_t *ciphertext, *auth_tag;
13079 	uint16_t plaintext_pad_len;
13080 	struct rte_cryptodev_info dev_info;
13081 
13082 	/* Verify the capabilities */
13083 	struct rte_cryptodev_sym_capability_idx cap_idx;
13084 	const struct rte_cryptodev_symmetric_capability *capability;
13085 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13086 	cap_idx.algo.aead = tdata->algo;
13087 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13088 	if (capability == NULL)
13089 		return TEST_SKIPPED;
13090 	if (rte_cryptodev_sym_capability_check_aead(
13091 		capability, tdata->key.len, tdata->auth_tag.len,
13092 		tdata->aad.len, tdata->iv.len))
13093 		return TEST_SKIPPED;
13094 
13095 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13096 	uint64_t feat_flags = dev_info.feature_flags;
13097 
13098 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13099 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13100 		return TEST_SKIPPED;
13101 
13102 	/* not supported with CPU crypto */
13103 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13104 		return TEST_SKIPPED;
13105 
13106 	/* Create AEAD session */
13107 	retval = create_aead_session(ts_params->valid_devs[0],
13108 			tdata->algo,
13109 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13110 			tdata->key.data, tdata->key.len,
13111 			tdata->aad.len, tdata->auth_tag.len,
13112 			tdata->iv.len);
13113 	if (retval < 0)
13114 		return retval;
13115 
13116 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13117 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13118 
13119 	/* clear mbuf payload */
13120 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13121 			rte_pktmbuf_tailroom(ut_params->ibuf));
13122 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13123 			rte_pktmbuf_tailroom(ut_params->obuf));
13124 
13125 	/* Create AEAD operation */
13126 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13127 	if (retval < 0)
13128 		return retval;
13129 
13130 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13131 
13132 	ut_params->op->sym->m_src = ut_params->ibuf;
13133 	ut_params->op->sym->m_dst = ut_params->obuf;
13134 
13135 	/* Process crypto operation */
13136 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13137 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13138 					       0);
13139 		if (retval != TEST_SUCCESS)
13140 			return retval;
13141 	} else
13142 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13143 			ut_params->op), "failed to process sym crypto op");
13144 
13145 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13146 			"crypto op processing failed");
13147 
13148 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13149 
13150 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13151 			ut_params->op->sym->cipher.data.offset);
13152 	auth_tag = ciphertext + plaintext_pad_len;
13153 
13154 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13155 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13156 
13157 	/* Validate obuf */
13158 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13159 			ciphertext,
13160 			tdata->ciphertext.data,
13161 			tdata->ciphertext.len,
13162 			"Ciphertext data not as expected");
13163 
13164 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13165 			auth_tag,
13166 			tdata->auth_tag.data,
13167 			tdata->auth_tag.len,
13168 			"Generated auth tag not as expected");
13169 
13170 	return 0;
13171 
13172 }
13173 
13174 static int
13175 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13176 {
13177 	return test_authenticated_encryption_oop(&gcm_test_case_5);
13178 }
13179 
13180 static int
13181 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13182 {
13183 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13184 	struct crypto_unittest_params *ut_params = &unittest_params;
13185 
13186 	int retval;
13187 	uint8_t *plaintext;
13188 	struct rte_cryptodev_info dev_info;
13189 
13190 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13191 	uint64_t feat_flags = dev_info.feature_flags;
13192 
13193 	/* Verify the capabilities */
13194 	struct rte_cryptodev_sym_capability_idx cap_idx;
13195 	const struct rte_cryptodev_symmetric_capability *capability;
13196 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13197 	cap_idx.algo.aead = tdata->algo;
13198 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13199 
13200 	if (capability == NULL)
13201 		return TEST_SKIPPED;
13202 
13203 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13204 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13205 		return TEST_SKIPPED;
13206 
13207 	/* not supported with CPU crypto and raw data-path APIs*/
13208 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13209 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
13210 		return TEST_SKIPPED;
13211 
13212 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13213 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13214 		printf("Device does not support RAW data-path APIs.\n");
13215 		return TEST_SKIPPED;
13216 	}
13217 
13218 	/* Create AEAD session */
13219 	retval = create_aead_session(ts_params->valid_devs[0],
13220 			tdata->algo,
13221 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13222 			tdata->key.data, tdata->key.len,
13223 			tdata->aad.len, tdata->auth_tag.len,
13224 			tdata->iv.len);
13225 	if (retval < 0)
13226 		return retval;
13227 
13228 	/* alloc mbuf and set payload */
13229 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13230 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13231 
13232 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13233 			rte_pktmbuf_tailroom(ut_params->ibuf));
13234 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13235 			rte_pktmbuf_tailroom(ut_params->obuf));
13236 
13237 	/* Create AEAD operation */
13238 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13239 	if (retval < 0)
13240 		return retval;
13241 
13242 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13243 
13244 	ut_params->op->sym->m_src = ut_params->ibuf;
13245 	ut_params->op->sym->m_dst = ut_params->obuf;
13246 
13247 	/* Process crypto operation */
13248 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13249 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13250 					       0);
13251 		if (retval != TEST_SUCCESS)
13252 			return retval;
13253 	} else
13254 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13255 			ut_params->op), "failed to process sym crypto op");
13256 
13257 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13258 			"crypto op processing failed");
13259 
13260 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13261 			ut_params->op->sym->cipher.data.offset);
13262 
13263 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13264 
13265 	/* Validate obuf */
13266 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13267 			plaintext,
13268 			tdata->plaintext.data,
13269 			tdata->plaintext.len,
13270 			"Plaintext data not as expected");
13271 
13272 	TEST_ASSERT_EQUAL(ut_params->op->status,
13273 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13274 			"Authentication failed");
13275 	return 0;
13276 }
13277 
13278 static int
13279 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
13280 {
13281 	return test_authenticated_decryption_oop(&gcm_test_case_5);
13282 }
13283 
13284 static int
13285 test_authenticated_encryption_sessionless(
13286 		const struct aead_test_data *tdata)
13287 {
13288 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13289 	struct crypto_unittest_params *ut_params = &unittest_params;
13290 
13291 	int retval;
13292 	uint8_t *ciphertext, *auth_tag;
13293 	uint16_t plaintext_pad_len;
13294 	uint8_t key[tdata->key.len + 1];
13295 	struct rte_cryptodev_info dev_info;
13296 
13297 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13298 	uint64_t feat_flags = dev_info.feature_flags;
13299 
13300 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13301 		printf("Device doesn't support Sessionless ops.\n");
13302 		return TEST_SKIPPED;
13303 	}
13304 
13305 	/* not supported with CPU crypto */
13306 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13307 		return TEST_SKIPPED;
13308 
13309 	/* Verify the capabilities */
13310 	struct rte_cryptodev_sym_capability_idx cap_idx;
13311 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13312 	cap_idx.algo.aead = tdata->algo;
13313 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13314 			&cap_idx) == NULL)
13315 		return TEST_SKIPPED;
13316 
13317 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13318 
13319 	/* clear mbuf payload */
13320 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13321 			rte_pktmbuf_tailroom(ut_params->ibuf));
13322 
13323 	/* Create AEAD operation */
13324 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13325 	if (retval < 0)
13326 		return retval;
13327 
13328 	/* Create GCM xform */
13329 	memcpy(key, tdata->key.data, tdata->key.len);
13330 	retval = create_aead_xform(ut_params->op,
13331 			tdata->algo,
13332 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13333 			key, tdata->key.len,
13334 			tdata->aad.len, tdata->auth_tag.len,
13335 			tdata->iv.len);
13336 	if (retval < 0)
13337 		return retval;
13338 
13339 	ut_params->op->sym->m_src = ut_params->ibuf;
13340 
13341 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13342 			RTE_CRYPTO_OP_SESSIONLESS,
13343 			"crypto op session type not sessionless");
13344 
13345 	/* Process crypto operation */
13346 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13347 			ut_params->op), "failed to process sym crypto op");
13348 
13349 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13350 
13351 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13352 			"crypto op status not success");
13353 
13354 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13355 
13356 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13357 			ut_params->op->sym->cipher.data.offset);
13358 	auth_tag = ciphertext + plaintext_pad_len;
13359 
13360 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13361 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13362 
13363 	/* Validate obuf */
13364 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13365 			ciphertext,
13366 			tdata->ciphertext.data,
13367 			tdata->ciphertext.len,
13368 			"Ciphertext data not as expected");
13369 
13370 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13371 			auth_tag,
13372 			tdata->auth_tag.data,
13373 			tdata->auth_tag.len,
13374 			"Generated auth tag not as expected");
13375 
13376 	return 0;
13377 
13378 }
13379 
13380 static int
13381 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
13382 {
13383 	return test_authenticated_encryption_sessionless(
13384 			&gcm_test_case_5);
13385 }
13386 
13387 static int
13388 test_authenticated_decryption_sessionless(
13389 		const struct aead_test_data *tdata)
13390 {
13391 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13392 	struct crypto_unittest_params *ut_params = &unittest_params;
13393 
13394 	int retval;
13395 	uint8_t *plaintext;
13396 	uint8_t key[tdata->key.len + 1];
13397 	struct rte_cryptodev_info dev_info;
13398 
13399 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13400 	uint64_t feat_flags = dev_info.feature_flags;
13401 
13402 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13403 		printf("Device doesn't support Sessionless ops.\n");
13404 		return TEST_SKIPPED;
13405 	}
13406 
13407 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13408 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13409 		printf("Device doesn't support RAW data-path APIs.\n");
13410 		return TEST_SKIPPED;
13411 	}
13412 
13413 	/* not supported with CPU crypto */
13414 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13415 		return TEST_SKIPPED;
13416 
13417 	/* Verify the capabilities */
13418 	struct rte_cryptodev_sym_capability_idx cap_idx;
13419 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13420 	cap_idx.algo.aead = tdata->algo;
13421 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13422 			&cap_idx) == NULL)
13423 		return TEST_SKIPPED;
13424 
13425 	/* alloc mbuf and set payload */
13426 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13427 
13428 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13429 			rte_pktmbuf_tailroom(ut_params->ibuf));
13430 
13431 	/* Create AEAD operation */
13432 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13433 	if (retval < 0)
13434 		return retval;
13435 
13436 	/* Create AEAD xform */
13437 	memcpy(key, tdata->key.data, tdata->key.len);
13438 	retval = create_aead_xform(ut_params->op,
13439 			tdata->algo,
13440 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13441 			key, tdata->key.len,
13442 			tdata->aad.len, tdata->auth_tag.len,
13443 			tdata->iv.len);
13444 	if (retval < 0)
13445 		return retval;
13446 
13447 	ut_params->op->sym->m_src = ut_params->ibuf;
13448 
13449 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13450 			RTE_CRYPTO_OP_SESSIONLESS,
13451 			"crypto op session type not sessionless");
13452 
13453 	/* Process crypto operation */
13454 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13455 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13456 					       0);
13457 		if (retval != TEST_SUCCESS)
13458 			return retval;
13459 	} else
13460 		TEST_ASSERT_NOT_NULL(process_crypto_request(
13461 			ts_params->valid_devs[0], ut_params->op),
13462 				"failed to process sym crypto op");
13463 
13464 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13465 
13466 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13467 			"crypto op status not success");
13468 
13469 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13470 			ut_params->op->sym->cipher.data.offset);
13471 
13472 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13473 
13474 	/* Validate obuf */
13475 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13476 			plaintext,
13477 			tdata->plaintext.data,
13478 			tdata->plaintext.len,
13479 			"Plaintext data not as expected");
13480 
13481 	TEST_ASSERT_EQUAL(ut_params->op->status,
13482 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13483 			"Authentication failed");
13484 	return 0;
13485 }
13486 
13487 static int
13488 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
13489 {
13490 	return test_authenticated_decryption_sessionless(
13491 			&gcm_test_case_5);
13492 }
13493 
13494 static int
13495 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
13496 {
13497 	return test_authenticated_encryption(&ccm_test_case_128_1);
13498 }
13499 
13500 static int
13501 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
13502 {
13503 	return test_authenticated_encryption(&ccm_test_case_128_2);
13504 }
13505 
13506 static int
13507 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
13508 {
13509 	return test_authenticated_encryption(&ccm_test_case_128_3);
13510 }
13511 
13512 static int
13513 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
13514 {
13515 	return test_authenticated_decryption(&ccm_test_case_128_1);
13516 }
13517 
13518 static int
13519 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
13520 {
13521 	return test_authenticated_decryption(&ccm_test_case_128_2);
13522 }
13523 
13524 static int
13525 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
13526 {
13527 	return test_authenticated_decryption(&ccm_test_case_128_3);
13528 }
13529 
13530 static int
13531 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
13532 {
13533 	return test_authenticated_encryption(&ccm_test_case_192_1);
13534 }
13535 
13536 static int
13537 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
13538 {
13539 	return test_authenticated_encryption(&ccm_test_case_192_2);
13540 }
13541 
13542 static int
13543 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
13544 {
13545 	return test_authenticated_encryption(&ccm_test_case_192_3);
13546 }
13547 
13548 static int
13549 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
13550 {
13551 	return test_authenticated_decryption(&ccm_test_case_192_1);
13552 }
13553 
13554 static int
13555 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
13556 {
13557 	return test_authenticated_decryption(&ccm_test_case_192_2);
13558 }
13559 
13560 static int
13561 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
13562 {
13563 	return test_authenticated_decryption(&ccm_test_case_192_3);
13564 }
13565 
13566 static int
13567 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
13568 {
13569 	return test_authenticated_encryption(&ccm_test_case_256_1);
13570 }
13571 
13572 static int
13573 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
13574 {
13575 	return test_authenticated_encryption(&ccm_test_case_256_2);
13576 }
13577 
13578 static int
13579 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
13580 {
13581 	return test_authenticated_encryption(&ccm_test_case_256_3);
13582 }
13583 
13584 static int
13585 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
13586 {
13587 	return test_authenticated_decryption(&ccm_test_case_256_1);
13588 }
13589 
13590 static int
13591 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
13592 {
13593 	return test_authenticated_decryption(&ccm_test_case_256_2);
13594 }
13595 
13596 static int
13597 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
13598 {
13599 	return test_authenticated_decryption(&ccm_test_case_256_3);
13600 }
13601 
13602 static int
13603 test_stats(void)
13604 {
13605 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13606 	struct rte_cryptodev_stats stats;
13607 
13608 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13609 		return TEST_SKIPPED;
13610 
13611 	/* Verify the capabilities */
13612 	struct rte_cryptodev_sym_capability_idx cap_idx;
13613 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13614 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
13615 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13616 			&cap_idx) == NULL)
13617 		return TEST_SKIPPED;
13618 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13619 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13620 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13621 			&cap_idx) == NULL)
13622 		return TEST_SKIPPED;
13623 
13624 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
13625 			== -ENOTSUP)
13626 		return TEST_SKIPPED;
13627 
13628 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13629 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
13630 			&stats) == -ENODEV),
13631 		"rte_cryptodev_stats_get invalid dev failed");
13632 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
13633 		"rte_cryptodev_stats_get invalid Param failed");
13634 
13635 	/* Test expected values */
13636 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
13637 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13638 			&stats),
13639 		"rte_cryptodev_stats_get failed");
13640 	TEST_ASSERT((stats.enqueued_count == 1),
13641 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
13642 	TEST_ASSERT((stats.dequeued_count == 1),
13643 		"rte_cryptodev_stats_get returned unexpected dequeued stat");
13644 	TEST_ASSERT((stats.enqueue_err_count == 0),
13645 		"rte_cryptodev_stats_get returned unexpected enqueued error count stat");
13646 	TEST_ASSERT((stats.dequeue_err_count == 0),
13647 		"rte_cryptodev_stats_get returned unexpected dequeued error count stat");
13648 
13649 	/* invalid device but should ignore and not reset device stats*/
13650 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
13651 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13652 			&stats),
13653 		"rte_cryptodev_stats_get failed");
13654 	TEST_ASSERT((stats.enqueued_count == 1),
13655 		"rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
13656 
13657 	/* check that a valid reset clears stats */
13658 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13659 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13660 			&stats),
13661 					  "rte_cryptodev_stats_get failed");
13662 	TEST_ASSERT((stats.enqueued_count == 0),
13663 		"rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
13664 	TEST_ASSERT((stats.dequeued_count == 0),
13665 		"rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
13666 
13667 	return TEST_SUCCESS;
13668 }
13669 
13670 static int
13671 test_device_reconfigure(void)
13672 {
13673 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13674 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
13675 	struct rte_cryptodev_qp_conf qp_conf = {
13676 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT,
13677 		.mp_session = ts_params->session_mpool
13678 	};
13679 	uint16_t qp_id, dev_id, num_devs = 0;
13680 
13681 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
13682 			"Need at least %d devices for test", 1);
13683 
13684 	dev_id = ts_params->valid_devs[0];
13685 
13686 	/* Stop the device in case it's started so it can be configured */
13687 	rte_cryptodev_stop(dev_id);
13688 
13689 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13690 			"Failed test for rte_cryptodev_configure: "
13691 			"dev_num %u", dev_id);
13692 
13693 	/* Reconfigure with same configure params */
13694 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13695 			"Failed test for rte_cryptodev_configure: "
13696 			"dev_num %u", dev_id);
13697 
13698 	/* Reconfigure with just one queue pair */
13699 	ts_params->conf.nb_queue_pairs = 1;
13700 
13701 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13702 			&ts_params->conf),
13703 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
13704 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13705 
13706 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13707 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13708 				ts_params->valid_devs[0], qp_id, &qp_conf,
13709 				rte_cryptodev_socket_id(
13710 						ts_params->valid_devs[0])),
13711 				"Failed test for "
13712 				"rte_cryptodev_queue_pair_setup: num_inflights "
13713 				"%u on qp %u on cryptodev %u",
13714 				qp_conf.nb_descriptors, qp_id,
13715 				ts_params->valid_devs[0]);
13716 	}
13717 
13718 	/* Reconfigure with max number of queue pairs */
13719 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
13720 
13721 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13722 			&ts_params->conf),
13723 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
13724 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13725 
13726 	qp_conf.mp_session = ts_params->session_mpool;
13727 
13728 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13729 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13730 				ts_params->valid_devs[0], qp_id, &qp_conf,
13731 				rte_cryptodev_socket_id(
13732 						ts_params->valid_devs[0])),
13733 				"Failed test for "
13734 				"rte_cryptodev_queue_pair_setup: num_inflights "
13735 				"%u on qp %u on cryptodev %u",
13736 				qp_conf.nb_descriptors, qp_id,
13737 				ts_params->valid_devs[0]);
13738 	}
13739 
13740 	/* Start the device */
13741 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
13742 			"Failed to start cryptodev %u",
13743 			ts_params->valid_devs[0]);
13744 
13745 	/* Test expected values */
13746 	return test_AES_CBC_HMAC_SHA1_encrypt_digest();
13747 }
13748 
13749 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
13750 				   struct crypto_unittest_params *ut_params,
13751 				   enum rte_crypto_auth_operation op,
13752 				   const struct HMAC_MD5_vector *test_case)
13753 {
13754 	uint8_t key[64];
13755 
13756 	memcpy(key, test_case->key.data, test_case->key.len);
13757 
13758 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13759 	ut_params->auth_xform.next = NULL;
13760 	ut_params->auth_xform.auth.op = op;
13761 
13762 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
13763 
13764 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
13765 	ut_params->auth_xform.auth.key.length = test_case->key.len;
13766 	ut_params->auth_xform.auth.key.data = key;
13767 
13768 	ut_params->sess = rte_cryptodev_sym_session_create(
13769 		ts_params->valid_devs[0], &ut_params->auth_xform,
13770 			ts_params->session_mpool);
13771 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13772 		return TEST_SKIPPED;
13773 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13774 
13775 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13776 
13777 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13778 			rte_pktmbuf_tailroom(ut_params->ibuf));
13779 
13780 	return 0;
13781 }
13782 
13783 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
13784 			      const struct HMAC_MD5_vector *test_case,
13785 			      uint8_t **plaintext)
13786 {
13787 	uint16_t plaintext_pad_len;
13788 
13789 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13790 
13791 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13792 				16);
13793 
13794 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13795 			plaintext_pad_len);
13796 	memcpy(*plaintext, test_case->plaintext.data,
13797 			test_case->plaintext.len);
13798 
13799 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13800 			ut_params->ibuf, MD5_DIGEST_LEN);
13801 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13802 			"no room to append digest");
13803 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13804 			ut_params->ibuf, plaintext_pad_len);
13805 
13806 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13807 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
13808 			   test_case->auth_tag.len);
13809 	}
13810 
13811 	sym_op->auth.data.offset = 0;
13812 	sym_op->auth.data.length = test_case->plaintext.len;
13813 
13814 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13815 	ut_params->op->sym->m_src = ut_params->ibuf;
13816 
13817 	return 0;
13818 }
13819 
13820 static int
13821 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
13822 {
13823 	uint16_t plaintext_pad_len;
13824 	uint8_t *plaintext, *auth_tag;
13825 	int ret;
13826 
13827 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13828 	struct crypto_unittest_params *ut_params = &unittest_params;
13829 	struct rte_cryptodev_info dev_info;
13830 
13831 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13832 	uint64_t feat_flags = dev_info.feature_flags;
13833 
13834 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13835 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13836 		printf("Device doesn't support RAW data-path APIs.\n");
13837 		return TEST_SKIPPED;
13838 	}
13839 
13840 	/* Verify the capabilities */
13841 	struct rte_cryptodev_sym_capability_idx cap_idx;
13842 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13843 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13844 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13845 			&cap_idx) == NULL)
13846 		return TEST_SKIPPED;
13847 
13848 	if (MD5_HMAC_create_session(ts_params, ut_params,
13849 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
13850 		return TEST_FAILED;
13851 
13852 	/* Generate Crypto op data structure */
13853 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13854 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13855 	TEST_ASSERT_NOT_NULL(ut_params->op,
13856 			"Failed to allocate symmetric crypto operation struct");
13857 
13858 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13859 				16);
13860 
13861 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13862 		return TEST_FAILED;
13863 
13864 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13865 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13866 			ut_params->op);
13867 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13868 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13869 		if (ret != TEST_SUCCESS)
13870 			return ret;
13871 	} else
13872 		TEST_ASSERT_NOT_NULL(
13873 			process_crypto_request(ts_params->valid_devs[0],
13874 				ut_params->op),
13875 				"failed to process sym crypto op");
13876 
13877 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13878 			"crypto op processing failed");
13879 
13880 	if (ut_params->op->sym->m_dst) {
13881 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13882 				uint8_t *, plaintext_pad_len);
13883 	} else {
13884 		auth_tag = plaintext + plaintext_pad_len;
13885 	}
13886 
13887 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13888 			auth_tag,
13889 			test_case->auth_tag.data,
13890 			test_case->auth_tag.len,
13891 			"HMAC_MD5 generated tag not as expected");
13892 
13893 	return TEST_SUCCESS;
13894 }
13895 
13896 static int
13897 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
13898 {
13899 	uint8_t *plaintext;
13900 	int ret;
13901 
13902 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13903 	struct crypto_unittest_params *ut_params = &unittest_params;
13904 	struct rte_cryptodev_info dev_info;
13905 
13906 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13907 	uint64_t feat_flags = dev_info.feature_flags;
13908 
13909 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13910 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13911 		printf("Device doesn't support RAW data-path APIs.\n");
13912 		return TEST_SKIPPED;
13913 	}
13914 
13915 	/* Verify the capabilities */
13916 	struct rte_cryptodev_sym_capability_idx cap_idx;
13917 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13918 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13919 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13920 			&cap_idx) == NULL)
13921 		return TEST_SKIPPED;
13922 
13923 	if (MD5_HMAC_create_session(ts_params, ut_params,
13924 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
13925 		return TEST_FAILED;
13926 	}
13927 
13928 	/* Generate Crypto op data structure */
13929 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13930 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13931 	TEST_ASSERT_NOT_NULL(ut_params->op,
13932 			"Failed to allocate symmetric crypto operation struct");
13933 
13934 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13935 		return TEST_FAILED;
13936 
13937 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13938 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13939 			ut_params->op);
13940 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13941 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13942 		if (ret != TEST_SUCCESS)
13943 			return ret;
13944 	} else
13945 		TEST_ASSERT_NOT_NULL(
13946 			process_crypto_request(ts_params->valid_devs[0],
13947 				ut_params->op),
13948 				"failed to process sym crypto op");
13949 
13950 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13951 			"HMAC_MD5 crypto op processing failed");
13952 
13953 	return TEST_SUCCESS;
13954 }
13955 
13956 static int
13957 test_MD5_HMAC_generate_case_1(void)
13958 {
13959 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
13960 }
13961 
13962 static int
13963 test_MD5_HMAC_verify_case_1(void)
13964 {
13965 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
13966 }
13967 
13968 static int
13969 test_MD5_HMAC_generate_case_2(void)
13970 {
13971 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
13972 }
13973 
13974 static int
13975 test_MD5_HMAC_verify_case_2(void)
13976 {
13977 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
13978 }
13979 
13980 static int
13981 test_multi_session(void)
13982 {
13983 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13984 	struct crypto_unittest_params *ut_params = &unittest_params;
13985 	struct rte_cryptodev_info dev_info;
13986 	int i, nb_sess, ret = TEST_SUCCESS;
13987 	void **sessions;
13988 
13989 	/* Verify the capabilities */
13990 	struct rte_cryptodev_sym_capability_idx cap_idx;
13991 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13992 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
13993 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13994 			&cap_idx) == NULL)
13995 		return TEST_SKIPPED;
13996 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13997 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13998 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13999 			&cap_idx) == NULL)
14000 		return TEST_SKIPPED;
14001 
14002 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14003 			aes_cbc_key, hmac_sha512_key);
14004 
14005 
14006 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14007 
14008 	sessions = rte_malloc(NULL,
14009 			sizeof(void *) *
14010 			(MAX_NB_SESSIONS + 1), 0);
14011 
14012 	/* Create multiple crypto sessions*/
14013 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
14014 		sessions[i] = rte_cryptodev_sym_session_create(
14015 			ts_params->valid_devs[0], &ut_params->auth_xform,
14016 				ts_params->session_mpool);
14017 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14018 			nb_sess = i;
14019 			ret = TEST_SKIPPED;
14020 			break;
14021 		}
14022 
14023 		TEST_ASSERT_NOT_NULL(sessions[i],
14024 				"Session creation failed at session number %u",
14025 				i);
14026 
14027 		/* Attempt to send a request on each session */
14028 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14029 			sessions[i],
14030 			ut_params,
14031 			ts_params,
14032 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14033 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14034 			aes_cbc_iv);
14035 
14036 		/* free crypto operation structure */
14037 		rte_crypto_op_free(ut_params->op);
14038 
14039 		/*
14040 		 * free mbuf - both obuf and ibuf are usually the same,
14041 		 * so check if they point at the same address is necessary,
14042 		 * to avoid freeing the mbuf twice.
14043 		 */
14044 		if (ut_params->obuf) {
14045 			rte_pktmbuf_free(ut_params->obuf);
14046 			if (ut_params->ibuf == ut_params->obuf)
14047 				ut_params->ibuf = 0;
14048 			ut_params->obuf = 0;
14049 		}
14050 		if (ut_params->ibuf) {
14051 			rte_pktmbuf_free(ut_params->ibuf);
14052 			ut_params->ibuf = 0;
14053 		}
14054 
14055 		if (ret != TEST_SUCCESS) {
14056 			i++;
14057 			break;
14058 		}
14059 	}
14060 
14061 	nb_sess = i;
14062 
14063 	for (i = 0; i < nb_sess; i++) {
14064 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14065 				sessions[i]);
14066 	}
14067 
14068 	rte_free(sessions);
14069 
14070 	if (ret != TEST_SKIPPED)
14071 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14072 
14073 	return ret;
14074 }
14075 
14076 struct multi_session_params {
14077 	struct crypto_unittest_params ut_params;
14078 	uint8_t *cipher_key;
14079 	uint8_t *hmac_key;
14080 	const uint8_t *cipher;
14081 	const uint8_t *digest;
14082 	uint8_t *iv;
14083 };
14084 
14085 #define MB_SESSION_NUMBER 3
14086 
14087 static int
14088 test_multi_session_random_usage(void)
14089 {
14090 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14091 	struct rte_cryptodev_info dev_info;
14092 	int index = 0, ret = TEST_SUCCESS;
14093 	uint32_t nb_sess, i, j;
14094 	void **sessions;
14095 	struct multi_session_params ut_paramz[] = {
14096 
14097 		{
14098 			.cipher_key = ms_aes_cbc_key0,
14099 			.hmac_key = ms_hmac_key0,
14100 			.cipher = ms_aes_cbc_cipher0,
14101 			.digest = ms_hmac_digest0,
14102 			.iv = ms_aes_cbc_iv0
14103 		},
14104 		{
14105 			.cipher_key = ms_aes_cbc_key1,
14106 			.hmac_key = ms_hmac_key1,
14107 			.cipher = ms_aes_cbc_cipher1,
14108 			.digest = ms_hmac_digest1,
14109 			.iv = ms_aes_cbc_iv1
14110 		},
14111 		{
14112 			.cipher_key = ms_aes_cbc_key2,
14113 			.hmac_key = ms_hmac_key2,
14114 			.cipher = ms_aes_cbc_cipher2,
14115 			.digest = ms_hmac_digest2,
14116 			.iv = ms_aes_cbc_iv2
14117 		},
14118 
14119 	};
14120 
14121 	/* Verify the capabilities */
14122 	struct rte_cryptodev_sym_capability_idx cap_idx;
14123 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14124 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14125 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14126 			&cap_idx) == NULL)
14127 		return TEST_SKIPPED;
14128 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14129 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14130 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14131 			&cap_idx) == NULL)
14132 		return TEST_SKIPPED;
14133 
14134 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14135 
14136 	sessions = rte_malloc(NULL, (sizeof(void *)
14137 					* MAX_NB_SESSIONS) + 1, 0);
14138 
14139 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
14140 
14141 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
14142 				sizeof(struct crypto_unittest_params));
14143 
14144 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14145 				&ut_paramz[i].ut_params,
14146 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14147 
14148 		/* Create multiple crypto sessions*/
14149 		sessions[i] = rte_cryptodev_sym_session_create(
14150 				ts_params->valid_devs[0],
14151 				&ut_paramz[i].ut_params.auth_xform,
14152 				ts_params->session_mpool);
14153 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14154 			nb_sess = i;
14155 			ret = TEST_SKIPPED;
14156 			goto session_clear;
14157 		}
14158 
14159 		TEST_ASSERT_NOT_NULL(sessions[i],
14160 				"Session creation failed at session number %u",
14161 				i);
14162 	}
14163 
14164 	nb_sess = i;
14165 
14166 	srand(time(NULL));
14167 	for (i = 0; i < 40000; i++) {
14168 
14169 		j = rand() % MB_SESSION_NUMBER;
14170 
14171 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14172 					sessions[j],
14173 					&ut_paramz[j].ut_params,
14174 					ts_params, ut_paramz[j].cipher,
14175 					ut_paramz[j].digest,
14176 					ut_paramz[j].iv);
14177 
14178 		rte_crypto_op_free(ut_paramz[j].ut_params.op);
14179 
14180 		/*
14181 		 * free mbuf - both obuf and ibuf are usually the same,
14182 		 * so check if they point at the same address is necessary,
14183 		 * to avoid freeing the mbuf twice.
14184 		 */
14185 		if (ut_paramz[j].ut_params.obuf) {
14186 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14187 			if (ut_paramz[j].ut_params.ibuf
14188 					== ut_paramz[j].ut_params.obuf)
14189 				ut_paramz[j].ut_params.ibuf = 0;
14190 			ut_paramz[j].ut_params.obuf = 0;
14191 		}
14192 		if (ut_paramz[j].ut_params.ibuf) {
14193 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14194 			ut_paramz[j].ut_params.ibuf = 0;
14195 		}
14196 
14197 		if (ret != TEST_SKIPPED) {
14198 			index = i;
14199 			break;
14200 		}
14201 	}
14202 
14203 session_clear:
14204 	for (i = 0; i < nb_sess; i++) {
14205 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14206 				sessions[i]);
14207 	}
14208 
14209 	rte_free(sessions);
14210 
14211 	if (ret != TEST_SKIPPED)
14212 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14213 
14214 	return TEST_SUCCESS;
14215 }
14216 
14217 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14218 			0xab, 0xab, 0xab, 0xab,
14219 			0xab, 0xab, 0xab, 0xab,
14220 			0xab, 0xab, 0xab, 0xab};
14221 
14222 static int
14223 test_null_invalid_operation(void)
14224 {
14225 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14226 	struct crypto_unittest_params *ut_params = &unittest_params;
14227 
14228 	/* This test is for NULL PMD only */
14229 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14230 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14231 		return TEST_SKIPPED;
14232 
14233 	/* Setup Cipher Parameters */
14234 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14235 	ut_params->cipher_xform.next = NULL;
14236 
14237 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14238 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14239 
14240 	/* Create Crypto session*/
14241 	ut_params->sess = rte_cryptodev_sym_session_create(
14242 			ts_params->valid_devs[0], &ut_params->cipher_xform,
14243 			ts_params->session_mpool);
14244 	TEST_ASSERT(ut_params->sess == NULL,
14245 			"Session creation succeeded unexpectedly");
14246 
14247 	/* Setup HMAC Parameters */
14248 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14249 	ut_params->auth_xform.next = NULL;
14250 
14251 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
14252 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14253 
14254 	/* Create Crypto session*/
14255 	ut_params->sess = rte_cryptodev_sym_session_create(
14256 			ts_params->valid_devs[0], &ut_params->auth_xform,
14257 			ts_params->session_mpool);
14258 	TEST_ASSERT(ut_params->sess == NULL,
14259 			"Session creation succeeded unexpectedly");
14260 
14261 	return TEST_SUCCESS;
14262 }
14263 
14264 
14265 #define NULL_BURST_LENGTH (32)
14266 
14267 static int
14268 test_null_burst_operation(void)
14269 {
14270 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14271 	struct crypto_unittest_params *ut_params = &unittest_params;
14272 
14273 	unsigned i, burst_len = NULL_BURST_LENGTH;
14274 
14275 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
14276 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
14277 
14278 	/* This test is for NULL PMD only */
14279 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14280 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14281 		return TEST_SKIPPED;
14282 
14283 	/* Setup Cipher Parameters */
14284 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14285 	ut_params->cipher_xform.next = &ut_params->auth_xform;
14286 
14287 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
14288 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14289 
14290 	/* Setup HMAC Parameters */
14291 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14292 	ut_params->auth_xform.next = NULL;
14293 
14294 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
14295 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14296 
14297 	/* Create Crypto session*/
14298 	ut_params->sess = rte_cryptodev_sym_session_create(
14299 				ts_params->valid_devs[0],
14300 				&ut_params->auth_xform,
14301 				ts_params->session_mpool);
14302 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14303 		return TEST_SKIPPED;
14304 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14305 
14306 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
14307 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
14308 			burst_len, "failed to generate burst of crypto ops");
14309 
14310 	/* Generate an operation for each mbuf in burst */
14311 	for (i = 0; i < burst_len; i++) {
14312 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14313 
14314 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
14315 
14316 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
14317 				sizeof(unsigned));
14318 		*data = i;
14319 
14320 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
14321 
14322 		burst[i]->sym->m_src = m;
14323 	}
14324 
14325 	/* Process crypto operation */
14326 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
14327 			0, burst, burst_len),
14328 			burst_len,
14329 			"Error enqueuing burst");
14330 
14331 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
14332 			0, burst_dequeued, burst_len),
14333 			burst_len,
14334 			"Error dequeuing burst");
14335 
14336 
14337 	for (i = 0; i < burst_len; i++) {
14338 		TEST_ASSERT_EQUAL(
14339 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
14340 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
14341 					uint32_t *),
14342 			"data not as expected");
14343 
14344 		rte_pktmbuf_free(burst[i]->sym->m_src);
14345 		rte_crypto_op_free(burst[i]);
14346 	}
14347 
14348 	return TEST_SUCCESS;
14349 }
14350 
14351 static uint16_t
14352 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14353 		  uint16_t nb_ops, void *user_param)
14354 {
14355 	RTE_SET_USED(dev_id);
14356 	RTE_SET_USED(qp_id);
14357 	RTE_SET_USED(ops);
14358 	RTE_SET_USED(user_param);
14359 
14360 	printf("crypto enqueue callback called\n");
14361 	return nb_ops;
14362 }
14363 
14364 static uint16_t
14365 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14366 		  uint16_t nb_ops, void *user_param)
14367 {
14368 	RTE_SET_USED(dev_id);
14369 	RTE_SET_USED(qp_id);
14370 	RTE_SET_USED(ops);
14371 	RTE_SET_USED(user_param);
14372 
14373 	printf("crypto dequeue callback called\n");
14374 	return nb_ops;
14375 }
14376 
14377 /*
14378  * Thread using enqueue/dequeue callback with RCU.
14379  */
14380 static int
14381 test_enqdeq_callback_thread(void *arg)
14382 {
14383 	RTE_SET_USED(arg);
14384 	/* DP thread calls rte_cryptodev_enqueue_burst()/
14385 	 * rte_cryptodev_dequeue_burst() and invokes callback.
14386 	 */
14387 	test_null_burst_operation();
14388 	return 0;
14389 }
14390 
14391 static int
14392 test_enq_callback_setup(void)
14393 {
14394 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14395 	struct rte_cryptodev_info dev_info;
14396 	struct rte_cryptodev_qp_conf qp_conf = {
14397 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
14398 	};
14399 
14400 	struct rte_cryptodev_cb *cb;
14401 	uint16_t qp_id = 0;
14402 
14403 	/* Stop the device in case it's started so it can be configured */
14404 	rte_cryptodev_stop(ts_params->valid_devs[0]);
14405 
14406 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14407 
14408 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14409 			&ts_params->conf),
14410 			"Failed to configure cryptodev %u",
14411 			ts_params->valid_devs[0]);
14412 
14413 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14414 	qp_conf.mp_session = ts_params->session_mpool;
14415 
14416 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14417 			ts_params->valid_devs[0], qp_id, &qp_conf,
14418 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14419 			"Failed test for "
14420 			"rte_cryptodev_queue_pair_setup: num_inflights "
14421 			"%u on qp %u on cryptodev %u",
14422 			qp_conf.nb_descriptors, qp_id,
14423 			ts_params->valid_devs[0]);
14424 
14425 	/* Test with invalid crypto device */
14426 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
14427 			qp_id, test_enq_callback, NULL);
14428 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14429 			"cryptodev %u did not fail",
14430 			qp_id, RTE_CRYPTO_MAX_DEVS);
14431 
14432 	/* Test with invalid queue pair */
14433 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14434 			dev_info.max_nb_queue_pairs + 1,
14435 			test_enq_callback, NULL);
14436 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14437 			"cryptodev %u did not fail",
14438 			dev_info.max_nb_queue_pairs + 1,
14439 			ts_params->valid_devs[0]);
14440 
14441 	/* Test with NULL callback */
14442 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14443 			qp_id, NULL, NULL);
14444 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14445 			"cryptodev %u did not fail",
14446 			qp_id, ts_params->valid_devs[0]);
14447 
14448 	/* Test with valid configuration */
14449 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14450 			qp_id, test_enq_callback, NULL);
14451 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14452 			"qp %u on cryptodev %u",
14453 			qp_id, ts_params->valid_devs[0]);
14454 
14455 	rte_cryptodev_start(ts_params->valid_devs[0]);
14456 
14457 	/* Launch a thread */
14458 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14459 				rte_get_next_lcore(-1, 1, 0));
14460 
14461 	/* Wait until reader exited. */
14462 	rte_eal_mp_wait_lcore();
14463 
14464 	/* Test with invalid crypto device */
14465 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14466 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14467 			"Expected call to fail as crypto device is invalid");
14468 
14469 	/* Test with invalid queue pair */
14470 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14471 			ts_params->valid_devs[0],
14472 			dev_info.max_nb_queue_pairs + 1, cb),
14473 			"Expected call to fail as queue pair is invalid");
14474 
14475 	/* Test with NULL callback */
14476 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14477 			ts_params->valid_devs[0], qp_id, NULL),
14478 			"Expected call to fail as callback is NULL");
14479 
14480 	/* Test with valid configuration */
14481 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
14482 			ts_params->valid_devs[0], qp_id, cb),
14483 			"Failed test to remove callback on "
14484 			"qp %u on cryptodev %u",
14485 			qp_id, ts_params->valid_devs[0]);
14486 
14487 	return TEST_SUCCESS;
14488 }
14489 
14490 static int
14491 test_deq_callback_setup(void)
14492 {
14493 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14494 	struct rte_cryptodev_info dev_info;
14495 	struct rte_cryptodev_qp_conf qp_conf = {
14496 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
14497 	};
14498 
14499 	struct rte_cryptodev_cb *cb;
14500 	uint16_t qp_id = 0;
14501 
14502 	/* Stop the device in case it's started so it can be configured */
14503 	rte_cryptodev_stop(ts_params->valid_devs[0]);
14504 
14505 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14506 
14507 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14508 			&ts_params->conf),
14509 			"Failed to configure cryptodev %u",
14510 			ts_params->valid_devs[0]);
14511 
14512 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14513 	qp_conf.mp_session = ts_params->session_mpool;
14514 
14515 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14516 			ts_params->valid_devs[0], qp_id, &qp_conf,
14517 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14518 			"Failed test for "
14519 			"rte_cryptodev_queue_pair_setup: num_inflights "
14520 			"%u on qp %u on cryptodev %u",
14521 			qp_conf.nb_descriptors, qp_id,
14522 			ts_params->valid_devs[0]);
14523 
14524 	/* Test with invalid crypto device */
14525 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
14526 			qp_id, test_deq_callback, NULL);
14527 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14528 			"cryptodev %u did not fail",
14529 			qp_id, RTE_CRYPTO_MAX_DEVS);
14530 
14531 	/* Test with invalid queue pair */
14532 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14533 			dev_info.max_nb_queue_pairs + 1,
14534 			test_deq_callback, NULL);
14535 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14536 			"cryptodev %u did not fail",
14537 			dev_info.max_nb_queue_pairs + 1,
14538 			ts_params->valid_devs[0]);
14539 
14540 	/* Test with NULL callback */
14541 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14542 			qp_id, NULL, NULL);
14543 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14544 			"cryptodev %u did not fail",
14545 			qp_id, ts_params->valid_devs[0]);
14546 
14547 	/* Test with valid configuration */
14548 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14549 			qp_id, test_deq_callback, NULL);
14550 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14551 			"qp %u on cryptodev %u",
14552 			qp_id, ts_params->valid_devs[0]);
14553 
14554 	rte_cryptodev_start(ts_params->valid_devs[0]);
14555 
14556 	/* Launch a thread */
14557 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14558 				rte_get_next_lcore(-1, 1, 0));
14559 
14560 	/* Wait until reader exited. */
14561 	rte_eal_mp_wait_lcore();
14562 
14563 	/* Test with invalid crypto device */
14564 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14565 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14566 			"Expected call to fail as crypto device is invalid");
14567 
14568 	/* Test with invalid queue pair */
14569 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14570 			ts_params->valid_devs[0],
14571 			dev_info.max_nb_queue_pairs + 1, cb),
14572 			"Expected call to fail as queue pair is invalid");
14573 
14574 	/* Test with NULL callback */
14575 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14576 			ts_params->valid_devs[0], qp_id, NULL),
14577 			"Expected call to fail as callback is NULL");
14578 
14579 	/* Test with valid configuration */
14580 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
14581 			ts_params->valid_devs[0], qp_id, cb),
14582 			"Failed test to remove callback on "
14583 			"qp %u on cryptodev %u",
14584 			qp_id, ts_params->valid_devs[0]);
14585 
14586 	return TEST_SUCCESS;
14587 }
14588 
14589 static void
14590 generate_gmac_large_plaintext(uint8_t *data)
14591 {
14592 	uint16_t i;
14593 
14594 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
14595 		memcpy(&data[i], &data[0], 32);
14596 }
14597 
14598 static int
14599 create_gmac_operation(enum rte_crypto_auth_operation op,
14600 		const struct gmac_test_data *tdata)
14601 {
14602 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14603 	struct crypto_unittest_params *ut_params = &unittest_params;
14604 	struct rte_crypto_sym_op *sym_op;
14605 
14606 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14607 
14608 	/* Generate Crypto op data structure */
14609 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14610 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14611 	TEST_ASSERT_NOT_NULL(ut_params->op,
14612 			"Failed to allocate symmetric crypto operation struct");
14613 
14614 	sym_op = ut_params->op->sym;
14615 
14616 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14617 			ut_params->ibuf, tdata->gmac_tag.len);
14618 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14619 			"no room to append digest");
14620 
14621 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14622 			ut_params->ibuf, plaintext_pad_len);
14623 
14624 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14625 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14626 				tdata->gmac_tag.len);
14627 		debug_hexdump(stdout, "digest:",
14628 				sym_op->auth.digest.data,
14629 				tdata->gmac_tag.len);
14630 	}
14631 
14632 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14633 			uint8_t *, IV_OFFSET);
14634 
14635 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14636 
14637 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14638 
14639 	sym_op->cipher.data.length = 0;
14640 	sym_op->cipher.data.offset = 0;
14641 
14642 	sym_op->auth.data.offset = 0;
14643 	sym_op->auth.data.length = tdata->plaintext.len;
14644 
14645 	return 0;
14646 }
14647 
14648 static int
14649 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
14650 		const struct gmac_test_data *tdata,
14651 		void *digest_mem, uint64_t digest_phys)
14652 {
14653 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14654 	struct crypto_unittest_params *ut_params = &unittest_params;
14655 	struct rte_crypto_sym_op *sym_op;
14656 
14657 	/* Generate Crypto op data structure */
14658 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14659 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14660 	TEST_ASSERT_NOT_NULL(ut_params->op,
14661 			"Failed to allocate symmetric crypto operation struct");
14662 
14663 	sym_op = ut_params->op->sym;
14664 
14665 	sym_op->auth.digest.data = digest_mem;
14666 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14667 			"no room to append digest");
14668 
14669 	sym_op->auth.digest.phys_addr = digest_phys;
14670 
14671 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14672 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14673 				tdata->gmac_tag.len);
14674 		debug_hexdump(stdout, "digest:",
14675 				sym_op->auth.digest.data,
14676 				tdata->gmac_tag.len);
14677 	}
14678 
14679 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14680 			uint8_t *, IV_OFFSET);
14681 
14682 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14683 
14684 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14685 
14686 	sym_op->cipher.data.length = 0;
14687 	sym_op->cipher.data.offset = 0;
14688 
14689 	sym_op->auth.data.offset = 0;
14690 	sym_op->auth.data.length = tdata->plaintext.len;
14691 
14692 	return 0;
14693 }
14694 
14695 static int create_gmac_session(uint8_t dev_id,
14696 		const struct gmac_test_data *tdata,
14697 		enum rte_crypto_auth_operation auth_op)
14698 {
14699 	uint8_t auth_key[tdata->key.len];
14700 
14701 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14702 	struct crypto_unittest_params *ut_params = &unittest_params;
14703 
14704 	memcpy(auth_key, tdata->key.data, tdata->key.len);
14705 
14706 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14707 	ut_params->auth_xform.next = NULL;
14708 
14709 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
14710 	ut_params->auth_xform.auth.op = auth_op;
14711 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
14712 	ut_params->auth_xform.auth.key.length = tdata->key.len;
14713 	ut_params->auth_xform.auth.key.data = auth_key;
14714 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14715 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
14716 
14717 
14718 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14719 			&ut_params->auth_xform, ts_params->session_mpool);
14720 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14721 		return TEST_SKIPPED;
14722 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14723 
14724 	return 0;
14725 }
14726 
14727 static int
14728 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
14729 {
14730 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14731 	struct crypto_unittest_params *ut_params = &unittest_params;
14732 	struct rte_cryptodev_info dev_info;
14733 
14734 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14735 	uint64_t feat_flags = dev_info.feature_flags;
14736 
14737 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14738 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14739 		printf("Device doesn't support RAW data-path APIs.\n");
14740 		return TEST_SKIPPED;
14741 	}
14742 
14743 	int retval;
14744 
14745 	uint8_t *auth_tag, *plaintext;
14746 	uint16_t plaintext_pad_len;
14747 
14748 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14749 			      "No GMAC length in the source data");
14750 
14751 	/* Verify the capabilities */
14752 	struct rte_cryptodev_sym_capability_idx cap_idx;
14753 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14754 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14755 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14756 			&cap_idx) == NULL)
14757 		return TEST_SKIPPED;
14758 
14759 	retval = create_gmac_session(ts_params->valid_devs[0],
14760 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14761 
14762 	if (retval == TEST_SKIPPED)
14763 		return TEST_SKIPPED;
14764 	if (retval < 0)
14765 		return retval;
14766 
14767 	if (tdata->plaintext.len > MBUF_SIZE)
14768 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14769 	else
14770 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14771 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14772 			"Failed to allocate input buffer in mempool");
14773 
14774 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14775 			rte_pktmbuf_tailroom(ut_params->ibuf));
14776 
14777 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14778 	/*
14779 	 * Runtime generate the large plain text instead of use hard code
14780 	 * plain text vector. It is done to avoid create huge source file
14781 	 * with the test vector.
14782 	 */
14783 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14784 		generate_gmac_large_plaintext(tdata->plaintext.data);
14785 
14786 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14787 				plaintext_pad_len);
14788 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14789 
14790 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14791 	debug_hexdump(stdout, "plaintext:", plaintext,
14792 			tdata->plaintext.len);
14793 
14794 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
14795 			tdata);
14796 
14797 	if (retval < 0)
14798 		return retval;
14799 
14800 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14801 
14802 	ut_params->op->sym->m_src = ut_params->ibuf;
14803 
14804 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14805 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14806 			ut_params->op);
14807 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14808 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14809 					       0);
14810 		if (retval != TEST_SUCCESS)
14811 			return retval;
14812 	} else
14813 		TEST_ASSERT_NOT_NULL(
14814 			process_crypto_request(ts_params->valid_devs[0],
14815 			ut_params->op), "failed to process sym crypto op");
14816 
14817 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14818 			"crypto op processing failed");
14819 
14820 	if (ut_params->op->sym->m_dst) {
14821 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14822 				uint8_t *, plaintext_pad_len);
14823 	} else {
14824 		auth_tag = plaintext + plaintext_pad_len;
14825 	}
14826 
14827 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14828 
14829 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14830 			auth_tag,
14831 			tdata->gmac_tag.data,
14832 			tdata->gmac_tag.len,
14833 			"GMAC Generated auth tag not as expected");
14834 
14835 	return 0;
14836 }
14837 
14838 static int
14839 test_AES_GMAC_authentication_test_case_1(void)
14840 {
14841 	return test_AES_GMAC_authentication(&gmac_test_case_1);
14842 }
14843 
14844 static int
14845 test_AES_GMAC_authentication_test_case_2(void)
14846 {
14847 	return test_AES_GMAC_authentication(&gmac_test_case_2);
14848 }
14849 
14850 static int
14851 test_AES_GMAC_authentication_test_case_3(void)
14852 {
14853 	return test_AES_GMAC_authentication(&gmac_test_case_3);
14854 }
14855 
14856 static int
14857 test_AES_GMAC_authentication_test_case_4(void)
14858 {
14859 	return test_AES_GMAC_authentication(&gmac_test_case_4);
14860 }
14861 
14862 static int
14863 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
14864 {
14865 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14866 	struct crypto_unittest_params *ut_params = &unittest_params;
14867 	int retval;
14868 	uint32_t plaintext_pad_len;
14869 	uint8_t *plaintext;
14870 	struct rte_cryptodev_info dev_info;
14871 
14872 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14873 	uint64_t feat_flags = dev_info.feature_flags;
14874 
14875 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14876 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14877 		printf("Device doesn't support RAW data-path APIs.\n");
14878 		return TEST_SKIPPED;
14879 	}
14880 
14881 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14882 			      "No GMAC length in the source data");
14883 
14884 	/* Verify the capabilities */
14885 	struct rte_cryptodev_sym_capability_idx cap_idx;
14886 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14887 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14888 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14889 			&cap_idx) == NULL)
14890 		return TEST_SKIPPED;
14891 
14892 	retval = create_gmac_session(ts_params->valid_devs[0],
14893 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
14894 
14895 	if (retval == TEST_SKIPPED)
14896 		return TEST_SKIPPED;
14897 	if (retval < 0)
14898 		return retval;
14899 
14900 	if (tdata->plaintext.len > MBUF_SIZE)
14901 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14902 	else
14903 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14904 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14905 			"Failed to allocate input buffer in mempool");
14906 
14907 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14908 			rte_pktmbuf_tailroom(ut_params->ibuf));
14909 
14910 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14911 
14912 	/*
14913 	 * Runtime generate the large plain text instead of use hard code
14914 	 * plain text vector. It is done to avoid create huge source file
14915 	 * with the test vector.
14916 	 */
14917 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14918 		generate_gmac_large_plaintext(tdata->plaintext.data);
14919 
14920 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14921 				plaintext_pad_len);
14922 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14923 
14924 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14925 	debug_hexdump(stdout, "plaintext:", plaintext,
14926 			tdata->plaintext.len);
14927 
14928 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
14929 			tdata);
14930 
14931 	if (retval < 0)
14932 		return retval;
14933 
14934 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14935 
14936 	ut_params->op->sym->m_src = ut_params->ibuf;
14937 
14938 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14939 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14940 			ut_params->op);
14941 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14942 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14943 					       0);
14944 		if (retval != TEST_SUCCESS)
14945 			return retval;
14946 	} else
14947 		TEST_ASSERT_NOT_NULL(
14948 			process_crypto_request(ts_params->valid_devs[0],
14949 			ut_params->op), "failed to process sym crypto op");
14950 
14951 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14952 			"crypto op processing failed");
14953 
14954 	return 0;
14955 
14956 }
14957 
14958 static int
14959 test_AES_GMAC_authentication_verify_test_case_1(void)
14960 {
14961 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
14962 }
14963 
14964 static int
14965 test_AES_GMAC_authentication_verify_test_case_2(void)
14966 {
14967 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
14968 }
14969 
14970 static int
14971 test_AES_GMAC_authentication_verify_test_case_3(void)
14972 {
14973 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
14974 }
14975 
14976 static int
14977 test_AES_GMAC_authentication_verify_test_case_4(void)
14978 {
14979 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
14980 }
14981 
14982 static int
14983 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
14984 				uint32_t fragsz)
14985 {
14986 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14987 	struct crypto_unittest_params *ut_params = &unittest_params;
14988 	struct rte_cryptodev_info dev_info;
14989 	uint64_t feature_flags;
14990 	unsigned int trn_data = 0;
14991 	void *digest_mem = NULL;
14992 	uint32_t segs = 1;
14993 	unsigned int to_trn = 0;
14994 	struct rte_mbuf *buf = NULL;
14995 	uint8_t *auth_tag, *plaintext;
14996 	int retval;
14997 
14998 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14999 			      "No GMAC length in the source data");
15000 
15001 	/* Verify the capabilities */
15002 	struct rte_cryptodev_sym_capability_idx cap_idx;
15003 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15004 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15005 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15006 			&cap_idx) == NULL)
15007 		return TEST_SKIPPED;
15008 
15009 	/* Check for any input SGL support */
15010 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15011 	feature_flags = dev_info.feature_flags;
15012 
15013 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15014 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15015 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15016 		return TEST_SKIPPED;
15017 
15018 	if (fragsz > tdata->plaintext.len)
15019 		fragsz = tdata->plaintext.len;
15020 
15021 	uint16_t plaintext_len = fragsz;
15022 
15023 	retval = create_gmac_session(ts_params->valid_devs[0],
15024 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15025 
15026 	if (retval == TEST_SKIPPED)
15027 		return TEST_SKIPPED;
15028 	if (retval < 0)
15029 		return retval;
15030 
15031 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15032 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15033 			"Failed to allocate input buffer in mempool");
15034 
15035 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15036 			rte_pktmbuf_tailroom(ut_params->ibuf));
15037 
15038 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15039 				plaintext_len);
15040 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15041 
15042 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15043 
15044 	trn_data += plaintext_len;
15045 
15046 	buf = ut_params->ibuf;
15047 
15048 	/*
15049 	 * Loop until no more fragments
15050 	 */
15051 
15052 	while (trn_data < tdata->plaintext.len) {
15053 		++segs;
15054 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15055 				(tdata->plaintext.len - trn_data) : fragsz;
15056 
15057 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15058 		buf = buf->next;
15059 
15060 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15061 				rte_pktmbuf_tailroom(buf));
15062 
15063 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15064 				to_trn);
15065 
15066 		memcpy(plaintext, tdata->plaintext.data + trn_data,
15067 				to_trn);
15068 		trn_data += to_trn;
15069 		if (trn_data  == tdata->plaintext.len)
15070 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15071 					tdata->gmac_tag.len);
15072 	}
15073 	ut_params->ibuf->nb_segs = segs;
15074 
15075 	/*
15076 	 * Place digest at the end of the last buffer
15077 	 */
15078 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15079 
15080 	if (!digest_mem) {
15081 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15082 				+ tdata->gmac_tag.len);
15083 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15084 				tdata->plaintext.len);
15085 	}
15086 
15087 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15088 			tdata, digest_mem, digest_phys);
15089 
15090 	if (retval < 0)
15091 		return retval;
15092 
15093 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15094 
15095 	ut_params->op->sym->m_src = ut_params->ibuf;
15096 
15097 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15098 		return TEST_SKIPPED;
15099 
15100 	TEST_ASSERT_NOT_NULL(
15101 		process_crypto_request(ts_params->valid_devs[0],
15102 		ut_params->op), "failed to process sym crypto op");
15103 
15104 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15105 			"crypto op processing failed");
15106 
15107 	auth_tag = digest_mem;
15108 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15109 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15110 			auth_tag,
15111 			tdata->gmac_tag.data,
15112 			tdata->gmac_tag.len,
15113 			"GMAC Generated auth tag not as expected");
15114 
15115 	return 0;
15116 }
15117 
15118 /* Segment size not multiple of block size (16B) */
15119 static int
15120 test_AES_GMAC_authentication_SGL_40B(void)
15121 {
15122 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15123 }
15124 
15125 static int
15126 test_AES_GMAC_authentication_SGL_80B(void)
15127 {
15128 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15129 }
15130 
15131 static int
15132 test_AES_GMAC_authentication_SGL_2048B(void)
15133 {
15134 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15135 }
15136 
15137 /* Segment size not multiple of block size (16B) */
15138 static int
15139 test_AES_GMAC_authentication_SGL_2047B(void)
15140 {
15141 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15142 }
15143 
15144 struct test_crypto_vector {
15145 	enum rte_crypto_cipher_algorithm crypto_algo;
15146 	unsigned int cipher_offset;
15147 	unsigned int cipher_len;
15148 
15149 	struct {
15150 		uint8_t data[64];
15151 		unsigned int len;
15152 	} cipher_key;
15153 
15154 	struct {
15155 		uint8_t data[64];
15156 		unsigned int len;
15157 	} iv;
15158 
15159 	struct {
15160 		const uint8_t *data;
15161 		unsigned int len;
15162 	} plaintext;
15163 
15164 	struct {
15165 		const uint8_t *data;
15166 		unsigned int len;
15167 	} ciphertext;
15168 
15169 	enum rte_crypto_auth_algorithm auth_algo;
15170 	unsigned int auth_offset;
15171 
15172 	struct {
15173 		uint8_t data[128];
15174 		unsigned int len;
15175 	} auth_key;
15176 
15177 	struct {
15178 		const uint8_t *data;
15179 		unsigned int len;
15180 	} aad;
15181 
15182 	struct {
15183 		uint8_t data[128];
15184 		unsigned int len;
15185 	} digest;
15186 };
15187 
15188 static const struct test_crypto_vector
15189 hmac_sha1_test_crypto_vector = {
15190 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15191 	.plaintext = {
15192 		.data = plaintext_hash,
15193 		.len = 512
15194 	},
15195 	.auth_key = {
15196 		.data = {
15197 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15198 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15199 			0xDE, 0xF4, 0xDE, 0xAD
15200 		},
15201 		.len = 20
15202 	},
15203 	.digest = {
15204 		.data = {
15205 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
15206 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
15207 			0x3F, 0x91, 0x64, 0x59
15208 		},
15209 		.len = 20
15210 	}
15211 };
15212 
15213 static const struct test_crypto_vector
15214 aes128_gmac_test_vector = {
15215 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
15216 	.plaintext = {
15217 		.data = plaintext_hash,
15218 		.len = 512
15219 	},
15220 	.iv = {
15221 		.data = {
15222 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15223 			0x08, 0x09, 0x0A, 0x0B
15224 		},
15225 		.len = 12
15226 	},
15227 	.auth_key = {
15228 		.data = {
15229 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15230 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
15231 		},
15232 		.len = 16
15233 	},
15234 	.digest = {
15235 		.data = {
15236 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
15237 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
15238 		},
15239 		.len = 16
15240 	}
15241 };
15242 
15243 static const struct test_crypto_vector
15244 aes128cbc_hmac_sha1_test_vector = {
15245 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15246 	.cipher_offset = 0,
15247 	.cipher_len = 512,
15248 	.cipher_key = {
15249 		.data = {
15250 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15251 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15252 		},
15253 		.len = 16
15254 	},
15255 	.iv = {
15256 		.data = {
15257 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15258 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15259 		},
15260 		.len = 16
15261 	},
15262 	.plaintext = {
15263 		.data = plaintext_hash,
15264 		.len = 512
15265 	},
15266 	.ciphertext = {
15267 		.data = ciphertext512_aes128cbc,
15268 		.len = 512
15269 	},
15270 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15271 	.auth_offset = 0,
15272 	.auth_key = {
15273 		.data = {
15274 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15275 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15276 			0xDE, 0xF4, 0xDE, 0xAD
15277 		},
15278 		.len = 20
15279 	},
15280 	.digest = {
15281 		.data = {
15282 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
15283 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15284 			0x18, 0x8C, 0x1D, 0x32
15285 		},
15286 		.len = 20
15287 	}
15288 };
15289 
15290 static const struct test_crypto_vector
15291 aes128cbc_hmac_sha1_aad_test_vector = {
15292 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15293 	.cipher_offset = 8,
15294 	.cipher_len = 496,
15295 	.cipher_key = {
15296 		.data = {
15297 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15298 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15299 		},
15300 		.len = 16
15301 	},
15302 	.iv = {
15303 		.data = {
15304 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15305 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15306 		},
15307 		.len = 16
15308 	},
15309 	.plaintext = {
15310 		.data = plaintext_hash,
15311 		.len = 512
15312 	},
15313 	.ciphertext = {
15314 		.data = ciphertext512_aes128cbc_aad,
15315 		.len = 512
15316 	},
15317 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15318 	.auth_offset = 0,
15319 	.auth_key = {
15320 		.data = {
15321 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15322 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15323 			0xDE, 0xF4, 0xDE, 0xAD
15324 		},
15325 		.len = 20
15326 	},
15327 	.digest = {
15328 		.data = {
15329 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
15330 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
15331 			0x62, 0x0F, 0xFB, 0x10
15332 		},
15333 		.len = 20
15334 	}
15335 };
15336 
15337 static void
15338 data_corruption(uint8_t *data)
15339 {
15340 	data[0] += 1;
15341 }
15342 
15343 static void
15344 tag_corruption(uint8_t *data, unsigned int tag_offset)
15345 {
15346 	data[tag_offset] += 1;
15347 }
15348 
15349 static int
15350 create_auth_session(struct crypto_unittest_params *ut_params,
15351 		uint8_t dev_id,
15352 		const struct test_crypto_vector *reference,
15353 		enum rte_crypto_auth_operation auth_op)
15354 {
15355 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15356 	uint8_t auth_key[reference->auth_key.len + 1];
15357 
15358 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15359 
15360 	/* Setup Authentication Parameters */
15361 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15362 	ut_params->auth_xform.auth.op = auth_op;
15363 	ut_params->auth_xform.next = NULL;
15364 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15365 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15366 	ut_params->auth_xform.auth.key.data = auth_key;
15367 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15368 
15369 	/* Create Crypto session*/
15370 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15371 				&ut_params->auth_xform,
15372 				ts_params->session_mpool);
15373 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15374 		return TEST_SKIPPED;
15375 
15376 	return 0;
15377 }
15378 
15379 static int
15380 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
15381 		uint8_t dev_id,
15382 		const struct test_crypto_vector *reference,
15383 		enum rte_crypto_auth_operation auth_op,
15384 		enum rte_crypto_cipher_operation cipher_op)
15385 {
15386 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15387 	uint8_t cipher_key[reference->cipher_key.len + 1];
15388 	uint8_t auth_key[reference->auth_key.len + 1];
15389 
15390 	memcpy(cipher_key, reference->cipher_key.data,
15391 			reference->cipher_key.len);
15392 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15393 
15394 	/* Setup Authentication Parameters */
15395 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15396 	ut_params->auth_xform.auth.op = auth_op;
15397 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15398 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15399 	ut_params->auth_xform.auth.key.data = auth_key;
15400 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15401 
15402 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
15403 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15404 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
15405 	} else {
15406 		ut_params->auth_xform.next = &ut_params->cipher_xform;
15407 
15408 		/* Setup Cipher Parameters */
15409 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15410 		ut_params->cipher_xform.next = NULL;
15411 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15412 		ut_params->cipher_xform.cipher.op = cipher_op;
15413 		ut_params->cipher_xform.cipher.key.data = cipher_key;
15414 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15415 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15416 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15417 	}
15418 
15419 	/* Create Crypto session*/
15420 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15421 				&ut_params->auth_xform,
15422 				ts_params->session_mpool);
15423 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15424 		return TEST_SKIPPED;
15425 
15426 	return 0;
15427 }
15428 
15429 static int
15430 create_auth_operation(struct crypto_testsuite_params *ts_params,
15431 		struct crypto_unittest_params *ut_params,
15432 		const struct test_crypto_vector *reference,
15433 		unsigned int auth_generate)
15434 {
15435 	/* Generate Crypto op data structure */
15436 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15437 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15438 	TEST_ASSERT_NOT_NULL(ut_params->op,
15439 			"Failed to allocate pktmbuf offload");
15440 
15441 	/* Set crypto operation data parameters */
15442 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15443 
15444 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15445 
15446 	/* set crypto operation source mbuf */
15447 	sym_op->m_src = ut_params->ibuf;
15448 
15449 	/* digest */
15450 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15451 			ut_params->ibuf, reference->digest.len);
15452 
15453 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15454 			"no room to append auth tag");
15455 
15456 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15457 			ut_params->ibuf, reference->plaintext.len);
15458 
15459 	if (auth_generate)
15460 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15461 	else
15462 		memcpy(sym_op->auth.digest.data,
15463 				reference->digest.data,
15464 				reference->digest.len);
15465 
15466 	debug_hexdump(stdout, "digest:",
15467 			sym_op->auth.digest.data,
15468 			reference->digest.len);
15469 
15470 	sym_op->auth.data.length = reference->plaintext.len;
15471 	sym_op->auth.data.offset = 0;
15472 
15473 	return 0;
15474 }
15475 
15476 static int
15477 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
15478 		struct crypto_unittest_params *ut_params,
15479 		const struct test_crypto_vector *reference,
15480 		unsigned int auth_generate)
15481 {
15482 	/* Generate Crypto op data structure */
15483 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15484 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15485 	TEST_ASSERT_NOT_NULL(ut_params->op,
15486 			"Failed to allocate pktmbuf offload");
15487 
15488 	/* Set crypto operation data parameters */
15489 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15490 
15491 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15492 
15493 	/* set crypto operation source mbuf */
15494 	sym_op->m_src = ut_params->ibuf;
15495 
15496 	/* digest */
15497 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15498 			ut_params->ibuf, reference->digest.len);
15499 
15500 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15501 			"no room to append auth tag");
15502 
15503 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15504 			ut_params->ibuf, reference->ciphertext.len);
15505 
15506 	if (auth_generate)
15507 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15508 	else
15509 		memcpy(sym_op->auth.digest.data,
15510 				reference->digest.data,
15511 				reference->digest.len);
15512 
15513 	debug_hexdump(stdout, "digest:",
15514 			sym_op->auth.digest.data,
15515 			reference->digest.len);
15516 
15517 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15518 			reference->iv.data, reference->iv.len);
15519 
15520 	sym_op->cipher.data.length = 0;
15521 	sym_op->cipher.data.offset = 0;
15522 
15523 	sym_op->auth.data.length = reference->plaintext.len;
15524 	sym_op->auth.data.offset = 0;
15525 
15526 	return 0;
15527 }
15528 
15529 static int
15530 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
15531 		struct crypto_unittest_params *ut_params,
15532 		const struct test_crypto_vector *reference,
15533 		unsigned int auth_generate)
15534 {
15535 	/* Generate Crypto op data structure */
15536 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15537 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15538 	TEST_ASSERT_NOT_NULL(ut_params->op,
15539 			"Failed to allocate pktmbuf offload");
15540 
15541 	/* Set crypto operation data parameters */
15542 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15543 
15544 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15545 
15546 	/* set crypto operation source mbuf */
15547 	sym_op->m_src = ut_params->ibuf;
15548 
15549 	/* digest */
15550 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15551 			ut_params->ibuf, reference->digest.len);
15552 
15553 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15554 			"no room to append auth tag");
15555 
15556 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15557 			ut_params->ibuf, reference->ciphertext.len);
15558 
15559 	if (auth_generate)
15560 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15561 	else
15562 		memcpy(sym_op->auth.digest.data,
15563 				reference->digest.data,
15564 				reference->digest.len);
15565 
15566 	debug_hexdump(stdout, "digest:",
15567 			sym_op->auth.digest.data,
15568 			reference->digest.len);
15569 
15570 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15571 			reference->iv.data, reference->iv.len);
15572 
15573 	sym_op->cipher.data.length = reference->cipher_len;
15574 	sym_op->cipher.data.offset = reference->cipher_offset;
15575 
15576 	sym_op->auth.data.length = reference->plaintext.len;
15577 	sym_op->auth.data.offset = reference->auth_offset;
15578 
15579 	return 0;
15580 }
15581 
15582 static int
15583 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15584 		struct crypto_unittest_params *ut_params,
15585 		const struct test_crypto_vector *reference)
15586 {
15587 	return create_auth_operation(ts_params, ut_params, reference, 0);
15588 }
15589 
15590 static int
15591 create_auth_verify_GMAC_operation(
15592 		struct crypto_testsuite_params *ts_params,
15593 		struct crypto_unittest_params *ut_params,
15594 		const struct test_crypto_vector *reference)
15595 {
15596 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
15597 }
15598 
15599 static int
15600 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15601 		struct crypto_unittest_params *ut_params,
15602 		const struct test_crypto_vector *reference)
15603 {
15604 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
15605 }
15606 
15607 static int
15608 test_authentication_verify_fail_when_data_corruption(
15609 		struct crypto_testsuite_params *ts_params,
15610 		struct crypto_unittest_params *ut_params,
15611 		const struct test_crypto_vector *reference,
15612 		unsigned int data_corrupted)
15613 {
15614 	int retval;
15615 
15616 	uint8_t *plaintext;
15617 	struct rte_cryptodev_info dev_info;
15618 
15619 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15620 	uint64_t feat_flags = dev_info.feature_flags;
15621 
15622 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15623 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15624 		printf("Device doesn't support RAW data-path APIs.\n");
15625 		return TEST_SKIPPED;
15626 	}
15627 
15628 	/* Verify the capabilities */
15629 	struct rte_cryptodev_sym_capability_idx cap_idx;
15630 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15631 	cap_idx.algo.auth = reference->auth_algo;
15632 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15633 			&cap_idx) == NULL)
15634 		return TEST_SKIPPED;
15635 
15636 
15637 	/* Create session */
15638 	retval = create_auth_session(ut_params,
15639 			ts_params->valid_devs[0],
15640 			reference,
15641 			RTE_CRYPTO_AUTH_OP_VERIFY);
15642 
15643 	if (retval == TEST_SKIPPED)
15644 		return TEST_SKIPPED;
15645 	if (retval < 0)
15646 		return retval;
15647 
15648 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15649 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15650 			"Failed to allocate input buffer in mempool");
15651 
15652 	/* clear mbuf payload */
15653 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15654 			rte_pktmbuf_tailroom(ut_params->ibuf));
15655 
15656 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15657 			reference->plaintext.len);
15658 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15659 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15660 
15661 	debug_hexdump(stdout, "plaintext:", plaintext,
15662 		reference->plaintext.len);
15663 
15664 	/* Create operation */
15665 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
15666 
15667 	if (retval < 0)
15668 		return retval;
15669 
15670 	if (data_corrupted)
15671 		data_corruption(plaintext);
15672 	else
15673 		tag_corruption(plaintext, reference->plaintext.len);
15674 
15675 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15676 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15677 			ut_params->op);
15678 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15679 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15680 			"authentication not failed");
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, 0, 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 	if (ut_params->op == NULL)
15691 		return 0;
15692 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
15693 		return 0;
15694 
15695 	return -1;
15696 }
15697 
15698 static int
15699 test_authentication_verify_GMAC_fail_when_corruption(
15700 		struct crypto_testsuite_params *ts_params,
15701 		struct crypto_unittest_params *ut_params,
15702 		const struct test_crypto_vector *reference,
15703 		unsigned int data_corrupted)
15704 {
15705 	int retval;
15706 	uint8_t *plaintext;
15707 	struct rte_cryptodev_info dev_info;
15708 
15709 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15710 	uint64_t feat_flags = dev_info.feature_flags;
15711 
15712 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15713 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15714 		printf("Device doesn't support RAW data-path APIs.\n");
15715 		return TEST_SKIPPED;
15716 	}
15717 
15718 	/* Verify the capabilities */
15719 	struct rte_cryptodev_sym_capability_idx cap_idx;
15720 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15721 	cap_idx.algo.auth = reference->auth_algo;
15722 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15723 			&cap_idx) == NULL)
15724 		return TEST_SKIPPED;
15725 
15726 	/* Create session */
15727 	retval = create_auth_cipher_session(ut_params,
15728 			ts_params->valid_devs[0],
15729 			reference,
15730 			RTE_CRYPTO_AUTH_OP_VERIFY,
15731 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
15732 	if (retval == TEST_SKIPPED)
15733 		return TEST_SKIPPED;
15734 	if (retval < 0)
15735 		return retval;
15736 
15737 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15738 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15739 			"Failed to allocate input buffer in mempool");
15740 
15741 	/* clear mbuf payload */
15742 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15743 			rte_pktmbuf_tailroom(ut_params->ibuf));
15744 
15745 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15746 			reference->plaintext.len);
15747 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15748 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15749 
15750 	debug_hexdump(stdout, "plaintext:", plaintext,
15751 		reference->plaintext.len);
15752 
15753 	/* Create operation */
15754 	retval = create_auth_verify_GMAC_operation(ts_params,
15755 			ut_params,
15756 			reference);
15757 
15758 	if (retval < 0)
15759 		return retval;
15760 
15761 	if (data_corrupted)
15762 		data_corruption(plaintext);
15763 	else
15764 		tag_corruption(plaintext, reference->aad.len);
15765 
15766 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15767 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15768 			ut_params->op);
15769 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15770 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15771 			"authentication not failed");
15772 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15773 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15774 					       0);
15775 		if (retval != TEST_SUCCESS)
15776 			return retval;
15777 	} else {
15778 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15779 			ut_params->op);
15780 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15781 	}
15782 
15783 	return 0;
15784 }
15785 
15786 static int
15787 test_authenticated_decryption_fail_when_corruption(
15788 		struct crypto_testsuite_params *ts_params,
15789 		struct crypto_unittest_params *ut_params,
15790 		const struct test_crypto_vector *reference,
15791 		unsigned int data_corrupted)
15792 {
15793 	int retval;
15794 
15795 	uint8_t *ciphertext;
15796 	struct rte_cryptodev_info dev_info;
15797 
15798 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15799 	uint64_t feat_flags = dev_info.feature_flags;
15800 
15801 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15802 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15803 		printf("Device doesn't support RAW data-path APIs.\n");
15804 		return TEST_SKIPPED;
15805 	}
15806 
15807 	/* Verify the capabilities */
15808 	struct rte_cryptodev_sym_capability_idx cap_idx;
15809 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15810 	cap_idx.algo.auth = reference->auth_algo;
15811 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15812 			&cap_idx) == NULL)
15813 		return TEST_SKIPPED;
15814 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15815 	cap_idx.algo.cipher = reference->crypto_algo;
15816 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15817 			&cap_idx) == NULL)
15818 		return TEST_SKIPPED;
15819 
15820 	/* Create session */
15821 	retval = create_auth_cipher_session(ut_params,
15822 			ts_params->valid_devs[0],
15823 			reference,
15824 			RTE_CRYPTO_AUTH_OP_VERIFY,
15825 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
15826 	if (retval == TEST_SKIPPED)
15827 		return TEST_SKIPPED;
15828 	if (retval < 0)
15829 		return retval;
15830 
15831 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15832 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15833 			"Failed to allocate input buffer in mempool");
15834 
15835 	/* clear mbuf payload */
15836 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15837 			rte_pktmbuf_tailroom(ut_params->ibuf));
15838 
15839 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15840 			reference->ciphertext.len);
15841 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15842 	memcpy(ciphertext, reference->ciphertext.data,
15843 			reference->ciphertext.len);
15844 
15845 	/* Create operation */
15846 	retval = create_cipher_auth_verify_operation(ts_params,
15847 			ut_params,
15848 			reference);
15849 
15850 	if (retval < 0)
15851 		return retval;
15852 
15853 	if (data_corrupted)
15854 		data_corruption(ciphertext);
15855 	else
15856 		tag_corruption(ciphertext, reference->ciphertext.len);
15857 
15858 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15859 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15860 			ut_params->op);
15861 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15862 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15863 			"authentication not failed");
15864 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15865 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15866 					       0);
15867 		if (retval != TEST_SUCCESS)
15868 			return retval;
15869 	} else {
15870 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15871 			ut_params->op);
15872 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15873 	}
15874 
15875 	return 0;
15876 }
15877 
15878 static int
15879 test_authenticated_encrypt_with_esn(
15880 		struct crypto_testsuite_params *ts_params,
15881 		struct crypto_unittest_params *ut_params,
15882 		const struct test_crypto_vector *reference)
15883 {
15884 	int retval;
15885 
15886 	uint8_t *authciphertext, *plaintext, *auth_tag;
15887 	uint16_t plaintext_pad_len;
15888 	uint8_t cipher_key[reference->cipher_key.len + 1];
15889 	uint8_t auth_key[reference->auth_key.len + 1];
15890 	struct rte_cryptodev_info dev_info;
15891 
15892 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15893 	uint64_t feat_flags = dev_info.feature_flags;
15894 
15895 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15896 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15897 		printf("Device doesn't support RAW data-path APIs.\n");
15898 		return TEST_SKIPPED;
15899 	}
15900 
15901 	/* Verify the capabilities */
15902 	struct rte_cryptodev_sym_capability_idx cap_idx;
15903 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15904 	cap_idx.algo.auth = reference->auth_algo;
15905 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15906 			&cap_idx) == NULL)
15907 		return TEST_SKIPPED;
15908 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15909 	cap_idx.algo.cipher = reference->crypto_algo;
15910 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15911 			&cap_idx) == NULL)
15912 		return TEST_SKIPPED;
15913 
15914 	/* Create session */
15915 	memcpy(cipher_key, reference->cipher_key.data,
15916 			reference->cipher_key.len);
15917 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15918 
15919 	/* Setup Cipher Parameters */
15920 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15921 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15922 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15923 	ut_params->cipher_xform.cipher.key.data = cipher_key;
15924 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15925 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15926 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15927 
15928 	ut_params->cipher_xform.next = &ut_params->auth_xform;
15929 
15930 	/* Setup Authentication Parameters */
15931 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15932 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15933 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15934 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15935 	ut_params->auth_xform.auth.key.data = auth_key;
15936 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15937 	ut_params->auth_xform.next = NULL;
15938 
15939 	/* Create Crypto session*/
15940 	ut_params->sess = rte_cryptodev_sym_session_create(
15941 			ts_params->valid_devs[0], &ut_params->cipher_xform,
15942 			ts_params->session_mpool);
15943 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15944 		return TEST_SKIPPED;
15945 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15946 
15947 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15948 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15949 			"Failed to allocate input buffer in mempool");
15950 
15951 	/* clear mbuf payload */
15952 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15953 			rte_pktmbuf_tailroom(ut_params->ibuf));
15954 
15955 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15956 			reference->plaintext.len);
15957 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15958 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15959 
15960 	/* Create operation */
15961 	retval = create_cipher_auth_operation(ts_params,
15962 			ut_params,
15963 			reference, 0);
15964 
15965 	if (retval < 0)
15966 		return retval;
15967 
15968 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15969 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15970 			ut_params->op);
15971 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15972 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15973 					       0);
15974 		if (retval != TEST_SUCCESS)
15975 			return retval;
15976 	} else
15977 		ut_params->op = process_crypto_request(
15978 			ts_params->valid_devs[0], ut_params->op);
15979 
15980 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
15981 
15982 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15983 			"crypto op processing failed");
15984 
15985 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
15986 
15987 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
15988 			ut_params->op->sym->auth.data.offset);
15989 	auth_tag = authciphertext + plaintext_pad_len;
15990 	debug_hexdump(stdout, "ciphertext:", authciphertext,
15991 			reference->ciphertext.len);
15992 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
15993 
15994 	/* Validate obuf */
15995 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15996 			authciphertext,
15997 			reference->ciphertext.data,
15998 			reference->ciphertext.len,
15999 			"Ciphertext data not as expected");
16000 
16001 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16002 			auth_tag,
16003 			reference->digest.data,
16004 			reference->digest.len,
16005 			"Generated digest not as expected");
16006 
16007 	return TEST_SUCCESS;
16008 
16009 }
16010 
16011 static int
16012 test_authenticated_decrypt_with_esn(
16013 		struct crypto_testsuite_params *ts_params,
16014 		struct crypto_unittest_params *ut_params,
16015 		const struct test_crypto_vector *reference)
16016 {
16017 	int retval;
16018 
16019 	uint8_t *ciphertext;
16020 	uint8_t cipher_key[reference->cipher_key.len + 1];
16021 	uint8_t auth_key[reference->auth_key.len + 1];
16022 	struct rte_cryptodev_info dev_info;
16023 
16024 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16025 	uint64_t feat_flags = dev_info.feature_flags;
16026 
16027 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16028 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16029 		printf("Device doesn't support RAW data-path APIs.\n");
16030 		return TEST_SKIPPED;
16031 	}
16032 
16033 	/* Verify the capabilities */
16034 	struct rte_cryptodev_sym_capability_idx cap_idx;
16035 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16036 	cap_idx.algo.auth = reference->auth_algo;
16037 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16038 			&cap_idx) == NULL)
16039 		return TEST_SKIPPED;
16040 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16041 	cap_idx.algo.cipher = reference->crypto_algo;
16042 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16043 			&cap_idx) == NULL)
16044 		return TEST_SKIPPED;
16045 
16046 	/* Create session */
16047 	memcpy(cipher_key, reference->cipher_key.data,
16048 			reference->cipher_key.len);
16049 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16050 
16051 	/* Setup Authentication Parameters */
16052 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16053 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16054 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16055 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16056 	ut_params->auth_xform.auth.key.data = auth_key;
16057 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16058 	ut_params->auth_xform.next = &ut_params->cipher_xform;
16059 
16060 	/* Setup Cipher Parameters */
16061 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16062 	ut_params->cipher_xform.next = NULL;
16063 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16064 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16065 	ut_params->cipher_xform.cipher.key.data = cipher_key;
16066 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16067 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16068 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16069 
16070 	/* Create Crypto session*/
16071 	ut_params->sess = rte_cryptodev_sym_session_create(
16072 			ts_params->valid_devs[0], &ut_params->auth_xform,
16073 			ts_params->session_mpool);
16074 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16075 		return TEST_SKIPPED;
16076 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16077 
16078 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16079 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16080 			"Failed to allocate input buffer in mempool");
16081 
16082 	/* clear mbuf payload */
16083 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16084 			rte_pktmbuf_tailroom(ut_params->ibuf));
16085 
16086 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16087 			reference->ciphertext.len);
16088 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16089 	memcpy(ciphertext, reference->ciphertext.data,
16090 			reference->ciphertext.len);
16091 
16092 	/* Create operation */
16093 	retval = create_cipher_auth_verify_operation(ts_params,
16094 			ut_params,
16095 			reference);
16096 
16097 	if (retval < 0)
16098 		return retval;
16099 
16100 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16101 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16102 			ut_params->op);
16103 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16104 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16105 					       0);
16106 		if (retval != TEST_SUCCESS)
16107 			return retval;
16108 	} else
16109 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16110 			ut_params->op);
16111 
16112 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16113 	TEST_ASSERT_EQUAL(ut_params->op->status,
16114 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16115 			"crypto op processing passed");
16116 
16117 	ut_params->obuf = ut_params->op->sym->m_src;
16118 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16119 
16120 	return 0;
16121 }
16122 
16123 static int
16124 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16125 		const struct aead_test_data *tdata,
16126 		void *digest_mem, uint64_t digest_phys)
16127 {
16128 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16129 	struct crypto_unittest_params *ut_params = &unittest_params;
16130 
16131 	const unsigned int auth_tag_len = tdata->auth_tag.len;
16132 	const unsigned int iv_len = tdata->iv.len;
16133 	unsigned int aad_len = tdata->aad.len;
16134 	unsigned int aad_len_pad = 0;
16135 
16136 	/* Generate Crypto op data structure */
16137 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16138 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16139 	TEST_ASSERT_NOT_NULL(ut_params->op,
16140 		"Failed to allocate symmetric crypto operation struct");
16141 
16142 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16143 
16144 	sym_op->aead.digest.data = digest_mem;
16145 
16146 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
16147 			"no room to append digest");
16148 
16149 	sym_op->aead.digest.phys_addr = digest_phys;
16150 
16151 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
16152 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
16153 				auth_tag_len);
16154 		debug_hexdump(stdout, "digest:",
16155 				sym_op->aead.digest.data,
16156 				auth_tag_len);
16157 	}
16158 
16159 	/* Append aad data */
16160 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
16161 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16162 				uint8_t *, IV_OFFSET);
16163 
16164 		/* Copy IV 1 byte after the IV pointer, according to the API */
16165 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
16166 
16167 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
16168 
16169 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16170 				ut_params->ibuf, aad_len);
16171 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16172 				"no room to prepend aad");
16173 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16174 				ut_params->ibuf);
16175 
16176 		memset(sym_op->aead.aad.data, 0, aad_len);
16177 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
16178 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16179 
16180 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16181 		debug_hexdump(stdout, "aad:",
16182 				sym_op->aead.aad.data, aad_len);
16183 	} else {
16184 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16185 				uint8_t *, IV_OFFSET);
16186 
16187 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
16188 
16189 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
16190 
16191 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16192 				ut_params->ibuf, aad_len_pad);
16193 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16194 				"no room to prepend aad");
16195 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16196 				ut_params->ibuf);
16197 
16198 		memset(sym_op->aead.aad.data, 0, aad_len);
16199 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16200 
16201 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16202 		debug_hexdump(stdout, "aad:",
16203 				sym_op->aead.aad.data, aad_len);
16204 	}
16205 
16206 	sym_op->aead.data.length = tdata->plaintext.len;
16207 	sym_op->aead.data.offset = aad_len_pad;
16208 
16209 	return 0;
16210 }
16211 
16212 #define SGL_MAX_NO	16
16213 
16214 static int
16215 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
16216 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
16217 {
16218 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16219 	struct crypto_unittest_params *ut_params = &unittest_params;
16220 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
16221 	int retval;
16222 	int to_trn = 0;
16223 	int to_trn_tbl[SGL_MAX_NO];
16224 	int segs = 1;
16225 	unsigned int trn_data = 0;
16226 	uint8_t *plaintext, *ciphertext, *auth_tag;
16227 	struct rte_cryptodev_info dev_info;
16228 
16229 	/* Verify the capabilities */
16230 	struct rte_cryptodev_sym_capability_idx cap_idx;
16231 	const struct rte_cryptodev_symmetric_capability *capability;
16232 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
16233 	cap_idx.algo.aead = tdata->algo;
16234 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
16235 	if (capability == NULL)
16236 		return TEST_SKIPPED;
16237 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
16238 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
16239 		return TEST_SKIPPED;
16240 
16241 	/*
16242 	 * SGL not supported on AESNI_MB PMD CPU crypto,
16243 	 * OOP not supported on AESNI_GCM CPU crypto
16244 	 */
16245 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
16246 			(gbl_driver_id == rte_cryptodev_driver_id_get(
16247 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
16248 		return TEST_SKIPPED;
16249 
16250 	/* Detailed check for the particular SGL support flag */
16251 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16252 	if (!oop) {
16253 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
16254 		if (sgl_in && (!(dev_info.feature_flags &
16255 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
16256 			return TEST_SKIPPED;
16257 
16258 		uint64_t feat_flags = dev_info.feature_flags;
16259 
16260 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16261 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16262 			printf("Device doesn't support RAW data-path APIs.\n");
16263 			return TEST_SKIPPED;
16264 		}
16265 	} else {
16266 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
16267 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
16268 				tdata->plaintext.len;
16269 		/* Raw data path API does not support OOP */
16270 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
16271 			return TEST_SKIPPED;
16272 		if (sgl_in && !sgl_out) {
16273 			if (!(dev_info.feature_flags &
16274 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
16275 				return TEST_SKIPPED;
16276 		} else if (!sgl_in && sgl_out) {
16277 			if (!(dev_info.feature_flags &
16278 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
16279 				return TEST_SKIPPED;
16280 		} else if (sgl_in && sgl_out) {
16281 			if (!(dev_info.feature_flags &
16282 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
16283 				return TEST_SKIPPED;
16284 		}
16285 	}
16286 
16287 	if (fragsz > tdata->plaintext.len)
16288 		fragsz = tdata->plaintext.len;
16289 
16290 	uint16_t plaintext_len = fragsz;
16291 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
16292 
16293 	if (fragsz_oop > tdata->plaintext.len)
16294 		frag_size_oop = tdata->plaintext.len;
16295 
16296 	int ecx = 0;
16297 	void *digest_mem = NULL;
16298 
16299 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
16300 
16301 	if (tdata->plaintext.len % fragsz != 0) {
16302 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
16303 			return 1;
16304 	}	else {
16305 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
16306 			return 1;
16307 	}
16308 
16309 	/*
16310 	 * For out-op-place we need to alloc another mbuf
16311 	 */
16312 	if (oop) {
16313 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16314 		rte_pktmbuf_append(ut_params->obuf,
16315 				frag_size_oop + prepend_len);
16316 		buf_oop = ut_params->obuf;
16317 	}
16318 
16319 	/* Create AEAD session */
16320 	retval = create_aead_session(ts_params->valid_devs[0],
16321 			tdata->algo,
16322 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
16323 			tdata->key.data, tdata->key.len,
16324 			tdata->aad.len, tdata->auth_tag.len,
16325 			tdata->iv.len);
16326 	if (retval < 0)
16327 		return retval;
16328 
16329 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16330 
16331 	/* clear mbuf payload */
16332 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16333 			rte_pktmbuf_tailroom(ut_params->ibuf));
16334 
16335 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16336 			plaintext_len);
16337 
16338 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
16339 
16340 	trn_data += plaintext_len;
16341 
16342 	buf = ut_params->ibuf;
16343 
16344 	/*
16345 	 * Loop until no more fragments
16346 	 */
16347 
16348 	while (trn_data < tdata->plaintext.len) {
16349 		++segs;
16350 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
16351 				(tdata->plaintext.len - trn_data) : fragsz;
16352 
16353 		to_trn_tbl[ecx++] = to_trn;
16354 
16355 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16356 		buf = buf->next;
16357 
16358 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
16359 				rte_pktmbuf_tailroom(buf));
16360 
16361 		/* OOP */
16362 		if (oop && !fragsz_oop) {
16363 			buf_last_oop = buf_oop->next =
16364 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
16365 			buf_oop = buf_oop->next;
16366 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16367 					0, rte_pktmbuf_tailroom(buf_oop));
16368 			rte_pktmbuf_append(buf_oop, to_trn);
16369 		}
16370 
16371 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
16372 				to_trn);
16373 
16374 		memcpy(plaintext, tdata->plaintext.data + trn_data,
16375 				to_trn);
16376 		trn_data += to_trn;
16377 		if (trn_data  == tdata->plaintext.len) {
16378 			if (oop) {
16379 				if (!fragsz_oop)
16380 					digest_mem = rte_pktmbuf_append(buf_oop,
16381 						tdata->auth_tag.len);
16382 			} else
16383 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
16384 					tdata->auth_tag.len);
16385 		}
16386 	}
16387 
16388 	uint64_t digest_phys = 0;
16389 
16390 	ut_params->ibuf->nb_segs = segs;
16391 
16392 	segs = 1;
16393 	if (fragsz_oop && oop) {
16394 		to_trn = 0;
16395 		ecx = 0;
16396 
16397 		if (frag_size_oop == tdata->plaintext.len) {
16398 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
16399 				tdata->auth_tag.len);
16400 
16401 			digest_phys = rte_pktmbuf_iova_offset(
16402 					ut_params->obuf,
16403 					tdata->plaintext.len + prepend_len);
16404 		}
16405 
16406 		trn_data = frag_size_oop;
16407 		while (trn_data < tdata->plaintext.len) {
16408 			++segs;
16409 			to_trn =
16410 				(tdata->plaintext.len - trn_data <
16411 						frag_size_oop) ?
16412 				(tdata->plaintext.len - trn_data) :
16413 						frag_size_oop;
16414 
16415 			to_trn_tbl[ecx++] = to_trn;
16416 
16417 			buf_last_oop = buf_oop->next =
16418 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
16419 			buf_oop = buf_oop->next;
16420 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16421 					0, rte_pktmbuf_tailroom(buf_oop));
16422 			rte_pktmbuf_append(buf_oop, to_trn);
16423 
16424 			trn_data += to_trn;
16425 
16426 			if (trn_data  == tdata->plaintext.len) {
16427 				digest_mem = rte_pktmbuf_append(buf_oop,
16428 					tdata->auth_tag.len);
16429 			}
16430 		}
16431 
16432 		ut_params->obuf->nb_segs = segs;
16433 	}
16434 
16435 	/*
16436 	 * Place digest at the end of the last buffer
16437 	 */
16438 	if (!digest_phys)
16439 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
16440 	if (oop && buf_last_oop)
16441 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
16442 
16443 	if (!digest_mem && !oop) {
16444 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16445 				+ tdata->auth_tag.len);
16446 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
16447 				tdata->plaintext.len);
16448 	}
16449 
16450 	/* Create AEAD operation */
16451 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
16452 			tdata, digest_mem, digest_phys);
16453 
16454 	if (retval < 0)
16455 		return retval;
16456 
16457 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16458 
16459 	ut_params->op->sym->m_src = ut_params->ibuf;
16460 	if (oop)
16461 		ut_params->op->sym->m_dst = ut_params->obuf;
16462 
16463 	/* Process crypto operation */
16464 	if (oop == IN_PLACE &&
16465 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16466 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
16467 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16468 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
16469 					       0);
16470 		if (retval != TEST_SUCCESS)
16471 			return retval;
16472 	} else
16473 		TEST_ASSERT_NOT_NULL(
16474 			process_crypto_request(ts_params->valid_devs[0],
16475 			ut_params->op), "failed to process sym crypto op");
16476 
16477 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16478 			"crypto op processing failed");
16479 
16480 
16481 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
16482 			uint8_t *, prepend_len);
16483 	if (oop) {
16484 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
16485 				uint8_t *, prepend_len);
16486 	}
16487 
16488 	if (fragsz_oop)
16489 		fragsz = fragsz_oop;
16490 
16491 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16492 			ciphertext,
16493 			tdata->ciphertext.data,
16494 			fragsz,
16495 			"Ciphertext data not as expected");
16496 
16497 	buf = ut_params->op->sym->m_src->next;
16498 	if (oop)
16499 		buf = ut_params->op->sym->m_dst->next;
16500 
16501 	unsigned int off = fragsz;
16502 
16503 	ecx = 0;
16504 	while (buf) {
16505 		ciphertext = rte_pktmbuf_mtod(buf,
16506 				uint8_t *);
16507 
16508 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
16509 				ciphertext,
16510 				tdata->ciphertext.data + off,
16511 				to_trn_tbl[ecx],
16512 				"Ciphertext data not as expected");
16513 
16514 		off += to_trn_tbl[ecx++];
16515 		buf = buf->next;
16516 	}
16517 
16518 	auth_tag = digest_mem;
16519 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16520 			auth_tag,
16521 			tdata->auth_tag.data,
16522 			tdata->auth_tag.len,
16523 			"Generated auth tag not as expected");
16524 
16525 	return 0;
16526 }
16527 
16528 static int
16529 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
16530 {
16531 	return test_authenticated_encryption_SGL(
16532 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
16533 }
16534 
16535 static int
16536 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
16537 {
16538 	return test_authenticated_encryption_SGL(
16539 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
16540 }
16541 
16542 static int
16543 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
16544 {
16545 	return test_authenticated_encryption_SGL(
16546 			&gcm_test_case_8, OUT_OF_PLACE, 400,
16547 			gcm_test_case_8.plaintext.len);
16548 }
16549 
16550 static int
16551 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
16552 {
16553 	/* This test is not for OPENSSL PMD */
16554 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
16555 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
16556 		return TEST_SKIPPED;
16557 
16558 	return test_authenticated_encryption_SGL(
16559 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
16560 }
16561 
16562 static int
16563 test_authentication_verify_fail_when_data_corrupted(
16564 		struct crypto_testsuite_params *ts_params,
16565 		struct crypto_unittest_params *ut_params,
16566 		const struct test_crypto_vector *reference)
16567 {
16568 	return test_authentication_verify_fail_when_data_corruption(
16569 			ts_params, ut_params, reference, 1);
16570 }
16571 
16572 static int
16573 test_authentication_verify_fail_when_tag_corrupted(
16574 		struct crypto_testsuite_params *ts_params,
16575 		struct crypto_unittest_params *ut_params,
16576 		const struct test_crypto_vector *reference)
16577 {
16578 	return test_authentication_verify_fail_when_data_corruption(
16579 			ts_params, ut_params, reference, 0);
16580 }
16581 
16582 static int
16583 test_authentication_verify_GMAC_fail_when_data_corrupted(
16584 		struct crypto_testsuite_params *ts_params,
16585 		struct crypto_unittest_params *ut_params,
16586 		const struct test_crypto_vector *reference)
16587 {
16588 	return test_authentication_verify_GMAC_fail_when_corruption(
16589 			ts_params, ut_params, reference, 1);
16590 }
16591 
16592 static int
16593 test_authentication_verify_GMAC_fail_when_tag_corrupted(
16594 		struct crypto_testsuite_params *ts_params,
16595 		struct crypto_unittest_params *ut_params,
16596 		const struct test_crypto_vector *reference)
16597 {
16598 	return test_authentication_verify_GMAC_fail_when_corruption(
16599 			ts_params, ut_params, reference, 0);
16600 }
16601 
16602 static int
16603 test_authenticated_decryption_fail_when_data_corrupted(
16604 		struct crypto_testsuite_params *ts_params,
16605 		struct crypto_unittest_params *ut_params,
16606 		const struct test_crypto_vector *reference)
16607 {
16608 	return test_authenticated_decryption_fail_when_corruption(
16609 			ts_params, ut_params, reference, 1);
16610 }
16611 
16612 static int
16613 test_authenticated_decryption_fail_when_tag_corrupted(
16614 		struct crypto_testsuite_params *ts_params,
16615 		struct crypto_unittest_params *ut_params,
16616 		const struct test_crypto_vector *reference)
16617 {
16618 	return test_authenticated_decryption_fail_when_corruption(
16619 			ts_params, ut_params, reference, 0);
16620 }
16621 
16622 static int
16623 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
16624 {
16625 	return test_authentication_verify_fail_when_data_corrupted(
16626 			&testsuite_params, &unittest_params,
16627 			&hmac_sha1_test_crypto_vector);
16628 }
16629 
16630 static int
16631 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
16632 {
16633 	return test_authentication_verify_fail_when_tag_corrupted(
16634 			&testsuite_params, &unittest_params,
16635 			&hmac_sha1_test_crypto_vector);
16636 }
16637 
16638 static int
16639 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
16640 {
16641 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
16642 			&testsuite_params, &unittest_params,
16643 			&aes128_gmac_test_vector);
16644 }
16645 
16646 static int
16647 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
16648 {
16649 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
16650 			&testsuite_params, &unittest_params,
16651 			&aes128_gmac_test_vector);
16652 }
16653 
16654 static int
16655 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
16656 {
16657 	return test_authenticated_decryption_fail_when_data_corrupted(
16658 			&testsuite_params,
16659 			&unittest_params,
16660 			&aes128cbc_hmac_sha1_test_vector);
16661 }
16662 
16663 static int
16664 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
16665 {
16666 	return test_authenticated_decryption_fail_when_tag_corrupted(
16667 			&testsuite_params,
16668 			&unittest_params,
16669 			&aes128cbc_hmac_sha1_test_vector);
16670 }
16671 
16672 static int
16673 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16674 {
16675 	return test_authenticated_encrypt_with_esn(
16676 			&testsuite_params,
16677 			&unittest_params,
16678 			&aes128cbc_hmac_sha1_aad_test_vector);
16679 }
16680 
16681 static int
16682 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16683 {
16684 	return test_authenticated_decrypt_with_esn(
16685 			&testsuite_params,
16686 			&unittest_params,
16687 			&aes128cbc_hmac_sha1_aad_test_vector);
16688 }
16689 
16690 static int
16691 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
16692 {
16693 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
16694 }
16695 
16696 static int
16697 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
16698 {
16699 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
16700 }
16701 
16702 static int
16703 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
16704 {
16705 	return test_authenticated_encryption_SGL(
16706 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
16707 		chacha20_poly1305_case_2.plaintext.len);
16708 }
16709 
16710 #ifdef RTE_CRYPTO_SCHEDULER
16711 
16712 /* global AESNI worker IDs for the scheduler test */
16713 uint8_t aesni_ids[2];
16714 
16715 static int
16716 scheduler_testsuite_setup(void)
16717 {
16718 	uint32_t i = 0;
16719 	int32_t nb_devs, ret;
16720 	char vdev_args[VDEV_ARGS_SIZE] = {""};
16721 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
16722 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
16723 	uint16_t worker_core_count = 0;
16724 	uint16_t socket_id = 0;
16725 
16726 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
16727 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
16728 
16729 		/* Identify the Worker Cores
16730 		 * Use 2 worker cores for the device args
16731 		 */
16732 		RTE_LCORE_FOREACH_WORKER(i) {
16733 			if (worker_core_count > 1)
16734 				break;
16735 			snprintf(vdev_args, sizeof(vdev_args),
16736 					"%s%d", temp_str, i);
16737 			strcpy(temp_str, vdev_args);
16738 			strlcat(temp_str, ";", sizeof(temp_str));
16739 			worker_core_count++;
16740 			socket_id = rte_lcore_to_socket_id(i);
16741 		}
16742 		if (worker_core_count != 2) {
16743 			RTE_LOG(ERR, USER1,
16744 				"Cryptodev scheduler test require at least "
16745 				"two worker cores to run. "
16746 				"Please use the correct coremask.\n");
16747 			return TEST_FAILED;
16748 		}
16749 		strcpy(temp_str, vdev_args);
16750 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
16751 				temp_str, socket_id);
16752 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
16753 		nb_devs = rte_cryptodev_device_count_by_driver(
16754 				rte_cryptodev_driver_id_get(
16755 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
16756 		if (nb_devs < 1) {
16757 			ret = rte_vdev_init(
16758 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
16759 					vdev_args);
16760 			TEST_ASSERT(ret == 0,
16761 				"Failed to create instance %u of pmd : %s",
16762 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16763 		}
16764 	}
16765 	return testsuite_setup();
16766 }
16767 
16768 static int
16769 test_scheduler_attach_worker_op(void)
16770 {
16771 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16772 	uint8_t sched_id = ts_params->valid_devs[0];
16773 	uint32_t i, nb_devs_attached = 0;
16774 	int ret;
16775 	char vdev_name[32];
16776 	unsigned int count = rte_cryptodev_count();
16777 
16778 	/* create 2 AESNI_MB vdevs on top of existing devices */
16779 	for (i = count; i < count + 2; i++) {
16780 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
16781 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
16782 				i);
16783 		ret = rte_vdev_init(vdev_name, NULL);
16784 
16785 		TEST_ASSERT(ret == 0,
16786 			"Failed to create instance %u of"
16787 			" pmd : %s",
16788 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16789 
16790 		if (ret < 0) {
16791 			RTE_LOG(ERR, USER1,
16792 				"Failed to create 2 AESNI MB PMDs.\n");
16793 			return TEST_SKIPPED;
16794 		}
16795 	}
16796 
16797 	/* attach 2 AESNI_MB cdevs */
16798 	for (i = count; i < count + 2; i++) {
16799 		struct rte_cryptodev_info info;
16800 		unsigned int session_size;
16801 
16802 		rte_cryptodev_info_get(i, &info);
16803 		if (info.driver_id != rte_cryptodev_driver_id_get(
16804 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
16805 			continue;
16806 
16807 		session_size = rte_cryptodev_sym_get_private_session_size(i);
16808 		/*
16809 		 * Create the session mempool again, since now there are new devices
16810 		 * to use the mempool.
16811 		 */
16812 		if (ts_params->session_mpool) {
16813 			rte_mempool_free(ts_params->session_mpool);
16814 			ts_params->session_mpool = NULL;
16815 		}
16816 
16817 		if (info.sym.max_nb_sessions != 0 &&
16818 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
16819 			RTE_LOG(ERR, USER1,
16820 					"Device does not support "
16821 					"at least %u sessions\n",
16822 					MAX_NB_SESSIONS);
16823 			return TEST_FAILED;
16824 		}
16825 		/*
16826 		 * Create mempool with maximum number of sessions,
16827 		 * to include the session headers
16828 		 */
16829 		if (ts_params->session_mpool == NULL) {
16830 			ts_params->session_mpool =
16831 				rte_cryptodev_sym_session_pool_create(
16832 						"test_sess_mp",
16833 						MAX_NB_SESSIONS, session_size,
16834 						0, 0, SOCKET_ID_ANY);
16835 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
16836 					"session mempool allocation failed");
16837 		}
16838 
16839 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
16840 
16841 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
16842 				(uint8_t)i);
16843 
16844 		TEST_ASSERT(ret == 0,
16845 			"Failed to attach device %u of pmd : %s", i,
16846 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16847 
16848 		aesni_ids[nb_devs_attached] = (uint8_t)i;
16849 
16850 		nb_devs_attached++;
16851 	}
16852 
16853 	return 0;
16854 }
16855 
16856 static int
16857 test_scheduler_detach_worker_op(void)
16858 {
16859 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16860 	uint8_t sched_id = ts_params->valid_devs[0];
16861 	uint32_t i;
16862 	int ret;
16863 
16864 	for (i = 0; i < 2; i++) {
16865 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
16866 				aesni_ids[i]);
16867 		TEST_ASSERT(ret == 0,
16868 			"Failed to detach device %u", aesni_ids[i]);
16869 	}
16870 
16871 	return 0;
16872 }
16873 
16874 static int
16875 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
16876 {
16877 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16878 	uint8_t sched_id = ts_params->valid_devs[0];
16879 	/* set mode */
16880 	return rte_cryptodev_scheduler_mode_set(sched_id,
16881 		scheduler_mode);
16882 }
16883 
16884 static int
16885 test_scheduler_mode_roundrobin_op(void)
16886 {
16887 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
16888 			0, "Failed to set roundrobin mode");
16889 	return 0;
16890 
16891 }
16892 
16893 static int
16894 test_scheduler_mode_multicore_op(void)
16895 {
16896 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
16897 			0, "Failed to set multicore mode");
16898 
16899 	return 0;
16900 }
16901 
16902 static int
16903 test_scheduler_mode_failover_op(void)
16904 {
16905 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
16906 			0, "Failed to set failover mode");
16907 
16908 	return 0;
16909 }
16910 
16911 static int
16912 test_scheduler_mode_pkt_size_distr_op(void)
16913 {
16914 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
16915 			0, "Failed to set pktsize mode");
16916 
16917 	return 0;
16918 }
16919 
16920 static int
16921 scheduler_multicore_testsuite_setup(void)
16922 {
16923 	if (test_scheduler_attach_worker_op() < 0)
16924 		return TEST_SKIPPED;
16925 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
16926 		return TEST_SKIPPED;
16927 	return 0;
16928 }
16929 
16930 static int
16931 scheduler_roundrobin_testsuite_setup(void)
16932 {
16933 	if (test_scheduler_attach_worker_op() < 0)
16934 		return TEST_SKIPPED;
16935 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
16936 		return TEST_SKIPPED;
16937 	return 0;
16938 }
16939 
16940 static int
16941 scheduler_failover_testsuite_setup(void)
16942 {
16943 	if (test_scheduler_attach_worker_op() < 0)
16944 		return TEST_SKIPPED;
16945 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
16946 		return TEST_SKIPPED;
16947 	return 0;
16948 }
16949 
16950 static int
16951 scheduler_pkt_size_distr_testsuite_setup(void)
16952 {
16953 	if (test_scheduler_attach_worker_op() < 0)
16954 		return TEST_SKIPPED;
16955 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
16956 		return TEST_SKIPPED;
16957 	return 0;
16958 }
16959 
16960 static void
16961 scheduler_mode_testsuite_teardown(void)
16962 {
16963 	test_scheduler_detach_worker_op();
16964 }
16965 
16966 #endif /* RTE_CRYPTO_SCHEDULER */
16967 
16968 static struct unit_test_suite end_testsuite = {
16969 	.suite_name = NULL,
16970 	.setup = NULL,
16971 	.teardown = NULL,
16972 	.unit_test_suites = NULL
16973 };
16974 
16975 #ifdef RTE_LIB_SECURITY
16976 static struct unit_test_suite ipsec_proto_testsuite  = {
16977 	.suite_name = "IPsec Proto Unit Test Suite",
16978 	.setup = ipsec_proto_testsuite_setup,
16979 	.unit_test_cases = {
16980 		TEST_CASE_NAMED_WITH_DATA(
16981 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16982 			ut_setup_security, ut_teardown,
16983 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
16984 		TEST_CASE_NAMED_WITH_DATA(
16985 			"Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
16986 			ut_setup_security, ut_teardown,
16987 			test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
16988 		TEST_CASE_NAMED_WITH_DATA(
16989 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
16990 			ut_setup_security, ut_teardown,
16991 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
16992 		TEST_CASE_NAMED_WITH_DATA(
16993 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
16994 			ut_setup_security, ut_teardown,
16995 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
16996 		TEST_CASE_NAMED_WITH_DATA(
16997 			"Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
16998 			ut_setup_security, ut_teardown,
16999 			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17000 		TEST_CASE_NAMED_WITH_DATA(
17001 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17002 			ut_setup_security, ut_teardown,
17003 			test_ipsec_proto_known_vec,
17004 			&pkt_aes_128_cbc_md5),
17005 		TEST_CASE_NAMED_WITH_DATA(
17006 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17007 			ut_setup_security, ut_teardown,
17008 			test_ipsec_proto_known_vec,
17009 			&pkt_aes_128_cbc_hmac_sha256),
17010 		TEST_CASE_NAMED_WITH_DATA(
17011 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17012 			ut_setup_security, ut_teardown,
17013 			test_ipsec_proto_known_vec,
17014 			&pkt_aes_128_cbc_hmac_sha384),
17015 		TEST_CASE_NAMED_WITH_DATA(
17016 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17017 			ut_setup_security, ut_teardown,
17018 			test_ipsec_proto_known_vec,
17019 			&pkt_aes_128_cbc_hmac_sha512),
17020 		TEST_CASE_NAMED_WITH_DATA(
17021 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17022 			ut_setup_security, ut_teardown,
17023 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
17024 		TEST_CASE_NAMED_WITH_DATA(
17025 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17026 			ut_setup_security, ut_teardown,
17027 			test_ipsec_proto_known_vec,
17028 			&pkt_aes_128_cbc_hmac_sha256_v6),
17029 		TEST_CASE_NAMED_WITH_DATA(
17030 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17031 			ut_setup_security, ut_teardown,
17032 			test_ipsec_proto_known_vec,
17033 			&pkt_null_aes_xcbc),
17034 		TEST_CASE_NAMED_WITH_DATA(
17035 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17036 			ut_setup_security, ut_teardown,
17037 			test_ipsec_proto_known_vec,
17038 			&pkt_des_cbc_hmac_sha256),
17039 		TEST_CASE_NAMED_WITH_DATA(
17040 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17041 			ut_setup_security, ut_teardown,
17042 			test_ipsec_proto_known_vec,
17043 			&pkt_des_cbc_hmac_sha384),
17044 		TEST_CASE_NAMED_WITH_DATA(
17045 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17046 			ut_setup_security, ut_teardown,
17047 			test_ipsec_proto_known_vec,
17048 			&pkt_des_cbc_hmac_sha512),
17049 		TEST_CASE_NAMED_WITH_DATA(
17050 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17051 			ut_setup_security, ut_teardown,
17052 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
17053 		TEST_CASE_NAMED_WITH_DATA(
17054 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17055 			ut_setup_security, ut_teardown,
17056 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
17057 		TEST_CASE_NAMED_WITH_DATA(
17058 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17059 			ut_setup_security, ut_teardown,
17060 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
17061 		TEST_CASE_NAMED_WITH_DATA(
17062 			"Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17063 			ut_setup_security, ut_teardown,
17064 			test_ipsec_proto_known_vec,
17065 			&pkt_des_cbc_hmac_sha256_v6),
17066 		TEST_CASE_NAMED_WITH_DATA(
17067 			"Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17068 			ut_setup_security, ut_teardown,
17069 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
17070 		TEST_CASE_NAMED_WITH_DATA(
17071 			"Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17072 			ut_setup_security, ut_teardown,
17073 			test_ipsec_proto_known_vec,
17074 			&pkt_ah_tunnel_sha256),
17075 		TEST_CASE_NAMED_WITH_DATA(
17076 			"Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17077 			ut_setup_security, ut_teardown,
17078 			test_ipsec_proto_known_vec,
17079 			&pkt_ah_transport_sha256),
17080 		TEST_CASE_NAMED_WITH_DATA(
17081 			"Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17082 			ut_setup_security, ut_teardown,
17083 			test_ipsec_proto_known_vec,
17084 			&pkt_ah_ipv4_aes_gmac_128),
17085 		TEST_CASE_NAMED_WITH_DATA(
17086 			"Outbound fragmented packet",
17087 			ut_setup_security, ut_teardown,
17088 			test_ipsec_proto_known_vec_fragmented,
17089 			&pkt_aes_128_gcm_frag),
17090 		TEST_CASE_NAMED_WITH_DATA(
17091 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17092 			ut_setup_security, ut_teardown,
17093 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
17094 		TEST_CASE_NAMED_WITH_DATA(
17095 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17096 			ut_setup_security, ut_teardown,
17097 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
17098 		TEST_CASE_NAMED_WITH_DATA(
17099 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17100 			ut_setup_security, ut_teardown,
17101 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
17102 		TEST_CASE_NAMED_WITH_DATA(
17103 			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17104 			ut_setup_security, ut_teardown,
17105 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
17106 		TEST_CASE_NAMED_WITH_DATA(
17107 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
17108 			ut_setup_security, ut_teardown,
17109 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
17110 		TEST_CASE_NAMED_WITH_DATA(
17111 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17112 			ut_setup_security, ut_teardown,
17113 			test_ipsec_proto_known_vec_inb,
17114 			&pkt_aes_128_cbc_md5),
17115 		TEST_CASE_NAMED_WITH_DATA(
17116 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17117 			ut_setup_security, ut_teardown,
17118 			test_ipsec_proto_known_vec_inb,
17119 			&pkt_aes_128_cbc_hmac_sha256),
17120 		TEST_CASE_NAMED_WITH_DATA(
17121 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17122 			ut_setup_security, ut_teardown,
17123 			test_ipsec_proto_known_vec_inb,
17124 			&pkt_aes_128_cbc_hmac_sha384),
17125 		TEST_CASE_NAMED_WITH_DATA(
17126 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17127 			ut_setup_security, ut_teardown,
17128 			test_ipsec_proto_known_vec_inb,
17129 			&pkt_aes_128_cbc_hmac_sha512),
17130 		TEST_CASE_NAMED_WITH_DATA(
17131 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17132 			ut_setup_security, ut_teardown,
17133 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
17134 		TEST_CASE_NAMED_WITH_DATA(
17135 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17136 			ut_setup_security, ut_teardown,
17137 			test_ipsec_proto_known_vec_inb,
17138 			&pkt_aes_128_cbc_hmac_sha256_v6),
17139 		TEST_CASE_NAMED_WITH_DATA(
17140 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17141 			ut_setup_security, ut_teardown,
17142 			test_ipsec_proto_known_vec_inb,
17143 			&pkt_null_aes_xcbc),
17144 		TEST_CASE_NAMED_WITH_DATA(
17145 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17146 			ut_setup_security, ut_teardown,
17147 			test_ipsec_proto_known_vec_inb,
17148 			&pkt_des_cbc_hmac_sha256),
17149 		TEST_CASE_NAMED_WITH_DATA(
17150 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17151 			ut_setup_security, ut_teardown,
17152 			test_ipsec_proto_known_vec_inb,
17153 			&pkt_des_cbc_hmac_sha384),
17154 		TEST_CASE_NAMED_WITH_DATA(
17155 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17156 			ut_setup_security, ut_teardown,
17157 			test_ipsec_proto_known_vec_inb,
17158 			&pkt_des_cbc_hmac_sha512),
17159 		TEST_CASE_NAMED_WITH_DATA(
17160 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17161 			ut_setup_security, ut_teardown,
17162 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
17163 		TEST_CASE_NAMED_WITH_DATA(
17164 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17165 			ut_setup_security, ut_teardown,
17166 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
17167 		TEST_CASE_NAMED_WITH_DATA(
17168 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17169 			ut_setup_security, ut_teardown,
17170 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
17171 		TEST_CASE_NAMED_WITH_DATA(
17172 			"Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17173 			ut_setup_security, ut_teardown,
17174 			test_ipsec_proto_known_vec_inb,
17175 			&pkt_des_cbc_hmac_sha256_v6),
17176 		TEST_CASE_NAMED_WITH_DATA(
17177 			"Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17178 			ut_setup_security, ut_teardown,
17179 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
17180 		TEST_CASE_NAMED_WITH_DATA(
17181 			"Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17182 			ut_setup_security, ut_teardown,
17183 			test_ipsec_proto_known_vec_inb,
17184 			&pkt_ah_tunnel_sha256),
17185 		TEST_CASE_NAMED_WITH_DATA(
17186 			"Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17187 			ut_setup_security, ut_teardown,
17188 			test_ipsec_proto_known_vec_inb,
17189 			&pkt_ah_transport_sha256),
17190 		TEST_CASE_NAMED_WITH_DATA(
17191 			"Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17192 			ut_setup_security, ut_teardown,
17193 			test_ipsec_proto_known_vec_inb,
17194 			&pkt_ah_ipv4_aes_gmac_128),
17195 		TEST_CASE_NAMED_ST(
17196 			"Combined test alg list",
17197 			ut_setup_security, ut_teardown,
17198 			test_ipsec_proto_display_list),
17199 		TEST_CASE_NAMED_ST(
17200 			"Combined test alg list (AH)",
17201 			ut_setup_security, ut_teardown,
17202 			test_ipsec_proto_ah_tunnel_ipv4),
17203 		TEST_CASE_NAMED_ST(
17204 			"IV generation",
17205 			ut_setup_security, ut_teardown,
17206 			test_ipsec_proto_iv_gen),
17207 		TEST_CASE_NAMED_ST(
17208 			"UDP encapsulation",
17209 			ut_setup_security, ut_teardown,
17210 			test_ipsec_proto_udp_encap),
17211 		TEST_CASE_NAMED_ST(
17212 			"UDP encapsulation with custom ports",
17213 			ut_setup_security, ut_teardown,
17214 			test_ipsec_proto_udp_encap_custom_ports),
17215 		TEST_CASE_NAMED_ST(
17216 			"UDP encapsulation ports verification test",
17217 			ut_setup_security, ut_teardown,
17218 			test_ipsec_proto_udp_ports_verify),
17219 		TEST_CASE_NAMED_ST(
17220 			"SA expiry packets soft",
17221 			ut_setup_security, ut_teardown,
17222 			test_ipsec_proto_sa_exp_pkts_soft),
17223 		TEST_CASE_NAMED_ST(
17224 			"SA expiry packets hard",
17225 			ut_setup_security, ut_teardown,
17226 			test_ipsec_proto_sa_exp_pkts_hard),
17227 		TEST_CASE_NAMED_ST(
17228 			"Negative test: ICV corruption",
17229 			ut_setup_security, ut_teardown,
17230 			test_ipsec_proto_err_icv_corrupt),
17231 		TEST_CASE_NAMED_ST(
17232 			"Tunnel dst addr verification",
17233 			ut_setup_security, ut_teardown,
17234 			test_ipsec_proto_tunnel_dst_addr_verify),
17235 		TEST_CASE_NAMED_ST(
17236 			"Tunnel src and dst addr verification",
17237 			ut_setup_security, ut_teardown,
17238 			test_ipsec_proto_tunnel_src_dst_addr_verify),
17239 		TEST_CASE_NAMED_ST(
17240 			"Inner IP checksum",
17241 			ut_setup_security, ut_teardown,
17242 			test_ipsec_proto_inner_ip_csum),
17243 		TEST_CASE_NAMED_ST(
17244 			"Inner L4 checksum",
17245 			ut_setup_security, ut_teardown,
17246 			test_ipsec_proto_inner_l4_csum),
17247 		TEST_CASE_NAMED_ST(
17248 			"Tunnel IPv4 in IPv4",
17249 			ut_setup_security, ut_teardown,
17250 			test_ipsec_proto_tunnel_v4_in_v4),
17251 		TEST_CASE_NAMED_ST(
17252 			"Tunnel IPv6 in IPv6",
17253 			ut_setup_security, ut_teardown,
17254 			test_ipsec_proto_tunnel_v6_in_v6),
17255 		TEST_CASE_NAMED_ST(
17256 			"Tunnel IPv4 in IPv6",
17257 			ut_setup_security, ut_teardown,
17258 			test_ipsec_proto_tunnel_v4_in_v6),
17259 		TEST_CASE_NAMED_ST(
17260 			"Tunnel IPv6 in IPv4",
17261 			ut_setup_security, ut_teardown,
17262 			test_ipsec_proto_tunnel_v6_in_v4),
17263 		TEST_CASE_NAMED_ST(
17264 			"Transport IPv4",
17265 			ut_setup_security, ut_teardown,
17266 			test_ipsec_proto_transport_v4),
17267 		TEST_CASE_NAMED_ST(
17268 			"AH transport IPv4",
17269 			ut_setup_security, ut_teardown,
17270 			test_ipsec_proto_ah_transport_ipv4),
17271 		TEST_CASE_NAMED_ST(
17272 			"Transport l4 checksum",
17273 			ut_setup_security, ut_teardown,
17274 			test_ipsec_proto_transport_l4_csum),
17275 		TEST_CASE_NAMED_ST(
17276 			"Statistics: success",
17277 			ut_setup_security, ut_teardown,
17278 			test_ipsec_proto_stats),
17279 		TEST_CASE_NAMED_ST(
17280 			"Fragmented packet",
17281 			ut_setup_security, ut_teardown,
17282 			test_ipsec_proto_pkt_fragment),
17283 		TEST_CASE_NAMED_ST(
17284 			"Tunnel header copy DF (inner 0)",
17285 			ut_setup_security, ut_teardown,
17286 			test_ipsec_proto_copy_df_inner_0),
17287 		TEST_CASE_NAMED_ST(
17288 			"Tunnel header copy DF (inner 1)",
17289 			ut_setup_security, ut_teardown,
17290 			test_ipsec_proto_copy_df_inner_1),
17291 		TEST_CASE_NAMED_ST(
17292 			"Tunnel header set DF 0 (inner 1)",
17293 			ut_setup_security, ut_teardown,
17294 			test_ipsec_proto_set_df_0_inner_1),
17295 		TEST_CASE_NAMED_ST(
17296 			"Tunnel header set DF 1 (inner 0)",
17297 			ut_setup_security, ut_teardown,
17298 			test_ipsec_proto_set_df_1_inner_0),
17299 		TEST_CASE_NAMED_ST(
17300 			"Tunnel header IPv4 copy DSCP (inner 0)",
17301 			ut_setup_security, ut_teardown,
17302 			test_ipsec_proto_ipv4_copy_dscp_inner_0),
17303 		TEST_CASE_NAMED_ST(
17304 			"Tunnel header IPv4 copy DSCP (inner 1)",
17305 			ut_setup_security, ut_teardown,
17306 			test_ipsec_proto_ipv4_copy_dscp_inner_1),
17307 		TEST_CASE_NAMED_ST(
17308 			"Tunnel header IPv4 set DSCP 0 (inner 1)",
17309 			ut_setup_security, ut_teardown,
17310 			test_ipsec_proto_ipv4_set_dscp_0_inner_1),
17311 		TEST_CASE_NAMED_ST(
17312 			"Tunnel header IPv4 set DSCP 1 (inner 0)",
17313 			ut_setup_security, ut_teardown,
17314 			test_ipsec_proto_ipv4_set_dscp_1_inner_0),
17315 		TEST_CASE_NAMED_ST(
17316 			"Tunnel header IPv6 copy DSCP (inner 0)",
17317 			ut_setup_security, ut_teardown,
17318 			test_ipsec_proto_ipv6_copy_dscp_inner_0),
17319 		TEST_CASE_NAMED_ST(
17320 			"Tunnel header IPv6 copy DSCP (inner 1)",
17321 			ut_setup_security, ut_teardown,
17322 			test_ipsec_proto_ipv6_copy_dscp_inner_1),
17323 		TEST_CASE_NAMED_ST(
17324 			"Tunnel header IPv6 set DSCP 0 (inner 1)",
17325 			ut_setup_security, ut_teardown,
17326 			test_ipsec_proto_ipv6_set_dscp_0_inner_1),
17327 		TEST_CASE_NAMED_ST(
17328 			"Tunnel header IPv6 set DSCP 1 (inner 0)",
17329 			ut_setup_security, ut_teardown,
17330 			test_ipsec_proto_ipv6_set_dscp_1_inner_0),
17331 		TEST_CASE_NAMED_WITH_DATA(
17332 			"Antireplay with window size 1024",
17333 			ut_setup_security, ut_teardown,
17334 			test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
17335 		TEST_CASE_NAMED_WITH_DATA(
17336 			"Antireplay with window size 2048",
17337 			ut_setup_security, ut_teardown,
17338 			test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
17339 		TEST_CASE_NAMED_WITH_DATA(
17340 			"Antireplay with window size 4096",
17341 			ut_setup_security, ut_teardown,
17342 			test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
17343 		TEST_CASE_NAMED_WITH_DATA(
17344 			"ESN and Antireplay with window size 1024",
17345 			ut_setup_security, ut_teardown,
17346 			test_ipsec_proto_pkt_esn_antireplay1024,
17347 			&pkt_aes_128_gcm),
17348 		TEST_CASE_NAMED_WITH_DATA(
17349 			"ESN and Antireplay with window size 2048",
17350 			ut_setup_security, ut_teardown,
17351 			test_ipsec_proto_pkt_esn_antireplay2048,
17352 			&pkt_aes_128_gcm),
17353 		TEST_CASE_NAMED_WITH_DATA(
17354 			"ESN and Antireplay with window size 4096",
17355 			ut_setup_security, ut_teardown,
17356 			test_ipsec_proto_pkt_esn_antireplay4096,
17357 			&pkt_aes_128_gcm),
17358 		TEST_CASE_NAMED_ST(
17359 			"Tunnel header IPv4 decrement inner TTL",
17360 			ut_setup_security, ut_teardown,
17361 			test_ipsec_proto_ipv4_ttl_decrement),
17362 		TEST_CASE_NAMED_ST(
17363 			"Tunnel header IPv6 decrement inner hop limit",
17364 			ut_setup_security, ut_teardown,
17365 			test_ipsec_proto_ipv6_hop_limit_decrement),
17366 		TEST_CASE_NAMED_ST(
17367 			"Multi-segmented mode",
17368 			ut_setup_security, ut_teardown,
17369 			test_ipsec_proto_sgl),
17370 		TEST_CASE_NAMED_ST(
17371 			"Multi-segmented external mbuf mode",
17372 			ut_setup_security, ut_teardown,
17373 			test_ipsec_proto_sgl_ext_mbuf),
17374 		TEST_CASE_NAMED_WITH_DATA(
17375 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
17376 			ut_setup_security_rx_inject, ut_teardown_rx_inject,
17377 			test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
17378 		TEST_CASES_END() /**< NULL terminate unit test array */
17379 	}
17380 };
17381 
17382 static struct unit_test_suite pdcp_proto_testsuite  = {
17383 	.suite_name = "PDCP Proto Unit Test Suite",
17384 	.setup = pdcp_proto_testsuite_setup,
17385 	.unit_test_cases = {
17386 		TEST_CASE_ST(ut_setup_security, ut_teardown,
17387 			test_PDCP_PROTO_all),
17388 		TEST_CASES_END() /**< NULL terminate unit test array */
17389 	}
17390 };
17391 
17392 static struct unit_test_suite tls12_record_proto_testsuite  = {
17393 	.suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
17394 	.setup = tls_record_proto_testsuite_setup,
17395 	.unit_test_cases = {
17396 		TEST_CASE_NAMED_WITH_DATA(
17397 			"Write record known vector AES-GCM-128 (vector 1)",
17398 			ut_setup_security, ut_teardown,
17399 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
17400 		TEST_CASE_NAMED_WITH_DATA(
17401 			"Write record known vector AES-GCM-128 (vector 2)",
17402 			ut_setup_security, ut_teardown,
17403 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
17404 		TEST_CASE_NAMED_WITH_DATA(
17405 			"Write record known vector AES-GCM-256",
17406 			ut_setup_security, ut_teardown,
17407 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
17408 		TEST_CASE_NAMED_WITH_DATA(
17409 			"Write record known vector AES-CBC-128-SHA1",
17410 			ut_setup_security, ut_teardown,
17411 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
17412 		TEST_CASE_NAMED_WITH_DATA(
17413 			"Write record known vector AES-128-CBC-SHA256",
17414 			ut_setup_security, ut_teardown,
17415 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
17416 		TEST_CASE_NAMED_WITH_DATA(
17417 			"Write record known vector AES-256-CBC-SHA1",
17418 			ut_setup_security, ut_teardown,
17419 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
17420 		TEST_CASE_NAMED_WITH_DATA(
17421 			"Write record known vector AES-256-CBC-SHA256",
17422 			ut_setup_security, ut_teardown,
17423 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
17424 		TEST_CASE_NAMED_WITH_DATA(
17425 			"Write record known vector AES-256-CBC-SHA384",
17426 			ut_setup_security, ut_teardown,
17427 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
17428 		TEST_CASE_NAMED_WITH_DATA(
17429 			"Write record known vector 3DES-CBC-SHA1-HMAC",
17430 			ut_setup_security, ut_teardown,
17431 			test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
17432 		TEST_CASE_NAMED_WITH_DATA(
17433 			"Write record known vector NULL-SHA1-HMAC",
17434 			ut_setup_security, ut_teardown,
17435 			test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
17436 		TEST_CASE_NAMED_WITH_DATA(
17437 			"Write record known vector CHACHA20-POLY1305",
17438 			ut_setup_security, ut_teardown,
17439 			test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
17440 
17441 		TEST_CASE_NAMED_WITH_DATA(
17442 			"Read record known vector AES-GCM-128 (vector 1)",
17443 			ut_setup_security, ut_teardown,
17444 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
17445 		TEST_CASE_NAMED_WITH_DATA(
17446 			"Read record known vector AES-GCM-128 (vector 2)",
17447 			ut_setup_security, ut_teardown,
17448 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
17449 		TEST_CASE_NAMED_WITH_DATA(
17450 			"Read record known vector AES-GCM-256",
17451 			ut_setup_security, ut_teardown,
17452 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
17453 		TEST_CASE_NAMED_WITH_DATA(
17454 			"Read record known vector AES-128-CBC-SHA1",
17455 			ut_setup_security, ut_teardown,
17456 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
17457 		TEST_CASE_NAMED_WITH_DATA(
17458 			"Read record known vector AES-128-CBC-SHA256",
17459 			ut_setup_security, ut_teardown,
17460 			test_tls_record_proto_known_vec_read,
17461 			&tls_test_data_aes_128_cbc_sha256_hmac),
17462 		TEST_CASE_NAMED_WITH_DATA(
17463 			"Read record known vector AES-256-CBC-SHA1",
17464 			ut_setup_security, ut_teardown,
17465 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
17466 		TEST_CASE_NAMED_WITH_DATA(
17467 			"Read record known vector AES-256-CBC-SHA256",
17468 			ut_setup_security, ut_teardown,
17469 			test_tls_record_proto_known_vec_read,
17470 			&tls_test_data_aes_256_cbc_sha256_hmac),
17471 		TEST_CASE_NAMED_WITH_DATA(
17472 			"Read record known vector AES-256-CBC-SHA384",
17473 			ut_setup_security, ut_teardown,
17474 			test_tls_record_proto_known_vec_read,
17475 			&tls_test_data_aes_256_cbc_sha384_hmac),
17476 		TEST_CASE_NAMED_WITH_DATA(
17477 			"Read record known vector 3DES-CBC-SHA1-HMAC",
17478 			ut_setup_security, ut_teardown,
17479 			test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
17480 		TEST_CASE_NAMED_WITH_DATA(
17481 			"Read record known vector NULL-SHA1-HMAC",
17482 			ut_setup_security, ut_teardown,
17483 			test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
17484 		TEST_CASE_NAMED_WITH_DATA(
17485 			"Read record known vector CHACHA20-POLY1305",
17486 			ut_setup_security, ut_teardown,
17487 			test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
17488 
17489 		TEST_CASE_NAMED_ST(
17490 			"Combined test alg list",
17491 			ut_setup_security, ut_teardown,
17492 			test_tls_1_2_record_proto_display_list),
17493 		TEST_CASE_NAMED_ST(
17494 			"Data walkthrough combined test alg list",
17495 			ut_setup_security, ut_teardown,
17496 			test_tls_1_2_record_proto_data_walkthrough),
17497 		TEST_CASE_NAMED_ST(
17498 			"Multi-segmented mode",
17499 			ut_setup_security, ut_teardown,
17500 			test_tls_1_2_record_proto_sgl),
17501 		TEST_CASE_NAMED_ST(
17502 			"Multi-segmented mode data walkthrough",
17503 			ut_setup_security, ut_teardown,
17504 			test_tls_1_2_record_proto_sgl_data_walkthrough),
17505 		TEST_CASE_NAMED_ST(
17506 			"TLS packet header corruption",
17507 			ut_setup_security, ut_teardown,
17508 			test_tls_record_proto_corrupt_pkt),
17509 		TEST_CASE_NAMED_ST(
17510 			"Custom content type",
17511 			ut_setup_security, ut_teardown,
17512 			test_tls_record_proto_custom_content_type),
17513 		TEST_CASE_NAMED_ST(
17514 			"Zero len TLS record with content type as app",
17515 			ut_setup_security, ut_teardown,
17516 			test_tls_record_proto_zero_len),
17517 		TEST_CASE_NAMED_ST(
17518 			"Zero len TLS record with content type as ctrl",
17519 			ut_setup_security, ut_teardown,
17520 			test_tls_record_proto_zero_len_non_app),
17521 		TEST_CASES_END() /**< NULL terminate unit test array */
17522 	}
17523 };
17524 
17525 static struct unit_test_suite dtls12_record_proto_testsuite  = {
17526 	.suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
17527 	.setup = tls_record_proto_testsuite_setup,
17528 	.unit_test_cases = {
17529 		TEST_CASE_NAMED_WITH_DATA(
17530 			"Write record known vector AES-GCM-128",
17531 			ut_setup_security, ut_teardown,
17532 			test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
17533 		TEST_CASE_NAMED_WITH_DATA(
17534 			"Write record known vector AES-GCM-256",
17535 			ut_setup_security, ut_teardown,
17536 			test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
17537 		TEST_CASE_NAMED_WITH_DATA(
17538 			"Write record known vector AES-128-CBC-SHA1",
17539 			ut_setup_security, ut_teardown,
17540 			test_tls_record_proto_known_vec,
17541 			&dtls_test_data_aes_128_cbc_sha1_hmac),
17542 		TEST_CASE_NAMED_WITH_DATA(
17543 			"Write record known vector AES-128-CBC-SHA256",
17544 			ut_setup_security, ut_teardown,
17545 			test_tls_record_proto_known_vec,
17546 			&dtls_test_data_aes_128_cbc_sha256_hmac),
17547 		TEST_CASE_NAMED_WITH_DATA(
17548 			"Write record known vector AES-256-CBC-SHA1",
17549 			ut_setup_security, ut_teardown,
17550 			test_tls_record_proto_known_vec,
17551 			&dtls_test_data_aes_256_cbc_sha1_hmac),
17552 		TEST_CASE_NAMED_WITH_DATA(
17553 			"Write record known vector AES-256-CBC-SHA256",
17554 			ut_setup_security, ut_teardown,
17555 			test_tls_record_proto_known_vec,
17556 			&dtls_test_data_aes_256_cbc_sha256_hmac),
17557 		TEST_CASE_NAMED_WITH_DATA(
17558 			"Write record known vector AES-256-CBC-SHA384",
17559 			ut_setup_security, ut_teardown,
17560 			test_tls_record_proto_known_vec,
17561 			&dtls_test_data_aes_256_cbc_sha384_hmac),
17562 		TEST_CASE_NAMED_WITH_DATA(
17563 			"Write record known vector 3DES-CBC-SHA1-HMAC",
17564 			ut_setup_security, ut_teardown,
17565 			test_tls_record_proto_known_vec,
17566 			&dtls_test_data_3des_cbc_sha1_hmac),
17567 		TEST_CASE_NAMED_WITH_DATA(
17568 			"Write record known vector NULL-SHA1-HMAC",
17569 			ut_setup_security, ut_teardown,
17570 			test_tls_record_proto_known_vec,
17571 			&dtls_test_data_null_cipher_sha1_hmac),
17572 		TEST_CASE_NAMED_WITH_DATA(
17573 			"Write record known vector CHACHA20-POLY1305",
17574 			ut_setup_security, ut_teardown,
17575 			test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
17576 		TEST_CASE_NAMED_WITH_DATA(
17577 			"Read record known vector AES-GCM-128",
17578 			ut_setup_security, ut_teardown,
17579 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
17580 		TEST_CASE_NAMED_WITH_DATA(
17581 			"Read record known vector AES-GCM-256",
17582 			ut_setup_security, ut_teardown,
17583 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
17584 		TEST_CASE_NAMED_WITH_DATA(
17585 			"Read record known vector AES-128-CBC-SHA1",
17586 			ut_setup_security, ut_teardown,
17587 			test_tls_record_proto_known_vec_read,
17588 			&dtls_test_data_aes_128_cbc_sha1_hmac),
17589 		TEST_CASE_NAMED_WITH_DATA(
17590 			"Read record known vector AES-128-CBC-SHA256",
17591 			ut_setup_security, ut_teardown,
17592 			test_tls_record_proto_known_vec_read,
17593 			&dtls_test_data_aes_128_cbc_sha256_hmac),
17594 		TEST_CASE_NAMED_WITH_DATA(
17595 			"Read record known vector AES-256-CBC-SHA1",
17596 			ut_setup_security, ut_teardown,
17597 			test_tls_record_proto_known_vec_read,
17598 			&dtls_test_data_aes_256_cbc_sha1_hmac),
17599 		TEST_CASE_NAMED_WITH_DATA(
17600 			"Read record known vector AES-256-CBC-SHA256",
17601 			ut_setup_security, ut_teardown,
17602 			test_tls_record_proto_known_vec_read,
17603 			&dtls_test_data_aes_256_cbc_sha256_hmac),
17604 		TEST_CASE_NAMED_WITH_DATA(
17605 			"Read record known vector AES-256-CBC-SHA384",
17606 			ut_setup_security, ut_teardown,
17607 			test_tls_record_proto_known_vec_read,
17608 			&dtls_test_data_aes_256_cbc_sha384_hmac),
17609 		TEST_CASE_NAMED_WITH_DATA(
17610 			"Read record known vector 3DES-CBC-SHA1-HMAC",
17611 			ut_setup_security, ut_teardown,
17612 			test_tls_record_proto_known_vec_read,
17613 			&dtls_test_data_3des_cbc_sha1_hmac),
17614 		TEST_CASE_NAMED_WITH_DATA(
17615 			"Read record known vector NULL-SHA1-HMAC",
17616 			ut_setup_security, ut_teardown,
17617 			test_tls_record_proto_known_vec_read,
17618 			&dtls_test_data_null_cipher_sha1_hmac),
17619 		TEST_CASE_NAMED_WITH_DATA(
17620 			"Read record known vector CHACHA20-POLY1305",
17621 			ut_setup_security, ut_teardown,
17622 			test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
17623 
17624 		TEST_CASE_NAMED_ST(
17625 			"Combined test alg list",
17626 			ut_setup_security, ut_teardown,
17627 			test_dtls_1_2_record_proto_display_list),
17628 		TEST_CASE_NAMED_ST(
17629 			"Data walkthrough combined test alg list",
17630 			ut_setup_security, ut_teardown,
17631 			test_dtls_1_2_record_proto_data_walkthrough),
17632 		TEST_CASE_NAMED_ST(
17633 			"Multi-segmented mode",
17634 			ut_setup_security, ut_teardown,
17635 			test_dtls_1_2_record_proto_sgl),
17636 		TEST_CASE_NAMED_ST(
17637 			"Multi-segmented mode data walkthrough",
17638 			ut_setup_security, ut_teardown,
17639 			test_dtls_1_2_record_proto_sgl_data_walkthrough),
17640 		TEST_CASE_NAMED_ST(
17641 			"Packet corruption",
17642 			ut_setup_security, ut_teardown,
17643 			test_dtls_1_2_record_proto_corrupt_pkt),
17644 		TEST_CASE_NAMED_ST(
17645 			"Custom content type",
17646 			ut_setup_security, ut_teardown,
17647 			test_dtls_1_2_record_proto_custom_content_type),
17648 		TEST_CASE_NAMED_ST(
17649 			"Zero len DTLS record with content type as app",
17650 			ut_setup_security, ut_teardown,
17651 			test_dtls_1_2_record_proto_zero_len),
17652 		TEST_CASE_NAMED_ST(
17653 			"Zero len DTLS record with content type as ctrl",
17654 			ut_setup_security, ut_teardown,
17655 			test_dtls_1_2_record_proto_zero_len_non_app),
17656 		TEST_CASE_NAMED_ST(
17657 			"Antireplay with window size 64",
17658 			ut_setup_security, ut_teardown,
17659 			test_dtls_1_2_record_proto_antireplay64),
17660 		TEST_CASE_NAMED_ST(
17661 			"Antireplay with window size 128",
17662 			ut_setup_security, ut_teardown,
17663 			test_dtls_1_2_record_proto_antireplay128),
17664 		TEST_CASE_NAMED_ST(
17665 			"Antireplay with window size 256",
17666 			ut_setup_security, ut_teardown,
17667 			test_dtls_1_2_record_proto_antireplay256),
17668 		TEST_CASE_NAMED_ST(
17669 			"Antireplay with window size 512",
17670 			ut_setup_security, ut_teardown,
17671 			test_dtls_1_2_record_proto_antireplay512),
17672 		TEST_CASE_NAMED_ST(
17673 			"Antireplay with window size 1024",
17674 			ut_setup_security, ut_teardown,
17675 			test_dtls_1_2_record_proto_antireplay1024),
17676 		TEST_CASE_NAMED_ST(
17677 			"Antireplay with window size 2048",
17678 			ut_setup_security, ut_teardown,
17679 			test_dtls_1_2_record_proto_antireplay2048),
17680 		TEST_CASE_NAMED_ST(
17681 			"Antireplay with window size 4096",
17682 			ut_setup_security, ut_teardown,
17683 			test_dtls_1_2_record_proto_antireplay4096),
17684 		TEST_CASES_END() /**< NULL terminate unit test array */
17685 	}
17686 };
17687 
17688 static struct unit_test_suite tls13_record_proto_testsuite  = {
17689 	.suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
17690 	.setup = tls_record_proto_testsuite_setup,
17691 	.unit_test_cases = {
17692 		TEST_CASE_NAMED_WITH_DATA(
17693 			"Write record known vector AES-GCM-128",
17694 			ut_setup_security, ut_teardown,
17695 			test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
17696 		TEST_CASE_NAMED_WITH_DATA(
17697 			"Write record known vector AES-GCM-256",
17698 			ut_setup_security, ut_teardown,
17699 			test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
17700 		TEST_CASE_NAMED_WITH_DATA(
17701 			"Write record known vector CHACHA20-POLY1305",
17702 			ut_setup_security, ut_teardown,
17703 			test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
17704 
17705 		TEST_CASE_NAMED_WITH_DATA(
17706 			"Read record known vector AES-GCM-128",
17707 			ut_setup_security, ut_teardown,
17708 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
17709 		TEST_CASE_NAMED_WITH_DATA(
17710 			"Read record known vector AES-GCM-256",
17711 			ut_setup_security, ut_teardown,
17712 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
17713 		TEST_CASE_NAMED_WITH_DATA(
17714 			"Read record known vector CHACHA20-POLY1305",
17715 			ut_setup_security, ut_teardown,
17716 			test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
17717 
17718 		TEST_CASES_END() /**< NULL terminate unit test array */
17719 	}
17720 };
17721 
17722 #define ADD_UPLINK_TESTCASE(data)						\
17723 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
17724 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
17725 
17726 #define ADD_DOWNLINK_TESTCASE(data)						\
17727 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
17728 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
17729 
17730 static struct unit_test_suite docsis_proto_testsuite  = {
17731 	.suite_name = "DOCSIS Proto Unit Test Suite",
17732 	.setup = docsis_proto_testsuite_setup,
17733 	.unit_test_cases = {
17734 		/* Uplink */
17735 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
17736 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
17737 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
17738 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
17739 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
17740 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
17741 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
17742 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
17743 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
17744 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
17745 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
17746 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
17747 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
17748 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
17749 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
17750 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
17751 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
17752 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
17753 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
17754 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
17755 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
17756 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
17757 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
17758 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
17759 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
17760 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
17761 		/* Downlink */
17762 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
17763 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
17764 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
17765 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
17766 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
17767 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
17768 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
17769 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
17770 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
17771 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
17772 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
17773 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
17774 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
17775 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
17776 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
17777 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
17778 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
17779 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
17780 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
17781 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
17782 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
17783 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
17784 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
17785 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
17786 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
17787 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
17788 		TEST_CASES_END() /**< NULL terminate unit test array */
17789 	}
17790 };
17791 #endif
17792 
17793 static struct unit_test_suite cryptodev_gen_testsuite  = {
17794 	.suite_name = "Crypto General Unit Test Suite",
17795 	.setup = crypto_gen_testsuite_setup,
17796 	.unit_test_cases = {
17797 		TEST_CASE_ST(ut_setup, ut_teardown,
17798 				test_device_reconfigure),
17799 		TEST_CASE_ST(ut_setup, ut_teardown,
17800 				test_device_configure_invalid_dev_id),
17801 		TEST_CASE_ST(ut_setup, ut_teardown,
17802 				test_queue_pair_descriptor_setup),
17803 		TEST_CASE_ST(ut_setup, ut_teardown,
17804 				test_device_configure_invalid_queue_pair_ids),
17805 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
17806 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
17807 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
17808 		TEST_CASES_END() /**< NULL terminate unit test array */
17809 	}
17810 };
17811 
17812 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
17813 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
17814 	.setup = negative_hmac_sha1_testsuite_setup,
17815 	.unit_test_cases = {
17816 		/** Negative tests */
17817 		TEST_CASE_ST(ut_setup, ut_teardown,
17818 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
17819 		TEST_CASE_ST(ut_setup, ut_teardown,
17820 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
17821 		TEST_CASE_ST(ut_setup, ut_teardown,
17822 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
17823 		TEST_CASE_ST(ut_setup, ut_teardown,
17824 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
17825 
17826 		TEST_CASES_END() /**< NULL terminate unit test array */
17827 	}
17828 };
17829 
17830 static struct unit_test_suite cryptodev_multi_session_testsuite = {
17831 	.suite_name = "Multi Session Unit Test Suite",
17832 	.setup = multi_session_testsuite_setup,
17833 	.unit_test_cases = {
17834 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
17835 		TEST_CASE_ST(ut_setup, ut_teardown,
17836 				test_multi_session_random_usage),
17837 
17838 		TEST_CASES_END() /**< NULL terminate unit test array */
17839 	}
17840 };
17841 
17842 static struct unit_test_suite cryptodev_null_testsuite  = {
17843 	.suite_name = "NULL Test Suite",
17844 	.setup = null_testsuite_setup,
17845 	.unit_test_cases = {
17846 		TEST_CASE_ST(ut_setup, ut_teardown,
17847 			test_null_invalid_operation),
17848 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
17849 		TEST_CASES_END()
17850 	}
17851 };
17852 
17853 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
17854 	.suite_name = "AES CCM Authenticated Test Suite",
17855 	.setup = aes_ccm_auth_testsuite_setup,
17856 	.unit_test_cases = {
17857 		/** AES CCM Authenticated Encryption 128 bits key*/
17858 		TEST_CASE_ST(ut_setup, ut_teardown,
17859 			test_AES_CCM_authenticated_encryption_test_case_128_1),
17860 		TEST_CASE_ST(ut_setup, ut_teardown,
17861 			test_AES_CCM_authenticated_encryption_test_case_128_2),
17862 		TEST_CASE_ST(ut_setup, ut_teardown,
17863 			test_AES_CCM_authenticated_encryption_test_case_128_3),
17864 
17865 		/** AES CCM Authenticated Decryption 128 bits key*/
17866 		TEST_CASE_ST(ut_setup, ut_teardown,
17867 			test_AES_CCM_authenticated_decryption_test_case_128_1),
17868 		TEST_CASE_ST(ut_setup, ut_teardown,
17869 			test_AES_CCM_authenticated_decryption_test_case_128_2),
17870 		TEST_CASE_ST(ut_setup, ut_teardown,
17871 			test_AES_CCM_authenticated_decryption_test_case_128_3),
17872 
17873 		/** AES CCM Authenticated Encryption 192 bits key */
17874 		TEST_CASE_ST(ut_setup, ut_teardown,
17875 			test_AES_CCM_authenticated_encryption_test_case_192_1),
17876 		TEST_CASE_ST(ut_setup, ut_teardown,
17877 			test_AES_CCM_authenticated_encryption_test_case_192_2),
17878 		TEST_CASE_ST(ut_setup, ut_teardown,
17879 			test_AES_CCM_authenticated_encryption_test_case_192_3),
17880 
17881 		/** AES CCM Authenticated Decryption 192 bits key*/
17882 		TEST_CASE_ST(ut_setup, ut_teardown,
17883 			test_AES_CCM_authenticated_decryption_test_case_192_1),
17884 		TEST_CASE_ST(ut_setup, ut_teardown,
17885 			test_AES_CCM_authenticated_decryption_test_case_192_2),
17886 		TEST_CASE_ST(ut_setup, ut_teardown,
17887 			test_AES_CCM_authenticated_decryption_test_case_192_3),
17888 
17889 		/** AES CCM Authenticated Encryption 256 bits key */
17890 		TEST_CASE_ST(ut_setup, ut_teardown,
17891 			test_AES_CCM_authenticated_encryption_test_case_256_1),
17892 		TEST_CASE_ST(ut_setup, ut_teardown,
17893 			test_AES_CCM_authenticated_encryption_test_case_256_2),
17894 		TEST_CASE_ST(ut_setup, ut_teardown,
17895 			test_AES_CCM_authenticated_encryption_test_case_256_3),
17896 
17897 		/** AES CCM Authenticated Decryption 256 bits key*/
17898 		TEST_CASE_ST(ut_setup, ut_teardown,
17899 			test_AES_CCM_authenticated_decryption_test_case_256_1),
17900 		TEST_CASE_ST(ut_setup, ut_teardown,
17901 			test_AES_CCM_authenticated_decryption_test_case_256_2),
17902 		TEST_CASE_ST(ut_setup, ut_teardown,
17903 			test_AES_CCM_authenticated_decryption_test_case_256_3),
17904 		TEST_CASES_END()
17905 	}
17906 };
17907 
17908 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
17909 	.suite_name = "AES GCM Authenticated Test Suite",
17910 	.setup = aes_gcm_auth_testsuite_setup,
17911 	.unit_test_cases = {
17912 		/** AES GCM Authenticated Encryption */
17913 		TEST_CASE_ST(ut_setup, ut_teardown,
17914 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
17915 		TEST_CASE_ST(ut_setup, ut_teardown,
17916 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
17917 		TEST_CASE_ST(ut_setup, ut_teardown,
17918 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
17919 		TEST_CASE_ST(ut_setup, ut_teardown,
17920 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
17921 		TEST_CASE_ST(ut_setup, ut_teardown,
17922 			test_AES_GCM_authenticated_encryption_test_case_1),
17923 		TEST_CASE_ST(ut_setup, ut_teardown,
17924 			test_AES_GCM_authenticated_encryption_test_case_2),
17925 		TEST_CASE_ST(ut_setup, ut_teardown,
17926 			test_AES_GCM_authenticated_encryption_test_case_3),
17927 		TEST_CASE_ST(ut_setup, ut_teardown,
17928 			test_AES_GCM_authenticated_encryption_test_case_4),
17929 		TEST_CASE_ST(ut_setup, ut_teardown,
17930 			test_AES_GCM_authenticated_encryption_test_case_5),
17931 		TEST_CASE_ST(ut_setup, ut_teardown,
17932 			test_AES_GCM_authenticated_encryption_test_case_6),
17933 		TEST_CASE_ST(ut_setup, ut_teardown,
17934 			test_AES_GCM_authenticated_encryption_test_case_7),
17935 		TEST_CASE_ST(ut_setup, ut_teardown,
17936 			test_AES_GCM_authenticated_encryption_test_case_8),
17937 		TEST_CASE_ST(ut_setup, ut_teardown,
17938 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
17939 
17940 		/** AES GCM Authenticated Decryption */
17941 		TEST_CASE_ST(ut_setup, ut_teardown,
17942 			test_AES_GCM_authenticated_decryption_test_case_1),
17943 		TEST_CASE_ST(ut_setup, ut_teardown,
17944 			test_AES_GCM_authenticated_decryption_test_case_2),
17945 		TEST_CASE_ST(ut_setup, ut_teardown,
17946 			test_AES_GCM_authenticated_decryption_test_case_3),
17947 		TEST_CASE_ST(ut_setup, ut_teardown,
17948 			test_AES_GCM_authenticated_decryption_test_case_4),
17949 		TEST_CASE_ST(ut_setup, ut_teardown,
17950 			test_AES_GCM_authenticated_decryption_test_case_5),
17951 		TEST_CASE_ST(ut_setup, ut_teardown,
17952 			test_AES_GCM_authenticated_decryption_test_case_6),
17953 		TEST_CASE_ST(ut_setup, ut_teardown,
17954 			test_AES_GCM_authenticated_decryption_test_case_7),
17955 		TEST_CASE_ST(ut_setup, ut_teardown,
17956 			test_AES_GCM_authenticated_decryption_test_case_8),
17957 		TEST_CASE_ST(ut_setup, ut_teardown,
17958 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
17959 
17960 		/** AES GCM Authenticated Encryption 192 bits key */
17961 		TEST_CASE_ST(ut_setup, ut_teardown,
17962 			test_AES_GCM_auth_encryption_test_case_192_1),
17963 		TEST_CASE_ST(ut_setup, ut_teardown,
17964 			test_AES_GCM_auth_encryption_test_case_192_2),
17965 		TEST_CASE_ST(ut_setup, ut_teardown,
17966 			test_AES_GCM_auth_encryption_test_case_192_3),
17967 		TEST_CASE_ST(ut_setup, ut_teardown,
17968 			test_AES_GCM_auth_encryption_test_case_192_4),
17969 		TEST_CASE_ST(ut_setup, ut_teardown,
17970 			test_AES_GCM_auth_encryption_test_case_192_5),
17971 		TEST_CASE_ST(ut_setup, ut_teardown,
17972 			test_AES_GCM_auth_encryption_test_case_192_6),
17973 		TEST_CASE_ST(ut_setup, ut_teardown,
17974 			test_AES_GCM_auth_encryption_test_case_192_7),
17975 
17976 		/** AES GCM Authenticated Decryption 192 bits key */
17977 		TEST_CASE_ST(ut_setup, ut_teardown,
17978 			test_AES_GCM_auth_decryption_test_case_192_1),
17979 		TEST_CASE_ST(ut_setup, ut_teardown,
17980 			test_AES_GCM_auth_decryption_test_case_192_2),
17981 		TEST_CASE_ST(ut_setup, ut_teardown,
17982 			test_AES_GCM_auth_decryption_test_case_192_3),
17983 		TEST_CASE_ST(ut_setup, ut_teardown,
17984 			test_AES_GCM_auth_decryption_test_case_192_4),
17985 		TEST_CASE_ST(ut_setup, ut_teardown,
17986 			test_AES_GCM_auth_decryption_test_case_192_5),
17987 		TEST_CASE_ST(ut_setup, ut_teardown,
17988 			test_AES_GCM_auth_decryption_test_case_192_6),
17989 		TEST_CASE_ST(ut_setup, ut_teardown,
17990 			test_AES_GCM_auth_decryption_test_case_192_7),
17991 
17992 		/** AES GCM Authenticated Encryption 256 bits key */
17993 		TEST_CASE_ST(ut_setup, ut_teardown,
17994 			test_AES_GCM_auth_encryption_test_case_256_1),
17995 		TEST_CASE_ST(ut_setup, ut_teardown,
17996 			test_AES_GCM_auth_encryption_test_case_256_2),
17997 		TEST_CASE_ST(ut_setup, ut_teardown,
17998 			test_AES_GCM_auth_encryption_test_case_256_3),
17999 		TEST_CASE_ST(ut_setup, ut_teardown,
18000 			test_AES_GCM_auth_encryption_test_case_256_4),
18001 		TEST_CASE_ST(ut_setup, ut_teardown,
18002 			test_AES_GCM_auth_encryption_test_case_256_5),
18003 		TEST_CASE_ST(ut_setup, ut_teardown,
18004 			test_AES_GCM_auth_encryption_test_case_256_6),
18005 		TEST_CASE_ST(ut_setup, ut_teardown,
18006 			test_AES_GCM_auth_encryption_test_case_256_7),
18007 		TEST_CASE_ST(ut_setup, ut_teardown,
18008 			test_AES_GCM_auth_encryption_test_case_256_8),
18009 
18010 		/** AES GCM Authenticated Decryption 256 bits key */
18011 		TEST_CASE_ST(ut_setup, ut_teardown,
18012 			test_AES_GCM_auth_decryption_test_case_256_1),
18013 		TEST_CASE_ST(ut_setup, ut_teardown,
18014 			test_AES_GCM_auth_decryption_test_case_256_2),
18015 		TEST_CASE_ST(ut_setup, ut_teardown,
18016 			test_AES_GCM_auth_decryption_test_case_256_3),
18017 		TEST_CASE_ST(ut_setup, ut_teardown,
18018 			test_AES_GCM_auth_decryption_test_case_256_4),
18019 		TEST_CASE_ST(ut_setup, ut_teardown,
18020 			test_AES_GCM_auth_decryption_test_case_256_5),
18021 		TEST_CASE_ST(ut_setup, ut_teardown,
18022 			test_AES_GCM_auth_decryption_test_case_256_6),
18023 		TEST_CASE_ST(ut_setup, ut_teardown,
18024 			test_AES_GCM_auth_decryption_test_case_256_7),
18025 		TEST_CASE_ST(ut_setup, ut_teardown,
18026 			test_AES_GCM_auth_decryption_test_case_256_8),
18027 
18028 		/** AES GCM Authenticated Encryption big aad size */
18029 		TEST_CASE_ST(ut_setup, ut_teardown,
18030 			test_AES_GCM_auth_encryption_test_case_aad_1),
18031 		TEST_CASE_ST(ut_setup, ut_teardown,
18032 			test_AES_GCM_auth_encryption_test_case_aad_2),
18033 
18034 		/** AES GCM Authenticated Decryption big aad size */
18035 		TEST_CASE_ST(ut_setup, ut_teardown,
18036 			test_AES_GCM_auth_decryption_test_case_aad_1),
18037 		TEST_CASE_ST(ut_setup, ut_teardown,
18038 			test_AES_GCM_auth_decryption_test_case_aad_2),
18039 
18040 		/** Out of place tests */
18041 		TEST_CASE_ST(ut_setup, ut_teardown,
18042 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
18043 		TEST_CASE_ST(ut_setup, ut_teardown,
18044 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
18045 
18046 		/** Session-less tests */
18047 		TEST_CASE_ST(ut_setup, ut_teardown,
18048 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
18049 		TEST_CASE_ST(ut_setup, ut_teardown,
18050 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
18051 
18052 		/** AES GCM external mbuf tests */
18053 		TEST_CASE_ST(ut_setup, ut_teardown,
18054 			test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
18055 		TEST_CASE_ST(ut_setup, ut_teardown,
18056 			test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
18057 
18058 		TEST_CASES_END()
18059 	}
18060 };
18061 
18062 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
18063 	.suite_name = "AES GMAC Authentication Test Suite",
18064 	.setup = aes_gmac_auth_testsuite_setup,
18065 	.unit_test_cases = {
18066 		TEST_CASE_ST(ut_setup, ut_teardown,
18067 			test_AES_GMAC_authentication_test_case_1),
18068 		TEST_CASE_ST(ut_setup, ut_teardown,
18069 			test_AES_GMAC_authentication_verify_test_case_1),
18070 		TEST_CASE_ST(ut_setup, ut_teardown,
18071 			test_AES_GMAC_authentication_test_case_2),
18072 		TEST_CASE_ST(ut_setup, ut_teardown,
18073 			test_AES_GMAC_authentication_verify_test_case_2),
18074 		TEST_CASE_ST(ut_setup, ut_teardown,
18075 			test_AES_GMAC_authentication_test_case_3),
18076 		TEST_CASE_ST(ut_setup, ut_teardown,
18077 			test_AES_GMAC_authentication_verify_test_case_3),
18078 		TEST_CASE_ST(ut_setup, ut_teardown,
18079 			test_AES_GMAC_authentication_test_case_4),
18080 		TEST_CASE_ST(ut_setup, ut_teardown,
18081 			test_AES_GMAC_authentication_verify_test_case_4),
18082 		TEST_CASE_ST(ut_setup, ut_teardown,
18083 			test_AES_GMAC_authentication_SGL_40B),
18084 		TEST_CASE_ST(ut_setup, ut_teardown,
18085 			test_AES_GMAC_authentication_SGL_80B),
18086 		TEST_CASE_ST(ut_setup, ut_teardown,
18087 			test_AES_GMAC_authentication_SGL_2048B),
18088 		TEST_CASE_ST(ut_setup, ut_teardown,
18089 			test_AES_GMAC_authentication_SGL_2047B),
18090 
18091 		TEST_CASES_END()
18092 	}
18093 };
18094 
18095 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
18096 	.suite_name = "Chacha20-Poly1305 Test Suite",
18097 	.setup = chacha20_poly1305_testsuite_setup,
18098 	.unit_test_cases = {
18099 		TEST_CASE_ST(ut_setup, ut_teardown,
18100 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
18101 		TEST_CASE_ST(ut_setup, ut_teardown,
18102 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
18103 		TEST_CASE_ST(ut_setup, ut_teardown,
18104 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
18105 		TEST_CASES_END()
18106 	}
18107 };
18108 
18109 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
18110 	.suite_name = "SNOW 3G Test Suite",
18111 	.setup = snow3g_testsuite_setup,
18112 	.unit_test_cases = {
18113 		/** SNOW 3G encrypt only (UEA2) */
18114 		TEST_CASE_ST(ut_setup, ut_teardown,
18115 			test_snow3g_encryption_test_case_1),
18116 		TEST_CASE_ST(ut_setup, ut_teardown,
18117 			test_snow3g_encryption_test_case_2),
18118 		TEST_CASE_ST(ut_setup, ut_teardown,
18119 			test_snow3g_encryption_test_case_3),
18120 		TEST_CASE_ST(ut_setup, ut_teardown,
18121 			test_snow3g_encryption_test_case_4),
18122 		TEST_CASE_ST(ut_setup, ut_teardown,
18123 			test_snow3g_encryption_test_case_5),
18124 
18125 		TEST_CASE_ST(ut_setup, ut_teardown,
18126 			test_snow3g_encryption_test_case_1_oop),
18127 		TEST_CASE_ST(ut_setup, ut_teardown,
18128 			test_snow3g_encryption_test_case_1_oop_sgl),
18129 		TEST_CASE_ST(ut_setup, ut_teardown,
18130 			test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
18131 		TEST_CASE_ST(ut_setup, ut_teardown,
18132 			test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
18133 		TEST_CASE_ST(ut_setup, ut_teardown,
18134 			test_snow3g_encryption_test_case_1_offset_oop),
18135 		TEST_CASE_ST(ut_setup, ut_teardown,
18136 			test_snow3g_decryption_test_case_1_oop),
18137 
18138 		/** SNOW 3G generate auth, then encrypt (UEA2) */
18139 		TEST_CASE_ST(ut_setup, ut_teardown,
18140 			test_snow3g_auth_cipher_test_case_1),
18141 		TEST_CASE_ST(ut_setup, ut_teardown,
18142 			test_snow3g_auth_cipher_test_case_2),
18143 		TEST_CASE_ST(ut_setup, ut_teardown,
18144 			test_snow3g_auth_cipher_test_case_2_oop),
18145 		TEST_CASE_ST(ut_setup, ut_teardown,
18146 			test_snow3g_auth_cipher_part_digest_enc),
18147 		TEST_CASE_ST(ut_setup, ut_teardown,
18148 			test_snow3g_auth_cipher_part_digest_enc_oop),
18149 		TEST_CASE_ST(ut_setup, ut_teardown,
18150 			test_snow3g_auth_cipher_test_case_3_sgl),
18151 		TEST_CASE_ST(ut_setup, ut_teardown,
18152 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
18153 		TEST_CASE_ST(ut_setup, ut_teardown,
18154 			test_snow3g_auth_cipher_part_digest_enc_sgl),
18155 		TEST_CASE_ST(ut_setup, ut_teardown,
18156 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
18157 		TEST_CASE_ST(ut_setup, ut_teardown,
18158 			test_snow3g_auth_cipher_total_digest_enc_1),
18159 		TEST_CASE_ST(ut_setup, ut_teardown,
18160 			test_snow3g_auth_cipher_total_digest_enc_1_oop),
18161 		TEST_CASE_ST(ut_setup, ut_teardown,
18162 			test_snow3g_auth_cipher_total_digest_enc_1_sgl),
18163 		TEST_CASE_ST(ut_setup, ut_teardown,
18164 			test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
18165 
18166 		/** SNOW 3G decrypt (UEA2), then verify auth */
18167 		TEST_CASE_ST(ut_setup, ut_teardown,
18168 			test_snow3g_auth_cipher_verify_test_case_1),
18169 		TEST_CASE_ST(ut_setup, ut_teardown,
18170 			test_snow3g_auth_cipher_verify_test_case_2),
18171 		TEST_CASE_ST(ut_setup, ut_teardown,
18172 			test_snow3g_auth_cipher_verify_test_case_2_oop),
18173 		TEST_CASE_ST(ut_setup, ut_teardown,
18174 			test_snow3g_auth_cipher_verify_part_digest_enc),
18175 		TEST_CASE_ST(ut_setup, ut_teardown,
18176 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
18177 		TEST_CASE_ST(ut_setup, ut_teardown,
18178 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
18179 		TEST_CASE_ST(ut_setup, ut_teardown,
18180 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
18181 		TEST_CASE_ST(ut_setup, ut_teardown,
18182 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
18183 		TEST_CASE_ST(ut_setup, ut_teardown,
18184 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
18185 		TEST_CASE_ST(ut_setup, ut_teardown,
18186 			test_snow3g_auth_cipher_verify_total_digest_enc_1),
18187 		TEST_CASE_ST(ut_setup, ut_teardown,
18188 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
18189 		TEST_CASE_ST(ut_setup, ut_teardown,
18190 			test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
18191 		TEST_CASE_ST(ut_setup, ut_teardown,
18192 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
18193 
18194 		/** SNOW 3G decrypt only (UEA2) */
18195 		TEST_CASE_ST(ut_setup, ut_teardown,
18196 			test_snow3g_decryption_test_case_1),
18197 		TEST_CASE_ST(ut_setup, ut_teardown,
18198 			test_snow3g_decryption_test_case_2),
18199 		TEST_CASE_ST(ut_setup, ut_teardown,
18200 			test_snow3g_decryption_test_case_3),
18201 		TEST_CASE_ST(ut_setup, ut_teardown,
18202 			test_snow3g_decryption_test_case_4),
18203 		TEST_CASE_ST(ut_setup, ut_teardown,
18204 			test_snow3g_decryption_test_case_5),
18205 		TEST_CASE_ST(ut_setup, ut_teardown,
18206 			test_snow3g_decryption_with_digest_test_case_1),
18207 		TEST_CASE_ST(ut_setup, ut_teardown,
18208 			test_snow3g_hash_generate_test_case_1),
18209 		TEST_CASE_ST(ut_setup, ut_teardown,
18210 			test_snow3g_hash_generate_test_case_2),
18211 		TEST_CASE_ST(ut_setup, ut_teardown,
18212 			test_snow3g_hash_generate_test_case_3),
18213 
18214 		/* Tests with buffers which length is not byte-aligned */
18215 		TEST_CASE_ST(ut_setup, ut_teardown,
18216 			test_snow3g_hash_generate_test_case_4),
18217 		TEST_CASE_ST(ut_setup, ut_teardown,
18218 			test_snow3g_hash_generate_test_case_5),
18219 		TEST_CASE_ST(ut_setup, ut_teardown,
18220 			test_snow3g_hash_generate_test_case_6),
18221 		TEST_CASE_ST(ut_setup, ut_teardown,
18222 			test_snow3g_hash_verify_test_case_1),
18223 		TEST_CASE_ST(ut_setup, ut_teardown,
18224 			test_snow3g_hash_verify_test_case_2),
18225 		TEST_CASE_ST(ut_setup, ut_teardown,
18226 			test_snow3g_hash_verify_test_case_3),
18227 
18228 		/* Tests with buffers which length is not byte-aligned */
18229 		TEST_CASE_ST(ut_setup, ut_teardown,
18230 			test_snow3g_hash_verify_test_case_4),
18231 		TEST_CASE_ST(ut_setup, ut_teardown,
18232 			test_snow3g_hash_verify_test_case_5),
18233 		TEST_CASE_ST(ut_setup, ut_teardown,
18234 			test_snow3g_hash_verify_test_case_6),
18235 		TEST_CASE_ST(ut_setup, ut_teardown,
18236 			test_snow3g_cipher_auth_test_case_1),
18237 		TEST_CASE_ST(ut_setup, ut_teardown,
18238 			test_snow3g_auth_cipher_with_digest_test_case_1),
18239 		TEST_CASES_END()
18240 	}
18241 };
18242 
18243 static struct unit_test_suite cryptodev_zuc_testsuite  = {
18244 	.suite_name = "ZUC Test Suite",
18245 	.setup = zuc_testsuite_setup,
18246 	.unit_test_cases = {
18247 		/** ZUC encrypt only (EEA3) */
18248 		TEST_CASE_ST(ut_setup, ut_teardown,
18249 			test_zuc_encryption_test_case_1),
18250 		TEST_CASE_ST(ut_setup, ut_teardown,
18251 			test_zuc_encryption_test_case_2),
18252 		TEST_CASE_ST(ut_setup, ut_teardown,
18253 			test_zuc_encryption_test_case_3),
18254 		TEST_CASE_ST(ut_setup, ut_teardown,
18255 			test_zuc_encryption_test_case_4),
18256 		TEST_CASE_ST(ut_setup, ut_teardown,
18257 			test_zuc_encryption_test_case_5),
18258 		TEST_CASE_ST(ut_setup, ut_teardown,
18259 			test_zuc_encryption_test_case_6_sgl),
18260 
18261 		/** ZUC decrypt only (EEA3) */
18262 		TEST_CASE_ST(ut_setup, ut_teardown,
18263 			test_zuc_decryption_test_case_1),
18264 		TEST_CASE_ST(ut_setup, ut_teardown,
18265 			test_zuc_decryption_test_case_2),
18266 		TEST_CASE_ST(ut_setup, ut_teardown,
18267 			test_zuc_decryption_test_case_3),
18268 		TEST_CASE_ST(ut_setup, ut_teardown,
18269 			test_zuc_decryption_test_case_4),
18270 		TEST_CASE_ST(ut_setup, ut_teardown,
18271 			test_zuc_decryption_test_case_5),
18272 		TEST_CASE_ST(ut_setup, ut_teardown,
18273 			test_zuc_decryption_test_case_6_sgl),
18274 
18275 		/** ZUC authenticate (EIA3) */
18276 		TEST_CASE_ST(ut_setup, ut_teardown,
18277 			test_zuc_hash_generate_test_case_1),
18278 		TEST_CASE_ST(ut_setup, ut_teardown,
18279 			test_zuc_hash_generate_test_case_2),
18280 		TEST_CASE_ST(ut_setup, ut_teardown,
18281 			test_zuc_hash_generate_test_case_3),
18282 		TEST_CASE_ST(ut_setup, ut_teardown,
18283 			test_zuc_hash_generate_test_case_4),
18284 		TEST_CASE_ST(ut_setup, ut_teardown,
18285 			test_zuc_hash_generate_test_case_5),
18286 		TEST_CASE_ST(ut_setup, ut_teardown,
18287 			test_zuc_hash_generate_test_case_6),
18288 		TEST_CASE_ST(ut_setup, ut_teardown,
18289 			test_zuc_hash_generate_test_case_7),
18290 		TEST_CASE_ST(ut_setup, ut_teardown,
18291 			test_zuc_hash_generate_test_case_8),
18292 
18293 		/** ZUC verify (EIA3) */
18294 		TEST_CASE_ST(ut_setup, ut_teardown,
18295 			test_zuc_hash_verify_test_case_1),
18296 		TEST_CASE_ST(ut_setup, ut_teardown,
18297 			test_zuc_hash_verify_test_case_2),
18298 		TEST_CASE_ST(ut_setup, ut_teardown,
18299 			test_zuc_hash_verify_test_case_3),
18300 		TEST_CASE_ST(ut_setup, ut_teardown,
18301 			test_zuc_hash_verify_test_case_4),
18302 		TEST_CASE_ST(ut_setup, ut_teardown,
18303 			test_zuc_hash_verify_test_case_5),
18304 		TEST_CASE_ST(ut_setup, ut_teardown,
18305 			test_zuc_hash_verify_test_case_6),
18306 		TEST_CASE_ST(ut_setup, ut_teardown,
18307 			test_zuc_hash_verify_test_case_7),
18308 		TEST_CASE_ST(ut_setup, ut_teardown,
18309 			test_zuc_hash_verify_test_case_8),
18310 
18311 		/** ZUC alg-chain (EEA3/EIA3) */
18312 		TEST_CASE_ST(ut_setup, ut_teardown,
18313 			test_zuc_cipher_auth_test_case_1),
18314 		TEST_CASE_ST(ut_setup, ut_teardown,
18315 			test_zuc_cipher_auth_test_case_2),
18316 
18317 		/** ZUC generate auth, then encrypt (EEA3) */
18318 		TEST_CASE_ST(ut_setup, ut_teardown,
18319 			test_zuc_auth_cipher_test_case_1),
18320 		TEST_CASE_ST(ut_setup, ut_teardown,
18321 			test_zuc_auth_cipher_test_case_1_oop),
18322 		TEST_CASE_ST(ut_setup, ut_teardown,
18323 			test_zuc_auth_cipher_test_case_1_sgl),
18324 		TEST_CASE_ST(ut_setup, ut_teardown,
18325 			test_zuc_auth_cipher_test_case_1_oop_sgl),
18326 		TEST_CASE_ST(ut_setup, ut_teardown,
18327 			test_zuc_auth_cipher_test_case_2),
18328 		TEST_CASE_ST(ut_setup, ut_teardown,
18329 			test_zuc_auth_cipher_test_case_2_oop),
18330 
18331 		/** ZUC decrypt (EEA3), then verify auth */
18332 		TEST_CASE_ST(ut_setup, ut_teardown,
18333 			test_zuc_auth_cipher_verify_test_case_1),
18334 		TEST_CASE_ST(ut_setup, ut_teardown,
18335 			test_zuc_auth_cipher_verify_test_case_1_oop),
18336 		TEST_CASE_ST(ut_setup, ut_teardown,
18337 			test_zuc_auth_cipher_verify_test_case_1_sgl),
18338 		TEST_CASE_ST(ut_setup, ut_teardown,
18339 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
18340 		TEST_CASE_ST(ut_setup, ut_teardown,
18341 			test_zuc_auth_cipher_verify_test_case_2),
18342 		TEST_CASE_ST(ut_setup, ut_teardown,
18343 			test_zuc_auth_cipher_verify_test_case_2_oop),
18344 
18345 		/** ZUC-256 encrypt only **/
18346 		TEST_CASE_ST(ut_setup, ut_teardown,
18347 			test_zuc256_encryption_test_case_1),
18348 		TEST_CASE_ST(ut_setup, ut_teardown,
18349 			test_zuc256_encryption_test_case_2),
18350 
18351 		/** ZUC-256 decrypt only **/
18352 		TEST_CASE_ST(ut_setup, ut_teardown,
18353 			test_zuc256_decryption_test_case_1),
18354 		TEST_CASE_ST(ut_setup, ut_teardown,
18355 			test_zuc256_decryption_test_case_2),
18356 
18357 		/** ZUC-256 authentication only **/
18358 		TEST_CASE_ST(ut_setup, ut_teardown,
18359 			test_zuc256_hash_generate_4b_tag_test_case_1),
18360 		TEST_CASE_ST(ut_setup, ut_teardown,
18361 			test_zuc256_hash_generate_4b_tag_test_case_2),
18362 		TEST_CASE_ST(ut_setup, ut_teardown,
18363 			test_zuc256_hash_generate_4b_tag_test_case_3),
18364 		TEST_CASE_ST(ut_setup, ut_teardown,
18365 			test_zuc256_hash_generate_8b_tag_test_case_1),
18366 		TEST_CASE_ST(ut_setup, ut_teardown,
18367 			test_zuc256_hash_generate_16b_tag_test_case_1),
18368 
18369 		/** ZUC-256 authentication verify only **/
18370 		TEST_CASE_ST(ut_setup, ut_teardown,
18371 			test_zuc256_hash_verify_4b_tag_test_case_1),
18372 		TEST_CASE_ST(ut_setup, ut_teardown,
18373 			test_zuc256_hash_verify_4b_tag_test_case_2),
18374 		TEST_CASE_ST(ut_setup, ut_teardown,
18375 			test_zuc256_hash_verify_4b_tag_test_case_3),
18376 		TEST_CASE_ST(ut_setup, ut_teardown,
18377 			test_zuc256_hash_verify_8b_tag_test_case_1),
18378 		TEST_CASE_ST(ut_setup, ut_teardown,
18379 			test_zuc256_hash_verify_16b_tag_test_case_1),
18380 
18381 		/** ZUC-256 encrypt and authenticate **/
18382 		TEST_CASE_ST(ut_setup, ut_teardown,
18383 			test_zuc256_cipher_auth_4b_tag_test_case_1),
18384 		TEST_CASE_ST(ut_setup, ut_teardown,
18385 			test_zuc256_cipher_auth_4b_tag_test_case_2),
18386 		TEST_CASE_ST(ut_setup, ut_teardown,
18387 			test_zuc256_cipher_auth_8b_tag_test_case_1),
18388 		TEST_CASE_ST(ut_setup, ut_teardown,
18389 			test_zuc256_cipher_auth_16b_tag_test_case_1),
18390 
18391 		/** ZUC-256 generate auth, then encrypt */
18392 		TEST_CASE_ST(ut_setup, ut_teardown,
18393 			test_zuc256_auth_cipher_4b_tag_test_case_1),
18394 		TEST_CASE_ST(ut_setup, ut_teardown,
18395 			test_zuc256_auth_cipher_4b_tag_test_case_2),
18396 		TEST_CASE_ST(ut_setup, ut_teardown,
18397 			test_zuc256_auth_cipher_8b_tag_test_case_1),
18398 		TEST_CASE_ST(ut_setup, ut_teardown,
18399 			test_zuc256_auth_cipher_16b_tag_test_case_1),
18400 
18401 		/** ZUC-256 decrypt, then verify auth */
18402 		TEST_CASE_ST(ut_setup, ut_teardown,
18403 			test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
18404 		TEST_CASE_ST(ut_setup, ut_teardown,
18405 			test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
18406 		TEST_CASE_ST(ut_setup, ut_teardown,
18407 			test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
18408 		TEST_CASE_ST(ut_setup, ut_teardown,
18409 			test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
18410 
18411 		TEST_CASES_END()
18412 	}
18413 };
18414 
18415 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
18416 	.suite_name = "HMAC_MD5 Authentication Test Suite",
18417 	.setup = hmac_md5_auth_testsuite_setup,
18418 	.unit_test_cases = {
18419 		TEST_CASE_ST(ut_setup, ut_teardown,
18420 			test_MD5_HMAC_generate_case_1),
18421 		TEST_CASE_ST(ut_setup, ut_teardown,
18422 			test_MD5_HMAC_verify_case_1),
18423 		TEST_CASE_ST(ut_setup, ut_teardown,
18424 			test_MD5_HMAC_generate_case_2),
18425 		TEST_CASE_ST(ut_setup, ut_teardown,
18426 			test_MD5_HMAC_verify_case_2),
18427 		TEST_CASES_END()
18428 	}
18429 };
18430 
18431 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
18432 	.suite_name = "Kasumi Test Suite",
18433 	.setup = kasumi_testsuite_setup,
18434 	.unit_test_cases = {
18435 		/** KASUMI hash only (UIA1) */
18436 		TEST_CASE_ST(ut_setup, ut_teardown,
18437 			test_kasumi_hash_generate_test_case_1),
18438 		TEST_CASE_ST(ut_setup, ut_teardown,
18439 			test_kasumi_hash_generate_test_case_2),
18440 		TEST_CASE_ST(ut_setup, ut_teardown,
18441 			test_kasumi_hash_generate_test_case_3),
18442 		TEST_CASE_ST(ut_setup, ut_teardown,
18443 			test_kasumi_hash_generate_test_case_4),
18444 		TEST_CASE_ST(ut_setup, ut_teardown,
18445 			test_kasumi_hash_generate_test_case_5),
18446 		TEST_CASE_ST(ut_setup, ut_teardown,
18447 			test_kasumi_hash_generate_test_case_6),
18448 
18449 		TEST_CASE_ST(ut_setup, ut_teardown,
18450 			test_kasumi_hash_verify_test_case_1),
18451 		TEST_CASE_ST(ut_setup, ut_teardown,
18452 			test_kasumi_hash_verify_test_case_2),
18453 		TEST_CASE_ST(ut_setup, ut_teardown,
18454 			test_kasumi_hash_verify_test_case_3),
18455 		TEST_CASE_ST(ut_setup, ut_teardown,
18456 			test_kasumi_hash_verify_test_case_4),
18457 		TEST_CASE_ST(ut_setup, ut_teardown,
18458 			test_kasumi_hash_verify_test_case_5),
18459 
18460 		/** KASUMI encrypt only (UEA1) */
18461 		TEST_CASE_ST(ut_setup, ut_teardown,
18462 			test_kasumi_encryption_test_case_1),
18463 		TEST_CASE_ST(ut_setup, ut_teardown,
18464 			test_kasumi_encryption_test_case_1_sgl),
18465 		TEST_CASE_ST(ut_setup, ut_teardown,
18466 			test_kasumi_encryption_test_case_1_oop),
18467 		TEST_CASE_ST(ut_setup, ut_teardown,
18468 			test_kasumi_encryption_test_case_1_oop_sgl),
18469 		TEST_CASE_ST(ut_setup, ut_teardown,
18470 			test_kasumi_encryption_test_case_2),
18471 		TEST_CASE_ST(ut_setup, ut_teardown,
18472 			test_kasumi_encryption_test_case_3),
18473 		TEST_CASE_ST(ut_setup, ut_teardown,
18474 			test_kasumi_encryption_test_case_4),
18475 		TEST_CASE_ST(ut_setup, ut_teardown,
18476 			test_kasumi_encryption_test_case_5),
18477 
18478 		/** KASUMI decrypt only (UEA1) */
18479 		TEST_CASE_ST(ut_setup, ut_teardown,
18480 			test_kasumi_decryption_test_case_1),
18481 		TEST_CASE_ST(ut_setup, ut_teardown,
18482 			test_kasumi_decryption_test_case_2),
18483 		TEST_CASE_ST(ut_setup, ut_teardown,
18484 			test_kasumi_decryption_test_case_3),
18485 		TEST_CASE_ST(ut_setup, ut_teardown,
18486 			test_kasumi_decryption_test_case_4),
18487 		TEST_CASE_ST(ut_setup, ut_teardown,
18488 			test_kasumi_decryption_test_case_5),
18489 		TEST_CASE_ST(ut_setup, ut_teardown,
18490 			test_kasumi_decryption_test_case_1_oop),
18491 		TEST_CASE_ST(ut_setup, ut_teardown,
18492 			test_kasumi_cipher_auth_test_case_1),
18493 
18494 		/** KASUMI generate auth, then encrypt (F8) */
18495 		TEST_CASE_ST(ut_setup, ut_teardown,
18496 			test_kasumi_auth_cipher_test_case_1),
18497 		TEST_CASE_ST(ut_setup, ut_teardown,
18498 			test_kasumi_auth_cipher_test_case_2),
18499 		TEST_CASE_ST(ut_setup, ut_teardown,
18500 			test_kasumi_auth_cipher_test_case_2_oop),
18501 		TEST_CASE_ST(ut_setup, ut_teardown,
18502 			test_kasumi_auth_cipher_test_case_2_sgl),
18503 		TEST_CASE_ST(ut_setup, ut_teardown,
18504 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
18505 
18506 		/** KASUMI decrypt (F8), then verify auth */
18507 		TEST_CASE_ST(ut_setup, ut_teardown,
18508 			test_kasumi_auth_cipher_verify_test_case_1),
18509 		TEST_CASE_ST(ut_setup, ut_teardown,
18510 			test_kasumi_auth_cipher_verify_test_case_2),
18511 		TEST_CASE_ST(ut_setup, ut_teardown,
18512 			test_kasumi_auth_cipher_verify_test_case_2_oop),
18513 		TEST_CASE_ST(ut_setup, ut_teardown,
18514 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
18515 		TEST_CASE_ST(ut_setup, ut_teardown,
18516 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
18517 
18518 		TEST_CASES_END()
18519 	}
18520 };
18521 
18522 static struct unit_test_suite cryptodev_esn_testsuite  = {
18523 	.suite_name = "ESN Test Suite",
18524 	.setup = esn_testsuite_setup,
18525 	.unit_test_cases = {
18526 		TEST_CASE_ST(ut_setup, ut_teardown,
18527 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
18528 		TEST_CASE_ST(ut_setup, ut_teardown,
18529 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
18530 		TEST_CASES_END()
18531 	}
18532 };
18533 
18534 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
18535 	.suite_name = "Negative AES GCM Test Suite",
18536 	.setup = negative_aes_gcm_testsuite_setup,
18537 	.unit_test_cases = {
18538 		TEST_CASE_ST(ut_setup, ut_teardown,
18539 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
18540 		TEST_CASE_ST(ut_setup, ut_teardown,
18541 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
18542 		TEST_CASE_ST(ut_setup, ut_teardown,
18543 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
18544 		TEST_CASE_ST(ut_setup, ut_teardown,
18545 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
18546 		TEST_CASE_ST(ut_setup, ut_teardown,
18547 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
18548 		TEST_CASE_ST(ut_setup, ut_teardown,
18549 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
18550 		TEST_CASE_ST(ut_setup, ut_teardown,
18551 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
18552 		TEST_CASE_ST(ut_setup, ut_teardown,
18553 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
18554 		TEST_CASE_ST(ut_setup, ut_teardown,
18555 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
18556 		TEST_CASE_ST(ut_setup, ut_teardown,
18557 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
18558 		TEST_CASE_ST(ut_setup, ut_teardown,
18559 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
18560 		TEST_CASE_ST(ut_setup, ut_teardown,
18561 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
18562 
18563 		TEST_CASES_END()
18564 	}
18565 };
18566 
18567 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
18568 	.suite_name = "Negative AES GMAC Test Suite",
18569 	.setup = negative_aes_gmac_testsuite_setup,
18570 	.unit_test_cases = {
18571 		TEST_CASE_ST(ut_setup, ut_teardown,
18572 			authentication_verify_AES128_GMAC_fail_data_corrupt),
18573 		TEST_CASE_ST(ut_setup, ut_teardown,
18574 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
18575 
18576 		TEST_CASES_END()
18577 	}
18578 };
18579 
18580 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
18581 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
18582 	.setup = mixed_cipher_hash_testsuite_setup,
18583 	.unit_test_cases = {
18584 		/** AUTH AES CMAC + CIPHER AES CTR */
18585 		TEST_CASE_ST(ut_setup, ut_teardown,
18586 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
18587 		TEST_CASE_ST(ut_setup, ut_teardown,
18588 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18589 		TEST_CASE_ST(ut_setup, ut_teardown,
18590 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18591 		TEST_CASE_ST(ut_setup, ut_teardown,
18592 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18593 		TEST_CASE_ST(ut_setup, ut_teardown,
18594 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
18595 		TEST_CASE_ST(ut_setup, ut_teardown,
18596 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18597 		TEST_CASE_ST(ut_setup, ut_teardown,
18598 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18599 		TEST_CASE_ST(ut_setup, ut_teardown,
18600 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18601 		TEST_CASE_ST(ut_setup, ut_teardown,
18602 			test_aes_cmac_aes_ctr_digest_enc_test_case_2),
18603 		TEST_CASE_ST(ut_setup, ut_teardown,
18604 			test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18605 		TEST_CASE_ST(ut_setup, ut_teardown,
18606 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
18607 		TEST_CASE_ST(ut_setup, ut_teardown,
18608 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18609 
18610 		/** AUTH ZUC + CIPHER SNOW3G */
18611 		TEST_CASE_ST(ut_setup, ut_teardown,
18612 			test_auth_zuc_cipher_snow_test_case_1),
18613 		TEST_CASE_ST(ut_setup, ut_teardown,
18614 			test_verify_auth_zuc_cipher_snow_test_case_1),
18615 		TEST_CASE_ST(ut_setup, ut_teardown,
18616 			test_auth_zuc_cipher_snow_test_case_1_inplace),
18617 		TEST_CASE_ST(ut_setup, ut_teardown,
18618 			test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
18619 		/** AUTH AES CMAC + CIPHER SNOW3G */
18620 		TEST_CASE_ST(ut_setup, ut_teardown,
18621 			test_auth_aes_cmac_cipher_snow_test_case_1),
18622 		TEST_CASE_ST(ut_setup, ut_teardown,
18623 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
18624 		TEST_CASE_ST(ut_setup, ut_teardown,
18625 			test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18626 		TEST_CASE_ST(ut_setup, ut_teardown,
18627 			test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18628 		/** AUTH ZUC + CIPHER AES CTR */
18629 		TEST_CASE_ST(ut_setup, ut_teardown,
18630 			test_auth_zuc_cipher_aes_ctr_test_case_1),
18631 		TEST_CASE_ST(ut_setup, ut_teardown,
18632 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
18633 		TEST_CASE_ST(ut_setup, ut_teardown,
18634 			test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18635 		TEST_CASE_ST(ut_setup, ut_teardown,
18636 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18637 		/** AUTH SNOW3G + CIPHER AES CTR */
18638 		TEST_CASE_ST(ut_setup, ut_teardown,
18639 			test_auth_snow_cipher_aes_ctr_test_case_1),
18640 		TEST_CASE_ST(ut_setup, ut_teardown,
18641 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
18642 		TEST_CASE_ST(ut_setup, ut_teardown,
18643 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18644 		TEST_CASE_ST(ut_setup, ut_teardown,
18645 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18646 		TEST_CASE_ST(ut_setup, ut_teardown,
18647 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18648 		TEST_CASE_ST(ut_setup, ut_teardown,
18649 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18650 		/** AUTH SNOW3G + CIPHER ZUC */
18651 		TEST_CASE_ST(ut_setup, ut_teardown,
18652 			test_auth_snow_cipher_zuc_test_case_1),
18653 		TEST_CASE_ST(ut_setup, ut_teardown,
18654 			test_verify_auth_snow_cipher_zuc_test_case_1),
18655 		TEST_CASE_ST(ut_setup, ut_teardown,
18656 			test_auth_snow_cipher_zuc_test_case_1_inplace),
18657 		TEST_CASE_ST(ut_setup, ut_teardown,
18658 			test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
18659 		/** AUTH AES CMAC + CIPHER ZUC */
18660 		TEST_CASE_ST(ut_setup, ut_teardown,
18661 			test_auth_aes_cmac_cipher_zuc_test_case_1),
18662 		TEST_CASE_ST(ut_setup, ut_teardown,
18663 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
18664 		TEST_CASE_ST(ut_setup, ut_teardown,
18665 			test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18666 		TEST_CASE_ST(ut_setup, ut_teardown,
18667 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18668 
18669 		/** AUTH NULL + CIPHER SNOW3G */
18670 		TEST_CASE_ST(ut_setup, ut_teardown,
18671 			test_auth_null_cipher_snow_test_case_1),
18672 		TEST_CASE_ST(ut_setup, ut_teardown,
18673 			test_verify_auth_null_cipher_snow_test_case_1),
18674 		/** AUTH NULL + CIPHER ZUC */
18675 		TEST_CASE_ST(ut_setup, ut_teardown,
18676 			test_auth_null_cipher_zuc_test_case_1),
18677 		TEST_CASE_ST(ut_setup, ut_teardown,
18678 			test_verify_auth_null_cipher_zuc_test_case_1),
18679 		/** AUTH SNOW3G + CIPHER NULL */
18680 		TEST_CASE_ST(ut_setup, ut_teardown,
18681 			test_auth_snow_cipher_null_test_case_1),
18682 		TEST_CASE_ST(ut_setup, ut_teardown,
18683 			test_verify_auth_snow_cipher_null_test_case_1),
18684 		/** AUTH ZUC + CIPHER NULL */
18685 		TEST_CASE_ST(ut_setup, ut_teardown,
18686 			test_auth_zuc_cipher_null_test_case_1),
18687 		TEST_CASE_ST(ut_setup, ut_teardown,
18688 			test_verify_auth_zuc_cipher_null_test_case_1),
18689 		/** AUTH NULL + CIPHER AES CTR */
18690 		TEST_CASE_ST(ut_setup, ut_teardown,
18691 			test_auth_null_cipher_aes_ctr_test_case_1),
18692 		TEST_CASE_ST(ut_setup, ut_teardown,
18693 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
18694 		/** AUTH AES CMAC + CIPHER NULL */
18695 		TEST_CASE_ST(ut_setup, ut_teardown,
18696 			test_auth_aes_cmac_cipher_null_test_case_1),
18697 		TEST_CASE_ST(ut_setup, ut_teardown,
18698 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
18699 		TEST_CASES_END()
18700 	}
18701 };
18702 
18703 static int
18704 run_cryptodev_testsuite(const char *pmd_name)
18705 {
18706 	uint8_t ret, j, i = 0, blk_start_idx = 0;
18707 	const enum blockcipher_test_type blk_suites[] = {
18708 		BLKCIPHER_AES_CHAIN_TYPE,
18709 		BLKCIPHER_AES_CIPHERONLY_TYPE,
18710 		BLKCIPHER_AES_DOCSIS_TYPE,
18711 		BLKCIPHER_3DES_CHAIN_TYPE,
18712 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
18713 		BLKCIPHER_DES_CIPHERONLY_TYPE,
18714 		BLKCIPHER_DES_DOCSIS_TYPE,
18715 		BLKCIPHER_SM4_CHAIN_TYPE,
18716 		BLKCIPHER_SM4_CIPHERONLY_TYPE,
18717 		BLKCIPHER_AUTHONLY_TYPE};
18718 	struct unit_test_suite *static_suites[] = {
18719 		&cryptodev_multi_session_testsuite,
18720 		&cryptodev_null_testsuite,
18721 		&cryptodev_aes_ccm_auth_testsuite,
18722 		&cryptodev_aes_gcm_auth_testsuite,
18723 		&cryptodev_aes_gmac_auth_testsuite,
18724 		&cryptodev_snow3g_testsuite,
18725 		&cryptodev_chacha20_poly1305_testsuite,
18726 		&cryptodev_zuc_testsuite,
18727 		&cryptodev_hmac_md5_auth_testsuite,
18728 		&cryptodev_kasumi_testsuite,
18729 		&cryptodev_esn_testsuite,
18730 		&cryptodev_negative_aes_gcm_testsuite,
18731 		&cryptodev_negative_aes_gmac_testsuite,
18732 		&cryptodev_mixed_cipher_hash_testsuite,
18733 		&cryptodev_negative_hmac_sha1_testsuite,
18734 		&cryptodev_gen_testsuite,
18735 #ifdef RTE_LIB_SECURITY
18736 		&ipsec_proto_testsuite,
18737 		&pdcp_proto_testsuite,
18738 		&docsis_proto_testsuite,
18739 		&tls12_record_proto_testsuite,
18740 		&dtls12_record_proto_testsuite,
18741 		&tls13_record_proto_testsuite,
18742 #endif
18743 		&end_testsuite
18744 	};
18745 	static struct unit_test_suite ts = {
18746 		.suite_name = "Cryptodev Unit Test Suite",
18747 		.setup = testsuite_setup,
18748 		.teardown = testsuite_teardown,
18749 		.unit_test_cases = {TEST_CASES_END()}
18750 	};
18751 
18752 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
18753 
18754 	if (gbl_driver_id == -1) {
18755 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
18756 		return TEST_SKIPPED;
18757 	}
18758 
18759 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
18760 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
18761 
18762 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
18763 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
18764 	ret = unit_test_suite_runner(&ts);
18765 
18766 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
18767 	free(ts.unit_test_suites);
18768 	return ret;
18769 }
18770 
18771 static int
18772 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
18773 {
18774 	struct rte_cryptodev_info dev_info;
18775 	uint8_t i, nb_devs;
18776 	int driver_id;
18777 
18778 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
18779 	if (driver_id == -1) {
18780 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
18781 		return TEST_SKIPPED;
18782 	}
18783 
18784 	nb_devs = rte_cryptodev_count();
18785 	if (nb_devs < 1) {
18786 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
18787 		return TEST_SKIPPED;
18788 	}
18789 
18790 	for (i = 0; i < nb_devs; i++) {
18791 		rte_cryptodev_info_get(i, &dev_info);
18792 		if (dev_info.driver_id == driver_id) {
18793 			if (!(dev_info.feature_flags & flag)) {
18794 				RTE_LOG(INFO, USER1, "%s not supported\n",
18795 						flag_name);
18796 				return TEST_SKIPPED;
18797 			}
18798 			return 0; /* found */
18799 		}
18800 	}
18801 
18802 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
18803 	return TEST_SKIPPED;
18804 }
18805 
18806 static int
18807 test_cryptodev_qat(void)
18808 {
18809 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
18810 }
18811 
18812 static int
18813 test_cryptodev_uadk(void)
18814 {
18815 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
18816 }
18817 
18818 static int
18819 test_cryptodev_virtio(void)
18820 {
18821 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
18822 }
18823 
18824 static int
18825 test_cryptodev_aesni_mb(void)
18826 {
18827 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18828 }
18829 
18830 static int
18831 test_cryptodev_cpu_aesni_mb(void)
18832 {
18833 	int32_t rc;
18834 	enum rte_security_session_action_type at = gbl_action_type;
18835 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18836 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18837 	gbl_action_type = at;
18838 	return rc;
18839 }
18840 
18841 static int
18842 test_cryptodev_chacha_poly_mb(void)
18843 {
18844 	int32_t rc;
18845 	enum rte_security_session_action_type at = gbl_action_type;
18846 	rc = run_cryptodev_testsuite(
18847 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
18848 	gbl_action_type = at;
18849 	return rc;
18850 }
18851 
18852 static int
18853 test_cryptodev_openssl(void)
18854 {
18855 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
18856 }
18857 
18858 static int
18859 test_cryptodev_aesni_gcm(void)
18860 {
18861 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18862 }
18863 
18864 static int
18865 test_cryptodev_cpu_aesni_gcm(void)
18866 {
18867 	int32_t rc;
18868 	enum rte_security_session_action_type at = gbl_action_type;
18869 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18870 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18871 	gbl_action_type = at;
18872 	return rc;
18873 }
18874 
18875 static int
18876 test_cryptodev_mlx5(void)
18877 {
18878 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
18879 }
18880 
18881 static int
18882 test_cryptodev_null(void)
18883 {
18884 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
18885 }
18886 
18887 static int
18888 test_cryptodev_sw_snow3g(void)
18889 {
18890 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
18891 }
18892 
18893 static int
18894 test_cryptodev_sw_kasumi(void)
18895 {
18896 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
18897 }
18898 
18899 static int
18900 test_cryptodev_sw_zuc(void)
18901 {
18902 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
18903 }
18904 
18905 static int
18906 test_cryptodev_armv8(void)
18907 {
18908 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
18909 }
18910 
18911 static int
18912 test_cryptodev_mrvl(void)
18913 {
18914 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
18915 }
18916 
18917 #ifdef RTE_CRYPTO_SCHEDULER
18918 
18919 static int
18920 test_cryptodev_scheduler(void)
18921 {
18922 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
18923 	const enum blockcipher_test_type blk_suites[] = {
18924 		BLKCIPHER_AES_CHAIN_TYPE,
18925 		BLKCIPHER_AES_CIPHERONLY_TYPE,
18926 		BLKCIPHER_AUTHONLY_TYPE
18927 	};
18928 	static struct unit_test_suite scheduler_multicore = {
18929 		.suite_name = "Scheduler Multicore Unit Test Suite",
18930 		.setup = scheduler_multicore_testsuite_setup,
18931 		.teardown = scheduler_mode_testsuite_teardown,
18932 		.unit_test_cases = {TEST_CASES_END()}
18933 	};
18934 	static struct unit_test_suite scheduler_round_robin = {
18935 		.suite_name = "Scheduler Round Robin Unit Test Suite",
18936 		.setup = scheduler_roundrobin_testsuite_setup,
18937 		.teardown = scheduler_mode_testsuite_teardown,
18938 		.unit_test_cases = {TEST_CASES_END()}
18939 	};
18940 	static struct unit_test_suite scheduler_failover = {
18941 		.suite_name = "Scheduler Failover Unit Test Suite",
18942 		.setup = scheduler_failover_testsuite_setup,
18943 		.teardown = scheduler_mode_testsuite_teardown,
18944 		.unit_test_cases = {TEST_CASES_END()}
18945 	};
18946 	static struct unit_test_suite scheduler_pkt_size_distr = {
18947 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
18948 		.setup = scheduler_pkt_size_distr_testsuite_setup,
18949 		.teardown = scheduler_mode_testsuite_teardown,
18950 		.unit_test_cases = {TEST_CASES_END()}
18951 	};
18952 	struct unit_test_suite *sched_mode_suites[] = {
18953 		&scheduler_multicore,
18954 		&scheduler_round_robin,
18955 		&scheduler_failover,
18956 		&scheduler_pkt_size_distr
18957 	};
18958 	static struct unit_test_suite scheduler_config = {
18959 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
18960 		.unit_test_cases = {
18961 			TEST_CASE(test_scheduler_attach_worker_op),
18962 			TEST_CASE(test_scheduler_mode_multicore_op),
18963 			TEST_CASE(test_scheduler_mode_roundrobin_op),
18964 			TEST_CASE(test_scheduler_mode_failover_op),
18965 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
18966 			TEST_CASE(test_scheduler_detach_worker_op),
18967 
18968 			TEST_CASES_END() /**< NULL terminate array */
18969 		}
18970 	};
18971 	struct unit_test_suite *static_suites[] = {
18972 		&scheduler_config,
18973 		&end_testsuite
18974 	};
18975 	struct unit_test_suite *sched_mode_static_suites[] = {
18976 #ifdef RTE_LIB_SECURITY
18977 		&docsis_proto_testsuite,
18978 #endif
18979 		&end_testsuite
18980 	};
18981 	static struct unit_test_suite ts = {
18982 		.suite_name = "Scheduler Unit Test Suite",
18983 		.setup = scheduler_testsuite_setup,
18984 		.teardown = testsuite_teardown,
18985 		.unit_test_cases = {TEST_CASES_END()}
18986 	};
18987 
18988 	gbl_driver_id =	rte_cryptodev_driver_id_get(
18989 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
18990 
18991 	if (gbl_driver_id == -1) {
18992 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
18993 		return TEST_SKIPPED;
18994 	}
18995 
18996 	if (rte_cryptodev_driver_id_get(
18997 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
18998 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
18999 		return TEST_SKIPPED;
19000 	}
19001 
19002 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19003 		uint8_t blk_i = 0;
19004 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
19005 				(struct unit_test_suite *) *
19006 				(RTE_DIM(blk_suites) +
19007 				RTE_DIM(sched_mode_static_suites) + 1));
19008 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19009 				blk_suites, RTE_DIM(blk_suites));
19010 		ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19011 				sched_mode_static_suites,
19012 				RTE_DIM(sched_mode_static_suites));
19013 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
19014 	}
19015 
19016 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19017 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
19018 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
19019 			RTE_DIM(sched_mode_suites));
19020 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19021 	ret = unit_test_suite_runner(&ts);
19022 
19023 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19024 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
19025 				(*sched_mode_suites[sched_i]),
19026 				RTE_DIM(blk_suites));
19027 		free(sched_mode_suites[sched_i]->unit_test_suites);
19028 	}
19029 	free(ts.unit_test_suites);
19030 	return ret;
19031 }
19032 
19033 REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
19034 
19035 #endif
19036 
19037 static int
19038 test_cryptodev_dpaa2_sec(void)
19039 {
19040 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19041 }
19042 
19043 static int
19044 test_cryptodev_dpaa_sec(void)
19045 {
19046 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19047 }
19048 
19049 static int
19050 test_cryptodev_ccp(void)
19051 {
19052 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
19053 }
19054 
19055 static int
19056 test_cryptodev_octeontx(void)
19057 {
19058 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
19059 }
19060 
19061 static int
19062 test_cryptodev_caam_jr(void)
19063 {
19064 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
19065 }
19066 
19067 static int
19068 test_cryptodev_nitrox(void)
19069 {
19070 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
19071 }
19072 
19073 static int
19074 test_cryptodev_bcmfs(void)
19075 {
19076 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
19077 }
19078 
19079 static int
19080 run_cryptodev_raw_testsuite(const char *pmd_name)
19081 {
19082 	int ret;
19083 
19084 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
19085 	if (ret)
19086 		return ret;
19087 
19088 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
19089 	ret = run_cryptodev_testsuite(pmd_name);
19090 	global_api_test_type = CRYPTODEV_API_TEST;
19091 
19092 	return ret;
19093 }
19094 
19095 static int
19096 test_cryptodev_qat_raw_api(void)
19097 {
19098 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19099 }
19100 
19101 static int
19102 test_cryptodev_cn9k(void)
19103 {
19104 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
19105 }
19106 
19107 static int
19108 test_cryptodev_cn10k(void)
19109 {
19110 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19111 }
19112 
19113 static int
19114 test_cryptodev_cn10k_raw_api(void)
19115 {
19116 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19117 }
19118 
19119 static int
19120 test_cryptodev_dpaa2_sec_raw_api(void)
19121 {
19122 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19123 }
19124 
19125 static int
19126 test_cryptodev_dpaa_sec_raw_api(void)
19127 {
19128 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19129 }
19130 
19131 REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
19132 		test_cryptodev_cn10k_raw_api);
19133 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
19134 		test_cryptodev_dpaa2_sec_raw_api);
19135 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
19136 		test_cryptodev_dpaa_sec_raw_api);
19137 REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
19138 		test_cryptodev_qat_raw_api);
19139 REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
19140 REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
19141 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
19142 	test_cryptodev_cpu_aesni_mb);
19143 REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
19144 	test_cryptodev_chacha_poly_mb);
19145 REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
19146 REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
19147 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
19148 	test_cryptodev_cpu_aesni_gcm);
19149 REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
19150 REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
19151 REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
19152 REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
19153 REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
19154 REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
19155 REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
19156 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
19157 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
19158 REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
19159 REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
19160 REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
19161 REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
19162 REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
19163 REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
19164 REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
19165 REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
19166 REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
19167