xref: /dpdk/app/test/test_cryptodev.c (revision f665790a5dbad7b645ff46f31d65e977324e7bfc)
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 static bool enq_cb_called;
203 static bool deq_cb_called;
204 
205 int
206 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
207 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
208 		uint8_t len_in_bits, uint8_t cipher_iv_len)
209 {
210 	struct rte_crypto_sym_op *sop = op->sym;
211 	struct rte_crypto_op *ret_op = NULL;
212 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
213 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
214 	union rte_crypto_sym_ofs ofs;
215 	struct rte_crypto_sym_vec vec;
216 	struct rte_crypto_sgl sgl, dest_sgl;
217 	uint32_t max_len;
218 	union rte_cryptodev_session_ctx sess;
219 	uint64_t auth_end_iova;
220 	uint32_t count = 0;
221 	struct rte_crypto_raw_dp_ctx *ctx;
222 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
223 			auth_len = 0;
224 	int32_t n;
225 	uint32_t n_success;
226 	int ctx_service_size;
227 	int32_t status = 0;
228 	int enqueue_status, dequeue_status;
229 	struct crypto_unittest_params *ut_params = &unittest_params;
230 	int is_sgl = sop->m_src->nb_segs > 1;
231 	int ret = TEST_SUCCESS, is_oop = 0;
232 
233 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
234 	if (ctx_service_size < 0)
235 		return TEST_SKIPPED;
236 
237 	ctx = malloc(ctx_service_size);
238 	if (ctx == NULL)
239 		return TEST_FAILED;
240 
241 	/* Both are enums, setting crypto_sess will suit any session type */
242 	sess.crypto_sess = op->sym->session;
243 
244 	ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
245 	if (ret == -ENOTSUP) {
246 		ret = TEST_SKIPPED;
247 		goto exit;
248 	} else if (ret) {
249 		ret = TEST_FAILED;
250 		goto exit;
251 	}
252 
253 	cipher_iv.iova = 0;
254 	cipher_iv.va = NULL;
255 	aad_auth_iv.iova = 0;
256 	aad_auth_iv.va = NULL;
257 	digest.iova = 0;
258 	digest.va = NULL;
259 	sgl.vec = data_vec;
260 	vec.num = 1;
261 	vec.src_sgl = &sgl;
262 	vec.iv = &cipher_iv;
263 	vec.digest = &digest;
264 	vec.aad = &aad_auth_iv;
265 	vec.status = &status;
266 
267 	ofs.raw = 0;
268 
269 	if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
270 		is_oop = 1;
271 
272 	if (is_cipher && is_auth) {
273 		cipher_offset = sop->cipher.data.offset;
274 		cipher_len = sop->cipher.data.length;
275 		auth_offset = sop->auth.data.offset;
276 		auth_len = sop->auth.data.length;
277 		max_len = RTE_MAX(cipher_offset + cipher_len,
278 				auth_offset + auth_len);
279 		if (len_in_bits) {
280 			max_len = max_len >> 3;
281 			cipher_offset = cipher_offset >> 3;
282 			auth_offset = auth_offset >> 3;
283 			cipher_len = cipher_len >> 3;
284 			auth_len = auth_len >> 3;
285 		}
286 		ofs.ofs.cipher.head = cipher_offset;
287 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
288 		ofs.ofs.auth.head = auth_offset;
289 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
290 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
291 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
292 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
293 				op, void *, IV_OFFSET + cipher_iv_len);
294 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
295 				cipher_iv_len);
296 		digest.va = (void *)sop->auth.digest.data;
297 		digest.iova = sop->auth.digest.phys_addr;
298 
299 		if (is_sgl) {
300 			uint32_t remaining_off = auth_offset + auth_len;
301 			struct rte_mbuf *sgl_buf = sop->m_src;
302 			if (is_oop)
303 				sgl_buf = sop->m_dst;
304 
305 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
306 					&& sgl_buf->next != NULL) {
307 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
308 				sgl_buf = sgl_buf->next;
309 			}
310 
311 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
312 				sgl_buf, remaining_off);
313 		} else {
314 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
315 							 auth_offset + auth_len;
316 		}
317 		/* Then check if digest-encrypted conditions are met */
318 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
319 				(digest.iova == auth_end_iova) && is_sgl)
320 			max_len = RTE_MAX(max_len,
321 				auth_offset + auth_len +
322 				ut_params->auth_xform.auth.digest_length);
323 
324 	} else if (is_cipher) {
325 		cipher_offset = sop->cipher.data.offset;
326 		cipher_len = sop->cipher.data.length;
327 		max_len = cipher_len + cipher_offset;
328 		if (len_in_bits) {
329 			max_len = max_len >> 3;
330 			cipher_offset = cipher_offset >> 3;
331 			cipher_len = cipher_len >> 3;
332 		}
333 		ofs.ofs.cipher.head = cipher_offset;
334 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
335 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
336 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
337 
338 	} else if (is_auth) {
339 		auth_offset = sop->auth.data.offset;
340 		auth_len = sop->auth.data.length;
341 		max_len = auth_len + auth_offset;
342 		if (len_in_bits) {
343 			max_len = max_len >> 3;
344 			auth_offset = auth_offset >> 3;
345 			auth_len = auth_len >> 3;
346 		}
347 		ofs.ofs.auth.head = auth_offset;
348 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
349 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
350 				op, void *, IV_OFFSET + cipher_iv_len);
351 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
352 				cipher_iv_len);
353 		digest.va = (void *)sop->auth.digest.data;
354 		digest.iova = sop->auth.digest.phys_addr;
355 
356 	} else { /* aead */
357 		cipher_offset = sop->aead.data.offset;
358 		cipher_len = sop->aead.data.length;
359 		max_len = cipher_len + cipher_offset;
360 		if (len_in_bits) {
361 			max_len = max_len >> 3;
362 			cipher_offset = cipher_offset >> 3;
363 			cipher_len = cipher_len >> 3;
364 		}
365 		ofs.ofs.cipher.head = cipher_offset;
366 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
367 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
368 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
369 		aad_auth_iv.va = (void *)sop->aead.aad.data;
370 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
371 		digest.va = (void *)sop->aead.digest.data;
372 		digest.iova = sop->aead.digest.phys_addr;
373 	}
374 
375 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
376 			data_vec, RTE_DIM(data_vec));
377 	if (n < 0 || n > sop->m_src->nb_segs) {
378 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
379 		goto exit;
380 	}
381 
382 	sgl.num = n;
383 	/* Out of place */
384 	if (is_oop) {
385 		dest_sgl.vec = dest_data_vec;
386 		vec.dest_sgl = &dest_sgl;
387 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
388 				dest_data_vec, RTE_DIM(dest_data_vec));
389 		if (n < 0 || n > sop->m_dst->nb_segs) {
390 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
391 			goto exit;
392 		}
393 		dest_sgl.num = n;
394 	} else
395 		vec.dest_sgl = NULL;
396 
397 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
398 			&enqueue_status) < 1) {
399 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
400 		goto exit;
401 	}
402 
403 	if (enqueue_status == 0) {
404 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
405 		if (status < 0) {
406 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
407 			goto exit;
408 		}
409 	} else if (enqueue_status < 0) {
410 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
411 		goto exit;
412 	}
413 
414 	n = n_success = 0;
415 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
416 		n = rte_cryptodev_raw_dequeue_burst(ctx,
417 			NULL, 1, post_process_raw_dp_op,
418 				(void **)&ret_op, 0, &n_success,
419 				&dequeue_status);
420 		if (dequeue_status < 0) {
421 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
422 			goto exit;
423 		}
424 		if (n == 0)
425 			rte_pause();
426 	}
427 
428 	if (n == 1 && dequeue_status == 0) {
429 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
430 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
431 			goto exit;
432 		}
433 	}
434 
435 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
436 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
437 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
438 					RTE_CRYPTO_OP_STATUS_SUCCESS;
439 
440 exit:
441 	free(ctx);
442 	return ret;
443 }
444 
445 static void
446 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
447 {
448 	int32_t n, st;
449 	struct rte_crypto_sym_op *sop;
450 	union rte_crypto_sym_ofs ofs;
451 	struct rte_crypto_sgl sgl;
452 	struct rte_crypto_sym_vec symvec;
453 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
454 	struct rte_crypto_vec vec[UINT8_MAX];
455 
456 	sop = op->sym;
457 
458 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
459 		sop->aead.data.length, vec, RTE_DIM(vec));
460 
461 	if (n < 0 || n != sop->m_src->nb_segs) {
462 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
463 		return;
464 	}
465 
466 	sgl.vec = vec;
467 	sgl.num = n;
468 	symvec.src_sgl = &sgl;
469 	symvec.iv = &iv_ptr;
470 	symvec.digest = &digest_ptr;
471 	symvec.aad = &aad_ptr;
472 	symvec.status = &st;
473 	symvec.num = 1;
474 
475 	/* for CPU crypto the IOVA address is not required */
476 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
477 	digest_ptr.va = (void *)sop->aead.digest.data;
478 	aad_ptr.va = (void *)sop->aead.aad.data;
479 
480 	ofs.raw = 0;
481 
482 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
483 		&symvec);
484 
485 	if (n != 1)
486 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
487 	else
488 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
489 }
490 
491 static void
492 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
493 {
494 	int32_t n, st;
495 	struct rte_crypto_sym_op *sop;
496 	union rte_crypto_sym_ofs ofs;
497 	struct rte_crypto_sgl sgl;
498 	struct rte_crypto_sym_vec symvec;
499 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
500 	struct rte_crypto_vec vec[UINT8_MAX];
501 
502 	sop = op->sym;
503 
504 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
505 		sop->auth.data.length, vec, RTE_DIM(vec));
506 
507 	if (n < 0 || n != sop->m_src->nb_segs) {
508 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
509 		return;
510 	}
511 
512 	sgl.vec = vec;
513 	sgl.num = n;
514 	symvec.src_sgl = &sgl;
515 	symvec.iv = &iv_ptr;
516 	symvec.digest = &digest_ptr;
517 	symvec.status = &st;
518 	symvec.num = 1;
519 
520 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
521 	digest_ptr.va = (void *)sop->auth.digest.data;
522 
523 	ofs.raw = 0;
524 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
525 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
526 		(sop->cipher.data.offset + sop->cipher.data.length);
527 
528 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
529 		&symvec);
530 
531 	if (n != 1)
532 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
533 	else
534 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
535 }
536 
537 static struct rte_crypto_op *
538 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
539 {
540 
541 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
542 
543 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
544 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
545 		return NULL;
546 	}
547 
548 	op = NULL;
549 
550 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
551 		rte_pause();
552 
553 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
554 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
555 		return NULL;
556 	}
557 
558 	return op;
559 }
560 
561 static int
562 testsuite_setup(void)
563 {
564 	struct crypto_testsuite_params *ts_params = &testsuite_params;
565 	struct rte_cryptodev_info info;
566 	uint32_t i = 0, nb_devs, dev_id;
567 	uint16_t qp_id;
568 
569 	memset(ts_params, 0, sizeof(*ts_params));
570 
571 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
572 	if (ts_params->mbuf_pool == NULL) {
573 		/* Not already created so create */
574 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
575 				"CRYPTO_MBUFPOOL",
576 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
577 				rte_socket_id());
578 		if (ts_params->mbuf_pool == NULL) {
579 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
580 			return TEST_FAILED;
581 		}
582 	}
583 
584 	ts_params->large_mbuf_pool = rte_mempool_lookup(
585 			"CRYPTO_LARGE_MBUFPOOL");
586 	if (ts_params->large_mbuf_pool == NULL) {
587 		/* Not already created so create */
588 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
589 				"CRYPTO_LARGE_MBUFPOOL",
590 				1, 0, 0, UINT16_MAX,
591 				rte_socket_id());
592 		if (ts_params->large_mbuf_pool == NULL) {
593 			RTE_LOG(ERR, USER1,
594 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
595 			return TEST_FAILED;
596 		}
597 	}
598 
599 	ts_params->op_mpool = rte_crypto_op_pool_create(
600 			"MBUF_CRYPTO_SYM_OP_POOL",
601 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
602 			NUM_MBUFS, MBUF_CACHE_SIZE,
603 			DEFAULT_NUM_XFORMS *
604 			sizeof(struct rte_crypto_sym_xform) +
605 			MAXIMUM_IV_LENGTH,
606 			rte_socket_id());
607 	if (ts_params->op_mpool == NULL) {
608 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
609 		return TEST_FAILED;
610 	}
611 
612 	nb_devs = rte_cryptodev_count();
613 	if (nb_devs < 1) {
614 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
615 		return TEST_SKIPPED;
616 	}
617 
618 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
619 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
620 				rte_cryptodev_driver_name_get(gbl_driver_id));
621 		return TEST_SKIPPED;
622 	}
623 
624 	/* Create list of valid crypto devs */
625 	for (i = 0; i < nb_devs; i++) {
626 		rte_cryptodev_info_get(i, &info);
627 		if (info.driver_id == gbl_driver_id)
628 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
629 	}
630 
631 	if (ts_params->valid_dev_count < 1)
632 		return TEST_FAILED;
633 
634 	/* Set up all the qps on the first of the valid devices found */
635 
636 	dev_id = ts_params->valid_devs[0];
637 
638 	rte_cryptodev_info_get(dev_id, &info);
639 
640 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
641 	ts_params->conf.socket_id = SOCKET_ID_ANY;
642 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
643 
644 	unsigned int session_size =
645 		rte_cryptodev_sym_get_private_session_size(dev_id);
646 
647 #ifdef RTE_LIB_SECURITY
648 	unsigned int security_session_size = rte_security_session_get_size(
649 			rte_cryptodev_get_sec_ctx(dev_id));
650 
651 	if (session_size < security_session_size)
652 		session_size = security_session_size;
653 #endif
654 	/*
655 	 * Create mempool with maximum number of sessions.
656 	 */
657 	if (info.sym.max_nb_sessions != 0 &&
658 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
659 		RTE_LOG(ERR, USER1, "Device does not support "
660 				"at least %u sessions\n",
661 				MAX_NB_SESSIONS);
662 		return TEST_FAILED;
663 	}
664 
665 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
666 			"test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
667 			SOCKET_ID_ANY);
668 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
669 			"session mempool allocation failed");
670 
671 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
672 			&ts_params->conf),
673 			"Failed to configure cryptodev %u with %u qps",
674 			dev_id, ts_params->conf.nb_queue_pairs);
675 
676 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
677 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
678 
679 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
680 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
681 			dev_id, qp_id, &ts_params->qp_conf,
682 			rte_cryptodev_socket_id(dev_id)),
683 			"Failed to setup queue pair %u on cryptodev %u",
684 			qp_id, dev_id);
685 	}
686 
687 	return TEST_SUCCESS;
688 }
689 
690 static void
691 testsuite_teardown(void)
692 {
693 	struct crypto_testsuite_params *ts_params = &testsuite_params;
694 	int res;
695 
696 	if (ts_params->mbuf_pool != NULL) {
697 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
698 		rte_mempool_avail_count(ts_params->mbuf_pool));
699 	}
700 
701 	if (ts_params->op_mpool != NULL) {
702 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
703 		rte_mempool_avail_count(ts_params->op_mpool));
704 	}
705 
706 	if (ts_params->session_mpool != NULL) {
707 		rte_mempool_free(ts_params->session_mpool);
708 		ts_params->session_mpool = NULL;
709 	}
710 
711 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
712 	if (res)
713 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
714 }
715 
716 static int
717 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
718 		const int *algs, uint16_t num_algs)
719 {
720 	uint8_t dev_id = testsuite_params.valid_devs[0];
721 	bool some_alg_supported = FALSE;
722 	uint16_t i;
723 
724 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
725 		struct rte_cryptodev_sym_capability_idx alg = {
726 			type, {algs[i]}
727 		};
728 		if (rte_cryptodev_sym_capability_get(dev_id,
729 				&alg) != NULL)
730 			some_alg_supported = TRUE;
731 	}
732 	if (!some_alg_supported)
733 		return TEST_SKIPPED;
734 
735 	return 0;
736 }
737 
738 int
739 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
740 		uint16_t num_ciphers)
741 {
742 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
743 			(const int *) ciphers, num_ciphers);
744 }
745 
746 int
747 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
748 		uint16_t num_auths)
749 {
750 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
751 			(const int *) auths, num_auths);
752 }
753 
754 int
755 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
756 		uint16_t num_aeads)
757 {
758 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
759 			(const int *) aeads, num_aeads);
760 }
761 
762 static int
763 null_testsuite_setup(void)
764 {
765 	struct crypto_testsuite_params *ts_params = &testsuite_params;
766 	uint8_t dev_id = ts_params->valid_devs[0];
767 	struct rte_cryptodev_info dev_info;
768 	const enum rte_crypto_cipher_algorithm ciphers[] = {
769 		RTE_CRYPTO_CIPHER_NULL
770 	};
771 	const enum rte_crypto_auth_algorithm auths[] = {
772 		RTE_CRYPTO_AUTH_NULL
773 	};
774 
775 	rte_cryptodev_info_get(dev_id, &dev_info);
776 
777 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
778 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
779 				"testsuite not met\n");
780 		return TEST_SKIPPED;
781 	}
782 
783 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
784 			&& check_auth_capabilities_supported(auths,
785 			RTE_DIM(auths)) != 0) {
786 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
787 				"testsuite not met\n");
788 		return TEST_SKIPPED;
789 	}
790 
791 	return 0;
792 }
793 
794 static int
795 crypto_gen_testsuite_setup(void)
796 {
797 	struct crypto_testsuite_params *ts_params = &testsuite_params;
798 	uint8_t dev_id = ts_params->valid_devs[0];
799 	struct rte_cryptodev_info dev_info;
800 
801 	rte_cryptodev_info_get(dev_id, &dev_info);
802 
803 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
804 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
805 				"testsuite not met\n");
806 		return TEST_SKIPPED;
807 	}
808 
809 	return 0;
810 }
811 
812 #ifdef RTE_LIB_SECURITY
813 static int
814 sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
815 {
816 	struct crypto_testsuite_params *ts_params = &testsuite_params;
817 	struct crypto_unittest_params *ut_params = &unittest_params;
818 	struct rte_cryptodev_info dev_info;
819 	int ret = 0;
820 
821 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
822 
823 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
824 		RTE_LOG(INFO, USER1,
825 			"Feature flag requirements for security protocol testsuite not met\n");
826 		return TEST_SKIPPED;
827 	}
828 
829 	/* Reconfigure to enable security */
830 	ret = dev_configure_and_start(0);
831 	if (ret != TEST_SUCCESS)
832 		return ret;
833 
834 	/* Set action type */
835 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
836 
837 	if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
838 		RTE_LOG(INFO, USER1,
839 			"Capability requirements for security protocol test not met\n");
840 		ret = TEST_SKIPPED;
841 	}
842 
843 	test_sec_alg_list_populate();
844 	test_sec_auth_only_alg_list_populate();
845 
846 	/*
847 	 * Stop the device. Device would be started again by individual test
848 	 * case setup routine.
849 	 */
850 	rte_cryptodev_stop(ts_params->valid_devs[0]);
851 
852 	return ret;
853 }
854 
855 static int
856 ipsec_proto_testsuite_setup(void)
857 {
858 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
859 }
860 
861 static int
862 tls_record_proto_testsuite_setup(void)
863 {
864 	test_sec_proto_pattern_generate();
865 
866 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
867 }
868 
869 static int
870 pdcp_proto_testsuite_setup(void)
871 {
872 	struct crypto_testsuite_params *ts_params = &testsuite_params;
873 	uint8_t dev_id = ts_params->valid_devs[0];
874 	struct rte_cryptodev_info dev_info;
875 	const enum rte_crypto_cipher_algorithm ciphers[] = {
876 		RTE_CRYPTO_CIPHER_NULL,
877 		RTE_CRYPTO_CIPHER_AES_CTR,
878 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
879 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
880 	};
881 	const enum rte_crypto_auth_algorithm auths[] = {
882 		RTE_CRYPTO_AUTH_NULL,
883 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
884 		RTE_CRYPTO_AUTH_AES_CMAC,
885 		RTE_CRYPTO_AUTH_ZUC_EIA3
886 	};
887 
888 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
889 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
890 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
891 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
892 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
893 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
894 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
895 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
896 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
897 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
898 
899 	rte_cryptodev_info_get(dev_id, &dev_info);
900 
901 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
902 			!(dev_info.feature_flags &
903 			RTE_CRYPTODEV_FF_SECURITY)) {
904 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
905 				"testsuite not met\n");
906 		return TEST_SKIPPED;
907 	}
908 
909 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
910 			&& check_auth_capabilities_supported(auths,
911 			RTE_DIM(auths)) != 0) {
912 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
913 				"testsuite not met\n");
914 		return TEST_SKIPPED;
915 	}
916 
917 	return 0;
918 }
919 
920 static int
921 docsis_proto_testsuite_setup(void)
922 {
923 	struct crypto_testsuite_params *ts_params = &testsuite_params;
924 	uint8_t dev_id = ts_params->valid_devs[0];
925 	struct rte_cryptodev_info dev_info;
926 	const enum rte_crypto_cipher_algorithm ciphers[] = {
927 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
928 	};
929 
930 	rte_cryptodev_info_get(dev_id, &dev_info);
931 
932 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
933 			!(dev_info.feature_flags &
934 			RTE_CRYPTODEV_FF_SECURITY)) {
935 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
936 				"Proto testsuite not met\n");
937 		return TEST_SKIPPED;
938 	}
939 
940 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
941 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
942 				"testsuite not met\n");
943 		return TEST_SKIPPED;
944 	}
945 
946 	return 0;
947 }
948 #endif
949 
950 static int
951 aes_ccm_auth_testsuite_setup(void)
952 {
953 	struct crypto_testsuite_params *ts_params = &testsuite_params;
954 	uint8_t dev_id = ts_params->valid_devs[0];
955 	struct rte_cryptodev_info dev_info;
956 	const enum rte_crypto_aead_algorithm aeads[] = {
957 		RTE_CRYPTO_AEAD_AES_CCM
958 	};
959 
960 	rte_cryptodev_info_get(dev_id, &dev_info);
961 
962 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
963 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
964 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
965 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
966 				"testsuite not met\n");
967 		return TEST_SKIPPED;
968 	}
969 
970 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
971 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
972 				"testsuite not met\n");
973 		return TEST_SKIPPED;
974 	}
975 
976 	return 0;
977 }
978 
979 static int
980 aes_gcm_auth_testsuite_setup(void)
981 {
982 	struct crypto_testsuite_params *ts_params = &testsuite_params;
983 	uint8_t dev_id = ts_params->valid_devs[0];
984 	struct rte_cryptodev_info dev_info;
985 	const enum rte_crypto_aead_algorithm aeads[] = {
986 		RTE_CRYPTO_AEAD_AES_GCM
987 	};
988 
989 	rte_cryptodev_info_get(dev_id, &dev_info);
990 
991 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
992 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
993 				"testsuite not met\n");
994 		return TEST_SKIPPED;
995 	}
996 
997 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
998 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
999 				"testsuite not met\n");
1000 		return TEST_SKIPPED;
1001 	}
1002 
1003 	return 0;
1004 }
1005 
1006 static int
1007 aes_gmac_auth_testsuite_setup(void)
1008 {
1009 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1010 	uint8_t dev_id = ts_params->valid_devs[0];
1011 	struct rte_cryptodev_info dev_info;
1012 	const enum rte_crypto_auth_algorithm auths[] = {
1013 		RTE_CRYPTO_AUTH_AES_GMAC
1014 	};
1015 
1016 	rte_cryptodev_info_get(dev_id, &dev_info);
1017 
1018 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1019 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1020 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1021 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1022 				"testsuite not met\n");
1023 		return TEST_SKIPPED;
1024 	}
1025 
1026 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1027 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1028 				"testsuite not met\n");
1029 		return TEST_SKIPPED;
1030 	}
1031 
1032 	return 0;
1033 }
1034 
1035 static int
1036 chacha20_poly1305_testsuite_setup(void)
1037 {
1038 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1039 	uint8_t dev_id = ts_params->valid_devs[0];
1040 	struct rte_cryptodev_info dev_info;
1041 	const enum rte_crypto_aead_algorithm aeads[] = {
1042 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1043 	};
1044 
1045 	rte_cryptodev_info_get(dev_id, &dev_info);
1046 
1047 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1048 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1049 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1050 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1051 				"Chacha20-Poly1305 testsuite not met\n");
1052 		return TEST_SKIPPED;
1053 	}
1054 
1055 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1056 		RTE_LOG(INFO, USER1, "Capability requirements for "
1057 				"Chacha20-Poly1305 testsuite not met\n");
1058 		return TEST_SKIPPED;
1059 	}
1060 
1061 	return 0;
1062 }
1063 
1064 static int
1065 snow3g_testsuite_setup(void)
1066 {
1067 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1068 	uint8_t dev_id = ts_params->valid_devs[0];
1069 	struct rte_cryptodev_info dev_info;
1070 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1071 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1072 
1073 	};
1074 	const enum rte_crypto_auth_algorithm auths[] = {
1075 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1076 	};
1077 
1078 	rte_cryptodev_info_get(dev_id, &dev_info);
1079 
1080 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1081 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1082 				"testsuite not met\n");
1083 		return TEST_SKIPPED;
1084 	}
1085 
1086 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1087 			&& check_auth_capabilities_supported(auths,
1088 			RTE_DIM(auths)) != 0) {
1089 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1090 				"testsuite not met\n");
1091 		return TEST_SKIPPED;
1092 	}
1093 
1094 	return 0;
1095 }
1096 
1097 static int
1098 zuc_testsuite_setup(void)
1099 {
1100 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1101 	uint8_t dev_id = ts_params->valid_devs[0];
1102 	struct rte_cryptodev_info dev_info;
1103 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1104 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1105 	};
1106 	const enum rte_crypto_auth_algorithm auths[] = {
1107 		RTE_CRYPTO_AUTH_ZUC_EIA3
1108 	};
1109 
1110 	rte_cryptodev_info_get(dev_id, &dev_info);
1111 
1112 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1113 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1114 				"testsuite not met\n");
1115 		return TEST_SKIPPED;
1116 	}
1117 
1118 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1119 			&& check_auth_capabilities_supported(auths,
1120 			RTE_DIM(auths)) != 0) {
1121 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1122 				"testsuite not met\n");
1123 		return TEST_SKIPPED;
1124 	}
1125 
1126 	return 0;
1127 }
1128 
1129 static int
1130 hmac_md5_auth_testsuite_setup(void)
1131 {
1132 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1133 	uint8_t dev_id = ts_params->valid_devs[0];
1134 	struct rte_cryptodev_info dev_info;
1135 	const enum rte_crypto_auth_algorithm auths[] = {
1136 		RTE_CRYPTO_AUTH_MD5_HMAC
1137 	};
1138 
1139 	rte_cryptodev_info_get(dev_id, &dev_info);
1140 
1141 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1142 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1143 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1144 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1145 				"Auth testsuite not met\n");
1146 		return TEST_SKIPPED;
1147 	}
1148 
1149 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1150 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1151 				"testsuite not met\n");
1152 		return TEST_SKIPPED;
1153 	}
1154 
1155 	return 0;
1156 }
1157 
1158 static int
1159 kasumi_testsuite_setup(void)
1160 {
1161 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1162 	uint8_t dev_id = ts_params->valid_devs[0];
1163 	struct rte_cryptodev_info dev_info;
1164 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1165 		RTE_CRYPTO_CIPHER_KASUMI_F8
1166 	};
1167 	const enum rte_crypto_auth_algorithm auths[] = {
1168 		RTE_CRYPTO_AUTH_KASUMI_F9
1169 	};
1170 
1171 	rte_cryptodev_info_get(dev_id, &dev_info);
1172 
1173 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1174 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1175 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1176 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1177 				"testsuite not met\n");
1178 		return TEST_SKIPPED;
1179 	}
1180 
1181 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1182 			&& check_auth_capabilities_supported(auths,
1183 			RTE_DIM(auths)) != 0) {
1184 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1185 				"testsuite not met\n");
1186 		return TEST_SKIPPED;
1187 	}
1188 
1189 	return 0;
1190 }
1191 
1192 static int
1193 negative_aes_gcm_testsuite_setup(void)
1194 {
1195 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1196 	uint8_t dev_id = ts_params->valid_devs[0];
1197 	struct rte_cryptodev_info dev_info;
1198 	const enum rte_crypto_aead_algorithm aeads[] = {
1199 		RTE_CRYPTO_AEAD_AES_GCM
1200 	};
1201 
1202 	rte_cryptodev_info_get(dev_id, &dev_info);
1203 
1204 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1205 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1206 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1207 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1208 				"AES GCM testsuite not met\n");
1209 		return TEST_SKIPPED;
1210 	}
1211 
1212 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1213 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1214 				"AES GCM testsuite not met\n");
1215 		return TEST_SKIPPED;
1216 	}
1217 
1218 	return 0;
1219 }
1220 
1221 static int
1222 negative_aes_gmac_testsuite_setup(void)
1223 {
1224 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1225 	uint8_t dev_id = ts_params->valid_devs[0];
1226 	struct rte_cryptodev_info dev_info;
1227 	const enum rte_crypto_auth_algorithm auths[] = {
1228 		RTE_CRYPTO_AUTH_AES_GMAC
1229 	};
1230 
1231 	rte_cryptodev_info_get(dev_id, &dev_info);
1232 
1233 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1234 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1235 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1236 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1237 				"AES GMAC testsuite not met\n");
1238 		return TEST_SKIPPED;
1239 	}
1240 
1241 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1242 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1243 				"AES GMAC testsuite not met\n");
1244 		return TEST_SKIPPED;
1245 	}
1246 
1247 	return 0;
1248 }
1249 
1250 static int
1251 mixed_cipher_hash_testsuite_setup(void)
1252 {
1253 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1254 	uint8_t dev_id = ts_params->valid_devs[0];
1255 	struct rte_cryptodev_info dev_info;
1256 	uint64_t feat_flags;
1257 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1258 		RTE_CRYPTO_CIPHER_NULL,
1259 		RTE_CRYPTO_CIPHER_AES_CTR,
1260 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1261 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1262 	};
1263 	const enum rte_crypto_auth_algorithm auths[] = {
1264 		RTE_CRYPTO_AUTH_NULL,
1265 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1266 		RTE_CRYPTO_AUTH_AES_CMAC,
1267 		RTE_CRYPTO_AUTH_ZUC_EIA3
1268 	};
1269 
1270 	rte_cryptodev_info_get(dev_id, &dev_info);
1271 	feat_flags = dev_info.feature_flags;
1272 
1273 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1274 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1275 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1276 				"Cipher Hash testsuite not met\n");
1277 		return TEST_SKIPPED;
1278 	}
1279 
1280 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1281 			&& check_auth_capabilities_supported(auths,
1282 			RTE_DIM(auths)) != 0) {
1283 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1284 				"Cipher Hash testsuite not met\n");
1285 		return TEST_SKIPPED;
1286 	}
1287 
1288 	return 0;
1289 }
1290 
1291 static int
1292 esn_testsuite_setup(void)
1293 {
1294 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1295 	uint8_t dev_id = ts_params->valid_devs[0];
1296 	struct rte_cryptodev_info dev_info;
1297 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1298 		RTE_CRYPTO_CIPHER_AES_CBC
1299 	};
1300 	const enum rte_crypto_auth_algorithm auths[] = {
1301 		RTE_CRYPTO_AUTH_SHA1_HMAC
1302 	};
1303 
1304 	rte_cryptodev_info_get(dev_id, &dev_info);
1305 
1306 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1307 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1308 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1309 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1310 				"testsuite not met\n");
1311 		return TEST_SKIPPED;
1312 	}
1313 
1314 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1315 			&& check_auth_capabilities_supported(auths,
1316 			RTE_DIM(auths)) != 0) {
1317 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1318 				"testsuite not met\n");
1319 		return TEST_SKIPPED;
1320 	}
1321 
1322 	return 0;
1323 }
1324 
1325 static int
1326 multi_session_testsuite_setup(void)
1327 {
1328 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1329 	uint8_t dev_id = ts_params->valid_devs[0];
1330 	struct rte_cryptodev_info dev_info;
1331 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1332 		RTE_CRYPTO_CIPHER_AES_CBC
1333 	};
1334 	const enum rte_crypto_auth_algorithm auths[] = {
1335 		RTE_CRYPTO_AUTH_SHA512_HMAC
1336 	};
1337 
1338 	rte_cryptodev_info_get(dev_id, &dev_info);
1339 
1340 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1341 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1342 				"Session testsuite not met\n");
1343 		return TEST_SKIPPED;
1344 	}
1345 
1346 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1347 			&& check_auth_capabilities_supported(auths,
1348 			RTE_DIM(auths)) != 0) {
1349 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1350 				"Session testsuite not met\n");
1351 		return TEST_SKIPPED;
1352 	}
1353 
1354 	return 0;
1355 }
1356 
1357 static int
1358 negative_hmac_sha1_testsuite_setup(void)
1359 {
1360 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1361 	uint8_t dev_id = ts_params->valid_devs[0];
1362 	struct rte_cryptodev_info dev_info;
1363 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1364 		RTE_CRYPTO_CIPHER_AES_CBC
1365 	};
1366 	const enum rte_crypto_auth_algorithm auths[] = {
1367 		RTE_CRYPTO_AUTH_SHA1_HMAC
1368 	};
1369 
1370 	rte_cryptodev_info_get(dev_id, &dev_info);
1371 
1372 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1373 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1374 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1375 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1376 				"HMAC SHA1 testsuite not met\n");
1377 		return TEST_SKIPPED;
1378 	}
1379 
1380 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1381 			&& check_auth_capabilities_supported(auths,
1382 			RTE_DIM(auths)) != 0) {
1383 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1384 				"HMAC SHA1 testsuite not met\n");
1385 		return TEST_SKIPPED;
1386 	}
1387 
1388 	return 0;
1389 }
1390 
1391 static int
1392 dev_configure_and_start(uint64_t ff_disable)
1393 {
1394 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1395 	struct crypto_unittest_params *ut_params = &unittest_params;
1396 
1397 	uint16_t qp_id;
1398 
1399 	/* Clear unit test parameters before running test */
1400 	memset(ut_params, 0, sizeof(*ut_params));
1401 
1402 	/* Reconfigure device to default parameters */
1403 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1404 	ts_params->conf.ff_disable = ff_disable;
1405 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1406 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1407 
1408 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1409 			&ts_params->conf),
1410 			"Failed to configure cryptodev %u",
1411 			ts_params->valid_devs[0]);
1412 
1413 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1414 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1415 			ts_params->valid_devs[0], qp_id,
1416 			&ts_params->qp_conf,
1417 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1418 			"Failed to setup queue pair %u on cryptodev %u",
1419 			qp_id, ts_params->valid_devs[0]);
1420 	}
1421 
1422 
1423 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1424 
1425 	/* Start the device */
1426 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1427 			"Failed to start cryptodev %u",
1428 			ts_params->valid_devs[0]);
1429 
1430 	return TEST_SUCCESS;
1431 }
1432 
1433 int
1434 ut_setup(void)
1435 {
1436 	/* Configure and start the device with security feature disabled */
1437 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1438 }
1439 
1440 static int
1441 ut_setup_security(void)
1442 {
1443 	/* Configure and start the device with no features disabled */
1444 	return dev_configure_and_start(0);
1445 }
1446 
1447 static int
1448 ut_setup_security_rx_inject(void)
1449 {
1450 	struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1451 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1452 	struct rte_eth_conf port_conf = {
1453 		.rxmode = {
1454 			.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1455 				    RTE_ETH_RX_OFFLOAD_SECURITY,
1456 		},
1457 		.txmode = {
1458 			.offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1459 		},
1460 		.lpbk_mode = 1,  /* Enable loopback */
1461 	};
1462 	struct rte_cryptodev_info dev_info;
1463 	struct rte_eth_rxconf rx_conf = {
1464 		.rx_thresh = {
1465 			.pthresh = 8,
1466 			.hthresh = 8,
1467 			.wthresh = 8,
1468 		},
1469 		.rx_free_thresh = 32,
1470 	};
1471 	uint16_t nb_ports;
1472 	void *sec_ctx;
1473 	int ret;
1474 
1475 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1476 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1477 	    !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1478 		RTE_LOG(INFO, USER1,
1479 			"Feature requirements for IPsec Rx inject test case not met\n");
1480 		return TEST_SKIPPED;
1481 	}
1482 
1483 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1484 	if (sec_ctx == NULL)
1485 		return TEST_SKIPPED;
1486 
1487 	nb_ports = rte_eth_dev_count_avail();
1488 	if (nb_ports == 0)
1489 		return TEST_SKIPPED;
1490 
1491 	ret = rte_eth_dev_configure(0 /* port_id */,
1492 				    1 /* nb_rx_queue */,
1493 				    0 /* nb_tx_queue */,
1494 				    &port_conf);
1495 	if (ret) {
1496 		printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1497 		return TEST_SKIPPED;
1498 	}
1499 
1500 	/* Rx queue setup */
1501 	ret = rte_eth_rx_queue_setup(0 /* port_id */,
1502 				     0 /* rx_queue_id */,
1503 				     1024 /* nb_rx_desc */,
1504 				     SOCKET_ID_ANY,
1505 				     &rx_conf,
1506 				     mbuf_pool);
1507 	if (ret) {
1508 		printf("Could not setup eth port 0 queue 0\n");
1509 		return TEST_SKIPPED;
1510 	}
1511 
1512 	ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1513 	if (ret) {
1514 		printf("Could not enable Rx inject offload");
1515 		return TEST_SKIPPED;
1516 	}
1517 
1518 	ret = rte_eth_dev_start(0);
1519 	if (ret) {
1520 		printf("Could not start ethdev");
1521 		return TEST_SKIPPED;
1522 	}
1523 
1524 	ret = rte_eth_promiscuous_enable(0);
1525 	if (ret) {
1526 		printf("Could not enable promiscuous mode");
1527 		return TEST_SKIPPED;
1528 	}
1529 
1530 	/* Configure and start cryptodev with no features disabled */
1531 	return dev_configure_and_start(0);
1532 }
1533 
1534 static inline void
1535 ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1536 {
1537 }
1538 
1539 static inline void
1540 ext_mbuf_memzone_free(int nb_segs)
1541 {
1542 	int i;
1543 
1544 	for (i = 0; i <= nb_segs; i++) {
1545 		char mz_name[RTE_MEMZONE_NAMESIZE];
1546 		const struct rte_memzone *memzone;
1547 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1548 		memzone = rte_memzone_lookup(mz_name);
1549 		if (memzone != NULL) {
1550 			rte_memzone_free(memzone);
1551 			memzone = NULL;
1552 		}
1553 	}
1554 }
1555 
1556 static inline struct rte_mbuf *
1557 ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1558 		int nb_segs, const void *input_text)
1559 {
1560 	struct rte_mbuf *m = NULL, *mbuf = NULL;
1561 	size_t data_off = 0;
1562 	uint8_t *dst;
1563 	int i, size;
1564 	int t_len;
1565 
1566 	if (pkt_len < 1) {
1567 		printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1568 		return NULL;
1569 	}
1570 
1571 	if (nb_segs < 1) {
1572 		printf("Number of segments must be 1 or more (is %d)\n",
1573 				nb_segs);
1574 		return NULL;
1575 	}
1576 
1577 	t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1578 	size = pkt_len;
1579 
1580 	/* Create chained mbuf_src with external buffer */
1581 	for (i = 0; size > 0; i++) {
1582 		struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1583 		uint16_t data_len = RTE_MIN(size, t_len);
1584 		char mz_name[RTE_MEMZONE_NAMESIZE];
1585 		const struct rte_memzone *memzone;
1586 		void *ext_buf_addr = NULL;
1587 		rte_iova_t buf_iova;
1588 		bool freed = false;
1589 		uint16_t buf_len;
1590 
1591 		buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1592 			sizeof(struct rte_mbuf_ext_shared_info), 8);
1593 
1594 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1595 		memzone = rte_memzone_lookup(mz_name);
1596 		if (memzone != NULL && memzone->len != buf_len) {
1597 			rte_memzone_free(memzone);
1598 			memzone = NULL;
1599 		}
1600 		if (memzone == NULL) {
1601 			memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1602 				RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1603 			if (memzone == NULL) {
1604 				printf("Can't allocate memory zone %s\n", mz_name);
1605 				return NULL;
1606 			}
1607 		}
1608 
1609 		ext_buf_addr = memzone->addr;
1610 		if (input_text)
1611 			memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1612 
1613 		/* Create buffer to hold rte_mbuf header */
1614 		m = rte_pktmbuf_alloc(mbuf_pool);
1615 		if (i == 0)
1616 			mbuf = m;
1617 
1618 		if (m == NULL) {
1619 			printf("Cannot create segment for source mbuf");
1620 			goto fail;
1621 		}
1622 
1623 		/* Save shared data (like callback function) in external buffer's end */
1624 		ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1625 			ext_mbuf_callback_fn_free, &freed);
1626 		if (ret_shinfo == NULL) {
1627 			printf("Shared mem initialization failed!\n");
1628 			goto fail;
1629 		}
1630 
1631 		buf_iova = rte_mem_virt2iova(ext_buf_addr);
1632 
1633 		/* Attach external buffer to mbuf */
1634 		rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1635 			ret_shinfo);
1636 		if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1637 			printf("External buffer is not attached to mbuf\n");
1638 			goto fail;
1639 		}
1640 
1641 		if (input_text) {
1642 			dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1643 			if (dst == NULL) {
1644 				printf("Cannot append %d bytes to the mbuf\n", data_len);
1645 				goto fail;
1646 			}
1647 		}
1648 
1649 		if (mbuf != m)
1650 			rte_pktmbuf_chain(mbuf, m);
1651 
1652 		size -= data_len;
1653 		data_off += data_len;
1654 	}
1655 
1656 	return mbuf;
1657 
1658 fail:
1659 	rte_pktmbuf_free(mbuf);
1660 	ext_mbuf_memzone_free(nb_segs);
1661 	return NULL;
1662 }
1663 
1664 void
1665 ut_teardown(void)
1666 {
1667 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1668 	struct crypto_unittest_params *ut_params = &unittest_params;
1669 
1670 	/* free crypto session structure */
1671 #ifdef RTE_LIB_SECURITY
1672 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1673 		if (ut_params->sec_session) {
1674 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1675 						(ts_params->valid_devs[0]),
1676 						ut_params->sec_session);
1677 			ut_params->sec_session = NULL;
1678 		}
1679 	} else
1680 #endif
1681 	{
1682 		if (ut_params->sess) {
1683 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1684 					ut_params->sess);
1685 			ut_params->sess = NULL;
1686 		}
1687 	}
1688 
1689 	/* free crypto operation structure */
1690 	rte_crypto_op_free(ut_params->op);
1691 
1692 	/*
1693 	 * free mbuf - both obuf and ibuf are usually the same,
1694 	 * so check if they point at the same address is necessary,
1695 	 * to avoid freeing the mbuf twice.
1696 	 */
1697 	if (ut_params->obuf) {
1698 		rte_pktmbuf_free(ut_params->obuf);
1699 		if (ut_params->ibuf == ut_params->obuf)
1700 			ut_params->ibuf = 0;
1701 		ut_params->obuf = 0;
1702 	}
1703 	if (ut_params->ibuf) {
1704 		ext_mbuf_memzone_free(1);
1705 		rte_pktmbuf_free(ut_params->ibuf);
1706 		ut_params->ibuf = 0;
1707 	}
1708 
1709 	if (ts_params->mbuf_pool != NULL)
1710 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1711 			rte_mempool_avail_count(ts_params->mbuf_pool));
1712 
1713 	/* Stop the device */
1714 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1715 }
1716 
1717 static void
1718 ut_teardown_rx_inject(void)
1719 {
1720 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1721 	void *sec_ctx;
1722 	int ret;
1723 
1724 	if  (rte_eth_dev_count_avail() != 0) {
1725 		ret = rte_eth_dev_reset(0);
1726 		if (ret)
1727 			printf("Could not reset eth port 0");
1728 
1729 	}
1730 
1731 	ut_teardown();
1732 
1733 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1734 	if (sec_ctx == NULL)
1735 		return;
1736 
1737 	ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1738 	if (ret) {
1739 		printf("Could not disable Rx inject offload");
1740 		return;
1741 	}
1742 }
1743 
1744 static int
1745 test_device_configure_invalid_dev_id(void)
1746 {
1747 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1748 	uint16_t dev_id, num_devs = 0;
1749 
1750 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1751 			"Need at least %d devices for test", 1);
1752 
1753 	/* valid dev_id values */
1754 	dev_id = ts_params->valid_devs[0];
1755 
1756 	/* Stop the device in case it's started so it can be configured */
1757 	rte_cryptodev_stop(dev_id);
1758 
1759 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1760 			"Failed test for rte_cryptodev_configure: "
1761 			"invalid dev_num %u", dev_id);
1762 
1763 	/* invalid dev_id values */
1764 	dev_id = num_devs;
1765 
1766 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1767 			"Failed test for rte_cryptodev_configure: "
1768 			"invalid dev_num %u", dev_id);
1769 
1770 	dev_id = 0xff;
1771 
1772 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1773 			"Failed test for rte_cryptodev_configure:"
1774 			"invalid dev_num %u", dev_id);
1775 
1776 	return TEST_SUCCESS;
1777 }
1778 
1779 static int
1780 test_device_configure_invalid_queue_pair_ids(void)
1781 {
1782 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1783 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1784 
1785 	/* Stop the device in case it's started so it can be configured */
1786 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1787 
1788 	/* valid - max value queue pairs */
1789 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1790 
1791 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1792 			&ts_params->conf),
1793 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1794 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1795 
1796 	/* valid - one queue pairs */
1797 	ts_params->conf.nb_queue_pairs = 1;
1798 
1799 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1800 			&ts_params->conf),
1801 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1802 			ts_params->valid_devs[0],
1803 			ts_params->conf.nb_queue_pairs);
1804 
1805 
1806 	/* invalid - zero queue pairs */
1807 	ts_params->conf.nb_queue_pairs = 0;
1808 
1809 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1810 			&ts_params->conf),
1811 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1812 			" invalid qps: %u",
1813 			ts_params->valid_devs[0],
1814 			ts_params->conf.nb_queue_pairs);
1815 
1816 
1817 	/* invalid - max value supported by field queue pairs */
1818 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1819 
1820 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1821 			&ts_params->conf),
1822 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1823 			" invalid qps: %u",
1824 			ts_params->valid_devs[0],
1825 			ts_params->conf.nb_queue_pairs);
1826 
1827 
1828 	/* invalid - max value + 1 queue pairs */
1829 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1830 
1831 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1832 			&ts_params->conf),
1833 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1834 			" invalid qps: %u",
1835 			ts_params->valid_devs[0],
1836 			ts_params->conf.nb_queue_pairs);
1837 
1838 	/* revert to original testsuite value */
1839 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1840 
1841 	return TEST_SUCCESS;
1842 }
1843 
1844 static int
1845 test_queue_pair_descriptor_setup(void)
1846 {
1847 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1848 	struct rte_cryptodev_qp_conf qp_conf = {
1849 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1850 	};
1851 	uint16_t qp_id;
1852 
1853 	/* Stop the device in case it's started so it can be configured */
1854 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1855 
1856 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1857 			&ts_params->conf),
1858 			"Failed to configure cryptodev %u",
1859 			ts_params->valid_devs[0]);
1860 
1861 	/*
1862 	 * Test various ring sizes on this device. memzones can't be
1863 	 * freed so are re-used if ring is released and re-created.
1864 	 */
1865 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1866 	qp_conf.mp_session = ts_params->session_mpool;
1867 
1868 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1869 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1870 				ts_params->valid_devs[0], qp_id, &qp_conf,
1871 				rte_cryptodev_socket_id(
1872 						ts_params->valid_devs[0])),
1873 				"Failed test for "
1874 				"rte_cryptodev_queue_pair_setup: num_inflights "
1875 				"%u on qp %u on cryptodev %u",
1876 				qp_conf.nb_descriptors, qp_id,
1877 				ts_params->valid_devs[0]);
1878 	}
1879 
1880 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1881 
1882 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1883 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1884 				ts_params->valid_devs[0], qp_id, &qp_conf,
1885 				rte_cryptodev_socket_id(
1886 						ts_params->valid_devs[0])),
1887 				"Failed test for"
1888 				" rte_cryptodev_queue_pair_setup: num_inflights"
1889 				" %u on qp %u on cryptodev %u",
1890 				qp_conf.nb_descriptors, qp_id,
1891 				ts_params->valid_devs[0]);
1892 	}
1893 
1894 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1895 
1896 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1897 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1898 				ts_params->valid_devs[0], qp_id, &qp_conf,
1899 				rte_cryptodev_socket_id(
1900 						ts_params->valid_devs[0])),
1901 				"Failed test for "
1902 				"rte_cryptodev_queue_pair_setup: num_inflights"
1903 				" %u on qp %u on cryptodev %u",
1904 				qp_conf.nb_descriptors, qp_id,
1905 				ts_params->valid_devs[0]);
1906 	}
1907 
1908 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1909 
1910 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1911 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1912 				ts_params->valid_devs[0], qp_id, &qp_conf,
1913 				rte_cryptodev_socket_id(
1914 						ts_params->valid_devs[0])),
1915 				"Failed test for"
1916 				" rte_cryptodev_queue_pair_setup:"
1917 				"num_inflights %u on qp %u on cryptodev %u",
1918 				qp_conf.nb_descriptors, qp_id,
1919 				ts_params->valid_devs[0]);
1920 	}
1921 
1922 	/* test invalid queue pair id */
1923 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1924 
1925 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1926 
1927 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1928 			ts_params->valid_devs[0],
1929 			qp_id, &qp_conf,
1930 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1931 			"Failed test for rte_cryptodev_queue_pair_setup:"
1932 			"invalid qp %u on cryptodev %u",
1933 			qp_id, ts_params->valid_devs[0]);
1934 
1935 	qp_id = 0xffff; /*invalid*/
1936 
1937 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1938 			ts_params->valid_devs[0],
1939 			qp_id, &qp_conf,
1940 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1941 			"Failed test for rte_cryptodev_queue_pair_setup:"
1942 			"invalid qp %u on cryptodev %u",
1943 			qp_id, ts_params->valid_devs[0]);
1944 
1945 	return TEST_SUCCESS;
1946 }
1947 
1948 /* ***** Plaintext data for tests ***** */
1949 
1950 const char catch_22_quote_1[] =
1951 		"There was only one catch and that was Catch-22, which "
1952 		"specified that a concern for one's safety in the face of "
1953 		"dangers that were real and immediate was the process of a "
1954 		"rational mind. Orr was crazy and could be grounded. All he "
1955 		"had to do was ask; and as soon as he did, he would no longer "
1956 		"be crazy and would have to fly more missions. Orr would be "
1957 		"crazy to fly more missions and sane if he didn't, but if he "
1958 		"was sane he had to fly them. If he flew them he was crazy "
1959 		"and didn't have to; but if he didn't want to he was sane and "
1960 		"had to. Yossarian was moved very deeply by the absolute "
1961 		"simplicity of this clause of Catch-22 and let out a "
1962 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1963 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1964 
1965 const char catch_22_quote[] =
1966 		"What a lousy earth! He wondered how many people were "
1967 		"destitute that same night even in his own prosperous country, "
1968 		"how many homes were shanties, how many husbands were drunk "
1969 		"and wives socked, and how many children were bullied, abused, "
1970 		"or abandoned. How many families hungered for food they could "
1971 		"not afford to buy? How many hearts were broken? How many "
1972 		"suicides would take place that same night, how many people "
1973 		"would go insane? How many cockroaches and landlords would "
1974 		"triumph? How many winners were losers, successes failures, "
1975 		"and rich men poor men? How many wise guys were stupid? How "
1976 		"many happy endings were unhappy endings? How many honest men "
1977 		"were liars, brave men cowards, loyal men traitors, how many "
1978 		"sainted men were corrupt, how many people in positions of "
1979 		"trust had sold their souls to bodyguards, how many had never "
1980 		"had souls? How many straight-and-narrow paths were crooked "
1981 		"paths? How many best families were worst families and how "
1982 		"many good people were bad people? When you added them all up "
1983 		"and then subtracted, you might be left with only the children, "
1984 		"and perhaps with Albert Einstein and an old violinist or "
1985 		"sculptor somewhere.";
1986 
1987 #define QUOTE_480_BYTES		(480)
1988 #define QUOTE_512_BYTES		(512)
1989 #define QUOTE_768_BYTES		(768)
1990 #define QUOTE_1024_BYTES	(1024)
1991 
1992 
1993 
1994 /* ***** SHA1 Hash Tests ***** */
1995 
1996 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1997 
1998 static uint8_t hmac_sha1_key[] = {
1999 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
2000 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
2001 	0xDE, 0xF4, 0xDE, 0xAD };
2002 
2003 /* ***** SHA224 Hash Tests ***** */
2004 
2005 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
2006 
2007 
2008 /* ***** AES-CBC Cipher Tests ***** */
2009 
2010 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
2011 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
2012 
2013 static uint8_t aes_cbc_key[] = {
2014 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2015 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2016 
2017 static uint8_t aes_cbc_iv[] = {
2018 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2019 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2020 
2021 
2022 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2023 
2024 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2025 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2026 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2027 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2028 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2029 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2030 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2031 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2032 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2033 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2034 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2035 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2036 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2037 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2038 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2039 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2040 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2041 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2042 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2043 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2044 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2045 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2046 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2047 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2048 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2049 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2050 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2051 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2052 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2053 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2054 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2055 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2056 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2057 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2058 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2059 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2060 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2061 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2062 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2063 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2064 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2065 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2066 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2067 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2068 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2069 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2070 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2071 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2072 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2073 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2074 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2075 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2076 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2077 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2078 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2079 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2080 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2081 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2082 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2083 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2084 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2085 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2086 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2087 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2088 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2089 };
2090 
2091 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2092 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2093 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2094 	0x18, 0x8c, 0x1d, 0x32
2095 };
2096 
2097 
2098 /* Multisession Vector context Test */
2099 /*Begin Session 0 */
2100 static uint8_t ms_aes_cbc_key0[] = {
2101 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2102 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2103 };
2104 
2105 static uint8_t ms_aes_cbc_iv0[] = {
2106 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2107 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2108 };
2109 
2110 static const uint8_t ms_aes_cbc_cipher0[] = {
2111 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2112 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2113 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2114 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2115 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2116 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2117 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2118 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2119 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2120 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2121 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2122 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2123 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2124 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2125 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2126 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2127 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2128 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2129 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2130 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2131 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2132 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2133 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2134 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2135 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2136 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2137 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2138 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2139 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2140 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2141 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2142 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2143 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2144 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2145 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2146 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2147 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2148 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2149 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2150 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2151 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2152 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2153 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2154 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2155 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2156 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2157 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2158 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2159 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2160 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2161 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2162 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2163 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2164 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2165 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2166 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2167 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2168 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2169 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2170 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2171 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2172 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2173 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2174 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2175 };
2176 
2177 
2178 static  uint8_t ms_hmac_key0[] = {
2179 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2180 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2181 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2182 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2183 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2184 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2185 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2186 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2187 };
2188 
2189 static const uint8_t ms_hmac_digest0[] = {
2190 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2191 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2192 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2193 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2194 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2195 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2196 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2197 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2198 		};
2199 
2200 /* End Session 0 */
2201 /* Begin session 1 */
2202 
2203 static  uint8_t ms_aes_cbc_key1[] = {
2204 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2205 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2206 };
2207 
2208 static  uint8_t ms_aes_cbc_iv1[] = {
2209 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2210 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2211 };
2212 
2213 static const uint8_t ms_aes_cbc_cipher1[] = {
2214 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2215 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2216 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2217 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2218 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2219 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2220 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2221 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2222 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2223 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2224 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2225 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2226 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2227 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2228 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2229 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2230 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2231 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2232 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2233 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2234 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2235 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2236 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2237 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2238 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2239 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2240 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2241 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2242 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2243 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2244 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2245 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2246 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2247 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2248 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2249 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2250 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2251 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2252 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2253 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2254 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2255 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2256 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2257 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2258 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2259 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2260 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2261 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2262 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2263 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2264 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2265 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2266 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2267 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2268 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2269 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2270 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2271 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2272 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2273 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2274 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2275 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2276 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2277 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2278 
2279 };
2280 
2281 static uint8_t ms_hmac_key1[] = {
2282 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2283 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2284 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2285 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2286 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2287 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2288 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2289 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2290 };
2291 
2292 static const uint8_t ms_hmac_digest1[] = {
2293 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2294 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2295 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2296 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2297 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2298 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2299 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2300 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2301 };
2302 /* End Session 1  */
2303 /* Begin Session 2 */
2304 static  uint8_t ms_aes_cbc_key2[] = {
2305 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2306 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2307 };
2308 
2309 static  uint8_t ms_aes_cbc_iv2[] = {
2310 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2311 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2312 };
2313 
2314 static const uint8_t ms_aes_cbc_cipher2[] = {
2315 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2316 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2317 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2318 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2319 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2320 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2321 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2322 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2323 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2324 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2325 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2326 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2327 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2328 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2329 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2330 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2331 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2332 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2333 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2334 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2335 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2336 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2337 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2338 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2339 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2340 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2341 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2342 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2343 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2344 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2345 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2346 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2347 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2348 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2349 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2350 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2351 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2352 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2353 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2354 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2355 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2356 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2357 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2358 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2359 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2360 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2361 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2362 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2363 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2364 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2365 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2366 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2367 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2368 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2369 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2370 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2371 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2372 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2373 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2374 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2375 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2376 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2377 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2378 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2379 };
2380 
2381 static  uint8_t ms_hmac_key2[] = {
2382 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2383 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2384 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2385 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2386 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2387 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2388 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2389 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2390 };
2391 
2392 static const uint8_t ms_hmac_digest2[] = {
2393 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2394 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2395 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2396 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2397 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2398 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2399 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2400 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2401 };
2402 
2403 /* End Session 2 */
2404 
2405 #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
2406 static int
2407 test_queue_pair_descriptor_count(void)
2408 {
2409 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2410 	struct crypto_unittest_params *ut_params = &unittest_params;
2411 	struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
2412 	struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
2413 	struct rte_cryptodev_sym_capability_idx cap_idx;
2414 	int qp_depth = 0;
2415 	int i;
2416 
2417 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
2418 
2419 	/* Verify if the queue pair depth API is supported by driver */
2420 	qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2421 	if (qp_depth == -ENOTSUP)
2422 		return TEST_SKIPPED;
2423 
2424 	/* Verify the capabilities */
2425 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2426 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2427 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2428 		return TEST_SKIPPED;
2429 
2430 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2431 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2432 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2433 		return TEST_SKIPPED;
2434 
2435 	/* Setup Cipher Parameters */
2436 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2437 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2438 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2439 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2440 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2441 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2442 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2443 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2444 
2445 	/* Setup HMAC Parameters */
2446 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2447 	ut_params->auth_xform.next = NULL;
2448 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2449 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2450 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2451 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2452 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2453 
2454 	rte_errno = 0;
2455 	ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
2456 			&ut_params->cipher_xform, ts_params->session_mpool);
2457 	if (rte_errno == ENOTSUP)
2458 		return TEST_SKIPPED;
2459 
2460 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2461 
2462 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
2463 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
2464 			MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
2465 
2466 	/* Generate crypto op data structure */
2467 	for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2468 		struct rte_mbuf *m;
2469 		uint8_t *digest;
2470 
2471 		/* Generate test mbuf data and space for digest */
2472 		m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
2473 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
2474 
2475 		digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
2476 		TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
2477 
2478 		rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
2479 
2480 		/* set crypto operation source mbuf */
2481 		ops[i]->sym->m_src = m;
2482 
2483 		/* Set crypto operation authentication parameters */
2484 		ops[i]->sym->auth.digest.data = digest;
2485 		ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
2486 
2487 		ops[i]->sym->auth.data.offset = 0;
2488 		ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
2489 
2490 		/* Copy IV at the end of the crypto operation */
2491 		memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
2492 				CIPHER_IV_LENGTH_AES_CBC);
2493 
2494 		/* Set crypto operation cipher parameters */
2495 		ops[i]->sym->cipher.data.offset = 0;
2496 		ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
2497 
2498 		TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
2499 					&ops[i], 1), 1, "Error enqueuing");
2500 	}
2501 
2502 	for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2503 		qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2504 		TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
2505 			"Crypto queue pair depth used does not match with inflight ops");
2506 
2507 		while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
2508 					&ops_deq[i], 1) == 0)
2509 			rte_pause();
2510 
2511 		TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2512 				"crypto op processing failed");
2513 
2514 		rte_pktmbuf_free(ops_deq[i]->sym->m_src);
2515 		rte_crypto_op_free(ops_deq[i]);
2516 	}
2517 
2518 	return TEST_SUCCESS;
2519 }
2520 
2521 static int
2522 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2523 {
2524 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2525 	struct crypto_unittest_params *ut_params = &unittest_params;
2526 	/* Verify the capabilities */
2527 	struct rte_cryptodev_sym_capability_idx cap_idx;
2528 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2529 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2530 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2531 			&cap_idx) == NULL)
2532 		return TEST_SKIPPED;
2533 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2534 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2535 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2536 			&cap_idx) == NULL)
2537 		return TEST_SKIPPED;
2538 
2539 	/* Generate test mbuf data and space for digest */
2540 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2541 			catch_22_quote,	QUOTE_512_BYTES, 0);
2542 
2543 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2544 			DIGEST_BYTE_LENGTH_SHA1);
2545 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2546 
2547 	/* Setup Cipher Parameters */
2548 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2549 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2550 
2551 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2552 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2553 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2554 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2555 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2556 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2557 
2558 	/* Setup HMAC Parameters */
2559 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2560 
2561 	ut_params->auth_xform.next = NULL;
2562 
2563 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2564 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2565 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2566 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2567 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2568 
2569 	rte_errno = 0;
2570 	ut_params->sess = rte_cryptodev_sym_session_create(
2571 			ts_params->valid_devs[0], &ut_params->cipher_xform,
2572 			ts_params->session_mpool);
2573 	if (rte_errno == ENOTSUP)
2574 		return TEST_SKIPPED;
2575 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2576 
2577 	/* Generate crypto op data structure */
2578 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2579 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2580 	TEST_ASSERT_NOT_NULL(ut_params->op,
2581 			"Failed to allocate symmetric crypto operation struct");
2582 
2583 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2584 
2585 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2586 
2587 	/* set crypto operation source mbuf */
2588 	sym_op->m_src = ut_params->ibuf;
2589 
2590 	/* Set crypto operation authentication parameters */
2591 	sym_op->auth.digest.data = ut_params->digest;
2592 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2593 			ut_params->ibuf, QUOTE_512_BYTES);
2594 
2595 	sym_op->auth.data.offset = 0;
2596 	sym_op->auth.data.length = QUOTE_512_BYTES;
2597 
2598 	/* Copy IV at the end of the crypto operation */
2599 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2600 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2601 
2602 	/* Set crypto operation cipher parameters */
2603 	sym_op->cipher.data.offset = 0;
2604 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2605 
2606 	/* Process crypto operation */
2607 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2608 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2609 			ut_params->op);
2610 	else
2611 		TEST_ASSERT_NOT_NULL(
2612 			process_crypto_request(ts_params->valid_devs[0],
2613 				ut_params->op),
2614 				"failed to process sym crypto op");
2615 
2616 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2617 			"crypto op processing failed");
2618 
2619 	/* Validate obuf */
2620 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2621 			uint8_t *);
2622 
2623 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2624 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2625 			QUOTE_512_BYTES,
2626 			"ciphertext data not as expected");
2627 
2628 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2629 
2630 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2631 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2632 			gbl_driver_id == rte_cryptodev_driver_id_get(
2633 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2634 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2635 					DIGEST_BYTE_LENGTH_SHA1,
2636 			"Generated digest data not as expected");
2637 
2638 	return TEST_SUCCESS;
2639 }
2640 
2641 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2642 
2643 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2644 
2645 static uint8_t hmac_sha512_key[] = {
2646 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2647 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2648 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2649 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2650 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2651 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2652 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2653 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2654 
2655 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2656 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2657 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2658 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2659 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2660 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2661 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2662 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2663 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2664 
2665 
2666 
2667 static int
2668 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2669 		struct crypto_unittest_params *ut_params,
2670 		uint8_t *cipher_key,
2671 		uint8_t *hmac_key);
2672 
2673 static int
2674 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2675 		struct crypto_unittest_params *ut_params,
2676 		struct crypto_testsuite_params *ts_params,
2677 		const uint8_t *cipher,
2678 		const uint8_t *digest,
2679 		const uint8_t *iv);
2680 
2681 
2682 static int
2683 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2684 		struct crypto_unittest_params *ut_params,
2685 		uint8_t *cipher_key,
2686 		uint8_t *hmac_key)
2687 {
2688 
2689 	/* Setup Cipher Parameters */
2690 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2691 	ut_params->cipher_xform.next = NULL;
2692 
2693 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2694 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2695 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2696 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2697 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2698 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2699 
2700 	/* Setup HMAC Parameters */
2701 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2702 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2703 
2704 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2705 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2706 	ut_params->auth_xform.auth.key.data = hmac_key;
2707 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2708 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2709 
2710 	return TEST_SUCCESS;
2711 }
2712 
2713 
2714 static int
2715 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2716 		struct crypto_unittest_params *ut_params,
2717 		struct crypto_testsuite_params *ts_params,
2718 		const uint8_t *cipher,
2719 		const uint8_t *digest,
2720 		const uint8_t *iv)
2721 {
2722 	int ret;
2723 
2724 	/* Generate test mbuf data and digest */
2725 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2726 			(const char *)
2727 			cipher,
2728 			QUOTE_512_BYTES, 0);
2729 
2730 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2731 			DIGEST_BYTE_LENGTH_SHA512);
2732 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2733 
2734 	rte_memcpy(ut_params->digest,
2735 			digest,
2736 			DIGEST_BYTE_LENGTH_SHA512);
2737 
2738 	/* Generate Crypto op data structure */
2739 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2740 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2741 	TEST_ASSERT_NOT_NULL(ut_params->op,
2742 			"Failed to allocate symmetric crypto operation struct");
2743 
2744 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2745 
2746 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2747 
2748 	/* set crypto operation source mbuf */
2749 	sym_op->m_src = ut_params->ibuf;
2750 
2751 	sym_op->auth.digest.data = ut_params->digest;
2752 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2753 			ut_params->ibuf, QUOTE_512_BYTES);
2754 
2755 	sym_op->auth.data.offset = 0;
2756 	sym_op->auth.data.length = QUOTE_512_BYTES;
2757 
2758 	/* Copy IV at the end of the crypto operation */
2759 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2760 			iv, CIPHER_IV_LENGTH_AES_CBC);
2761 
2762 	sym_op->cipher.data.offset = 0;
2763 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2764 
2765 	/* Process crypto operation */
2766 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2767 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2768 			ut_params->op);
2769 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2770 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2771 		if (ret != TEST_SUCCESS)
2772 			return ret;
2773 	} else
2774 		TEST_ASSERT_NOT_NULL(
2775 				process_crypto_request(ts_params->valid_devs[0],
2776 					ut_params->op),
2777 					"failed to process sym crypto op");
2778 
2779 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2780 			"crypto op processing failed");
2781 
2782 	ut_params->obuf = ut_params->op->sym->m_src;
2783 
2784 	/* Validate obuf */
2785 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2786 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2787 			catch_22_quote,
2788 			QUOTE_512_BYTES,
2789 			"Plaintext data not as expected");
2790 
2791 	/* Validate obuf */
2792 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2793 			"Digest verification failed");
2794 
2795 	return TEST_SUCCESS;
2796 }
2797 
2798 /* ***** SNOW 3G Tests ***** */
2799 static int
2800 create_wireless_algo_hash_session(uint8_t dev_id,
2801 	const uint8_t *key, const uint8_t key_len,
2802 	const uint8_t iv_len, const uint8_t auth_len,
2803 	enum rte_crypto_auth_operation op,
2804 	enum rte_crypto_auth_algorithm algo)
2805 {
2806 	uint8_t hash_key[key_len];
2807 
2808 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2809 	struct crypto_unittest_params *ut_params = &unittest_params;
2810 
2811 	memcpy(hash_key, key, key_len);
2812 
2813 	debug_hexdump(stdout, "key:", key, key_len);
2814 
2815 	/* Setup Authentication Parameters */
2816 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2817 	ut_params->auth_xform.next = NULL;
2818 
2819 	ut_params->auth_xform.auth.op = op;
2820 	ut_params->auth_xform.auth.algo = algo;
2821 	ut_params->auth_xform.auth.key.length = key_len;
2822 	ut_params->auth_xform.auth.key.data = hash_key;
2823 	ut_params->auth_xform.auth.digest_length = auth_len;
2824 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2825 	ut_params->auth_xform.auth.iv.length = iv_len;
2826 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2827 			&ut_params->auth_xform, ts_params->session_mpool);
2828 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2829 		return TEST_SKIPPED;
2830 
2831 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2832 	return 0;
2833 }
2834 
2835 static int
2836 create_wireless_algo_cipher_session(uint8_t dev_id,
2837 			enum rte_crypto_cipher_operation op,
2838 			enum rte_crypto_cipher_algorithm algo,
2839 			const uint8_t *key, const uint8_t key_len,
2840 			uint8_t iv_len)
2841 {
2842 	uint8_t cipher_key[key_len];
2843 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2844 	struct crypto_unittest_params *ut_params = &unittest_params;
2845 
2846 	memcpy(cipher_key, key, key_len);
2847 
2848 	/* Setup Cipher Parameters */
2849 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2850 	ut_params->cipher_xform.next = NULL;
2851 
2852 	ut_params->cipher_xform.cipher.algo = algo;
2853 	ut_params->cipher_xform.cipher.op = op;
2854 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2855 	ut_params->cipher_xform.cipher.key.length = key_len;
2856 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2857 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2858 
2859 	debug_hexdump(stdout, "key:", key, key_len);
2860 
2861 	/* Create Crypto session */
2862 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2863 			&ut_params->cipher_xform, ts_params->session_mpool);
2864 
2865 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2866 		return TEST_SKIPPED;
2867 
2868 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2869 	return 0;
2870 }
2871 
2872 static int
2873 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2874 			unsigned int cipher_len,
2875 			unsigned int cipher_offset)
2876 {
2877 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2878 	struct crypto_unittest_params *ut_params = &unittest_params;
2879 
2880 	/* Generate Crypto op data structure */
2881 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2882 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2883 	TEST_ASSERT_NOT_NULL(ut_params->op,
2884 				"Failed to allocate pktmbuf offload");
2885 
2886 	/* Set crypto operation data parameters */
2887 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2888 
2889 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2890 
2891 	/* set crypto operation source mbuf */
2892 	sym_op->m_src = ut_params->ibuf;
2893 
2894 	/* iv */
2895 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2896 			iv, iv_len);
2897 	sym_op->cipher.data.length = cipher_len;
2898 	sym_op->cipher.data.offset = cipher_offset;
2899 	return 0;
2900 }
2901 
2902 static int
2903 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2904 			unsigned int cipher_len,
2905 			unsigned int cipher_offset)
2906 {
2907 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2908 	struct crypto_unittest_params *ut_params = &unittest_params;
2909 
2910 	/* Generate Crypto op data structure */
2911 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2912 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2913 	TEST_ASSERT_NOT_NULL(ut_params->op,
2914 				"Failed to allocate pktmbuf offload");
2915 
2916 	/* Set crypto operation data parameters */
2917 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2918 
2919 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2920 
2921 	/* set crypto operation source mbuf */
2922 	sym_op->m_src = ut_params->ibuf;
2923 	sym_op->m_dst = ut_params->obuf;
2924 
2925 	/* iv */
2926 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2927 			iv, iv_len);
2928 	sym_op->cipher.data.length = cipher_len;
2929 	sym_op->cipher.data.offset = cipher_offset;
2930 	return 0;
2931 }
2932 
2933 static int
2934 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2935 		enum rte_crypto_cipher_operation cipher_op,
2936 		enum rte_crypto_auth_operation auth_op,
2937 		enum rte_crypto_auth_algorithm auth_algo,
2938 		enum rte_crypto_cipher_algorithm cipher_algo,
2939 		const uint8_t *a_key, uint8_t a_key_len,
2940 		const uint8_t *c_key, uint8_t c_key_len,
2941 		uint8_t auth_iv_len, uint8_t auth_len,
2942 		uint8_t cipher_iv_len)
2943 
2944 {
2945 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2946 	struct crypto_unittest_params *ut_params = &unittest_params;
2947 
2948 	/* Setup Authentication Parameters */
2949 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2950 	ut_params->auth_xform.next = NULL;
2951 
2952 	ut_params->auth_xform.auth.op = auth_op;
2953 	ut_params->auth_xform.auth.algo = auth_algo;
2954 	ut_params->auth_xform.auth.key.length = a_key_len;
2955 	ut_params->auth_xform.auth.key.data = a_key;
2956 	ut_params->auth_xform.auth.digest_length = auth_len;
2957 	/* Auth IV will be after cipher IV */
2958 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2959 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2960 
2961 	/* Setup Cipher Parameters */
2962 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2963 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2964 
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, c_key_len);
2973 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2974 
2975 	/* Create Crypto session*/
2976 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2977 			&ut_params->cipher_xform, ts_params->session_mpool);
2978 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2979 		return TEST_SKIPPED;
2980 
2981 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2982 	return 0;
2983 }
2984 
2985 static int
2986 create_wireless_cipher_auth_session(uint8_t dev_id,
2987 		enum rte_crypto_cipher_operation cipher_op,
2988 		enum rte_crypto_auth_operation auth_op,
2989 		enum rte_crypto_auth_algorithm auth_algo,
2990 		enum rte_crypto_cipher_algorithm cipher_algo,
2991 		const struct wireless_test_data *tdata)
2992 {
2993 	const uint8_t key_len = tdata->key.len;
2994 	uint8_t cipher_auth_key[key_len];
2995 
2996 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2997 	struct crypto_unittest_params *ut_params = &unittest_params;
2998 	const uint8_t *key = tdata->key.data;
2999 	const uint8_t auth_len = tdata->digest.len;
3000 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
3001 	uint8_t auth_iv_len = tdata->auth_iv.len;
3002 
3003 	memcpy(cipher_auth_key, key, key_len);
3004 
3005 	/* Setup Authentication Parameters */
3006 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3007 	ut_params->auth_xform.next = NULL;
3008 
3009 	ut_params->auth_xform.auth.op = auth_op;
3010 	ut_params->auth_xform.auth.algo = auth_algo;
3011 	ut_params->auth_xform.auth.key.length = key_len;
3012 	/* Hash key = cipher key */
3013 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
3014 	ut_params->auth_xform.auth.digest_length = auth_len;
3015 	/* Auth IV will be after cipher IV */
3016 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3017 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
3018 
3019 	/* Setup Cipher Parameters */
3020 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3021 	ut_params->cipher_xform.next = &ut_params->auth_xform;
3022 
3023 	ut_params->cipher_xform.cipher.algo = cipher_algo;
3024 	ut_params->cipher_xform.cipher.op = cipher_op;
3025 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
3026 	ut_params->cipher_xform.cipher.key.length = key_len;
3027 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3028 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3029 
3030 
3031 	debug_hexdump(stdout, "key:", key, key_len);
3032 
3033 	/* Create Crypto session*/
3034 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3035 			&ut_params->cipher_xform, ts_params->session_mpool);
3036 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3037 		return TEST_SKIPPED;
3038 
3039 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3040 	return 0;
3041 }
3042 
3043 static int
3044 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
3045 		const struct wireless_test_data *tdata)
3046 {
3047 	return create_wireless_cipher_auth_session(dev_id,
3048 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3049 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
3050 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
3051 }
3052 
3053 static int
3054 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
3055 		enum rte_crypto_cipher_operation cipher_op,
3056 		enum rte_crypto_auth_operation auth_op,
3057 		enum rte_crypto_auth_algorithm auth_algo,
3058 		enum rte_crypto_cipher_algorithm cipher_algo,
3059 		const uint8_t *a_key, const uint8_t a_key_len,
3060 		const uint8_t *c_key, const uint8_t c_key_len,
3061 		uint8_t auth_iv_len, uint8_t auth_len,
3062 		uint8_t cipher_iv_len)
3063 {
3064 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3065 	struct crypto_unittest_params *ut_params = &unittest_params;
3066 
3067 	/* Setup Authentication Parameters */
3068 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3069 	ut_params->auth_xform.auth.op = auth_op;
3070 	ut_params->auth_xform.next = &ut_params->cipher_xform;
3071 	ut_params->auth_xform.auth.algo = auth_algo;
3072 	ut_params->auth_xform.auth.key.length = a_key_len;
3073 	ut_params->auth_xform.auth.key.data = a_key;
3074 	ut_params->auth_xform.auth.digest_length = auth_len;
3075 	/* Auth IV will be after cipher IV */
3076 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3077 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
3078 
3079 	/* Setup Cipher Parameters */
3080 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3081 	ut_params->cipher_xform.next = NULL;
3082 	ut_params->cipher_xform.cipher.algo = cipher_algo;
3083 	ut_params->cipher_xform.cipher.op = cipher_op;
3084 	ut_params->cipher_xform.cipher.key.data = c_key;
3085 	ut_params->cipher_xform.cipher.key.length = c_key_len;
3086 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3087 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3088 
3089 	debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
3090 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3091 
3092 	/* Create Crypto session*/
3093 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3094 		ut_params->auth_xform.next = NULL;
3095 		ut_params->cipher_xform.next = &ut_params->auth_xform;
3096 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3097 			&ut_params->cipher_xform, ts_params->session_mpool);
3098 	} else
3099 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3100 			&ut_params->auth_xform, ts_params->session_mpool);
3101 
3102 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3103 		return TEST_SKIPPED;
3104 
3105 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3106 
3107 	return 0;
3108 }
3109 
3110 static int
3111 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
3112 		unsigned int auth_tag_len,
3113 		const uint8_t *iv, unsigned int iv_len,
3114 		unsigned int data_pad_len,
3115 		enum rte_crypto_auth_operation op,
3116 		unsigned int auth_len, unsigned int auth_offset)
3117 {
3118 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3119 
3120 	struct crypto_unittest_params *ut_params = &unittest_params;
3121 
3122 	/* Generate Crypto op data structure */
3123 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3124 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3125 	TEST_ASSERT_NOT_NULL(ut_params->op,
3126 		"Failed to allocate pktmbuf offload");
3127 
3128 	/* Set crypto operation data parameters */
3129 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3130 
3131 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3132 
3133 	/* set crypto operation source mbuf */
3134 	sym_op->m_src = ut_params->ibuf;
3135 
3136 	/* iv */
3137 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3138 			iv, iv_len);
3139 	/* digest */
3140 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3141 					ut_params->ibuf, auth_tag_len);
3142 
3143 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3144 				"no room to append auth tag");
3145 	ut_params->digest = sym_op->auth.digest.data;
3146 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3147 			ut_params->ibuf, data_pad_len);
3148 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3149 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3150 	else
3151 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3152 
3153 	debug_hexdump(stdout, "digest:",
3154 		sym_op->auth.digest.data,
3155 		auth_tag_len);
3156 
3157 	sym_op->auth.data.length = auth_len;
3158 	sym_op->auth.data.offset = auth_offset;
3159 
3160 	return 0;
3161 }
3162 
3163 static int
3164 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3165 	enum rte_crypto_auth_operation op)
3166 {
3167 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3168 	struct crypto_unittest_params *ut_params = &unittest_params;
3169 
3170 	const uint8_t *auth_tag = tdata->digest.data;
3171 	const unsigned int auth_tag_len = tdata->digest.len;
3172 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3173 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3174 
3175 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
3176 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3177 	const uint8_t *auth_iv = tdata->auth_iv.data;
3178 	const uint8_t auth_iv_len = tdata->auth_iv.len;
3179 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3180 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
3181 
3182 	/* Generate Crypto op data structure */
3183 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3184 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3185 	TEST_ASSERT_NOT_NULL(ut_params->op,
3186 			"Failed to allocate pktmbuf offload");
3187 	/* Set crypto operation data parameters */
3188 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3189 
3190 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3191 
3192 	/* set crypto operation source mbuf */
3193 	sym_op->m_src = ut_params->ibuf;
3194 
3195 	/* digest */
3196 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3197 			ut_params->ibuf, auth_tag_len);
3198 
3199 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3200 			"no room to append auth tag");
3201 	ut_params->digest = sym_op->auth.digest.data;
3202 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3203 			ut_params->ibuf, data_pad_len);
3204 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3205 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3206 	else
3207 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3208 
3209 	debug_hexdump(stdout, "digest:",
3210 		sym_op->auth.digest.data,
3211 		auth_tag_len);
3212 
3213 	/* Copy cipher and auth IVs at the end of the crypto operation */
3214 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3215 						IV_OFFSET);
3216 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3217 	iv_ptr += cipher_iv_len;
3218 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3219 
3220 	sym_op->cipher.data.length = cipher_len;
3221 	sym_op->cipher.data.offset = 0;
3222 	sym_op->auth.data.length = auth_len;
3223 	sym_op->auth.data.offset = 0;
3224 
3225 	return 0;
3226 }
3227 
3228 static int
3229 create_zuc_cipher_hash_generate_operation(
3230 		const struct wireless_test_data *tdata)
3231 {
3232 	return create_wireless_cipher_hash_operation(tdata,
3233 		RTE_CRYPTO_AUTH_OP_GENERATE);
3234 }
3235 
3236 static int
3237 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3238 		const unsigned auth_tag_len,
3239 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3240 		unsigned data_pad_len,
3241 		enum rte_crypto_auth_operation op,
3242 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3243 		const unsigned cipher_len, const unsigned cipher_offset,
3244 		const unsigned auth_len, const unsigned auth_offset)
3245 {
3246 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3247 	struct crypto_unittest_params *ut_params = &unittest_params;
3248 
3249 	enum rte_crypto_cipher_algorithm cipher_algo =
3250 			ut_params->cipher_xform.cipher.algo;
3251 	enum rte_crypto_auth_algorithm auth_algo =
3252 			ut_params->auth_xform.auth.algo;
3253 
3254 	/* Generate Crypto op data structure */
3255 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3256 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3257 	TEST_ASSERT_NOT_NULL(ut_params->op,
3258 			"Failed to allocate pktmbuf offload");
3259 	/* Set crypto operation data parameters */
3260 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3261 
3262 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3263 
3264 	/* set crypto operation source mbuf */
3265 	sym_op->m_src = ut_params->ibuf;
3266 
3267 	/* digest */
3268 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3269 			ut_params->ibuf, auth_tag_len);
3270 
3271 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3272 			"no room to append auth tag");
3273 	ut_params->digest = sym_op->auth.digest.data;
3274 
3275 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3276 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3277 				ut_params->ibuf, data_pad_len);
3278 	} else {
3279 		struct rte_mbuf *m = ut_params->ibuf;
3280 		unsigned int offset = data_pad_len;
3281 
3282 		while (offset > m->data_len && m->next != NULL) {
3283 			offset -= m->data_len;
3284 			m = m->next;
3285 		}
3286 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3287 			m, offset);
3288 	}
3289 
3290 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3291 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3292 	else
3293 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3294 
3295 	debug_hexdump(stdout, "digest:",
3296 		sym_op->auth.digest.data,
3297 		auth_tag_len);
3298 
3299 	/* Copy cipher and auth IVs at the end of the crypto operation */
3300 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3301 						IV_OFFSET);
3302 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3303 	iv_ptr += cipher_iv_len;
3304 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3305 
3306 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3307 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3308 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3309 		sym_op->cipher.data.length = cipher_len;
3310 		sym_op->cipher.data.offset = cipher_offset;
3311 	} else {
3312 		sym_op->cipher.data.length = cipher_len >> 3;
3313 		sym_op->cipher.data.offset = cipher_offset >> 3;
3314 	}
3315 
3316 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3317 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3318 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3319 		sym_op->auth.data.length = auth_len;
3320 		sym_op->auth.data.offset = auth_offset;
3321 	} else {
3322 		sym_op->auth.data.length = auth_len >> 3;
3323 		sym_op->auth.data.offset = auth_offset >> 3;
3324 	}
3325 
3326 	return 0;
3327 }
3328 
3329 static int
3330 create_wireless_algo_auth_cipher_operation(
3331 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3332 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3333 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3334 		unsigned int data_pad_len,
3335 		unsigned int cipher_len, unsigned int cipher_offset,
3336 		unsigned int auth_len, unsigned int auth_offset,
3337 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3338 {
3339 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3340 	struct crypto_unittest_params *ut_params = &unittest_params;
3341 
3342 	enum rte_crypto_cipher_algorithm cipher_algo =
3343 			ut_params->cipher_xform.cipher.algo;
3344 	enum rte_crypto_auth_algorithm auth_algo =
3345 			ut_params->auth_xform.auth.algo;
3346 
3347 	/* Generate Crypto op data structure */
3348 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3349 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3350 	TEST_ASSERT_NOT_NULL(ut_params->op,
3351 			"Failed to allocate pktmbuf offload");
3352 
3353 	/* Set crypto operation data parameters */
3354 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3355 
3356 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3357 
3358 	/* set crypto operation mbufs */
3359 	sym_op->m_src = ut_params->ibuf;
3360 	if (op_mode == OUT_OF_PLACE)
3361 		sym_op->m_dst = ut_params->obuf;
3362 
3363 	/* digest */
3364 	if (!do_sgl) {
3365 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3366 			(op_mode == IN_PLACE ?
3367 				ut_params->ibuf : ut_params->obuf),
3368 			uint8_t *, data_pad_len);
3369 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3370 			(op_mode == IN_PLACE ?
3371 				ut_params->ibuf : ut_params->obuf),
3372 			data_pad_len);
3373 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3374 	} else {
3375 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3376 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3377 				sym_op->m_src : sym_op->m_dst);
3378 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3379 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3380 			sgl_buf = sgl_buf->next;
3381 		}
3382 
3383 		/* The last segment should be large enough to hold full digest */
3384 		if (sgl_buf->data_len < auth_tag_len) {
3385 			rte_pktmbuf_free(sgl_buf->next);
3386 			sgl_buf->next = NULL;
3387 			TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3388 					auth_tag_len - sgl_buf->data_len),
3389 					"No room to append auth tag");
3390 		}
3391 
3392 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3393 				uint8_t *, remaining_off);
3394 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3395 				remaining_off);
3396 		memset(sym_op->auth.digest.data, 0, remaining_off);
3397 		while (sgl_buf->next != NULL) {
3398 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3399 				0, rte_pktmbuf_data_len(sgl_buf));
3400 			sgl_buf = sgl_buf->next;
3401 		}
3402 	}
3403 
3404 	/* Copy digest for the verification */
3405 	if (verify)
3406 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3407 
3408 	/* Copy cipher and auth IVs at the end of the crypto operation */
3409 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3410 			ut_params->op, uint8_t *, IV_OFFSET);
3411 
3412 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3413 	iv_ptr += cipher_iv_len;
3414 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3415 
3416 	/* Only copy over the offset data needed from src to dst in OOP,
3417 	 * if the auth and cipher offsets are not aligned
3418 	 */
3419 	if (op_mode == OUT_OF_PLACE) {
3420 		if (cipher_offset > auth_offset)
3421 			rte_memcpy(
3422 				rte_pktmbuf_mtod_offset(
3423 					sym_op->m_dst,
3424 					uint8_t *, auth_offset >> 3),
3425 				rte_pktmbuf_mtod_offset(
3426 					sym_op->m_src,
3427 					uint8_t *, auth_offset >> 3),
3428 				((cipher_offset >> 3) - (auth_offset >> 3)));
3429 	}
3430 
3431 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3432 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3433 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3434 		sym_op->cipher.data.length = cipher_len;
3435 		sym_op->cipher.data.offset = cipher_offset;
3436 	} else {
3437 		sym_op->cipher.data.length = cipher_len >> 3;
3438 		sym_op->cipher.data.offset = cipher_offset >> 3;
3439 	}
3440 
3441 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3442 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3443 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3444 		sym_op->auth.data.length = auth_len;
3445 		sym_op->auth.data.offset = auth_offset;
3446 	} else {
3447 		sym_op->auth.data.length = auth_len >> 3;
3448 		sym_op->auth.data.offset = auth_offset >> 3;
3449 	}
3450 
3451 	return 0;
3452 }
3453 
3454 static int
3455 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3456 {
3457 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3458 	struct crypto_unittest_params *ut_params = &unittest_params;
3459 
3460 	int retval;
3461 	unsigned plaintext_pad_len;
3462 	unsigned plaintext_len;
3463 	uint8_t *plaintext;
3464 	struct rte_cryptodev_info dev_info;
3465 
3466 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3467 	uint64_t feat_flags = dev_info.feature_flags;
3468 
3469 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3470 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3471 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3472 		return TEST_SKIPPED;
3473 	}
3474 
3475 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3476 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3477 		printf("Device doesn't support RAW data-path APIs.\n");
3478 		return TEST_SKIPPED;
3479 	}
3480 
3481 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3482 		return TEST_SKIPPED;
3483 
3484 	/* Verify the capabilities */
3485 	struct rte_cryptodev_sym_capability_idx cap_idx;
3486 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3487 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3488 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3489 			&cap_idx) == NULL)
3490 		return TEST_SKIPPED;
3491 
3492 	/* Create SNOW 3G session */
3493 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3494 			tdata->key.data, tdata->key.len,
3495 			tdata->auth_iv.len, tdata->digest.len,
3496 			RTE_CRYPTO_AUTH_OP_GENERATE,
3497 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3498 	if (retval < 0)
3499 		return retval;
3500 
3501 	/* alloc mbuf and set payload */
3502 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3503 
3504 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3505 	rte_pktmbuf_tailroom(ut_params->ibuf));
3506 
3507 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3508 	/* Append data which is padded to a multiple of */
3509 	/* the algorithms block size */
3510 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3511 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3512 				plaintext_pad_len);
3513 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3514 
3515 	/* Create SNOW 3G operation */
3516 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3517 			tdata->auth_iv.data, tdata->auth_iv.len,
3518 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3519 			tdata->validAuthLenInBits.len,
3520 			0);
3521 	if (retval < 0)
3522 		return retval;
3523 
3524 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3525 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3526 					       0);
3527 		if (retval != TEST_SUCCESS)
3528 			return retval;
3529 	} else
3530 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3531 				ut_params->op);
3532 	ut_params->obuf = ut_params->op->sym->m_src;
3533 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3534 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3535 						    uint8_t *,
3536 						    plaintext_pad_len);
3537 
3538 	/* Validate obuf */
3539 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3540 	ut_params->digest,
3541 	tdata->digest.data,
3542 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3543 	"SNOW 3G Generated auth tag not as expected");
3544 
3545 	return 0;
3546 }
3547 
3548 static int
3549 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3550 {
3551 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3552 	struct crypto_unittest_params *ut_params = &unittest_params;
3553 
3554 	int retval;
3555 	unsigned plaintext_pad_len;
3556 	unsigned plaintext_len;
3557 	uint8_t *plaintext;
3558 	struct rte_cryptodev_info dev_info;
3559 
3560 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3561 	uint64_t feat_flags = dev_info.feature_flags;
3562 
3563 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3564 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3565 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3566 		return TEST_SKIPPED;
3567 	}
3568 
3569 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3570 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3571 		printf("Device doesn't support RAW data-path APIs.\n");
3572 		return TEST_SKIPPED;
3573 	}
3574 
3575 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3576 		return TEST_SKIPPED;
3577 
3578 	/* Verify the capabilities */
3579 	struct rte_cryptodev_sym_capability_idx cap_idx;
3580 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3581 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3582 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3583 			&cap_idx) == NULL)
3584 		return TEST_SKIPPED;
3585 
3586 	/* Create SNOW 3G session */
3587 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3588 				tdata->key.data, tdata->key.len,
3589 				tdata->auth_iv.len, tdata->digest.len,
3590 				RTE_CRYPTO_AUTH_OP_VERIFY,
3591 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3592 	if (retval < 0)
3593 		return retval;
3594 	/* alloc mbuf and set payload */
3595 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3596 
3597 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3598 	rte_pktmbuf_tailroom(ut_params->ibuf));
3599 
3600 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3601 	/* Append data which is padded to a multiple of */
3602 	/* the algorithms block size */
3603 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3604 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3605 				plaintext_pad_len);
3606 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3607 
3608 	/* Create SNOW 3G operation */
3609 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3610 			tdata->digest.len,
3611 			tdata->auth_iv.data, tdata->auth_iv.len,
3612 			plaintext_pad_len,
3613 			RTE_CRYPTO_AUTH_OP_VERIFY,
3614 			tdata->validAuthLenInBits.len,
3615 			0);
3616 	if (retval < 0)
3617 		return retval;
3618 
3619 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3620 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3621 					       0);
3622 		if (retval != TEST_SUCCESS)
3623 			return retval;
3624 	} else
3625 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3626 				ut_params->op);
3627 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3628 	ut_params->obuf = ut_params->op->sym->m_src;
3629 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3630 						    uint8_t *,
3631 						    plaintext_pad_len);
3632 
3633 	/* Validate obuf */
3634 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3635 		return 0;
3636 	else
3637 		return -1;
3638 
3639 	return 0;
3640 }
3641 
3642 static int
3643 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3644 {
3645 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3646 	struct crypto_unittest_params *ut_params = &unittest_params;
3647 
3648 	int retval;
3649 	unsigned plaintext_pad_len;
3650 	unsigned plaintext_len;
3651 	uint8_t *plaintext;
3652 	struct rte_cryptodev_info dev_info;
3653 
3654 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3655 	uint64_t feat_flags = dev_info.feature_flags;
3656 
3657 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3658 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3659 		printf("Device doesn't support RAW data-path APIs.\n");
3660 		return TEST_SKIPPED;
3661 	}
3662 
3663 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3664 		return TEST_SKIPPED;
3665 
3666 	/* Verify the capabilities */
3667 	struct rte_cryptodev_sym_capability_idx cap_idx;
3668 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3669 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3670 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3671 			&cap_idx) == NULL)
3672 		return TEST_SKIPPED;
3673 
3674 	/* Create KASUMI session */
3675 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3676 			tdata->key.data, tdata->key.len,
3677 			0, tdata->digest.len,
3678 			RTE_CRYPTO_AUTH_OP_GENERATE,
3679 			RTE_CRYPTO_AUTH_KASUMI_F9);
3680 	if (retval < 0)
3681 		return retval;
3682 
3683 	/* alloc mbuf and set payload */
3684 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3685 
3686 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3687 	rte_pktmbuf_tailroom(ut_params->ibuf));
3688 
3689 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3690 	/* Append data which is padded to a multiple of */
3691 	/* the algorithms block size */
3692 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3693 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3694 				plaintext_pad_len);
3695 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3696 
3697 	/* Create KASUMI operation */
3698 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3699 			NULL, 0,
3700 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3701 			tdata->plaintext.len,
3702 			0);
3703 	if (retval < 0)
3704 		return retval;
3705 
3706 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3707 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3708 			ut_params->op);
3709 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3710 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3711 					       0);
3712 		if (retval != TEST_SUCCESS)
3713 			return retval;
3714 	} else
3715 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3716 			ut_params->op);
3717 
3718 	ut_params->obuf = ut_params->op->sym->m_src;
3719 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3720 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3721 						    uint8_t *,
3722 						    plaintext_pad_len);
3723 
3724 	/* Validate obuf */
3725 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3726 	ut_params->digest,
3727 	tdata->digest.data,
3728 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3729 	"KASUMI Generated auth tag not as expected");
3730 
3731 	return 0;
3732 }
3733 
3734 static int
3735 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3736 {
3737 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3738 	struct crypto_unittest_params *ut_params = &unittest_params;
3739 
3740 	int retval;
3741 	unsigned plaintext_pad_len;
3742 	unsigned plaintext_len;
3743 	uint8_t *plaintext;
3744 	struct rte_cryptodev_info dev_info;
3745 
3746 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3747 	uint64_t feat_flags = dev_info.feature_flags;
3748 
3749 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3750 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3751 		printf("Device doesn't support RAW data-path APIs.\n");
3752 		return TEST_SKIPPED;
3753 	}
3754 
3755 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3756 		return TEST_SKIPPED;
3757 
3758 	/* Verify the capabilities */
3759 	struct rte_cryptodev_sym_capability_idx cap_idx;
3760 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3761 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3762 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3763 			&cap_idx) == NULL)
3764 		return TEST_SKIPPED;
3765 
3766 	/* Create KASUMI session */
3767 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3768 				tdata->key.data, tdata->key.len,
3769 				0, tdata->digest.len,
3770 				RTE_CRYPTO_AUTH_OP_VERIFY,
3771 				RTE_CRYPTO_AUTH_KASUMI_F9);
3772 	if (retval < 0)
3773 		return retval;
3774 	/* alloc mbuf and set payload */
3775 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3776 
3777 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3778 	rte_pktmbuf_tailroom(ut_params->ibuf));
3779 
3780 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3781 	/* Append data which is padded to a multiple */
3782 	/* of the algorithms block size */
3783 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3784 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3785 				plaintext_pad_len);
3786 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3787 
3788 	/* Create KASUMI operation */
3789 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3790 			tdata->digest.len,
3791 			NULL, 0,
3792 			plaintext_pad_len,
3793 			RTE_CRYPTO_AUTH_OP_VERIFY,
3794 			tdata->plaintext.len,
3795 			0);
3796 	if (retval < 0)
3797 		return retval;
3798 
3799 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3800 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3801 					       0);
3802 		if (retval != TEST_SUCCESS)
3803 			return retval;
3804 	} else
3805 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3806 				ut_params->op);
3807 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3808 	ut_params->obuf = ut_params->op->sym->m_src;
3809 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3810 						    uint8_t *,
3811 						    plaintext_pad_len);
3812 
3813 	/* Validate obuf */
3814 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3815 		return 0;
3816 	else
3817 		return -1;
3818 
3819 	return 0;
3820 }
3821 
3822 static int
3823 test_snow3g_hash_generate_test_case_1(void)
3824 {
3825 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3826 }
3827 
3828 static int
3829 test_snow3g_hash_generate_test_case_2(void)
3830 {
3831 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3832 }
3833 
3834 static int
3835 test_snow3g_hash_generate_test_case_3(void)
3836 {
3837 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3838 }
3839 
3840 static int
3841 test_snow3g_hash_generate_test_case_4(void)
3842 {
3843 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3844 }
3845 
3846 static int
3847 test_snow3g_hash_generate_test_case_5(void)
3848 {
3849 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3850 }
3851 
3852 static int
3853 test_snow3g_hash_generate_test_case_6(void)
3854 {
3855 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3856 }
3857 
3858 static int
3859 test_snow3g_hash_verify_test_case_1(void)
3860 {
3861 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3862 
3863 }
3864 
3865 static int
3866 test_snow3g_hash_verify_test_case_2(void)
3867 {
3868 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3869 }
3870 
3871 static int
3872 test_snow3g_hash_verify_test_case_3(void)
3873 {
3874 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3875 }
3876 
3877 static int
3878 test_snow3g_hash_verify_test_case_4(void)
3879 {
3880 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3881 }
3882 
3883 static int
3884 test_snow3g_hash_verify_test_case_5(void)
3885 {
3886 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3887 }
3888 
3889 static int
3890 test_snow3g_hash_verify_test_case_6(void)
3891 {
3892 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3893 }
3894 
3895 static int
3896 test_kasumi_hash_generate_test_case_1(void)
3897 {
3898 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3899 }
3900 
3901 static int
3902 test_kasumi_hash_generate_test_case_2(void)
3903 {
3904 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3905 }
3906 
3907 static int
3908 test_kasumi_hash_generate_test_case_3(void)
3909 {
3910 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3911 }
3912 
3913 static int
3914 test_kasumi_hash_generate_test_case_4(void)
3915 {
3916 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3917 }
3918 
3919 static int
3920 test_kasumi_hash_generate_test_case_5(void)
3921 {
3922 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3923 }
3924 
3925 static int
3926 test_kasumi_hash_generate_test_case_6(void)
3927 {
3928 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3929 }
3930 
3931 static int
3932 test_kasumi_hash_verify_test_case_1(void)
3933 {
3934 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3935 }
3936 
3937 static int
3938 test_kasumi_hash_verify_test_case_2(void)
3939 {
3940 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3941 }
3942 
3943 static int
3944 test_kasumi_hash_verify_test_case_3(void)
3945 {
3946 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3947 }
3948 
3949 static int
3950 test_kasumi_hash_verify_test_case_4(void)
3951 {
3952 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3953 }
3954 
3955 static int
3956 test_kasumi_hash_verify_test_case_5(void)
3957 {
3958 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3959 }
3960 
3961 static int
3962 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3963 {
3964 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3965 	struct crypto_unittest_params *ut_params = &unittest_params;
3966 
3967 	int retval;
3968 	uint8_t *plaintext, *ciphertext;
3969 	unsigned plaintext_pad_len;
3970 	unsigned plaintext_len;
3971 	struct rte_cryptodev_info dev_info;
3972 
3973 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3974 	uint64_t feat_flags = dev_info.feature_flags;
3975 
3976 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3977 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3978 		printf("Device doesn't support RAW data-path APIs.\n");
3979 		return TEST_SKIPPED;
3980 	}
3981 
3982 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3983 		return TEST_SKIPPED;
3984 
3985 	/* Verify the capabilities */
3986 	struct rte_cryptodev_sym_capability_idx cap_idx;
3987 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3988 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3989 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3990 			&cap_idx) == NULL)
3991 		return TEST_SKIPPED;
3992 
3993 	/* Create KASUMI session */
3994 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3995 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3996 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3997 					tdata->key.data, tdata->key.len,
3998 					tdata->cipher_iv.len);
3999 	if (retval < 0)
4000 		return retval;
4001 
4002 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4003 
4004 	/* Clear mbuf payload */
4005 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4006 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4007 
4008 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4009 	/* Append data which is padded to a multiple */
4010 	/* of the algorithms block size */
4011 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4012 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4013 				plaintext_pad_len);
4014 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4015 
4016 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4017 
4018 	/* Create KASUMI operation */
4019 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4020 				tdata->cipher_iv.len,
4021 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4022 				tdata->validCipherOffsetInBits.len);
4023 	if (retval < 0)
4024 		return retval;
4025 
4026 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4027 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4028 					       tdata->cipher_iv.len);
4029 		if (retval != TEST_SUCCESS)
4030 			return retval;
4031 	} else
4032 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4033 				ut_params->op);
4034 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4035 
4036 	ut_params->obuf = ut_params->op->sym->m_dst;
4037 	if (ut_params->obuf)
4038 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4039 	else
4040 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4041 
4042 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4043 
4044 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4045 				(tdata->validCipherOffsetInBits.len >> 3);
4046 	/* Validate obuf */
4047 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4048 		ciphertext,
4049 		reference_ciphertext,
4050 		tdata->validCipherLenInBits.len,
4051 		"KASUMI Ciphertext data not as expected");
4052 	return 0;
4053 }
4054 
4055 static int
4056 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4057 {
4058 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4059 	struct crypto_unittest_params *ut_params = &unittest_params;
4060 
4061 	int retval;
4062 
4063 	unsigned int plaintext_pad_len;
4064 	unsigned int plaintext_len;
4065 
4066 	uint8_t buffer[10000];
4067 	const uint8_t *ciphertext;
4068 
4069 	struct rte_cryptodev_info dev_info;
4070 
4071 	/* Verify the capabilities */
4072 	struct rte_cryptodev_sym_capability_idx cap_idx;
4073 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4074 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4075 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4076 			&cap_idx) == NULL)
4077 		return TEST_SKIPPED;
4078 
4079 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4080 
4081 	uint64_t feat_flags = dev_info.feature_flags;
4082 
4083 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4084 		printf("Device doesn't support in-place scatter-gather. "
4085 				"Test Skipped.\n");
4086 		return TEST_SKIPPED;
4087 	}
4088 
4089 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4090 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4091 		printf("Device doesn't support RAW data-path APIs.\n");
4092 		return TEST_SKIPPED;
4093 	}
4094 
4095 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4096 		return TEST_SKIPPED;
4097 
4098 	/* Create KASUMI session */
4099 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4100 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4101 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4102 					tdata->key.data, tdata->key.len,
4103 					tdata->cipher_iv.len);
4104 	if (retval < 0)
4105 		return retval;
4106 
4107 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4108 
4109 
4110 	/* Append data which is padded to a multiple */
4111 	/* of the algorithms block size */
4112 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4113 
4114 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4115 			plaintext_pad_len, 10, 0);
4116 
4117 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4118 
4119 	/* Create KASUMI operation */
4120 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4121 				tdata->cipher_iv.len,
4122 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4123 				tdata->validCipherOffsetInBits.len);
4124 	if (retval < 0)
4125 		return retval;
4126 
4127 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4128 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4129 					       tdata->cipher_iv.len);
4130 		if (retval != TEST_SUCCESS)
4131 			return retval;
4132 	} else
4133 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4134 						ut_params->op);
4135 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4136 
4137 	ut_params->obuf = ut_params->op->sym->m_dst;
4138 
4139 	if (ut_params->obuf)
4140 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4141 				plaintext_len, buffer);
4142 	else
4143 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4144 				tdata->validCipherOffsetInBits.len >> 3,
4145 				plaintext_len, buffer);
4146 
4147 	/* Validate obuf */
4148 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4149 
4150 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4151 				(tdata->validCipherOffsetInBits.len >> 3);
4152 	/* Validate obuf */
4153 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4154 		ciphertext,
4155 		reference_ciphertext,
4156 		tdata->validCipherLenInBits.len,
4157 		"KASUMI Ciphertext data not as expected");
4158 	return 0;
4159 }
4160 
4161 static int
4162 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4163 {
4164 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4165 	struct crypto_unittest_params *ut_params = &unittest_params;
4166 
4167 	int retval;
4168 	uint8_t *plaintext, *ciphertext;
4169 	unsigned plaintext_pad_len;
4170 	unsigned plaintext_len;
4171 
4172 	/* Verify the capabilities */
4173 	struct rte_cryptodev_sym_capability_idx cap_idx;
4174 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4175 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4176 	/* Data-path service does not support OOP */
4177 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4178 			&cap_idx) == NULL)
4179 		return TEST_SKIPPED;
4180 
4181 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4182 		return TEST_SKIPPED;
4183 
4184 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4185 		return TEST_SKIPPED;
4186 
4187 	/* Create KASUMI session */
4188 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4189 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4190 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4191 					tdata->key.data, tdata->key.len,
4192 					tdata->cipher_iv.len);
4193 	if (retval < 0)
4194 		return retval;
4195 
4196 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4197 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4198 
4199 	/* Clear mbuf payload */
4200 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4201 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4202 
4203 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4204 	/* Append data which is padded to a multiple */
4205 	/* of the algorithms block size */
4206 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4207 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4208 				plaintext_pad_len);
4209 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4210 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4211 
4212 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4213 
4214 	/* Create KASUMI operation */
4215 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4216 				tdata->cipher_iv.len,
4217 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4218 				tdata->validCipherOffsetInBits.len);
4219 	if (retval < 0)
4220 		return retval;
4221 
4222 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4223 						ut_params->op);
4224 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4225 
4226 	ut_params->obuf = ut_params->op->sym->m_dst;
4227 	if (ut_params->obuf)
4228 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4229 	else
4230 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4231 
4232 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4233 
4234 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4235 				(tdata->validCipherOffsetInBits.len >> 3);
4236 	/* Validate obuf */
4237 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4238 		ciphertext,
4239 		reference_ciphertext,
4240 		tdata->validCipherLenInBits.len,
4241 		"KASUMI Ciphertext data not as expected");
4242 	return 0;
4243 }
4244 
4245 static int
4246 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4247 {
4248 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4249 	struct crypto_unittest_params *ut_params = &unittest_params;
4250 
4251 	int retval;
4252 	unsigned int plaintext_pad_len;
4253 	unsigned int plaintext_len;
4254 
4255 	const uint8_t *ciphertext;
4256 	uint8_t buffer[2048];
4257 
4258 	struct rte_cryptodev_info dev_info;
4259 
4260 	/* Verify the capabilities */
4261 	struct rte_cryptodev_sym_capability_idx cap_idx;
4262 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4263 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4264 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4265 			&cap_idx) == NULL)
4266 		return TEST_SKIPPED;
4267 
4268 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4269 		return TEST_SKIPPED;
4270 
4271 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4272 		return TEST_SKIPPED;
4273 
4274 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4275 
4276 	uint64_t feat_flags = dev_info.feature_flags;
4277 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4278 		printf("Device doesn't support out-of-place scatter-gather "
4279 				"in both input and output mbufs. "
4280 				"Test Skipped.\n");
4281 		return TEST_SKIPPED;
4282 	}
4283 
4284 	/* Create KASUMI session */
4285 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4286 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4287 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4288 					tdata->key.data, tdata->key.len,
4289 					tdata->cipher_iv.len);
4290 	if (retval < 0)
4291 		return retval;
4292 
4293 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4294 	/* Append data which is padded to a multiple */
4295 	/* of the algorithms block size */
4296 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4297 
4298 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4299 			plaintext_pad_len, 10, 0);
4300 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4301 			plaintext_pad_len, 3, 0);
4302 
4303 	/* Append data which is padded to a multiple */
4304 	/* of the algorithms block size */
4305 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4306 
4307 	/* Create KASUMI operation */
4308 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4309 				tdata->cipher_iv.len,
4310 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4311 				tdata->validCipherOffsetInBits.len);
4312 	if (retval < 0)
4313 		return retval;
4314 
4315 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4316 						ut_params->op);
4317 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4318 
4319 	ut_params->obuf = ut_params->op->sym->m_dst;
4320 	if (ut_params->obuf)
4321 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4322 				plaintext_pad_len, buffer);
4323 	else
4324 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4325 				tdata->validCipherOffsetInBits.len >> 3,
4326 				plaintext_pad_len, buffer);
4327 
4328 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4329 				(tdata->validCipherOffsetInBits.len >> 3);
4330 	/* Validate obuf */
4331 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4332 		ciphertext,
4333 		reference_ciphertext,
4334 		tdata->validCipherLenInBits.len,
4335 		"KASUMI Ciphertext data not as expected");
4336 	return 0;
4337 }
4338 
4339 
4340 static int
4341 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4342 {
4343 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4344 	struct crypto_unittest_params *ut_params = &unittest_params;
4345 
4346 	int retval;
4347 	uint8_t *ciphertext, *plaintext;
4348 	unsigned ciphertext_pad_len;
4349 	unsigned ciphertext_len;
4350 
4351 	/* Verify the capabilities */
4352 	struct rte_cryptodev_sym_capability_idx cap_idx;
4353 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4354 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4355 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4356 			&cap_idx) == NULL)
4357 		return TEST_SKIPPED;
4358 
4359 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4360 		return TEST_SKIPPED;
4361 
4362 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4363 		return TEST_SKIPPED;
4364 
4365 	/* Create KASUMI session */
4366 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4367 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4368 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4369 					tdata->key.data, tdata->key.len,
4370 					tdata->cipher_iv.len);
4371 	if (retval < 0)
4372 		return retval;
4373 
4374 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4375 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4376 
4377 	/* Clear mbuf payload */
4378 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4379 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4380 
4381 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4382 	/* Append data which is padded to a multiple */
4383 	/* of the algorithms block size */
4384 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4385 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4386 				ciphertext_pad_len);
4387 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4388 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4389 
4390 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4391 
4392 	/* Create KASUMI operation */
4393 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4394 				tdata->cipher_iv.len,
4395 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4396 				tdata->validCipherOffsetInBits.len);
4397 	if (retval < 0)
4398 		return retval;
4399 
4400 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4401 						ut_params->op);
4402 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4403 
4404 	ut_params->obuf = ut_params->op->sym->m_dst;
4405 	if (ut_params->obuf)
4406 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4407 	else
4408 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4409 
4410 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4411 
4412 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4413 				(tdata->validCipherOffsetInBits.len >> 3);
4414 	/* Validate obuf */
4415 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4416 		plaintext,
4417 		reference_plaintext,
4418 		tdata->validCipherLenInBits.len,
4419 		"KASUMI Plaintext data not as expected");
4420 	return 0;
4421 }
4422 
4423 static int
4424 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4425 {
4426 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4427 	struct crypto_unittest_params *ut_params = &unittest_params;
4428 
4429 	int retval;
4430 	uint8_t *ciphertext, *plaintext;
4431 	unsigned ciphertext_pad_len;
4432 	unsigned ciphertext_len;
4433 	struct rte_cryptodev_info dev_info;
4434 
4435 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4436 	uint64_t feat_flags = dev_info.feature_flags;
4437 
4438 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4439 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4440 		printf("Device doesn't support RAW data-path APIs.\n");
4441 		return TEST_SKIPPED;
4442 	}
4443 
4444 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4445 		return TEST_SKIPPED;
4446 
4447 	/* Verify the capabilities */
4448 	struct rte_cryptodev_sym_capability_idx cap_idx;
4449 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4450 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4451 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4452 			&cap_idx) == NULL)
4453 		return TEST_SKIPPED;
4454 
4455 	/* Create KASUMI session */
4456 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4457 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4458 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4459 					tdata->key.data, tdata->key.len,
4460 					tdata->cipher_iv.len);
4461 	if (retval < 0)
4462 		return retval;
4463 
4464 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4465 
4466 	/* Clear mbuf payload */
4467 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4468 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4469 
4470 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4471 	/* Append data which is padded to a multiple */
4472 	/* of the algorithms block size */
4473 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4474 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4475 				ciphertext_pad_len);
4476 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4477 
4478 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4479 
4480 	/* Create KASUMI operation */
4481 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4482 			tdata->cipher_iv.len,
4483 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4484 			tdata->validCipherOffsetInBits.len);
4485 	if (retval < 0)
4486 		return retval;
4487 
4488 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4489 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4490 					       0);
4491 		if (retval != TEST_SUCCESS)
4492 			return retval;
4493 	} else
4494 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4495 						ut_params->op);
4496 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4497 
4498 	ut_params->obuf = ut_params->op->sym->m_dst;
4499 	if (ut_params->obuf)
4500 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4501 	else
4502 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4503 
4504 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4505 
4506 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4507 				(tdata->validCipherOffsetInBits.len >> 3);
4508 	/* Validate obuf */
4509 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4510 		plaintext,
4511 		reference_plaintext,
4512 		tdata->validCipherLenInBits.len,
4513 		"KASUMI Plaintext data not as expected");
4514 	return 0;
4515 }
4516 
4517 static int
4518 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4519 {
4520 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4521 	struct crypto_unittest_params *ut_params = &unittest_params;
4522 
4523 	int retval;
4524 	uint8_t *plaintext, *ciphertext;
4525 	unsigned plaintext_pad_len;
4526 	unsigned plaintext_len;
4527 	struct rte_cryptodev_info dev_info;
4528 
4529 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4530 	uint64_t feat_flags = dev_info.feature_flags;
4531 
4532 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4533 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4534 		printf("Device doesn't support RAW data-path APIs.\n");
4535 		return TEST_SKIPPED;
4536 	}
4537 
4538 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4539 		return TEST_SKIPPED;
4540 
4541 	/* Verify the capabilities */
4542 	struct rte_cryptodev_sym_capability_idx cap_idx;
4543 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4544 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4545 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4546 			&cap_idx) == NULL)
4547 		return TEST_SKIPPED;
4548 
4549 	/* Create SNOW 3G session */
4550 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4551 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4552 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4553 					tdata->key.data, tdata->key.len,
4554 					tdata->cipher_iv.len);
4555 	if (retval < 0)
4556 		return retval;
4557 
4558 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4559 
4560 	/* Clear mbuf payload */
4561 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4562 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4563 
4564 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4565 	/* Append data which is padded to a multiple of */
4566 	/* the algorithms block size */
4567 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4568 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4569 				plaintext_pad_len);
4570 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4571 
4572 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4573 
4574 	/* Create SNOW 3G operation */
4575 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4576 					tdata->cipher_iv.len,
4577 					tdata->validCipherLenInBits.len,
4578 					0);
4579 	if (retval < 0)
4580 		return retval;
4581 
4582 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4583 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4584 					       tdata->cipher_iv.len);
4585 		if (retval != TEST_SUCCESS)
4586 			return retval;
4587 	} else
4588 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4589 						ut_params->op);
4590 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4591 
4592 	ut_params->obuf = ut_params->op->sym->m_dst;
4593 	if (ut_params->obuf)
4594 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4595 	else
4596 		ciphertext = plaintext;
4597 
4598 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4599 
4600 	/* Validate obuf */
4601 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4602 		ciphertext,
4603 		tdata->ciphertext.data,
4604 		tdata->validDataLenInBits.len,
4605 		"SNOW 3G Ciphertext data not as expected");
4606 	return 0;
4607 }
4608 
4609 
4610 static int
4611 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4612 {
4613 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4614 	struct crypto_unittest_params *ut_params = &unittest_params;
4615 	uint8_t *plaintext, *ciphertext;
4616 
4617 	int retval;
4618 	unsigned plaintext_pad_len;
4619 	unsigned plaintext_len;
4620 	struct rte_cryptodev_info dev_info;
4621 
4622 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4623 	uint64_t feat_flags = dev_info.feature_flags;
4624 
4625 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4626 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4627 		printf("Device does not support RAW data-path APIs.\n");
4628 		return -ENOTSUP;
4629 	}
4630 
4631 	/* Verify the capabilities */
4632 	struct rte_cryptodev_sym_capability_idx cap_idx;
4633 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4634 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4635 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4636 			&cap_idx) == NULL)
4637 		return TEST_SKIPPED;
4638 
4639 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4640 		return TEST_SKIPPED;
4641 
4642 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4643 		return TEST_SKIPPED;
4644 
4645 	/* Create SNOW 3G session */
4646 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4647 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4648 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4649 					tdata->key.data, tdata->key.len,
4650 					tdata->cipher_iv.len);
4651 	if (retval < 0)
4652 		return retval;
4653 
4654 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4655 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4656 
4657 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4658 			"Failed to allocate input buffer in mempool");
4659 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4660 			"Failed to allocate output buffer in mempool");
4661 
4662 	/* Clear mbuf payload */
4663 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4664 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4665 
4666 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4667 	/* Append data which is padded to a multiple of */
4668 	/* the algorithms block size */
4669 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4670 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4671 				plaintext_pad_len);
4672 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4673 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4674 
4675 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4676 
4677 	/* Create SNOW 3G operation */
4678 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4679 					tdata->cipher_iv.len,
4680 					tdata->validCipherLenInBits.len,
4681 					0);
4682 	if (retval < 0)
4683 		return retval;
4684 
4685 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4686 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4687 					       tdata->cipher_iv.len);
4688 		if (retval != TEST_SUCCESS)
4689 			return retval;
4690 	} else
4691 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4692 						ut_params->op);
4693 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4694 
4695 	ut_params->obuf = ut_params->op->sym->m_dst;
4696 	if (ut_params->obuf)
4697 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4698 	else
4699 		ciphertext = plaintext;
4700 
4701 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4702 
4703 	/* Validate obuf */
4704 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4705 		ciphertext,
4706 		tdata->ciphertext.data,
4707 		tdata->validDataLenInBits.len,
4708 		"SNOW 3G Ciphertext data not as expected");
4709 	return 0;
4710 }
4711 
4712 static int
4713 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4714 		uint8_t sgl_in, uint8_t sgl_out)
4715 {
4716 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4717 	struct crypto_unittest_params *ut_params = &unittest_params;
4718 
4719 	int retval;
4720 	unsigned int plaintext_pad_len;
4721 	unsigned int plaintext_len;
4722 	uint8_t buffer[10000];
4723 	const uint8_t *ciphertext;
4724 
4725 	struct rte_cryptodev_info dev_info;
4726 
4727 	/* Verify the capabilities */
4728 	struct rte_cryptodev_sym_capability_idx cap_idx;
4729 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4730 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4731 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4732 			&cap_idx) == NULL)
4733 		return TEST_SKIPPED;
4734 
4735 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4736 		return TEST_SKIPPED;
4737 
4738 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4739 		return TEST_SKIPPED;
4740 
4741 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4742 
4743 	uint64_t feat_flags = dev_info.feature_flags;
4744 
4745 	if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4746 			|| ((!sgl_in && sgl_out) &&
4747 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4748 			|| ((sgl_in && !sgl_out) &&
4749 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4750 		printf("Device doesn't support out-of-place scatter gather type. "
4751 				"Test Skipped.\n");
4752 		return TEST_SKIPPED;
4753 	}
4754 
4755 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4756 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4757 		printf("Device does not support RAW data-path APIs.\n");
4758 		return -ENOTSUP;
4759 	}
4760 
4761 	/* Create SNOW 3G session */
4762 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4763 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4764 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4765 					tdata->key.data, tdata->key.len,
4766 					tdata->cipher_iv.len);
4767 	if (retval < 0)
4768 		return retval;
4769 
4770 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4771 	/* Append data which is padded to a multiple of */
4772 	/* the algorithms block size */
4773 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4774 
4775 	if (sgl_in)
4776 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4777 				plaintext_pad_len, 10, 0);
4778 	else {
4779 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4780 		rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4781 	}
4782 
4783 	if (sgl_out)
4784 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4785 				plaintext_pad_len, 3, 0);
4786 	else {
4787 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4788 		rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4789 	}
4790 
4791 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4792 			"Failed to allocate input buffer in mempool");
4793 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4794 			"Failed to allocate output buffer in mempool");
4795 
4796 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4797 
4798 	/* Create SNOW 3G operation */
4799 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4800 					tdata->cipher_iv.len,
4801 					tdata->validCipherLenInBits.len,
4802 					0);
4803 	if (retval < 0)
4804 		return retval;
4805 
4806 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4807 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4808 					       tdata->cipher_iv.len);
4809 		if (retval != TEST_SUCCESS)
4810 			return retval;
4811 	} else
4812 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4813 						ut_params->op);
4814 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4815 
4816 	ut_params->obuf = ut_params->op->sym->m_dst;
4817 	if (ut_params->obuf)
4818 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4819 				plaintext_len, buffer);
4820 	else
4821 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4822 				plaintext_len, buffer);
4823 
4824 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4825 
4826 	/* Validate obuf */
4827 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4828 		ciphertext,
4829 		tdata->ciphertext.data,
4830 		tdata->validDataLenInBits.len,
4831 		"SNOW 3G Ciphertext data not as expected");
4832 
4833 	return 0;
4834 }
4835 
4836 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4837 static void
4838 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4839 {
4840 	uint8_t curr_byte, prev_byte;
4841 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4842 	uint8_t lower_byte_mask = (1 << offset) - 1;
4843 	unsigned i;
4844 
4845 	prev_byte = buffer[0];
4846 	buffer[0] >>= offset;
4847 
4848 	for (i = 1; i < length_in_bytes; i++) {
4849 		curr_byte = buffer[i];
4850 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4851 				(curr_byte >> offset);
4852 		prev_byte = curr_byte;
4853 	}
4854 }
4855 
4856 static int
4857 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4858 {
4859 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4860 	struct crypto_unittest_params *ut_params = &unittest_params;
4861 	uint8_t *plaintext, *ciphertext;
4862 	int retval;
4863 	uint32_t plaintext_len;
4864 	uint32_t plaintext_pad_len;
4865 	uint8_t extra_offset = 4;
4866 	uint8_t *expected_ciphertext_shifted;
4867 	struct rte_cryptodev_info dev_info;
4868 
4869 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4870 	uint64_t feat_flags = dev_info.feature_flags;
4871 
4872 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4873 			((tdata->validDataLenInBits.len % 8) != 0)) {
4874 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4875 		return TEST_SKIPPED;
4876 	}
4877 
4878 	/* Verify the capabilities */
4879 	struct rte_cryptodev_sym_capability_idx cap_idx;
4880 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4881 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4882 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4883 			&cap_idx) == NULL)
4884 		return TEST_SKIPPED;
4885 
4886 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4887 		return TEST_SKIPPED;
4888 
4889 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4890 		return TEST_SKIPPED;
4891 
4892 	/* Create SNOW 3G session */
4893 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4894 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4895 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4896 					tdata->key.data, tdata->key.len,
4897 					tdata->cipher_iv.len);
4898 	if (retval < 0)
4899 		return retval;
4900 
4901 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4902 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4903 
4904 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4905 			"Failed to allocate input buffer in mempool");
4906 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4907 			"Failed to allocate output buffer in mempool");
4908 
4909 	/* Clear mbuf payload */
4910 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4911 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4912 
4913 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4914 	/*
4915 	 * Append data which is padded to a
4916 	 * multiple of the algorithms block size
4917 	 */
4918 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4919 
4920 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4921 						plaintext_pad_len);
4922 
4923 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4924 
4925 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4926 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4927 
4928 #ifdef RTE_APP_TEST_DEBUG
4929 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4930 #endif
4931 	/* Create SNOW 3G operation */
4932 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4933 					tdata->cipher_iv.len,
4934 					tdata->validCipherLenInBits.len,
4935 					extra_offset);
4936 	if (retval < 0)
4937 		return retval;
4938 
4939 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4940 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4941 					       tdata->cipher_iv.len);
4942 		if (retval != TEST_SUCCESS)
4943 			return retval;
4944 	} else
4945 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4946 						ut_params->op);
4947 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4948 
4949 	ut_params->obuf = ut_params->op->sym->m_dst;
4950 	if (ut_params->obuf)
4951 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4952 	else
4953 		ciphertext = plaintext;
4954 
4955 #ifdef RTE_APP_TEST_DEBUG
4956 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4957 #endif
4958 
4959 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4960 
4961 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4962 			"failed to reserve memory for ciphertext shifted\n");
4963 
4964 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4965 			ceil_byte_length(tdata->ciphertext.len));
4966 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4967 			extra_offset);
4968 	/* Validate obuf */
4969 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4970 		ciphertext,
4971 		expected_ciphertext_shifted,
4972 		tdata->validDataLenInBits.len,
4973 		extra_offset,
4974 		"SNOW 3G Ciphertext data not as expected");
4975 	return 0;
4976 }
4977 
4978 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4979 {
4980 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4981 	struct crypto_unittest_params *ut_params = &unittest_params;
4982 
4983 	int retval;
4984 
4985 	uint8_t *plaintext, *ciphertext;
4986 	unsigned ciphertext_pad_len;
4987 	unsigned ciphertext_len;
4988 	struct rte_cryptodev_info dev_info;
4989 
4990 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4991 	uint64_t feat_flags = dev_info.feature_flags;
4992 
4993 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4994 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4995 		printf("Device doesn't support RAW data-path APIs.\n");
4996 		return TEST_SKIPPED;
4997 	}
4998 
4999 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5000 		return TEST_SKIPPED;
5001 
5002 	/* Verify the capabilities */
5003 	struct rte_cryptodev_sym_capability_idx cap_idx;
5004 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5005 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5006 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5007 			&cap_idx) == NULL)
5008 		return TEST_SKIPPED;
5009 
5010 	/* Create SNOW 3G session */
5011 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5012 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
5013 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5014 					tdata->key.data, tdata->key.len,
5015 					tdata->cipher_iv.len);
5016 	if (retval < 0)
5017 		return retval;
5018 
5019 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5020 
5021 	/* Clear mbuf payload */
5022 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5023 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5024 
5025 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5026 	/* Append data which is padded to a multiple of */
5027 	/* the algorithms block size */
5028 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5029 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5030 				ciphertext_pad_len);
5031 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5032 
5033 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5034 
5035 	/* Create SNOW 3G operation */
5036 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5037 					tdata->cipher_iv.len,
5038 					tdata->validCipherLenInBits.len,
5039 					tdata->cipher.offset_bits);
5040 	if (retval < 0)
5041 		return retval;
5042 
5043 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5044 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5045 					       tdata->cipher_iv.len);
5046 		if (retval != TEST_SUCCESS)
5047 			return retval;
5048 	} else
5049 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5050 						ut_params->op);
5051 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5052 	ut_params->obuf = ut_params->op->sym->m_dst;
5053 	if (ut_params->obuf)
5054 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5055 	else
5056 		plaintext = ciphertext;
5057 
5058 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5059 
5060 	/* Validate obuf */
5061 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5062 				tdata->plaintext.data,
5063 				tdata->validDataLenInBits.len,
5064 				"SNOW 3G Plaintext data not as expected");
5065 	return 0;
5066 }
5067 
5068 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5069 {
5070 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5071 	struct crypto_unittest_params *ut_params = &unittest_params;
5072 
5073 	int retval;
5074 
5075 	uint8_t *plaintext, *ciphertext;
5076 	unsigned ciphertext_pad_len;
5077 	unsigned ciphertext_len;
5078 	struct rte_cryptodev_info dev_info;
5079 
5080 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5081 	uint64_t feat_flags = dev_info.feature_flags;
5082 
5083 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5084 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5085 		printf("Device does not support RAW data-path APIs.\n");
5086 		return -ENOTSUP;
5087 	}
5088 	/* Verify the capabilities */
5089 	struct rte_cryptodev_sym_capability_idx cap_idx;
5090 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5091 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5092 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5093 			&cap_idx) == NULL)
5094 		return TEST_SKIPPED;
5095 
5096 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5097 		return TEST_SKIPPED;
5098 
5099 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5100 		return TEST_SKIPPED;
5101 
5102 	/* Create SNOW 3G session */
5103 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5104 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
5105 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5106 					tdata->key.data, tdata->key.len,
5107 					tdata->cipher_iv.len);
5108 	if (retval < 0)
5109 		return retval;
5110 
5111 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5112 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5113 
5114 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5115 			"Failed to allocate input buffer");
5116 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
5117 			"Failed to allocate output buffer");
5118 
5119 	/* Clear mbuf payload */
5120 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5121 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5122 
5123 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5124 		       rte_pktmbuf_tailroom(ut_params->obuf));
5125 
5126 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5127 	/* Append data which is padded to a multiple of */
5128 	/* the algorithms block size */
5129 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5130 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5131 				ciphertext_pad_len);
5132 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5133 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5134 
5135 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5136 
5137 	/* Create SNOW 3G operation */
5138 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5139 					tdata->cipher_iv.len,
5140 					tdata->validCipherLenInBits.len,
5141 					0);
5142 	if (retval < 0)
5143 		return retval;
5144 
5145 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5146 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5147 					       tdata->cipher_iv.len);
5148 		if (retval != TEST_SUCCESS)
5149 			return retval;
5150 	} else
5151 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5152 						ut_params->op);
5153 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5154 	ut_params->obuf = ut_params->op->sym->m_dst;
5155 	if (ut_params->obuf)
5156 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5157 	else
5158 		plaintext = ciphertext;
5159 
5160 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5161 
5162 	/* Validate obuf */
5163 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5164 				tdata->plaintext.data,
5165 				tdata->validDataLenInBits.len,
5166 				"SNOW 3G Plaintext data not as expected");
5167 	return 0;
5168 }
5169 
5170 static int
5171 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5172 {
5173 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5174 	struct crypto_unittest_params *ut_params = &unittest_params;
5175 
5176 	int retval;
5177 
5178 	uint8_t *plaintext, *ciphertext;
5179 	unsigned int plaintext_pad_len;
5180 	unsigned int plaintext_len;
5181 
5182 	struct rte_cryptodev_info dev_info;
5183 
5184 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5185 	uint64_t feat_flags = dev_info.feature_flags;
5186 
5187 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5188 			((tdata->validAuthLenInBits.len % 8 != 0) ||
5189 			(tdata->validDataLenInBits.len % 8 != 0))) {
5190 		printf("Device doesn't support NON-Byte Aligned Data.\n");
5191 		return TEST_SKIPPED;
5192 	}
5193 
5194 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5195 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5196 		printf("Device doesn't support RAW data-path APIs.\n");
5197 		return TEST_SKIPPED;
5198 	}
5199 
5200 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5201 		return TEST_SKIPPED;
5202 
5203 	/* Check if device supports ZUC EEA3 */
5204 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5205 			tdata->key.len, tdata->cipher_iv.len) < 0)
5206 		return TEST_SKIPPED;
5207 
5208 	/* Check if device supports ZUC EIA3 */
5209 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5210 			tdata->key.len, tdata->auth_iv.len,
5211 			tdata->digest.len) < 0)
5212 		return TEST_SKIPPED;
5213 
5214 	/* Create ZUC session */
5215 	retval = create_zuc_cipher_auth_encrypt_generate_session(
5216 			ts_params->valid_devs[0],
5217 			tdata);
5218 	if (retval != 0)
5219 		return retval;
5220 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5221 
5222 	/* clear mbuf payload */
5223 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5224 			rte_pktmbuf_tailroom(ut_params->ibuf));
5225 
5226 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5227 	/* Append data which is padded to a multiple of */
5228 	/* the algorithms block size */
5229 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5230 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5231 				plaintext_pad_len);
5232 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5233 
5234 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5235 
5236 	/* Create ZUC operation */
5237 	retval = create_zuc_cipher_hash_generate_operation(tdata);
5238 	if (retval < 0)
5239 		return retval;
5240 
5241 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5242 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5243 					       tdata->cipher_iv.len);
5244 		if (retval != TEST_SUCCESS)
5245 			return retval;
5246 	} else
5247 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5248 			ut_params->op);
5249 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5250 	ut_params->obuf = ut_params->op->sym->m_src;
5251 	if (ut_params->obuf)
5252 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5253 	else
5254 		ciphertext = plaintext;
5255 
5256 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5257 	/* Validate obuf */
5258 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5259 			ciphertext,
5260 			tdata->ciphertext.data,
5261 			tdata->validDataLenInBits.len,
5262 			"ZUC Ciphertext data not as expected");
5263 
5264 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5265 						    uint8_t *,
5266 						    plaintext_pad_len);
5267 
5268 	/* Validate obuf */
5269 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5270 			ut_params->digest,
5271 			tdata->digest.data,
5272 			tdata->digest.len,
5273 			"ZUC Generated auth tag not as expected");
5274 	return 0;
5275 }
5276 
5277 static int
5278 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
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, *ciphertext;
5286 	unsigned plaintext_pad_len;
5287 	unsigned plaintext_len;
5288 	struct rte_cryptodev_info dev_info;
5289 
5290 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5291 	uint64_t feat_flags = dev_info.feature_flags;
5292 
5293 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5294 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5295 		printf("Device doesn't support RAW data-path APIs.\n");
5296 		return TEST_SKIPPED;
5297 	}
5298 
5299 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5300 		return TEST_SKIPPED;
5301 
5302 	/* Verify the capabilities */
5303 	struct rte_cryptodev_sym_capability_idx cap_idx;
5304 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5305 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5306 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5307 			&cap_idx) == NULL)
5308 		return TEST_SKIPPED;
5309 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5310 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5311 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5312 			&cap_idx) == NULL)
5313 		return TEST_SKIPPED;
5314 
5315 	/* Create SNOW 3G session */
5316 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5317 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5318 			RTE_CRYPTO_AUTH_OP_GENERATE,
5319 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5320 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5321 			tdata->key.data, tdata->key.len,
5322 			tdata->key.data, tdata->key.len,
5323 			tdata->auth_iv.len, tdata->digest.len,
5324 			tdata->cipher_iv.len);
5325 	if (retval != 0)
5326 		return retval;
5327 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5328 
5329 	/* clear mbuf payload */
5330 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5331 			rte_pktmbuf_tailroom(ut_params->ibuf));
5332 
5333 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5334 	/* Append data which is padded to a multiple of */
5335 	/* the algorithms block size */
5336 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5337 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5338 				plaintext_pad_len);
5339 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5340 
5341 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5342 
5343 	/* Create SNOW 3G operation */
5344 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5345 			tdata->digest.len, tdata->auth_iv.data,
5346 			tdata->auth_iv.len,
5347 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5348 			tdata->cipher_iv.data, tdata->cipher_iv.len,
5349 			tdata->validCipherLenInBits.len,
5350 			0,
5351 			tdata->validAuthLenInBits.len,
5352 			0
5353 			);
5354 	if (retval < 0)
5355 		return retval;
5356 
5357 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5358 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5359 					       tdata->cipher_iv.len);
5360 		if (retval != TEST_SUCCESS)
5361 			return retval;
5362 	} else
5363 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5364 			ut_params->op);
5365 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5366 	ut_params->obuf = ut_params->op->sym->m_src;
5367 	if (ut_params->obuf)
5368 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5369 	else
5370 		ciphertext = plaintext;
5371 
5372 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5373 	/* Validate obuf */
5374 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5375 			ciphertext,
5376 			tdata->ciphertext.data,
5377 			tdata->validDataLenInBits.len,
5378 			"SNOW 3G Ciphertext data not as expected");
5379 
5380 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5381 						    uint8_t *,
5382 						    plaintext_pad_len);
5383 
5384 	/* Validate obuf */
5385 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5386 			ut_params->digest,
5387 			tdata->digest.data,
5388 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5389 			"SNOW 3G Generated auth tag not as expected");
5390 	return 0;
5391 }
5392 
5393 static int
5394 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5395 	uint8_t op_mode, uint8_t verify)
5396 {
5397 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5398 	struct crypto_unittest_params *ut_params = &unittest_params;
5399 
5400 	int retval;
5401 
5402 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5403 	unsigned int plaintext_pad_len;
5404 	unsigned int plaintext_len;
5405 	unsigned int ciphertext_pad_len;
5406 	unsigned int ciphertext_len;
5407 	unsigned int digest_offset;
5408 
5409 	struct rte_cryptodev_info dev_info;
5410 
5411 	/* Verify the capabilities */
5412 	struct rte_cryptodev_sym_capability_idx cap_idx;
5413 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5414 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5415 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5416 			&cap_idx) == NULL)
5417 		return TEST_SKIPPED;
5418 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5419 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5420 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5421 			&cap_idx) == NULL)
5422 		return TEST_SKIPPED;
5423 
5424 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5425 		return TEST_SKIPPED;
5426 
5427 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5428 
5429 	uint64_t feat_flags = dev_info.feature_flags;
5430 
5431 	if (op_mode == OUT_OF_PLACE) {
5432 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5433 			printf("Device doesn't support digest encrypted.\n");
5434 			return TEST_SKIPPED;
5435 		}
5436 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5437 			return TEST_SKIPPED;
5438 	}
5439 
5440 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5441 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5442 		printf("Device doesn't support RAW data-path APIs.\n");
5443 		return TEST_SKIPPED;
5444 	}
5445 
5446 	/* Create SNOW 3G session */
5447 	retval = create_wireless_algo_auth_cipher_session(
5448 			ts_params->valid_devs[0],
5449 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5450 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5451 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5452 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5453 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5454 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5455 			tdata->key.data, tdata->key.len,
5456 			tdata->key.data, tdata->key.len,
5457 			tdata->auth_iv.len, tdata->digest.len,
5458 			tdata->cipher_iv.len);
5459 	if (retval != 0)
5460 		return retval;
5461 
5462 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5463 	if (op_mode == OUT_OF_PLACE)
5464 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5465 
5466 	/* clear mbuf payload */
5467 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5468 		rte_pktmbuf_tailroom(ut_params->ibuf));
5469 	if (op_mode == OUT_OF_PLACE)
5470 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5471 			rte_pktmbuf_tailroom(ut_params->obuf));
5472 
5473 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5474 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5475 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5476 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5477 
5478 	if (verify) {
5479 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5480 					ciphertext_pad_len);
5481 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5482 		if (op_mode == OUT_OF_PLACE)
5483 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5484 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5485 			ciphertext_len);
5486 	} else {
5487 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5488 					plaintext_pad_len);
5489 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5490 		if (op_mode == OUT_OF_PLACE)
5491 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5492 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5493 	}
5494 
5495 	/* Create SNOW 3G operation */
5496 	retval = create_wireless_algo_auth_cipher_operation(
5497 		tdata->digest.data, tdata->digest.len,
5498 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5499 		tdata->auth_iv.data, tdata->auth_iv.len,
5500 		(tdata->digest.offset_bytes == 0 ?
5501 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5502 			: tdata->digest.offset_bytes),
5503 		tdata->validCipherLenInBits.len,
5504 		tdata->cipher.offset_bits,
5505 		tdata->validAuthLenInBits.len,
5506 		tdata->auth.offset_bits,
5507 		op_mode, 0, verify);
5508 
5509 	if (retval < 0)
5510 		return retval;
5511 
5512 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5513 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5514 					       tdata->cipher_iv.len);
5515 		if (retval != TEST_SUCCESS)
5516 			return retval;
5517 	} else
5518 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5519 			ut_params->op);
5520 
5521 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5522 
5523 	ut_params->obuf = (op_mode == IN_PLACE ?
5524 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5525 
5526 	if (verify) {
5527 		if (ut_params->obuf)
5528 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5529 							uint8_t *);
5530 		else
5531 			plaintext = ciphertext +
5532 				(tdata->cipher.offset_bits >> 3);
5533 
5534 		debug_hexdump(stdout, "plaintext:", plaintext,
5535 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5536 		debug_hexdump(stdout, "plaintext expected:",
5537 			tdata->plaintext.data,
5538 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5539 	} else {
5540 		if (ut_params->obuf)
5541 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5542 							uint8_t *);
5543 		else
5544 			ciphertext = plaintext;
5545 
5546 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5547 			ciphertext_len);
5548 		debug_hexdump(stdout, "ciphertext expected:",
5549 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5550 
5551 		if (tdata->digest.offset_bytes == 0)
5552 			digest_offset = plaintext_pad_len;
5553 		else
5554 			digest_offset = tdata->digest.offset_bytes;
5555 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5556 						    uint8_t *, digest_offset);
5557 
5558 		debug_hexdump(stdout, "digest:", ut_params->digest,
5559 			tdata->digest.len);
5560 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5561 				tdata->digest.len);
5562 	}
5563 
5564 	/* Validate obuf */
5565 	if (verify) {
5566 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5567 			plaintext,
5568 			tdata->plaintext.data,
5569 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5570 			 (tdata->digest.len << 3)),
5571 			tdata->cipher.offset_bits,
5572 			"SNOW 3G Plaintext data not as expected");
5573 	} else {
5574 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5575 			ciphertext,
5576 			tdata->ciphertext.data,
5577 			(tdata->validDataLenInBits.len -
5578 			 tdata->cipher.offset_bits),
5579 			tdata->cipher.offset_bits,
5580 			"SNOW 3G Ciphertext data not as expected");
5581 
5582 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5583 			ut_params->digest,
5584 			tdata->digest.data,
5585 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5586 			"SNOW 3G Generated auth tag not as expected");
5587 	}
5588 	return 0;
5589 }
5590 
5591 static int
5592 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5593 	uint8_t op_mode, uint8_t verify)
5594 {
5595 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5596 	struct crypto_unittest_params *ut_params = &unittest_params;
5597 
5598 	int retval;
5599 
5600 	const uint8_t *plaintext = NULL;
5601 	const uint8_t *ciphertext = NULL;
5602 	const uint8_t *digest = NULL;
5603 	unsigned int plaintext_pad_len;
5604 	unsigned int plaintext_len;
5605 	unsigned int ciphertext_pad_len;
5606 	unsigned int ciphertext_len;
5607 	uint8_t buffer[10000];
5608 	uint8_t digest_buffer[10000];
5609 
5610 	struct rte_cryptodev_info dev_info;
5611 
5612 	/* Verify the capabilities */
5613 	struct rte_cryptodev_sym_capability_idx cap_idx;
5614 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5615 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5616 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5617 			&cap_idx) == NULL)
5618 		return TEST_SKIPPED;
5619 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5620 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5621 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5622 			&cap_idx) == NULL)
5623 		return TEST_SKIPPED;
5624 
5625 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5626 		return TEST_SKIPPED;
5627 
5628 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5629 
5630 	uint64_t feat_flags = dev_info.feature_flags;
5631 
5632 	if (op_mode == IN_PLACE) {
5633 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5634 			printf("Device doesn't support in-place scatter-gather "
5635 					"in both input and output mbufs.\n");
5636 			return TEST_SKIPPED;
5637 		}
5638 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5639 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5640 			printf("Device doesn't support RAW data-path APIs.\n");
5641 			return TEST_SKIPPED;
5642 		}
5643 	} else {
5644 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5645 			return TEST_SKIPPED;
5646 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5647 			printf("Device doesn't support out-of-place scatter-gather "
5648 					"in both input and output mbufs.\n");
5649 			return TEST_SKIPPED;
5650 		}
5651 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5652 			printf("Device doesn't support digest encrypted.\n");
5653 			return TEST_SKIPPED;
5654 		}
5655 	}
5656 
5657 	/* Create SNOW 3G session */
5658 	retval = create_wireless_algo_auth_cipher_session(
5659 			ts_params->valid_devs[0],
5660 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5661 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5662 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5663 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5664 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5665 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5666 			tdata->key.data, tdata->key.len,
5667 			tdata->key.data, tdata->key.len,
5668 			tdata->auth_iv.len, tdata->digest.len,
5669 			tdata->cipher_iv.len);
5670 
5671 	if (retval != 0)
5672 		return retval;
5673 
5674 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5675 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5676 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5677 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5678 
5679 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5680 			plaintext_pad_len, 15, 0);
5681 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5682 			"Failed to allocate input buffer in mempool");
5683 
5684 	if (op_mode == OUT_OF_PLACE) {
5685 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5686 				plaintext_pad_len, 15, 0);
5687 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5688 				"Failed to allocate output buffer in mempool");
5689 	}
5690 
5691 	if (verify) {
5692 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5693 			tdata->ciphertext.data);
5694 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5695 					ciphertext_len, buffer);
5696 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5697 			ciphertext_len);
5698 	} else {
5699 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5700 			tdata->plaintext.data);
5701 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5702 					plaintext_len, buffer);
5703 		debug_hexdump(stdout, "plaintext:", plaintext,
5704 			plaintext_len);
5705 	}
5706 	memset(buffer, 0, sizeof(buffer));
5707 
5708 	/* Create SNOW 3G operation */
5709 	retval = create_wireless_algo_auth_cipher_operation(
5710 		tdata->digest.data, tdata->digest.len,
5711 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5712 		tdata->auth_iv.data, tdata->auth_iv.len,
5713 		(tdata->digest.offset_bytes == 0 ?
5714 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5715 			: tdata->digest.offset_bytes),
5716 		tdata->validCipherLenInBits.len,
5717 		tdata->cipher.offset_bits,
5718 		tdata->validAuthLenInBits.len,
5719 		tdata->auth.offset_bits,
5720 		op_mode, 1, verify);
5721 
5722 	if (retval < 0)
5723 		return retval;
5724 
5725 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5726 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5727 					       tdata->cipher_iv.len);
5728 		if (retval != TEST_SUCCESS)
5729 			return retval;
5730 	} else
5731 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5732 			ut_params->op);
5733 
5734 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5735 
5736 	ut_params->obuf = (op_mode == IN_PLACE ?
5737 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5738 
5739 	if (verify) {
5740 		if (ut_params->obuf)
5741 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5742 					plaintext_len, buffer);
5743 		else
5744 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5745 					plaintext_len, buffer);
5746 
5747 		debug_hexdump(stdout, "plaintext:", plaintext,
5748 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5749 		debug_hexdump(stdout, "plaintext expected:",
5750 			tdata->plaintext.data,
5751 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5752 	} else {
5753 		if (ut_params->obuf)
5754 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5755 					ciphertext_len, buffer);
5756 		else
5757 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5758 					ciphertext_len, buffer);
5759 
5760 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5761 			ciphertext_len);
5762 		debug_hexdump(stdout, "ciphertext expected:",
5763 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5764 
5765 		if (ut_params->obuf)
5766 			digest = rte_pktmbuf_read(ut_params->obuf,
5767 				(tdata->digest.offset_bytes == 0 ?
5768 				plaintext_pad_len : tdata->digest.offset_bytes),
5769 				tdata->digest.len, digest_buffer);
5770 		else
5771 			digest = rte_pktmbuf_read(ut_params->ibuf,
5772 				(tdata->digest.offset_bytes == 0 ?
5773 				plaintext_pad_len : tdata->digest.offset_bytes),
5774 				tdata->digest.len, digest_buffer);
5775 
5776 		debug_hexdump(stdout, "digest:", digest,
5777 			tdata->digest.len);
5778 		debug_hexdump(stdout, "digest expected:",
5779 			tdata->digest.data, tdata->digest.len);
5780 	}
5781 
5782 	/* Validate obuf */
5783 	if (verify) {
5784 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5785 			plaintext,
5786 			tdata->plaintext.data,
5787 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5788 			 (tdata->digest.len << 3)),
5789 			tdata->cipher.offset_bits,
5790 			"SNOW 3G Plaintext data not as expected");
5791 	} else {
5792 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5793 			ciphertext,
5794 			tdata->ciphertext.data,
5795 			(tdata->validDataLenInBits.len -
5796 			 tdata->cipher.offset_bits),
5797 			tdata->cipher.offset_bits,
5798 			"SNOW 3G Ciphertext data not as expected");
5799 
5800 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5801 			digest,
5802 			tdata->digest.data,
5803 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5804 			"SNOW 3G Generated auth tag not as expected");
5805 	}
5806 	return 0;
5807 }
5808 
5809 static int
5810 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5811 	uint8_t op_mode, uint8_t verify)
5812 {
5813 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5814 	struct crypto_unittest_params *ut_params = &unittest_params;
5815 
5816 	int retval;
5817 
5818 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5819 	unsigned int plaintext_pad_len;
5820 	unsigned int plaintext_len;
5821 	unsigned int ciphertext_pad_len;
5822 	unsigned int ciphertext_len;
5823 	unsigned int digest_offset;
5824 
5825 	struct rte_cryptodev_info dev_info;
5826 
5827 	/* Verify the capabilities */
5828 	struct rte_cryptodev_sym_capability_idx cap_idx;
5829 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5830 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5831 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5832 			&cap_idx) == NULL)
5833 		return TEST_SKIPPED;
5834 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5835 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5836 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5837 			&cap_idx) == NULL)
5838 		return TEST_SKIPPED;
5839 
5840 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5841 
5842 	uint64_t feat_flags = dev_info.feature_flags;
5843 
5844 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5845 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5846 		printf("Device doesn't support RAW data-path APIs.\n");
5847 		return TEST_SKIPPED;
5848 	}
5849 
5850 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5851 		return TEST_SKIPPED;
5852 
5853 	if (op_mode == OUT_OF_PLACE) {
5854 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5855 			return TEST_SKIPPED;
5856 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5857 			printf("Device doesn't support digest encrypted.\n");
5858 			return TEST_SKIPPED;
5859 		}
5860 	}
5861 
5862 	/* Create KASUMI session */
5863 	retval = create_wireless_algo_auth_cipher_session(
5864 			ts_params->valid_devs[0],
5865 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5866 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5867 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5868 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5869 			RTE_CRYPTO_AUTH_KASUMI_F9,
5870 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5871 			tdata->key.data, tdata->key.len,
5872 			tdata->key.data, tdata->key.len,
5873 			0, tdata->digest.len,
5874 			tdata->cipher_iv.len);
5875 
5876 	if (retval != 0)
5877 		return retval;
5878 
5879 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5880 	if (op_mode == OUT_OF_PLACE)
5881 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5882 
5883 	/* clear mbuf payload */
5884 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5885 		rte_pktmbuf_tailroom(ut_params->ibuf));
5886 	if (op_mode == OUT_OF_PLACE)
5887 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5888 			rte_pktmbuf_tailroom(ut_params->obuf));
5889 
5890 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5891 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5892 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5893 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5894 
5895 	if (verify) {
5896 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5897 					ciphertext_pad_len);
5898 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5899 		if (op_mode == OUT_OF_PLACE)
5900 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5901 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5902 			ciphertext_len);
5903 	} else {
5904 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5905 					plaintext_pad_len);
5906 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5907 		if (op_mode == OUT_OF_PLACE)
5908 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5909 		debug_hexdump(stdout, "plaintext:", plaintext,
5910 			plaintext_len);
5911 	}
5912 
5913 	/* Create KASUMI operation */
5914 	retval = create_wireless_algo_auth_cipher_operation(
5915 		tdata->digest.data, tdata->digest.len,
5916 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5917 		NULL, 0,
5918 		(tdata->digest.offset_bytes == 0 ?
5919 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5920 			: tdata->digest.offset_bytes),
5921 		tdata->validCipherLenInBits.len,
5922 		tdata->validCipherOffsetInBits.len,
5923 		tdata->validAuthLenInBits.len,
5924 		0,
5925 		op_mode, 0, verify);
5926 
5927 	if (retval < 0)
5928 		return retval;
5929 
5930 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5931 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5932 					       tdata->cipher_iv.len);
5933 		if (retval != TEST_SUCCESS)
5934 			return retval;
5935 	} else
5936 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5937 			ut_params->op);
5938 
5939 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5940 
5941 	ut_params->obuf = (op_mode == IN_PLACE ?
5942 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5943 
5944 
5945 	if (verify) {
5946 		if (ut_params->obuf)
5947 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5948 							uint8_t *);
5949 		else
5950 			plaintext = ciphertext;
5951 
5952 		debug_hexdump(stdout, "plaintext:", plaintext,
5953 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5954 		debug_hexdump(stdout, "plaintext expected:",
5955 			tdata->plaintext.data,
5956 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5957 	} else {
5958 		if (ut_params->obuf)
5959 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5960 							uint8_t *);
5961 		else
5962 			ciphertext = plaintext;
5963 
5964 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5965 			ciphertext_len);
5966 		debug_hexdump(stdout, "ciphertext expected:",
5967 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5968 
5969 		if (tdata->digest.offset_bytes == 0)
5970 			digest_offset = plaintext_pad_len;
5971 		else
5972 			digest_offset = tdata->digest.offset_bytes;
5973 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5974 						    uint8_t *, digest_offset);
5975 
5976 		debug_hexdump(stdout, "digest:", ut_params->digest,
5977 			tdata->digest.len);
5978 		debug_hexdump(stdout, "digest expected:",
5979 			tdata->digest.data, tdata->digest.len);
5980 	}
5981 
5982 	/* Validate obuf */
5983 	if (verify) {
5984 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5985 			plaintext,
5986 			tdata->plaintext.data,
5987 			tdata->plaintext.len >> 3,
5988 			"KASUMI Plaintext data not as expected");
5989 	} else {
5990 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5991 			ciphertext,
5992 			tdata->ciphertext.data,
5993 			tdata->ciphertext.len >> 3,
5994 			"KASUMI Ciphertext data not as expected");
5995 
5996 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5997 			ut_params->digest,
5998 			tdata->digest.data,
5999 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6000 			"KASUMI Generated auth tag not as expected");
6001 	}
6002 	return 0;
6003 }
6004 
6005 static int
6006 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6007 	uint8_t op_mode, uint8_t verify)
6008 {
6009 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6010 	struct crypto_unittest_params *ut_params = &unittest_params;
6011 
6012 	int retval;
6013 
6014 	const uint8_t *plaintext = NULL;
6015 	const uint8_t *ciphertext = NULL;
6016 	const uint8_t *digest = NULL;
6017 	unsigned int plaintext_pad_len;
6018 	unsigned int plaintext_len;
6019 	unsigned int ciphertext_pad_len;
6020 	unsigned int ciphertext_len;
6021 	uint8_t buffer[10000];
6022 	uint8_t digest_buffer[10000];
6023 
6024 	struct rte_cryptodev_info dev_info;
6025 
6026 	/* Verify the capabilities */
6027 	struct rte_cryptodev_sym_capability_idx cap_idx;
6028 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6029 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6030 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6031 			&cap_idx) == NULL)
6032 		return TEST_SKIPPED;
6033 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6034 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6035 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6036 			&cap_idx) == NULL)
6037 		return TEST_SKIPPED;
6038 
6039 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6040 		return TEST_SKIPPED;
6041 
6042 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6043 
6044 	uint64_t feat_flags = dev_info.feature_flags;
6045 
6046 	if (op_mode == IN_PLACE) {
6047 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6048 			printf("Device doesn't support in-place scatter-gather "
6049 					"in both input and output mbufs.\n");
6050 			return TEST_SKIPPED;
6051 		}
6052 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6053 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6054 			printf("Device doesn't support RAW data-path APIs.\n");
6055 			return TEST_SKIPPED;
6056 		}
6057 	} else {
6058 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6059 			return TEST_SKIPPED;
6060 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6061 			printf("Device doesn't support out-of-place scatter-gather "
6062 					"in both input and output mbufs.\n");
6063 			return TEST_SKIPPED;
6064 		}
6065 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6066 			printf("Device doesn't support digest encrypted.\n");
6067 			return TEST_SKIPPED;
6068 		}
6069 	}
6070 
6071 	/* Create KASUMI session */
6072 	retval = create_wireless_algo_auth_cipher_session(
6073 			ts_params->valid_devs[0],
6074 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6075 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6076 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6077 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6078 			RTE_CRYPTO_AUTH_KASUMI_F9,
6079 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6080 			tdata->key.data, tdata->key.len,
6081 			tdata->key.data, tdata->key.len,
6082 			0, tdata->digest.len,
6083 			tdata->cipher_iv.len);
6084 
6085 	if (retval != 0)
6086 		return retval;
6087 
6088 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6089 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6090 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6091 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6092 
6093 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6094 			plaintext_pad_len, 15, 0);
6095 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6096 			"Failed to allocate input buffer in mempool");
6097 
6098 	if (op_mode == OUT_OF_PLACE) {
6099 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6100 				plaintext_pad_len, 15, 0);
6101 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6102 				"Failed to allocate output buffer in mempool");
6103 	}
6104 
6105 	if (verify) {
6106 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6107 			tdata->ciphertext.data);
6108 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6109 					ciphertext_len, buffer);
6110 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6111 			ciphertext_len);
6112 	} else {
6113 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6114 			tdata->plaintext.data);
6115 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6116 					plaintext_len, buffer);
6117 		debug_hexdump(stdout, "plaintext:", plaintext,
6118 			plaintext_len);
6119 	}
6120 	memset(buffer, 0, sizeof(buffer));
6121 
6122 	/* Create KASUMI operation */
6123 	retval = create_wireless_algo_auth_cipher_operation(
6124 		tdata->digest.data, tdata->digest.len,
6125 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6126 		NULL, 0,
6127 		(tdata->digest.offset_bytes == 0 ?
6128 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6129 			: tdata->digest.offset_bytes),
6130 		tdata->validCipherLenInBits.len,
6131 		tdata->validCipherOffsetInBits.len,
6132 		tdata->validAuthLenInBits.len,
6133 		0,
6134 		op_mode, 1, verify);
6135 
6136 	if (retval < 0)
6137 		return retval;
6138 
6139 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6140 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6141 					       tdata->cipher_iv.len);
6142 		if (retval != TEST_SUCCESS)
6143 			return retval;
6144 	} else
6145 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6146 			ut_params->op);
6147 
6148 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6149 
6150 	ut_params->obuf = (op_mode == IN_PLACE ?
6151 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6152 
6153 	if (verify) {
6154 		if (ut_params->obuf)
6155 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6156 					plaintext_len, buffer);
6157 		else
6158 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6159 					plaintext_len, buffer);
6160 
6161 		debug_hexdump(stdout, "plaintext:", plaintext,
6162 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6163 		debug_hexdump(stdout, "plaintext expected:",
6164 			tdata->plaintext.data,
6165 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6166 	} else {
6167 		if (ut_params->obuf)
6168 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6169 					ciphertext_len, buffer);
6170 		else
6171 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6172 					ciphertext_len, buffer);
6173 
6174 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6175 			ciphertext_len);
6176 		debug_hexdump(stdout, "ciphertext expected:",
6177 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6178 
6179 		if (ut_params->obuf)
6180 			digest = rte_pktmbuf_read(ut_params->obuf,
6181 				(tdata->digest.offset_bytes == 0 ?
6182 				plaintext_pad_len : tdata->digest.offset_bytes),
6183 				tdata->digest.len, digest_buffer);
6184 		else
6185 			digest = rte_pktmbuf_read(ut_params->ibuf,
6186 				(tdata->digest.offset_bytes == 0 ?
6187 				plaintext_pad_len : tdata->digest.offset_bytes),
6188 				tdata->digest.len, digest_buffer);
6189 
6190 		debug_hexdump(stdout, "digest:", digest,
6191 			tdata->digest.len);
6192 		debug_hexdump(stdout, "digest expected:",
6193 			tdata->digest.data, tdata->digest.len);
6194 	}
6195 
6196 	/* Validate obuf */
6197 	if (verify) {
6198 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6199 			plaintext,
6200 			tdata->plaintext.data,
6201 			tdata->plaintext.len >> 3,
6202 			"KASUMI Plaintext data not as expected");
6203 	} else {
6204 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6205 			ciphertext,
6206 			tdata->ciphertext.data,
6207 			tdata->validDataLenInBits.len,
6208 			"KASUMI Ciphertext data not as expected");
6209 
6210 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6211 			digest,
6212 			tdata->digest.data,
6213 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6214 			"KASUMI Generated auth tag not as expected");
6215 	}
6216 	return 0;
6217 }
6218 
6219 static int
6220 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6221 {
6222 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6223 	struct crypto_unittest_params *ut_params = &unittest_params;
6224 
6225 	int retval;
6226 
6227 	uint8_t *plaintext, *ciphertext;
6228 	unsigned plaintext_pad_len;
6229 	unsigned plaintext_len;
6230 	struct rte_cryptodev_info dev_info;
6231 
6232 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6233 	uint64_t feat_flags = dev_info.feature_flags;
6234 
6235 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6236 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6237 		printf("Device doesn't support RAW data-path APIs.\n");
6238 		return TEST_SKIPPED;
6239 	}
6240 
6241 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6242 		return TEST_SKIPPED;
6243 
6244 	/* Verify the capabilities */
6245 	struct rte_cryptodev_sym_capability_idx cap_idx;
6246 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6247 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6248 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6249 			&cap_idx) == NULL)
6250 		return TEST_SKIPPED;
6251 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6252 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6253 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6254 			&cap_idx) == NULL)
6255 		return TEST_SKIPPED;
6256 
6257 	/* Create KASUMI session */
6258 	retval = create_wireless_algo_cipher_auth_session(
6259 			ts_params->valid_devs[0],
6260 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6261 			RTE_CRYPTO_AUTH_OP_GENERATE,
6262 			RTE_CRYPTO_AUTH_KASUMI_F9,
6263 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6264 			tdata->key.data, tdata->key.len,
6265 			tdata->key.data, tdata->key.len,
6266 			0, tdata->digest.len,
6267 			tdata->cipher_iv.len);
6268 	if (retval != 0)
6269 		return retval;
6270 
6271 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6272 
6273 	/* clear mbuf payload */
6274 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6275 			rte_pktmbuf_tailroom(ut_params->ibuf));
6276 
6277 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6278 	/* Append data which is padded to a multiple of */
6279 	/* the algorithms block size */
6280 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6281 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6282 				plaintext_pad_len);
6283 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6284 
6285 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6286 
6287 	/* Create KASUMI operation */
6288 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6289 				tdata->digest.len, NULL, 0,
6290 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6291 				tdata->cipher_iv.data, tdata->cipher_iv.len,
6292 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6293 				tdata->validCipherOffsetInBits.len,
6294 				tdata->validAuthLenInBits.len,
6295 				0
6296 				);
6297 	if (retval < 0)
6298 		return retval;
6299 
6300 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6301 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6302 					       tdata->cipher_iv.len);
6303 		if (retval != TEST_SUCCESS)
6304 			return retval;
6305 	} else
6306 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6307 			ut_params->op);
6308 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6309 
6310 	if (ut_params->op->sym->m_dst)
6311 		ut_params->obuf = ut_params->op->sym->m_dst;
6312 	else
6313 		ut_params->obuf = ut_params->op->sym->m_src;
6314 
6315 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6316 				tdata->validCipherOffsetInBits.len >> 3);
6317 
6318 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6319 						    uint8_t *,
6320 						    plaintext_pad_len);
6321 
6322 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6323 				(tdata->validCipherOffsetInBits.len >> 3);
6324 	/* Validate obuf */
6325 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6326 		ciphertext,
6327 		reference_ciphertext,
6328 		tdata->validCipherLenInBits.len,
6329 		"KASUMI Ciphertext data not as expected");
6330 
6331 	/* Validate obuf */
6332 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6333 		ut_params->digest,
6334 		tdata->digest.data,
6335 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6336 		"KASUMI Generated auth tag not as expected");
6337 	return 0;
6338 }
6339 
6340 static int
6341 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6342 			const enum rte_crypto_cipher_algorithm cipher_algo,
6343 			const uint16_t key_size, const uint16_t iv_size)
6344 {
6345 	struct rte_cryptodev_sym_capability_idx cap_idx;
6346 	const struct rte_cryptodev_symmetric_capability *cap;
6347 
6348 	/* Check if device supports the algorithm */
6349 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6350 	cap_idx.algo.cipher = cipher_algo;
6351 
6352 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6353 			&cap_idx);
6354 
6355 	if (cap == NULL)
6356 		return -1;
6357 
6358 	/* Check if device supports key size and IV size */
6359 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6360 			iv_size) < 0) {
6361 		return -1;
6362 	}
6363 
6364 	return 0;
6365 }
6366 
6367 static int
6368 check_auth_capability(const struct crypto_testsuite_params *ts_params,
6369 			const enum rte_crypto_auth_algorithm auth_algo,
6370 			const uint16_t key_size, const uint16_t iv_size,
6371 			const uint16_t tag_size)
6372 {
6373 	struct rte_cryptodev_sym_capability_idx cap_idx;
6374 	const struct rte_cryptodev_symmetric_capability *cap;
6375 
6376 	/* Check if device supports the algorithm */
6377 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6378 	cap_idx.algo.auth = auth_algo;
6379 
6380 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6381 			&cap_idx);
6382 
6383 	if (cap == NULL)
6384 		return -1;
6385 
6386 	/* Check if device supports key size and IV size */
6387 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6388 			tag_size, iv_size) < 0) {
6389 		return -1;
6390 	}
6391 
6392 	return 0;
6393 }
6394 
6395 static int
6396 test_zuc_cipher(const struct wireless_test_data *tdata,
6397 		enum rte_crypto_cipher_operation direction)
6398 {
6399 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6400 	struct crypto_unittest_params *ut_params = &unittest_params;
6401 
6402 	int retval;
6403 	uint8_t *plaintext = NULL;
6404 	uint8_t *ciphertext = NULL;
6405 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6406 	unsigned int plaintext_len = 0;
6407 	unsigned int ciphertext_len = 0;
6408 	struct rte_cryptodev_info dev_info;
6409 
6410 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6411 	uint64_t feat_flags = dev_info.feature_flags;
6412 
6413 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6414 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6415 		printf("Device doesn't support RAW data-path APIs.\n");
6416 		return TEST_SKIPPED;
6417 	}
6418 
6419 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6420 		return TEST_SKIPPED;
6421 
6422 	/* Check if device supports ZUC EEA3 */
6423 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6424 			tdata->key.len, tdata->cipher_iv.len) < 0)
6425 		return TEST_SKIPPED;
6426 
6427 	/* Create ZUC session */
6428 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6429 					direction,
6430 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
6431 					tdata->key.data, tdata->key.len,
6432 					tdata->cipher_iv.len);
6433 	if (retval != 0)
6434 		return retval;
6435 
6436 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6437 
6438 	/* Clear mbuf payload */
6439 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6440 	       rte_pktmbuf_tailroom(ut_params->ibuf));
6441 
6442 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6443 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6444 		/* Append data which is padded to a multiple */
6445 		/* of the algorithms block size */
6446 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6447 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6448 				plaintext_pad_len);
6449 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6450 
6451 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6452 	} else {
6453 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6454 		/* Append data which is padded to a multiple */
6455 		/* of the algorithms block size */
6456 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6457 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6458 				ciphertext_pad_len);
6459 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6460 
6461 		debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6462 	}
6463 
6464 	/* Create ZUC operation */
6465 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6466 					tdata->cipher_iv.len,
6467 					tdata->plaintext.len,
6468 					tdata->validCipherOffsetInBits.len);
6469 	if (retval < 0)
6470 		return retval;
6471 
6472 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6473 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6474 					       tdata->cipher_iv.len);
6475 		if (retval != TEST_SUCCESS)
6476 			return retval;
6477 	} else
6478 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6479 						ut_params->op);
6480 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6481 
6482 	ut_params->obuf = ut_params->op->sym->m_dst;
6483 
6484 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6485 		if (ut_params->obuf)
6486 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6487 		else
6488 			ciphertext = plaintext;
6489 
6490 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6491 
6492 		/* Validate obuf */
6493 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6494 				ciphertext,
6495 				tdata->ciphertext.data,
6496 				tdata->validCipherLenInBits.len,
6497 				"ZUC Ciphertext data not as expected");
6498 	} else {
6499 		if (ut_params->obuf)
6500 			plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6501 		else
6502 			plaintext = ciphertext;
6503 
6504 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6505 
6506 		const uint8_t *reference_plaintext = tdata->plaintext.data +
6507 				(tdata->validCipherOffsetInBits.len >> 3);
6508 
6509 		/* Validate obuf */
6510 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6511 				plaintext,
6512 				reference_plaintext,
6513 				tdata->validCipherLenInBits.len,
6514 				"ZUC Plaintext data not as expected");
6515 	}
6516 
6517 	return 0;
6518 }
6519 
6520 static int
6521 test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6522 		enum rte_crypto_cipher_operation direction)
6523 {
6524 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6525 	struct crypto_unittest_params *ut_params = &unittest_params;
6526 
6527 	int retval;
6528 
6529 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6530 	unsigned int plaintext_len = 0;
6531 	unsigned int ciphertext_len = 0;
6532 	const uint8_t *ciphertext, *plaintext;
6533 	uint8_t buffer[2048];
6534 	struct rte_cryptodev_info dev_info;
6535 
6536 	/* Check if device supports ZUC EEA3 */
6537 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6538 			tdata->key.len, tdata->cipher_iv.len) < 0)
6539 		return TEST_SKIPPED;
6540 
6541 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6542 		return TEST_SKIPPED;
6543 
6544 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6545 
6546 	uint64_t feat_flags = dev_info.feature_flags;
6547 
6548 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6549 		printf("Device doesn't support in-place scatter-gather. "
6550 				"Test Skipped.\n");
6551 		return TEST_SKIPPED;
6552 	}
6553 
6554 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6555 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6556 		printf("Device doesn't support RAW data-path APIs.\n");
6557 		return TEST_SKIPPED;
6558 	}
6559 
6560 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6561 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6562 
6563 		/* Append data which is padded to a multiple */
6564 		/* of the algorithms block size */
6565 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6566 
6567 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6568 				plaintext_pad_len, 10, 0);
6569 
6570 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6571 				tdata->plaintext.data);
6572 	} else {
6573 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6574 
6575 		/* Append data which is padded to a multiple */
6576 		/* of the algorithms block size */
6577 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6578 
6579 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6580 				ciphertext_pad_len, 10, 0);
6581 
6582 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6583 				tdata->ciphertext.data);
6584 
6585 	}
6586 
6587 	/* Create ZUC session */
6588 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6589 			direction,
6590 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6591 			tdata->key.data, tdata->key.len,
6592 			tdata->cipher_iv.len);
6593 	if (retval < 0)
6594 		return retval;
6595 
6596 	/* Clear mbuf payload */
6597 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6598 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6599 	else
6600 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6601 
6602 	/* Create ZUC operation */
6603 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6604 			tdata->cipher_iv.len, tdata->plaintext.len,
6605 			tdata->validCipherOffsetInBits.len);
6606 	if (retval < 0)
6607 		return retval;
6608 
6609 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6610 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6611 					       tdata->cipher_iv.len);
6612 		if (retval != TEST_SUCCESS)
6613 			return retval;
6614 	} else
6615 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6616 						ut_params->op);
6617 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6618 
6619 	ut_params->obuf = ut_params->op->sym->m_dst;
6620 
6621 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6622 		if (ut_params->obuf)
6623 			ciphertext = rte_pktmbuf_read(ut_params->obuf,
6624 				0, plaintext_len, buffer);
6625 		else
6626 			ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6627 				0, plaintext_len, buffer);
6628 
6629 		/* Validate obuf */
6630 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6631 
6632 		/* Validate obuf */
6633 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6634 			ciphertext,
6635 			tdata->ciphertext.data,
6636 			tdata->validCipherLenInBits.len,
6637 			"ZUC Ciphertext data not as expected");
6638 	} else {
6639 		if (ut_params->obuf)
6640 			plaintext = rte_pktmbuf_read(ut_params->obuf,
6641 				0, ciphertext_len, buffer);
6642 		else
6643 			plaintext = rte_pktmbuf_read(ut_params->ibuf,
6644 				0, ciphertext_len, buffer);
6645 
6646 		/* Validate obuf */
6647 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6648 
6649 		/* Validate obuf */
6650 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6651 			plaintext,
6652 			tdata->plaintext.data,
6653 			tdata->validCipherLenInBits.len,
6654 			"ZUC Plaintext data not as expected");
6655 		}
6656 
6657 	return 0;
6658 }
6659 
6660 static int
6661 test_zuc_authentication(const struct wireless_test_data *tdata,
6662 		enum rte_crypto_auth_operation auth_op)
6663 {
6664 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6665 	struct crypto_unittest_params *ut_params = &unittest_params;
6666 
6667 	int retval;
6668 	unsigned plaintext_pad_len;
6669 	unsigned plaintext_len;
6670 	uint8_t *plaintext;
6671 
6672 	struct rte_cryptodev_info dev_info;
6673 
6674 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6675 	uint64_t feat_flags = dev_info.feature_flags;
6676 
6677 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6678 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6679 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6680 		return TEST_SKIPPED;
6681 	}
6682 
6683 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6684 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6685 		printf("Device doesn't support RAW data-path APIs.\n");
6686 		return TEST_SKIPPED;
6687 	}
6688 
6689 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6690 		return TEST_SKIPPED;
6691 
6692 	/* Check if device supports ZUC EIA3 */
6693 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6694 			tdata->key.len, tdata->auth_iv.len,
6695 			tdata->digest.len) < 0)
6696 		return TEST_SKIPPED;
6697 
6698 	/* Create ZUC session */
6699 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6700 			tdata->key.data, tdata->key.len,
6701 			tdata->auth_iv.len, tdata->digest.len,
6702 			auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6703 	if (retval != 0)
6704 		return retval;
6705 
6706 	/* alloc mbuf and set payload */
6707 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6708 
6709 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6710 	rte_pktmbuf_tailroom(ut_params->ibuf));
6711 
6712 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6713 	/* Append data which is padded to a multiple of */
6714 	/* the algorithms block size */
6715 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6716 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6717 				plaintext_pad_len);
6718 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6719 
6720 	/* Create ZUC operation */
6721 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
6722 			tdata->digest.len,
6723 			tdata->auth_iv.data, tdata->auth_iv.len,
6724 			plaintext_pad_len,
6725 			auth_op, tdata->validAuthLenInBits.len, 0);
6726 	if (retval < 0)
6727 		return retval;
6728 
6729 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6730 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6731 					       0);
6732 		if (retval != TEST_SUCCESS)
6733 			return retval;
6734 	} else
6735 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6736 				ut_params->op);
6737 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6738 	ut_params->obuf = ut_params->op->sym->m_src;
6739 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6740 						    uint8_t *,
6741 						    plaintext_pad_len);
6742 
6743 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6744 		/* Validate obuf */
6745 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6746 				ut_params->digest,
6747 				tdata->digest.data,
6748 				tdata->digest.len,
6749 				"ZUC Generated auth tag not as expected");
6750 		return 0;
6751 	}
6752 
6753 	/* Validate obuf */
6754 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6755 		return 0;
6756 	else
6757 		return -1;
6758 
6759 	return 0;
6760 }
6761 
6762 static int
6763 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6764 	uint8_t op_mode, uint8_t verify)
6765 {
6766 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6767 	struct crypto_unittest_params *ut_params = &unittest_params;
6768 
6769 	int retval;
6770 
6771 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6772 	unsigned int plaintext_pad_len;
6773 	unsigned int plaintext_len;
6774 	unsigned int ciphertext_pad_len;
6775 	unsigned int ciphertext_len;
6776 	unsigned int digest_offset;
6777 
6778 	struct rte_cryptodev_info dev_info;
6779 
6780 	/* Check if device supports ZUC EEA3 */
6781 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6782 			tdata->key.len, tdata->cipher_iv.len) < 0)
6783 		return TEST_SKIPPED;
6784 
6785 	/* Check if device supports ZUC EIA3 */
6786 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6787 			tdata->key.len, tdata->auth_iv.len,
6788 			tdata->digest.len) < 0)
6789 		return TEST_SKIPPED;
6790 
6791 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6792 		return TEST_SKIPPED;
6793 
6794 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6795 
6796 	uint64_t feat_flags = dev_info.feature_flags;
6797 
6798 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6799 		printf("Device doesn't support digest encrypted.\n");
6800 		return TEST_SKIPPED;
6801 	}
6802 	if (op_mode == IN_PLACE) {
6803 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6804 			printf("Device doesn't support in-place scatter-gather "
6805 					"in both input and output mbufs.\n");
6806 			return TEST_SKIPPED;
6807 		}
6808 
6809 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6810 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6811 			printf("Device doesn't support RAW data-path APIs.\n");
6812 			return TEST_SKIPPED;
6813 		}
6814 	} else {
6815 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6816 			return TEST_SKIPPED;
6817 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6818 			printf("Device doesn't support out-of-place scatter-gather "
6819 					"in both input and output mbufs.\n");
6820 			return TEST_SKIPPED;
6821 		}
6822 	}
6823 
6824 	/* Create ZUC session */
6825 	retval = create_wireless_algo_auth_cipher_session(
6826 			ts_params->valid_devs[0],
6827 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6828 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6829 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6830 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6831 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6832 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6833 			tdata->key.data, tdata->key.len,
6834 			tdata->key.data, tdata->key.len,
6835 			tdata->auth_iv.len, tdata->digest.len,
6836 			tdata->cipher_iv.len);
6837 
6838 	if (retval != 0)
6839 		return retval;
6840 
6841 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6842 	if (op_mode == OUT_OF_PLACE)
6843 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6844 
6845 	/* clear mbuf payload */
6846 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6847 		rte_pktmbuf_tailroom(ut_params->ibuf));
6848 	if (op_mode == OUT_OF_PLACE)
6849 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6850 			rte_pktmbuf_tailroom(ut_params->obuf));
6851 
6852 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6853 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6854 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6855 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6856 
6857 	if (verify) {
6858 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6859 					ciphertext_pad_len);
6860 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6861 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6862 			ciphertext_len);
6863 	} else {
6864 		/* make sure enough space to cover partial digest verify case */
6865 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6866 					ciphertext_pad_len);
6867 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6868 		debug_hexdump(stdout, "plaintext:", plaintext,
6869 			plaintext_len);
6870 	}
6871 
6872 	if (op_mode == OUT_OF_PLACE)
6873 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6874 
6875 	/* Create ZUC operation */
6876 	retval = create_wireless_algo_auth_cipher_operation(
6877 		tdata->digest.data, tdata->digest.len,
6878 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6879 		tdata->auth_iv.data, tdata->auth_iv.len,
6880 		(tdata->digest.offset_bytes == 0 ?
6881 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6882 			: tdata->digest.offset_bytes),
6883 		tdata->validCipherLenInBits.len,
6884 		tdata->validCipherOffsetInBits.len,
6885 		tdata->validAuthLenInBits.len,
6886 		0,
6887 		op_mode, 0, verify);
6888 
6889 	if (retval < 0)
6890 		return retval;
6891 
6892 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6893 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6894 					       tdata->cipher_iv.len);
6895 		if (retval != TEST_SUCCESS)
6896 			return retval;
6897 	} else
6898 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6899 			ut_params->op);
6900 
6901 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6902 
6903 	ut_params->obuf = (op_mode == IN_PLACE ?
6904 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6905 
6906 
6907 	if (verify) {
6908 		if (ut_params->obuf)
6909 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6910 							uint8_t *);
6911 		else
6912 			plaintext = ciphertext;
6913 
6914 		debug_hexdump(stdout, "plaintext:", plaintext,
6915 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6916 		debug_hexdump(stdout, "plaintext expected:",
6917 			tdata->plaintext.data,
6918 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6919 	} else {
6920 		if (ut_params->obuf)
6921 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6922 							uint8_t *);
6923 		else
6924 			ciphertext = plaintext;
6925 
6926 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6927 			ciphertext_len);
6928 		debug_hexdump(stdout, "ciphertext expected:",
6929 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6930 
6931 		if (tdata->digest.offset_bytes == 0)
6932 			digest_offset = plaintext_pad_len;
6933 		else
6934 			digest_offset =  tdata->digest.offset_bytes;
6935 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6936 					    uint8_t *, digest_offset);
6937 
6938 		debug_hexdump(stdout, "digest:", ut_params->digest,
6939 			tdata->digest.len);
6940 		debug_hexdump(stdout, "digest expected:",
6941 			tdata->digest.data, tdata->digest.len);
6942 	}
6943 
6944 	/* Validate obuf */
6945 	if (verify) {
6946 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6947 			plaintext,
6948 			tdata->plaintext.data,
6949 			tdata->plaintext.len >> 3,
6950 			"ZUC Plaintext data not as expected");
6951 	} else {
6952 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6953 			ciphertext,
6954 			tdata->ciphertext.data,
6955 			tdata->ciphertext.len >> 3,
6956 			"ZUC Ciphertext data not as expected");
6957 
6958 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6959 			ut_params->digest,
6960 			tdata->digest.data,
6961 			tdata->digest.len,
6962 			"ZUC Generated auth tag not as expected");
6963 	}
6964 	return 0;
6965 }
6966 
6967 static int
6968 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6969 	uint8_t op_mode, uint8_t verify)
6970 {
6971 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6972 	struct crypto_unittest_params *ut_params = &unittest_params;
6973 
6974 	int retval;
6975 
6976 	const uint8_t *plaintext = NULL;
6977 	const uint8_t *ciphertext = NULL;
6978 	const uint8_t *digest = NULL;
6979 	unsigned int plaintext_pad_len;
6980 	unsigned int plaintext_len;
6981 	unsigned int ciphertext_pad_len;
6982 	unsigned int ciphertext_len;
6983 	uint8_t buffer[10000];
6984 	uint8_t digest_buffer[10000];
6985 
6986 	struct rte_cryptodev_info dev_info;
6987 
6988 	/* Check if device supports ZUC EEA3 */
6989 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6990 			tdata->key.len, tdata->cipher_iv.len) < 0)
6991 		return TEST_SKIPPED;
6992 
6993 	/* Check if device supports ZUC EIA3 */
6994 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6995 			tdata->key.len, tdata->auth_iv.len,
6996 			tdata->digest.len) < 0)
6997 		return TEST_SKIPPED;
6998 
6999 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7000 		return TEST_SKIPPED;
7001 
7002 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7003 
7004 	uint64_t feat_flags = dev_info.feature_flags;
7005 
7006 	if (op_mode == IN_PLACE) {
7007 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7008 			printf("Device doesn't support in-place scatter-gather "
7009 					"in both input and output mbufs.\n");
7010 			return TEST_SKIPPED;
7011 		}
7012 
7013 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7014 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7015 			printf("Device doesn't support RAW data-path APIs.\n");
7016 			return TEST_SKIPPED;
7017 		}
7018 	} else {
7019 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7020 			return TEST_SKIPPED;
7021 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7022 			printf("Device doesn't support out-of-place scatter-gather "
7023 					"in both input and output mbufs.\n");
7024 			return TEST_SKIPPED;
7025 		}
7026 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7027 			printf("Device doesn't support digest encrypted.\n");
7028 			return TEST_SKIPPED;
7029 		}
7030 	}
7031 
7032 	/* Create ZUC session */
7033 	retval = create_wireless_algo_auth_cipher_session(
7034 			ts_params->valid_devs[0],
7035 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7036 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7037 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7038 					: RTE_CRYPTO_AUTH_OP_GENERATE),
7039 			RTE_CRYPTO_AUTH_ZUC_EIA3,
7040 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
7041 			tdata->key.data, tdata->key.len,
7042 			tdata->key.data, tdata->key.len,
7043 			tdata->auth_iv.len, tdata->digest.len,
7044 			tdata->cipher_iv.len);
7045 
7046 	if (retval != 0)
7047 		return retval;
7048 
7049 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7050 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
7051 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7052 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7053 
7054 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7055 			plaintext_pad_len, 15, 0);
7056 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7057 			"Failed to allocate input buffer in mempool");
7058 
7059 	if (op_mode == OUT_OF_PLACE) {
7060 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7061 				plaintext_pad_len, 15, 0);
7062 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
7063 				"Failed to allocate output buffer in mempool");
7064 	}
7065 
7066 	if (verify) {
7067 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7068 			tdata->ciphertext.data);
7069 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7070 					ciphertext_len, buffer);
7071 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7072 			ciphertext_len);
7073 	} else {
7074 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7075 			tdata->plaintext.data);
7076 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7077 					plaintext_len, buffer);
7078 		debug_hexdump(stdout, "plaintext:", plaintext,
7079 			plaintext_len);
7080 	}
7081 	memset(buffer, 0, sizeof(buffer));
7082 
7083 	/* Create ZUC operation */
7084 	retval = create_wireless_algo_auth_cipher_operation(
7085 		tdata->digest.data, tdata->digest.len,
7086 		tdata->cipher_iv.data, tdata->cipher_iv.len,
7087 		tdata->auth_iv.data, tdata->auth_iv.len,
7088 		(tdata->digest.offset_bytes == 0 ?
7089 		(verify ? ciphertext_pad_len : plaintext_pad_len)
7090 			: tdata->digest.offset_bytes),
7091 		tdata->validCipherLenInBits.len,
7092 		tdata->validCipherOffsetInBits.len,
7093 		tdata->validAuthLenInBits.len,
7094 		0,
7095 		op_mode, 1, verify);
7096 
7097 	if (retval < 0)
7098 		return retval;
7099 
7100 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7101 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7102 					       tdata->cipher_iv.len);
7103 		if (retval != TEST_SUCCESS)
7104 			return retval;
7105 	} else
7106 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7107 			ut_params->op);
7108 
7109 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7110 
7111 	ut_params->obuf = (op_mode == IN_PLACE ?
7112 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7113 
7114 	if (verify) {
7115 		if (ut_params->obuf)
7116 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7117 					plaintext_len, buffer);
7118 		else
7119 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7120 					plaintext_len, buffer);
7121 
7122 		debug_hexdump(stdout, "plaintext:", plaintext,
7123 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7124 		debug_hexdump(stdout, "plaintext expected:",
7125 			tdata->plaintext.data,
7126 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7127 	} else {
7128 		if (ut_params->obuf)
7129 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7130 					ciphertext_len, buffer);
7131 		else
7132 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7133 					ciphertext_len, buffer);
7134 
7135 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7136 			ciphertext_len);
7137 		debug_hexdump(stdout, "ciphertext expected:",
7138 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7139 
7140 		if (ut_params->obuf)
7141 			digest = rte_pktmbuf_read(ut_params->obuf,
7142 				(tdata->digest.offset_bytes == 0 ?
7143 				plaintext_pad_len : tdata->digest.offset_bytes),
7144 				tdata->digest.len, digest_buffer);
7145 		else
7146 			digest = rte_pktmbuf_read(ut_params->ibuf,
7147 				(tdata->digest.offset_bytes == 0 ?
7148 				plaintext_pad_len : tdata->digest.offset_bytes),
7149 				tdata->digest.len, digest_buffer);
7150 
7151 		debug_hexdump(stdout, "digest:", digest,
7152 			tdata->digest.len);
7153 		debug_hexdump(stdout, "digest expected:",
7154 			tdata->digest.data, tdata->digest.len);
7155 	}
7156 
7157 	/* Validate obuf */
7158 	if (verify) {
7159 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7160 			plaintext,
7161 			tdata->plaintext.data,
7162 			tdata->plaintext.len >> 3,
7163 			"ZUC Plaintext data not as expected");
7164 	} else {
7165 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7166 			ciphertext,
7167 			tdata->ciphertext.data,
7168 			tdata->validDataLenInBits.len,
7169 			"ZUC Ciphertext data not as expected");
7170 
7171 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7172 			digest,
7173 			tdata->digest.data,
7174 			tdata->digest.len,
7175 			"ZUC Generated auth tag not as expected");
7176 	}
7177 	return 0;
7178 }
7179 
7180 static int
7181 test_kasumi_encryption_test_case_1(void)
7182 {
7183 	return test_kasumi_encryption(&kasumi_test_case_1);
7184 }
7185 
7186 static int
7187 test_kasumi_encryption_test_case_1_sgl(void)
7188 {
7189 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7190 }
7191 
7192 static int
7193 test_kasumi_encryption_test_case_1_oop(void)
7194 {
7195 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
7196 }
7197 
7198 static int
7199 test_kasumi_encryption_test_case_1_oop_sgl(void)
7200 {
7201 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7202 }
7203 
7204 static int
7205 test_kasumi_encryption_test_case_2(void)
7206 {
7207 	return test_kasumi_encryption(&kasumi_test_case_2);
7208 }
7209 
7210 static int
7211 test_kasumi_encryption_test_case_3(void)
7212 {
7213 	return test_kasumi_encryption(&kasumi_test_case_3);
7214 }
7215 
7216 static int
7217 test_kasumi_encryption_test_case_4(void)
7218 {
7219 	return test_kasumi_encryption(&kasumi_test_case_4);
7220 }
7221 
7222 static int
7223 test_kasumi_encryption_test_case_5(void)
7224 {
7225 	return test_kasumi_encryption(&kasumi_test_case_5);
7226 }
7227 
7228 static int
7229 test_kasumi_decryption_test_case_1(void)
7230 {
7231 	return test_kasumi_decryption(&kasumi_test_case_1);
7232 }
7233 
7234 static int
7235 test_kasumi_decryption_test_case_1_oop(void)
7236 {
7237 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
7238 }
7239 
7240 static int
7241 test_kasumi_decryption_test_case_2(void)
7242 {
7243 	return test_kasumi_decryption(&kasumi_test_case_2);
7244 }
7245 
7246 static int
7247 test_kasumi_decryption_test_case_3(void)
7248 {
7249 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7250 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7251 		return TEST_SKIPPED;
7252 	return test_kasumi_decryption(&kasumi_test_case_3);
7253 }
7254 
7255 static int
7256 test_kasumi_decryption_test_case_4(void)
7257 {
7258 	return test_kasumi_decryption(&kasumi_test_case_4);
7259 }
7260 
7261 static int
7262 test_kasumi_decryption_test_case_5(void)
7263 {
7264 	return test_kasumi_decryption(&kasumi_test_case_5);
7265 }
7266 static int
7267 test_snow3g_encryption_test_case_1(void)
7268 {
7269 	return test_snow3g_encryption(&snow3g_test_case_1);
7270 }
7271 
7272 static int
7273 test_snow3g_encryption_test_case_1_oop(void)
7274 {
7275 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
7276 }
7277 
7278 static int
7279 test_snow3g_encryption_test_case_1_oop_sgl(void)
7280 {
7281 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7282 }
7283 
7284 static int
7285 test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7286 {
7287 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7288 }
7289 
7290 static int
7291 test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7292 {
7293 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7294 }
7295 
7296 static int
7297 test_snow3g_encryption_test_case_1_offset_oop(void)
7298 {
7299 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7300 }
7301 
7302 static int
7303 test_snow3g_encryption_test_case_2(void)
7304 {
7305 	return test_snow3g_encryption(&snow3g_test_case_2);
7306 }
7307 
7308 static int
7309 test_snow3g_encryption_test_case_3(void)
7310 {
7311 	return test_snow3g_encryption(&snow3g_test_case_3);
7312 }
7313 
7314 static int
7315 test_snow3g_encryption_test_case_4(void)
7316 {
7317 	return test_snow3g_encryption(&snow3g_test_case_4);
7318 }
7319 
7320 static int
7321 test_snow3g_encryption_test_case_5(void)
7322 {
7323 	return test_snow3g_encryption(&snow3g_test_case_5);
7324 }
7325 
7326 static int
7327 test_snow3g_decryption_test_case_1(void)
7328 {
7329 	return test_snow3g_decryption(&snow3g_test_case_1);
7330 }
7331 
7332 static int
7333 test_snow3g_decryption_test_case_1_oop(void)
7334 {
7335 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
7336 }
7337 
7338 static int
7339 test_snow3g_decryption_test_case_2(void)
7340 {
7341 	return test_snow3g_decryption(&snow3g_test_case_2);
7342 }
7343 
7344 static int
7345 test_snow3g_decryption_test_case_3(void)
7346 {
7347 	return test_snow3g_decryption(&snow3g_test_case_3);
7348 }
7349 
7350 static int
7351 test_snow3g_decryption_test_case_4(void)
7352 {
7353 	return test_snow3g_decryption(&snow3g_test_case_4);
7354 }
7355 
7356 static int
7357 test_snow3g_decryption_test_case_5(void)
7358 {
7359 	return test_snow3g_decryption(&snow3g_test_case_5);
7360 }
7361 
7362 /*
7363  * Function prepares snow3g_hash_test_data from snow3g_test_data.
7364  * Pattern digest from snow3g_test_data must be allocated as
7365  * 4 last bytes in plaintext.
7366  */
7367 static void
7368 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7369 		struct snow3g_hash_test_data *output)
7370 {
7371 	if ((pattern != NULL) && (output != NULL)) {
7372 		output->key.len = pattern->key.len;
7373 
7374 		memcpy(output->key.data,
7375 		pattern->key.data, pattern->key.len);
7376 
7377 		output->auth_iv.len = pattern->auth_iv.len;
7378 
7379 		memcpy(output->auth_iv.data,
7380 		pattern->auth_iv.data, pattern->auth_iv.len);
7381 
7382 		output->plaintext.len = pattern->plaintext.len;
7383 
7384 		memcpy(output->plaintext.data,
7385 		pattern->plaintext.data, pattern->plaintext.len >> 3);
7386 
7387 		output->digest.len = pattern->digest.len;
7388 
7389 		memcpy(output->digest.data,
7390 		&pattern->plaintext.data[pattern->digest.offset_bytes],
7391 		pattern->digest.len);
7392 
7393 		output->validAuthLenInBits.len =
7394 		pattern->validAuthLenInBits.len;
7395 	}
7396 }
7397 
7398 /*
7399  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7400  */
7401 static int
7402 test_snow3g_decryption_with_digest_test_case_1(void)
7403 {
7404 	int ret;
7405 	struct snow3g_hash_test_data snow3g_hash_data;
7406 	struct rte_cryptodev_info dev_info;
7407 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7408 
7409 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7410 	uint64_t feat_flags = dev_info.feature_flags;
7411 
7412 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7413 		printf("Device doesn't support encrypted digest operations.\n");
7414 		return TEST_SKIPPED;
7415 	}
7416 
7417 	/*
7418 	 * Function prepare data for hash verification test case.
7419 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
7420 	 */
7421 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7422 
7423 	ret = test_snow3g_decryption(&snow3g_test_case_7);
7424 	if (ret != 0)
7425 		return ret;
7426 
7427 	return test_snow3g_authentication_verify(&snow3g_hash_data);
7428 }
7429 
7430 static int
7431 test_snow3g_cipher_auth_test_case_1(void)
7432 {
7433 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
7434 }
7435 
7436 static int
7437 test_snow3g_auth_cipher_test_case_1(void)
7438 {
7439 	return test_snow3g_auth_cipher(
7440 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7441 }
7442 
7443 static int
7444 test_snow3g_auth_cipher_test_case_2(void)
7445 {
7446 	return test_snow3g_auth_cipher(
7447 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7448 }
7449 
7450 static int
7451 test_snow3g_auth_cipher_test_case_2_oop(void)
7452 {
7453 	return test_snow3g_auth_cipher(
7454 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7455 }
7456 
7457 static int
7458 test_snow3g_auth_cipher_part_digest_enc(void)
7459 {
7460 	return test_snow3g_auth_cipher(
7461 		&snow3g_auth_cipher_partial_digest_encryption,
7462 			IN_PLACE, 0);
7463 }
7464 
7465 static int
7466 test_snow3g_auth_cipher_part_digest_enc_oop(void)
7467 {
7468 	return test_snow3g_auth_cipher(
7469 		&snow3g_auth_cipher_partial_digest_encryption,
7470 			OUT_OF_PLACE, 0);
7471 }
7472 
7473 static int
7474 test_snow3g_auth_cipher_test_case_3_sgl(void)
7475 {
7476 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7477 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7478 		return TEST_SKIPPED;
7479 	return test_snow3g_auth_cipher_sgl(
7480 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7481 }
7482 
7483 static int
7484 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7485 {
7486 	return test_snow3g_auth_cipher_sgl(
7487 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7488 }
7489 
7490 static int
7491 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7492 {
7493 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7494 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7495 		return TEST_SKIPPED;
7496 	return test_snow3g_auth_cipher_sgl(
7497 		&snow3g_auth_cipher_partial_digest_encryption,
7498 			IN_PLACE, 0);
7499 }
7500 
7501 static int
7502 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7503 {
7504 	return test_snow3g_auth_cipher_sgl(
7505 		&snow3g_auth_cipher_partial_digest_encryption,
7506 			OUT_OF_PLACE, 0);
7507 }
7508 
7509 static int
7510 test_snow3g_auth_cipher_total_digest_enc_1(void)
7511 {
7512 	return test_snow3g_auth_cipher(
7513 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7514 }
7515 
7516 static int
7517 test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7518 {
7519 	return test_snow3g_auth_cipher(
7520 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7521 }
7522 
7523 static int
7524 test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7525 {
7526 	return test_snow3g_auth_cipher_sgl(
7527 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7528 }
7529 
7530 static int
7531 test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7532 {
7533 	return test_snow3g_auth_cipher_sgl(
7534 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7535 }
7536 
7537 static int
7538 test_snow3g_auth_cipher_verify_test_case_1(void)
7539 {
7540 	return test_snow3g_auth_cipher(
7541 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7542 }
7543 
7544 static int
7545 test_snow3g_auth_cipher_verify_test_case_2(void)
7546 {
7547 	return test_snow3g_auth_cipher(
7548 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7549 }
7550 
7551 static int
7552 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7553 {
7554 	return test_snow3g_auth_cipher(
7555 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7556 }
7557 
7558 static int
7559 test_snow3g_auth_cipher_verify_part_digest_enc(void)
7560 {
7561 	return test_snow3g_auth_cipher(
7562 		&snow3g_auth_cipher_partial_digest_encryption,
7563 			IN_PLACE, 1);
7564 }
7565 
7566 static int
7567 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7568 {
7569 	return test_snow3g_auth_cipher(
7570 		&snow3g_auth_cipher_partial_digest_encryption,
7571 			OUT_OF_PLACE, 1);
7572 }
7573 
7574 static int
7575 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7576 {
7577 	return test_snow3g_auth_cipher_sgl(
7578 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7579 }
7580 
7581 static int
7582 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7583 {
7584 	return test_snow3g_auth_cipher_sgl(
7585 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7586 }
7587 
7588 static int
7589 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7590 {
7591 	return test_snow3g_auth_cipher_sgl(
7592 		&snow3g_auth_cipher_partial_digest_encryption,
7593 			IN_PLACE, 1);
7594 }
7595 
7596 static int
7597 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7598 {
7599 	return test_snow3g_auth_cipher_sgl(
7600 		&snow3g_auth_cipher_partial_digest_encryption,
7601 			OUT_OF_PLACE, 1);
7602 }
7603 
7604 static int
7605 test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7606 {
7607 	return test_snow3g_auth_cipher(
7608 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7609 }
7610 
7611 static int
7612 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7613 {
7614 	return test_snow3g_auth_cipher(
7615 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7616 }
7617 
7618 static int
7619 test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7620 {
7621 	return test_snow3g_auth_cipher_sgl(
7622 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7623 }
7624 
7625 static int
7626 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7627 {
7628 	return test_snow3g_auth_cipher_sgl(
7629 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7630 }
7631 
7632 static int
7633 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7634 {
7635 	return test_snow3g_auth_cipher(
7636 		&snow3g_test_case_7, IN_PLACE, 0);
7637 }
7638 
7639 static int
7640 test_kasumi_auth_cipher_test_case_1(void)
7641 {
7642 	return test_kasumi_auth_cipher(
7643 		&kasumi_test_case_3, IN_PLACE, 0);
7644 }
7645 
7646 static int
7647 test_kasumi_auth_cipher_test_case_2(void)
7648 {
7649 	return test_kasumi_auth_cipher(
7650 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7651 }
7652 
7653 static int
7654 test_kasumi_auth_cipher_test_case_2_oop(void)
7655 {
7656 	return test_kasumi_auth_cipher(
7657 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7658 }
7659 
7660 static int
7661 test_kasumi_auth_cipher_test_case_2_sgl(void)
7662 {
7663 	return test_kasumi_auth_cipher_sgl(
7664 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7665 }
7666 
7667 static int
7668 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7669 {
7670 	return test_kasumi_auth_cipher_sgl(
7671 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7672 }
7673 
7674 static int
7675 test_kasumi_auth_cipher_verify_test_case_1(void)
7676 {
7677 	return test_kasumi_auth_cipher(
7678 		&kasumi_test_case_3, IN_PLACE, 1);
7679 }
7680 
7681 static int
7682 test_kasumi_auth_cipher_verify_test_case_2(void)
7683 {
7684 	return test_kasumi_auth_cipher(
7685 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7686 }
7687 
7688 static int
7689 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7690 {
7691 	return test_kasumi_auth_cipher(
7692 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7693 }
7694 
7695 static int
7696 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7697 {
7698 	return test_kasumi_auth_cipher_sgl(
7699 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7700 }
7701 
7702 static int
7703 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7704 {
7705 	return test_kasumi_auth_cipher_sgl(
7706 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7707 }
7708 
7709 static int
7710 test_kasumi_cipher_auth_test_case_1(void)
7711 {
7712 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7713 }
7714 
7715 static int
7716 test_zuc_encryption_test_case_1(void)
7717 {
7718 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7719 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7720 }
7721 
7722 static int
7723 test_zuc_encryption_test_case_2(void)
7724 {
7725 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7726 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7727 }
7728 
7729 static int
7730 test_zuc_encryption_test_case_3(void)
7731 {
7732 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7733 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7734 }
7735 
7736 static int
7737 test_zuc_encryption_test_case_4(void)
7738 {
7739 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7740 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7741 }
7742 
7743 static int
7744 test_zuc_encryption_test_case_5(void)
7745 {
7746 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7747 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7748 }
7749 
7750 static int
7751 test_zuc_encryption_test_case_6_sgl(void)
7752 {
7753 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7754 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7755 }
7756 
7757 static int
7758 test_zuc_decryption_test_case_1(void)
7759 {
7760 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7761 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7762 }
7763 
7764 static int
7765 test_zuc_decryption_test_case_2(void)
7766 {
7767 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7768 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7769 }
7770 
7771 static int
7772 test_zuc_decryption_test_case_3(void)
7773 {
7774 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7775 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7776 }
7777 
7778 static int
7779 test_zuc_decryption_test_case_4(void)
7780 {
7781 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7782 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7783 }
7784 
7785 static int
7786 test_zuc_decryption_test_case_5(void)
7787 {
7788 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7789 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7790 }
7791 
7792 static int
7793 test_zuc_decryption_test_case_6_sgl(void)
7794 {
7795 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7796 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7797 }
7798 
7799 static int
7800 test_zuc_hash_generate_test_case_1(void)
7801 {
7802 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7803 			RTE_CRYPTO_AUTH_OP_GENERATE);
7804 }
7805 
7806 static int
7807 test_zuc_hash_generate_test_case_2(void)
7808 {
7809 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7810 			RTE_CRYPTO_AUTH_OP_GENERATE);
7811 }
7812 
7813 static int
7814 test_zuc_hash_generate_test_case_3(void)
7815 {
7816 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7817 			RTE_CRYPTO_AUTH_OP_GENERATE);
7818 }
7819 
7820 static int
7821 test_zuc_hash_generate_test_case_4(void)
7822 {
7823 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7824 			RTE_CRYPTO_AUTH_OP_GENERATE);
7825 }
7826 
7827 static int
7828 test_zuc_hash_generate_test_case_5(void)
7829 {
7830 	return test_zuc_authentication(&zuc_test_auth_5670b,
7831 			RTE_CRYPTO_AUTH_OP_GENERATE);
7832 }
7833 
7834 static int
7835 test_zuc_hash_generate_test_case_6(void)
7836 {
7837 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7838 			RTE_CRYPTO_AUTH_OP_GENERATE);
7839 }
7840 
7841 static int
7842 test_zuc_hash_generate_test_case_7(void)
7843 {
7844 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7845 			RTE_CRYPTO_AUTH_OP_GENERATE);
7846 }
7847 
7848 static int
7849 test_zuc_hash_generate_test_case_8(void)
7850 {
7851 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7852 			RTE_CRYPTO_AUTH_OP_GENERATE);
7853 }
7854 
7855 static int
7856 test_zuc_hash_verify_test_case_1(void)
7857 {
7858 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7859 			RTE_CRYPTO_AUTH_OP_VERIFY);
7860 }
7861 
7862 static int
7863 test_zuc_hash_verify_test_case_2(void)
7864 {
7865 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7866 			RTE_CRYPTO_AUTH_OP_VERIFY);
7867 }
7868 
7869 static int
7870 test_zuc_hash_verify_test_case_3(void)
7871 {
7872 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7873 			RTE_CRYPTO_AUTH_OP_VERIFY);
7874 }
7875 
7876 static int
7877 test_zuc_hash_verify_test_case_4(void)
7878 {
7879 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7880 			RTE_CRYPTO_AUTH_OP_VERIFY);
7881 }
7882 
7883 static int
7884 test_zuc_hash_verify_test_case_5(void)
7885 {
7886 	return test_zuc_authentication(&zuc_test_auth_5670b,
7887 			RTE_CRYPTO_AUTH_OP_VERIFY);
7888 }
7889 
7890 static int
7891 test_zuc_hash_verify_test_case_6(void)
7892 {
7893 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7894 			RTE_CRYPTO_AUTH_OP_VERIFY);
7895 }
7896 
7897 static int
7898 test_zuc_hash_verify_test_case_7(void)
7899 {
7900 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7901 			RTE_CRYPTO_AUTH_OP_VERIFY);
7902 }
7903 
7904 static int
7905 test_zuc_hash_verify_test_case_8(void)
7906 {
7907 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7908 			RTE_CRYPTO_AUTH_OP_VERIFY);
7909 }
7910 
7911 static int
7912 test_zuc_cipher_auth_test_case_1(void)
7913 {
7914 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7915 }
7916 
7917 static int
7918 test_zuc_cipher_auth_test_case_2(void)
7919 {
7920 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7921 }
7922 
7923 static int
7924 test_zuc_auth_cipher_test_case_1(void)
7925 {
7926 	return test_zuc_auth_cipher(
7927 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7928 }
7929 
7930 static int
7931 test_zuc_auth_cipher_test_case_1_oop(void)
7932 {
7933 	return test_zuc_auth_cipher(
7934 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7935 }
7936 
7937 static int
7938 test_zuc_auth_cipher_test_case_1_sgl(void)
7939 {
7940 	return test_zuc_auth_cipher_sgl(
7941 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7942 }
7943 
7944 static int
7945 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7946 {
7947 	return test_zuc_auth_cipher_sgl(
7948 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7949 }
7950 
7951 static int
7952 test_zuc_auth_cipher_test_case_2(void)
7953 {
7954 	return test_zuc_auth_cipher(
7955 		&zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7956 }
7957 
7958 static int
7959 test_zuc_auth_cipher_test_case_2_oop(void)
7960 {
7961 	return test_zuc_auth_cipher(
7962 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7963 }
7964 
7965 static int
7966 test_zuc_auth_cipher_verify_test_case_1(void)
7967 {
7968 	return test_zuc_auth_cipher(
7969 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7970 }
7971 
7972 static int
7973 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7974 {
7975 	return test_zuc_auth_cipher(
7976 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7977 }
7978 
7979 static int
7980 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7981 {
7982 	return test_zuc_auth_cipher_sgl(
7983 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7984 }
7985 
7986 static int
7987 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7988 {
7989 	return test_zuc_auth_cipher_sgl(
7990 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7991 }
7992 
7993 static int
7994 test_zuc_auth_cipher_verify_test_case_2(void)
7995 {
7996 	return test_zuc_auth_cipher(
7997 		&zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7998 }
7999 
8000 static int
8001 test_zuc_auth_cipher_verify_test_case_2_oop(void)
8002 {
8003 	return test_zuc_auth_cipher(
8004 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8005 }
8006 
8007 static int
8008 test_zuc256_encryption_test_case_1(void)
8009 {
8010 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
8011 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8012 }
8013 
8014 static int
8015 test_zuc256_encryption_test_case_2(void)
8016 {
8017 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
8018 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8019 }
8020 
8021 static int
8022 test_zuc256_decryption_test_case_1(void)
8023 {
8024 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
8025 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
8026 }
8027 
8028 static int
8029 test_zuc256_decryption_test_case_2(void)
8030 {
8031 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
8032 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
8033 }
8034 
8035 static int
8036 test_zuc256_hash_generate_4b_tag_test_case_1(void)
8037 {
8038 	return test_zuc_authentication(&zuc256_test_case_auth_1,
8039 			RTE_CRYPTO_AUTH_OP_GENERATE);
8040 }
8041 
8042 static int
8043 test_zuc256_hash_generate_4b_tag_test_case_2(void)
8044 {
8045 	return test_zuc_authentication(&zuc256_test_case_auth_2,
8046 			RTE_CRYPTO_AUTH_OP_GENERATE);
8047 }
8048 
8049 static int
8050 test_zuc256_hash_generate_4b_tag_test_case_3(void)
8051 {
8052 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8053 			RTE_CRYPTO_AUTH_OP_GENERATE);
8054 }
8055 
8056 static int
8057 test_zuc256_hash_generate_8b_tag_test_case_1(void)
8058 {
8059 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8060 			RTE_CRYPTO_AUTH_OP_GENERATE);
8061 }
8062 
8063 static int
8064 test_zuc256_hash_generate_16b_tag_test_case_1(void)
8065 {
8066 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8067 			RTE_CRYPTO_AUTH_OP_GENERATE);
8068 }
8069 
8070 static int
8071 test_zuc256_hash_verify_4b_tag_test_case_1(void)
8072 {
8073 	return test_zuc_authentication(&zuc256_test_case_auth_1,
8074 			RTE_CRYPTO_AUTH_OP_VERIFY);
8075 }
8076 
8077 static int
8078 test_zuc256_hash_verify_4b_tag_test_case_2(void)
8079 {
8080 	return test_zuc_authentication(&zuc256_test_case_auth_2,
8081 			RTE_CRYPTO_AUTH_OP_VERIFY);
8082 }
8083 
8084 static int
8085 test_zuc256_hash_verify_4b_tag_test_case_3(void)
8086 {
8087 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8088 			RTE_CRYPTO_AUTH_OP_VERIFY);
8089 }
8090 
8091 static int
8092 test_zuc256_hash_verify_8b_tag_test_case_1(void)
8093 {
8094 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8095 			RTE_CRYPTO_AUTH_OP_VERIFY);
8096 }
8097 
8098 static int
8099 test_zuc256_hash_verify_16b_tag_test_case_1(void)
8100 {
8101 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8102 			RTE_CRYPTO_AUTH_OP_VERIFY);
8103 }
8104 
8105 static int
8106 test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8107 {
8108 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8109 }
8110 
8111 static int
8112 test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8113 {
8114 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8115 }
8116 
8117 static int
8118 test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8119 {
8120 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8121 }
8122 
8123 static int
8124 test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8125 {
8126 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8127 }
8128 
8129 static int
8130 test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8131 {
8132 	return test_zuc_auth_cipher(
8133 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8134 }
8135 
8136 static int
8137 test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8138 {
8139 	return test_zuc_auth_cipher(
8140 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8141 }
8142 
8143 static int
8144 test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8145 {
8146 	return test_zuc_auth_cipher(
8147 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8148 }
8149 
8150 static int
8151 test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8152 {
8153 	return test_zuc_auth_cipher(
8154 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8155 }
8156 
8157 static int
8158 test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8159 {
8160 	return test_zuc_auth_cipher(
8161 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8162 }
8163 
8164 static int
8165 test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8166 {
8167 	return test_zuc_auth_cipher(
8168 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8169 }
8170 
8171 static int
8172 test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8173 {
8174 	return test_zuc_auth_cipher(
8175 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8176 }
8177 
8178 static int
8179 test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8180 {
8181 	return test_zuc_auth_cipher(
8182 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8183 }
8184 
8185 static int
8186 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8187 {
8188 	uint8_t dev_id = testsuite_params.valid_devs[0];
8189 
8190 	struct rte_cryptodev_sym_capability_idx cap_idx;
8191 
8192 	/* Check if device supports particular cipher algorithm */
8193 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8194 	cap_idx.algo.cipher = tdata->cipher_algo;
8195 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8196 		return TEST_SKIPPED;
8197 
8198 	/* Check if device supports particular hash algorithm */
8199 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8200 	cap_idx.algo.auth = tdata->auth_algo;
8201 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8202 		return TEST_SKIPPED;
8203 
8204 	return 0;
8205 }
8206 
8207 static int
8208 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8209 	uint8_t op_mode, uint8_t verify)
8210 {
8211 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8212 	struct crypto_unittest_params *ut_params = &unittest_params;
8213 
8214 	int retval;
8215 
8216 	uint8_t *plaintext = NULL, *ciphertext = NULL;
8217 	unsigned int plaintext_pad_len;
8218 	unsigned int plaintext_len;
8219 	unsigned int ciphertext_pad_len;
8220 	unsigned int ciphertext_len;
8221 	unsigned int digest_offset;
8222 
8223 	struct rte_cryptodev_info dev_info;
8224 	struct rte_crypto_op *op;
8225 
8226 	/* Check if device supports particular algorithms separately */
8227 	if (test_mixed_check_if_unsupported(tdata))
8228 		return TEST_SKIPPED;
8229 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8230 		return TEST_SKIPPED;
8231 
8232 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8233 		return TEST_SKIPPED;
8234 
8235 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8236 
8237 	uint64_t feat_flags = dev_info.feature_flags;
8238 
8239 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8240 		printf("Device doesn't support digest encrypted.\n");
8241 		return TEST_SKIPPED;
8242 	}
8243 
8244 	/* Create the session */
8245 	if (verify)
8246 		retval = create_wireless_algo_cipher_auth_session(
8247 				ts_params->valid_devs[0],
8248 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8249 				RTE_CRYPTO_AUTH_OP_VERIFY,
8250 				tdata->auth_algo,
8251 				tdata->cipher_algo,
8252 				tdata->auth_key.data, tdata->auth_key.len,
8253 				tdata->cipher_key.data, tdata->cipher_key.len,
8254 				tdata->auth_iv.len, tdata->digest_enc.len,
8255 				tdata->cipher_iv.len);
8256 	else
8257 		retval = create_wireless_algo_auth_cipher_session(
8258 				ts_params->valid_devs[0],
8259 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8260 				RTE_CRYPTO_AUTH_OP_GENERATE,
8261 				tdata->auth_algo,
8262 				tdata->cipher_algo,
8263 				tdata->auth_key.data, tdata->auth_key.len,
8264 				tdata->cipher_key.data, tdata->cipher_key.len,
8265 				tdata->auth_iv.len, tdata->digest_enc.len,
8266 				tdata->cipher_iv.len);
8267 	if (retval != 0)
8268 		return retval;
8269 
8270 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8271 	if (op_mode == OUT_OF_PLACE)
8272 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8273 
8274 	/* clear mbuf payload */
8275 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8276 		rte_pktmbuf_tailroom(ut_params->ibuf));
8277 	if (op_mode == OUT_OF_PLACE) {
8278 
8279 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8280 				rte_pktmbuf_tailroom(ut_params->obuf));
8281 	}
8282 
8283 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8284 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8285 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8286 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8287 
8288 	if (verify) {
8289 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8290 				ciphertext_pad_len);
8291 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8292 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8293 				ciphertext_len);
8294 	} else {
8295 		/* make sure enough space to cover partial digest verify case */
8296 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8297 				ciphertext_pad_len);
8298 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8299 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8300 	}
8301 
8302 	if (op_mode == OUT_OF_PLACE)
8303 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8304 
8305 	/* Create the operation */
8306 	retval = create_wireless_algo_auth_cipher_operation(
8307 			tdata->digest_enc.data, tdata->digest_enc.len,
8308 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8309 			tdata->auth_iv.data, tdata->auth_iv.len,
8310 			(tdata->digest_enc.offset == 0 ?
8311 				plaintext_pad_len
8312 				: tdata->digest_enc.offset),
8313 			tdata->validCipherLen.len_bits,
8314 			tdata->cipher.offset_bits,
8315 			tdata->validAuthLen.len_bits,
8316 			tdata->auth.offset_bits,
8317 			op_mode, 0, verify);
8318 
8319 	if (retval < 0)
8320 		return retval;
8321 
8322 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8323 
8324 	/* Check if the op failed because the device doesn't */
8325 	/* support this particular combination of algorithms */
8326 	if (op == NULL && ut_params->op->status ==
8327 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8328 		printf("Device doesn't support this mixed combination. "
8329 				"Test Skipped.\n");
8330 		return TEST_SKIPPED;
8331 	}
8332 	ut_params->op = op;
8333 
8334 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8335 
8336 	ut_params->obuf = (op_mode == IN_PLACE ?
8337 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8338 
8339 	if (verify) {
8340 		if (ut_params->obuf)
8341 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8342 							uint8_t *);
8343 		else
8344 			plaintext = ciphertext +
8345 					(tdata->cipher.offset_bits >> 3);
8346 
8347 		debug_hexdump(stdout, "plaintext:", plaintext,
8348 				tdata->plaintext.len_bits >> 3);
8349 		debug_hexdump(stdout, "plaintext expected:",
8350 				tdata->plaintext.data,
8351 				tdata->plaintext.len_bits >> 3);
8352 	} else {
8353 		if (ut_params->obuf)
8354 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8355 					uint8_t *);
8356 		else
8357 			ciphertext = plaintext;
8358 
8359 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8360 				ciphertext_len);
8361 		debug_hexdump(stdout, "ciphertext expected:",
8362 				tdata->ciphertext.data,
8363 				tdata->ciphertext.len_bits >> 3);
8364 
8365 		if (tdata->digest_enc.offset == 0)
8366 			digest_offset = plaintext_pad_len;
8367 		else
8368 			digest_offset = tdata->digest_enc.offset;
8369 
8370 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8371 					    uint8_t *, digest_offset);
8372 
8373 		debug_hexdump(stdout, "digest:", ut_params->digest,
8374 				tdata->digest_enc.len);
8375 		debug_hexdump(stdout, "digest expected:",
8376 				tdata->digest_enc.data,
8377 				tdata->digest_enc.len);
8378 	}
8379 
8380 	if (!verify) {
8381 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8382 				ut_params->digest,
8383 				tdata->digest_enc.data,
8384 				tdata->digest_enc.len,
8385 				"Generated auth tag not as expected");
8386 	}
8387 
8388 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8389 		if (verify) {
8390 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8391 					plaintext,
8392 					tdata->plaintext.data,
8393 					tdata->plaintext.len_bits >> 3,
8394 					"Plaintext data not as expected");
8395 		} else {
8396 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8397 					ciphertext,
8398 					tdata->ciphertext.data,
8399 					tdata->validDataLen.len_bits,
8400 					"Ciphertext data not as expected");
8401 		}
8402 	}
8403 
8404 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8405 			"crypto op processing failed");
8406 
8407 	return 0;
8408 }
8409 
8410 static int
8411 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8412 	uint8_t op_mode, uint8_t verify)
8413 {
8414 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8415 	struct crypto_unittest_params *ut_params = &unittest_params;
8416 
8417 	int retval;
8418 
8419 	const uint8_t *plaintext = NULL;
8420 	const uint8_t *ciphertext = NULL;
8421 	const uint8_t *digest = NULL;
8422 	unsigned int plaintext_pad_len;
8423 	unsigned int plaintext_len;
8424 	unsigned int ciphertext_pad_len;
8425 	unsigned int ciphertext_len;
8426 	uint8_t buffer[10000];
8427 	uint8_t digest_buffer[10000];
8428 
8429 	struct rte_cryptodev_info dev_info;
8430 	struct rte_crypto_op *op;
8431 
8432 	/* Check if device supports particular algorithms */
8433 	if (test_mixed_check_if_unsupported(tdata))
8434 		return TEST_SKIPPED;
8435 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8436 		return TEST_SKIPPED;
8437 
8438 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8439 
8440 	uint64_t feat_flags = dev_info.feature_flags;
8441 
8442 	if (op_mode == IN_PLACE) {
8443 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8444 			printf("Device doesn't support in-place scatter-gather "
8445 					"in both input and output mbufs.\n");
8446 			return TEST_SKIPPED;
8447 		}
8448 	} else {
8449 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8450 			printf("Device doesn't support out-of-place scatter-gather "
8451 					"in both input and output mbufs.\n");
8452 			return TEST_SKIPPED;
8453 		}
8454 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8455 			printf("Device doesn't support digest encrypted.\n");
8456 			return TEST_SKIPPED;
8457 		}
8458 	}
8459 
8460 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8461 		return TEST_SKIPPED;
8462 
8463 	/* Create the session */
8464 	if (verify)
8465 		retval = create_wireless_algo_cipher_auth_session(
8466 				ts_params->valid_devs[0],
8467 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8468 				RTE_CRYPTO_AUTH_OP_VERIFY,
8469 				tdata->auth_algo,
8470 				tdata->cipher_algo,
8471 				tdata->auth_key.data, tdata->auth_key.len,
8472 				tdata->cipher_key.data, tdata->cipher_key.len,
8473 				tdata->auth_iv.len, tdata->digest_enc.len,
8474 				tdata->cipher_iv.len);
8475 	else
8476 		retval = create_wireless_algo_auth_cipher_session(
8477 				ts_params->valid_devs[0],
8478 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8479 				RTE_CRYPTO_AUTH_OP_GENERATE,
8480 				tdata->auth_algo,
8481 				tdata->cipher_algo,
8482 				tdata->auth_key.data, tdata->auth_key.len,
8483 				tdata->cipher_key.data, tdata->cipher_key.len,
8484 				tdata->auth_iv.len, tdata->digest_enc.len,
8485 				tdata->cipher_iv.len);
8486 	if (retval != 0)
8487 		return retval;
8488 
8489 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8490 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8491 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8492 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8493 
8494 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8495 			ciphertext_pad_len, 15, 0);
8496 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8497 			"Failed to allocate input buffer in mempool");
8498 
8499 	if (op_mode == OUT_OF_PLACE) {
8500 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8501 				plaintext_pad_len, 15, 0);
8502 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
8503 				"Failed to allocate output buffer in mempool");
8504 	}
8505 
8506 	if (verify) {
8507 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8508 			tdata->ciphertext.data);
8509 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8510 					ciphertext_len, buffer);
8511 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8512 			ciphertext_len);
8513 	} else {
8514 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8515 			tdata->plaintext.data);
8516 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8517 					plaintext_len, buffer);
8518 		debug_hexdump(stdout, "plaintext:", plaintext,
8519 			plaintext_len);
8520 	}
8521 	memset(buffer, 0, sizeof(buffer));
8522 
8523 	/* Create the operation */
8524 	retval = create_wireless_algo_auth_cipher_operation(
8525 			tdata->digest_enc.data, tdata->digest_enc.len,
8526 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8527 			tdata->auth_iv.data, tdata->auth_iv.len,
8528 			(tdata->digest_enc.offset == 0 ?
8529 				plaintext_pad_len
8530 				: tdata->digest_enc.offset),
8531 			tdata->validCipherLen.len_bits,
8532 			tdata->cipher.offset_bits,
8533 			tdata->validAuthLen.len_bits,
8534 			tdata->auth.offset_bits,
8535 			op_mode, 1, verify);
8536 
8537 	if (retval < 0)
8538 		return retval;
8539 
8540 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8541 
8542 	/* Check if the op failed because the device doesn't */
8543 	/* support this particular combination of algorithms */
8544 	if (op == NULL && ut_params->op->status ==
8545 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8546 		printf("Device doesn't support this mixed combination. "
8547 				"Test Skipped.\n");
8548 		return TEST_SKIPPED;
8549 	}
8550 	ut_params->op = op;
8551 
8552 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8553 
8554 	ut_params->obuf = (op_mode == IN_PLACE ?
8555 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8556 
8557 	if (verify) {
8558 		if (ut_params->obuf)
8559 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8560 					plaintext_len, buffer);
8561 		else
8562 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8563 					plaintext_len, buffer);
8564 
8565 		debug_hexdump(stdout, "plaintext:", plaintext,
8566 				(tdata->plaintext.len_bits >> 3) -
8567 				tdata->digest_enc.len);
8568 		debug_hexdump(stdout, "plaintext expected:",
8569 				tdata->plaintext.data,
8570 				(tdata->plaintext.len_bits >> 3) -
8571 				tdata->digest_enc.len);
8572 	} else {
8573 		if (ut_params->obuf)
8574 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8575 					ciphertext_len, buffer);
8576 		else
8577 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8578 					ciphertext_len, buffer);
8579 
8580 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8581 			ciphertext_len);
8582 		debug_hexdump(stdout, "ciphertext expected:",
8583 			tdata->ciphertext.data,
8584 			tdata->ciphertext.len_bits >> 3);
8585 
8586 		if (ut_params->obuf)
8587 			digest = rte_pktmbuf_read(ut_params->obuf,
8588 					(tdata->digest_enc.offset == 0 ?
8589 						plaintext_pad_len :
8590 						tdata->digest_enc.offset),
8591 					tdata->digest_enc.len, digest_buffer);
8592 		else
8593 			digest = rte_pktmbuf_read(ut_params->ibuf,
8594 					(tdata->digest_enc.offset == 0 ?
8595 						plaintext_pad_len :
8596 						tdata->digest_enc.offset),
8597 					tdata->digest_enc.len, digest_buffer);
8598 
8599 		debug_hexdump(stdout, "digest:", digest,
8600 				tdata->digest_enc.len);
8601 		debug_hexdump(stdout, "digest expected:",
8602 				tdata->digest_enc.data, tdata->digest_enc.len);
8603 	}
8604 
8605 	if (!verify) {
8606 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8607 				digest,
8608 				tdata->digest_enc.data,
8609 				tdata->digest_enc.len,
8610 				"Generated auth tag not as expected");
8611 	}
8612 
8613 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8614 		if (verify) {
8615 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8616 					plaintext,
8617 					tdata->plaintext.data,
8618 					tdata->plaintext.len_bits >> 3,
8619 					"Plaintext data not as expected");
8620 		} else {
8621 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8622 					ciphertext,
8623 					tdata->ciphertext.data,
8624 					tdata->validDataLen.len_bits,
8625 					"Ciphertext data not as expected");
8626 		}
8627 	}
8628 
8629 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8630 			"crypto op processing failed");
8631 
8632 	return 0;
8633 }
8634 
8635 /** AUTH AES CMAC + CIPHER AES CTR */
8636 
8637 static int
8638 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8639 {
8640 	return test_mixed_auth_cipher(
8641 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8642 }
8643 
8644 static int
8645 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8646 {
8647 	return test_mixed_auth_cipher(
8648 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8649 }
8650 
8651 static int
8652 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8653 {
8654 	return test_mixed_auth_cipher_sgl(
8655 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8656 }
8657 
8658 static int
8659 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8660 {
8661 	return test_mixed_auth_cipher_sgl(
8662 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8663 }
8664 
8665 static int
8666 test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8667 {
8668 	return test_mixed_auth_cipher(
8669 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8670 }
8671 
8672 static int
8673 test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8674 {
8675 	return test_mixed_auth_cipher(
8676 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8677 }
8678 
8679 static int
8680 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8681 {
8682 	return test_mixed_auth_cipher(
8683 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8684 }
8685 
8686 static int
8687 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8688 {
8689 	return test_mixed_auth_cipher(
8690 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8691 }
8692 
8693 static int
8694 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8695 {
8696 	return test_mixed_auth_cipher(
8697 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8698 }
8699 
8700 static int
8701 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8702 {
8703 	return test_mixed_auth_cipher_sgl(
8704 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8705 }
8706 
8707 static int
8708 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8709 {
8710 	return test_mixed_auth_cipher_sgl(
8711 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8712 }
8713 
8714 static int
8715 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8716 {
8717 	return test_mixed_auth_cipher(
8718 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8719 }
8720 
8721 /** MIXED AUTH + CIPHER */
8722 
8723 static int
8724 test_auth_zuc_cipher_snow_test_case_1(void)
8725 {
8726 	return test_mixed_auth_cipher(
8727 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8728 }
8729 
8730 static int
8731 test_verify_auth_zuc_cipher_snow_test_case_1(void)
8732 {
8733 	return test_mixed_auth_cipher(
8734 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8735 }
8736 
8737 static int
8738 test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8739 {
8740 	return test_mixed_auth_cipher(
8741 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8742 }
8743 
8744 static int
8745 test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8746 {
8747 	return test_mixed_auth_cipher(
8748 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8749 }
8750 
8751 
8752 static int
8753 test_auth_aes_cmac_cipher_snow_test_case_1(void)
8754 {
8755 	return test_mixed_auth_cipher(
8756 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8757 }
8758 
8759 static int
8760 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8761 {
8762 	return test_mixed_auth_cipher(
8763 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8764 }
8765 
8766 static int
8767 test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8768 {
8769 	return test_mixed_auth_cipher(
8770 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8771 }
8772 
8773 static int
8774 test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8775 {
8776 	return test_mixed_auth_cipher(
8777 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8778 }
8779 
8780 static int
8781 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8782 {
8783 	return test_mixed_auth_cipher(
8784 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8785 }
8786 
8787 static int
8788 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8789 {
8790 	return test_mixed_auth_cipher(
8791 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8792 }
8793 
8794 static int
8795 test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8796 {
8797 	return test_mixed_auth_cipher(
8798 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8799 }
8800 
8801 static int
8802 test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8803 {
8804 	return test_mixed_auth_cipher(
8805 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8806 }
8807 
8808 static int
8809 test_auth_snow_cipher_aes_ctr_test_case_1(void)
8810 {
8811 	return test_mixed_auth_cipher(
8812 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8813 }
8814 
8815 static int
8816 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8817 {
8818 	return test_mixed_auth_cipher(
8819 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8820 }
8821 
8822 static int
8823 test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8824 {
8825 	return test_mixed_auth_cipher_sgl(
8826 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8827 }
8828 
8829 static int
8830 test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8831 {
8832 	return test_mixed_auth_cipher(
8833 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8834 }
8835 
8836 static int
8837 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8838 {
8839 	return test_mixed_auth_cipher_sgl(
8840 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8841 }
8842 
8843 static int
8844 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8845 {
8846 	return test_mixed_auth_cipher(
8847 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8848 }
8849 
8850 static int
8851 test_auth_snow_cipher_zuc_test_case_1(void)
8852 {
8853 	return test_mixed_auth_cipher(
8854 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8855 }
8856 
8857 static int
8858 test_verify_auth_snow_cipher_zuc_test_case_1(void)
8859 {
8860 	return test_mixed_auth_cipher(
8861 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8862 }
8863 
8864 static int
8865 test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8866 {
8867 	return test_mixed_auth_cipher(
8868 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8869 }
8870 
8871 static int
8872 test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8873 {
8874 	return test_mixed_auth_cipher(
8875 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8876 }
8877 
8878 static int
8879 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8880 {
8881 	return test_mixed_auth_cipher(
8882 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8883 }
8884 
8885 static int
8886 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8887 {
8888 	return test_mixed_auth_cipher(
8889 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8890 }
8891 static int
8892 test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8893 {
8894 	return test_mixed_auth_cipher(
8895 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8896 }
8897 
8898 static int
8899 test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8900 {
8901 	return test_mixed_auth_cipher(
8902 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8903 }
8904 
8905 static int
8906 test_auth_null_cipher_snow_test_case_1(void)
8907 {
8908 	return test_mixed_auth_cipher(
8909 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8910 }
8911 
8912 static int
8913 test_verify_auth_null_cipher_snow_test_case_1(void)
8914 {
8915 	return test_mixed_auth_cipher(
8916 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8917 }
8918 
8919 static int
8920 test_auth_null_cipher_zuc_test_case_1(void)
8921 {
8922 	return test_mixed_auth_cipher(
8923 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8924 }
8925 
8926 static int
8927 test_verify_auth_null_cipher_zuc_test_case_1(void)
8928 {
8929 	return test_mixed_auth_cipher(
8930 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8931 }
8932 
8933 static int
8934 test_auth_snow_cipher_null_test_case_1(void)
8935 {
8936 	return test_mixed_auth_cipher(
8937 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8938 }
8939 
8940 static int
8941 test_verify_auth_snow_cipher_null_test_case_1(void)
8942 {
8943 	return test_mixed_auth_cipher(
8944 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8945 }
8946 
8947 static int
8948 test_auth_zuc_cipher_null_test_case_1(void)
8949 {
8950 	return test_mixed_auth_cipher(
8951 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8952 }
8953 
8954 static int
8955 test_verify_auth_zuc_cipher_null_test_case_1(void)
8956 {
8957 	return test_mixed_auth_cipher(
8958 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8959 }
8960 
8961 static int
8962 test_auth_null_cipher_aes_ctr_test_case_1(void)
8963 {
8964 	return test_mixed_auth_cipher(
8965 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8966 }
8967 
8968 static int
8969 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8970 {
8971 	return test_mixed_auth_cipher(
8972 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8973 }
8974 
8975 static int
8976 test_auth_aes_cmac_cipher_null_test_case_1(void)
8977 {
8978 	return test_mixed_auth_cipher(
8979 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8980 }
8981 
8982 static int
8983 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8984 {
8985 	return test_mixed_auth_cipher(
8986 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8987 }
8988 
8989 /* ***** AEAD algorithm Tests ***** */
8990 
8991 static int
8992 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8993 		enum rte_crypto_aead_operation op,
8994 		const uint8_t *key, const uint8_t key_len,
8995 		const uint16_t aad_len, const uint8_t auth_len,
8996 		uint8_t iv_len)
8997 {
8998 	uint8_t aead_key[key_len];
8999 
9000 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9001 	struct crypto_unittest_params *ut_params = &unittest_params;
9002 
9003 	memcpy(aead_key, key, key_len);
9004 
9005 	/* Setup AEAD Parameters */
9006 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9007 	ut_params->aead_xform.next = NULL;
9008 	ut_params->aead_xform.aead.algo = algo;
9009 	ut_params->aead_xform.aead.op = op;
9010 	ut_params->aead_xform.aead.key.data = aead_key;
9011 	ut_params->aead_xform.aead.key.length = key_len;
9012 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9013 	ut_params->aead_xform.aead.iv.length = iv_len;
9014 	ut_params->aead_xform.aead.digest_length = auth_len;
9015 	ut_params->aead_xform.aead.aad_length = aad_len;
9016 
9017 	debug_hexdump(stdout, "key:", key, key_len);
9018 
9019 	/* Create Crypto session*/
9020 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9021 			&ut_params->aead_xform, ts_params->session_mpool);
9022 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9023 		return TEST_SKIPPED;
9024 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9025 	return 0;
9026 }
9027 
9028 static int
9029 create_aead_xform(struct rte_crypto_op *op,
9030 		enum rte_crypto_aead_algorithm algo,
9031 		enum rte_crypto_aead_operation aead_op,
9032 		uint8_t *key, const uint8_t key_len,
9033 		const uint8_t aad_len, const uint8_t auth_len,
9034 		uint8_t iv_len)
9035 {
9036 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9037 			"failed to allocate space for crypto transform");
9038 
9039 	struct rte_crypto_sym_op *sym_op = op->sym;
9040 
9041 	/* Setup AEAD Parameters */
9042 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9043 	sym_op->xform->next = NULL;
9044 	sym_op->xform->aead.algo = algo;
9045 	sym_op->xform->aead.op = aead_op;
9046 	sym_op->xform->aead.key.data = key;
9047 	sym_op->xform->aead.key.length = key_len;
9048 	sym_op->xform->aead.iv.offset = IV_OFFSET;
9049 	sym_op->xform->aead.iv.length = iv_len;
9050 	sym_op->xform->aead.digest_length = auth_len;
9051 	sym_op->xform->aead.aad_length = aad_len;
9052 
9053 	debug_hexdump(stdout, "key:", key, key_len);
9054 
9055 	return 0;
9056 }
9057 
9058 static int
9059 create_aead_operation(enum rte_crypto_aead_operation op,
9060 		const struct aead_test_data *tdata)
9061 {
9062 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9063 	struct crypto_unittest_params *ut_params = &unittest_params;
9064 
9065 	uint8_t *plaintext, *ciphertext;
9066 	unsigned int aad_pad_len, plaintext_pad_len;
9067 
9068 	/* Generate Crypto op data structure */
9069 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9070 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9071 	TEST_ASSERT_NOT_NULL(ut_params->op,
9072 			"Failed to allocate symmetric crypto operation struct");
9073 
9074 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9075 
9076 	/* Append aad data */
9077 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9078 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9079 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9080 				aad_pad_len);
9081 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9082 				"no room to append aad");
9083 
9084 		sym_op->aead.aad.phys_addr =
9085 				rte_pktmbuf_iova(ut_params->ibuf);
9086 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
9087 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9088 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9089 			tdata->aad.len);
9090 
9091 		/* Append IV at the end of the crypto operation*/
9092 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9093 				uint8_t *, IV_OFFSET);
9094 
9095 		/* Copy IV 1 byte after the IV pointer, according to the API */
9096 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9097 		debug_hexdump(stdout, "iv:", iv_ptr + 1,
9098 			tdata->iv.len);
9099 	} else {
9100 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9101 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9102 				aad_pad_len);
9103 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9104 				"no room to append aad");
9105 
9106 		sym_op->aead.aad.phys_addr =
9107 				rte_pktmbuf_iova(ut_params->ibuf);
9108 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9109 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9110 			tdata->aad.len);
9111 
9112 		/* Append IV at the end of the crypto operation*/
9113 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9114 				uint8_t *, IV_OFFSET);
9115 
9116 		if (tdata->iv.len == 0) {
9117 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9118 			debug_hexdump(stdout, "iv:", iv_ptr,
9119 				AES_GCM_J0_LENGTH);
9120 		} else {
9121 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9122 			debug_hexdump(stdout, "iv:", iv_ptr,
9123 				tdata->iv.len);
9124 		}
9125 	}
9126 
9127 	/* Append plaintext/ciphertext */
9128 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9129 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9130 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9131 				plaintext_pad_len);
9132 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9133 
9134 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9135 		debug_hexdump(stdout, "plaintext:", plaintext,
9136 				tdata->plaintext.len);
9137 
9138 		if (ut_params->obuf) {
9139 			ciphertext = (uint8_t *)rte_pktmbuf_append(
9140 					ut_params->obuf,
9141 					plaintext_pad_len + aad_pad_len);
9142 			TEST_ASSERT_NOT_NULL(ciphertext,
9143 					"no room to append ciphertext");
9144 
9145 			memset(ciphertext + aad_pad_len, 0,
9146 					tdata->ciphertext.len);
9147 		}
9148 	} else {
9149 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9150 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9151 				plaintext_pad_len);
9152 		TEST_ASSERT_NOT_NULL(ciphertext,
9153 				"no room to append ciphertext");
9154 
9155 		memcpy(ciphertext, tdata->ciphertext.data,
9156 				tdata->ciphertext.len);
9157 		debug_hexdump(stdout, "ciphertext:", ciphertext,
9158 				tdata->ciphertext.len);
9159 
9160 		if (ut_params->obuf) {
9161 			plaintext = (uint8_t *)rte_pktmbuf_append(
9162 					ut_params->obuf,
9163 					plaintext_pad_len + aad_pad_len);
9164 			TEST_ASSERT_NOT_NULL(plaintext,
9165 					"no room to append plaintext");
9166 
9167 			memset(plaintext + aad_pad_len, 0,
9168 					tdata->plaintext.len);
9169 		}
9170 	}
9171 
9172 	/* Append digest data */
9173 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9174 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9175 				ut_params->obuf ? ut_params->obuf :
9176 						ut_params->ibuf,
9177 						tdata->auth_tag.len);
9178 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9179 				"no room to append digest");
9180 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9181 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9182 				ut_params->obuf ? ut_params->obuf :
9183 						ut_params->ibuf,
9184 						plaintext_pad_len +
9185 						aad_pad_len);
9186 	} else {
9187 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9188 				ut_params->ibuf, tdata->auth_tag.len);
9189 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9190 				"no room to append digest");
9191 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9192 				ut_params->ibuf,
9193 				plaintext_pad_len + aad_pad_len);
9194 
9195 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9196 			tdata->auth_tag.len);
9197 		debug_hexdump(stdout, "digest:",
9198 			sym_op->aead.digest.data,
9199 			tdata->auth_tag.len);
9200 	}
9201 
9202 	sym_op->aead.data.length = tdata->plaintext.len;
9203 	sym_op->aead.data.offset = aad_pad_len;
9204 
9205 	return 0;
9206 }
9207 
9208 static int
9209 test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9210 {
9211 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9212 	struct crypto_unittest_params *ut_params = &unittest_params;
9213 
9214 	int retval;
9215 	uint8_t *ciphertext, *auth_tag;
9216 	uint16_t plaintext_pad_len;
9217 	uint32_t i;
9218 	struct rte_cryptodev_info dev_info;
9219 
9220 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9221 	uint64_t feat_flags = dev_info.feature_flags;
9222 
9223 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9224 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9225 		printf("Device doesn't support RAW data-path APIs.\n");
9226 		return TEST_SKIPPED;
9227 	}
9228 
9229 	/* Verify the capabilities */
9230 	struct rte_cryptodev_sym_capability_idx cap_idx;
9231 	const struct rte_cryptodev_symmetric_capability *capability;
9232 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9233 	cap_idx.algo.aead = tdata->algo;
9234 	capability = rte_cryptodev_sym_capability_get(
9235 			ts_params->valid_devs[0], &cap_idx);
9236 	if (capability == NULL)
9237 		return TEST_SKIPPED;
9238 	if (rte_cryptodev_sym_capability_check_aead(
9239 			capability, tdata->key.len, tdata->auth_tag.len,
9240 			tdata->aad.len, tdata->iv.len))
9241 		return TEST_SKIPPED;
9242 
9243 	/* Create AEAD session */
9244 	retval = create_aead_session(ts_params->valid_devs[0],
9245 			tdata->algo,
9246 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9247 			tdata->key.data, tdata->key.len,
9248 			tdata->aad.len, tdata->auth_tag.len,
9249 			tdata->iv.len);
9250 	if (retval != TEST_SUCCESS)
9251 		return retval;
9252 
9253 	if (tdata->aad.len > MBUF_SIZE) {
9254 		if (use_ext_mbuf) {
9255 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9256 							  AEAD_TEXT_MAX_LENGTH,
9257 							  1 /* nb_segs */,
9258 							  NULL);
9259 		} else {
9260 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9261 		}
9262 		/* Populate full size of add data */
9263 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9264 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9265 	} else {
9266 		if (use_ext_mbuf) {
9267 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9268 							  AEAD_TEXT_MAX_LENGTH,
9269 							  1 /* nb_segs */,
9270 							  NULL);
9271 		} else {
9272 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9273 		}
9274 	}
9275 
9276 	/* clear mbuf payload */
9277 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9278 			rte_pktmbuf_tailroom(ut_params->ibuf));
9279 
9280 	/* Create AEAD operation */
9281 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9282 	if (retval < 0)
9283 		return retval;
9284 
9285 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9286 
9287 	ut_params->op->sym->m_src = ut_params->ibuf;
9288 
9289 	/* Process crypto operation */
9290 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9291 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9292 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9293 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9294 					       0);
9295 		if (retval != TEST_SUCCESS)
9296 			return retval;
9297 	} else
9298 		TEST_ASSERT_NOT_NULL(
9299 			process_crypto_request(ts_params->valid_devs[0],
9300 			ut_params->op), "failed to process sym crypto op");
9301 
9302 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9303 			"crypto op processing failed");
9304 
9305 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9306 
9307 	if (ut_params->op->sym->m_dst) {
9308 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9309 				uint8_t *);
9310 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9311 				uint8_t *, plaintext_pad_len);
9312 	} else {
9313 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9314 				uint8_t *,
9315 				ut_params->op->sym->cipher.data.offset);
9316 		auth_tag = ciphertext + plaintext_pad_len;
9317 	}
9318 
9319 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9320 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9321 
9322 	/* Validate obuf */
9323 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9324 			ciphertext,
9325 			tdata->ciphertext.data,
9326 			tdata->ciphertext.len,
9327 			"Ciphertext data not as expected");
9328 
9329 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9330 			auth_tag,
9331 			tdata->auth_tag.data,
9332 			tdata->auth_tag.len,
9333 			"Generated auth tag not as expected");
9334 
9335 	return 0;
9336 
9337 }
9338 
9339 static int
9340 test_authenticated_encryption(const struct aead_test_data *tdata)
9341 {
9342 	return test_authenticated_encryption_helper(tdata, false);
9343 }
9344 
9345 #ifdef RTE_LIB_SECURITY
9346 static int
9347 security_proto_supported(enum rte_security_session_action_type action,
9348 	enum rte_security_session_protocol proto)
9349 {
9350 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9351 
9352 	const struct rte_security_capability *capabilities;
9353 	const struct rte_security_capability *capability;
9354 	uint16_t i = 0;
9355 
9356 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9357 
9358 
9359 	capabilities = rte_security_capabilities_get(ctx);
9360 
9361 	if (capabilities == NULL)
9362 		return -ENOTSUP;
9363 
9364 	while ((capability = &capabilities[i++])->action !=
9365 			RTE_SECURITY_ACTION_TYPE_NONE) {
9366 		if (capability->action == action &&
9367 				capability->protocol == proto)
9368 			return 0;
9369 	}
9370 
9371 	return -ENOTSUP;
9372 }
9373 
9374 /* Basic algorithm run function for async inplace mode.
9375  * Creates a session from input parameters and runs one operation
9376  * on input_vec. Checks the output of the crypto operation against
9377  * output_vec.
9378  */
9379 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9380 			   enum rte_crypto_auth_operation opa,
9381 			   const uint8_t *input_vec, unsigned int input_vec_len,
9382 			   const uint8_t *output_vec,
9383 			   unsigned int output_vec_len,
9384 			   enum rte_crypto_cipher_algorithm cipher_alg,
9385 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
9386 			   enum rte_crypto_auth_algorithm auth_alg,
9387 			   const uint8_t *auth_key, uint32_t auth_key_len,
9388 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
9389 			   uint8_t packet_direction, uint8_t sn_size,
9390 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9391 {
9392 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9393 	struct crypto_unittest_params *ut_params = &unittest_params;
9394 	uint8_t *plaintext;
9395 	int ret = TEST_SUCCESS;
9396 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9397 	struct rte_cryptodev_info dev_info;
9398 	uint64_t feat_flags;
9399 
9400 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9401 	feat_flags = dev_info.feature_flags;
9402 
9403 	/* Verify the capabilities */
9404 	struct rte_security_capability_idx sec_cap_idx;
9405 
9406 	sec_cap_idx.action = ut_params->type;
9407 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9408 	sec_cap_idx.pdcp.domain = domain;
9409 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9410 		return TEST_SKIPPED;
9411 
9412 	/* Generate test mbuf data */
9413 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9414 
9415 	/* clear mbuf payload */
9416 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9417 			rte_pktmbuf_tailroom(ut_params->ibuf));
9418 
9419 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9420 						  input_vec_len);
9421 	memcpy(plaintext, input_vec, input_vec_len);
9422 
9423 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9424 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9425 		printf("Device does not support RAW data-path APIs.\n");
9426 		return TEST_SKIPPED;
9427 	}
9428 	/* Out of place support */
9429 	if (oop) {
9430 		/*
9431 		 * For out-of-place we need to alloc another mbuf
9432 		 */
9433 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9434 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9435 	}
9436 
9437 	/* Setup Cipher Parameters */
9438 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9439 	ut_params->cipher_xform.cipher.algo = cipher_alg;
9440 	ut_params->cipher_xform.cipher.op = opc;
9441 	ut_params->cipher_xform.cipher.key.data = cipher_key;
9442 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9443 	ut_params->cipher_xform.cipher.iv.length =
9444 				packet_direction ? 4 : 0;
9445 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9446 
9447 	/* Setup HMAC Parameters if ICV header is required */
9448 	if (auth_alg != 0) {
9449 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9450 		ut_params->auth_xform.next = NULL;
9451 		ut_params->auth_xform.auth.algo = auth_alg;
9452 		ut_params->auth_xform.auth.op = opa;
9453 		ut_params->auth_xform.auth.key.data = auth_key;
9454 		ut_params->auth_xform.auth.key.length = auth_key_len;
9455 
9456 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9457 	} else {
9458 		ut_params->cipher_xform.next = NULL;
9459 	}
9460 
9461 	struct rte_security_session_conf sess_conf = {
9462 		.action_type = ut_params->type,
9463 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9464 		{.pdcp = {
9465 			.bearer = bearer,
9466 			.domain = domain,
9467 			.pkt_dir = packet_direction,
9468 			.sn_size = sn_size,
9469 			.hfn = packet_direction ? 0 : hfn,
9470 			/**
9471 			 * hfn can be set as pdcp_test_hfn[i]
9472 			 * if hfn_ovrd is not set. Here, PDCP
9473 			 * packet direction is just used to
9474 			 * run half of the cases with session
9475 			 * HFN and other half with per packet
9476 			 * HFN.
9477 			 */
9478 			.hfn_threshold = hfn_threshold,
9479 			.hfn_ovrd = packet_direction ? 1 : 0,
9480 			.sdap_enabled = sdap,
9481 		} },
9482 		.crypto_xform = &ut_params->cipher_xform
9483 	};
9484 
9485 	/* Create security session */
9486 	ut_params->sec_session = rte_security_session_create(ctx,
9487 				&sess_conf, ts_params->session_mpool);
9488 
9489 	if (!ut_params->sec_session) {
9490 		printf("TestCase %s()-%d line %d failed %s: ",
9491 			__func__, i, __LINE__, "Failed to allocate session");
9492 		ret = TEST_FAILED;
9493 		goto on_err;
9494 	}
9495 
9496 	/* Generate crypto op data structure */
9497 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9498 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9499 	if (!ut_params->op) {
9500 		printf("TestCase %s()-%d line %d failed %s: ",
9501 			__func__, i, __LINE__,
9502 			"Failed to allocate symmetric crypto operation struct");
9503 		ret = TEST_FAILED;
9504 		goto on_err;
9505 	}
9506 
9507 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9508 					uint32_t *, IV_OFFSET);
9509 	*per_pkt_hfn = packet_direction ? hfn : 0;
9510 
9511 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9512 
9513 	/* set crypto operation source mbuf */
9514 	ut_params->op->sym->m_src = ut_params->ibuf;
9515 	if (oop)
9516 		ut_params->op->sym->m_dst = ut_params->obuf;
9517 
9518 	/* Process crypto operation */
9519 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9520 		/* filling lengths */
9521 		ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9522 		ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9523 
9524 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9525 		if (ret != TEST_SUCCESS)
9526 			return ret;
9527 	} else {
9528 		ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9529 	}
9530 	if (ut_params->op == NULL) {
9531 		printf("TestCase %s()-%d line %d failed %s: ",
9532 			__func__, i, __LINE__,
9533 			"failed to process sym crypto op");
9534 		ret = TEST_FAILED;
9535 		goto on_err;
9536 	}
9537 
9538 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9539 		printf("TestCase %s()-%d line %d failed %s: ",
9540 			__func__, i, __LINE__, "crypto op processing failed");
9541 		ret = TEST_FAILED;
9542 		goto on_err;
9543 	}
9544 
9545 	/* Validate obuf */
9546 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9547 			uint8_t *);
9548 	if (oop) {
9549 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9550 				uint8_t *);
9551 	}
9552 
9553 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
9554 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9555 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9556 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9557 		ret = TEST_FAILED;
9558 		goto on_err;
9559 	}
9560 
9561 on_err:
9562 	rte_crypto_op_free(ut_params->op);
9563 	ut_params->op = NULL;
9564 
9565 	if (ut_params->sec_session)
9566 		rte_security_session_destroy(ctx, ut_params->sec_session);
9567 	ut_params->sec_session = NULL;
9568 
9569 	rte_pktmbuf_free(ut_params->ibuf);
9570 	ut_params->ibuf = NULL;
9571 	if (oop) {
9572 		rte_pktmbuf_free(ut_params->obuf);
9573 		ut_params->obuf = NULL;
9574 	}
9575 
9576 	return ret;
9577 }
9578 
9579 static int
9580 test_pdcp_proto_SGL(int i, int oop,
9581 	enum rte_crypto_cipher_operation opc,
9582 	enum rte_crypto_auth_operation opa,
9583 	uint8_t *input_vec,
9584 	unsigned int input_vec_len,
9585 	uint8_t *output_vec,
9586 	unsigned int output_vec_len,
9587 	uint32_t fragsz,
9588 	uint32_t fragsz_oop)
9589 {
9590 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9591 	struct crypto_unittest_params *ut_params = &unittest_params;
9592 	uint8_t *plaintext;
9593 	struct rte_mbuf *buf, *buf_oop = NULL;
9594 	int ret = TEST_SUCCESS;
9595 	int to_trn = 0;
9596 	int to_trn_tbl[16];
9597 	int segs = 1;
9598 	unsigned int trn_data = 0;
9599 	struct rte_cryptodev_info dev_info;
9600 	uint64_t feat_flags;
9601 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9602 	struct rte_mbuf *temp_mbuf;
9603 
9604 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9605 	feat_flags = dev_info.feature_flags;
9606 
9607 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9608 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9609 		printf("Device does not support RAW data-path APIs.\n");
9610 		return -ENOTSUP;
9611 	}
9612 	/* Verify the capabilities */
9613 	struct rte_security_capability_idx sec_cap_idx;
9614 
9615 	sec_cap_idx.action = ut_params->type;
9616 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9617 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9618 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9619 		return TEST_SKIPPED;
9620 
9621 	if (fragsz > input_vec_len)
9622 		fragsz = input_vec_len;
9623 
9624 	uint16_t plaintext_len = fragsz;
9625 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9626 
9627 	if (fragsz_oop > output_vec_len)
9628 		frag_size_oop = output_vec_len;
9629 
9630 	int ecx = 0;
9631 	if (input_vec_len % fragsz != 0) {
9632 		if (input_vec_len / fragsz + 1 > 16)
9633 			return 1;
9634 	} else if (input_vec_len / fragsz > 16)
9635 		return 1;
9636 
9637 	/* Out of place support */
9638 	if (oop) {
9639 		/*
9640 		 * For out-of-place we need to alloc another mbuf
9641 		 */
9642 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9643 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9644 		buf_oop = ut_params->obuf;
9645 	}
9646 
9647 	/* Generate test mbuf data */
9648 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9649 
9650 	/* clear mbuf payload */
9651 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9652 			rte_pktmbuf_tailroom(ut_params->ibuf));
9653 
9654 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9655 						  plaintext_len);
9656 	memcpy(plaintext, input_vec, plaintext_len);
9657 	trn_data += plaintext_len;
9658 
9659 	buf = ut_params->ibuf;
9660 
9661 	/*
9662 	 * Loop until no more fragments
9663 	 */
9664 
9665 	while (trn_data < input_vec_len) {
9666 		++segs;
9667 		to_trn = (input_vec_len - trn_data < fragsz) ?
9668 				(input_vec_len - trn_data) : fragsz;
9669 
9670 		to_trn_tbl[ecx++] = to_trn;
9671 
9672 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9673 		buf = buf->next;
9674 
9675 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9676 				rte_pktmbuf_tailroom(buf));
9677 
9678 		/* OOP */
9679 		if (oop && !fragsz_oop) {
9680 			buf_oop->next =
9681 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
9682 			buf_oop = buf_oop->next;
9683 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9684 					0, rte_pktmbuf_tailroom(buf_oop));
9685 			rte_pktmbuf_append(buf_oop, to_trn);
9686 		}
9687 
9688 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9689 				to_trn);
9690 
9691 		memcpy(plaintext, input_vec + trn_data, to_trn);
9692 		trn_data += to_trn;
9693 	}
9694 
9695 	ut_params->ibuf->nb_segs = segs;
9696 
9697 	segs = 1;
9698 	if (fragsz_oop && oop) {
9699 		to_trn = 0;
9700 		ecx = 0;
9701 
9702 		trn_data = frag_size_oop;
9703 		while (trn_data < output_vec_len) {
9704 			++segs;
9705 			to_trn =
9706 				(output_vec_len - trn_data <
9707 						frag_size_oop) ?
9708 				(output_vec_len - trn_data) :
9709 						frag_size_oop;
9710 
9711 			to_trn_tbl[ecx++] = to_trn;
9712 
9713 			buf_oop->next =
9714 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
9715 			buf_oop = buf_oop->next;
9716 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9717 					0, rte_pktmbuf_tailroom(buf_oop));
9718 			rte_pktmbuf_append(buf_oop, to_trn);
9719 
9720 			trn_data += to_trn;
9721 		}
9722 		ut_params->obuf->nb_segs = segs;
9723 	}
9724 
9725 	/* Setup Cipher Parameters */
9726 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9727 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9728 	ut_params->cipher_xform.cipher.op = opc;
9729 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9730 	ut_params->cipher_xform.cipher.key.length =
9731 					pdcp_test_params[i].cipher_key_len;
9732 	ut_params->cipher_xform.cipher.iv.length = 0;
9733 
9734 	/* Setup HMAC Parameters if ICV header is required */
9735 	if (pdcp_test_params[i].auth_alg != 0) {
9736 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9737 		ut_params->auth_xform.next = NULL;
9738 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9739 		ut_params->auth_xform.auth.op = opa;
9740 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9741 		ut_params->auth_xform.auth.key.length =
9742 					pdcp_test_params[i].auth_key_len;
9743 
9744 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9745 	} else {
9746 		ut_params->cipher_xform.next = NULL;
9747 	}
9748 
9749 	struct rte_security_session_conf sess_conf = {
9750 		.action_type = ut_params->type,
9751 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9752 		{.pdcp = {
9753 			.bearer = pdcp_test_bearer[i],
9754 			.domain = pdcp_test_params[i].domain,
9755 			.pkt_dir = pdcp_test_packet_direction[i],
9756 			.sn_size = pdcp_test_data_sn_size[i],
9757 			.hfn = pdcp_test_hfn[i],
9758 			.hfn_threshold = pdcp_test_hfn_threshold[i],
9759 			.hfn_ovrd = 0,
9760 		} },
9761 		.crypto_xform = &ut_params->cipher_xform
9762 	};
9763 
9764 	/* Create security session */
9765 	ut_params->sec_session = rte_security_session_create(ctx,
9766 				&sess_conf, ts_params->session_mpool);
9767 
9768 	if (!ut_params->sec_session) {
9769 		printf("TestCase %s()-%d line %d failed %s: ",
9770 			__func__, i, __LINE__, "Failed to allocate session");
9771 		ret = TEST_FAILED;
9772 		goto on_err;
9773 	}
9774 
9775 	/* Generate crypto op data structure */
9776 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9777 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9778 	if (!ut_params->op) {
9779 		printf("TestCase %s()-%d line %d failed %s: ",
9780 			__func__, i, __LINE__,
9781 			"Failed to allocate symmetric crypto operation struct");
9782 		ret = TEST_FAILED;
9783 		goto on_err;
9784 	}
9785 
9786 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9787 
9788 	/* set crypto operation source mbuf */
9789 	ut_params->op->sym->m_src = ut_params->ibuf;
9790 	if (oop)
9791 		ut_params->op->sym->m_dst = ut_params->obuf;
9792 
9793 	/* Process crypto operation */
9794 	temp_mbuf = ut_params->op->sym->m_src;
9795 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9796 		/* filling lengths */
9797 		while (temp_mbuf) {
9798 			ut_params->op->sym->cipher.data.length
9799 				+= temp_mbuf->pkt_len;
9800 			ut_params->op->sym->auth.data.length
9801 				+= temp_mbuf->pkt_len;
9802 			temp_mbuf = temp_mbuf->next;
9803 		}
9804 
9805 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9806 		if (ret != TEST_SUCCESS)
9807 			return ret;
9808 	} else {
9809 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9810 							ut_params->op);
9811 	}
9812 	if (ut_params->op == NULL) {
9813 		printf("TestCase %s()-%d line %d failed %s: ",
9814 			__func__, i, __LINE__,
9815 			"failed to process sym crypto op");
9816 		ret = TEST_FAILED;
9817 		goto on_err;
9818 	}
9819 
9820 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9821 		printf("TestCase %s()-%d line %d failed %s: ",
9822 			__func__, i, __LINE__, "crypto op processing failed");
9823 		ret = TEST_FAILED;
9824 		goto on_err;
9825 	}
9826 
9827 	/* Validate obuf */
9828 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9829 			uint8_t *);
9830 	if (oop) {
9831 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9832 				uint8_t *);
9833 	}
9834 	if (fragsz_oop)
9835 		fragsz = frag_size_oop;
9836 	if (memcmp(ciphertext, output_vec, fragsz)) {
9837 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9838 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9839 		rte_hexdump(stdout, "reference", output_vec, fragsz);
9840 		ret = TEST_FAILED;
9841 		goto on_err;
9842 	}
9843 
9844 	buf = ut_params->op->sym->m_src->next;
9845 	if (oop)
9846 		buf = ut_params->op->sym->m_dst->next;
9847 
9848 	unsigned int off = fragsz;
9849 
9850 	ecx = 0;
9851 	while (buf) {
9852 		ciphertext = rte_pktmbuf_mtod(buf,
9853 				uint8_t *);
9854 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9855 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9856 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9857 			rte_hexdump(stdout, "reference", output_vec + off,
9858 					to_trn_tbl[ecx]);
9859 			ret = TEST_FAILED;
9860 			goto on_err;
9861 		}
9862 		off += to_trn_tbl[ecx++];
9863 		buf = buf->next;
9864 	}
9865 on_err:
9866 	rte_crypto_op_free(ut_params->op);
9867 	ut_params->op = NULL;
9868 
9869 	if (ut_params->sec_session)
9870 		rte_security_session_destroy(ctx, ut_params->sec_session);
9871 	ut_params->sec_session = NULL;
9872 
9873 	rte_pktmbuf_free(ut_params->ibuf);
9874 	ut_params->ibuf = NULL;
9875 	if (oop) {
9876 		rte_pktmbuf_free(ut_params->obuf);
9877 		ut_params->obuf = NULL;
9878 	}
9879 
9880 	return ret;
9881 }
9882 
9883 int
9884 test_pdcp_proto_cplane_encap(int i)
9885 {
9886 	return test_pdcp_proto(
9887 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9888 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9889 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9890 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9891 		pdcp_test_params[i].cipher_key_len,
9892 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9893 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9894 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9895 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9896 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9897 }
9898 
9899 int
9900 test_pdcp_proto_uplane_encap(int i)
9901 {
9902 	return test_pdcp_proto(
9903 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9904 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9905 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9906 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9907 		pdcp_test_params[i].cipher_key_len,
9908 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9909 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9910 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9911 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9912 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9913 }
9914 
9915 int
9916 test_pdcp_proto_uplane_encap_with_int(int i)
9917 {
9918 	return test_pdcp_proto(
9919 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9920 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9921 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9922 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9923 		pdcp_test_params[i].cipher_key_len,
9924 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9925 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9926 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9927 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9928 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9929 }
9930 
9931 int
9932 test_pdcp_proto_cplane_decap(int i)
9933 {
9934 	return test_pdcp_proto(
9935 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9936 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9937 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9938 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9939 		pdcp_test_params[i].cipher_key_len,
9940 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9941 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9942 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9943 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9944 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9945 }
9946 
9947 int
9948 test_pdcp_proto_uplane_decap(int i)
9949 {
9950 	return test_pdcp_proto(
9951 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9952 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9953 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9954 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9955 		pdcp_test_params[i].cipher_key_len,
9956 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9957 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9958 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9959 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9960 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9961 }
9962 
9963 int
9964 test_pdcp_proto_uplane_decap_with_int(int i)
9965 {
9966 	return test_pdcp_proto(
9967 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9968 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9969 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9970 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9971 		pdcp_test_params[i].cipher_key_len,
9972 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9973 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9974 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9975 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9976 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9977 }
9978 
9979 static int
9980 test_PDCP_PROTO_SGL_in_place_32B(void)
9981 {
9982 	/* i can be used for running any PDCP case
9983 	 * In this case it is uplane 12-bit AES-SNOW DL encap
9984 	 */
9985 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9986 	return test_pdcp_proto_SGL(i, IN_PLACE,
9987 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9988 			RTE_CRYPTO_AUTH_OP_GENERATE,
9989 			pdcp_test_data_in[i],
9990 			pdcp_test_data_in_len[i],
9991 			pdcp_test_data_out[i],
9992 			pdcp_test_data_in_len[i]+4,
9993 			32, 0);
9994 }
9995 static int
9996 test_PDCP_PROTO_SGL_oop_32B_128B(void)
9997 {
9998 	/* i can be used for running any PDCP case
9999 	 * In this case it is uplane 18-bit NULL-NULL DL encap
10000 	 */
10001 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10002 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10003 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10004 			RTE_CRYPTO_AUTH_OP_GENERATE,
10005 			pdcp_test_data_in[i],
10006 			pdcp_test_data_in_len[i],
10007 			pdcp_test_data_out[i],
10008 			pdcp_test_data_in_len[i]+4,
10009 			32, 128);
10010 }
10011 static int
10012 test_PDCP_PROTO_SGL_oop_32B_40B(void)
10013 {
10014 	/* i can be used for running any PDCP case
10015 	 * In this case it is uplane 18-bit AES DL encap
10016 	 */
10017 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10018 			+ DOWNLINK;
10019 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10020 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10021 			RTE_CRYPTO_AUTH_OP_GENERATE,
10022 			pdcp_test_data_in[i],
10023 			pdcp_test_data_in_len[i],
10024 			pdcp_test_data_out[i],
10025 			pdcp_test_data_in_len[i],
10026 			32, 40);
10027 }
10028 static int
10029 test_PDCP_PROTO_SGL_oop_128B_32B(void)
10030 {
10031 	/* i can be used for running any PDCP case
10032 	 * In this case it is cplane 12-bit AES-ZUC DL encap
10033 	 */
10034 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10035 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10036 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10037 			RTE_CRYPTO_AUTH_OP_GENERATE,
10038 			pdcp_test_data_in[i],
10039 			pdcp_test_data_in_len[i],
10040 			pdcp_test_data_out[i],
10041 			pdcp_test_data_in_len[i]+4,
10042 			128, 32);
10043 }
10044 
10045 static int
10046 test_PDCP_SDAP_PROTO_encap_all(void)
10047 {
10048 	int i = 0, size = 0;
10049 	int err, all_err = TEST_SUCCESS;
10050 	const struct pdcp_sdap_test *cur_test;
10051 
10052 	size = RTE_DIM(list_pdcp_sdap_tests);
10053 
10054 	for (i = 0; i < size; i++) {
10055 		cur_test = &list_pdcp_sdap_tests[i];
10056 		err = test_pdcp_proto(
10057 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10058 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10059 			cur_test->in_len, cur_test->data_out,
10060 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10061 			cur_test->param.cipher_alg, cur_test->cipher_key,
10062 			cur_test->param.cipher_key_len,
10063 			cur_test->param.auth_alg,
10064 			cur_test->auth_key, cur_test->param.auth_key_len,
10065 			cur_test->bearer, cur_test->param.domain,
10066 			cur_test->packet_direction, cur_test->sn_size,
10067 			cur_test->hfn,
10068 			cur_test->hfn_threshold, SDAP_ENABLED);
10069 		if (err) {
10070 			printf("\t%d) %s: Encapsulation failed\n",
10071 					cur_test->test_idx,
10072 					cur_test->param.name);
10073 			err = TEST_FAILED;
10074 		} else {
10075 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10076 					cur_test->param.name);
10077 			err = TEST_SUCCESS;
10078 		}
10079 		all_err += err;
10080 	}
10081 
10082 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10083 
10084 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10085 }
10086 
10087 static int
10088 test_PDCP_PROTO_short_mac(void)
10089 {
10090 	int i = 0, size = 0;
10091 	int err, all_err = TEST_SUCCESS;
10092 	const struct pdcp_short_mac_test *cur_test;
10093 
10094 	size = RTE_DIM(list_pdcp_smac_tests);
10095 
10096 	for (i = 0; i < size; i++) {
10097 		cur_test = &list_pdcp_smac_tests[i];
10098 		err = test_pdcp_proto(
10099 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10100 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10101 			cur_test->in_len, cur_test->data_out,
10102 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10103 			RTE_CRYPTO_CIPHER_NULL, NULL,
10104 			0, cur_test->param.auth_alg,
10105 			cur_test->auth_key, cur_test->param.auth_key_len,
10106 			0, cur_test->param.domain, 0, 0,
10107 			0, 0, 0);
10108 		if (err) {
10109 			printf("\t%d) %s: Short MAC test failed\n",
10110 					cur_test->test_idx,
10111 					cur_test->param.name);
10112 			err = TEST_FAILED;
10113 		} else {
10114 			printf("\t%d) %s: Short MAC test PASS\n",
10115 					cur_test->test_idx,
10116 					cur_test->param.name);
10117 			rte_hexdump(stdout, "MAC I",
10118 				    cur_test->data_out + cur_test->in_len + 2,
10119 				    2);
10120 			err = TEST_SUCCESS;
10121 		}
10122 		all_err += err;
10123 	}
10124 
10125 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10126 
10127 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10128 
10129 }
10130 
10131 static int
10132 test_PDCP_SDAP_PROTO_decap_all(void)
10133 {
10134 	int i = 0, size = 0;
10135 	int err, all_err = TEST_SUCCESS;
10136 	const struct pdcp_sdap_test *cur_test;
10137 
10138 	size = RTE_DIM(list_pdcp_sdap_tests);
10139 
10140 	for (i = 0; i < size; i++) {
10141 		cur_test = &list_pdcp_sdap_tests[i];
10142 		err = test_pdcp_proto(
10143 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10144 			RTE_CRYPTO_AUTH_OP_VERIFY,
10145 			cur_test->data_out,
10146 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10147 			cur_test->data_in, cur_test->in_len,
10148 			cur_test->param.cipher_alg,
10149 			cur_test->cipher_key, cur_test->param.cipher_key_len,
10150 			cur_test->param.auth_alg, cur_test->auth_key,
10151 			cur_test->param.auth_key_len, cur_test->bearer,
10152 			cur_test->param.domain, cur_test->packet_direction,
10153 			cur_test->sn_size, cur_test->hfn,
10154 			cur_test->hfn_threshold, SDAP_ENABLED);
10155 		if (err) {
10156 			printf("\t%d) %s: Decapsulation failed\n",
10157 					cur_test->test_idx,
10158 					cur_test->param.name);
10159 			err = TEST_FAILED;
10160 		} else {
10161 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10162 					cur_test->param.name);
10163 			err = TEST_SUCCESS;
10164 		}
10165 		all_err += err;
10166 	}
10167 
10168 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10169 
10170 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10171 }
10172 
10173 static int
10174 test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10175 			       struct crypto_unittest_params *ut_params,
10176 			       struct rte_security_ipsec_xform *ipsec_xform,
10177 			       const struct ipsec_test_data *td,
10178 			       const struct ipsec_test_flags *flags,
10179 			       int pkt_num)
10180 {
10181 	uint8_t dev_id = ts_params->valid_devs[0];
10182 	enum rte_security_ipsec_sa_direction dir;
10183 	int ret;
10184 
10185 	dir = ipsec_xform->direction;
10186 
10187 	/* Generate crypto op data structure */
10188 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10189 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10190 	if (!ut_params->op) {
10191 		printf("Could not allocate crypto op");
10192 		return TEST_FAILED;
10193 	}
10194 
10195 	/* Attach session to operation */
10196 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10197 
10198 	/* Set crypto operation mbufs */
10199 	ut_params->op->sym->m_src = ut_params->ibuf;
10200 	ut_params->op->sym->m_dst = NULL;
10201 
10202 	/* Copy IV in crypto operation when IV generation is disabled */
10203 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10204 	    ipsec_xform->options.iv_gen_disable == 1) {
10205 		uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10206 							uint8_t *,
10207 							IV_OFFSET);
10208 		int len;
10209 
10210 		if (td->aead)
10211 			len = td->xform.aead.aead.iv.length;
10212 		else if (td->aes_gmac)
10213 			len = td->xform.chain.auth.auth.iv.length;
10214 		else
10215 			len = td->xform.chain.cipher.cipher.iv.length;
10216 
10217 		memcpy(iv, td->iv.data, len);
10218 	}
10219 
10220 	/* Process crypto operation */
10221 	process_crypto_request(dev_id, ut_params->op);
10222 
10223 	ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10224 
10225 	rte_crypto_op_free(ut_params->op);
10226 	ut_params->op = NULL;
10227 
10228 	return ret;
10229 }
10230 
10231 static int
10232 test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10233 			  struct crypto_unittest_params *ut_params,
10234 			  void *ctx)
10235 {
10236 	uint64_t timeout, userdata;
10237 	struct rte_ether_hdr *hdr;
10238 	struct rte_mbuf *m;
10239 	void **sec_sess;
10240 	int ret;
10241 
10242 	RTE_SET_USED(ts_params);
10243 
10244 	hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10245 	hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10246 
10247 	ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10248 	ut_params->ibuf->port = 0;
10249 
10250 	sec_sess = &ut_params->sec_session;
10251 	ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10252 
10253 	if (ret != 1)
10254 		return TEST_FAILED;
10255 
10256 	ut_params->ibuf = NULL;
10257 
10258 	/* Add a timeout for 1 s */
10259 	timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10260 
10261 	do {
10262 		/* Get packet from port 0, queue 0 */
10263 		ret = rte_eth_rx_burst(0, 0, &m, 1);
10264 	} while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10265 
10266 	if (ret == 0) {
10267 		printf("Could not receive packets from ethdev\n");
10268 		return TEST_FAILED;
10269 	}
10270 
10271 	if (m == NULL) {
10272 		printf("Received mbuf is NULL\n");
10273 		return TEST_FAILED;
10274 	}
10275 
10276 	ut_params->ibuf = m;
10277 
10278 	if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10279 		printf("Received packet is not Rx security processed\n");
10280 		return TEST_FAILED;
10281 	}
10282 
10283 	if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10284 		printf("Received packet has failed Rx security processing\n");
10285 		return TEST_FAILED;
10286 	}
10287 
10288 	/*
10289 	 * 'ut_params' is set as userdata. Verify that the field is returned
10290 	 * correctly.
10291 	 */
10292 	userdata = *(uint64_t *)rte_security_dynfield(m);
10293 	if (userdata != (uint64_t)ut_params) {
10294 		printf("Userdata retrieved not matching expected\n");
10295 		return TEST_FAILED;
10296 	}
10297 
10298 	/* Trim L2 header */
10299 	rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10300 
10301 	return TEST_SUCCESS;
10302 }
10303 
10304 static int
10305 test_ipsec_proto_process(const struct ipsec_test_data td[],
10306 			 struct ipsec_test_data res_d[],
10307 			 int nb_td,
10308 			 bool silent,
10309 			 const struct ipsec_test_flags *flags)
10310 {
10311 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10312 				0x0000, 0x001a};
10313 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10314 				0xe82c, 0x4887};
10315 	const struct rte_ipv4_hdr *ipv4 =
10316 			(const struct rte_ipv4_hdr *)td[0].output_text.data;
10317 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10318 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10319 	struct crypto_unittest_params *ut_params = &unittest_params;
10320 	struct rte_security_capability_idx sec_cap_idx;
10321 	const struct rte_security_capability *sec_cap;
10322 	struct rte_security_ipsec_xform ipsec_xform;
10323 	uint8_t dev_id = ts_params->valid_devs[0];
10324 	enum rte_security_ipsec_sa_direction dir;
10325 	struct ipsec_test_data *res_d_tmp = NULL;
10326 	uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10327 	int salt_len, i, ret = TEST_SUCCESS;
10328 	void *ctx;
10329 	uint32_t src, dst;
10330 	uint32_t verify;
10331 
10332 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10333 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10334 
10335 	/* Use first test data to create session */
10336 
10337 	/* Copy IPsec xform */
10338 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10339 
10340 	dir = ipsec_xform.direction;
10341 	verify = flags->tunnel_hdr_verify;
10342 
10343 	memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10344 	memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10345 
10346 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10347 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10348 			src += 1;
10349 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10350 			dst += 1;
10351 	}
10352 
10353 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10354 		if (td->ipsec_xform.tunnel.type ==
10355 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10356 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10357 			       sizeof(src));
10358 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10359 			       sizeof(dst));
10360 
10361 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10362 				ipsec_xform.tunnel.ipv4.df = 0;
10363 
10364 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10365 				ipsec_xform.tunnel.ipv4.df = 1;
10366 
10367 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10368 				ipsec_xform.tunnel.ipv4.dscp = 0;
10369 
10370 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10371 				ipsec_xform.tunnel.ipv4.dscp =
10372 						TEST_IPSEC_DSCP_VAL;
10373 
10374 		} else {
10375 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10376 				ipsec_xform.tunnel.ipv6.dscp = 0;
10377 
10378 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10379 				ipsec_xform.tunnel.ipv6.dscp =
10380 						TEST_IPSEC_DSCP_VAL;
10381 
10382 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10383 			       sizeof(v6_src));
10384 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10385 			       sizeof(v6_dst));
10386 		}
10387 	}
10388 
10389 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
10390 
10391 	sec_cap_idx.action = ut_params->type;
10392 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10393 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10394 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10395 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10396 
10397 	if (flags->udp_encap)
10398 		ipsec_xform.options.udp_encap = 1;
10399 
10400 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10401 	if (sec_cap == NULL)
10402 		return TEST_SKIPPED;
10403 
10404 	/* Copy cipher session parameters */
10405 	if (td[0].aead) {
10406 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10407 		       sizeof(ut_params->aead_xform));
10408 		ut_params->aead_xform.aead.key.data = td[0].key.data;
10409 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10410 
10411 		/* Verify crypto capabilities */
10412 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10413 			if (!silent)
10414 				RTE_LOG(INFO, USER1,
10415 					"Crypto capabilities not supported\n");
10416 			return TEST_SKIPPED;
10417 		}
10418 	} else if (td[0].auth_only) {
10419 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10420 		       sizeof(ut_params->auth_xform));
10421 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10422 
10423 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10424 			if (!silent)
10425 				RTE_LOG(INFO, USER1,
10426 					"Auth crypto capabilities not supported\n");
10427 			return TEST_SKIPPED;
10428 		}
10429 	} else {
10430 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10431 		       sizeof(ut_params->cipher_xform));
10432 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10433 		       sizeof(ut_params->auth_xform));
10434 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10435 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10436 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10437 
10438 		/* Verify crypto capabilities */
10439 
10440 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10441 			if (!silent)
10442 				RTE_LOG(INFO, USER1,
10443 					"Cipher crypto capabilities not supported\n");
10444 			return TEST_SKIPPED;
10445 		}
10446 
10447 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10448 			if (!silent)
10449 				RTE_LOG(INFO, USER1,
10450 					"Auth crypto capabilities not supported\n");
10451 			return TEST_SKIPPED;
10452 		}
10453 	}
10454 
10455 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10456 		return TEST_SKIPPED;
10457 
10458 	struct rte_security_session_conf sess_conf = {
10459 		.action_type = ut_params->type,
10460 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10461 	};
10462 
10463 	if (td[0].aead || td[0].aes_gmac) {
10464 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10465 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10466 	}
10467 
10468 	if (td[0].aead) {
10469 		sess_conf.ipsec = ipsec_xform;
10470 		sess_conf.crypto_xform = &ut_params->aead_xform;
10471 	} else if (td[0].auth_only) {
10472 		sess_conf.ipsec = ipsec_xform;
10473 		sess_conf.crypto_xform = &ut_params->auth_xform;
10474 	} else {
10475 		sess_conf.ipsec = ipsec_xform;
10476 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10477 			sess_conf.crypto_xform = &ut_params->cipher_xform;
10478 			ut_params->cipher_xform.next = &ut_params->auth_xform;
10479 		} else {
10480 			sess_conf.crypto_xform = &ut_params->auth_xform;
10481 			ut_params->auth_xform.next = &ut_params->cipher_xform;
10482 		}
10483 	}
10484 
10485 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10486 		sess_conf.userdata = ut_params;
10487 
10488 	/* Create security session */
10489 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10490 					ts_params->session_mpool);
10491 
10492 	if (ut_params->sec_session == NULL)
10493 		return TEST_SKIPPED;
10494 
10495 	for (i = 0; i < nb_td; i++) {
10496 		if (flags->antireplay &&
10497 		    (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10498 			sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10499 			ret = rte_security_session_update(ctx,
10500 				ut_params->sec_session, &sess_conf);
10501 			if (ret) {
10502 				printf("Could not update sequence number in "
10503 				       "session\n");
10504 				return TEST_SKIPPED;
10505 			}
10506 		}
10507 
10508 		/* Copy test data before modification */
10509 		memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10510 		if (test_ipsec_pkt_update(input_text, flags)) {
10511 			ret = TEST_FAILED;
10512 			goto mbuf_free;
10513 		}
10514 
10515 		/* Setup source mbuf payload */
10516 		if (flags->use_ext_mbuf) {
10517 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10518 					td[i].input_text.len, nb_segs, input_text);
10519 		} else {
10520 			ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10521 					td[i].input_text.len, nb_segs, 0);
10522 			pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10523 		}
10524 
10525 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10526 			ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10527 							ctx);
10528 		else
10529 			ret = test_ipsec_proto_crypto_op_enq(ts_params,
10530 							     ut_params,
10531 							     &ipsec_xform,
10532 							     &td[i], flags,
10533 							     i + 1);
10534 
10535 		if (ret != TEST_SUCCESS)
10536 			goto mbuf_free;
10537 
10538 		if (res_d != NULL)
10539 			res_d_tmp = &res_d[i];
10540 
10541 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10542 					      res_d_tmp, silent, flags);
10543 		if (ret != TEST_SUCCESS)
10544 			goto mbuf_free;
10545 
10546 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10547 					      flags, dir);
10548 		if (ret != TEST_SUCCESS)
10549 			goto mbuf_free;
10550 
10551 		rte_pktmbuf_free(ut_params->ibuf);
10552 		ut_params->ibuf = NULL;
10553 	}
10554 
10555 mbuf_free:
10556 	if (flags->use_ext_mbuf)
10557 		ext_mbuf_memzone_free(nb_segs);
10558 
10559 	rte_pktmbuf_free(ut_params->ibuf);
10560 	ut_params->ibuf = NULL;
10561 
10562 	if (ut_params->sec_session)
10563 		rte_security_session_destroy(ctx, ut_params->sec_session);
10564 	ut_params->sec_session = NULL;
10565 
10566 	return ret;
10567 }
10568 
10569 static int
10570 test_ipsec_proto_known_vec(const void *test_data)
10571 {
10572 	struct ipsec_test_data td_outb;
10573 	struct ipsec_test_flags flags;
10574 
10575 	memset(&flags, 0, sizeof(flags));
10576 
10577 	memcpy(&td_outb, test_data, sizeof(td_outb));
10578 
10579 	if (td_outb.aes_gmac || td_outb.aead ||
10580 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10581 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10582 		/* Disable IV gen to be able to test with known vectors */
10583 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10584 	}
10585 
10586 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10587 }
10588 
10589 static int
10590 test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10591 {
10592 	struct ipsec_test_data td_outb;
10593 	struct ipsec_test_flags flags;
10594 
10595 	memset(&flags, 0, sizeof(flags));
10596 	flags.use_ext_mbuf = true;
10597 
10598 	memcpy(&td_outb, test_data, sizeof(td_outb));
10599 
10600 	if (td_outb.aes_gmac || td_outb.aead ||
10601 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10602 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10603 		/* Disable IV gen to be able to test with known vectors */
10604 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10605 	}
10606 
10607 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10608 }
10609 
10610 static int
10611 test_ipsec_proto_known_vec_inb(const void *test_data)
10612 {
10613 	const struct ipsec_test_data *td = test_data;
10614 	struct ipsec_test_flags flags;
10615 	struct ipsec_test_data td_inb;
10616 
10617 	memset(&flags, 0, sizeof(flags));
10618 
10619 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10620 		test_ipsec_td_in_from_out(td, &td_inb);
10621 	else
10622 		memcpy(&td_inb, td, sizeof(td_inb));
10623 
10624 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10625 }
10626 
10627 static int
10628 test_ipsec_proto_known_vec_fragmented(const void *test_data)
10629 {
10630 	struct ipsec_test_data td_outb;
10631 	struct ipsec_test_flags flags;
10632 
10633 	memset(&flags, 0, sizeof(flags));
10634 	flags.fragment = true;
10635 
10636 	memcpy(&td_outb, test_data, sizeof(td_outb));
10637 
10638 	/* Disable IV gen to be able to test with known vectors */
10639 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
10640 
10641 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10642 }
10643 
10644 static int
10645 test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10646 {
10647 	const struct ipsec_test_data *td = test_data;
10648 	struct ipsec_test_flags flags;
10649 	struct ipsec_test_data td_inb;
10650 
10651 	memset(&flags, 0, sizeof(flags));
10652 	flags.rx_inject = true;
10653 
10654 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10655 		test_ipsec_td_in_from_out(td, &td_inb);
10656 	else
10657 		memcpy(&td_inb, td, sizeof(td_inb));
10658 
10659 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10660 }
10661 
10662 static int
10663 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10664 {
10665 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10666 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10667 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10668 	int ret;
10669 
10670 	if (flags->iv_gen ||
10671 	    flags->sa_expiry_pkts_soft ||
10672 	    flags->sa_expiry_pkts_hard)
10673 		nb_pkts = TEST_SEC_PKTS_MAX;
10674 
10675 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10676 		test_ipsec_td_prepare(sec_alg_list[i].param1,
10677 				      sec_alg_list[i].param2,
10678 				      flags,
10679 				      td_outb,
10680 				      nb_pkts);
10681 
10682 		if (!td_outb->aead) {
10683 			enum rte_crypto_cipher_algorithm cipher_alg;
10684 			enum rte_crypto_auth_algorithm auth_alg;
10685 
10686 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10687 			auth_alg = td_outb->xform.chain.auth.auth.algo;
10688 
10689 			if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10690 				continue;
10691 
10692 			/* ICV is not applicable for NULL auth */
10693 			if (flags->icv_corrupt &&
10694 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
10695 				continue;
10696 
10697 			/* IV is not applicable for NULL cipher */
10698 			if (flags->iv_gen &&
10699 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10700 				continue;
10701 		}
10702 
10703 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10704 					       flags);
10705 		if (ret == TEST_SKIPPED)
10706 			continue;
10707 
10708 		if (ret == TEST_FAILED)
10709 			return TEST_FAILED;
10710 
10711 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10712 
10713 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10714 					       flags);
10715 		if (ret == TEST_SKIPPED)
10716 			continue;
10717 
10718 		if (ret == TEST_FAILED)
10719 			return TEST_FAILED;
10720 
10721 		if (flags->display_alg)
10722 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10723 
10724 		pass_cnt++;
10725 	}
10726 
10727 	if (pass_cnt > 0)
10728 		return TEST_SUCCESS;
10729 	else
10730 		return TEST_SKIPPED;
10731 }
10732 
10733 static int
10734 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10735 {
10736 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10737 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10738 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10739 	int ret;
10740 
10741 	for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10742 		test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10743 				      sec_auth_only_alg_list[i].param2,
10744 				      flags,
10745 				      td_outb,
10746 				      nb_pkts);
10747 
10748 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10749 					       flags);
10750 		if (ret == TEST_SKIPPED)
10751 			continue;
10752 
10753 		if (ret == TEST_FAILED)
10754 			return TEST_FAILED;
10755 
10756 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10757 
10758 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10759 					       flags);
10760 		if (ret == TEST_SKIPPED)
10761 			continue;
10762 
10763 		if (ret == TEST_FAILED)
10764 			return TEST_FAILED;
10765 
10766 		if (flags->display_alg)
10767 			test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10768 					     sec_auth_only_alg_list[i].param2);
10769 
10770 		pass_cnt++;
10771 	}
10772 
10773 	if (pass_cnt > 0)
10774 		return TEST_SUCCESS;
10775 	else
10776 		return TEST_SKIPPED;
10777 }
10778 
10779 static int
10780 test_ipsec_proto_display_list(void)
10781 {
10782 	struct ipsec_test_flags flags;
10783 
10784 	memset(&flags, 0, sizeof(flags));
10785 
10786 	flags.display_alg = true;
10787 
10788 	return test_ipsec_proto_all(&flags);
10789 }
10790 
10791 static int
10792 test_ipsec_proto_ah_tunnel_ipv4(void)
10793 {
10794 	struct ipsec_test_flags flags;
10795 
10796 	memset(&flags, 0, sizeof(flags));
10797 
10798 	flags.ah = true;
10799 	flags.display_alg = true;
10800 
10801 	return test_ipsec_ah_proto_all(&flags);
10802 }
10803 
10804 static int
10805 test_ipsec_proto_ah_transport_ipv4(void)
10806 {
10807 	struct ipsec_test_flags flags;
10808 
10809 	memset(&flags, 0, sizeof(flags));
10810 
10811 	flags.ah = true;
10812 	flags.transport = true;
10813 
10814 	return test_ipsec_ah_proto_all(&flags);
10815 }
10816 
10817 static int
10818 test_ipsec_proto_iv_gen(void)
10819 {
10820 	struct ipsec_test_flags flags;
10821 
10822 	memset(&flags, 0, sizeof(flags));
10823 
10824 	flags.iv_gen = true;
10825 
10826 	return test_ipsec_proto_all(&flags);
10827 }
10828 
10829 static int
10830 test_ipsec_proto_sa_exp_pkts_soft(void)
10831 {
10832 	struct ipsec_test_flags flags;
10833 
10834 	memset(&flags, 0, sizeof(flags));
10835 
10836 	flags.sa_expiry_pkts_soft = true;
10837 
10838 	return test_ipsec_proto_all(&flags);
10839 }
10840 
10841 static int
10842 test_ipsec_proto_sa_exp_pkts_hard(void)
10843 {
10844 	struct ipsec_test_flags flags;
10845 
10846 	memset(&flags, 0, sizeof(flags));
10847 
10848 	flags.sa_expiry_pkts_hard = true;
10849 
10850 	return test_ipsec_proto_all(&flags);
10851 }
10852 
10853 static int
10854 test_ipsec_proto_err_icv_corrupt(void)
10855 {
10856 	struct ipsec_test_flags flags;
10857 
10858 	memset(&flags, 0, sizeof(flags));
10859 
10860 	flags.icv_corrupt = true;
10861 
10862 	return test_ipsec_proto_all(&flags);
10863 }
10864 
10865 static int
10866 test_ipsec_proto_udp_encap_custom_ports(void)
10867 {
10868 	struct ipsec_test_flags flags;
10869 
10870 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10871 			RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10872 		return TEST_SKIPPED;
10873 
10874 	memset(&flags, 0, sizeof(flags));
10875 
10876 	flags.udp_encap = true;
10877 	flags.udp_encap_custom_ports = true;
10878 
10879 	return test_ipsec_proto_all(&flags);
10880 }
10881 
10882 static int
10883 test_ipsec_proto_udp_encap(void)
10884 {
10885 	struct ipsec_test_flags flags;
10886 
10887 	memset(&flags, 0, sizeof(flags));
10888 
10889 	flags.udp_encap = true;
10890 
10891 	return test_ipsec_proto_all(&flags);
10892 }
10893 
10894 static int
10895 test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10896 {
10897 	struct ipsec_test_flags flags;
10898 
10899 	memset(&flags, 0, sizeof(flags));
10900 
10901 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10902 
10903 	return test_ipsec_proto_all(&flags);
10904 }
10905 
10906 static int
10907 test_ipsec_proto_tunnel_dst_addr_verify(void)
10908 {
10909 	struct ipsec_test_flags flags;
10910 
10911 	memset(&flags, 0, sizeof(flags));
10912 
10913 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10914 
10915 	return test_ipsec_proto_all(&flags);
10916 }
10917 
10918 static int
10919 test_ipsec_proto_udp_ports_verify(void)
10920 {
10921 	struct ipsec_test_flags flags;
10922 
10923 	memset(&flags, 0, sizeof(flags));
10924 
10925 	flags.udp_encap = true;
10926 	flags.udp_ports_verify = true;
10927 
10928 	return test_ipsec_proto_all(&flags);
10929 }
10930 
10931 static int
10932 test_ipsec_proto_inner_ip_csum(void)
10933 {
10934 	struct ipsec_test_flags flags;
10935 
10936 	memset(&flags, 0, sizeof(flags));
10937 
10938 	flags.ip_csum = true;
10939 
10940 	return test_ipsec_proto_all(&flags);
10941 }
10942 
10943 static int
10944 test_ipsec_proto_inner_l4_csum(void)
10945 {
10946 	struct ipsec_test_flags flags;
10947 
10948 	memset(&flags, 0, sizeof(flags));
10949 
10950 	flags.l4_csum = true;
10951 
10952 	return test_ipsec_proto_all(&flags);
10953 }
10954 
10955 static int
10956 test_ipsec_proto_tunnel_v4_in_v4(void)
10957 {
10958 	struct ipsec_test_flags flags;
10959 
10960 	memset(&flags, 0, sizeof(flags));
10961 
10962 	flags.ipv6 = false;
10963 	flags.tunnel_ipv6 = false;
10964 
10965 	return test_ipsec_proto_all(&flags);
10966 }
10967 
10968 static int
10969 test_ipsec_proto_tunnel_v6_in_v6(void)
10970 {
10971 	struct ipsec_test_flags flags;
10972 
10973 	memset(&flags, 0, sizeof(flags));
10974 
10975 	flags.ipv6 = true;
10976 	flags.tunnel_ipv6 = true;
10977 
10978 	return test_ipsec_proto_all(&flags);
10979 }
10980 
10981 static int
10982 test_ipsec_proto_tunnel_v4_in_v6(void)
10983 {
10984 	struct ipsec_test_flags flags;
10985 
10986 	memset(&flags, 0, sizeof(flags));
10987 
10988 	flags.ipv6 = false;
10989 	flags.tunnel_ipv6 = true;
10990 
10991 	return test_ipsec_proto_all(&flags);
10992 }
10993 
10994 static int
10995 test_ipsec_proto_tunnel_v6_in_v4(void)
10996 {
10997 	struct ipsec_test_flags flags;
10998 
10999 	memset(&flags, 0, sizeof(flags));
11000 
11001 	flags.ipv6 = true;
11002 	flags.tunnel_ipv6 = false;
11003 
11004 	return test_ipsec_proto_all(&flags);
11005 }
11006 
11007 static int
11008 test_ipsec_proto_transport_v4(void)
11009 {
11010 	struct ipsec_test_flags flags;
11011 
11012 	memset(&flags, 0, sizeof(flags));
11013 
11014 	flags.ipv6 = false;
11015 	flags.transport = true;
11016 
11017 	return test_ipsec_proto_all(&flags);
11018 }
11019 
11020 static int
11021 test_ipsec_proto_transport_l4_csum(void)
11022 {
11023 	struct ipsec_test_flags flags = {
11024 		.l4_csum = true,
11025 		.transport = true,
11026 	};
11027 
11028 	return test_ipsec_proto_all(&flags);
11029 }
11030 
11031 static int
11032 test_ipsec_proto_stats(void)
11033 {
11034 	struct ipsec_test_flags flags;
11035 
11036 	memset(&flags, 0, sizeof(flags));
11037 
11038 	flags.stats_success = true;
11039 
11040 	return test_ipsec_proto_all(&flags);
11041 }
11042 
11043 static int
11044 test_ipsec_proto_pkt_fragment(void)
11045 {
11046 	struct ipsec_test_flags flags;
11047 
11048 	memset(&flags, 0, sizeof(flags));
11049 
11050 	flags.fragment = true;
11051 
11052 	return test_ipsec_proto_all(&flags);
11053 
11054 }
11055 
11056 static int
11057 test_ipsec_proto_copy_df_inner_0(void)
11058 {
11059 	struct ipsec_test_flags flags;
11060 
11061 	memset(&flags, 0, sizeof(flags));
11062 
11063 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11064 
11065 	return test_ipsec_proto_all(&flags);
11066 }
11067 
11068 static int
11069 test_ipsec_proto_copy_df_inner_1(void)
11070 {
11071 	struct ipsec_test_flags flags;
11072 
11073 	memset(&flags, 0, sizeof(flags));
11074 
11075 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11076 
11077 	return test_ipsec_proto_all(&flags);
11078 }
11079 
11080 static int
11081 test_ipsec_proto_set_df_0_inner_1(void)
11082 {
11083 	struct ipsec_test_flags flags;
11084 
11085 	memset(&flags, 0, sizeof(flags));
11086 
11087 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11088 
11089 	return test_ipsec_proto_all(&flags);
11090 }
11091 
11092 static int
11093 test_ipsec_proto_set_df_1_inner_0(void)
11094 {
11095 	struct ipsec_test_flags flags;
11096 
11097 	memset(&flags, 0, sizeof(flags));
11098 
11099 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11100 
11101 	return test_ipsec_proto_all(&flags);
11102 }
11103 
11104 static int
11105 test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11106 {
11107 	struct ipsec_test_flags flags;
11108 
11109 	memset(&flags, 0, sizeof(flags));
11110 
11111 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11112 
11113 	return test_ipsec_proto_all(&flags);
11114 }
11115 
11116 static int
11117 test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11118 {
11119 	struct ipsec_test_flags flags;
11120 
11121 	memset(&flags, 0, sizeof(flags));
11122 
11123 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11124 
11125 	return test_ipsec_proto_all(&flags);
11126 }
11127 
11128 static int
11129 test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11130 {
11131 	struct ipsec_test_flags flags;
11132 
11133 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11134 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11135 		return TEST_SKIPPED;
11136 
11137 	memset(&flags, 0, sizeof(flags));
11138 
11139 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11140 
11141 	return test_ipsec_proto_all(&flags);
11142 }
11143 
11144 static int
11145 test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11146 {
11147 	struct ipsec_test_flags flags;
11148 
11149 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11150 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11151 		return TEST_SKIPPED;
11152 
11153 	memset(&flags, 0, sizeof(flags));
11154 
11155 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11156 
11157 	return test_ipsec_proto_all(&flags);
11158 }
11159 
11160 static int
11161 test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11162 {
11163 	struct ipsec_test_flags flags;
11164 
11165 	memset(&flags, 0, sizeof(flags));
11166 
11167 	flags.ipv6 = true;
11168 	flags.tunnel_ipv6 = true;
11169 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11170 
11171 	return test_ipsec_proto_all(&flags);
11172 }
11173 
11174 static int
11175 test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11176 {
11177 	struct ipsec_test_flags flags;
11178 
11179 	memset(&flags, 0, sizeof(flags));
11180 
11181 	flags.ipv6 = true;
11182 	flags.tunnel_ipv6 = true;
11183 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11184 
11185 	return test_ipsec_proto_all(&flags);
11186 }
11187 
11188 static int
11189 test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11190 {
11191 	struct ipsec_test_flags flags;
11192 
11193 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11194 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11195 		return TEST_SKIPPED;
11196 
11197 	memset(&flags, 0, sizeof(flags));
11198 
11199 	flags.ipv6 = true;
11200 	flags.tunnel_ipv6 = true;
11201 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11202 
11203 	return test_ipsec_proto_all(&flags);
11204 }
11205 
11206 static int
11207 test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11208 {
11209 	struct ipsec_test_flags flags;
11210 
11211 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11212 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11213 		return TEST_SKIPPED;
11214 
11215 	memset(&flags, 0, sizeof(flags));
11216 
11217 	flags.ipv6 = true;
11218 	flags.tunnel_ipv6 = true;
11219 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11220 
11221 	return test_ipsec_proto_all(&flags);
11222 }
11223 
11224 static int
11225 test_ipsec_proto_sgl(void)
11226 {
11227 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11228 	struct rte_cryptodev_info dev_info;
11229 
11230 	struct ipsec_test_flags flags = {
11231 		.nb_segs_in_mbuf = 5
11232 	};
11233 
11234 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11235 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11236 		printf("Device doesn't support in-place scatter-gather. "
11237 				"Test Skipped.\n");
11238 		return TEST_SKIPPED;
11239 	}
11240 
11241 	return test_ipsec_proto_all(&flags);
11242 }
11243 
11244 static int
11245 test_ipsec_proto_sgl_ext_mbuf(void)
11246 {
11247 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11248 	struct rte_cryptodev_info dev_info;
11249 
11250 	struct ipsec_test_flags flags = {
11251 		.nb_segs_in_mbuf = 5,
11252 		.use_ext_mbuf = 1
11253 	};
11254 
11255 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11256 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11257 		printf("Device doesn't support in-place scatter-gather. "
11258 				"Test Skipped.\n");
11259 		return TEST_SKIPPED;
11260 	}
11261 
11262 	return test_ipsec_proto_all(&flags);
11263 }
11264 
11265 static int
11266 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11267 		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11268 		      uint64_t winsz)
11269 {
11270 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11271 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11272 	struct ipsec_test_flags flags;
11273 	uint32_t i = 0, ret = 0;
11274 
11275 	if (nb_pkts == 0)
11276 		return TEST_FAILED;
11277 
11278 	memset(&flags, 0, sizeof(flags));
11279 	flags.antireplay = true;
11280 
11281 	for (i = 0; i < nb_pkts; i++) {
11282 		memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11283 		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11284 		td_outb[i].ipsec_xform.replay_win_sz = winsz;
11285 		td_outb[i].ipsec_xform.options.esn = esn_en;
11286 	}
11287 
11288 	for (i = 0; i < nb_pkts; i++)
11289 		td_outb[i].ipsec_xform.esn.value = esn[i];
11290 
11291 	ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11292 				       &flags);
11293 	if (ret != TEST_SUCCESS)
11294 		return ret;
11295 
11296 	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11297 
11298 	for (i = 0; i < nb_pkts; i++) {
11299 		td_inb[i].ipsec_xform.options.esn = esn_en;
11300 		/* Set antireplay flag for packets to be dropped */
11301 		td_inb[i].ar_packet = replayed_pkt[i];
11302 	}
11303 
11304 	ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11305 				       &flags);
11306 
11307 	return ret;
11308 }
11309 
11310 static int
11311 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11312 {
11313 
11314 	uint32_t nb_pkts = 5;
11315 	bool replayed_pkt[5];
11316 	uint64_t esn[5];
11317 
11318 	/* 1. Advance the TOP of the window to WS * 2 */
11319 	esn[0] = winsz * 2;
11320 	/* 2. Test sequence number within the new window(WS + 1) */
11321 	esn[1] = winsz + 1;
11322 	/* 3. Test sequence number less than the window BOTTOM */
11323 	esn[2] = winsz;
11324 	/* 4. Test sequence number in the middle of the window */
11325 	esn[3] = winsz + (winsz / 2);
11326 	/* 5. Test replay of the packet in the middle of the window */
11327 	esn[4] = winsz + (winsz / 2);
11328 
11329 	replayed_pkt[0] = false;
11330 	replayed_pkt[1] = false;
11331 	replayed_pkt[2] = true;
11332 	replayed_pkt[3] = false;
11333 	replayed_pkt[4] = true;
11334 
11335 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11336 				     false, winsz);
11337 }
11338 
11339 static int
11340 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11341 {
11342 	return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11343 }
11344 
11345 static int
11346 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11347 {
11348 	return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11349 }
11350 
11351 static int
11352 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11353 {
11354 	return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11355 }
11356 
11357 static int
11358 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11359 {
11360 
11361 	uint32_t nb_pkts = 7;
11362 	bool replayed_pkt[7];
11363 	uint64_t esn[7];
11364 
11365 	/* Set the initial sequence number */
11366 	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11367 	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11368 	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11369 	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11370 	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11371 	/* 3. Test with sequence number within window (1<<32 - 1) */
11372 	esn[3] = (uint64_t)((1ULL << 32) - 1);
11373 	/* 4. Test with sequence number within window (1<<32 - 1) */
11374 	esn[4] = (uint64_t)(1ULL << 32);
11375 	/* 5. Test with duplicate sequence number within
11376 	 * new window (1<<32 - 1)
11377 	 */
11378 	esn[5] = (uint64_t)((1ULL << 32) - 1);
11379 	/* 6. Test with duplicate sequence number within new window (1<<32) */
11380 	esn[6] = (uint64_t)(1ULL << 32);
11381 
11382 	replayed_pkt[0] = false;
11383 	replayed_pkt[1] = false;
11384 	replayed_pkt[2] = false;
11385 	replayed_pkt[3] = false;
11386 	replayed_pkt[4] = false;
11387 	replayed_pkt[5] = true;
11388 	replayed_pkt[6] = true;
11389 
11390 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11391 				     true, winsz);
11392 }
11393 
11394 static int
11395 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11396 {
11397 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11398 }
11399 
11400 static int
11401 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11402 {
11403 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11404 }
11405 
11406 static int
11407 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11408 {
11409 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11410 }
11411 
11412 static int
11413 test_PDCP_PROTO_all(void)
11414 {
11415 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11416 	struct crypto_unittest_params *ut_params = &unittest_params;
11417 	struct rte_cryptodev_info dev_info;
11418 	int status;
11419 
11420 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11421 	uint64_t feat_flags = dev_info.feature_flags;
11422 
11423 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11424 		return TEST_SKIPPED;
11425 
11426 	/* Set action type */
11427 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11428 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11429 		gbl_action_type;
11430 
11431 	if (security_proto_supported(ut_params->type,
11432 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
11433 		return TEST_SKIPPED;
11434 
11435 	status = test_PDCP_PROTO_cplane_encap_all();
11436 	status += test_PDCP_PROTO_cplane_decap_all();
11437 	status += test_PDCP_PROTO_uplane_encap_all();
11438 	status += test_PDCP_PROTO_uplane_decap_all();
11439 	status += test_PDCP_PROTO_SGL_in_place_32B();
11440 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
11441 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
11442 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
11443 	status += test_PDCP_SDAP_PROTO_encap_all();
11444 	status += test_PDCP_SDAP_PROTO_decap_all();
11445 	status += test_PDCP_PROTO_short_mac();
11446 
11447 	if (status)
11448 		return TEST_FAILED;
11449 	else
11450 		return TEST_SUCCESS;
11451 }
11452 
11453 static int
11454 test_ipsec_proto_ipv4_ttl_decrement(void)
11455 {
11456 	struct ipsec_test_flags flags = {
11457 		.dec_ttl_or_hop_limit = true
11458 	};
11459 
11460 	return test_ipsec_proto_all(&flags);
11461 }
11462 
11463 static int
11464 test_ipsec_proto_ipv6_hop_limit_decrement(void)
11465 {
11466 	struct ipsec_test_flags flags = {
11467 		.ipv6 = true,
11468 		.dec_ttl_or_hop_limit = true
11469 	};
11470 
11471 	return test_ipsec_proto_all(&flags);
11472 }
11473 
11474 static int
11475 test_docsis_proto_uplink(const void *data)
11476 {
11477 	const struct docsis_test_data *d_td = data;
11478 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11479 	struct crypto_unittest_params *ut_params = &unittest_params;
11480 	uint8_t *plaintext = NULL;
11481 	uint8_t *ciphertext = NULL;
11482 	uint8_t *iv_ptr;
11483 	int32_t cipher_len, crc_len;
11484 	uint32_t crc_data_len;
11485 	int ret = TEST_SUCCESS;
11486 
11487 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11488 
11489 	/* Verify the capabilities */
11490 	struct rte_security_capability_idx sec_cap_idx;
11491 	const struct rte_security_capability *sec_cap;
11492 	const struct rte_cryptodev_capabilities *crypto_cap;
11493 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11494 	int j = 0;
11495 
11496 	/* Set action type */
11497 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11498 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11499 		gbl_action_type;
11500 
11501 	if (security_proto_supported(ut_params->type,
11502 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11503 		return TEST_SKIPPED;
11504 
11505 	sec_cap_idx.action = ut_params->type;
11506 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11507 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11508 
11509 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11510 	if (sec_cap == NULL)
11511 		return TEST_SKIPPED;
11512 
11513 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11514 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11515 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11516 				crypto_cap->sym.xform_type ==
11517 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11518 				crypto_cap->sym.cipher.algo ==
11519 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11520 			sym_cap = &crypto_cap->sym;
11521 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11522 						d_td->key.len,
11523 						d_td->iv.len) == 0)
11524 				break;
11525 		}
11526 	}
11527 
11528 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11529 		return TEST_SKIPPED;
11530 
11531 	/* Setup source mbuf payload */
11532 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11533 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11534 			rte_pktmbuf_tailroom(ut_params->ibuf));
11535 
11536 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11537 			d_td->ciphertext.len);
11538 
11539 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11540 
11541 	/* Setup cipher session parameters */
11542 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11543 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11544 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11545 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11546 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11547 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11548 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11549 	ut_params->cipher_xform.next = NULL;
11550 
11551 	/* Setup DOCSIS session parameters */
11552 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11553 
11554 	struct rte_security_session_conf sess_conf = {
11555 		.action_type = ut_params->type,
11556 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11557 		.docsis = ut_params->docsis_xform,
11558 		.crypto_xform = &ut_params->cipher_xform,
11559 	};
11560 
11561 	/* Create security session */
11562 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11563 					ts_params->session_mpool);
11564 
11565 	if (!ut_params->sec_session) {
11566 		printf("Test function %s line %u: failed to allocate session\n",
11567 			__func__, __LINE__);
11568 		ret = TEST_FAILED;
11569 		goto on_err;
11570 	}
11571 
11572 	/* Generate crypto op data structure */
11573 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11574 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11575 	if (!ut_params->op) {
11576 		printf("Test function %s line %u: failed to allocate symmetric "
11577 			"crypto operation\n", __func__, __LINE__);
11578 		ret = TEST_FAILED;
11579 		goto on_err;
11580 	}
11581 
11582 	/* Setup CRC operation parameters */
11583 	crc_len = d_td->ciphertext.no_crc == false ?
11584 			(d_td->ciphertext.len -
11585 				d_td->ciphertext.crc_offset -
11586 				RTE_ETHER_CRC_LEN) :
11587 			0;
11588 	crc_len = crc_len > 0 ? crc_len : 0;
11589 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11590 	ut_params->op->sym->auth.data.length = crc_len;
11591 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11592 
11593 	/* Setup cipher operation parameters */
11594 	cipher_len = d_td->ciphertext.no_cipher == false ?
11595 			(d_td->ciphertext.len -
11596 				d_td->ciphertext.cipher_offset) :
11597 			0;
11598 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11599 	ut_params->op->sym->cipher.data.length = cipher_len;
11600 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11601 
11602 	/* Setup cipher IV */
11603 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11604 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11605 
11606 	/* Attach session to operation */
11607 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11608 
11609 	/* Set crypto operation mbufs */
11610 	ut_params->op->sym->m_src = ut_params->ibuf;
11611 	ut_params->op->sym->m_dst = NULL;
11612 
11613 	/* Process crypto operation */
11614 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11615 			NULL) {
11616 		printf("Test function %s line %u: failed to process security "
11617 			"crypto op\n", __func__, __LINE__);
11618 		ret = TEST_FAILED;
11619 		goto on_err;
11620 	}
11621 
11622 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11623 		printf("Test function %s line %u: failed to process crypto op\n",
11624 			__func__, __LINE__);
11625 		ret = TEST_FAILED;
11626 		goto on_err;
11627 	}
11628 
11629 	/* Validate plaintext */
11630 	plaintext = ciphertext;
11631 
11632 	if (memcmp(plaintext, d_td->plaintext.data,
11633 			d_td->plaintext.len - crc_data_len)) {
11634 		printf("Test function %s line %u: plaintext not as expected\n",
11635 			__func__, __LINE__);
11636 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
11637 				d_td->plaintext.len);
11638 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11639 		ret = TEST_FAILED;
11640 		goto on_err;
11641 	}
11642 
11643 on_err:
11644 	rte_crypto_op_free(ut_params->op);
11645 	ut_params->op = NULL;
11646 
11647 	if (ut_params->sec_session)
11648 		rte_security_session_destroy(ctx, ut_params->sec_session);
11649 	ut_params->sec_session = NULL;
11650 
11651 	rte_pktmbuf_free(ut_params->ibuf);
11652 	ut_params->ibuf = NULL;
11653 
11654 	return ret;
11655 }
11656 
11657 static int
11658 test_docsis_proto_downlink(const void *data)
11659 {
11660 	const struct docsis_test_data *d_td = data;
11661 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11662 	struct crypto_unittest_params *ut_params = &unittest_params;
11663 	uint8_t *plaintext = NULL;
11664 	uint8_t *ciphertext = NULL;
11665 	uint8_t *iv_ptr;
11666 	int32_t cipher_len, crc_len;
11667 	int ret = TEST_SUCCESS;
11668 
11669 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11670 
11671 	/* Verify the capabilities */
11672 	struct rte_security_capability_idx sec_cap_idx;
11673 	const struct rte_security_capability *sec_cap;
11674 	const struct rte_cryptodev_capabilities *crypto_cap;
11675 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11676 	int j = 0;
11677 
11678 	/* Set action type */
11679 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11680 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11681 		gbl_action_type;
11682 
11683 	if (security_proto_supported(ut_params->type,
11684 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11685 		return TEST_SKIPPED;
11686 
11687 	sec_cap_idx.action = ut_params->type;
11688 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11689 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11690 
11691 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11692 	if (sec_cap == NULL)
11693 		return TEST_SKIPPED;
11694 
11695 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11696 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11697 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11698 				crypto_cap->sym.xform_type ==
11699 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11700 				crypto_cap->sym.cipher.algo ==
11701 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11702 			sym_cap = &crypto_cap->sym;
11703 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11704 						d_td->key.len,
11705 						d_td->iv.len) == 0)
11706 				break;
11707 		}
11708 	}
11709 
11710 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11711 		return TEST_SKIPPED;
11712 
11713 	/* Setup source mbuf payload */
11714 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11715 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11716 			rte_pktmbuf_tailroom(ut_params->ibuf));
11717 
11718 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11719 			d_td->plaintext.len);
11720 
11721 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11722 
11723 	/* Setup cipher session parameters */
11724 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11725 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11726 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11727 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11728 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11729 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11730 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11731 	ut_params->cipher_xform.next = NULL;
11732 
11733 	/* Setup DOCSIS session parameters */
11734 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11735 
11736 	struct rte_security_session_conf sess_conf = {
11737 		.action_type = ut_params->type,
11738 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11739 		.docsis = ut_params->docsis_xform,
11740 		.crypto_xform = &ut_params->cipher_xform,
11741 	};
11742 
11743 	/* Create security session */
11744 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11745 					ts_params->session_mpool);
11746 
11747 	if (!ut_params->sec_session) {
11748 		printf("Test function %s line %u: failed to allocate session\n",
11749 			__func__, __LINE__);
11750 		ret = TEST_FAILED;
11751 		goto on_err;
11752 	}
11753 
11754 	/* Generate crypto op data structure */
11755 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11756 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11757 	if (!ut_params->op) {
11758 		printf("Test function %s line %u: failed to allocate symmetric "
11759 			"crypto operation\n", __func__, __LINE__);
11760 		ret = TEST_FAILED;
11761 		goto on_err;
11762 	}
11763 
11764 	/* Setup CRC operation parameters */
11765 	crc_len = d_td->plaintext.no_crc == false ?
11766 			(d_td->plaintext.len -
11767 				d_td->plaintext.crc_offset -
11768 				RTE_ETHER_CRC_LEN) :
11769 			0;
11770 	crc_len = crc_len > 0 ? crc_len : 0;
11771 	ut_params->op->sym->auth.data.length = crc_len;
11772 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11773 
11774 	/* Setup cipher operation parameters */
11775 	cipher_len = d_td->plaintext.no_cipher == false ?
11776 			(d_td->plaintext.len -
11777 				d_td->plaintext.cipher_offset) :
11778 			0;
11779 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11780 	ut_params->op->sym->cipher.data.length = cipher_len;
11781 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11782 
11783 	/* Setup cipher IV */
11784 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11785 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11786 
11787 	/* Attach session to operation */
11788 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11789 
11790 	/* Set crypto operation mbufs */
11791 	ut_params->op->sym->m_src = ut_params->ibuf;
11792 	ut_params->op->sym->m_dst = NULL;
11793 
11794 	/* Process crypto operation */
11795 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11796 			NULL) {
11797 		printf("Test function %s line %u: failed to process crypto op\n",
11798 			__func__, __LINE__);
11799 		ret = TEST_FAILED;
11800 		goto on_err;
11801 	}
11802 
11803 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11804 		printf("Test function %s line %u: crypto op processing failed\n",
11805 			__func__, __LINE__);
11806 		ret = TEST_FAILED;
11807 		goto on_err;
11808 	}
11809 
11810 	/* Validate ciphertext */
11811 	ciphertext = plaintext;
11812 
11813 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11814 		printf("Test function %s line %u: plaintext not as expected\n",
11815 			__func__, __LINE__);
11816 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11817 				d_td->ciphertext.len);
11818 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11819 		ret = TEST_FAILED;
11820 		goto on_err;
11821 	}
11822 
11823 on_err:
11824 	rte_crypto_op_free(ut_params->op);
11825 	ut_params->op = NULL;
11826 
11827 	if (ut_params->sec_session)
11828 		rte_security_session_destroy(ctx, ut_params->sec_session);
11829 	ut_params->sec_session = NULL;
11830 
11831 	rte_pktmbuf_free(ut_params->ibuf);
11832 	ut_params->ibuf = NULL;
11833 
11834 	return ret;
11835 }
11836 
11837 static void
11838 test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11839 				 struct rte_security_tls_record_xform *tls_record_xform)
11840 {
11841 	unsigned int imp_nonce_len;
11842 	uint8_t *imp_nonce;
11843 
11844 	switch (tls_record_xform->ver) {
11845 	case RTE_SECURITY_VERSION_TLS_1_2:
11846 		imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11847 		imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11848 		break;
11849 	case RTE_SECURITY_VERSION_DTLS_1_2:
11850 		imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11851 		imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11852 		break;
11853 	case RTE_SECURITY_VERSION_TLS_1_3:
11854 		imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11855 		imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11856 		break;
11857 	default:
11858 		return;
11859 	}
11860 
11861 	imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11862 	memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11863 }
11864 
11865 static int
11866 test_tls_record_proto_process(const struct tls_record_test_data td[],
11867 			      struct tls_record_test_data res_d[], int nb_td, bool silent,
11868 			      const struct tls_record_test_flags *flags)
11869 {
11870 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11871 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11872 	struct crypto_unittest_params *ut_params = &unittest_params;
11873 	struct rte_security_tls_record_xform tls_record_xform;
11874 	struct rte_security_capability_idx sec_cap_idx;
11875 	const struct rte_security_capability *sec_cap;
11876 	struct tls_record_test_data *res_d_tmp = NULL;
11877 	enum rte_security_tls_sess_type sess_type;
11878 	uint8_t dev_id = ts_params->valid_devs[0];
11879 	struct rte_security_ctx *ctx;
11880 	int i, ret = TEST_SUCCESS;
11881 
11882 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11883 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11884 
11885 	/* Use first test data to create session */
11886 
11887 	/* Copy TLS record xform */
11888 	memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11889 
11890 	sess_type = tls_record_xform.type;
11891 
11892 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
11893 
11894 	sec_cap_idx.action = ut_params->type;
11895 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11896 	sec_cap_idx.tls_record.type = tls_record_xform.type;
11897 	sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11898 
11899 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11900 	if (sec_cap == NULL)
11901 		return TEST_SKIPPED;
11902 
11903 	/* Copy cipher session parameters */
11904 	if (td[0].aead) {
11905 		memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11906 		ut_params->aead_xform.aead.key.data = td[0].key.data;
11907 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11908 
11909 		/* Verify crypto capabilities */
11910 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11911 			if (!silent)
11912 				RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11913 			return TEST_SKIPPED;
11914 		}
11915 	} else {
11916 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
11917 		       sizeof(ut_params->cipher_xform));
11918 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
11919 		       sizeof(ut_params->auth_xform));
11920 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
11921 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11922 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
11923 
11924 		/* Verify crypto capabilities */
11925 
11926 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
11927 			if (!silent)
11928 				RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
11929 			return TEST_SKIPPED;
11930 		}
11931 
11932 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
11933 			if (!silent)
11934 				RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
11935 			return TEST_SKIPPED;
11936 		}
11937 	}
11938 
11939 	if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
11940 		return TEST_SKIPPED;
11941 
11942 	struct rte_security_session_conf sess_conf = {
11943 		.action_type = ut_params->type,
11944 		.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
11945 	};
11946 
11947 	if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
11948 	    (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
11949 		sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
11950 
11951 	if (td[0].aead)
11952 		test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
11953 
11954 	if (flags->opt_padding)
11955 		tls_record_xform.options.extra_padding_enable = 1;
11956 
11957 	sess_conf.tls_record = tls_record_xform;
11958 
11959 	if (td[0].aead) {
11960 		sess_conf.crypto_xform = &ut_params->aead_xform;
11961 	} else {
11962 		if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
11963 			sess_conf.crypto_xform = &ut_params->cipher_xform;
11964 			ut_params->cipher_xform.next = &ut_params->auth_xform;
11965 		} else {
11966 			sess_conf.crypto_xform = &ut_params->auth_xform;
11967 			ut_params->auth_xform.next = &ut_params->cipher_xform;
11968 		}
11969 	}
11970 
11971 	if (ut_params->sec_session == NULL) {
11972 		/* Create security session */
11973 		ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11974 				ts_params->session_mpool);
11975 	}
11976 
11977 	if (ut_params->sec_session == NULL)
11978 		return TEST_SKIPPED;
11979 
11980 	for (i = 0; i < nb_td; i++) {
11981 		if (flags->ar_win_size &&
11982 			(sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
11983 			sess_conf.tls_record.dtls_1_2.seq_no =
11984 				td[i].tls_record_xform.dtls_1_2.seq_no;
11985 			ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
11986 			if (ret) {
11987 				printf("Could not update sequence number in session\n");
11988 				return TEST_SKIPPED;
11989 			}
11990 		}
11991 
11992 		/* Setup source mbuf payload */
11993 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, td[i].input_text.len,
11994 				nb_segs, 0);
11995 		pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
11996 		if (flags->out_of_place)
11997 			ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
11998 					td[i].output_text.len, nb_segs, 0);
11999 		else
12000 			ut_params->obuf = NULL;
12001 
12002 		/* Generate crypto op data structure */
12003 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12004 						    RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12005 		if (ut_params->op == NULL) {
12006 			printf("Could not allocate crypto op");
12007 			ret = TEST_FAILED;
12008 			goto crypto_op_free;
12009 		}
12010 
12011 		/* Attach session to operation */
12012 		rte_security_attach_session(ut_params->op, ut_params->sec_session);
12013 
12014 		/* Set crypto operation mbufs */
12015 		ut_params->op->sym->m_src = ut_params->ibuf;
12016 		ut_params->op->sym->m_dst = ut_params->obuf;
12017 		ut_params->op->param1.tls_record.content_type = td[i].app_type;
12018 
12019 		if (flags->opt_padding)
12020 			ut_params->op->aux_flags = flags->opt_padding;
12021 
12022 		/* Copy IV in crypto operation when IV generation is disabled */
12023 		if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12024 		    (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12025 		    (tls_record_xform.options.iv_gen_disable == 1)) {
12026 			uint8_t *iv;
12027 			int len;
12028 
12029 			iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12030 			if (td[i].aead)
12031 				len = td[i].xform.aead.aead.iv.length - 4;
12032 			else
12033 				len = td[i].xform.chain.cipher.cipher.iv.length;
12034 			memcpy(iv, td[i].iv.data, len);
12035 		}
12036 
12037 		/* Process crypto operation */
12038 		process_crypto_request(dev_id, ut_params->op);
12039 
12040 		ret = test_tls_record_status_check(ut_params->op, &td[i]);
12041 		if (ret != TEST_SUCCESS)
12042 			goto crypto_op_free;
12043 
12044 		if (res_d != NULL)
12045 			res_d_tmp = &res_d[i];
12046 
12047 		if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12048 			struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12049 						ut_params->ibuf;
12050 
12051 			ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12052 							   silent, flags);
12053 			if (ret != TEST_SUCCESS)
12054 				goto crypto_op_free;
12055 		}
12056 
12057 		rte_crypto_op_free(ut_params->op);
12058 		ut_params->op = NULL;
12059 
12060 		if (flags->out_of_place) {
12061 			rte_pktmbuf_free(ut_params->obuf);
12062 			ut_params->obuf = NULL;
12063 		}
12064 
12065 		rte_pktmbuf_free(ut_params->ibuf);
12066 		ut_params->ibuf = NULL;
12067 	}
12068 
12069 crypto_op_free:
12070 	rte_crypto_op_free(ut_params->op);
12071 	ut_params->op = NULL;
12072 
12073 	if (flags->out_of_place) {
12074 		rte_pktmbuf_free(ut_params->obuf);
12075 		ut_params->obuf = NULL;
12076 	}
12077 
12078 	rte_pktmbuf_free(ut_params->ibuf);
12079 	ut_params->ibuf = NULL;
12080 
12081 	if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12082 		rte_security_session_destroy(ctx, ut_params->sec_session);
12083 		ut_params->sec_session = NULL;
12084 	}
12085 
12086 	RTE_SET_USED(flags);
12087 
12088 	return ret;
12089 }
12090 
12091 static int
12092 test_tls_record_proto_known_vec(const void *test_data)
12093 {
12094 	struct tls_record_test_data td_write;
12095 	struct tls_record_test_flags flags;
12096 
12097 	memset(&flags, 0, sizeof(flags));
12098 
12099 	memcpy(&td_write, test_data, sizeof(td_write));
12100 
12101 	/* Disable IV gen to be able to test with known vectors */
12102 	td_write.tls_record_xform.options.iv_gen_disable = 1;
12103 
12104 	return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12105 }
12106 
12107 static int
12108 test_tls_record_proto_known_vec_read(const void *test_data)
12109 {
12110 	const struct tls_record_test_data *td = test_data;
12111 	struct tls_record_test_flags flags;
12112 	struct tls_record_test_data td_inb;
12113 
12114 	memset(&flags, 0, sizeof(flags));
12115 
12116 	if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12117 		test_tls_record_td_read_from_write(td, &td_inb);
12118 	else
12119 		memcpy(&td_inb, td, sizeof(td_inb));
12120 
12121 	return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12122 }
12123 
12124 static int
12125 test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12126 {
12127 	unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12128 	struct crypto_unittest_params *ut_params = &unittest_params;
12129 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12130 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12131 	void *sec_session_outb = NULL;
12132 	void *sec_session_inb = NULL;
12133 	int ret;
12134 
12135 	switch (flags->tls_version) {
12136 	case RTE_SECURITY_VERSION_TLS_1_2:
12137 		max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12138 		break;
12139 	case RTE_SECURITY_VERSION_TLS_1_3:
12140 		max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12141 		break;
12142 	case RTE_SECURITY_VERSION_DTLS_1_2:
12143 		max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12144 		break;
12145 	default:
12146 		max_payload_len = 0;
12147 	}
12148 
12149 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12150 		payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12151 		if (flags->nb_segs_in_mbuf)
12152 			payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12153 
12154 		if (flags->zero_len)
12155 			payload_len = 0;
12156 again:
12157 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12158 						 flags, td_outb, nb_pkts, payload_len);
12159 		if (ret == TEST_SKIPPED)
12160 			continue;
12161 
12162 		if (flags->skip_sess_destroy)
12163 			ut_params->sec_session = sec_session_outb;
12164 
12165 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12166 		if (ret == TEST_SKIPPED)
12167 			continue;
12168 
12169 		if (flags->skip_sess_destroy && sec_session_outb == NULL)
12170 			sec_session_outb = ut_params->sec_session;
12171 
12172 		if (flags->zero_len &&
12173 		    ((flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12174 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12175 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE))) {
12176 			if (ret == TEST_SUCCESS)
12177 				return TEST_FAILED;
12178 			goto skip_decrypt;
12179 		} else if (ret == TEST_FAILED) {
12180 			return TEST_FAILED;
12181 		}
12182 
12183 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12184 
12185 		if (flags->skip_sess_destroy)
12186 			ut_params->sec_session = sec_session_inb;
12187 
12188 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12189 		if (ret == TEST_SKIPPED)
12190 			continue;
12191 
12192 		if (flags->skip_sess_destroy && sec_session_inb == NULL)
12193 			sec_session_inb = ut_params->sec_session;
12194 
12195 		if (flags->pkt_corruption || flags->padding_corruption) {
12196 			if (ret == TEST_SUCCESS)
12197 				return TEST_FAILED;
12198 		} else {
12199 			if (ret == TEST_FAILED)
12200 				return TEST_FAILED;
12201 		}
12202 
12203 skip_decrypt:
12204 		if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12205 			goto again;
12206 
12207 		if (flags->display_alg)
12208 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12209 
12210 		if (flags->skip_sess_destroy) {
12211 			uint8_t dev_id = testsuite_params.valid_devs[0];
12212 			struct rte_security_ctx *ctx;
12213 
12214 			ctx = rte_cryptodev_get_sec_ctx(dev_id);
12215 			if (sec_session_inb != NULL) {
12216 				rte_security_session_destroy(ctx, sec_session_inb);
12217 				sec_session_inb = NULL;
12218 			}
12219 			if (sec_session_outb != NULL) {
12220 				rte_security_session_destroy(ctx, sec_session_outb);
12221 				sec_session_outb = NULL;
12222 			}
12223 			ut_params->sec_session = NULL;
12224 		}
12225 
12226 		pass_cnt++;
12227 	}
12228 
12229 	if (pass_cnt > 0)
12230 		return TEST_SUCCESS;
12231 	else
12232 		return TEST_SKIPPED;
12233 }
12234 
12235 static int
12236 test_tls_1_2_record_proto_data_walkthrough(void)
12237 {
12238 	struct tls_record_test_flags flags;
12239 
12240 	memset(&flags, 0, sizeof(flags));
12241 
12242 	flags.data_walkthrough = true;
12243 	flags.skip_sess_destroy = true;
12244 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12245 
12246 	return test_tls_record_proto_all(&flags);
12247 }
12248 
12249 static int
12250 test_tls_1_2_record_proto_display_list(void)
12251 {
12252 	struct tls_record_test_flags flags;
12253 
12254 	memset(&flags, 0, sizeof(flags));
12255 
12256 	flags.display_alg = true;
12257 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12258 
12259 	return test_tls_record_proto_all(&flags);
12260 }
12261 
12262 static int
12263 test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12264 {
12265 	struct tls_record_test_flags flags = {
12266 		.nb_segs_in_mbuf = 5,
12267 		.tls_version = tls_version
12268 	};
12269 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12270 	struct rte_cryptodev_info dev_info;
12271 
12272 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12273 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12274 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12275 		return TEST_SKIPPED;
12276 	}
12277 
12278 	return test_tls_record_proto_all(&flags);
12279 }
12280 
12281 static int
12282 test_tls_1_2_record_proto_sgl(void)
12283 {
12284 	return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12285 }
12286 
12287 static int
12288 test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12289 {
12290 	struct tls_record_test_flags flags = {
12291 		.nb_segs_in_mbuf = 5,
12292 		.tls_version = tls_version,
12293 		.skip_sess_destroy = true,
12294 		.data_walkthrough = true
12295 	};
12296 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12297 	struct rte_cryptodev_info dev_info;
12298 
12299 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12300 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12301 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12302 		return TEST_SKIPPED;
12303 	}
12304 
12305 	return test_tls_record_proto_all(&flags);
12306 }
12307 
12308 static int
12309 test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12310 {
12311 	struct tls_record_test_flags flags = {
12312 		.nb_segs_in_mbuf = 5,
12313 		.out_of_place = true,
12314 		.tls_version = tls_version
12315 	};
12316 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12317 	struct rte_cryptodev_info dev_info;
12318 
12319 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12320 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12321 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12322 		return TEST_SKIPPED;
12323 	}
12324 
12325 	return test_tls_record_proto_all(&flags);
12326 }
12327 
12328 static int
12329 test_tls_1_2_record_proto_sgl_oop(void)
12330 {
12331 	return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12332 }
12333 
12334 static int
12335 test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12336 {
12337 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12338 }
12339 
12340 static int
12341 test_tls_record_proto_corrupt_pkt(void)
12342 {
12343 	struct tls_record_test_flags flags = {
12344 		.pkt_corruption = 1
12345 	};
12346 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12347 	struct rte_cryptodev_info dev_info;
12348 
12349 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12350 
12351 	return test_tls_record_proto_all(&flags);
12352 }
12353 
12354 static int
12355 test_tls_record_proto_custom_content_type(void)
12356 {
12357 	struct tls_record_test_flags flags = {
12358 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12359 	};
12360 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12361 	struct rte_cryptodev_info dev_info;
12362 
12363 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12364 
12365 	return test_tls_record_proto_all(&flags);
12366 }
12367 
12368 static int
12369 test_tls_record_proto_zero_len(void)
12370 {
12371 	struct tls_record_test_flags flags = {
12372 		.zero_len = 1
12373 	};
12374 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12375 	struct rte_cryptodev_info dev_info;
12376 
12377 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12378 
12379 	return test_tls_record_proto_all(&flags);
12380 }
12381 
12382 static int
12383 test_tls_record_proto_zero_len_non_app(void)
12384 {
12385 	struct tls_record_test_flags flags = {
12386 		.zero_len = 1,
12387 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12388 	};
12389 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12390 	struct rte_cryptodev_info dev_info;
12391 
12392 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12393 
12394 	return test_tls_record_proto_all(&flags);
12395 }
12396 
12397 static int
12398 test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12399 				  enum rte_security_tls_version tls_version)
12400 {
12401 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12402 	struct rte_cryptodev_info dev_info;
12403 	struct tls_record_test_flags flags = {
12404 		.nb_segs_in_mbuf = num_segs,
12405 		.tls_version = tls_version,
12406 		.opt_padding = padding
12407 	};
12408 
12409 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12410 
12411 	return test_tls_record_proto_all(&flags);
12412 }
12413 
12414 static int
12415 test_tls_record_proto_dm_opt_padding(void)
12416 {
12417 	return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12418 }
12419 
12420 static int
12421 test_tls_record_proto_dm_opt_padding_1(void)
12422 {
12423 	return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12424 }
12425 
12426 static int
12427 test_tls_record_proto_sg_opt_padding(void)
12428 {
12429 	return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12430 }
12431 
12432 static int
12433 test_tls_record_proto_sg_opt_padding_1(void)
12434 {
12435 	return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12436 }
12437 
12438 static int
12439 test_tls_record_proto_sg_opt_padding_2(void)
12440 {
12441 	return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12442 }
12443 
12444 static int
12445 test_tls_record_proto_sg_opt_padding_max(void)
12446 {
12447 	return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12448 }
12449 
12450 static int
12451 test_tls_record_proto_sg_opt_padding_corrupt(void)
12452 {
12453 	struct tls_record_test_flags flags = {
12454 		.opt_padding = 8,
12455 		.padding_corruption = true,
12456 		.nb_segs_in_mbuf = 4,
12457 	};
12458 
12459 	return test_tls_record_proto_all(&flags);
12460 }
12461 
12462 static int
12463 test_dtls_1_2_record_proto_data_walkthrough(void)
12464 {
12465 	struct tls_record_test_flags flags;
12466 
12467 	memset(&flags, 0, sizeof(flags));
12468 
12469 	flags.data_walkthrough = true;
12470 	flags.skip_sess_destroy = true;
12471 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12472 
12473 	return test_tls_record_proto_all(&flags);
12474 }
12475 
12476 static int
12477 test_dtls_1_2_record_proto_display_list(void)
12478 {
12479 	struct tls_record_test_flags flags;
12480 
12481 	memset(&flags, 0, sizeof(flags));
12482 
12483 	flags.display_alg = true;
12484 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12485 
12486 	return test_tls_record_proto_all(&flags);
12487 }
12488 
12489 static int
12490 test_dtls_pkt_replay(const uint64_t seq_no[],
12491 		      bool replayed_pkt[], uint32_t nb_pkts,
12492 		      struct tls_record_test_flags *flags)
12493 {
12494 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12495 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12496 	unsigned int i, idx, pass_cnt = 0;
12497 	int ret;
12498 
12499 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12500 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12501 						 flags, td_outb, nb_pkts, 0);
12502 		if (ret == TEST_SKIPPED)
12503 			continue;
12504 
12505 		for (idx = 0; idx < nb_pkts; idx++)
12506 			td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12507 
12508 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12509 		if (ret == TEST_SKIPPED)
12510 			continue;
12511 
12512 		if (ret == TEST_FAILED)
12513 			return TEST_FAILED;
12514 
12515 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12516 
12517 		for (idx = 0; idx < nb_pkts; idx++) {
12518 			td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12519 			/* Set antireplay flag for packets to be dropped */
12520 			td_inb[idx].ar_packet = replayed_pkt[idx];
12521 		}
12522 
12523 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12524 		if (ret == TEST_SKIPPED)
12525 			continue;
12526 
12527 		if (ret == TEST_FAILED)
12528 			return TEST_FAILED;
12529 
12530 		if (flags->display_alg)
12531 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12532 
12533 		pass_cnt++;
12534 	}
12535 
12536 	if (pass_cnt > 0)
12537 		return TEST_SUCCESS;
12538 	else
12539 		return TEST_SKIPPED;
12540 }
12541 
12542 static int
12543 test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12544 {
12545 	struct tls_record_test_flags flags;
12546 	uint32_t nb_pkts = 5;
12547 	bool replayed_pkt[5];
12548 	uint64_t seq_no[5];
12549 
12550 	memset(&flags, 0, sizeof(flags));
12551 
12552 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12553 	flags.ar_win_size = winsz;
12554 
12555 	/* 1. Advance the TOP of the window to WS * 2 */
12556 	seq_no[0] = winsz * 2;
12557 	/* 2. Test sequence number within the new window(WS + 1) */
12558 	seq_no[1] = winsz + 1;
12559 	/* 3. Test sequence number less than the window BOTTOM */
12560 	seq_no[2] = winsz;
12561 	/* 4. Test sequence number in the middle of the window */
12562 	seq_no[3] = winsz + (winsz / 2);
12563 	/* 5. Test replay of the packet in the middle of the window */
12564 	seq_no[4] = winsz + (winsz / 2);
12565 
12566 	replayed_pkt[0] = false;
12567 	replayed_pkt[1] = false;
12568 	replayed_pkt[2] = true;
12569 	replayed_pkt[3] = false;
12570 	replayed_pkt[4] = true;
12571 
12572 	return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12573 }
12574 
12575 static int
12576 test_dtls_1_2_record_proto_antireplay64(void)
12577 {
12578 	return test_dtls_1_2_record_proto_antireplay(64);
12579 }
12580 
12581 static int
12582 test_dtls_1_2_record_proto_antireplay128(void)
12583 {
12584 	return test_dtls_1_2_record_proto_antireplay(128);
12585 }
12586 
12587 static int
12588 test_dtls_1_2_record_proto_antireplay256(void)
12589 {
12590 	return test_dtls_1_2_record_proto_antireplay(256);
12591 }
12592 
12593 static int
12594 test_dtls_1_2_record_proto_antireplay512(void)
12595 {
12596 	return test_dtls_1_2_record_proto_antireplay(512);
12597 }
12598 
12599 static int
12600 test_dtls_1_2_record_proto_antireplay1024(void)
12601 {
12602 	return test_dtls_1_2_record_proto_antireplay(1024);
12603 }
12604 
12605 static int
12606 test_dtls_1_2_record_proto_antireplay2048(void)
12607 {
12608 	return test_dtls_1_2_record_proto_antireplay(2048);
12609 }
12610 
12611 static int
12612 test_dtls_1_2_record_proto_antireplay4096(void)
12613 {
12614 	return test_dtls_1_2_record_proto_antireplay(4096);
12615 }
12616 
12617 static int
12618 test_dtls_1_2_record_proto_sgl(void)
12619 {
12620 	return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12621 }
12622 
12623 static int
12624 test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12625 {
12626 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12627 }
12628 
12629 static int
12630 test_dtls_1_2_record_proto_sgl_oop(void)
12631 {
12632 	return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12633 }
12634 
12635 static int
12636 test_dtls_1_2_record_proto_corrupt_pkt(void)
12637 {
12638 	struct tls_record_test_flags flags = {
12639 		.pkt_corruption = 1,
12640 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12641 	};
12642 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12643 	struct rte_cryptodev_info dev_info;
12644 
12645 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12646 
12647 	return test_tls_record_proto_all(&flags);
12648 }
12649 
12650 static int
12651 test_dtls_1_2_record_proto_custom_content_type(void)
12652 {
12653 	struct tls_record_test_flags flags = {
12654 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12655 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12656 	};
12657 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12658 	struct rte_cryptodev_info dev_info;
12659 
12660 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12661 
12662 	return test_tls_record_proto_all(&flags);
12663 }
12664 
12665 static int
12666 test_dtls_1_2_record_proto_zero_len(void)
12667 {
12668 	struct tls_record_test_flags flags = {
12669 		.zero_len = 1,
12670 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12671 	};
12672 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12673 	struct rte_cryptodev_info dev_info;
12674 
12675 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12676 
12677 	return test_tls_record_proto_all(&flags);
12678 }
12679 
12680 static int
12681 test_dtls_1_2_record_proto_zero_len_non_app(void)
12682 {
12683 	struct tls_record_test_flags flags = {
12684 		.zero_len = 1,
12685 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12686 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12687 	};
12688 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12689 	struct rte_cryptodev_info dev_info;
12690 
12691 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12692 
12693 	return test_tls_record_proto_all(&flags);
12694 }
12695 
12696 static int
12697 test_dtls_1_2_record_proto_dm_opt_padding(void)
12698 {
12699 	return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12700 }
12701 
12702 static int
12703 test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12704 {
12705 	return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12706 }
12707 
12708 static int
12709 test_dtls_1_2_record_proto_sg_opt_padding(void)
12710 {
12711 	return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12712 }
12713 
12714 static int
12715 test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12716 {
12717 	return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12718 }
12719 
12720 static int
12721 test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12722 {
12723 	return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12724 }
12725 
12726 static int
12727 test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12728 {
12729 	return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12730 }
12731 
12732 static int
12733 test_tls_1_3_record_proto_display_list(void)
12734 {
12735 	struct tls_record_test_flags flags;
12736 
12737 	memset(&flags, 0, sizeof(flags));
12738 
12739 	flags.display_alg = true;
12740 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12741 
12742 	return test_tls_record_proto_all(&flags);
12743 }
12744 
12745 static int
12746 test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12747 {
12748 	struct tls_record_test_flags flags = {
12749 		.opt_padding = 8,
12750 		.padding_corruption = true,
12751 		.nb_segs_in_mbuf = 4,
12752 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12753 	};
12754 
12755 	return test_tls_record_proto_all(&flags);
12756 }
12757 
12758 static int
12759 test_tls_1_3_record_proto_corrupt_pkt(void)
12760 {
12761 	struct tls_record_test_flags flags = {
12762 		.pkt_corruption = 1,
12763 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12764 	};
12765 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12766 	struct rte_cryptodev_info dev_info;
12767 
12768 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12769 
12770 	return test_tls_record_proto_all(&flags);
12771 }
12772 
12773 static int
12774 test_tls_1_3_record_proto_custom_content_type(void)
12775 {
12776 	struct tls_record_test_flags flags = {
12777 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12778 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12779 	};
12780 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12781 	struct rte_cryptodev_info dev_info;
12782 
12783 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12784 
12785 	return test_tls_record_proto_all(&flags);
12786 }
12787 
12788 static int
12789 test_tls_1_3_record_proto_zero_len(void)
12790 {
12791 	struct tls_record_test_flags flags = {
12792 		.zero_len = 1,
12793 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12794 	};
12795 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12796 	struct rte_cryptodev_info dev_info;
12797 
12798 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12799 
12800 	return test_tls_record_proto_all(&flags);
12801 }
12802 
12803 static int
12804 test_tls_1_3_record_proto_zero_len_non_app(void)
12805 {
12806 	struct tls_record_test_flags flags = {
12807 		.zero_len = 1,
12808 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12809 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12810 	};
12811 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12812 	struct rte_cryptodev_info dev_info;
12813 
12814 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12815 
12816 	return test_tls_record_proto_all(&flags);
12817 }
12818 
12819 static int
12820 test_tls_1_3_record_proto_dm_opt_padding(void)
12821 {
12822 	return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12823 }
12824 
12825 static int
12826 test_tls_1_3_record_proto_sg_opt_padding(void)
12827 {
12828 	return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12829 }
12830 
12831 static int
12832 test_tls_1_3_record_proto_sg_opt_padding_1(void)
12833 {
12834 	return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12835 }
12836 
12837 static int
12838 test_tls_1_3_record_proto_data_walkthrough(void)
12839 {
12840 	struct tls_record_test_flags flags;
12841 
12842 	memset(&flags, 0, sizeof(flags));
12843 
12844 	flags.data_walkthrough = true;
12845 	flags.skip_sess_destroy = true;
12846 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12847 
12848 	return test_tls_record_proto_all(&flags);
12849 }
12850 
12851 static int
12852 test_tls_1_3_record_proto_sgl(void)
12853 {
12854 	return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
12855 }
12856 
12857 static int
12858 test_tls_1_3_record_proto_sgl_data_walkthrough(void)
12859 {
12860 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
12861 }
12862 
12863 static int
12864 test_tls_1_3_record_proto_sgl_oop(void)
12865 {
12866 	return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
12867 }
12868 
12869 #endif
12870 
12871 static int
12872 test_AES_GCM_authenticated_encryption_test_case_1(void)
12873 {
12874 	return test_authenticated_encryption(&gcm_test_case_1);
12875 }
12876 
12877 static int
12878 test_AES_GCM_authenticated_encryption_test_case_2(void)
12879 {
12880 	return test_authenticated_encryption(&gcm_test_case_2);
12881 }
12882 
12883 static int
12884 test_AES_GCM_authenticated_encryption_test_case_3(void)
12885 {
12886 	return test_authenticated_encryption(&gcm_test_case_3);
12887 }
12888 
12889 static int
12890 test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
12891 {
12892 	return test_authenticated_encryption_helper(&gcm_test_case_3, true);
12893 }
12894 
12895 static int
12896 test_AES_GCM_authenticated_encryption_test_case_4(void)
12897 {
12898 	return test_authenticated_encryption(&gcm_test_case_4);
12899 }
12900 
12901 static int
12902 test_AES_GCM_authenticated_encryption_test_case_5(void)
12903 {
12904 	return test_authenticated_encryption(&gcm_test_case_5);
12905 }
12906 
12907 static int
12908 test_AES_GCM_authenticated_encryption_test_case_6(void)
12909 {
12910 	return test_authenticated_encryption(&gcm_test_case_6);
12911 }
12912 
12913 static int
12914 test_AES_GCM_authenticated_encryption_test_case_7(void)
12915 {
12916 	return test_authenticated_encryption(&gcm_test_case_7);
12917 }
12918 
12919 static int
12920 test_AES_GCM_authenticated_encryption_test_case_8(void)
12921 {
12922 	return test_authenticated_encryption(&gcm_test_case_8);
12923 }
12924 
12925 static int
12926 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
12927 {
12928 	return test_authenticated_encryption(&gcm_J0_test_case_1);
12929 }
12930 
12931 static int
12932 test_AES_GCM_auth_encryption_test_case_192_1(void)
12933 {
12934 	return test_authenticated_encryption(&gcm_test_case_192_1);
12935 }
12936 
12937 static int
12938 test_AES_GCM_auth_encryption_test_case_192_2(void)
12939 {
12940 	return test_authenticated_encryption(&gcm_test_case_192_2);
12941 }
12942 
12943 static int
12944 test_AES_GCM_auth_encryption_test_case_192_3(void)
12945 {
12946 	return test_authenticated_encryption(&gcm_test_case_192_3);
12947 }
12948 
12949 static int
12950 test_AES_GCM_auth_encryption_test_case_192_4(void)
12951 {
12952 	return test_authenticated_encryption(&gcm_test_case_192_4);
12953 }
12954 
12955 static int
12956 test_AES_GCM_auth_encryption_test_case_192_5(void)
12957 {
12958 	return test_authenticated_encryption(&gcm_test_case_192_5);
12959 }
12960 
12961 static int
12962 test_AES_GCM_auth_encryption_test_case_192_6(void)
12963 {
12964 	return test_authenticated_encryption(&gcm_test_case_192_6);
12965 }
12966 
12967 static int
12968 test_AES_GCM_auth_encryption_test_case_192_7(void)
12969 {
12970 	return test_authenticated_encryption(&gcm_test_case_192_7);
12971 }
12972 
12973 static int
12974 test_AES_GCM_auth_encryption_test_case_256_1(void)
12975 {
12976 	return test_authenticated_encryption(&gcm_test_case_256_1);
12977 }
12978 
12979 static int
12980 test_AES_GCM_auth_encryption_test_case_256_2(void)
12981 {
12982 	return test_authenticated_encryption(&gcm_test_case_256_2);
12983 }
12984 
12985 static int
12986 test_AES_GCM_auth_encryption_test_case_256_3(void)
12987 {
12988 	return test_authenticated_encryption(&gcm_test_case_256_3);
12989 }
12990 
12991 static int
12992 test_AES_GCM_auth_encryption_test_case_256_4(void)
12993 {
12994 	return test_authenticated_encryption(&gcm_test_case_256_4);
12995 }
12996 
12997 static int
12998 test_AES_GCM_auth_encryption_test_case_256_5(void)
12999 {
13000 	return test_authenticated_encryption(&gcm_test_case_256_5);
13001 }
13002 
13003 static int
13004 test_AES_GCM_auth_encryption_test_case_256_6(void)
13005 {
13006 	return test_authenticated_encryption(&gcm_test_case_256_6);
13007 }
13008 
13009 static int
13010 test_AES_GCM_auth_encryption_test_case_256_7(void)
13011 {
13012 	return test_authenticated_encryption(&gcm_test_case_256_7);
13013 }
13014 
13015 static int
13016 test_AES_GCM_auth_encryption_test_case_aad_1(void)
13017 {
13018 	return test_authenticated_encryption(&gcm_test_case_aad_1);
13019 }
13020 
13021 static int
13022 test_AES_GCM_auth_encryption_test_case_aad_2(void)
13023 {
13024 	return test_authenticated_encryption(&gcm_test_case_aad_2);
13025 }
13026 
13027 static int
13028 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13029 {
13030 	struct aead_test_data tdata;
13031 	int res;
13032 
13033 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13034 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13035 	tdata.iv.data[0] += 1;
13036 	res = test_authenticated_encryption(&tdata);
13037 	if (res == TEST_SKIPPED)
13038 		return res;
13039 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13040 	return TEST_SUCCESS;
13041 }
13042 
13043 static int
13044 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13045 {
13046 	struct aead_test_data tdata;
13047 	int res;
13048 
13049 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13050 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13051 	tdata.plaintext.data[0] += 1;
13052 	res = test_authenticated_encryption(&tdata);
13053 	if (res == TEST_SKIPPED)
13054 		return res;
13055 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13056 	return TEST_SUCCESS;
13057 }
13058 
13059 static int
13060 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13061 {
13062 	struct aead_test_data tdata;
13063 	int res;
13064 
13065 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13066 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13067 	tdata.ciphertext.data[0] += 1;
13068 	res = test_authenticated_encryption(&tdata);
13069 	if (res == TEST_SKIPPED)
13070 		return res;
13071 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13072 	return TEST_SUCCESS;
13073 }
13074 
13075 static int
13076 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13077 {
13078 	struct aead_test_data tdata;
13079 	int res;
13080 
13081 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13082 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13083 	tdata.aad.len += 1;
13084 	res = test_authenticated_encryption(&tdata);
13085 	if (res == TEST_SKIPPED)
13086 		return res;
13087 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13088 	return TEST_SUCCESS;
13089 }
13090 
13091 static int
13092 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13093 {
13094 	struct aead_test_data tdata;
13095 	uint8_t aad[gcm_test_case_7.aad.len];
13096 	int res;
13097 
13098 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13099 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13100 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13101 	aad[0] += 1;
13102 	tdata.aad.data = aad;
13103 	res = test_authenticated_encryption(&tdata);
13104 	if (res == TEST_SKIPPED)
13105 		return res;
13106 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13107 	return TEST_SUCCESS;
13108 }
13109 
13110 static int
13111 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13112 {
13113 	struct aead_test_data tdata;
13114 	int res;
13115 
13116 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13117 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13118 	tdata.auth_tag.data[0] += 1;
13119 	res = test_authenticated_encryption(&tdata);
13120 	if (res == TEST_SKIPPED)
13121 		return res;
13122 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13123 	return TEST_SUCCESS;
13124 }
13125 
13126 static int
13127 test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13128 {
13129 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13130 	struct crypto_unittest_params *ut_params = &unittest_params;
13131 
13132 	int retval;
13133 	uint8_t *plaintext;
13134 	uint32_t i;
13135 	struct rte_cryptodev_info dev_info;
13136 
13137 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13138 	uint64_t feat_flags = dev_info.feature_flags;
13139 
13140 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13141 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13142 		printf("Device doesn't support RAW data-path APIs.\n");
13143 		return TEST_SKIPPED;
13144 	}
13145 
13146 	/* Verify the capabilities */
13147 	struct rte_cryptodev_sym_capability_idx cap_idx;
13148 	const struct rte_cryptodev_symmetric_capability *capability;
13149 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13150 	cap_idx.algo.aead = tdata->algo;
13151 	capability = rte_cryptodev_sym_capability_get(
13152 			ts_params->valid_devs[0], &cap_idx);
13153 	if (capability == NULL)
13154 		return TEST_SKIPPED;
13155 	if (rte_cryptodev_sym_capability_check_aead(
13156 			capability, tdata->key.len, tdata->auth_tag.len,
13157 			tdata->aad.len, tdata->iv.len))
13158 		return TEST_SKIPPED;
13159 
13160 	/* Create AEAD session */
13161 	retval = create_aead_session(ts_params->valid_devs[0],
13162 			tdata->algo,
13163 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13164 			tdata->key.data, tdata->key.len,
13165 			tdata->aad.len, tdata->auth_tag.len,
13166 			tdata->iv.len);
13167 	if (retval != TEST_SUCCESS)
13168 		return retval;
13169 
13170 	/* alloc mbuf and set payload */
13171 	if (tdata->aad.len > MBUF_SIZE) {
13172 		if (use_ext_mbuf) {
13173 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13174 							  AEAD_TEXT_MAX_LENGTH,
13175 							  1 /* nb_segs */,
13176 							  NULL);
13177 		} else {
13178 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13179 		}
13180 		/* Populate full size of add data */
13181 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13182 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13183 	} else {
13184 		if (use_ext_mbuf) {
13185 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13186 							  AEAD_TEXT_MAX_LENGTH,
13187 							  1 /* nb_segs */,
13188 							  NULL);
13189 		} else {
13190 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13191 		}
13192 	}
13193 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13194 			rte_pktmbuf_tailroom(ut_params->ibuf));
13195 
13196 	/* Create AEAD operation */
13197 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13198 	if (retval < 0)
13199 		return retval;
13200 
13201 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13202 
13203 	ut_params->op->sym->m_src = ut_params->ibuf;
13204 
13205 	/* Process crypto operation */
13206 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13207 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13208 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13209 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13210 					       0);
13211 		if (retval != TEST_SUCCESS)
13212 			return retval;
13213 	} else
13214 		TEST_ASSERT_NOT_NULL(
13215 			process_crypto_request(ts_params->valid_devs[0],
13216 			ut_params->op), "failed to process sym crypto op");
13217 
13218 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13219 			"crypto op processing failed");
13220 
13221 	if (ut_params->op->sym->m_dst)
13222 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13223 				uint8_t *);
13224 	else
13225 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13226 				uint8_t *,
13227 				ut_params->op->sym->cipher.data.offset);
13228 
13229 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13230 
13231 	/* Validate obuf */
13232 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13233 			plaintext,
13234 			tdata->plaintext.data,
13235 			tdata->plaintext.len,
13236 			"Plaintext data not as expected");
13237 
13238 	TEST_ASSERT_EQUAL(ut_params->op->status,
13239 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13240 			"Authentication failed");
13241 
13242 	return 0;
13243 }
13244 
13245 static int
13246 test_authenticated_decryption(const struct aead_test_data *tdata)
13247 {
13248 	return test_authenticated_decryption_helper(tdata, false);
13249 }
13250 
13251 static int
13252 test_AES_GCM_authenticated_decryption_test_case_1(void)
13253 {
13254 	return test_authenticated_decryption(&gcm_test_case_1);
13255 }
13256 
13257 static int
13258 test_AES_GCM_authenticated_decryption_test_case_2(void)
13259 {
13260 	return test_authenticated_decryption(&gcm_test_case_2);
13261 }
13262 
13263 static int
13264 test_AES_GCM_authenticated_decryption_test_case_3(void)
13265 {
13266 	return test_authenticated_decryption(&gcm_test_case_3);
13267 }
13268 
13269 static int
13270 test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13271 {
13272 	return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13273 }
13274 
13275 static int
13276 test_AES_GCM_authenticated_decryption_test_case_4(void)
13277 {
13278 	return test_authenticated_decryption(&gcm_test_case_4);
13279 }
13280 
13281 static int
13282 test_AES_GCM_authenticated_decryption_test_case_5(void)
13283 {
13284 	return test_authenticated_decryption(&gcm_test_case_5);
13285 }
13286 
13287 static int
13288 test_AES_GCM_authenticated_decryption_test_case_6(void)
13289 {
13290 	return test_authenticated_decryption(&gcm_test_case_6);
13291 }
13292 
13293 static int
13294 test_AES_GCM_authenticated_decryption_test_case_7(void)
13295 {
13296 	return test_authenticated_decryption(&gcm_test_case_7);
13297 }
13298 
13299 static int
13300 test_AES_GCM_authenticated_decryption_test_case_8(void)
13301 {
13302 	return test_authenticated_decryption(&gcm_test_case_8);
13303 }
13304 
13305 static int
13306 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13307 {
13308 	return test_authenticated_decryption(&gcm_J0_test_case_1);
13309 }
13310 
13311 static int
13312 test_AES_GCM_auth_decryption_test_case_192_1(void)
13313 {
13314 	return test_authenticated_decryption(&gcm_test_case_192_1);
13315 }
13316 
13317 static int
13318 test_AES_GCM_auth_decryption_test_case_192_2(void)
13319 {
13320 	return test_authenticated_decryption(&gcm_test_case_192_2);
13321 }
13322 
13323 static int
13324 test_AES_GCM_auth_decryption_test_case_192_3(void)
13325 {
13326 	return test_authenticated_decryption(&gcm_test_case_192_3);
13327 }
13328 
13329 static int
13330 test_AES_GCM_auth_decryption_test_case_192_4(void)
13331 {
13332 	return test_authenticated_decryption(&gcm_test_case_192_4);
13333 }
13334 
13335 static int
13336 test_AES_GCM_auth_decryption_test_case_192_5(void)
13337 {
13338 	return test_authenticated_decryption(&gcm_test_case_192_5);
13339 }
13340 
13341 static int
13342 test_AES_GCM_auth_decryption_test_case_192_6(void)
13343 {
13344 	return test_authenticated_decryption(&gcm_test_case_192_6);
13345 }
13346 
13347 static int
13348 test_AES_GCM_auth_decryption_test_case_192_7(void)
13349 {
13350 	return test_authenticated_decryption(&gcm_test_case_192_7);
13351 }
13352 
13353 static int
13354 test_AES_GCM_auth_decryption_test_case_256_1(void)
13355 {
13356 	return test_authenticated_decryption(&gcm_test_case_256_1);
13357 }
13358 
13359 static int
13360 test_AES_GCM_auth_decryption_test_case_256_2(void)
13361 {
13362 	return test_authenticated_decryption(&gcm_test_case_256_2);
13363 }
13364 
13365 static int
13366 test_AES_GCM_auth_decryption_test_case_256_3(void)
13367 {
13368 	return test_authenticated_decryption(&gcm_test_case_256_3);
13369 }
13370 
13371 static int
13372 test_AES_GCM_auth_decryption_test_case_256_4(void)
13373 {
13374 	return test_authenticated_decryption(&gcm_test_case_256_4);
13375 }
13376 
13377 static int
13378 test_AES_GCM_auth_decryption_test_case_256_5(void)
13379 {
13380 	return test_authenticated_decryption(&gcm_test_case_256_5);
13381 }
13382 
13383 static int
13384 test_AES_GCM_auth_decryption_test_case_256_6(void)
13385 {
13386 	return test_authenticated_decryption(&gcm_test_case_256_6);
13387 }
13388 
13389 static int
13390 test_AES_GCM_auth_decryption_test_case_256_7(void)
13391 {
13392 	return test_authenticated_decryption(&gcm_test_case_256_7);
13393 }
13394 
13395 static int
13396 test_AES_GCM_auth_decryption_test_case_256_8(void)
13397 {
13398 	return test_authenticated_decryption(&gcm_test_case_256_8);
13399 }
13400 
13401 static int
13402 test_AES_GCM_auth_encryption_test_case_256_8(void)
13403 {
13404 	return test_authenticated_encryption(&gcm_test_case_256_8);
13405 }
13406 
13407 static int
13408 test_AES_GCM_auth_decryption_test_case_aad_1(void)
13409 {
13410 	return test_authenticated_decryption(&gcm_test_case_aad_1);
13411 }
13412 
13413 static int
13414 test_AES_GCM_auth_decryption_test_case_aad_2(void)
13415 {
13416 	return test_authenticated_decryption(&gcm_test_case_aad_2);
13417 }
13418 
13419 static int
13420 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13421 {
13422 	struct aead_test_data tdata;
13423 	int res;
13424 
13425 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13426 	tdata.iv.data[0] += 1;
13427 	res = test_authenticated_decryption(&tdata);
13428 	if (res == TEST_SKIPPED)
13429 		return res;
13430 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13431 	return TEST_SUCCESS;
13432 }
13433 
13434 static int
13435 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13436 {
13437 	struct aead_test_data tdata;
13438 	int res;
13439 
13440 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13441 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13442 	tdata.plaintext.data[0] += 1;
13443 	res = test_authenticated_decryption(&tdata);
13444 	if (res == TEST_SKIPPED)
13445 		return res;
13446 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13447 	return TEST_SUCCESS;
13448 }
13449 
13450 static int
13451 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13452 {
13453 	struct aead_test_data tdata;
13454 	int res;
13455 
13456 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13457 	tdata.ciphertext.data[0] += 1;
13458 	res = test_authenticated_decryption(&tdata);
13459 	if (res == TEST_SKIPPED)
13460 		return res;
13461 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13462 	return TEST_SUCCESS;
13463 }
13464 
13465 static int
13466 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13467 {
13468 	struct aead_test_data tdata;
13469 	int res;
13470 
13471 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13472 	tdata.aad.len += 1;
13473 	res = test_authenticated_decryption(&tdata);
13474 	if (res == TEST_SKIPPED)
13475 		return res;
13476 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13477 	return TEST_SUCCESS;
13478 }
13479 
13480 static int
13481 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13482 {
13483 	struct aead_test_data tdata;
13484 	uint8_t aad[gcm_test_case_7.aad.len];
13485 	int res;
13486 
13487 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13488 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13489 	aad[0] += 1;
13490 	tdata.aad.data = aad;
13491 	res = test_authenticated_decryption(&tdata);
13492 	if (res == TEST_SKIPPED)
13493 		return res;
13494 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13495 	return TEST_SUCCESS;
13496 }
13497 
13498 static int
13499 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13500 {
13501 	struct aead_test_data tdata;
13502 	int res;
13503 
13504 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13505 	tdata.auth_tag.data[0] += 1;
13506 	res = test_authenticated_decryption(&tdata);
13507 	if (res == TEST_SKIPPED)
13508 		return res;
13509 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13510 	return TEST_SUCCESS;
13511 }
13512 
13513 static int
13514 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13515 {
13516 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13517 	struct crypto_unittest_params *ut_params = &unittest_params;
13518 
13519 	int retval;
13520 	uint8_t *ciphertext, *auth_tag;
13521 	uint16_t plaintext_pad_len;
13522 	struct rte_cryptodev_info dev_info;
13523 
13524 	/* Verify the capabilities */
13525 	struct rte_cryptodev_sym_capability_idx cap_idx;
13526 	const struct rte_cryptodev_symmetric_capability *capability;
13527 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13528 	cap_idx.algo.aead = tdata->algo;
13529 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13530 	if (capability == NULL)
13531 		return TEST_SKIPPED;
13532 	if (rte_cryptodev_sym_capability_check_aead(
13533 		capability, tdata->key.len, tdata->auth_tag.len,
13534 		tdata->aad.len, tdata->iv.len))
13535 		return TEST_SKIPPED;
13536 
13537 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13538 	uint64_t feat_flags = dev_info.feature_flags;
13539 
13540 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13541 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13542 		return TEST_SKIPPED;
13543 
13544 	/* not supported with CPU crypto */
13545 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13546 		return TEST_SKIPPED;
13547 
13548 	/* Create AEAD session */
13549 	retval = create_aead_session(ts_params->valid_devs[0],
13550 			tdata->algo,
13551 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13552 			tdata->key.data, tdata->key.len,
13553 			tdata->aad.len, tdata->auth_tag.len,
13554 			tdata->iv.len);
13555 	if (retval < 0)
13556 		return retval;
13557 
13558 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13559 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13560 
13561 	/* clear mbuf payload */
13562 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13563 			rte_pktmbuf_tailroom(ut_params->ibuf));
13564 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13565 			rte_pktmbuf_tailroom(ut_params->obuf));
13566 
13567 	/* Create AEAD operation */
13568 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13569 	if (retval < 0)
13570 		return retval;
13571 
13572 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13573 
13574 	ut_params->op->sym->m_src = ut_params->ibuf;
13575 	ut_params->op->sym->m_dst = ut_params->obuf;
13576 
13577 	/* Process crypto operation */
13578 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13579 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13580 					       0);
13581 		if (retval != TEST_SUCCESS)
13582 			return retval;
13583 	} else
13584 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13585 			ut_params->op), "failed to process sym crypto op");
13586 
13587 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13588 			"crypto op processing failed");
13589 
13590 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13591 
13592 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13593 			ut_params->op->sym->cipher.data.offset);
13594 	auth_tag = ciphertext + plaintext_pad_len;
13595 
13596 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13597 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13598 
13599 	/* Validate obuf */
13600 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13601 			ciphertext,
13602 			tdata->ciphertext.data,
13603 			tdata->ciphertext.len,
13604 			"Ciphertext data not as expected");
13605 
13606 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13607 			auth_tag,
13608 			tdata->auth_tag.data,
13609 			tdata->auth_tag.len,
13610 			"Generated auth tag not as expected");
13611 
13612 	return 0;
13613 
13614 }
13615 
13616 static int
13617 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13618 {
13619 	return test_authenticated_encryption_oop(&gcm_test_case_5);
13620 }
13621 
13622 static int
13623 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13624 {
13625 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13626 	struct crypto_unittest_params *ut_params = &unittest_params;
13627 
13628 	int retval;
13629 	uint8_t *plaintext;
13630 	struct rte_cryptodev_info dev_info;
13631 
13632 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13633 	uint64_t feat_flags = dev_info.feature_flags;
13634 
13635 	/* Verify the capabilities */
13636 	struct rte_cryptodev_sym_capability_idx cap_idx;
13637 	const struct rte_cryptodev_symmetric_capability *capability;
13638 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13639 	cap_idx.algo.aead = tdata->algo;
13640 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13641 
13642 	if (capability == NULL)
13643 		return TEST_SKIPPED;
13644 
13645 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13646 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13647 		return TEST_SKIPPED;
13648 
13649 	/* not supported with CPU crypto and raw data-path APIs*/
13650 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13651 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
13652 		return TEST_SKIPPED;
13653 
13654 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13655 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13656 		printf("Device does not support RAW data-path APIs.\n");
13657 		return TEST_SKIPPED;
13658 	}
13659 
13660 	/* Create AEAD session */
13661 	retval = create_aead_session(ts_params->valid_devs[0],
13662 			tdata->algo,
13663 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13664 			tdata->key.data, tdata->key.len,
13665 			tdata->aad.len, tdata->auth_tag.len,
13666 			tdata->iv.len);
13667 	if (retval < 0)
13668 		return retval;
13669 
13670 	/* alloc mbuf and set payload */
13671 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13672 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13673 
13674 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13675 			rte_pktmbuf_tailroom(ut_params->ibuf));
13676 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13677 			rte_pktmbuf_tailroom(ut_params->obuf));
13678 
13679 	/* Create AEAD operation */
13680 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13681 	if (retval < 0)
13682 		return retval;
13683 
13684 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13685 
13686 	ut_params->op->sym->m_src = ut_params->ibuf;
13687 	ut_params->op->sym->m_dst = ut_params->obuf;
13688 
13689 	/* Process crypto operation */
13690 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13691 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13692 					       0);
13693 		if (retval != TEST_SUCCESS)
13694 			return retval;
13695 	} else
13696 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13697 			ut_params->op), "failed to process sym crypto op");
13698 
13699 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13700 			"crypto op processing failed");
13701 
13702 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13703 			ut_params->op->sym->cipher.data.offset);
13704 
13705 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13706 
13707 	/* Validate obuf */
13708 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13709 			plaintext,
13710 			tdata->plaintext.data,
13711 			tdata->plaintext.len,
13712 			"Plaintext data not as expected");
13713 
13714 	TEST_ASSERT_EQUAL(ut_params->op->status,
13715 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13716 			"Authentication failed");
13717 	return 0;
13718 }
13719 
13720 static int
13721 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
13722 {
13723 	return test_authenticated_decryption_oop(&gcm_test_case_5);
13724 }
13725 
13726 static int
13727 test_authenticated_encryption_sessionless(
13728 		const struct aead_test_data *tdata)
13729 {
13730 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13731 	struct crypto_unittest_params *ut_params = &unittest_params;
13732 
13733 	int retval;
13734 	uint8_t *ciphertext, *auth_tag;
13735 	uint16_t plaintext_pad_len;
13736 	uint8_t key[tdata->key.len + 1];
13737 	struct rte_cryptodev_info dev_info;
13738 
13739 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13740 	uint64_t feat_flags = dev_info.feature_flags;
13741 
13742 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13743 		printf("Device doesn't support Sessionless ops.\n");
13744 		return TEST_SKIPPED;
13745 	}
13746 
13747 	/* not supported with CPU crypto */
13748 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13749 		return TEST_SKIPPED;
13750 
13751 	/* Verify the capabilities */
13752 	struct rte_cryptodev_sym_capability_idx cap_idx;
13753 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13754 	cap_idx.algo.aead = tdata->algo;
13755 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13756 			&cap_idx) == NULL)
13757 		return TEST_SKIPPED;
13758 
13759 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13760 
13761 	/* clear mbuf payload */
13762 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13763 			rte_pktmbuf_tailroom(ut_params->ibuf));
13764 
13765 	/* Create AEAD operation */
13766 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13767 	if (retval < 0)
13768 		return retval;
13769 
13770 	/* Create GCM xform */
13771 	memcpy(key, tdata->key.data, tdata->key.len);
13772 	retval = create_aead_xform(ut_params->op,
13773 			tdata->algo,
13774 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13775 			key, tdata->key.len,
13776 			tdata->aad.len, tdata->auth_tag.len,
13777 			tdata->iv.len);
13778 	if (retval < 0)
13779 		return retval;
13780 
13781 	ut_params->op->sym->m_src = ut_params->ibuf;
13782 
13783 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13784 			RTE_CRYPTO_OP_SESSIONLESS,
13785 			"crypto op session type not sessionless");
13786 
13787 	/* Process crypto operation */
13788 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13789 			ut_params->op), "failed to process sym crypto op");
13790 
13791 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13792 
13793 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13794 			"crypto op status not success");
13795 
13796 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13797 
13798 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13799 			ut_params->op->sym->cipher.data.offset);
13800 	auth_tag = ciphertext + plaintext_pad_len;
13801 
13802 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13803 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13804 
13805 	/* Validate obuf */
13806 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13807 			ciphertext,
13808 			tdata->ciphertext.data,
13809 			tdata->ciphertext.len,
13810 			"Ciphertext data not as expected");
13811 
13812 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13813 			auth_tag,
13814 			tdata->auth_tag.data,
13815 			tdata->auth_tag.len,
13816 			"Generated auth tag not as expected");
13817 
13818 	return 0;
13819 
13820 }
13821 
13822 static int
13823 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
13824 {
13825 	return test_authenticated_encryption_sessionless(
13826 			&gcm_test_case_5);
13827 }
13828 
13829 static int
13830 test_authenticated_decryption_sessionless(
13831 		const struct aead_test_data *tdata)
13832 {
13833 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13834 	struct crypto_unittest_params *ut_params = &unittest_params;
13835 
13836 	int retval;
13837 	uint8_t *plaintext;
13838 	uint8_t key[tdata->key.len + 1];
13839 	struct rte_cryptodev_info dev_info;
13840 
13841 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13842 	uint64_t feat_flags = dev_info.feature_flags;
13843 
13844 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13845 		printf("Device doesn't support Sessionless ops.\n");
13846 		return TEST_SKIPPED;
13847 	}
13848 
13849 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13850 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13851 		printf("Device doesn't support RAW data-path APIs.\n");
13852 		return TEST_SKIPPED;
13853 	}
13854 
13855 	/* not supported with CPU crypto */
13856 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13857 		return TEST_SKIPPED;
13858 
13859 	/* Verify the capabilities */
13860 	struct rte_cryptodev_sym_capability_idx cap_idx;
13861 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13862 	cap_idx.algo.aead = tdata->algo;
13863 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13864 			&cap_idx) == NULL)
13865 		return TEST_SKIPPED;
13866 
13867 	/* alloc mbuf and set payload */
13868 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13869 
13870 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13871 			rte_pktmbuf_tailroom(ut_params->ibuf));
13872 
13873 	/* Create AEAD operation */
13874 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13875 	if (retval < 0)
13876 		return retval;
13877 
13878 	/* Create AEAD xform */
13879 	memcpy(key, tdata->key.data, tdata->key.len);
13880 	retval = create_aead_xform(ut_params->op,
13881 			tdata->algo,
13882 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13883 			key, tdata->key.len,
13884 			tdata->aad.len, tdata->auth_tag.len,
13885 			tdata->iv.len);
13886 	if (retval < 0)
13887 		return retval;
13888 
13889 	ut_params->op->sym->m_src = ut_params->ibuf;
13890 
13891 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13892 			RTE_CRYPTO_OP_SESSIONLESS,
13893 			"crypto op session type not sessionless");
13894 
13895 	/* Process crypto operation */
13896 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13897 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13898 					       0);
13899 		if (retval != TEST_SUCCESS)
13900 			return retval;
13901 	} else
13902 		TEST_ASSERT_NOT_NULL(process_crypto_request(
13903 			ts_params->valid_devs[0], ut_params->op),
13904 				"failed to process sym crypto op");
13905 
13906 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13907 
13908 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13909 			"crypto op status not success");
13910 
13911 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13912 			ut_params->op->sym->cipher.data.offset);
13913 
13914 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13915 
13916 	/* Validate obuf */
13917 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13918 			plaintext,
13919 			tdata->plaintext.data,
13920 			tdata->plaintext.len,
13921 			"Plaintext data not as expected");
13922 
13923 	TEST_ASSERT_EQUAL(ut_params->op->status,
13924 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13925 			"Authentication failed");
13926 	return 0;
13927 }
13928 
13929 static int
13930 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
13931 {
13932 	return test_authenticated_decryption_sessionless(
13933 			&gcm_test_case_5);
13934 }
13935 
13936 static int
13937 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
13938 {
13939 	return test_authenticated_encryption(&ccm_test_case_128_1);
13940 }
13941 
13942 static int
13943 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
13944 {
13945 	return test_authenticated_encryption(&ccm_test_case_128_2);
13946 }
13947 
13948 static int
13949 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
13950 {
13951 	return test_authenticated_encryption(&ccm_test_case_128_3);
13952 }
13953 
13954 static int
13955 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
13956 {
13957 	return test_authenticated_decryption(&ccm_test_case_128_1);
13958 }
13959 
13960 static int
13961 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
13962 {
13963 	return test_authenticated_decryption(&ccm_test_case_128_2);
13964 }
13965 
13966 static int
13967 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
13968 {
13969 	return test_authenticated_decryption(&ccm_test_case_128_3);
13970 }
13971 
13972 static int
13973 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
13974 {
13975 	return test_authenticated_encryption(&ccm_test_case_192_1);
13976 }
13977 
13978 static int
13979 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
13980 {
13981 	return test_authenticated_encryption(&ccm_test_case_192_2);
13982 }
13983 
13984 static int
13985 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
13986 {
13987 	return test_authenticated_encryption(&ccm_test_case_192_3);
13988 }
13989 
13990 static int
13991 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
13992 {
13993 	return test_authenticated_decryption(&ccm_test_case_192_1);
13994 }
13995 
13996 static int
13997 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
13998 {
13999 	return test_authenticated_decryption(&ccm_test_case_192_2);
14000 }
14001 
14002 static int
14003 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14004 {
14005 	return test_authenticated_decryption(&ccm_test_case_192_3);
14006 }
14007 
14008 static int
14009 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14010 {
14011 	return test_authenticated_encryption(&ccm_test_case_256_1);
14012 }
14013 
14014 static int
14015 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14016 {
14017 	return test_authenticated_encryption(&ccm_test_case_256_2);
14018 }
14019 
14020 static int
14021 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14022 {
14023 	return test_authenticated_encryption(&ccm_test_case_256_3);
14024 }
14025 
14026 static int
14027 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14028 {
14029 	return test_authenticated_decryption(&ccm_test_case_256_1);
14030 }
14031 
14032 static int
14033 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14034 {
14035 	return test_authenticated_decryption(&ccm_test_case_256_2);
14036 }
14037 
14038 static int
14039 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14040 {
14041 	return test_authenticated_decryption(&ccm_test_case_256_3);
14042 }
14043 
14044 static int
14045 test_stats(void)
14046 {
14047 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14048 	struct rte_cryptodev_stats stats;
14049 
14050 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14051 		return TEST_SKIPPED;
14052 
14053 	/* Verify the capabilities */
14054 	struct rte_cryptodev_sym_capability_idx cap_idx;
14055 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14056 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14057 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14058 			&cap_idx) == NULL)
14059 		return TEST_SKIPPED;
14060 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14061 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14062 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14063 			&cap_idx) == NULL)
14064 		return TEST_SKIPPED;
14065 
14066 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14067 			== -ENOTSUP)
14068 		return TEST_SKIPPED;
14069 
14070 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14071 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14072 			&stats) == -ENODEV),
14073 		"rte_cryptodev_stats_get invalid dev failed");
14074 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14075 		"rte_cryptodev_stats_get invalid Param failed");
14076 
14077 	/* Test expected values */
14078 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
14079 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14080 			&stats),
14081 		"rte_cryptodev_stats_get failed");
14082 	TEST_ASSERT((stats.enqueued_count == 1),
14083 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
14084 	TEST_ASSERT((stats.dequeued_count == 1),
14085 		"rte_cryptodev_stats_get returned unexpected dequeued stat");
14086 	TEST_ASSERT((stats.enqueue_err_count == 0),
14087 		"rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14088 	TEST_ASSERT((stats.dequeue_err_count == 0),
14089 		"rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14090 
14091 	/* invalid device but should ignore and not reset device stats*/
14092 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14093 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14094 			&stats),
14095 		"rte_cryptodev_stats_get failed");
14096 	TEST_ASSERT((stats.enqueued_count == 1),
14097 		"rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14098 
14099 	/* check that a valid reset clears stats */
14100 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14101 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14102 			&stats),
14103 					  "rte_cryptodev_stats_get failed");
14104 	TEST_ASSERT((stats.enqueued_count == 0),
14105 		"rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14106 	TEST_ASSERT((stats.dequeued_count == 0),
14107 		"rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14108 
14109 	return TEST_SUCCESS;
14110 }
14111 
14112 static int
14113 test_device_reconfigure(void)
14114 {
14115 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14116 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14117 	struct rte_cryptodev_qp_conf qp_conf = {
14118 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14119 		.mp_session = ts_params->session_mpool
14120 	};
14121 	uint16_t qp_id, dev_id, num_devs = 0;
14122 
14123 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14124 			"Need at least %d devices for test", 1);
14125 
14126 	dev_id = ts_params->valid_devs[0];
14127 
14128 	/* Stop the device in case it's started so it can be configured */
14129 	rte_cryptodev_stop(dev_id);
14130 
14131 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14132 			"Failed test for rte_cryptodev_configure: "
14133 			"dev_num %u", dev_id);
14134 
14135 	/* Reconfigure with same configure params */
14136 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14137 			"Failed test for rte_cryptodev_configure: "
14138 			"dev_num %u", dev_id);
14139 
14140 	/* Reconfigure with just one queue pair */
14141 	ts_params->conf.nb_queue_pairs = 1;
14142 
14143 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14144 			&ts_params->conf),
14145 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
14146 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14147 
14148 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14149 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14150 				ts_params->valid_devs[0], qp_id, &qp_conf,
14151 				rte_cryptodev_socket_id(
14152 						ts_params->valid_devs[0])),
14153 				"Failed test for "
14154 				"rte_cryptodev_queue_pair_setup: num_inflights "
14155 				"%u on qp %u on cryptodev %u",
14156 				qp_conf.nb_descriptors, qp_id,
14157 				ts_params->valid_devs[0]);
14158 	}
14159 
14160 	/* Reconfigure with max number of queue pairs */
14161 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
14162 
14163 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14164 			&ts_params->conf),
14165 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
14166 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14167 
14168 	qp_conf.mp_session = ts_params->session_mpool;
14169 
14170 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14171 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14172 				ts_params->valid_devs[0], qp_id, &qp_conf,
14173 				rte_cryptodev_socket_id(
14174 						ts_params->valid_devs[0])),
14175 				"Failed test for "
14176 				"rte_cryptodev_queue_pair_setup: num_inflights "
14177 				"%u on qp %u on cryptodev %u",
14178 				qp_conf.nb_descriptors, qp_id,
14179 				ts_params->valid_devs[0]);
14180 	}
14181 
14182 	/* Start the device */
14183 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14184 			"Failed to start cryptodev %u",
14185 			ts_params->valid_devs[0]);
14186 
14187 	/* Test expected values */
14188 	return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14189 }
14190 
14191 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14192 				   struct crypto_unittest_params *ut_params,
14193 				   enum rte_crypto_auth_operation op,
14194 				   const struct HMAC_MD5_vector *test_case)
14195 {
14196 	uint8_t key[64];
14197 
14198 	memcpy(key, test_case->key.data, test_case->key.len);
14199 
14200 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14201 	ut_params->auth_xform.next = NULL;
14202 	ut_params->auth_xform.auth.op = op;
14203 
14204 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14205 
14206 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14207 	ut_params->auth_xform.auth.key.length = test_case->key.len;
14208 	ut_params->auth_xform.auth.key.data = key;
14209 
14210 	ut_params->sess = rte_cryptodev_sym_session_create(
14211 		ts_params->valid_devs[0], &ut_params->auth_xform,
14212 			ts_params->session_mpool);
14213 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14214 		return TEST_SKIPPED;
14215 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14216 
14217 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14218 
14219 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14220 			rte_pktmbuf_tailroom(ut_params->ibuf));
14221 
14222 	return 0;
14223 }
14224 
14225 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14226 			      const struct HMAC_MD5_vector *test_case,
14227 			      uint8_t **plaintext)
14228 {
14229 	uint16_t plaintext_pad_len;
14230 
14231 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14232 
14233 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14234 				16);
14235 
14236 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14237 			plaintext_pad_len);
14238 	memcpy(*plaintext, test_case->plaintext.data,
14239 			test_case->plaintext.len);
14240 
14241 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14242 			ut_params->ibuf, MD5_DIGEST_LEN);
14243 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14244 			"no room to append digest");
14245 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14246 			ut_params->ibuf, plaintext_pad_len);
14247 
14248 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14249 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14250 			   test_case->auth_tag.len);
14251 	}
14252 
14253 	sym_op->auth.data.offset = 0;
14254 	sym_op->auth.data.length = test_case->plaintext.len;
14255 
14256 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14257 	ut_params->op->sym->m_src = ut_params->ibuf;
14258 
14259 	return 0;
14260 }
14261 
14262 static int
14263 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14264 {
14265 	uint16_t plaintext_pad_len;
14266 	uint8_t *plaintext, *auth_tag;
14267 	int ret;
14268 
14269 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14270 	struct crypto_unittest_params *ut_params = &unittest_params;
14271 	struct rte_cryptodev_info dev_info;
14272 
14273 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14274 	uint64_t feat_flags = dev_info.feature_flags;
14275 
14276 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14277 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14278 		printf("Device doesn't support RAW data-path APIs.\n");
14279 		return TEST_SKIPPED;
14280 	}
14281 
14282 	/* Verify the capabilities */
14283 	struct rte_cryptodev_sym_capability_idx cap_idx;
14284 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14285 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14286 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14287 			&cap_idx) == NULL)
14288 		return TEST_SKIPPED;
14289 
14290 	if (MD5_HMAC_create_session(ts_params, ut_params,
14291 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14292 		return TEST_FAILED;
14293 
14294 	/* Generate Crypto op data structure */
14295 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14296 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14297 	TEST_ASSERT_NOT_NULL(ut_params->op,
14298 			"Failed to allocate symmetric crypto operation struct");
14299 
14300 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14301 				16);
14302 
14303 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14304 		return TEST_FAILED;
14305 
14306 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14307 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14308 			ut_params->op);
14309 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14310 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14311 		if (ret != TEST_SUCCESS)
14312 			return ret;
14313 	} else
14314 		TEST_ASSERT_NOT_NULL(
14315 			process_crypto_request(ts_params->valid_devs[0],
14316 				ut_params->op),
14317 				"failed to process sym crypto op");
14318 
14319 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14320 			"crypto op processing failed");
14321 
14322 	if (ut_params->op->sym->m_dst) {
14323 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14324 				uint8_t *, plaintext_pad_len);
14325 	} else {
14326 		auth_tag = plaintext + plaintext_pad_len;
14327 	}
14328 
14329 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14330 			auth_tag,
14331 			test_case->auth_tag.data,
14332 			test_case->auth_tag.len,
14333 			"HMAC_MD5 generated tag not as expected");
14334 
14335 	return TEST_SUCCESS;
14336 }
14337 
14338 static int
14339 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14340 {
14341 	uint8_t *plaintext;
14342 	int ret;
14343 
14344 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14345 	struct crypto_unittest_params *ut_params = &unittest_params;
14346 	struct rte_cryptodev_info dev_info;
14347 
14348 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14349 	uint64_t feat_flags = dev_info.feature_flags;
14350 
14351 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14352 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14353 		printf("Device doesn't support RAW data-path APIs.\n");
14354 		return TEST_SKIPPED;
14355 	}
14356 
14357 	/* Verify the capabilities */
14358 	struct rte_cryptodev_sym_capability_idx cap_idx;
14359 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14360 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14361 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14362 			&cap_idx) == NULL)
14363 		return TEST_SKIPPED;
14364 
14365 	if (MD5_HMAC_create_session(ts_params, ut_params,
14366 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14367 		return TEST_FAILED;
14368 	}
14369 
14370 	/* Generate Crypto op data structure */
14371 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14372 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14373 	TEST_ASSERT_NOT_NULL(ut_params->op,
14374 			"Failed to allocate symmetric crypto operation struct");
14375 
14376 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14377 		return TEST_FAILED;
14378 
14379 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14380 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14381 			ut_params->op);
14382 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14383 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14384 		if (ret != TEST_SUCCESS)
14385 			return ret;
14386 	} else
14387 		TEST_ASSERT_NOT_NULL(
14388 			process_crypto_request(ts_params->valid_devs[0],
14389 				ut_params->op),
14390 				"failed to process sym crypto op");
14391 
14392 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14393 			"HMAC_MD5 crypto op processing failed");
14394 
14395 	return TEST_SUCCESS;
14396 }
14397 
14398 static int
14399 test_MD5_HMAC_generate_case_1(void)
14400 {
14401 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14402 }
14403 
14404 static int
14405 test_MD5_HMAC_verify_case_1(void)
14406 {
14407 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14408 }
14409 
14410 static int
14411 test_MD5_HMAC_generate_case_2(void)
14412 {
14413 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14414 }
14415 
14416 static int
14417 test_MD5_HMAC_verify_case_2(void)
14418 {
14419 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14420 }
14421 
14422 static int
14423 test_multi_session(void)
14424 {
14425 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14426 	struct crypto_unittest_params *ut_params = &unittest_params;
14427 	struct rte_cryptodev_info dev_info;
14428 	int i, nb_sess, ret = TEST_SUCCESS;
14429 	void **sessions;
14430 
14431 	/* Verify the capabilities */
14432 	struct rte_cryptodev_sym_capability_idx cap_idx;
14433 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14434 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14435 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14436 			&cap_idx) == NULL)
14437 		return TEST_SKIPPED;
14438 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14439 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14440 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14441 			&cap_idx) == NULL)
14442 		return TEST_SKIPPED;
14443 
14444 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14445 			aes_cbc_key, hmac_sha512_key);
14446 
14447 
14448 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14449 
14450 	sessions = rte_malloc(NULL,
14451 			sizeof(void *) *
14452 			(MAX_NB_SESSIONS + 1), 0);
14453 
14454 	/* Create multiple crypto sessions*/
14455 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
14456 		sessions[i] = rte_cryptodev_sym_session_create(
14457 			ts_params->valid_devs[0], &ut_params->auth_xform,
14458 				ts_params->session_mpool);
14459 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14460 			nb_sess = i;
14461 			ret = TEST_SKIPPED;
14462 			break;
14463 		}
14464 
14465 		TEST_ASSERT_NOT_NULL(sessions[i],
14466 				"Session creation failed at session number %u",
14467 				i);
14468 
14469 		/* Attempt to send a request on each session */
14470 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14471 			sessions[i],
14472 			ut_params,
14473 			ts_params,
14474 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14475 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14476 			aes_cbc_iv);
14477 
14478 		/* free crypto operation structure */
14479 		rte_crypto_op_free(ut_params->op);
14480 
14481 		/*
14482 		 * free mbuf - both obuf and ibuf are usually the same,
14483 		 * so check if they point at the same address is necessary,
14484 		 * to avoid freeing the mbuf twice.
14485 		 */
14486 		if (ut_params->obuf) {
14487 			rte_pktmbuf_free(ut_params->obuf);
14488 			if (ut_params->ibuf == ut_params->obuf)
14489 				ut_params->ibuf = 0;
14490 			ut_params->obuf = 0;
14491 		}
14492 		if (ut_params->ibuf) {
14493 			rte_pktmbuf_free(ut_params->ibuf);
14494 			ut_params->ibuf = 0;
14495 		}
14496 
14497 		if (ret != TEST_SUCCESS) {
14498 			i++;
14499 			break;
14500 		}
14501 	}
14502 
14503 	nb_sess = i;
14504 
14505 	for (i = 0; i < nb_sess; i++) {
14506 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14507 				sessions[i]);
14508 	}
14509 
14510 	rte_free(sessions);
14511 
14512 	if (ret != TEST_SKIPPED)
14513 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14514 
14515 	return ret;
14516 }
14517 
14518 struct multi_session_params {
14519 	struct crypto_unittest_params ut_params;
14520 	uint8_t *cipher_key;
14521 	uint8_t *hmac_key;
14522 	const uint8_t *cipher;
14523 	const uint8_t *digest;
14524 	uint8_t *iv;
14525 };
14526 
14527 #define MB_SESSION_NUMBER 3
14528 
14529 static int
14530 test_multi_session_random_usage(void)
14531 {
14532 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14533 	struct rte_cryptodev_info dev_info;
14534 	int index = 0, ret = TEST_SUCCESS;
14535 	uint32_t nb_sess, i, j;
14536 	void **sessions;
14537 	struct multi_session_params ut_paramz[] = {
14538 
14539 		{
14540 			.cipher_key = ms_aes_cbc_key0,
14541 			.hmac_key = ms_hmac_key0,
14542 			.cipher = ms_aes_cbc_cipher0,
14543 			.digest = ms_hmac_digest0,
14544 			.iv = ms_aes_cbc_iv0
14545 		},
14546 		{
14547 			.cipher_key = ms_aes_cbc_key1,
14548 			.hmac_key = ms_hmac_key1,
14549 			.cipher = ms_aes_cbc_cipher1,
14550 			.digest = ms_hmac_digest1,
14551 			.iv = ms_aes_cbc_iv1
14552 		},
14553 		{
14554 			.cipher_key = ms_aes_cbc_key2,
14555 			.hmac_key = ms_hmac_key2,
14556 			.cipher = ms_aes_cbc_cipher2,
14557 			.digest = ms_hmac_digest2,
14558 			.iv = ms_aes_cbc_iv2
14559 		},
14560 
14561 	};
14562 
14563 	/* Verify the capabilities */
14564 	struct rte_cryptodev_sym_capability_idx cap_idx;
14565 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14566 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14567 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14568 			&cap_idx) == NULL)
14569 		return TEST_SKIPPED;
14570 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14571 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14572 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14573 			&cap_idx) == NULL)
14574 		return TEST_SKIPPED;
14575 
14576 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14577 
14578 	sessions = rte_malloc(NULL, (sizeof(void *)
14579 					* MAX_NB_SESSIONS) + 1, 0);
14580 
14581 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
14582 
14583 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
14584 				sizeof(struct crypto_unittest_params));
14585 
14586 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14587 				&ut_paramz[i].ut_params,
14588 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14589 
14590 		/* Create multiple crypto sessions*/
14591 		sessions[i] = rte_cryptodev_sym_session_create(
14592 				ts_params->valid_devs[0],
14593 				&ut_paramz[i].ut_params.auth_xform,
14594 				ts_params->session_mpool);
14595 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14596 			nb_sess = i;
14597 			ret = TEST_SKIPPED;
14598 			goto session_clear;
14599 		}
14600 
14601 		TEST_ASSERT_NOT_NULL(sessions[i],
14602 				"Session creation failed at session number %u",
14603 				i);
14604 	}
14605 
14606 	nb_sess = i;
14607 
14608 	srand(time(NULL));
14609 	for (i = 0; i < 40000; i++) {
14610 
14611 		j = rand() % MB_SESSION_NUMBER;
14612 
14613 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14614 					sessions[j],
14615 					&ut_paramz[j].ut_params,
14616 					ts_params, ut_paramz[j].cipher,
14617 					ut_paramz[j].digest,
14618 					ut_paramz[j].iv);
14619 
14620 		rte_crypto_op_free(ut_paramz[j].ut_params.op);
14621 
14622 		/*
14623 		 * free mbuf - both obuf and ibuf are usually the same,
14624 		 * so check if they point at the same address is necessary,
14625 		 * to avoid freeing the mbuf twice.
14626 		 */
14627 		if (ut_paramz[j].ut_params.obuf) {
14628 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14629 			if (ut_paramz[j].ut_params.ibuf
14630 					== ut_paramz[j].ut_params.obuf)
14631 				ut_paramz[j].ut_params.ibuf = 0;
14632 			ut_paramz[j].ut_params.obuf = 0;
14633 		}
14634 		if (ut_paramz[j].ut_params.ibuf) {
14635 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14636 			ut_paramz[j].ut_params.ibuf = 0;
14637 		}
14638 
14639 		if (ret != TEST_SKIPPED) {
14640 			index = i;
14641 			break;
14642 		}
14643 	}
14644 
14645 session_clear:
14646 	for (i = 0; i < nb_sess; i++) {
14647 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14648 				sessions[i]);
14649 	}
14650 
14651 	rte_free(sessions);
14652 
14653 	if (ret != TEST_SKIPPED)
14654 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14655 
14656 	return TEST_SUCCESS;
14657 }
14658 
14659 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14660 			0xab, 0xab, 0xab, 0xab,
14661 			0xab, 0xab, 0xab, 0xab,
14662 			0xab, 0xab, 0xab, 0xab};
14663 
14664 static int
14665 test_null_invalid_operation(void)
14666 {
14667 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14668 	struct crypto_unittest_params *ut_params = &unittest_params;
14669 
14670 	/* This test is for NULL PMD only */
14671 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14672 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14673 		return TEST_SKIPPED;
14674 
14675 	/* Setup Cipher Parameters */
14676 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14677 	ut_params->cipher_xform.next = NULL;
14678 
14679 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14680 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14681 
14682 	/* Create Crypto session*/
14683 	ut_params->sess = rte_cryptodev_sym_session_create(
14684 			ts_params->valid_devs[0], &ut_params->cipher_xform,
14685 			ts_params->session_mpool);
14686 	TEST_ASSERT(ut_params->sess == NULL,
14687 			"Session creation succeeded unexpectedly");
14688 
14689 	/* Setup HMAC Parameters */
14690 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14691 	ut_params->auth_xform.next = NULL;
14692 
14693 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
14694 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14695 
14696 	/* Create Crypto session*/
14697 	ut_params->sess = rte_cryptodev_sym_session_create(
14698 			ts_params->valid_devs[0], &ut_params->auth_xform,
14699 			ts_params->session_mpool);
14700 	TEST_ASSERT(ut_params->sess == NULL,
14701 			"Session creation succeeded unexpectedly");
14702 
14703 	return TEST_SUCCESS;
14704 }
14705 
14706 
14707 #define NULL_BURST_LENGTH (32)
14708 
14709 static int
14710 test_null_burst_operation(void)
14711 {
14712 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14713 	struct crypto_unittest_params *ut_params = &unittest_params;
14714 
14715 	unsigned i, burst_len = NULL_BURST_LENGTH;
14716 
14717 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
14718 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
14719 
14720 	/* This test is for NULL PMD only */
14721 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14722 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14723 		return TEST_SKIPPED;
14724 
14725 	/* Setup Cipher Parameters */
14726 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14727 	ut_params->cipher_xform.next = &ut_params->auth_xform;
14728 
14729 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
14730 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14731 
14732 	/* Setup HMAC Parameters */
14733 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14734 	ut_params->auth_xform.next = NULL;
14735 
14736 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
14737 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14738 
14739 	/* Create Crypto session*/
14740 	ut_params->sess = rte_cryptodev_sym_session_create(
14741 				ts_params->valid_devs[0],
14742 				&ut_params->auth_xform,
14743 				ts_params->session_mpool);
14744 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14745 		return TEST_SKIPPED;
14746 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14747 
14748 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
14749 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
14750 			burst_len, "failed to generate burst of crypto ops");
14751 
14752 	/* Generate an operation for each mbuf in burst */
14753 	for (i = 0; i < burst_len; i++) {
14754 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14755 
14756 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
14757 
14758 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
14759 				sizeof(unsigned));
14760 		*data = i;
14761 
14762 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
14763 
14764 		burst[i]->sym->m_src = m;
14765 	}
14766 
14767 	/* Process crypto operation */
14768 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
14769 			0, burst, burst_len),
14770 			burst_len,
14771 			"Error enqueuing burst");
14772 
14773 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
14774 			0, burst_dequeued, burst_len),
14775 			burst_len,
14776 			"Error dequeuing burst");
14777 
14778 
14779 	for (i = 0; i < burst_len; i++) {
14780 		TEST_ASSERT_EQUAL(
14781 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
14782 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
14783 					uint32_t *),
14784 			"data not as expected");
14785 
14786 		rte_pktmbuf_free(burst[i]->sym->m_src);
14787 		rte_crypto_op_free(burst[i]);
14788 	}
14789 
14790 	return TEST_SUCCESS;
14791 }
14792 
14793 static uint16_t
14794 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14795 		  uint16_t nb_ops, void *user_param)
14796 {
14797 	RTE_SET_USED(dev_id);
14798 	RTE_SET_USED(qp_id);
14799 	RTE_SET_USED(ops);
14800 	RTE_SET_USED(user_param);
14801 
14802 	enq_cb_called = true;
14803 	printf("crypto enqueue callback called\n");
14804 	return nb_ops;
14805 }
14806 
14807 static uint16_t
14808 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14809 		  uint16_t nb_ops, void *user_param)
14810 {
14811 	RTE_SET_USED(dev_id);
14812 	RTE_SET_USED(qp_id);
14813 	RTE_SET_USED(ops);
14814 	RTE_SET_USED(user_param);
14815 
14816 	deq_cb_called = true;
14817 	printf("crypto dequeue callback called\n");
14818 	return nb_ops;
14819 }
14820 
14821 /*
14822  * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
14823  */
14824 static int
14825 test_enqdeq_callback_null_cipher(void)
14826 {
14827 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14828 	struct crypto_unittest_params *ut_params = &unittest_params;
14829 
14830 	/* Setup Cipher Parameters */
14831 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14832 	ut_params->cipher_xform.next = &ut_params->auth_xform;
14833 
14834 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
14835 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14836 
14837 	/* Setup Auth Parameters */
14838 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14839 	ut_params->auth_xform.next = NULL;
14840 
14841 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
14842 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14843 
14844 	/* Create Crypto session */
14845 	ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
14846 				&ut_params->auth_xform, ts_params->session_mpool);
14847 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14848 
14849 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14850 	TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
14851 
14852 	/* Allocate mbuf */
14853 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14854 	TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
14855 
14856 	/* Append some random data */
14857 	TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
14858 			"no room to append data");
14859 
14860 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14861 
14862 	ut_params->op->sym->m_src = ut_params->ibuf;
14863 
14864 	/* Process crypto operation */
14865 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
14866 			"failed to process sym crypto op");
14867 
14868 	return 0;
14869 }
14870 
14871 static int
14872 test_enq_callback_setup(void)
14873 {
14874 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14875 	struct rte_cryptodev_sym_capability_idx cap_idx;
14876 	struct rte_cryptodev_info dev_info;
14877 	struct rte_cryptodev_qp_conf qp_conf = {
14878 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
14879 	};
14880 
14881 	struct rte_cryptodev_cb *cb;
14882 	uint16_t qp_id = 0;
14883 	int j = 0;
14884 
14885 	/* Verify the crypto capabilities for which enqueue/dequeue is done. */
14886 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14887 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
14888 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14889 			&cap_idx) == NULL)
14890 		return TEST_SKIPPED;
14891 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14892 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
14893 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14894 			&cap_idx) == NULL)
14895 		return TEST_SKIPPED;
14896 
14897 	/* Stop the device in case it's started so it can be configured */
14898 	rte_cryptodev_stop(ts_params->valid_devs[0]);
14899 
14900 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14901 
14902 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14903 			&ts_params->conf),
14904 			"Failed to configure cryptodev %u",
14905 			ts_params->valid_devs[0]);
14906 
14907 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14908 	qp_conf.mp_session = ts_params->session_mpool;
14909 
14910 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14911 			ts_params->valid_devs[0], qp_id, &qp_conf,
14912 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14913 			"Failed test for "
14914 			"rte_cryptodev_queue_pair_setup: num_inflights "
14915 			"%u on qp %u on cryptodev %u",
14916 			qp_conf.nb_descriptors, qp_id,
14917 			ts_params->valid_devs[0]);
14918 
14919 	enq_cb_called = false;
14920 	/* Test with invalid crypto device */
14921 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
14922 			qp_id, test_enq_callback, NULL);
14923 	if (rte_errno == ENOTSUP) {
14924 		RTE_LOG(ERR, USER1, "%s line %d: "
14925 			"rte_cryptodev_add_enq_callback() "
14926 			"Not supported, skipped\n", __func__, __LINE__);
14927 		return TEST_SKIPPED;
14928 	}
14929 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14930 			"cryptodev %u did not fail",
14931 			qp_id, RTE_CRYPTO_MAX_DEVS);
14932 
14933 	/* Test with invalid queue pair */
14934 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14935 			dev_info.max_nb_queue_pairs + 1,
14936 			test_enq_callback, NULL);
14937 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14938 			"cryptodev %u did not fail",
14939 			dev_info.max_nb_queue_pairs + 1,
14940 			ts_params->valid_devs[0]);
14941 
14942 	/* Test with NULL callback */
14943 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14944 			qp_id, NULL, NULL);
14945 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14946 			"cryptodev %u did not fail",
14947 			qp_id, ts_params->valid_devs[0]);
14948 
14949 	/* Test with valid configuration */
14950 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14951 			qp_id, test_enq_callback, NULL);
14952 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14953 			"qp %u on cryptodev %u",
14954 			qp_id, ts_params->valid_devs[0]);
14955 
14956 	rte_cryptodev_start(ts_params->valid_devs[0]);
14957 
14958 	TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
14959 
14960 	/* Wait until callback not called. */
14961 	while (!enq_cb_called && (j++ < 10))
14962 		rte_delay_ms(10);
14963 
14964 	/* Test with invalid crypto device */
14965 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14966 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14967 			"Expected call to fail as crypto device is invalid");
14968 
14969 	/* Test with invalid queue pair */
14970 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14971 			ts_params->valid_devs[0],
14972 			dev_info.max_nb_queue_pairs + 1, cb),
14973 			"Expected call to fail as queue pair is invalid");
14974 
14975 	/* Test with NULL callback */
14976 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14977 			ts_params->valid_devs[0], qp_id, NULL),
14978 			"Expected call to fail as callback is NULL");
14979 
14980 	/* Test with valid configuration */
14981 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
14982 			ts_params->valid_devs[0], qp_id, cb),
14983 			"Failed test to remove callback on "
14984 			"qp %u on cryptodev %u",
14985 			qp_id, ts_params->valid_devs[0]);
14986 
14987 	TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
14988 
14989 	return TEST_SUCCESS;
14990 }
14991 
14992 static int
14993 test_deq_callback_setup(void)
14994 {
14995 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14996 	struct rte_cryptodev_sym_capability_idx cap_idx;
14997 	struct rte_cryptodev_info dev_info;
14998 	struct rte_cryptodev_qp_conf qp_conf = {
14999 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
15000 	};
15001 
15002 	struct rte_cryptodev_cb *cb;
15003 	uint16_t qp_id = 0;
15004 	int j = 0;
15005 
15006 	/* Verify the crypto capabilities for which enqueue/dequeue is done. */
15007 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15008 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15009 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15010 			&cap_idx) == NULL)
15011 		return TEST_SKIPPED;
15012 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15013 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15014 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15015 			&cap_idx) == NULL)
15016 		return TEST_SKIPPED;
15017 
15018 	/* Stop the device in case it's started so it can be configured */
15019 	rte_cryptodev_stop(ts_params->valid_devs[0]);
15020 
15021 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15022 
15023 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15024 			&ts_params->conf),
15025 			"Failed to configure cryptodev %u",
15026 			ts_params->valid_devs[0]);
15027 
15028 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15029 	qp_conf.mp_session = ts_params->session_mpool;
15030 
15031 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15032 			ts_params->valid_devs[0], qp_id, &qp_conf,
15033 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15034 			"Failed test for "
15035 			"rte_cryptodev_queue_pair_setup: num_inflights "
15036 			"%u on qp %u on cryptodev %u",
15037 			qp_conf.nb_descriptors, qp_id,
15038 			ts_params->valid_devs[0]);
15039 
15040 	deq_cb_called = false;
15041 	/* Test with invalid crypto device */
15042 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15043 			qp_id, test_deq_callback, NULL);
15044 	if (rte_errno == ENOTSUP) {
15045 		RTE_LOG(ERR, USER1, "%s line %d: "
15046 			"rte_cryptodev_add_deq_callback() "
15047 			"Not supported, skipped\n", __func__, __LINE__);
15048 		return TEST_SKIPPED;
15049 	}
15050 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15051 			"cryptodev %u did not fail",
15052 			qp_id, RTE_CRYPTO_MAX_DEVS);
15053 
15054 	/* Test with invalid queue pair */
15055 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15056 			dev_info.max_nb_queue_pairs + 1,
15057 			test_deq_callback, NULL);
15058 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15059 			"cryptodev %u did not fail",
15060 			dev_info.max_nb_queue_pairs + 1,
15061 			ts_params->valid_devs[0]);
15062 
15063 	/* Test with NULL callback */
15064 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15065 			qp_id, NULL, NULL);
15066 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15067 			"cryptodev %u did not fail",
15068 			qp_id, ts_params->valid_devs[0]);
15069 
15070 	/* Test with valid configuration */
15071 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15072 			qp_id, test_deq_callback, NULL);
15073 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15074 			"qp %u on cryptodev %u",
15075 			qp_id, ts_params->valid_devs[0]);
15076 
15077 	rte_cryptodev_start(ts_params->valid_devs[0]);
15078 
15079 	TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15080 
15081 	/* Wait until callback not called. */
15082 	while (!deq_cb_called && (j++ < 10))
15083 		rte_delay_ms(10);
15084 
15085 	/* Test with invalid crypto device */
15086 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15087 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15088 			"Expected call to fail as crypto device is invalid");
15089 
15090 	/* Test with invalid queue pair */
15091 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15092 			ts_params->valid_devs[0],
15093 			dev_info.max_nb_queue_pairs + 1, cb),
15094 			"Expected call to fail as queue pair is invalid");
15095 
15096 	/* Test with NULL callback */
15097 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15098 			ts_params->valid_devs[0], qp_id, NULL),
15099 			"Expected call to fail as callback is NULL");
15100 
15101 	/* Test with valid configuration */
15102 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15103 			ts_params->valid_devs[0], qp_id, cb),
15104 			"Failed test to remove callback on "
15105 			"qp %u on cryptodev %u",
15106 			qp_id, ts_params->valid_devs[0]);
15107 
15108 	TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15109 
15110 	return TEST_SUCCESS;
15111 }
15112 
15113 static void
15114 generate_gmac_large_plaintext(uint8_t *data)
15115 {
15116 	uint16_t i;
15117 
15118 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15119 		memcpy(&data[i], &data[0], 32);
15120 }
15121 
15122 static int
15123 create_gmac_operation(enum rte_crypto_auth_operation op,
15124 		const struct gmac_test_data *tdata)
15125 {
15126 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15127 	struct crypto_unittest_params *ut_params = &unittest_params;
15128 	struct rte_crypto_sym_op *sym_op;
15129 
15130 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15131 
15132 	/* Generate Crypto op data structure */
15133 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15134 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15135 	TEST_ASSERT_NOT_NULL(ut_params->op,
15136 			"Failed to allocate symmetric crypto operation struct");
15137 
15138 	sym_op = ut_params->op->sym;
15139 
15140 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15141 			ut_params->ibuf, tdata->gmac_tag.len);
15142 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15143 			"no room to append digest");
15144 
15145 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15146 			ut_params->ibuf, plaintext_pad_len);
15147 
15148 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15149 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15150 				tdata->gmac_tag.len);
15151 		debug_hexdump(stdout, "digest:",
15152 				sym_op->auth.digest.data,
15153 				tdata->gmac_tag.len);
15154 	}
15155 
15156 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15157 			uint8_t *, IV_OFFSET);
15158 
15159 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15160 
15161 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15162 
15163 	sym_op->cipher.data.length = 0;
15164 	sym_op->cipher.data.offset = 0;
15165 
15166 	sym_op->auth.data.offset = 0;
15167 	sym_op->auth.data.length = tdata->plaintext.len;
15168 
15169 	return 0;
15170 }
15171 
15172 static int
15173 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15174 		const struct gmac_test_data *tdata,
15175 		void *digest_mem, uint64_t digest_phys)
15176 {
15177 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15178 	struct crypto_unittest_params *ut_params = &unittest_params;
15179 	struct rte_crypto_sym_op *sym_op;
15180 
15181 	/* Generate Crypto op data structure */
15182 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15183 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15184 	TEST_ASSERT_NOT_NULL(ut_params->op,
15185 			"Failed to allocate symmetric crypto operation struct");
15186 
15187 	sym_op = ut_params->op->sym;
15188 
15189 	sym_op->auth.digest.data = digest_mem;
15190 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15191 			"no room to append digest");
15192 
15193 	sym_op->auth.digest.phys_addr = digest_phys;
15194 
15195 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15196 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15197 				tdata->gmac_tag.len);
15198 		debug_hexdump(stdout, "digest:",
15199 				sym_op->auth.digest.data,
15200 				tdata->gmac_tag.len);
15201 	}
15202 
15203 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15204 			uint8_t *, IV_OFFSET);
15205 
15206 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15207 
15208 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15209 
15210 	sym_op->cipher.data.length = 0;
15211 	sym_op->cipher.data.offset = 0;
15212 
15213 	sym_op->auth.data.offset = 0;
15214 	sym_op->auth.data.length = tdata->plaintext.len;
15215 
15216 	return 0;
15217 }
15218 
15219 static int create_gmac_session(uint8_t dev_id,
15220 		const struct gmac_test_data *tdata,
15221 		enum rte_crypto_auth_operation auth_op)
15222 {
15223 	uint8_t auth_key[tdata->key.len];
15224 
15225 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15226 	struct crypto_unittest_params *ut_params = &unittest_params;
15227 
15228 	memcpy(auth_key, tdata->key.data, tdata->key.len);
15229 
15230 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15231 	ut_params->auth_xform.next = NULL;
15232 
15233 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15234 	ut_params->auth_xform.auth.op = auth_op;
15235 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15236 	ut_params->auth_xform.auth.key.length = tdata->key.len;
15237 	ut_params->auth_xform.auth.key.data = auth_key;
15238 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15239 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15240 
15241 
15242 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15243 			&ut_params->auth_xform, ts_params->session_mpool);
15244 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15245 		return TEST_SKIPPED;
15246 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15247 
15248 	return 0;
15249 }
15250 
15251 static int
15252 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15253 {
15254 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15255 	struct crypto_unittest_params *ut_params = &unittest_params;
15256 	struct rte_cryptodev_info dev_info;
15257 
15258 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15259 	uint64_t feat_flags = dev_info.feature_flags;
15260 
15261 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15262 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15263 		printf("Device doesn't support RAW data-path APIs.\n");
15264 		return TEST_SKIPPED;
15265 	}
15266 
15267 	int retval;
15268 
15269 	uint8_t *auth_tag, *plaintext;
15270 	uint16_t plaintext_pad_len;
15271 
15272 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15273 			      "No GMAC length in the source data");
15274 
15275 	/* Verify the capabilities */
15276 	struct rte_cryptodev_sym_capability_idx cap_idx;
15277 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15278 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15279 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15280 			&cap_idx) == NULL)
15281 		return TEST_SKIPPED;
15282 
15283 	retval = create_gmac_session(ts_params->valid_devs[0],
15284 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15285 
15286 	if (retval == TEST_SKIPPED)
15287 		return TEST_SKIPPED;
15288 	if (retval < 0)
15289 		return retval;
15290 
15291 	if (tdata->plaintext.len > MBUF_SIZE)
15292 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15293 	else
15294 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15295 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15296 			"Failed to allocate input buffer in mempool");
15297 
15298 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15299 			rte_pktmbuf_tailroom(ut_params->ibuf));
15300 
15301 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15302 	/*
15303 	 * Runtime generate the large plain text instead of use hard code
15304 	 * plain text vector. It is done to avoid create huge source file
15305 	 * with the test vector.
15306 	 */
15307 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15308 		generate_gmac_large_plaintext(tdata->plaintext.data);
15309 
15310 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15311 				plaintext_pad_len);
15312 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15313 
15314 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15315 	debug_hexdump(stdout, "plaintext:", plaintext,
15316 			tdata->plaintext.len);
15317 
15318 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15319 			tdata);
15320 
15321 	if (retval < 0)
15322 		return retval;
15323 
15324 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15325 
15326 	ut_params->op->sym->m_src = ut_params->ibuf;
15327 
15328 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15329 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15330 			ut_params->op);
15331 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15332 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15333 					       0);
15334 		if (retval != TEST_SUCCESS)
15335 			return retval;
15336 	} else
15337 		TEST_ASSERT_NOT_NULL(
15338 			process_crypto_request(ts_params->valid_devs[0],
15339 			ut_params->op), "failed to process sym crypto op");
15340 
15341 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15342 			"crypto op processing failed");
15343 
15344 	if (ut_params->op->sym->m_dst) {
15345 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15346 				uint8_t *, plaintext_pad_len);
15347 	} else {
15348 		auth_tag = plaintext + plaintext_pad_len;
15349 	}
15350 
15351 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15352 
15353 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15354 			auth_tag,
15355 			tdata->gmac_tag.data,
15356 			tdata->gmac_tag.len,
15357 			"GMAC Generated auth tag not as expected");
15358 
15359 	return 0;
15360 }
15361 
15362 static int
15363 test_AES_GMAC_authentication_test_case_1(void)
15364 {
15365 	return test_AES_GMAC_authentication(&gmac_test_case_1);
15366 }
15367 
15368 static int
15369 test_AES_GMAC_authentication_test_case_2(void)
15370 {
15371 	return test_AES_GMAC_authentication(&gmac_test_case_2);
15372 }
15373 
15374 static int
15375 test_AES_GMAC_authentication_test_case_3(void)
15376 {
15377 	return test_AES_GMAC_authentication(&gmac_test_case_3);
15378 }
15379 
15380 static int
15381 test_AES_GMAC_authentication_test_case_4(void)
15382 {
15383 	return test_AES_GMAC_authentication(&gmac_test_case_4);
15384 }
15385 
15386 static int
15387 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15388 {
15389 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15390 	struct crypto_unittest_params *ut_params = &unittest_params;
15391 	int retval;
15392 	uint32_t plaintext_pad_len;
15393 	uint8_t *plaintext;
15394 	struct rte_cryptodev_info dev_info;
15395 
15396 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15397 	uint64_t feat_flags = dev_info.feature_flags;
15398 
15399 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15400 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15401 		printf("Device doesn't support RAW data-path APIs.\n");
15402 		return TEST_SKIPPED;
15403 	}
15404 
15405 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15406 			      "No GMAC length in the source data");
15407 
15408 	/* Verify the capabilities */
15409 	struct rte_cryptodev_sym_capability_idx cap_idx;
15410 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15411 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15412 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15413 			&cap_idx) == NULL)
15414 		return TEST_SKIPPED;
15415 
15416 	retval = create_gmac_session(ts_params->valid_devs[0],
15417 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15418 
15419 	if (retval == TEST_SKIPPED)
15420 		return TEST_SKIPPED;
15421 	if (retval < 0)
15422 		return retval;
15423 
15424 	if (tdata->plaintext.len > MBUF_SIZE)
15425 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15426 	else
15427 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15428 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15429 			"Failed to allocate input buffer in mempool");
15430 
15431 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15432 			rte_pktmbuf_tailroom(ut_params->ibuf));
15433 
15434 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15435 
15436 	/*
15437 	 * Runtime generate the large plain text instead of use hard code
15438 	 * plain text vector. It is done to avoid create huge source file
15439 	 * with the test vector.
15440 	 */
15441 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15442 		generate_gmac_large_plaintext(tdata->plaintext.data);
15443 
15444 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15445 				plaintext_pad_len);
15446 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15447 
15448 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15449 	debug_hexdump(stdout, "plaintext:", plaintext,
15450 			tdata->plaintext.len);
15451 
15452 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15453 			tdata);
15454 
15455 	if (retval < 0)
15456 		return retval;
15457 
15458 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15459 
15460 	ut_params->op->sym->m_src = ut_params->ibuf;
15461 
15462 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15463 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15464 			ut_params->op);
15465 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15466 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15467 					       0);
15468 		if (retval != TEST_SUCCESS)
15469 			return retval;
15470 	} else
15471 		TEST_ASSERT_NOT_NULL(
15472 			process_crypto_request(ts_params->valid_devs[0],
15473 			ut_params->op), "failed to process sym crypto op");
15474 
15475 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15476 			"crypto op processing failed");
15477 
15478 	return 0;
15479 
15480 }
15481 
15482 static int
15483 test_AES_GMAC_authentication_verify_test_case_1(void)
15484 {
15485 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15486 }
15487 
15488 static int
15489 test_AES_GMAC_authentication_verify_test_case_2(void)
15490 {
15491 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15492 }
15493 
15494 static int
15495 test_AES_GMAC_authentication_verify_test_case_3(void)
15496 {
15497 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15498 }
15499 
15500 static int
15501 test_AES_GMAC_authentication_verify_test_case_4(void)
15502 {
15503 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15504 }
15505 
15506 static int
15507 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15508 				uint32_t fragsz)
15509 {
15510 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15511 	struct crypto_unittest_params *ut_params = &unittest_params;
15512 	struct rte_cryptodev_info dev_info;
15513 	uint64_t feature_flags;
15514 	unsigned int trn_data = 0;
15515 	void *digest_mem = NULL;
15516 	uint32_t segs = 1;
15517 	unsigned int to_trn = 0;
15518 	struct rte_mbuf *buf = NULL;
15519 	uint8_t *auth_tag, *plaintext;
15520 	int retval;
15521 
15522 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15523 			      "No GMAC length in the source data");
15524 
15525 	/* Verify the capabilities */
15526 	struct rte_cryptodev_sym_capability_idx cap_idx;
15527 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15528 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15529 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15530 			&cap_idx) == NULL)
15531 		return TEST_SKIPPED;
15532 
15533 	/* Check for any input SGL support */
15534 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15535 	feature_flags = dev_info.feature_flags;
15536 
15537 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15538 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15539 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15540 		return TEST_SKIPPED;
15541 
15542 	if (fragsz > tdata->plaintext.len)
15543 		fragsz = tdata->plaintext.len;
15544 
15545 	uint16_t plaintext_len = fragsz;
15546 
15547 	retval = create_gmac_session(ts_params->valid_devs[0],
15548 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15549 
15550 	if (retval == TEST_SKIPPED)
15551 		return TEST_SKIPPED;
15552 	if (retval < 0)
15553 		return retval;
15554 
15555 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15556 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15557 			"Failed to allocate input buffer in mempool");
15558 
15559 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15560 			rte_pktmbuf_tailroom(ut_params->ibuf));
15561 
15562 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15563 				plaintext_len);
15564 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15565 
15566 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15567 
15568 	trn_data += plaintext_len;
15569 
15570 	buf = ut_params->ibuf;
15571 
15572 	/*
15573 	 * Loop until no more fragments
15574 	 */
15575 
15576 	while (trn_data < tdata->plaintext.len) {
15577 		++segs;
15578 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15579 				(tdata->plaintext.len - trn_data) : fragsz;
15580 
15581 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15582 		buf = buf->next;
15583 
15584 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15585 				rte_pktmbuf_tailroom(buf));
15586 
15587 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15588 				to_trn);
15589 
15590 		memcpy(plaintext, tdata->plaintext.data + trn_data,
15591 				to_trn);
15592 		trn_data += to_trn;
15593 		if (trn_data  == tdata->plaintext.len)
15594 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15595 					tdata->gmac_tag.len);
15596 	}
15597 	ut_params->ibuf->nb_segs = segs;
15598 
15599 	/*
15600 	 * Place digest at the end of the last buffer
15601 	 */
15602 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15603 
15604 	if (!digest_mem) {
15605 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15606 				+ tdata->gmac_tag.len);
15607 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15608 				tdata->plaintext.len);
15609 	}
15610 
15611 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15612 			tdata, digest_mem, digest_phys);
15613 
15614 	if (retval < 0)
15615 		return retval;
15616 
15617 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15618 
15619 	ut_params->op->sym->m_src = ut_params->ibuf;
15620 
15621 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15622 		return TEST_SKIPPED;
15623 
15624 	TEST_ASSERT_NOT_NULL(
15625 		process_crypto_request(ts_params->valid_devs[0],
15626 		ut_params->op), "failed to process sym crypto op");
15627 
15628 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15629 			"crypto op processing failed");
15630 
15631 	auth_tag = digest_mem;
15632 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15633 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15634 			auth_tag,
15635 			tdata->gmac_tag.data,
15636 			tdata->gmac_tag.len,
15637 			"GMAC Generated auth tag not as expected");
15638 
15639 	return 0;
15640 }
15641 
15642 /* Segment size not multiple of block size (16B) */
15643 static int
15644 test_AES_GMAC_authentication_SGL_40B(void)
15645 {
15646 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15647 }
15648 
15649 static int
15650 test_AES_GMAC_authentication_SGL_80B(void)
15651 {
15652 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15653 }
15654 
15655 static int
15656 test_AES_GMAC_authentication_SGL_2048B(void)
15657 {
15658 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15659 }
15660 
15661 /* Segment size not multiple of block size (16B) */
15662 static int
15663 test_AES_GMAC_authentication_SGL_2047B(void)
15664 {
15665 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15666 }
15667 
15668 struct test_crypto_vector {
15669 	enum rte_crypto_cipher_algorithm crypto_algo;
15670 	unsigned int cipher_offset;
15671 	unsigned int cipher_len;
15672 
15673 	struct {
15674 		uint8_t data[64];
15675 		unsigned int len;
15676 	} cipher_key;
15677 
15678 	struct {
15679 		uint8_t data[64];
15680 		unsigned int len;
15681 	} iv;
15682 
15683 	struct {
15684 		const uint8_t *data;
15685 		unsigned int len;
15686 	} plaintext;
15687 
15688 	struct {
15689 		const uint8_t *data;
15690 		unsigned int len;
15691 	} ciphertext;
15692 
15693 	enum rte_crypto_auth_algorithm auth_algo;
15694 	unsigned int auth_offset;
15695 
15696 	struct {
15697 		uint8_t data[128];
15698 		unsigned int len;
15699 	} auth_key;
15700 
15701 	struct {
15702 		const uint8_t *data;
15703 		unsigned int len;
15704 	} aad;
15705 
15706 	struct {
15707 		uint8_t data[128];
15708 		unsigned int len;
15709 	} digest;
15710 };
15711 
15712 static const struct test_crypto_vector
15713 hmac_sha1_test_crypto_vector = {
15714 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15715 	.plaintext = {
15716 		.data = plaintext_hash,
15717 		.len = 512
15718 	},
15719 	.auth_key = {
15720 		.data = {
15721 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15722 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15723 			0xDE, 0xF4, 0xDE, 0xAD
15724 		},
15725 		.len = 20
15726 	},
15727 	.digest = {
15728 		.data = {
15729 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
15730 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
15731 			0x3F, 0x91, 0x64, 0x59
15732 		},
15733 		.len = 20
15734 	}
15735 };
15736 
15737 static const struct test_crypto_vector
15738 aes128_gmac_test_vector = {
15739 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
15740 	.plaintext = {
15741 		.data = plaintext_hash,
15742 		.len = 512
15743 	},
15744 	.iv = {
15745 		.data = {
15746 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15747 			0x08, 0x09, 0x0A, 0x0B
15748 		},
15749 		.len = 12
15750 	},
15751 	.auth_key = {
15752 		.data = {
15753 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15754 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
15755 		},
15756 		.len = 16
15757 	},
15758 	.digest = {
15759 		.data = {
15760 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
15761 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
15762 		},
15763 		.len = 16
15764 	}
15765 };
15766 
15767 static const struct test_crypto_vector
15768 aes128cbc_hmac_sha1_test_vector = {
15769 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15770 	.cipher_offset = 0,
15771 	.cipher_len = 512,
15772 	.cipher_key = {
15773 		.data = {
15774 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15775 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15776 		},
15777 		.len = 16
15778 	},
15779 	.iv = {
15780 		.data = {
15781 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15782 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15783 		},
15784 		.len = 16
15785 	},
15786 	.plaintext = {
15787 		.data = plaintext_hash,
15788 		.len = 512
15789 	},
15790 	.ciphertext = {
15791 		.data = ciphertext512_aes128cbc,
15792 		.len = 512
15793 	},
15794 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15795 	.auth_offset = 0,
15796 	.auth_key = {
15797 		.data = {
15798 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15799 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15800 			0xDE, 0xF4, 0xDE, 0xAD
15801 		},
15802 		.len = 20
15803 	},
15804 	.digest = {
15805 		.data = {
15806 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
15807 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15808 			0x18, 0x8C, 0x1D, 0x32
15809 		},
15810 		.len = 20
15811 	}
15812 };
15813 
15814 static const struct test_crypto_vector
15815 aes128cbc_hmac_sha1_aad_test_vector = {
15816 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15817 	.cipher_offset = 8,
15818 	.cipher_len = 496,
15819 	.cipher_key = {
15820 		.data = {
15821 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15822 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15823 		},
15824 		.len = 16
15825 	},
15826 	.iv = {
15827 		.data = {
15828 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15829 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15830 		},
15831 		.len = 16
15832 	},
15833 	.plaintext = {
15834 		.data = plaintext_hash,
15835 		.len = 512
15836 	},
15837 	.ciphertext = {
15838 		.data = ciphertext512_aes128cbc_aad,
15839 		.len = 512
15840 	},
15841 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15842 	.auth_offset = 0,
15843 	.auth_key = {
15844 		.data = {
15845 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15846 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15847 			0xDE, 0xF4, 0xDE, 0xAD
15848 		},
15849 		.len = 20
15850 	},
15851 	.digest = {
15852 		.data = {
15853 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
15854 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
15855 			0x62, 0x0F, 0xFB, 0x10
15856 		},
15857 		.len = 20
15858 	}
15859 };
15860 
15861 static void
15862 data_corruption(uint8_t *data)
15863 {
15864 	data[0] += 1;
15865 }
15866 
15867 static void
15868 tag_corruption(uint8_t *data, unsigned int tag_offset)
15869 {
15870 	data[tag_offset] += 1;
15871 }
15872 
15873 static int
15874 create_auth_session(struct crypto_unittest_params *ut_params,
15875 		uint8_t dev_id,
15876 		const struct test_crypto_vector *reference,
15877 		enum rte_crypto_auth_operation auth_op)
15878 {
15879 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15880 	uint8_t auth_key[reference->auth_key.len + 1];
15881 
15882 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15883 
15884 	/* Setup Authentication Parameters */
15885 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15886 	ut_params->auth_xform.auth.op = auth_op;
15887 	ut_params->auth_xform.next = NULL;
15888 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15889 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15890 	ut_params->auth_xform.auth.key.data = auth_key;
15891 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15892 
15893 	/* Create Crypto session*/
15894 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15895 				&ut_params->auth_xform,
15896 				ts_params->session_mpool);
15897 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15898 		return TEST_SKIPPED;
15899 
15900 	return 0;
15901 }
15902 
15903 static int
15904 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
15905 		uint8_t dev_id,
15906 		const struct test_crypto_vector *reference,
15907 		enum rte_crypto_auth_operation auth_op,
15908 		enum rte_crypto_cipher_operation cipher_op)
15909 {
15910 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15911 	uint8_t cipher_key[reference->cipher_key.len + 1];
15912 	uint8_t auth_key[reference->auth_key.len + 1];
15913 
15914 	memcpy(cipher_key, reference->cipher_key.data,
15915 			reference->cipher_key.len);
15916 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15917 
15918 	/* Setup Authentication Parameters */
15919 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15920 	ut_params->auth_xform.auth.op = auth_op;
15921 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15922 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15923 	ut_params->auth_xform.auth.key.data = auth_key;
15924 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15925 
15926 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
15927 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15928 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
15929 	} else {
15930 		ut_params->auth_xform.next = &ut_params->cipher_xform;
15931 
15932 		/* Setup Cipher Parameters */
15933 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15934 		ut_params->cipher_xform.next = NULL;
15935 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15936 		ut_params->cipher_xform.cipher.op = cipher_op;
15937 		ut_params->cipher_xform.cipher.key.data = cipher_key;
15938 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15939 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15940 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15941 	}
15942 
15943 	/* Create Crypto session*/
15944 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15945 				&ut_params->auth_xform,
15946 				ts_params->session_mpool);
15947 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15948 		return TEST_SKIPPED;
15949 
15950 	return 0;
15951 }
15952 
15953 static int
15954 create_auth_operation(struct crypto_testsuite_params *ts_params,
15955 		struct crypto_unittest_params *ut_params,
15956 		const struct test_crypto_vector *reference,
15957 		unsigned int auth_generate)
15958 {
15959 	/* Generate Crypto op data structure */
15960 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15961 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15962 	TEST_ASSERT_NOT_NULL(ut_params->op,
15963 			"Failed to allocate pktmbuf offload");
15964 
15965 	/* Set crypto operation data parameters */
15966 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15967 
15968 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15969 
15970 	/* set crypto operation source mbuf */
15971 	sym_op->m_src = ut_params->ibuf;
15972 
15973 	/* digest */
15974 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15975 			ut_params->ibuf, reference->digest.len);
15976 
15977 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15978 			"no room to append auth tag");
15979 
15980 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15981 			ut_params->ibuf, reference->plaintext.len);
15982 
15983 	if (auth_generate)
15984 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15985 	else
15986 		memcpy(sym_op->auth.digest.data,
15987 				reference->digest.data,
15988 				reference->digest.len);
15989 
15990 	debug_hexdump(stdout, "digest:",
15991 			sym_op->auth.digest.data,
15992 			reference->digest.len);
15993 
15994 	sym_op->auth.data.length = reference->plaintext.len;
15995 	sym_op->auth.data.offset = 0;
15996 
15997 	return 0;
15998 }
15999 
16000 static int
16001 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16002 		struct crypto_unittest_params *ut_params,
16003 		const struct test_crypto_vector *reference,
16004 		unsigned int auth_generate)
16005 {
16006 	/* Generate Crypto op data structure */
16007 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16008 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16009 	TEST_ASSERT_NOT_NULL(ut_params->op,
16010 			"Failed to allocate pktmbuf offload");
16011 
16012 	/* Set crypto operation data parameters */
16013 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16014 
16015 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16016 
16017 	/* set crypto operation source mbuf */
16018 	sym_op->m_src = ut_params->ibuf;
16019 
16020 	/* digest */
16021 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16022 			ut_params->ibuf, reference->digest.len);
16023 
16024 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16025 			"no room to append auth tag");
16026 
16027 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16028 			ut_params->ibuf, reference->ciphertext.len);
16029 
16030 	if (auth_generate)
16031 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
16032 	else
16033 		memcpy(sym_op->auth.digest.data,
16034 				reference->digest.data,
16035 				reference->digest.len);
16036 
16037 	debug_hexdump(stdout, "digest:",
16038 			sym_op->auth.digest.data,
16039 			reference->digest.len);
16040 
16041 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16042 			reference->iv.data, reference->iv.len);
16043 
16044 	sym_op->cipher.data.length = 0;
16045 	sym_op->cipher.data.offset = 0;
16046 
16047 	sym_op->auth.data.length = reference->plaintext.len;
16048 	sym_op->auth.data.offset = 0;
16049 
16050 	return 0;
16051 }
16052 
16053 static int
16054 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16055 		struct crypto_unittest_params *ut_params,
16056 		const struct test_crypto_vector *reference,
16057 		unsigned int auth_generate)
16058 {
16059 	/* Generate Crypto op data structure */
16060 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16061 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16062 	TEST_ASSERT_NOT_NULL(ut_params->op,
16063 			"Failed to allocate pktmbuf offload");
16064 
16065 	/* Set crypto operation data parameters */
16066 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16067 
16068 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16069 
16070 	/* set crypto operation source mbuf */
16071 	sym_op->m_src = ut_params->ibuf;
16072 
16073 	/* digest */
16074 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16075 			ut_params->ibuf, reference->digest.len);
16076 
16077 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16078 			"no room to append auth tag");
16079 
16080 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16081 			ut_params->ibuf, reference->ciphertext.len);
16082 
16083 	if (auth_generate)
16084 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
16085 	else
16086 		memcpy(sym_op->auth.digest.data,
16087 				reference->digest.data,
16088 				reference->digest.len);
16089 
16090 	debug_hexdump(stdout, "digest:",
16091 			sym_op->auth.digest.data,
16092 			reference->digest.len);
16093 
16094 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16095 			reference->iv.data, reference->iv.len);
16096 
16097 	sym_op->cipher.data.length = reference->cipher_len;
16098 	sym_op->cipher.data.offset = reference->cipher_offset;
16099 
16100 	sym_op->auth.data.length = reference->plaintext.len;
16101 	sym_op->auth.data.offset = reference->auth_offset;
16102 
16103 	return 0;
16104 }
16105 
16106 static int
16107 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16108 		struct crypto_unittest_params *ut_params,
16109 		const struct test_crypto_vector *reference)
16110 {
16111 	return create_auth_operation(ts_params, ut_params, reference, 0);
16112 }
16113 
16114 static int
16115 create_auth_verify_GMAC_operation(
16116 		struct crypto_testsuite_params *ts_params,
16117 		struct crypto_unittest_params *ut_params,
16118 		const struct test_crypto_vector *reference)
16119 {
16120 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16121 }
16122 
16123 static int
16124 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16125 		struct crypto_unittest_params *ut_params,
16126 		const struct test_crypto_vector *reference)
16127 {
16128 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16129 }
16130 
16131 static int
16132 test_authentication_verify_fail_when_data_corruption(
16133 		struct crypto_testsuite_params *ts_params,
16134 		struct crypto_unittest_params *ut_params,
16135 		const struct test_crypto_vector *reference,
16136 		unsigned int data_corrupted)
16137 {
16138 	int retval;
16139 
16140 	uint8_t *plaintext;
16141 	struct rte_cryptodev_info dev_info;
16142 
16143 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16144 	uint64_t feat_flags = dev_info.feature_flags;
16145 
16146 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16147 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16148 		printf("Device doesn't support RAW data-path APIs.\n");
16149 		return TEST_SKIPPED;
16150 	}
16151 
16152 	/* Verify the capabilities */
16153 	struct rte_cryptodev_sym_capability_idx cap_idx;
16154 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16155 	cap_idx.algo.auth = reference->auth_algo;
16156 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16157 			&cap_idx) == NULL)
16158 		return TEST_SKIPPED;
16159 
16160 
16161 	/* Create session */
16162 	retval = create_auth_session(ut_params,
16163 			ts_params->valid_devs[0],
16164 			reference,
16165 			RTE_CRYPTO_AUTH_OP_VERIFY);
16166 
16167 	if (retval == TEST_SKIPPED)
16168 		return TEST_SKIPPED;
16169 	if (retval < 0)
16170 		return retval;
16171 
16172 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16173 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16174 			"Failed to allocate input buffer in mempool");
16175 
16176 	/* clear mbuf payload */
16177 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16178 			rte_pktmbuf_tailroom(ut_params->ibuf));
16179 
16180 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16181 			reference->plaintext.len);
16182 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16183 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16184 
16185 	debug_hexdump(stdout, "plaintext:", plaintext,
16186 		reference->plaintext.len);
16187 
16188 	/* Create operation */
16189 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
16190 
16191 	if (retval < 0)
16192 		return retval;
16193 
16194 	if (data_corrupted)
16195 		data_corruption(plaintext);
16196 	else
16197 		tag_corruption(plaintext, reference->plaintext.len);
16198 
16199 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16200 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16201 			ut_params->op);
16202 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16203 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16204 			"authentication not failed");
16205 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16206 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16207 					       0);
16208 		if (retval != TEST_SUCCESS)
16209 			return retval;
16210 	} else {
16211 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16212 			ut_params->op);
16213 	}
16214 	if (ut_params->op == NULL)
16215 		return 0;
16216 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16217 		return 0;
16218 
16219 	return -1;
16220 }
16221 
16222 static int
16223 test_authentication_verify_GMAC_fail_when_corruption(
16224 		struct crypto_testsuite_params *ts_params,
16225 		struct crypto_unittest_params *ut_params,
16226 		const struct test_crypto_vector *reference,
16227 		unsigned int data_corrupted)
16228 {
16229 	int retval;
16230 	uint8_t *plaintext;
16231 	struct rte_cryptodev_info dev_info;
16232 
16233 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16234 	uint64_t feat_flags = dev_info.feature_flags;
16235 
16236 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16237 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16238 		printf("Device doesn't support RAW data-path APIs.\n");
16239 		return TEST_SKIPPED;
16240 	}
16241 
16242 	/* Verify the capabilities */
16243 	struct rte_cryptodev_sym_capability_idx cap_idx;
16244 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16245 	cap_idx.algo.auth = reference->auth_algo;
16246 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16247 			&cap_idx) == NULL)
16248 		return TEST_SKIPPED;
16249 
16250 	/* Create session */
16251 	retval = create_auth_cipher_session(ut_params,
16252 			ts_params->valid_devs[0],
16253 			reference,
16254 			RTE_CRYPTO_AUTH_OP_VERIFY,
16255 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
16256 	if (retval == TEST_SKIPPED)
16257 		return TEST_SKIPPED;
16258 	if (retval < 0)
16259 		return retval;
16260 
16261 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16262 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16263 			"Failed to allocate input buffer in mempool");
16264 
16265 	/* clear mbuf payload */
16266 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16267 			rte_pktmbuf_tailroom(ut_params->ibuf));
16268 
16269 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16270 			reference->plaintext.len);
16271 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16272 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16273 
16274 	debug_hexdump(stdout, "plaintext:", plaintext,
16275 		reference->plaintext.len);
16276 
16277 	/* Create operation */
16278 	retval = create_auth_verify_GMAC_operation(ts_params,
16279 			ut_params,
16280 			reference);
16281 
16282 	if (retval < 0)
16283 		return retval;
16284 
16285 	if (data_corrupted)
16286 		data_corruption(plaintext);
16287 	else
16288 		tag_corruption(plaintext, reference->aad.len);
16289 
16290 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16291 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16292 			ut_params->op);
16293 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16294 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16295 			"authentication not failed");
16296 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16297 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16298 					       0);
16299 		if (retval != TEST_SUCCESS)
16300 			return retval;
16301 	} else {
16302 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16303 			ut_params->op);
16304 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16305 	}
16306 
16307 	return 0;
16308 }
16309 
16310 static int
16311 test_authenticated_decryption_fail_when_corruption(
16312 		struct crypto_testsuite_params *ts_params,
16313 		struct crypto_unittest_params *ut_params,
16314 		const struct test_crypto_vector *reference,
16315 		unsigned int data_corrupted)
16316 {
16317 	int retval;
16318 
16319 	uint8_t *ciphertext;
16320 	struct rte_cryptodev_info dev_info;
16321 
16322 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16323 	uint64_t feat_flags = dev_info.feature_flags;
16324 
16325 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16326 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16327 		printf("Device doesn't support RAW data-path APIs.\n");
16328 		return TEST_SKIPPED;
16329 	}
16330 
16331 	/* Verify the capabilities */
16332 	struct rte_cryptodev_sym_capability_idx cap_idx;
16333 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16334 	cap_idx.algo.auth = reference->auth_algo;
16335 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16336 			&cap_idx) == NULL)
16337 		return TEST_SKIPPED;
16338 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16339 	cap_idx.algo.cipher = reference->crypto_algo;
16340 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16341 			&cap_idx) == NULL)
16342 		return TEST_SKIPPED;
16343 
16344 	/* Create session */
16345 	retval = create_auth_cipher_session(ut_params,
16346 			ts_params->valid_devs[0],
16347 			reference,
16348 			RTE_CRYPTO_AUTH_OP_VERIFY,
16349 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
16350 	if (retval == TEST_SKIPPED)
16351 		return TEST_SKIPPED;
16352 	if (retval < 0)
16353 		return retval;
16354 
16355 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16356 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16357 			"Failed to allocate input buffer in mempool");
16358 
16359 	/* clear mbuf payload */
16360 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16361 			rte_pktmbuf_tailroom(ut_params->ibuf));
16362 
16363 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16364 			reference->ciphertext.len);
16365 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16366 	memcpy(ciphertext, reference->ciphertext.data,
16367 			reference->ciphertext.len);
16368 
16369 	/* Create operation */
16370 	retval = create_cipher_auth_verify_operation(ts_params,
16371 			ut_params,
16372 			reference);
16373 
16374 	if (retval < 0)
16375 		return retval;
16376 
16377 	if (data_corrupted)
16378 		data_corruption(ciphertext);
16379 	else
16380 		tag_corruption(ciphertext, reference->ciphertext.len);
16381 
16382 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16383 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16384 			ut_params->op);
16385 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16386 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16387 			"authentication not failed");
16388 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16389 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16390 					       0);
16391 		if (retval != TEST_SUCCESS)
16392 			return retval;
16393 	} else {
16394 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16395 			ut_params->op);
16396 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16397 	}
16398 
16399 	return 0;
16400 }
16401 
16402 static int
16403 test_authenticated_encrypt_with_esn(
16404 		struct crypto_testsuite_params *ts_params,
16405 		struct crypto_unittest_params *ut_params,
16406 		const struct test_crypto_vector *reference)
16407 {
16408 	int retval;
16409 
16410 	uint8_t *authciphertext, *plaintext, *auth_tag;
16411 	uint16_t plaintext_pad_len;
16412 	uint8_t cipher_key[reference->cipher_key.len + 1];
16413 	uint8_t auth_key[reference->auth_key.len + 1];
16414 	struct rte_cryptodev_info dev_info;
16415 
16416 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16417 	uint64_t feat_flags = dev_info.feature_flags;
16418 
16419 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16420 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16421 		printf("Device doesn't support RAW data-path APIs.\n");
16422 		return TEST_SKIPPED;
16423 	}
16424 
16425 	/* Verify the capabilities */
16426 	struct rte_cryptodev_sym_capability_idx cap_idx;
16427 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16428 	cap_idx.algo.auth = reference->auth_algo;
16429 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16430 			&cap_idx) == NULL)
16431 		return TEST_SKIPPED;
16432 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16433 	cap_idx.algo.cipher = reference->crypto_algo;
16434 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16435 			&cap_idx) == NULL)
16436 		return TEST_SKIPPED;
16437 
16438 	/* Create session */
16439 	memcpy(cipher_key, reference->cipher_key.data,
16440 			reference->cipher_key.len);
16441 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16442 
16443 	/* Setup Cipher Parameters */
16444 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16445 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16446 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16447 	ut_params->cipher_xform.cipher.key.data = cipher_key;
16448 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16449 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16450 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16451 
16452 	ut_params->cipher_xform.next = &ut_params->auth_xform;
16453 
16454 	/* Setup Authentication Parameters */
16455 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16456 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16457 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16458 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16459 	ut_params->auth_xform.auth.key.data = auth_key;
16460 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16461 	ut_params->auth_xform.next = NULL;
16462 
16463 	/* Create Crypto session*/
16464 	ut_params->sess = rte_cryptodev_sym_session_create(
16465 			ts_params->valid_devs[0], &ut_params->cipher_xform,
16466 			ts_params->session_mpool);
16467 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16468 		return TEST_SKIPPED;
16469 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16470 
16471 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16472 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16473 			"Failed to allocate input buffer in mempool");
16474 
16475 	/* clear mbuf payload */
16476 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16477 			rte_pktmbuf_tailroom(ut_params->ibuf));
16478 
16479 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16480 			reference->plaintext.len);
16481 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16482 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16483 
16484 	/* Create operation */
16485 	retval = create_cipher_auth_operation(ts_params,
16486 			ut_params,
16487 			reference, 0);
16488 
16489 	if (retval < 0)
16490 		return retval;
16491 
16492 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16493 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16494 			ut_params->op);
16495 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16496 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16497 					       0);
16498 		if (retval != TEST_SUCCESS)
16499 			return retval;
16500 	} else
16501 		ut_params->op = process_crypto_request(
16502 			ts_params->valid_devs[0], ut_params->op);
16503 
16504 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16505 
16506 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16507 			"crypto op processing failed");
16508 
16509 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16510 
16511 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16512 			ut_params->op->sym->auth.data.offset);
16513 	auth_tag = authciphertext + plaintext_pad_len;
16514 	debug_hexdump(stdout, "ciphertext:", authciphertext,
16515 			reference->ciphertext.len);
16516 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16517 
16518 	/* Validate obuf */
16519 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16520 			authciphertext,
16521 			reference->ciphertext.data,
16522 			reference->ciphertext.len,
16523 			"Ciphertext data not as expected");
16524 
16525 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16526 			auth_tag,
16527 			reference->digest.data,
16528 			reference->digest.len,
16529 			"Generated digest not as expected");
16530 
16531 	return TEST_SUCCESS;
16532 
16533 }
16534 
16535 static int
16536 test_authenticated_decrypt_with_esn(
16537 		struct crypto_testsuite_params *ts_params,
16538 		struct crypto_unittest_params *ut_params,
16539 		const struct test_crypto_vector *reference)
16540 {
16541 	int retval;
16542 
16543 	uint8_t *ciphertext;
16544 	uint8_t cipher_key[reference->cipher_key.len + 1];
16545 	uint8_t auth_key[reference->auth_key.len + 1];
16546 	struct rte_cryptodev_info dev_info;
16547 
16548 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16549 	uint64_t feat_flags = dev_info.feature_flags;
16550 
16551 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16552 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16553 		printf("Device doesn't support RAW data-path APIs.\n");
16554 		return TEST_SKIPPED;
16555 	}
16556 
16557 	/* Verify the capabilities */
16558 	struct rte_cryptodev_sym_capability_idx cap_idx;
16559 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16560 	cap_idx.algo.auth = reference->auth_algo;
16561 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16562 			&cap_idx) == NULL)
16563 		return TEST_SKIPPED;
16564 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16565 	cap_idx.algo.cipher = reference->crypto_algo;
16566 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16567 			&cap_idx) == NULL)
16568 		return TEST_SKIPPED;
16569 
16570 	/* Create session */
16571 	memcpy(cipher_key, reference->cipher_key.data,
16572 			reference->cipher_key.len);
16573 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16574 
16575 	/* Setup Authentication Parameters */
16576 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16577 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16578 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16579 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16580 	ut_params->auth_xform.auth.key.data = auth_key;
16581 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16582 	ut_params->auth_xform.next = &ut_params->cipher_xform;
16583 
16584 	/* Setup Cipher Parameters */
16585 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16586 	ut_params->cipher_xform.next = NULL;
16587 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16588 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16589 	ut_params->cipher_xform.cipher.key.data = cipher_key;
16590 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16591 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16592 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16593 
16594 	/* Create Crypto session*/
16595 	ut_params->sess = rte_cryptodev_sym_session_create(
16596 			ts_params->valid_devs[0], &ut_params->auth_xform,
16597 			ts_params->session_mpool);
16598 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16599 		return TEST_SKIPPED;
16600 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16601 
16602 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16603 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16604 			"Failed to allocate input buffer in mempool");
16605 
16606 	/* clear mbuf payload */
16607 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16608 			rte_pktmbuf_tailroom(ut_params->ibuf));
16609 
16610 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16611 			reference->ciphertext.len);
16612 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16613 	memcpy(ciphertext, reference->ciphertext.data,
16614 			reference->ciphertext.len);
16615 
16616 	/* Create operation */
16617 	retval = create_cipher_auth_verify_operation(ts_params,
16618 			ut_params,
16619 			reference);
16620 
16621 	if (retval < 0)
16622 		return retval;
16623 
16624 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16625 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16626 			ut_params->op);
16627 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16628 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16629 					       0);
16630 		if (retval != TEST_SUCCESS)
16631 			return retval;
16632 	} else
16633 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16634 			ut_params->op);
16635 
16636 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16637 	TEST_ASSERT_EQUAL(ut_params->op->status,
16638 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16639 			"crypto op processing passed");
16640 
16641 	ut_params->obuf = ut_params->op->sym->m_src;
16642 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16643 
16644 	return 0;
16645 }
16646 
16647 static int
16648 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16649 		const struct aead_test_data *tdata,
16650 		void *digest_mem, uint64_t digest_phys)
16651 {
16652 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16653 	struct crypto_unittest_params *ut_params = &unittest_params;
16654 
16655 	const unsigned int auth_tag_len = tdata->auth_tag.len;
16656 	const unsigned int iv_len = tdata->iv.len;
16657 	unsigned int aad_len = tdata->aad.len;
16658 	unsigned int aad_len_pad = 0;
16659 
16660 	/* Generate Crypto op data structure */
16661 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16662 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16663 	TEST_ASSERT_NOT_NULL(ut_params->op,
16664 		"Failed to allocate symmetric crypto operation struct");
16665 
16666 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16667 
16668 	sym_op->aead.digest.data = digest_mem;
16669 
16670 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
16671 			"no room to append digest");
16672 
16673 	sym_op->aead.digest.phys_addr = digest_phys;
16674 
16675 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
16676 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
16677 				auth_tag_len);
16678 		debug_hexdump(stdout, "digest:",
16679 				sym_op->aead.digest.data,
16680 				auth_tag_len);
16681 	}
16682 
16683 	/* Append aad data */
16684 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
16685 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16686 				uint8_t *, IV_OFFSET);
16687 
16688 		/* Copy IV 1 byte after the IV pointer, according to the API */
16689 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
16690 
16691 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
16692 
16693 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16694 				ut_params->ibuf, aad_len);
16695 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16696 				"no room to prepend aad");
16697 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16698 				ut_params->ibuf);
16699 
16700 		memset(sym_op->aead.aad.data, 0, aad_len);
16701 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
16702 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16703 
16704 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16705 		debug_hexdump(stdout, "aad:",
16706 				sym_op->aead.aad.data, aad_len);
16707 	} else {
16708 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16709 				uint8_t *, IV_OFFSET);
16710 
16711 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
16712 
16713 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
16714 
16715 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16716 				ut_params->ibuf, aad_len_pad);
16717 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16718 				"no room to prepend aad");
16719 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16720 				ut_params->ibuf);
16721 
16722 		memset(sym_op->aead.aad.data, 0, aad_len);
16723 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16724 
16725 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16726 		debug_hexdump(stdout, "aad:",
16727 				sym_op->aead.aad.data, aad_len);
16728 	}
16729 
16730 	sym_op->aead.data.length = tdata->plaintext.len;
16731 	sym_op->aead.data.offset = aad_len_pad;
16732 
16733 	return 0;
16734 }
16735 
16736 #define SGL_MAX_NO	16
16737 
16738 static int
16739 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
16740 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
16741 {
16742 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16743 	struct crypto_unittest_params *ut_params = &unittest_params;
16744 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
16745 	int retval;
16746 	int to_trn = 0;
16747 	int to_trn_tbl[SGL_MAX_NO];
16748 	int segs = 1;
16749 	unsigned int trn_data = 0;
16750 	uint8_t *plaintext, *ciphertext, *auth_tag;
16751 	struct rte_cryptodev_info dev_info;
16752 
16753 	/* Verify the capabilities */
16754 	struct rte_cryptodev_sym_capability_idx cap_idx;
16755 	const struct rte_cryptodev_symmetric_capability *capability;
16756 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
16757 	cap_idx.algo.aead = tdata->algo;
16758 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
16759 	if (capability == NULL)
16760 		return TEST_SKIPPED;
16761 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
16762 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
16763 		return TEST_SKIPPED;
16764 
16765 	/*
16766 	 * SGL not supported on AESNI_MB PMD CPU crypto,
16767 	 * OOP not supported on AESNI_GCM CPU crypto
16768 	 */
16769 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
16770 			(gbl_driver_id == rte_cryptodev_driver_id_get(
16771 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
16772 		return TEST_SKIPPED;
16773 
16774 	/* Detailed check for the particular SGL support flag */
16775 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16776 	if (!oop) {
16777 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
16778 		if (sgl_in && (!(dev_info.feature_flags &
16779 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
16780 			return TEST_SKIPPED;
16781 
16782 		uint64_t feat_flags = dev_info.feature_flags;
16783 
16784 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16785 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16786 			printf("Device doesn't support RAW data-path APIs.\n");
16787 			return TEST_SKIPPED;
16788 		}
16789 	} else {
16790 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
16791 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
16792 				tdata->plaintext.len;
16793 		/* Raw data path API does not support OOP */
16794 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
16795 			return TEST_SKIPPED;
16796 		if (sgl_in && !sgl_out) {
16797 			if (!(dev_info.feature_flags &
16798 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
16799 				return TEST_SKIPPED;
16800 		} else if (!sgl_in && sgl_out) {
16801 			if (!(dev_info.feature_flags &
16802 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
16803 				return TEST_SKIPPED;
16804 		} else if (sgl_in && sgl_out) {
16805 			if (!(dev_info.feature_flags &
16806 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
16807 				return TEST_SKIPPED;
16808 		}
16809 	}
16810 
16811 	if (fragsz > tdata->plaintext.len)
16812 		fragsz = tdata->plaintext.len;
16813 
16814 	uint16_t plaintext_len = fragsz;
16815 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
16816 
16817 	if (fragsz_oop > tdata->plaintext.len)
16818 		frag_size_oop = tdata->plaintext.len;
16819 
16820 	int ecx = 0;
16821 	void *digest_mem = NULL;
16822 
16823 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
16824 
16825 	if (tdata->plaintext.len % fragsz != 0) {
16826 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
16827 			return 1;
16828 	}	else {
16829 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
16830 			return 1;
16831 	}
16832 
16833 	/*
16834 	 * For out-of-place we need to alloc another mbuf
16835 	 */
16836 	if (oop) {
16837 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16838 		rte_pktmbuf_append(ut_params->obuf,
16839 				frag_size_oop + prepend_len);
16840 		buf_oop = ut_params->obuf;
16841 	}
16842 
16843 	/* Create AEAD session */
16844 	retval = create_aead_session(ts_params->valid_devs[0],
16845 			tdata->algo,
16846 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
16847 			tdata->key.data, tdata->key.len,
16848 			tdata->aad.len, tdata->auth_tag.len,
16849 			tdata->iv.len);
16850 	if (retval < 0)
16851 		return retval;
16852 
16853 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16854 
16855 	/* clear mbuf payload */
16856 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16857 			rte_pktmbuf_tailroom(ut_params->ibuf));
16858 
16859 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16860 			plaintext_len);
16861 
16862 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
16863 
16864 	trn_data += plaintext_len;
16865 
16866 	buf = ut_params->ibuf;
16867 
16868 	/*
16869 	 * Loop until no more fragments
16870 	 */
16871 
16872 	while (trn_data < tdata->plaintext.len) {
16873 		++segs;
16874 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
16875 				(tdata->plaintext.len - trn_data) : fragsz;
16876 
16877 		to_trn_tbl[ecx++] = to_trn;
16878 
16879 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16880 		buf = buf->next;
16881 
16882 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
16883 				rte_pktmbuf_tailroom(buf));
16884 
16885 		/* OOP */
16886 		if (oop && !fragsz_oop) {
16887 			buf_last_oop = buf_oop->next =
16888 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
16889 			buf_oop = buf_oop->next;
16890 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16891 					0, rte_pktmbuf_tailroom(buf_oop));
16892 			rte_pktmbuf_append(buf_oop, to_trn);
16893 		}
16894 
16895 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
16896 				to_trn);
16897 
16898 		memcpy(plaintext, tdata->plaintext.data + trn_data,
16899 				to_trn);
16900 		trn_data += to_trn;
16901 		if (trn_data  == tdata->plaintext.len) {
16902 			if (oop) {
16903 				if (!fragsz_oop)
16904 					digest_mem = rte_pktmbuf_append(buf_oop,
16905 						tdata->auth_tag.len);
16906 			} else
16907 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
16908 					tdata->auth_tag.len);
16909 		}
16910 	}
16911 
16912 	uint64_t digest_phys = 0;
16913 
16914 	ut_params->ibuf->nb_segs = segs;
16915 
16916 	segs = 1;
16917 	if (fragsz_oop && oop) {
16918 		to_trn = 0;
16919 		ecx = 0;
16920 
16921 		if (frag_size_oop == tdata->plaintext.len) {
16922 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
16923 				tdata->auth_tag.len);
16924 
16925 			digest_phys = rte_pktmbuf_iova_offset(
16926 					ut_params->obuf,
16927 					tdata->plaintext.len + prepend_len);
16928 		}
16929 
16930 		trn_data = frag_size_oop;
16931 		while (trn_data < tdata->plaintext.len) {
16932 			++segs;
16933 			to_trn =
16934 				(tdata->plaintext.len - trn_data <
16935 						frag_size_oop) ?
16936 				(tdata->plaintext.len - trn_data) :
16937 						frag_size_oop;
16938 
16939 			to_trn_tbl[ecx++] = to_trn;
16940 
16941 			buf_last_oop = buf_oop->next =
16942 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
16943 			buf_oop = buf_oop->next;
16944 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16945 					0, rte_pktmbuf_tailroom(buf_oop));
16946 			rte_pktmbuf_append(buf_oop, to_trn);
16947 
16948 			trn_data += to_trn;
16949 
16950 			if (trn_data  == tdata->plaintext.len) {
16951 				digest_mem = rte_pktmbuf_append(buf_oop,
16952 					tdata->auth_tag.len);
16953 			}
16954 		}
16955 
16956 		ut_params->obuf->nb_segs = segs;
16957 	}
16958 
16959 	/*
16960 	 * Place digest at the end of the last buffer
16961 	 */
16962 	if (!digest_phys)
16963 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
16964 	if (oop && buf_last_oop)
16965 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
16966 
16967 	if (!digest_mem && !oop) {
16968 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16969 				+ tdata->auth_tag.len);
16970 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
16971 				tdata->plaintext.len);
16972 	}
16973 
16974 	/* Create AEAD operation */
16975 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
16976 			tdata, digest_mem, digest_phys);
16977 
16978 	if (retval < 0)
16979 		return retval;
16980 
16981 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16982 
16983 	ut_params->op->sym->m_src = ut_params->ibuf;
16984 	if (oop)
16985 		ut_params->op->sym->m_dst = ut_params->obuf;
16986 
16987 	/* Process crypto operation */
16988 	if (oop == IN_PLACE &&
16989 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16990 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
16991 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16992 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
16993 					       0);
16994 		if (retval != TEST_SUCCESS)
16995 			return retval;
16996 	} else
16997 		TEST_ASSERT_NOT_NULL(
16998 			process_crypto_request(ts_params->valid_devs[0],
16999 			ut_params->op), "failed to process sym crypto op");
17000 
17001 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17002 			"crypto op processing failed");
17003 
17004 
17005 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17006 			uint8_t *, prepend_len);
17007 	if (oop) {
17008 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17009 				uint8_t *, prepend_len);
17010 	}
17011 
17012 	if (fragsz_oop)
17013 		fragsz = fragsz_oop;
17014 
17015 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
17016 			ciphertext,
17017 			tdata->ciphertext.data,
17018 			fragsz,
17019 			"Ciphertext data not as expected");
17020 
17021 	buf = ut_params->op->sym->m_src->next;
17022 	if (oop)
17023 		buf = ut_params->op->sym->m_dst->next;
17024 
17025 	unsigned int off = fragsz;
17026 
17027 	ecx = 0;
17028 	while (buf) {
17029 		ciphertext = rte_pktmbuf_mtod(buf,
17030 				uint8_t *);
17031 
17032 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
17033 				ciphertext,
17034 				tdata->ciphertext.data + off,
17035 				to_trn_tbl[ecx],
17036 				"Ciphertext data not as expected");
17037 
17038 		off += to_trn_tbl[ecx++];
17039 		buf = buf->next;
17040 	}
17041 
17042 	auth_tag = digest_mem;
17043 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
17044 			auth_tag,
17045 			tdata->auth_tag.data,
17046 			tdata->auth_tag.len,
17047 			"Generated auth tag not as expected");
17048 
17049 	return 0;
17050 }
17051 
17052 static int
17053 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17054 {
17055 	return test_authenticated_encryption_SGL(
17056 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17057 }
17058 
17059 static int
17060 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17061 {
17062 	return test_authenticated_encryption_SGL(
17063 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17064 }
17065 
17066 static int
17067 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17068 {
17069 	return test_authenticated_encryption_SGL(
17070 			&gcm_test_case_8, OUT_OF_PLACE, 400,
17071 			gcm_test_case_8.plaintext.len);
17072 }
17073 
17074 static int
17075 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17076 {
17077 	/* This test is not for OPENSSL PMD */
17078 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
17079 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17080 		return TEST_SKIPPED;
17081 
17082 	return test_authenticated_encryption_SGL(
17083 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17084 }
17085 
17086 static int
17087 test_authentication_verify_fail_when_data_corrupted(
17088 		struct crypto_testsuite_params *ts_params,
17089 		struct crypto_unittest_params *ut_params,
17090 		const struct test_crypto_vector *reference)
17091 {
17092 	return test_authentication_verify_fail_when_data_corruption(
17093 			ts_params, ut_params, reference, 1);
17094 }
17095 
17096 static int
17097 test_authentication_verify_fail_when_tag_corrupted(
17098 		struct crypto_testsuite_params *ts_params,
17099 		struct crypto_unittest_params *ut_params,
17100 		const struct test_crypto_vector *reference)
17101 {
17102 	return test_authentication_verify_fail_when_data_corruption(
17103 			ts_params, ut_params, reference, 0);
17104 }
17105 
17106 static int
17107 test_authentication_verify_GMAC_fail_when_data_corrupted(
17108 		struct crypto_testsuite_params *ts_params,
17109 		struct crypto_unittest_params *ut_params,
17110 		const struct test_crypto_vector *reference)
17111 {
17112 	return test_authentication_verify_GMAC_fail_when_corruption(
17113 			ts_params, ut_params, reference, 1);
17114 }
17115 
17116 static int
17117 test_authentication_verify_GMAC_fail_when_tag_corrupted(
17118 		struct crypto_testsuite_params *ts_params,
17119 		struct crypto_unittest_params *ut_params,
17120 		const struct test_crypto_vector *reference)
17121 {
17122 	return test_authentication_verify_GMAC_fail_when_corruption(
17123 			ts_params, ut_params, reference, 0);
17124 }
17125 
17126 static int
17127 test_authenticated_decryption_fail_when_data_corrupted(
17128 		struct crypto_testsuite_params *ts_params,
17129 		struct crypto_unittest_params *ut_params,
17130 		const struct test_crypto_vector *reference)
17131 {
17132 	return test_authenticated_decryption_fail_when_corruption(
17133 			ts_params, ut_params, reference, 1);
17134 }
17135 
17136 static int
17137 test_authenticated_decryption_fail_when_tag_corrupted(
17138 		struct crypto_testsuite_params *ts_params,
17139 		struct crypto_unittest_params *ut_params,
17140 		const struct test_crypto_vector *reference)
17141 {
17142 	return test_authenticated_decryption_fail_when_corruption(
17143 			ts_params, ut_params, reference, 0);
17144 }
17145 
17146 static int
17147 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17148 {
17149 	return test_authentication_verify_fail_when_data_corrupted(
17150 			&testsuite_params, &unittest_params,
17151 			&hmac_sha1_test_crypto_vector);
17152 }
17153 
17154 static int
17155 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17156 {
17157 	return test_authentication_verify_fail_when_tag_corrupted(
17158 			&testsuite_params, &unittest_params,
17159 			&hmac_sha1_test_crypto_vector);
17160 }
17161 
17162 static int
17163 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17164 {
17165 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
17166 			&testsuite_params, &unittest_params,
17167 			&aes128_gmac_test_vector);
17168 }
17169 
17170 static int
17171 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17172 {
17173 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17174 			&testsuite_params, &unittest_params,
17175 			&aes128_gmac_test_vector);
17176 }
17177 
17178 static int
17179 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17180 {
17181 	return test_authenticated_decryption_fail_when_data_corrupted(
17182 			&testsuite_params,
17183 			&unittest_params,
17184 			&aes128cbc_hmac_sha1_test_vector);
17185 }
17186 
17187 static int
17188 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17189 {
17190 	return test_authenticated_decryption_fail_when_tag_corrupted(
17191 			&testsuite_params,
17192 			&unittest_params,
17193 			&aes128cbc_hmac_sha1_test_vector);
17194 }
17195 
17196 static int
17197 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17198 {
17199 	return test_authenticated_encrypt_with_esn(
17200 			&testsuite_params,
17201 			&unittest_params,
17202 			&aes128cbc_hmac_sha1_aad_test_vector);
17203 }
17204 
17205 static int
17206 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17207 {
17208 	return test_authenticated_decrypt_with_esn(
17209 			&testsuite_params,
17210 			&unittest_params,
17211 			&aes128cbc_hmac_sha1_aad_test_vector);
17212 }
17213 
17214 static int
17215 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17216 {
17217 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17218 }
17219 
17220 static int
17221 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17222 {
17223 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17224 }
17225 
17226 static int
17227 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17228 {
17229 	return test_authenticated_encryption_SGL(
17230 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17231 		chacha20_poly1305_case_2.plaintext.len);
17232 }
17233 
17234 #ifdef RTE_CRYPTO_SCHEDULER
17235 
17236 /* global AESNI worker IDs for the scheduler test */
17237 uint8_t aesni_ids[2];
17238 
17239 static int
17240 scheduler_testsuite_setup(void)
17241 {
17242 	uint32_t i = 0;
17243 	int32_t nb_devs, ret;
17244 	char vdev_args[VDEV_ARGS_SIZE] = {""};
17245 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17246 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
17247 	uint16_t worker_core_count = 0;
17248 	uint16_t socket_id = 0;
17249 
17250 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
17251 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17252 
17253 		/* Identify the Worker Cores
17254 		 * Use 2 worker cores for the device args
17255 		 */
17256 		RTE_LCORE_FOREACH_WORKER(i) {
17257 			if (worker_core_count > 1)
17258 				break;
17259 			snprintf(vdev_args, sizeof(vdev_args),
17260 					"%s%d", temp_str, i);
17261 			strcpy(temp_str, vdev_args);
17262 			strlcat(temp_str, ";", sizeof(temp_str));
17263 			worker_core_count++;
17264 			socket_id = rte_lcore_to_socket_id(i);
17265 		}
17266 		if (worker_core_count != 2) {
17267 			RTE_LOG(ERR, USER1,
17268 				"Cryptodev scheduler test require at least "
17269 				"two worker cores to run. "
17270 				"Please use the correct coremask.\n");
17271 			return TEST_FAILED;
17272 		}
17273 		strcpy(temp_str, vdev_args);
17274 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
17275 				temp_str, socket_id);
17276 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17277 		nb_devs = rte_cryptodev_device_count_by_driver(
17278 				rte_cryptodev_driver_id_get(
17279 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17280 		if (nb_devs < 1) {
17281 			ret = rte_vdev_init(
17282 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17283 					vdev_args);
17284 			TEST_ASSERT(ret == 0,
17285 				"Failed to create instance %u of pmd : %s",
17286 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17287 		}
17288 	}
17289 	return testsuite_setup();
17290 }
17291 
17292 static int
17293 test_scheduler_attach_worker_op(void)
17294 {
17295 	struct crypto_testsuite_params *ts_params = &testsuite_params;
17296 	uint8_t sched_id = ts_params->valid_devs[0];
17297 	uint32_t i, nb_devs_attached = 0;
17298 	int ret;
17299 	char vdev_name[32];
17300 	unsigned int count = rte_cryptodev_count();
17301 
17302 	/* create 2 AESNI_MB vdevs on top of existing devices */
17303 	for (i = count; i < count + 2; i++) {
17304 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17305 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17306 				i);
17307 		ret = rte_vdev_init(vdev_name, NULL);
17308 
17309 		TEST_ASSERT(ret == 0,
17310 			"Failed to create instance %u of"
17311 			" pmd : %s",
17312 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17313 
17314 		if (ret < 0) {
17315 			RTE_LOG(ERR, USER1,
17316 				"Failed to create 2 AESNI MB PMDs.\n");
17317 			return TEST_SKIPPED;
17318 		}
17319 	}
17320 
17321 	/* attach 2 AESNI_MB cdevs */
17322 	for (i = count; i < count + 2; i++) {
17323 		struct rte_cryptodev_info info;
17324 		unsigned int session_size;
17325 
17326 		rte_cryptodev_info_get(i, &info);
17327 		if (info.driver_id != rte_cryptodev_driver_id_get(
17328 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17329 			continue;
17330 
17331 		session_size = rte_cryptodev_sym_get_private_session_size(i);
17332 		/*
17333 		 * Create the session mempool again, since now there are new devices
17334 		 * to use the mempool.
17335 		 */
17336 		if (ts_params->session_mpool) {
17337 			rte_mempool_free(ts_params->session_mpool);
17338 			ts_params->session_mpool = NULL;
17339 		}
17340 
17341 		if (info.sym.max_nb_sessions != 0 &&
17342 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17343 			RTE_LOG(ERR, USER1,
17344 					"Device does not support "
17345 					"at least %u sessions\n",
17346 					MAX_NB_SESSIONS);
17347 			return TEST_FAILED;
17348 		}
17349 		/*
17350 		 * Create mempool with maximum number of sessions,
17351 		 * to include the session headers
17352 		 */
17353 		if (ts_params->session_mpool == NULL) {
17354 			ts_params->session_mpool =
17355 				rte_cryptodev_sym_session_pool_create(
17356 						"test_sess_mp",
17357 						MAX_NB_SESSIONS, session_size,
17358 						0, 0, SOCKET_ID_ANY);
17359 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17360 					"session mempool allocation failed");
17361 		}
17362 
17363 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
17364 
17365 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17366 				(uint8_t)i);
17367 
17368 		TEST_ASSERT(ret == 0,
17369 			"Failed to attach device %u of pmd : %s", i,
17370 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17371 
17372 		aesni_ids[nb_devs_attached] = (uint8_t)i;
17373 
17374 		nb_devs_attached++;
17375 	}
17376 
17377 	return 0;
17378 }
17379 
17380 static int
17381 test_scheduler_detach_worker_op(void)
17382 {
17383 	struct crypto_testsuite_params *ts_params = &testsuite_params;
17384 	uint8_t sched_id = ts_params->valid_devs[0];
17385 	uint32_t i;
17386 	int ret;
17387 
17388 	for (i = 0; i < 2; i++) {
17389 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17390 				aesni_ids[i]);
17391 		TEST_ASSERT(ret == 0,
17392 			"Failed to detach device %u", aesni_ids[i]);
17393 	}
17394 
17395 	return 0;
17396 }
17397 
17398 static int
17399 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17400 {
17401 	struct crypto_testsuite_params *ts_params = &testsuite_params;
17402 	uint8_t sched_id = ts_params->valid_devs[0];
17403 	/* set mode */
17404 	return rte_cryptodev_scheduler_mode_set(sched_id,
17405 		scheduler_mode);
17406 }
17407 
17408 static int
17409 test_scheduler_mode_roundrobin_op(void)
17410 {
17411 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17412 			0, "Failed to set roundrobin mode");
17413 	return 0;
17414 
17415 }
17416 
17417 static int
17418 test_scheduler_mode_multicore_op(void)
17419 {
17420 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17421 			0, "Failed to set multicore mode");
17422 
17423 	return 0;
17424 }
17425 
17426 static int
17427 test_scheduler_mode_failover_op(void)
17428 {
17429 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17430 			0, "Failed to set failover mode");
17431 
17432 	return 0;
17433 }
17434 
17435 static int
17436 test_scheduler_mode_pkt_size_distr_op(void)
17437 {
17438 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17439 			0, "Failed to set pktsize mode");
17440 
17441 	return 0;
17442 }
17443 
17444 static int
17445 scheduler_multicore_testsuite_setup(void)
17446 {
17447 	if (test_scheduler_attach_worker_op() < 0)
17448 		return TEST_SKIPPED;
17449 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17450 		return TEST_SKIPPED;
17451 	return 0;
17452 }
17453 
17454 static int
17455 scheduler_roundrobin_testsuite_setup(void)
17456 {
17457 	if (test_scheduler_attach_worker_op() < 0)
17458 		return TEST_SKIPPED;
17459 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17460 		return TEST_SKIPPED;
17461 	return 0;
17462 }
17463 
17464 static int
17465 scheduler_failover_testsuite_setup(void)
17466 {
17467 	if (test_scheduler_attach_worker_op() < 0)
17468 		return TEST_SKIPPED;
17469 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17470 		return TEST_SKIPPED;
17471 	return 0;
17472 }
17473 
17474 static int
17475 scheduler_pkt_size_distr_testsuite_setup(void)
17476 {
17477 	if (test_scheduler_attach_worker_op() < 0)
17478 		return TEST_SKIPPED;
17479 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17480 		return TEST_SKIPPED;
17481 	return 0;
17482 }
17483 
17484 static void
17485 scheduler_mode_testsuite_teardown(void)
17486 {
17487 	test_scheduler_detach_worker_op();
17488 }
17489 
17490 #endif /* RTE_CRYPTO_SCHEDULER */
17491 
17492 static struct unit_test_suite end_testsuite = {
17493 	.suite_name = NULL,
17494 	.setup = NULL,
17495 	.teardown = NULL,
17496 	.unit_test_suites = NULL
17497 };
17498 
17499 #ifdef RTE_LIB_SECURITY
17500 static struct unit_test_suite ipsec_proto_testsuite  = {
17501 	.suite_name = "IPsec Proto Unit Test Suite",
17502 	.setup = ipsec_proto_testsuite_setup,
17503 	.unit_test_cases = {
17504 		TEST_CASE_NAMED_WITH_DATA(
17505 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17506 			ut_setup_security, ut_teardown,
17507 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17508 		TEST_CASE_NAMED_WITH_DATA(
17509 			"Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17510 			ut_setup_security, ut_teardown,
17511 			test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17512 		TEST_CASE_NAMED_WITH_DATA(
17513 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17514 			ut_setup_security, ut_teardown,
17515 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17516 		TEST_CASE_NAMED_WITH_DATA(
17517 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17518 			ut_setup_security, ut_teardown,
17519 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17520 		TEST_CASE_NAMED_WITH_DATA(
17521 			"Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17522 			ut_setup_security, ut_teardown,
17523 			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17524 		TEST_CASE_NAMED_WITH_DATA(
17525 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17526 			ut_setup_security, ut_teardown,
17527 			test_ipsec_proto_known_vec,
17528 			&pkt_aes_128_cbc_md5),
17529 		TEST_CASE_NAMED_WITH_DATA(
17530 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17531 			ut_setup_security, ut_teardown,
17532 			test_ipsec_proto_known_vec,
17533 			&pkt_aes_128_cbc_hmac_sha256),
17534 		TEST_CASE_NAMED_WITH_DATA(
17535 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17536 			ut_setup_security, ut_teardown,
17537 			test_ipsec_proto_known_vec,
17538 			&pkt_aes_128_cbc_hmac_sha384),
17539 		TEST_CASE_NAMED_WITH_DATA(
17540 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17541 			ut_setup_security, ut_teardown,
17542 			test_ipsec_proto_known_vec,
17543 			&pkt_aes_128_cbc_hmac_sha512),
17544 		TEST_CASE_NAMED_WITH_DATA(
17545 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17546 			ut_setup_security, ut_teardown,
17547 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
17548 		TEST_CASE_NAMED_WITH_DATA(
17549 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17550 			ut_setup_security, ut_teardown,
17551 			test_ipsec_proto_known_vec,
17552 			&pkt_aes_128_cbc_hmac_sha256_v6),
17553 		TEST_CASE_NAMED_WITH_DATA(
17554 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17555 			ut_setup_security, ut_teardown,
17556 			test_ipsec_proto_known_vec,
17557 			&pkt_null_aes_xcbc),
17558 		TEST_CASE_NAMED_WITH_DATA(
17559 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17560 			ut_setup_security, ut_teardown,
17561 			test_ipsec_proto_known_vec,
17562 			&pkt_des_cbc_hmac_sha256),
17563 		TEST_CASE_NAMED_WITH_DATA(
17564 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17565 			ut_setup_security, ut_teardown,
17566 			test_ipsec_proto_known_vec,
17567 			&pkt_des_cbc_hmac_sha384),
17568 		TEST_CASE_NAMED_WITH_DATA(
17569 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17570 			ut_setup_security, ut_teardown,
17571 			test_ipsec_proto_known_vec,
17572 			&pkt_des_cbc_hmac_sha512),
17573 		TEST_CASE_NAMED_WITH_DATA(
17574 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17575 			ut_setup_security, ut_teardown,
17576 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
17577 		TEST_CASE_NAMED_WITH_DATA(
17578 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17579 			ut_setup_security, ut_teardown,
17580 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
17581 		TEST_CASE_NAMED_WITH_DATA(
17582 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17583 			ut_setup_security, ut_teardown,
17584 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
17585 		TEST_CASE_NAMED_WITH_DATA(
17586 			"Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17587 			ut_setup_security, ut_teardown,
17588 			test_ipsec_proto_known_vec,
17589 			&pkt_des_cbc_hmac_sha256_v6),
17590 		TEST_CASE_NAMED_WITH_DATA(
17591 			"Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17592 			ut_setup_security, ut_teardown,
17593 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
17594 		TEST_CASE_NAMED_WITH_DATA(
17595 			"Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17596 			ut_setup_security, ut_teardown,
17597 			test_ipsec_proto_known_vec,
17598 			&pkt_ah_tunnel_sha256),
17599 		TEST_CASE_NAMED_WITH_DATA(
17600 			"Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17601 			ut_setup_security, ut_teardown,
17602 			test_ipsec_proto_known_vec,
17603 			&pkt_ah_transport_sha256),
17604 		TEST_CASE_NAMED_WITH_DATA(
17605 			"Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17606 			ut_setup_security, ut_teardown,
17607 			test_ipsec_proto_known_vec,
17608 			&pkt_ah_ipv4_aes_gmac_128),
17609 		TEST_CASE_NAMED_WITH_DATA(
17610 			"Outbound fragmented packet",
17611 			ut_setup_security, ut_teardown,
17612 			test_ipsec_proto_known_vec_fragmented,
17613 			&pkt_aes_128_gcm_frag),
17614 		TEST_CASE_NAMED_WITH_DATA(
17615 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17616 			ut_setup_security, ut_teardown,
17617 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
17618 		TEST_CASE_NAMED_WITH_DATA(
17619 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17620 			ut_setup_security, ut_teardown,
17621 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
17622 		TEST_CASE_NAMED_WITH_DATA(
17623 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17624 			ut_setup_security, ut_teardown,
17625 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
17626 		TEST_CASE_NAMED_WITH_DATA(
17627 			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17628 			ut_setup_security, ut_teardown,
17629 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
17630 		TEST_CASE_NAMED_WITH_DATA(
17631 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
17632 			ut_setup_security, ut_teardown,
17633 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
17634 		TEST_CASE_NAMED_WITH_DATA(
17635 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17636 			ut_setup_security, ut_teardown,
17637 			test_ipsec_proto_known_vec_inb,
17638 			&pkt_aes_128_cbc_md5),
17639 		TEST_CASE_NAMED_WITH_DATA(
17640 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17641 			ut_setup_security, ut_teardown,
17642 			test_ipsec_proto_known_vec_inb,
17643 			&pkt_aes_128_cbc_hmac_sha256),
17644 		TEST_CASE_NAMED_WITH_DATA(
17645 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17646 			ut_setup_security, ut_teardown,
17647 			test_ipsec_proto_known_vec_inb,
17648 			&pkt_aes_128_cbc_hmac_sha384),
17649 		TEST_CASE_NAMED_WITH_DATA(
17650 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17651 			ut_setup_security, ut_teardown,
17652 			test_ipsec_proto_known_vec_inb,
17653 			&pkt_aes_128_cbc_hmac_sha512),
17654 		TEST_CASE_NAMED_WITH_DATA(
17655 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17656 			ut_setup_security, ut_teardown,
17657 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
17658 		TEST_CASE_NAMED_WITH_DATA(
17659 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17660 			ut_setup_security, ut_teardown,
17661 			test_ipsec_proto_known_vec_inb,
17662 			&pkt_aes_128_cbc_hmac_sha256_v6),
17663 		TEST_CASE_NAMED_WITH_DATA(
17664 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17665 			ut_setup_security, ut_teardown,
17666 			test_ipsec_proto_known_vec_inb,
17667 			&pkt_null_aes_xcbc),
17668 		TEST_CASE_NAMED_WITH_DATA(
17669 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17670 			ut_setup_security, ut_teardown,
17671 			test_ipsec_proto_known_vec_inb,
17672 			&pkt_des_cbc_hmac_sha256),
17673 		TEST_CASE_NAMED_WITH_DATA(
17674 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17675 			ut_setup_security, ut_teardown,
17676 			test_ipsec_proto_known_vec_inb,
17677 			&pkt_des_cbc_hmac_sha384),
17678 		TEST_CASE_NAMED_WITH_DATA(
17679 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17680 			ut_setup_security, ut_teardown,
17681 			test_ipsec_proto_known_vec_inb,
17682 			&pkt_des_cbc_hmac_sha512),
17683 		TEST_CASE_NAMED_WITH_DATA(
17684 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17685 			ut_setup_security, ut_teardown,
17686 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
17687 		TEST_CASE_NAMED_WITH_DATA(
17688 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17689 			ut_setup_security, ut_teardown,
17690 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
17691 		TEST_CASE_NAMED_WITH_DATA(
17692 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17693 			ut_setup_security, ut_teardown,
17694 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
17695 		TEST_CASE_NAMED_WITH_DATA(
17696 			"Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17697 			ut_setup_security, ut_teardown,
17698 			test_ipsec_proto_known_vec_inb,
17699 			&pkt_des_cbc_hmac_sha256_v6),
17700 		TEST_CASE_NAMED_WITH_DATA(
17701 			"Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17702 			ut_setup_security, ut_teardown,
17703 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
17704 		TEST_CASE_NAMED_WITH_DATA(
17705 			"Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17706 			ut_setup_security, ut_teardown,
17707 			test_ipsec_proto_known_vec_inb,
17708 			&pkt_ah_tunnel_sha256),
17709 		TEST_CASE_NAMED_WITH_DATA(
17710 			"Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17711 			ut_setup_security, ut_teardown,
17712 			test_ipsec_proto_known_vec_inb,
17713 			&pkt_ah_transport_sha256),
17714 		TEST_CASE_NAMED_WITH_DATA(
17715 			"Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17716 			ut_setup_security, ut_teardown,
17717 			test_ipsec_proto_known_vec_inb,
17718 			&pkt_ah_ipv4_aes_gmac_128),
17719 		TEST_CASE_NAMED_ST(
17720 			"Combined test alg list",
17721 			ut_setup_security, ut_teardown,
17722 			test_ipsec_proto_display_list),
17723 		TEST_CASE_NAMED_ST(
17724 			"Combined test alg list (AH)",
17725 			ut_setup_security, ut_teardown,
17726 			test_ipsec_proto_ah_tunnel_ipv4),
17727 		TEST_CASE_NAMED_ST(
17728 			"IV generation",
17729 			ut_setup_security, ut_teardown,
17730 			test_ipsec_proto_iv_gen),
17731 		TEST_CASE_NAMED_ST(
17732 			"UDP encapsulation",
17733 			ut_setup_security, ut_teardown,
17734 			test_ipsec_proto_udp_encap),
17735 		TEST_CASE_NAMED_ST(
17736 			"UDP encapsulation with custom ports",
17737 			ut_setup_security, ut_teardown,
17738 			test_ipsec_proto_udp_encap_custom_ports),
17739 		TEST_CASE_NAMED_ST(
17740 			"UDP encapsulation ports verification test",
17741 			ut_setup_security, ut_teardown,
17742 			test_ipsec_proto_udp_ports_verify),
17743 		TEST_CASE_NAMED_ST(
17744 			"SA expiry packets soft",
17745 			ut_setup_security, ut_teardown,
17746 			test_ipsec_proto_sa_exp_pkts_soft),
17747 		TEST_CASE_NAMED_ST(
17748 			"SA expiry packets hard",
17749 			ut_setup_security, ut_teardown,
17750 			test_ipsec_proto_sa_exp_pkts_hard),
17751 		TEST_CASE_NAMED_ST(
17752 			"Negative test: ICV corruption",
17753 			ut_setup_security, ut_teardown,
17754 			test_ipsec_proto_err_icv_corrupt),
17755 		TEST_CASE_NAMED_ST(
17756 			"Tunnel dst addr verification",
17757 			ut_setup_security, ut_teardown,
17758 			test_ipsec_proto_tunnel_dst_addr_verify),
17759 		TEST_CASE_NAMED_ST(
17760 			"Tunnel src and dst addr verification",
17761 			ut_setup_security, ut_teardown,
17762 			test_ipsec_proto_tunnel_src_dst_addr_verify),
17763 		TEST_CASE_NAMED_ST(
17764 			"Inner IP checksum",
17765 			ut_setup_security, ut_teardown,
17766 			test_ipsec_proto_inner_ip_csum),
17767 		TEST_CASE_NAMED_ST(
17768 			"Inner L4 checksum",
17769 			ut_setup_security, ut_teardown,
17770 			test_ipsec_proto_inner_l4_csum),
17771 		TEST_CASE_NAMED_ST(
17772 			"Tunnel IPv4 in IPv4",
17773 			ut_setup_security, ut_teardown,
17774 			test_ipsec_proto_tunnel_v4_in_v4),
17775 		TEST_CASE_NAMED_ST(
17776 			"Tunnel IPv6 in IPv6",
17777 			ut_setup_security, ut_teardown,
17778 			test_ipsec_proto_tunnel_v6_in_v6),
17779 		TEST_CASE_NAMED_ST(
17780 			"Tunnel IPv4 in IPv6",
17781 			ut_setup_security, ut_teardown,
17782 			test_ipsec_proto_tunnel_v4_in_v6),
17783 		TEST_CASE_NAMED_ST(
17784 			"Tunnel IPv6 in IPv4",
17785 			ut_setup_security, ut_teardown,
17786 			test_ipsec_proto_tunnel_v6_in_v4),
17787 		TEST_CASE_NAMED_ST(
17788 			"Transport IPv4",
17789 			ut_setup_security, ut_teardown,
17790 			test_ipsec_proto_transport_v4),
17791 		TEST_CASE_NAMED_ST(
17792 			"AH transport IPv4",
17793 			ut_setup_security, ut_teardown,
17794 			test_ipsec_proto_ah_transport_ipv4),
17795 		TEST_CASE_NAMED_ST(
17796 			"Transport l4 checksum",
17797 			ut_setup_security, ut_teardown,
17798 			test_ipsec_proto_transport_l4_csum),
17799 		TEST_CASE_NAMED_ST(
17800 			"Statistics: success",
17801 			ut_setup_security, ut_teardown,
17802 			test_ipsec_proto_stats),
17803 		TEST_CASE_NAMED_ST(
17804 			"Fragmented packet",
17805 			ut_setup_security, ut_teardown,
17806 			test_ipsec_proto_pkt_fragment),
17807 		TEST_CASE_NAMED_ST(
17808 			"Tunnel header copy DF (inner 0)",
17809 			ut_setup_security, ut_teardown,
17810 			test_ipsec_proto_copy_df_inner_0),
17811 		TEST_CASE_NAMED_ST(
17812 			"Tunnel header copy DF (inner 1)",
17813 			ut_setup_security, ut_teardown,
17814 			test_ipsec_proto_copy_df_inner_1),
17815 		TEST_CASE_NAMED_ST(
17816 			"Tunnel header set DF 0 (inner 1)",
17817 			ut_setup_security, ut_teardown,
17818 			test_ipsec_proto_set_df_0_inner_1),
17819 		TEST_CASE_NAMED_ST(
17820 			"Tunnel header set DF 1 (inner 0)",
17821 			ut_setup_security, ut_teardown,
17822 			test_ipsec_proto_set_df_1_inner_0),
17823 		TEST_CASE_NAMED_ST(
17824 			"Tunnel header IPv4 copy DSCP (inner 0)",
17825 			ut_setup_security, ut_teardown,
17826 			test_ipsec_proto_ipv4_copy_dscp_inner_0),
17827 		TEST_CASE_NAMED_ST(
17828 			"Tunnel header IPv4 copy DSCP (inner 1)",
17829 			ut_setup_security, ut_teardown,
17830 			test_ipsec_proto_ipv4_copy_dscp_inner_1),
17831 		TEST_CASE_NAMED_ST(
17832 			"Tunnel header IPv4 set DSCP 0 (inner 1)",
17833 			ut_setup_security, ut_teardown,
17834 			test_ipsec_proto_ipv4_set_dscp_0_inner_1),
17835 		TEST_CASE_NAMED_ST(
17836 			"Tunnel header IPv4 set DSCP 1 (inner 0)",
17837 			ut_setup_security, ut_teardown,
17838 			test_ipsec_proto_ipv4_set_dscp_1_inner_0),
17839 		TEST_CASE_NAMED_ST(
17840 			"Tunnel header IPv6 copy DSCP (inner 0)",
17841 			ut_setup_security, ut_teardown,
17842 			test_ipsec_proto_ipv6_copy_dscp_inner_0),
17843 		TEST_CASE_NAMED_ST(
17844 			"Tunnel header IPv6 copy DSCP (inner 1)",
17845 			ut_setup_security, ut_teardown,
17846 			test_ipsec_proto_ipv6_copy_dscp_inner_1),
17847 		TEST_CASE_NAMED_ST(
17848 			"Tunnel header IPv6 set DSCP 0 (inner 1)",
17849 			ut_setup_security, ut_teardown,
17850 			test_ipsec_proto_ipv6_set_dscp_0_inner_1),
17851 		TEST_CASE_NAMED_ST(
17852 			"Tunnel header IPv6 set DSCP 1 (inner 0)",
17853 			ut_setup_security, ut_teardown,
17854 			test_ipsec_proto_ipv6_set_dscp_1_inner_0),
17855 		TEST_CASE_NAMED_WITH_DATA(
17856 			"Antireplay with window size 1024",
17857 			ut_setup_security, ut_teardown,
17858 			test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
17859 		TEST_CASE_NAMED_WITH_DATA(
17860 			"Antireplay with window size 2048",
17861 			ut_setup_security, ut_teardown,
17862 			test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
17863 		TEST_CASE_NAMED_WITH_DATA(
17864 			"Antireplay with window size 4096",
17865 			ut_setup_security, ut_teardown,
17866 			test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
17867 		TEST_CASE_NAMED_WITH_DATA(
17868 			"ESN and Antireplay with window size 1024",
17869 			ut_setup_security, ut_teardown,
17870 			test_ipsec_proto_pkt_esn_antireplay1024,
17871 			&pkt_aes_128_gcm),
17872 		TEST_CASE_NAMED_WITH_DATA(
17873 			"ESN and Antireplay with window size 2048",
17874 			ut_setup_security, ut_teardown,
17875 			test_ipsec_proto_pkt_esn_antireplay2048,
17876 			&pkt_aes_128_gcm),
17877 		TEST_CASE_NAMED_WITH_DATA(
17878 			"ESN and Antireplay with window size 4096",
17879 			ut_setup_security, ut_teardown,
17880 			test_ipsec_proto_pkt_esn_antireplay4096,
17881 			&pkt_aes_128_gcm),
17882 		TEST_CASE_NAMED_ST(
17883 			"Tunnel header IPv4 decrement inner TTL",
17884 			ut_setup_security, ut_teardown,
17885 			test_ipsec_proto_ipv4_ttl_decrement),
17886 		TEST_CASE_NAMED_ST(
17887 			"Tunnel header IPv6 decrement inner hop limit",
17888 			ut_setup_security, ut_teardown,
17889 			test_ipsec_proto_ipv6_hop_limit_decrement),
17890 		TEST_CASE_NAMED_ST(
17891 			"Multi-segmented mode",
17892 			ut_setup_security, ut_teardown,
17893 			test_ipsec_proto_sgl),
17894 		TEST_CASE_NAMED_ST(
17895 			"Multi-segmented external mbuf mode",
17896 			ut_setup_security, ut_teardown,
17897 			test_ipsec_proto_sgl_ext_mbuf),
17898 		TEST_CASE_NAMED_WITH_DATA(
17899 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
17900 			ut_setup_security_rx_inject, ut_teardown_rx_inject,
17901 			test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
17902 		TEST_CASES_END() /**< NULL terminate unit test array */
17903 	}
17904 };
17905 
17906 static struct unit_test_suite pdcp_proto_testsuite  = {
17907 	.suite_name = "PDCP Proto Unit Test Suite",
17908 	.setup = pdcp_proto_testsuite_setup,
17909 	.unit_test_cases = {
17910 		TEST_CASE_ST(ut_setup_security, ut_teardown,
17911 			test_PDCP_PROTO_all),
17912 		TEST_CASES_END() /**< NULL terminate unit test array */
17913 	}
17914 };
17915 
17916 static struct unit_test_suite tls12_record_proto_testsuite  = {
17917 	.suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
17918 	.setup = tls_record_proto_testsuite_setup,
17919 	.unit_test_cases = {
17920 		TEST_CASE_NAMED_WITH_DATA(
17921 			"Write record known vector AES-GCM-128 (vector 1)",
17922 			ut_setup_security, ut_teardown,
17923 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
17924 		TEST_CASE_NAMED_WITH_DATA(
17925 			"Write record known vector AES-GCM-128 (vector 2)",
17926 			ut_setup_security, ut_teardown,
17927 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
17928 		TEST_CASE_NAMED_WITH_DATA(
17929 			"Write record known vector AES-GCM-256",
17930 			ut_setup_security, ut_teardown,
17931 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
17932 		TEST_CASE_NAMED_WITH_DATA(
17933 			"Write record known vector AES-CBC-128-SHA1",
17934 			ut_setup_security, ut_teardown,
17935 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
17936 		TEST_CASE_NAMED_WITH_DATA(
17937 			"Write record known vector AES-128-CBC-SHA256",
17938 			ut_setup_security, ut_teardown,
17939 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
17940 		TEST_CASE_NAMED_WITH_DATA(
17941 			"Write record known vector AES-256-CBC-SHA1",
17942 			ut_setup_security, ut_teardown,
17943 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
17944 		TEST_CASE_NAMED_WITH_DATA(
17945 			"Write record known vector AES-256-CBC-SHA256",
17946 			ut_setup_security, ut_teardown,
17947 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
17948 		TEST_CASE_NAMED_WITH_DATA(
17949 			"Write record known vector AES-256-CBC-SHA384",
17950 			ut_setup_security, ut_teardown,
17951 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
17952 		TEST_CASE_NAMED_WITH_DATA(
17953 			"Write record known vector 3DES-CBC-SHA1-HMAC",
17954 			ut_setup_security, ut_teardown,
17955 			test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
17956 		TEST_CASE_NAMED_WITH_DATA(
17957 			"Write record known vector NULL-SHA1-HMAC",
17958 			ut_setup_security, ut_teardown,
17959 			test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
17960 		TEST_CASE_NAMED_WITH_DATA(
17961 			"Write record known vector CHACHA20-POLY1305",
17962 			ut_setup_security, ut_teardown,
17963 			test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
17964 
17965 		TEST_CASE_NAMED_WITH_DATA(
17966 			"Read record known vector AES-GCM-128 (vector 1)",
17967 			ut_setup_security, ut_teardown,
17968 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
17969 		TEST_CASE_NAMED_WITH_DATA(
17970 			"Read record known vector AES-GCM-128 (vector 2)",
17971 			ut_setup_security, ut_teardown,
17972 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
17973 		TEST_CASE_NAMED_WITH_DATA(
17974 			"Read record known vector AES-GCM-256",
17975 			ut_setup_security, ut_teardown,
17976 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
17977 		TEST_CASE_NAMED_WITH_DATA(
17978 			"Read record known vector AES-128-CBC-SHA1",
17979 			ut_setup_security, ut_teardown,
17980 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
17981 		TEST_CASE_NAMED_WITH_DATA(
17982 			"Read record known vector AES-128-CBC-SHA256",
17983 			ut_setup_security, ut_teardown,
17984 			test_tls_record_proto_known_vec_read,
17985 			&tls_test_data_aes_128_cbc_sha256_hmac),
17986 		TEST_CASE_NAMED_WITH_DATA(
17987 			"Read record known vector AES-256-CBC-SHA1",
17988 			ut_setup_security, ut_teardown,
17989 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
17990 		TEST_CASE_NAMED_WITH_DATA(
17991 			"Read record known vector AES-256-CBC-SHA256",
17992 			ut_setup_security, ut_teardown,
17993 			test_tls_record_proto_known_vec_read,
17994 			&tls_test_data_aes_256_cbc_sha256_hmac),
17995 		TEST_CASE_NAMED_WITH_DATA(
17996 			"Read record known vector AES-256-CBC-SHA384",
17997 			ut_setup_security, ut_teardown,
17998 			test_tls_record_proto_known_vec_read,
17999 			&tls_test_data_aes_256_cbc_sha384_hmac),
18000 		TEST_CASE_NAMED_WITH_DATA(
18001 			"Read record known vector 3DES-CBC-SHA1-HMAC",
18002 			ut_setup_security, ut_teardown,
18003 			test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18004 		TEST_CASE_NAMED_WITH_DATA(
18005 			"Read record known vector NULL-SHA1-HMAC",
18006 			ut_setup_security, ut_teardown,
18007 			test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18008 		TEST_CASE_NAMED_WITH_DATA(
18009 			"Read record known vector CHACHA20-POLY1305",
18010 			ut_setup_security, ut_teardown,
18011 			test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18012 
18013 		TEST_CASE_NAMED_ST(
18014 			"Combined test alg list",
18015 			ut_setup_security, ut_teardown,
18016 			test_tls_1_2_record_proto_display_list),
18017 		TEST_CASE_NAMED_ST(
18018 			"Data walkthrough combined test alg list",
18019 			ut_setup_security, ut_teardown,
18020 			test_tls_1_2_record_proto_data_walkthrough),
18021 		TEST_CASE_NAMED_ST(
18022 			"Multi-segmented mode",
18023 			ut_setup_security, ut_teardown,
18024 			test_tls_1_2_record_proto_sgl),
18025 		TEST_CASE_NAMED_ST(
18026 			"Multi-segmented mode data walkthrough",
18027 			ut_setup_security, ut_teardown,
18028 			test_tls_1_2_record_proto_sgl_data_walkthrough),
18029 		TEST_CASE_NAMED_ST(
18030 			"Multi-segmented mode out of place",
18031 			ut_setup_security, ut_teardown,
18032 			test_tls_1_2_record_proto_sgl_oop),
18033 		TEST_CASE_NAMED_ST(
18034 			"TLS packet header corruption",
18035 			ut_setup_security, ut_teardown,
18036 			test_tls_record_proto_corrupt_pkt),
18037 		TEST_CASE_NAMED_ST(
18038 			"Custom content type",
18039 			ut_setup_security, ut_teardown,
18040 			test_tls_record_proto_custom_content_type),
18041 		TEST_CASE_NAMED_ST(
18042 			"Zero len TLS record with content type as app",
18043 			ut_setup_security, ut_teardown,
18044 			test_tls_record_proto_zero_len),
18045 		TEST_CASE_NAMED_ST(
18046 			"Zero len TLS record with content type as ctrl",
18047 			ut_setup_security, ut_teardown,
18048 			test_tls_record_proto_zero_len_non_app),
18049 		TEST_CASE_NAMED_ST(
18050 			"TLS record DM mode with optional padding < 2 blocks",
18051 			ut_setup_security, ut_teardown,
18052 			test_tls_record_proto_dm_opt_padding),
18053 		TEST_CASE_NAMED_ST(
18054 			"TLS record DM mode with optional padding > 2 blocks",
18055 			ut_setup_security, ut_teardown,
18056 			test_tls_record_proto_dm_opt_padding_1),
18057 		TEST_CASE_NAMED_ST(
18058 			"TLS record SG mode with optional padding < 2 blocks",
18059 			ut_setup_security, ut_teardown,
18060 			test_tls_record_proto_sg_opt_padding),
18061 		TEST_CASE_NAMED_ST(
18062 			"TLS record SG mode with optional padding > 2 blocks",
18063 			ut_setup_security, ut_teardown,
18064 			test_tls_record_proto_sg_opt_padding_1),
18065 		TEST_CASE_NAMED_ST(
18066 			"TLS record SG mode with optional padding > 2 blocks",
18067 			ut_setup_security, ut_teardown,
18068 			test_tls_record_proto_sg_opt_padding_2),
18069 		TEST_CASE_NAMED_ST(
18070 			"TLS record SG mode with optional padding > max range",
18071 			ut_setup_security, ut_teardown,
18072 			test_tls_record_proto_sg_opt_padding_max),
18073 		TEST_CASE_NAMED_ST(
18074 			"TLS record SG mode with padding corruption",
18075 			ut_setup_security, ut_teardown,
18076 			test_tls_record_proto_sg_opt_padding_corrupt),
18077 		TEST_CASES_END() /**< NULL terminate unit test array */
18078 	}
18079 };
18080 
18081 static struct unit_test_suite dtls12_record_proto_testsuite  = {
18082 	.suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18083 	.setup = tls_record_proto_testsuite_setup,
18084 	.unit_test_cases = {
18085 		TEST_CASE_NAMED_WITH_DATA(
18086 			"Write record known vector AES-GCM-128",
18087 			ut_setup_security, ut_teardown,
18088 			test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18089 		TEST_CASE_NAMED_WITH_DATA(
18090 			"Write record known vector AES-GCM-256",
18091 			ut_setup_security, ut_teardown,
18092 			test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18093 		TEST_CASE_NAMED_WITH_DATA(
18094 			"Write record known vector AES-128-CBC-SHA1",
18095 			ut_setup_security, ut_teardown,
18096 			test_tls_record_proto_known_vec,
18097 			&dtls_test_data_aes_128_cbc_sha1_hmac),
18098 		TEST_CASE_NAMED_WITH_DATA(
18099 			"Write record known vector AES-128-CBC-SHA256",
18100 			ut_setup_security, ut_teardown,
18101 			test_tls_record_proto_known_vec,
18102 			&dtls_test_data_aes_128_cbc_sha256_hmac),
18103 		TEST_CASE_NAMED_WITH_DATA(
18104 			"Write record known vector AES-256-CBC-SHA1",
18105 			ut_setup_security, ut_teardown,
18106 			test_tls_record_proto_known_vec,
18107 			&dtls_test_data_aes_256_cbc_sha1_hmac),
18108 		TEST_CASE_NAMED_WITH_DATA(
18109 			"Write record known vector AES-256-CBC-SHA256",
18110 			ut_setup_security, ut_teardown,
18111 			test_tls_record_proto_known_vec,
18112 			&dtls_test_data_aes_256_cbc_sha256_hmac),
18113 		TEST_CASE_NAMED_WITH_DATA(
18114 			"Write record known vector AES-256-CBC-SHA384",
18115 			ut_setup_security, ut_teardown,
18116 			test_tls_record_proto_known_vec,
18117 			&dtls_test_data_aes_256_cbc_sha384_hmac),
18118 		TEST_CASE_NAMED_WITH_DATA(
18119 			"Write record known vector 3DES-CBC-SHA1-HMAC",
18120 			ut_setup_security, ut_teardown,
18121 			test_tls_record_proto_known_vec,
18122 			&dtls_test_data_3des_cbc_sha1_hmac),
18123 		TEST_CASE_NAMED_WITH_DATA(
18124 			"Write record known vector NULL-SHA1-HMAC",
18125 			ut_setup_security, ut_teardown,
18126 			test_tls_record_proto_known_vec,
18127 			&dtls_test_data_null_cipher_sha1_hmac),
18128 		TEST_CASE_NAMED_WITH_DATA(
18129 			"Write record known vector CHACHA20-POLY1305",
18130 			ut_setup_security, ut_teardown,
18131 			test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18132 		TEST_CASE_NAMED_WITH_DATA(
18133 			"Read record known vector AES-GCM-128",
18134 			ut_setup_security, ut_teardown,
18135 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18136 		TEST_CASE_NAMED_WITH_DATA(
18137 			"Read record known vector AES-GCM-256",
18138 			ut_setup_security, ut_teardown,
18139 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18140 		TEST_CASE_NAMED_WITH_DATA(
18141 			"Read record known vector AES-128-CBC-SHA1",
18142 			ut_setup_security, ut_teardown,
18143 			test_tls_record_proto_known_vec_read,
18144 			&dtls_test_data_aes_128_cbc_sha1_hmac),
18145 		TEST_CASE_NAMED_WITH_DATA(
18146 			"Read record known vector AES-128-CBC-SHA256",
18147 			ut_setup_security, ut_teardown,
18148 			test_tls_record_proto_known_vec_read,
18149 			&dtls_test_data_aes_128_cbc_sha256_hmac),
18150 		TEST_CASE_NAMED_WITH_DATA(
18151 			"Read record known vector AES-256-CBC-SHA1",
18152 			ut_setup_security, ut_teardown,
18153 			test_tls_record_proto_known_vec_read,
18154 			&dtls_test_data_aes_256_cbc_sha1_hmac),
18155 		TEST_CASE_NAMED_WITH_DATA(
18156 			"Read record known vector AES-256-CBC-SHA256",
18157 			ut_setup_security, ut_teardown,
18158 			test_tls_record_proto_known_vec_read,
18159 			&dtls_test_data_aes_256_cbc_sha256_hmac),
18160 		TEST_CASE_NAMED_WITH_DATA(
18161 			"Read record known vector AES-256-CBC-SHA384",
18162 			ut_setup_security, ut_teardown,
18163 			test_tls_record_proto_known_vec_read,
18164 			&dtls_test_data_aes_256_cbc_sha384_hmac),
18165 		TEST_CASE_NAMED_WITH_DATA(
18166 			"Read record known vector 3DES-CBC-SHA1-HMAC",
18167 			ut_setup_security, ut_teardown,
18168 			test_tls_record_proto_known_vec_read,
18169 			&dtls_test_data_3des_cbc_sha1_hmac),
18170 		TEST_CASE_NAMED_WITH_DATA(
18171 			"Read record known vector NULL-SHA1-HMAC",
18172 			ut_setup_security, ut_teardown,
18173 			test_tls_record_proto_known_vec_read,
18174 			&dtls_test_data_null_cipher_sha1_hmac),
18175 		TEST_CASE_NAMED_WITH_DATA(
18176 			"Read record known vector CHACHA20-POLY1305",
18177 			ut_setup_security, ut_teardown,
18178 			test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18179 
18180 		TEST_CASE_NAMED_ST(
18181 			"Combined test alg list",
18182 			ut_setup_security, ut_teardown,
18183 			test_dtls_1_2_record_proto_display_list),
18184 		TEST_CASE_NAMED_ST(
18185 			"Data walkthrough combined test alg list",
18186 			ut_setup_security, ut_teardown,
18187 			test_dtls_1_2_record_proto_data_walkthrough),
18188 		TEST_CASE_NAMED_ST(
18189 			"Multi-segmented mode",
18190 			ut_setup_security, ut_teardown,
18191 			test_dtls_1_2_record_proto_sgl),
18192 		TEST_CASE_NAMED_ST(
18193 			"Multi-segmented mode data walkthrough",
18194 			ut_setup_security, ut_teardown,
18195 			test_dtls_1_2_record_proto_sgl_data_walkthrough),
18196 		TEST_CASE_NAMED_ST(
18197 			"Multi-segmented mode out of place",
18198 			ut_setup_security, ut_teardown,
18199 			test_dtls_1_2_record_proto_sgl_oop),
18200 		TEST_CASE_NAMED_ST(
18201 			"Packet corruption",
18202 			ut_setup_security, ut_teardown,
18203 			test_dtls_1_2_record_proto_corrupt_pkt),
18204 		TEST_CASE_NAMED_ST(
18205 			"Custom content type",
18206 			ut_setup_security, ut_teardown,
18207 			test_dtls_1_2_record_proto_custom_content_type),
18208 		TEST_CASE_NAMED_ST(
18209 			"Zero len DTLS record with content type as app",
18210 			ut_setup_security, ut_teardown,
18211 			test_dtls_1_2_record_proto_zero_len),
18212 		TEST_CASE_NAMED_ST(
18213 			"Zero len DTLS record with content type as ctrl",
18214 			ut_setup_security, ut_teardown,
18215 			test_dtls_1_2_record_proto_zero_len_non_app),
18216 		TEST_CASE_NAMED_ST(
18217 			"Antireplay with window size 64",
18218 			ut_setup_security, ut_teardown,
18219 			test_dtls_1_2_record_proto_antireplay64),
18220 		TEST_CASE_NAMED_ST(
18221 			"Antireplay with window size 128",
18222 			ut_setup_security, ut_teardown,
18223 			test_dtls_1_2_record_proto_antireplay128),
18224 		TEST_CASE_NAMED_ST(
18225 			"Antireplay with window size 256",
18226 			ut_setup_security, ut_teardown,
18227 			test_dtls_1_2_record_proto_antireplay256),
18228 		TEST_CASE_NAMED_ST(
18229 			"Antireplay with window size 512",
18230 			ut_setup_security, ut_teardown,
18231 			test_dtls_1_2_record_proto_antireplay512),
18232 		TEST_CASE_NAMED_ST(
18233 			"Antireplay with window size 1024",
18234 			ut_setup_security, ut_teardown,
18235 			test_dtls_1_2_record_proto_antireplay1024),
18236 		TEST_CASE_NAMED_ST(
18237 			"Antireplay with window size 2048",
18238 			ut_setup_security, ut_teardown,
18239 			test_dtls_1_2_record_proto_antireplay2048),
18240 		TEST_CASE_NAMED_ST(
18241 			"Antireplay with window size 4096",
18242 			ut_setup_security, ut_teardown,
18243 			test_dtls_1_2_record_proto_antireplay4096),
18244 		TEST_CASE_NAMED_ST(
18245 			"DTLS record DM mode with optional padding < 2 blocks",
18246 			ut_setup_security, ut_teardown,
18247 			test_dtls_1_2_record_proto_dm_opt_padding),
18248 		TEST_CASE_NAMED_ST(
18249 			"DTLS record DM mode with optional padding > 2 blocks",
18250 			ut_setup_security, ut_teardown,
18251 			test_dtls_1_2_record_proto_dm_opt_padding_1),
18252 		TEST_CASE_NAMED_ST(
18253 			"DTLS record SG mode with optional padding < 2 blocks",
18254 			ut_setup_security, ut_teardown,
18255 			test_dtls_1_2_record_proto_sg_opt_padding),
18256 		TEST_CASE_NAMED_ST(
18257 			"DTLS record SG mode with optional padding > 2 blocks",
18258 			ut_setup_security, ut_teardown,
18259 			test_dtls_1_2_record_proto_sg_opt_padding_1),
18260 		TEST_CASE_NAMED_ST(
18261 			"DTLS record SG mode with optional padding > 2 blocks",
18262 			ut_setup_security, ut_teardown,
18263 			test_dtls_1_2_record_proto_sg_opt_padding_2),
18264 		TEST_CASE_NAMED_ST(
18265 			"DTLS record SG mode with optional padding > max range",
18266 			ut_setup_security, ut_teardown,
18267 			test_dtls_1_2_record_proto_sg_opt_padding_max),
18268 		TEST_CASE_NAMED_ST(
18269 			"DTLS record SG mode with padding corruption",
18270 			ut_setup_security, ut_teardown,
18271 			test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18272 		TEST_CASES_END() /**< NULL terminate unit test array */
18273 	}
18274 };
18275 
18276 static struct unit_test_suite tls13_record_proto_testsuite  = {
18277 	.suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18278 	.setup = tls_record_proto_testsuite_setup,
18279 	.unit_test_cases = {
18280 		TEST_CASE_NAMED_WITH_DATA(
18281 			"Write record known vector AES-GCM-128",
18282 			ut_setup_security, ut_teardown,
18283 			test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18284 		TEST_CASE_NAMED_WITH_DATA(
18285 			"Write record known vector AES-GCM-256",
18286 			ut_setup_security, ut_teardown,
18287 			test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18288 		TEST_CASE_NAMED_WITH_DATA(
18289 			"Write record known vector CHACHA20-POLY1305",
18290 			ut_setup_security, ut_teardown,
18291 			test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18292 
18293 		TEST_CASE_NAMED_WITH_DATA(
18294 			"Read record known vector AES-GCM-128",
18295 			ut_setup_security, ut_teardown,
18296 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18297 		TEST_CASE_NAMED_WITH_DATA(
18298 			"Read record known vector AES-GCM-256",
18299 			ut_setup_security, ut_teardown,
18300 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18301 		TEST_CASE_NAMED_WITH_DATA(
18302 			"Read record known vector CHACHA20-POLY1305",
18303 			ut_setup_security, ut_teardown,
18304 			test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18305 		TEST_CASE_NAMED_ST(
18306 			"TLS-1.3 record header corruption",
18307 			ut_setup_security, ut_teardown,
18308 			test_tls_1_3_record_proto_corrupt_pkt),
18309 		TEST_CASE_NAMED_ST(
18310 			"TLS-1.3 record header with custom content type",
18311 			ut_setup_security, ut_teardown,
18312 			test_tls_1_3_record_proto_custom_content_type),
18313 		TEST_CASE_NAMED_ST(
18314 			"TLS-1.3 record with zero len and content type as app",
18315 			ut_setup_security, ut_teardown,
18316 			test_tls_1_3_record_proto_zero_len),
18317 		TEST_CASE_NAMED_ST(
18318 			"TLS-1.3 record with zero len and content type as ctrl",
18319 			ut_setup_security, ut_teardown,
18320 			test_tls_1_3_record_proto_zero_len_non_app),
18321 		TEST_CASE_NAMED_ST(
18322 			"TLS-1.3 record DM mode with optional padding",
18323 			ut_setup_security, ut_teardown,
18324 			test_tls_1_3_record_proto_dm_opt_padding),
18325 		TEST_CASE_NAMED_ST(
18326 			"TLS-1.3 record SG mode with optional padding - 1",
18327 			ut_setup_security, ut_teardown,
18328 			test_tls_1_3_record_proto_sg_opt_padding),
18329 		TEST_CASE_NAMED_ST(
18330 			"TLS-1.3 record SG mode with optional padding",
18331 			ut_setup_security, ut_teardown,
18332 			test_tls_1_3_record_proto_sg_opt_padding_1),
18333 		TEST_CASE_NAMED_ST(
18334 			"Combined test alg list",
18335 			ut_setup_security, ut_teardown,
18336 			test_tls_1_3_record_proto_display_list),
18337 		TEST_CASE_NAMED_ST(
18338 			"Data walkthrough combined test alg list",
18339 			ut_setup_security, ut_teardown,
18340 			test_tls_1_3_record_proto_data_walkthrough),
18341 		TEST_CASE_NAMED_ST(
18342 			"Multi-segmented mode",
18343 			ut_setup_security, ut_teardown,
18344 			test_tls_1_3_record_proto_sgl),
18345 		TEST_CASE_NAMED_ST(
18346 			"Multi-segmented mode data walkthrough",
18347 			ut_setup_security, ut_teardown,
18348 			test_tls_1_3_record_proto_sgl_data_walkthrough),
18349 		TEST_CASE_NAMED_ST(
18350 			"Multi-segmented mode out of place",
18351 			ut_setup_security, ut_teardown,
18352 			test_tls_1_3_record_proto_sgl_oop),
18353 		TEST_CASES_END() /**< NULL terminate unit test array */
18354 	}
18355 };
18356 
18357 #define ADD_UPLINK_TESTCASE(data)						\
18358 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
18359 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
18360 
18361 #define ADD_DOWNLINK_TESTCASE(data)						\
18362 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
18363 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
18364 
18365 static struct unit_test_suite docsis_proto_testsuite  = {
18366 	.suite_name = "DOCSIS Proto Unit Test Suite",
18367 	.setup = docsis_proto_testsuite_setup,
18368 	.unit_test_cases = {
18369 		/* Uplink */
18370 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
18371 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
18372 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
18373 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
18374 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
18375 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
18376 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
18377 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
18378 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
18379 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
18380 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
18381 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
18382 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
18383 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
18384 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
18385 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
18386 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
18387 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
18388 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
18389 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
18390 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
18391 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
18392 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
18393 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
18394 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
18395 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
18396 		/* Downlink */
18397 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18398 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18399 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18400 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18401 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18402 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18403 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18404 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18405 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18406 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18407 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18408 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18409 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18410 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18411 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18412 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18413 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18414 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18415 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18416 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18417 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18418 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18419 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18420 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18421 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18422 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18423 		TEST_CASES_END() /**< NULL terminate unit test array */
18424 	}
18425 };
18426 #endif
18427 
18428 static struct unit_test_suite cryptodev_gen_testsuite  = {
18429 	.suite_name = "Crypto General Unit Test Suite",
18430 	.setup = crypto_gen_testsuite_setup,
18431 	.unit_test_cases = {
18432 		TEST_CASE_ST(ut_setup, ut_teardown,
18433 				test_device_reconfigure),
18434 		TEST_CASE_ST(ut_setup, ut_teardown,
18435 				test_device_configure_invalid_dev_id),
18436 		TEST_CASE_ST(ut_setup, ut_teardown,
18437 				test_queue_pair_descriptor_setup),
18438 		TEST_CASE_ST(ut_setup, ut_teardown,
18439 				test_device_configure_invalid_queue_pair_ids),
18440 		TEST_CASE_ST(ut_setup, ut_teardown,
18441 				test_queue_pair_descriptor_count),
18442 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18443 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18444 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18445 		TEST_CASES_END() /**< NULL terminate unit test array */
18446 	}
18447 };
18448 
18449 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18450 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
18451 	.setup = negative_hmac_sha1_testsuite_setup,
18452 	.unit_test_cases = {
18453 		/** Negative tests */
18454 		TEST_CASE_ST(ut_setup, ut_teardown,
18455 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
18456 		TEST_CASE_ST(ut_setup, ut_teardown,
18457 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18458 		TEST_CASE_ST(ut_setup, ut_teardown,
18459 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18460 		TEST_CASE_ST(ut_setup, ut_teardown,
18461 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18462 
18463 		TEST_CASES_END() /**< NULL terminate unit test array */
18464 	}
18465 };
18466 
18467 static struct unit_test_suite cryptodev_multi_session_testsuite = {
18468 	.suite_name = "Multi Session Unit Test Suite",
18469 	.setup = multi_session_testsuite_setup,
18470 	.unit_test_cases = {
18471 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18472 		TEST_CASE_ST(ut_setup, ut_teardown,
18473 				test_multi_session_random_usage),
18474 
18475 		TEST_CASES_END() /**< NULL terminate unit test array */
18476 	}
18477 };
18478 
18479 static struct unit_test_suite cryptodev_null_testsuite  = {
18480 	.suite_name = "NULL Test Suite",
18481 	.setup = null_testsuite_setup,
18482 	.unit_test_cases = {
18483 		TEST_CASE_ST(ut_setup, ut_teardown,
18484 			test_null_invalid_operation),
18485 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
18486 		TEST_CASES_END()
18487 	}
18488 };
18489 
18490 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
18491 	.suite_name = "AES CCM Authenticated Test Suite",
18492 	.setup = aes_ccm_auth_testsuite_setup,
18493 	.unit_test_cases = {
18494 		/** AES CCM Authenticated Encryption 128 bits key*/
18495 		TEST_CASE_ST(ut_setup, ut_teardown,
18496 			test_AES_CCM_authenticated_encryption_test_case_128_1),
18497 		TEST_CASE_ST(ut_setup, ut_teardown,
18498 			test_AES_CCM_authenticated_encryption_test_case_128_2),
18499 		TEST_CASE_ST(ut_setup, ut_teardown,
18500 			test_AES_CCM_authenticated_encryption_test_case_128_3),
18501 
18502 		/** AES CCM Authenticated Decryption 128 bits key*/
18503 		TEST_CASE_ST(ut_setup, ut_teardown,
18504 			test_AES_CCM_authenticated_decryption_test_case_128_1),
18505 		TEST_CASE_ST(ut_setup, ut_teardown,
18506 			test_AES_CCM_authenticated_decryption_test_case_128_2),
18507 		TEST_CASE_ST(ut_setup, ut_teardown,
18508 			test_AES_CCM_authenticated_decryption_test_case_128_3),
18509 
18510 		/** AES CCM Authenticated Encryption 192 bits key */
18511 		TEST_CASE_ST(ut_setup, ut_teardown,
18512 			test_AES_CCM_authenticated_encryption_test_case_192_1),
18513 		TEST_CASE_ST(ut_setup, ut_teardown,
18514 			test_AES_CCM_authenticated_encryption_test_case_192_2),
18515 		TEST_CASE_ST(ut_setup, ut_teardown,
18516 			test_AES_CCM_authenticated_encryption_test_case_192_3),
18517 
18518 		/** AES CCM Authenticated Decryption 192 bits key*/
18519 		TEST_CASE_ST(ut_setup, ut_teardown,
18520 			test_AES_CCM_authenticated_decryption_test_case_192_1),
18521 		TEST_CASE_ST(ut_setup, ut_teardown,
18522 			test_AES_CCM_authenticated_decryption_test_case_192_2),
18523 		TEST_CASE_ST(ut_setup, ut_teardown,
18524 			test_AES_CCM_authenticated_decryption_test_case_192_3),
18525 
18526 		/** AES CCM Authenticated Encryption 256 bits key */
18527 		TEST_CASE_ST(ut_setup, ut_teardown,
18528 			test_AES_CCM_authenticated_encryption_test_case_256_1),
18529 		TEST_CASE_ST(ut_setup, ut_teardown,
18530 			test_AES_CCM_authenticated_encryption_test_case_256_2),
18531 		TEST_CASE_ST(ut_setup, ut_teardown,
18532 			test_AES_CCM_authenticated_encryption_test_case_256_3),
18533 
18534 		/** AES CCM Authenticated Decryption 256 bits key*/
18535 		TEST_CASE_ST(ut_setup, ut_teardown,
18536 			test_AES_CCM_authenticated_decryption_test_case_256_1),
18537 		TEST_CASE_ST(ut_setup, ut_teardown,
18538 			test_AES_CCM_authenticated_decryption_test_case_256_2),
18539 		TEST_CASE_ST(ut_setup, ut_teardown,
18540 			test_AES_CCM_authenticated_decryption_test_case_256_3),
18541 		TEST_CASES_END()
18542 	}
18543 };
18544 
18545 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
18546 	.suite_name = "AES GCM Authenticated Test Suite",
18547 	.setup = aes_gcm_auth_testsuite_setup,
18548 	.unit_test_cases = {
18549 		/** AES GCM Authenticated Encryption */
18550 		TEST_CASE_ST(ut_setup, ut_teardown,
18551 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
18552 		TEST_CASE_ST(ut_setup, ut_teardown,
18553 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
18554 		TEST_CASE_ST(ut_setup, ut_teardown,
18555 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
18556 		TEST_CASE_ST(ut_setup, ut_teardown,
18557 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
18558 		TEST_CASE_ST(ut_setup, ut_teardown,
18559 			test_AES_GCM_authenticated_encryption_test_case_1),
18560 		TEST_CASE_ST(ut_setup, ut_teardown,
18561 			test_AES_GCM_authenticated_encryption_test_case_2),
18562 		TEST_CASE_ST(ut_setup, ut_teardown,
18563 			test_AES_GCM_authenticated_encryption_test_case_3),
18564 		TEST_CASE_ST(ut_setup, ut_teardown,
18565 			test_AES_GCM_authenticated_encryption_test_case_4),
18566 		TEST_CASE_ST(ut_setup, ut_teardown,
18567 			test_AES_GCM_authenticated_encryption_test_case_5),
18568 		TEST_CASE_ST(ut_setup, ut_teardown,
18569 			test_AES_GCM_authenticated_encryption_test_case_6),
18570 		TEST_CASE_ST(ut_setup, ut_teardown,
18571 			test_AES_GCM_authenticated_encryption_test_case_7),
18572 		TEST_CASE_ST(ut_setup, ut_teardown,
18573 			test_AES_GCM_authenticated_encryption_test_case_8),
18574 		TEST_CASE_ST(ut_setup, ut_teardown,
18575 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
18576 
18577 		/** AES GCM Authenticated Decryption */
18578 		TEST_CASE_ST(ut_setup, ut_teardown,
18579 			test_AES_GCM_authenticated_decryption_test_case_1),
18580 		TEST_CASE_ST(ut_setup, ut_teardown,
18581 			test_AES_GCM_authenticated_decryption_test_case_2),
18582 		TEST_CASE_ST(ut_setup, ut_teardown,
18583 			test_AES_GCM_authenticated_decryption_test_case_3),
18584 		TEST_CASE_ST(ut_setup, ut_teardown,
18585 			test_AES_GCM_authenticated_decryption_test_case_4),
18586 		TEST_CASE_ST(ut_setup, ut_teardown,
18587 			test_AES_GCM_authenticated_decryption_test_case_5),
18588 		TEST_CASE_ST(ut_setup, ut_teardown,
18589 			test_AES_GCM_authenticated_decryption_test_case_6),
18590 		TEST_CASE_ST(ut_setup, ut_teardown,
18591 			test_AES_GCM_authenticated_decryption_test_case_7),
18592 		TEST_CASE_ST(ut_setup, ut_teardown,
18593 			test_AES_GCM_authenticated_decryption_test_case_8),
18594 		TEST_CASE_ST(ut_setup, ut_teardown,
18595 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
18596 
18597 		/** AES GCM Authenticated Encryption 192 bits key */
18598 		TEST_CASE_ST(ut_setup, ut_teardown,
18599 			test_AES_GCM_auth_encryption_test_case_192_1),
18600 		TEST_CASE_ST(ut_setup, ut_teardown,
18601 			test_AES_GCM_auth_encryption_test_case_192_2),
18602 		TEST_CASE_ST(ut_setup, ut_teardown,
18603 			test_AES_GCM_auth_encryption_test_case_192_3),
18604 		TEST_CASE_ST(ut_setup, ut_teardown,
18605 			test_AES_GCM_auth_encryption_test_case_192_4),
18606 		TEST_CASE_ST(ut_setup, ut_teardown,
18607 			test_AES_GCM_auth_encryption_test_case_192_5),
18608 		TEST_CASE_ST(ut_setup, ut_teardown,
18609 			test_AES_GCM_auth_encryption_test_case_192_6),
18610 		TEST_CASE_ST(ut_setup, ut_teardown,
18611 			test_AES_GCM_auth_encryption_test_case_192_7),
18612 
18613 		/** AES GCM Authenticated Decryption 192 bits key */
18614 		TEST_CASE_ST(ut_setup, ut_teardown,
18615 			test_AES_GCM_auth_decryption_test_case_192_1),
18616 		TEST_CASE_ST(ut_setup, ut_teardown,
18617 			test_AES_GCM_auth_decryption_test_case_192_2),
18618 		TEST_CASE_ST(ut_setup, ut_teardown,
18619 			test_AES_GCM_auth_decryption_test_case_192_3),
18620 		TEST_CASE_ST(ut_setup, ut_teardown,
18621 			test_AES_GCM_auth_decryption_test_case_192_4),
18622 		TEST_CASE_ST(ut_setup, ut_teardown,
18623 			test_AES_GCM_auth_decryption_test_case_192_5),
18624 		TEST_CASE_ST(ut_setup, ut_teardown,
18625 			test_AES_GCM_auth_decryption_test_case_192_6),
18626 		TEST_CASE_ST(ut_setup, ut_teardown,
18627 			test_AES_GCM_auth_decryption_test_case_192_7),
18628 
18629 		/** AES GCM Authenticated Encryption 256 bits key */
18630 		TEST_CASE_ST(ut_setup, ut_teardown,
18631 			test_AES_GCM_auth_encryption_test_case_256_1),
18632 		TEST_CASE_ST(ut_setup, ut_teardown,
18633 			test_AES_GCM_auth_encryption_test_case_256_2),
18634 		TEST_CASE_ST(ut_setup, ut_teardown,
18635 			test_AES_GCM_auth_encryption_test_case_256_3),
18636 		TEST_CASE_ST(ut_setup, ut_teardown,
18637 			test_AES_GCM_auth_encryption_test_case_256_4),
18638 		TEST_CASE_ST(ut_setup, ut_teardown,
18639 			test_AES_GCM_auth_encryption_test_case_256_5),
18640 		TEST_CASE_ST(ut_setup, ut_teardown,
18641 			test_AES_GCM_auth_encryption_test_case_256_6),
18642 		TEST_CASE_ST(ut_setup, ut_teardown,
18643 			test_AES_GCM_auth_encryption_test_case_256_7),
18644 		TEST_CASE_ST(ut_setup, ut_teardown,
18645 			test_AES_GCM_auth_encryption_test_case_256_8),
18646 
18647 		/** AES GCM Authenticated Decryption 256 bits key */
18648 		TEST_CASE_ST(ut_setup, ut_teardown,
18649 			test_AES_GCM_auth_decryption_test_case_256_1),
18650 		TEST_CASE_ST(ut_setup, ut_teardown,
18651 			test_AES_GCM_auth_decryption_test_case_256_2),
18652 		TEST_CASE_ST(ut_setup, ut_teardown,
18653 			test_AES_GCM_auth_decryption_test_case_256_3),
18654 		TEST_CASE_ST(ut_setup, ut_teardown,
18655 			test_AES_GCM_auth_decryption_test_case_256_4),
18656 		TEST_CASE_ST(ut_setup, ut_teardown,
18657 			test_AES_GCM_auth_decryption_test_case_256_5),
18658 		TEST_CASE_ST(ut_setup, ut_teardown,
18659 			test_AES_GCM_auth_decryption_test_case_256_6),
18660 		TEST_CASE_ST(ut_setup, ut_teardown,
18661 			test_AES_GCM_auth_decryption_test_case_256_7),
18662 		TEST_CASE_ST(ut_setup, ut_teardown,
18663 			test_AES_GCM_auth_decryption_test_case_256_8),
18664 
18665 		/** AES GCM Authenticated Encryption big aad size */
18666 		TEST_CASE_ST(ut_setup, ut_teardown,
18667 			test_AES_GCM_auth_encryption_test_case_aad_1),
18668 		TEST_CASE_ST(ut_setup, ut_teardown,
18669 			test_AES_GCM_auth_encryption_test_case_aad_2),
18670 
18671 		/** AES GCM Authenticated Decryption big aad size */
18672 		TEST_CASE_ST(ut_setup, ut_teardown,
18673 			test_AES_GCM_auth_decryption_test_case_aad_1),
18674 		TEST_CASE_ST(ut_setup, ut_teardown,
18675 			test_AES_GCM_auth_decryption_test_case_aad_2),
18676 
18677 		/** Out of place tests */
18678 		TEST_CASE_ST(ut_setup, ut_teardown,
18679 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
18680 		TEST_CASE_ST(ut_setup, ut_teardown,
18681 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
18682 
18683 		/** Session-less tests */
18684 		TEST_CASE_ST(ut_setup, ut_teardown,
18685 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
18686 		TEST_CASE_ST(ut_setup, ut_teardown,
18687 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
18688 
18689 		/** AES GCM external mbuf tests */
18690 		TEST_CASE_ST(ut_setup, ut_teardown,
18691 			test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
18692 		TEST_CASE_ST(ut_setup, ut_teardown,
18693 			test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
18694 
18695 		TEST_CASES_END()
18696 	}
18697 };
18698 
18699 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
18700 	.suite_name = "AES GMAC Authentication Test Suite",
18701 	.setup = aes_gmac_auth_testsuite_setup,
18702 	.unit_test_cases = {
18703 		TEST_CASE_ST(ut_setup, ut_teardown,
18704 			test_AES_GMAC_authentication_test_case_1),
18705 		TEST_CASE_ST(ut_setup, ut_teardown,
18706 			test_AES_GMAC_authentication_verify_test_case_1),
18707 		TEST_CASE_ST(ut_setup, ut_teardown,
18708 			test_AES_GMAC_authentication_test_case_2),
18709 		TEST_CASE_ST(ut_setup, ut_teardown,
18710 			test_AES_GMAC_authentication_verify_test_case_2),
18711 		TEST_CASE_ST(ut_setup, ut_teardown,
18712 			test_AES_GMAC_authentication_test_case_3),
18713 		TEST_CASE_ST(ut_setup, ut_teardown,
18714 			test_AES_GMAC_authentication_verify_test_case_3),
18715 		TEST_CASE_ST(ut_setup, ut_teardown,
18716 			test_AES_GMAC_authentication_test_case_4),
18717 		TEST_CASE_ST(ut_setup, ut_teardown,
18718 			test_AES_GMAC_authentication_verify_test_case_4),
18719 		TEST_CASE_ST(ut_setup, ut_teardown,
18720 			test_AES_GMAC_authentication_SGL_40B),
18721 		TEST_CASE_ST(ut_setup, ut_teardown,
18722 			test_AES_GMAC_authentication_SGL_80B),
18723 		TEST_CASE_ST(ut_setup, ut_teardown,
18724 			test_AES_GMAC_authentication_SGL_2048B),
18725 		TEST_CASE_ST(ut_setup, ut_teardown,
18726 			test_AES_GMAC_authentication_SGL_2047B),
18727 
18728 		TEST_CASES_END()
18729 	}
18730 };
18731 
18732 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
18733 	.suite_name = "Chacha20-Poly1305 Test Suite",
18734 	.setup = chacha20_poly1305_testsuite_setup,
18735 	.unit_test_cases = {
18736 		TEST_CASE_ST(ut_setup, ut_teardown,
18737 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
18738 		TEST_CASE_ST(ut_setup, ut_teardown,
18739 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
18740 		TEST_CASE_ST(ut_setup, ut_teardown,
18741 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
18742 		TEST_CASES_END()
18743 	}
18744 };
18745 
18746 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
18747 	.suite_name = "SNOW 3G Test Suite",
18748 	.setup = snow3g_testsuite_setup,
18749 	.unit_test_cases = {
18750 		/** SNOW 3G encrypt only (UEA2) */
18751 		TEST_CASE_ST(ut_setup, ut_teardown,
18752 			test_snow3g_encryption_test_case_1),
18753 		TEST_CASE_ST(ut_setup, ut_teardown,
18754 			test_snow3g_encryption_test_case_2),
18755 		TEST_CASE_ST(ut_setup, ut_teardown,
18756 			test_snow3g_encryption_test_case_3),
18757 		TEST_CASE_ST(ut_setup, ut_teardown,
18758 			test_snow3g_encryption_test_case_4),
18759 		TEST_CASE_ST(ut_setup, ut_teardown,
18760 			test_snow3g_encryption_test_case_5),
18761 
18762 		TEST_CASE_ST(ut_setup, ut_teardown,
18763 			test_snow3g_encryption_test_case_1_oop),
18764 		TEST_CASE_ST(ut_setup, ut_teardown,
18765 			test_snow3g_encryption_test_case_1_oop_sgl),
18766 		TEST_CASE_ST(ut_setup, ut_teardown,
18767 			test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
18768 		TEST_CASE_ST(ut_setup, ut_teardown,
18769 			test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
18770 		TEST_CASE_ST(ut_setup, ut_teardown,
18771 			test_snow3g_encryption_test_case_1_offset_oop),
18772 		TEST_CASE_ST(ut_setup, ut_teardown,
18773 			test_snow3g_decryption_test_case_1_oop),
18774 
18775 		/** SNOW 3G generate auth, then encrypt (UEA2) */
18776 		TEST_CASE_ST(ut_setup, ut_teardown,
18777 			test_snow3g_auth_cipher_test_case_1),
18778 		TEST_CASE_ST(ut_setup, ut_teardown,
18779 			test_snow3g_auth_cipher_test_case_2),
18780 		TEST_CASE_ST(ut_setup, ut_teardown,
18781 			test_snow3g_auth_cipher_test_case_2_oop),
18782 		TEST_CASE_ST(ut_setup, ut_teardown,
18783 			test_snow3g_auth_cipher_part_digest_enc),
18784 		TEST_CASE_ST(ut_setup, ut_teardown,
18785 			test_snow3g_auth_cipher_part_digest_enc_oop),
18786 		TEST_CASE_ST(ut_setup, ut_teardown,
18787 			test_snow3g_auth_cipher_test_case_3_sgl),
18788 		TEST_CASE_ST(ut_setup, ut_teardown,
18789 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
18790 		TEST_CASE_ST(ut_setup, ut_teardown,
18791 			test_snow3g_auth_cipher_part_digest_enc_sgl),
18792 		TEST_CASE_ST(ut_setup, ut_teardown,
18793 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
18794 		TEST_CASE_ST(ut_setup, ut_teardown,
18795 			test_snow3g_auth_cipher_total_digest_enc_1),
18796 		TEST_CASE_ST(ut_setup, ut_teardown,
18797 			test_snow3g_auth_cipher_total_digest_enc_1_oop),
18798 		TEST_CASE_ST(ut_setup, ut_teardown,
18799 			test_snow3g_auth_cipher_total_digest_enc_1_sgl),
18800 		TEST_CASE_ST(ut_setup, ut_teardown,
18801 			test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
18802 
18803 		/** SNOW 3G decrypt (UEA2), then verify auth */
18804 		TEST_CASE_ST(ut_setup, ut_teardown,
18805 			test_snow3g_auth_cipher_verify_test_case_1),
18806 		TEST_CASE_ST(ut_setup, ut_teardown,
18807 			test_snow3g_auth_cipher_verify_test_case_2),
18808 		TEST_CASE_ST(ut_setup, ut_teardown,
18809 			test_snow3g_auth_cipher_verify_test_case_2_oop),
18810 		TEST_CASE_ST(ut_setup, ut_teardown,
18811 			test_snow3g_auth_cipher_verify_part_digest_enc),
18812 		TEST_CASE_ST(ut_setup, ut_teardown,
18813 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
18814 		TEST_CASE_ST(ut_setup, ut_teardown,
18815 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
18816 		TEST_CASE_ST(ut_setup, ut_teardown,
18817 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
18818 		TEST_CASE_ST(ut_setup, ut_teardown,
18819 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
18820 		TEST_CASE_ST(ut_setup, ut_teardown,
18821 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
18822 		TEST_CASE_ST(ut_setup, ut_teardown,
18823 			test_snow3g_auth_cipher_verify_total_digest_enc_1),
18824 		TEST_CASE_ST(ut_setup, ut_teardown,
18825 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
18826 		TEST_CASE_ST(ut_setup, ut_teardown,
18827 			test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
18828 		TEST_CASE_ST(ut_setup, ut_teardown,
18829 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
18830 
18831 		/** SNOW 3G decrypt only (UEA2) */
18832 		TEST_CASE_ST(ut_setup, ut_teardown,
18833 			test_snow3g_decryption_test_case_1),
18834 		TEST_CASE_ST(ut_setup, ut_teardown,
18835 			test_snow3g_decryption_test_case_2),
18836 		TEST_CASE_ST(ut_setup, ut_teardown,
18837 			test_snow3g_decryption_test_case_3),
18838 		TEST_CASE_ST(ut_setup, ut_teardown,
18839 			test_snow3g_decryption_test_case_4),
18840 		TEST_CASE_ST(ut_setup, ut_teardown,
18841 			test_snow3g_decryption_test_case_5),
18842 		TEST_CASE_ST(ut_setup, ut_teardown,
18843 			test_snow3g_decryption_with_digest_test_case_1),
18844 		TEST_CASE_ST(ut_setup, ut_teardown,
18845 			test_snow3g_hash_generate_test_case_1),
18846 		TEST_CASE_ST(ut_setup, ut_teardown,
18847 			test_snow3g_hash_generate_test_case_2),
18848 		TEST_CASE_ST(ut_setup, ut_teardown,
18849 			test_snow3g_hash_generate_test_case_3),
18850 
18851 		/* Tests with buffers which length is not byte-aligned */
18852 		TEST_CASE_ST(ut_setup, ut_teardown,
18853 			test_snow3g_hash_generate_test_case_4),
18854 		TEST_CASE_ST(ut_setup, ut_teardown,
18855 			test_snow3g_hash_generate_test_case_5),
18856 		TEST_CASE_ST(ut_setup, ut_teardown,
18857 			test_snow3g_hash_generate_test_case_6),
18858 		TEST_CASE_ST(ut_setup, ut_teardown,
18859 			test_snow3g_hash_verify_test_case_1),
18860 		TEST_CASE_ST(ut_setup, ut_teardown,
18861 			test_snow3g_hash_verify_test_case_2),
18862 		TEST_CASE_ST(ut_setup, ut_teardown,
18863 			test_snow3g_hash_verify_test_case_3),
18864 
18865 		/* Tests with buffers which length is not byte-aligned */
18866 		TEST_CASE_ST(ut_setup, ut_teardown,
18867 			test_snow3g_hash_verify_test_case_4),
18868 		TEST_CASE_ST(ut_setup, ut_teardown,
18869 			test_snow3g_hash_verify_test_case_5),
18870 		TEST_CASE_ST(ut_setup, ut_teardown,
18871 			test_snow3g_hash_verify_test_case_6),
18872 		TEST_CASE_ST(ut_setup, ut_teardown,
18873 			test_snow3g_cipher_auth_test_case_1),
18874 		TEST_CASE_ST(ut_setup, ut_teardown,
18875 			test_snow3g_auth_cipher_with_digest_test_case_1),
18876 		TEST_CASES_END()
18877 	}
18878 };
18879 
18880 static struct unit_test_suite cryptodev_zuc_testsuite  = {
18881 	.suite_name = "ZUC Test Suite",
18882 	.setup = zuc_testsuite_setup,
18883 	.unit_test_cases = {
18884 		/** ZUC encrypt only (EEA3) */
18885 		TEST_CASE_ST(ut_setup, ut_teardown,
18886 			test_zuc_encryption_test_case_1),
18887 		TEST_CASE_ST(ut_setup, ut_teardown,
18888 			test_zuc_encryption_test_case_2),
18889 		TEST_CASE_ST(ut_setup, ut_teardown,
18890 			test_zuc_encryption_test_case_3),
18891 		TEST_CASE_ST(ut_setup, ut_teardown,
18892 			test_zuc_encryption_test_case_4),
18893 		TEST_CASE_ST(ut_setup, ut_teardown,
18894 			test_zuc_encryption_test_case_5),
18895 		TEST_CASE_ST(ut_setup, ut_teardown,
18896 			test_zuc_encryption_test_case_6_sgl),
18897 
18898 		/** ZUC decrypt only (EEA3) */
18899 		TEST_CASE_ST(ut_setup, ut_teardown,
18900 			test_zuc_decryption_test_case_1),
18901 		TEST_CASE_ST(ut_setup, ut_teardown,
18902 			test_zuc_decryption_test_case_2),
18903 		TEST_CASE_ST(ut_setup, ut_teardown,
18904 			test_zuc_decryption_test_case_3),
18905 		TEST_CASE_ST(ut_setup, ut_teardown,
18906 			test_zuc_decryption_test_case_4),
18907 		TEST_CASE_ST(ut_setup, ut_teardown,
18908 			test_zuc_decryption_test_case_5),
18909 		TEST_CASE_ST(ut_setup, ut_teardown,
18910 			test_zuc_decryption_test_case_6_sgl),
18911 
18912 		/** ZUC authenticate (EIA3) */
18913 		TEST_CASE_ST(ut_setup, ut_teardown,
18914 			test_zuc_hash_generate_test_case_1),
18915 		TEST_CASE_ST(ut_setup, ut_teardown,
18916 			test_zuc_hash_generate_test_case_2),
18917 		TEST_CASE_ST(ut_setup, ut_teardown,
18918 			test_zuc_hash_generate_test_case_3),
18919 		TEST_CASE_ST(ut_setup, ut_teardown,
18920 			test_zuc_hash_generate_test_case_4),
18921 		TEST_CASE_ST(ut_setup, ut_teardown,
18922 			test_zuc_hash_generate_test_case_5),
18923 		TEST_CASE_ST(ut_setup, ut_teardown,
18924 			test_zuc_hash_generate_test_case_6),
18925 		TEST_CASE_ST(ut_setup, ut_teardown,
18926 			test_zuc_hash_generate_test_case_7),
18927 		TEST_CASE_ST(ut_setup, ut_teardown,
18928 			test_zuc_hash_generate_test_case_8),
18929 
18930 		/** ZUC verify (EIA3) */
18931 		TEST_CASE_ST(ut_setup, ut_teardown,
18932 			test_zuc_hash_verify_test_case_1),
18933 		TEST_CASE_ST(ut_setup, ut_teardown,
18934 			test_zuc_hash_verify_test_case_2),
18935 		TEST_CASE_ST(ut_setup, ut_teardown,
18936 			test_zuc_hash_verify_test_case_3),
18937 		TEST_CASE_ST(ut_setup, ut_teardown,
18938 			test_zuc_hash_verify_test_case_4),
18939 		TEST_CASE_ST(ut_setup, ut_teardown,
18940 			test_zuc_hash_verify_test_case_5),
18941 		TEST_CASE_ST(ut_setup, ut_teardown,
18942 			test_zuc_hash_verify_test_case_6),
18943 		TEST_CASE_ST(ut_setup, ut_teardown,
18944 			test_zuc_hash_verify_test_case_7),
18945 		TEST_CASE_ST(ut_setup, ut_teardown,
18946 			test_zuc_hash_verify_test_case_8),
18947 
18948 		/** ZUC alg-chain (EEA3/EIA3) */
18949 		TEST_CASE_ST(ut_setup, ut_teardown,
18950 			test_zuc_cipher_auth_test_case_1),
18951 		TEST_CASE_ST(ut_setup, ut_teardown,
18952 			test_zuc_cipher_auth_test_case_2),
18953 
18954 		/** ZUC generate auth, then encrypt (EEA3) */
18955 		TEST_CASE_ST(ut_setup, ut_teardown,
18956 			test_zuc_auth_cipher_test_case_1),
18957 		TEST_CASE_ST(ut_setup, ut_teardown,
18958 			test_zuc_auth_cipher_test_case_1_oop),
18959 		TEST_CASE_ST(ut_setup, ut_teardown,
18960 			test_zuc_auth_cipher_test_case_1_sgl),
18961 		TEST_CASE_ST(ut_setup, ut_teardown,
18962 			test_zuc_auth_cipher_test_case_1_oop_sgl),
18963 		TEST_CASE_ST(ut_setup, ut_teardown,
18964 			test_zuc_auth_cipher_test_case_2),
18965 		TEST_CASE_ST(ut_setup, ut_teardown,
18966 			test_zuc_auth_cipher_test_case_2_oop),
18967 
18968 		/** ZUC decrypt (EEA3), then verify auth */
18969 		TEST_CASE_ST(ut_setup, ut_teardown,
18970 			test_zuc_auth_cipher_verify_test_case_1),
18971 		TEST_CASE_ST(ut_setup, ut_teardown,
18972 			test_zuc_auth_cipher_verify_test_case_1_oop),
18973 		TEST_CASE_ST(ut_setup, ut_teardown,
18974 			test_zuc_auth_cipher_verify_test_case_1_sgl),
18975 		TEST_CASE_ST(ut_setup, ut_teardown,
18976 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
18977 		TEST_CASE_ST(ut_setup, ut_teardown,
18978 			test_zuc_auth_cipher_verify_test_case_2),
18979 		TEST_CASE_ST(ut_setup, ut_teardown,
18980 			test_zuc_auth_cipher_verify_test_case_2_oop),
18981 
18982 		/** ZUC-256 encrypt only **/
18983 		TEST_CASE_ST(ut_setup, ut_teardown,
18984 			test_zuc256_encryption_test_case_1),
18985 		TEST_CASE_ST(ut_setup, ut_teardown,
18986 			test_zuc256_encryption_test_case_2),
18987 
18988 		/** ZUC-256 decrypt only **/
18989 		TEST_CASE_ST(ut_setup, ut_teardown,
18990 			test_zuc256_decryption_test_case_1),
18991 		TEST_CASE_ST(ut_setup, ut_teardown,
18992 			test_zuc256_decryption_test_case_2),
18993 
18994 		/** ZUC-256 authentication only **/
18995 		TEST_CASE_ST(ut_setup, ut_teardown,
18996 			test_zuc256_hash_generate_4b_tag_test_case_1),
18997 		TEST_CASE_ST(ut_setup, ut_teardown,
18998 			test_zuc256_hash_generate_4b_tag_test_case_2),
18999 		TEST_CASE_ST(ut_setup, ut_teardown,
19000 			test_zuc256_hash_generate_4b_tag_test_case_3),
19001 		TEST_CASE_ST(ut_setup, ut_teardown,
19002 			test_zuc256_hash_generate_8b_tag_test_case_1),
19003 		TEST_CASE_ST(ut_setup, ut_teardown,
19004 			test_zuc256_hash_generate_16b_tag_test_case_1),
19005 
19006 		/** ZUC-256 authentication verify only **/
19007 		TEST_CASE_ST(ut_setup, ut_teardown,
19008 			test_zuc256_hash_verify_4b_tag_test_case_1),
19009 		TEST_CASE_ST(ut_setup, ut_teardown,
19010 			test_zuc256_hash_verify_4b_tag_test_case_2),
19011 		TEST_CASE_ST(ut_setup, ut_teardown,
19012 			test_zuc256_hash_verify_4b_tag_test_case_3),
19013 		TEST_CASE_ST(ut_setup, ut_teardown,
19014 			test_zuc256_hash_verify_8b_tag_test_case_1),
19015 		TEST_CASE_ST(ut_setup, ut_teardown,
19016 			test_zuc256_hash_verify_16b_tag_test_case_1),
19017 
19018 		/** ZUC-256 encrypt and authenticate **/
19019 		TEST_CASE_ST(ut_setup, ut_teardown,
19020 			test_zuc256_cipher_auth_4b_tag_test_case_1),
19021 		TEST_CASE_ST(ut_setup, ut_teardown,
19022 			test_zuc256_cipher_auth_4b_tag_test_case_2),
19023 		TEST_CASE_ST(ut_setup, ut_teardown,
19024 			test_zuc256_cipher_auth_8b_tag_test_case_1),
19025 		TEST_CASE_ST(ut_setup, ut_teardown,
19026 			test_zuc256_cipher_auth_16b_tag_test_case_1),
19027 
19028 		/** ZUC-256 generate auth, then encrypt */
19029 		TEST_CASE_ST(ut_setup, ut_teardown,
19030 			test_zuc256_auth_cipher_4b_tag_test_case_1),
19031 		TEST_CASE_ST(ut_setup, ut_teardown,
19032 			test_zuc256_auth_cipher_4b_tag_test_case_2),
19033 		TEST_CASE_ST(ut_setup, ut_teardown,
19034 			test_zuc256_auth_cipher_8b_tag_test_case_1),
19035 		TEST_CASE_ST(ut_setup, ut_teardown,
19036 			test_zuc256_auth_cipher_16b_tag_test_case_1),
19037 
19038 		/** ZUC-256 decrypt, then verify auth */
19039 		TEST_CASE_ST(ut_setup, ut_teardown,
19040 			test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19041 		TEST_CASE_ST(ut_setup, ut_teardown,
19042 			test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19043 		TEST_CASE_ST(ut_setup, ut_teardown,
19044 			test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19045 		TEST_CASE_ST(ut_setup, ut_teardown,
19046 			test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19047 
19048 		TEST_CASES_END()
19049 	}
19050 };
19051 
19052 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
19053 	.suite_name = "HMAC_MD5 Authentication Test Suite",
19054 	.setup = hmac_md5_auth_testsuite_setup,
19055 	.unit_test_cases = {
19056 		TEST_CASE_ST(ut_setup, ut_teardown,
19057 			test_MD5_HMAC_generate_case_1),
19058 		TEST_CASE_ST(ut_setup, ut_teardown,
19059 			test_MD5_HMAC_verify_case_1),
19060 		TEST_CASE_ST(ut_setup, ut_teardown,
19061 			test_MD5_HMAC_generate_case_2),
19062 		TEST_CASE_ST(ut_setup, ut_teardown,
19063 			test_MD5_HMAC_verify_case_2),
19064 		TEST_CASES_END()
19065 	}
19066 };
19067 
19068 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
19069 	.suite_name = "Kasumi Test Suite",
19070 	.setup = kasumi_testsuite_setup,
19071 	.unit_test_cases = {
19072 		/** KASUMI hash only (UIA1) */
19073 		TEST_CASE_ST(ut_setup, ut_teardown,
19074 			test_kasumi_hash_generate_test_case_1),
19075 		TEST_CASE_ST(ut_setup, ut_teardown,
19076 			test_kasumi_hash_generate_test_case_2),
19077 		TEST_CASE_ST(ut_setup, ut_teardown,
19078 			test_kasumi_hash_generate_test_case_3),
19079 		TEST_CASE_ST(ut_setup, ut_teardown,
19080 			test_kasumi_hash_generate_test_case_4),
19081 		TEST_CASE_ST(ut_setup, ut_teardown,
19082 			test_kasumi_hash_generate_test_case_5),
19083 		TEST_CASE_ST(ut_setup, ut_teardown,
19084 			test_kasumi_hash_generate_test_case_6),
19085 
19086 		TEST_CASE_ST(ut_setup, ut_teardown,
19087 			test_kasumi_hash_verify_test_case_1),
19088 		TEST_CASE_ST(ut_setup, ut_teardown,
19089 			test_kasumi_hash_verify_test_case_2),
19090 		TEST_CASE_ST(ut_setup, ut_teardown,
19091 			test_kasumi_hash_verify_test_case_3),
19092 		TEST_CASE_ST(ut_setup, ut_teardown,
19093 			test_kasumi_hash_verify_test_case_4),
19094 		TEST_CASE_ST(ut_setup, ut_teardown,
19095 			test_kasumi_hash_verify_test_case_5),
19096 
19097 		/** KASUMI encrypt only (UEA1) */
19098 		TEST_CASE_ST(ut_setup, ut_teardown,
19099 			test_kasumi_encryption_test_case_1),
19100 		TEST_CASE_ST(ut_setup, ut_teardown,
19101 			test_kasumi_encryption_test_case_1_sgl),
19102 		TEST_CASE_ST(ut_setup, ut_teardown,
19103 			test_kasumi_encryption_test_case_1_oop),
19104 		TEST_CASE_ST(ut_setup, ut_teardown,
19105 			test_kasumi_encryption_test_case_1_oop_sgl),
19106 		TEST_CASE_ST(ut_setup, ut_teardown,
19107 			test_kasumi_encryption_test_case_2),
19108 		TEST_CASE_ST(ut_setup, ut_teardown,
19109 			test_kasumi_encryption_test_case_3),
19110 		TEST_CASE_ST(ut_setup, ut_teardown,
19111 			test_kasumi_encryption_test_case_4),
19112 		TEST_CASE_ST(ut_setup, ut_teardown,
19113 			test_kasumi_encryption_test_case_5),
19114 
19115 		/** KASUMI decrypt only (UEA1) */
19116 		TEST_CASE_ST(ut_setup, ut_teardown,
19117 			test_kasumi_decryption_test_case_1),
19118 		TEST_CASE_ST(ut_setup, ut_teardown,
19119 			test_kasumi_decryption_test_case_2),
19120 		TEST_CASE_ST(ut_setup, ut_teardown,
19121 			test_kasumi_decryption_test_case_3),
19122 		TEST_CASE_ST(ut_setup, ut_teardown,
19123 			test_kasumi_decryption_test_case_4),
19124 		TEST_CASE_ST(ut_setup, ut_teardown,
19125 			test_kasumi_decryption_test_case_5),
19126 		TEST_CASE_ST(ut_setup, ut_teardown,
19127 			test_kasumi_decryption_test_case_1_oop),
19128 		TEST_CASE_ST(ut_setup, ut_teardown,
19129 			test_kasumi_cipher_auth_test_case_1),
19130 
19131 		/** KASUMI generate auth, then encrypt (F8) */
19132 		TEST_CASE_ST(ut_setup, ut_teardown,
19133 			test_kasumi_auth_cipher_test_case_1),
19134 		TEST_CASE_ST(ut_setup, ut_teardown,
19135 			test_kasumi_auth_cipher_test_case_2),
19136 		TEST_CASE_ST(ut_setup, ut_teardown,
19137 			test_kasumi_auth_cipher_test_case_2_oop),
19138 		TEST_CASE_ST(ut_setup, ut_teardown,
19139 			test_kasumi_auth_cipher_test_case_2_sgl),
19140 		TEST_CASE_ST(ut_setup, ut_teardown,
19141 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
19142 
19143 		/** KASUMI decrypt (F8), then verify auth */
19144 		TEST_CASE_ST(ut_setup, ut_teardown,
19145 			test_kasumi_auth_cipher_verify_test_case_1),
19146 		TEST_CASE_ST(ut_setup, ut_teardown,
19147 			test_kasumi_auth_cipher_verify_test_case_2),
19148 		TEST_CASE_ST(ut_setup, ut_teardown,
19149 			test_kasumi_auth_cipher_verify_test_case_2_oop),
19150 		TEST_CASE_ST(ut_setup, ut_teardown,
19151 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
19152 		TEST_CASE_ST(ut_setup, ut_teardown,
19153 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19154 
19155 		TEST_CASES_END()
19156 	}
19157 };
19158 
19159 static struct unit_test_suite cryptodev_esn_testsuite  = {
19160 	.suite_name = "ESN Test Suite",
19161 	.setup = esn_testsuite_setup,
19162 	.unit_test_cases = {
19163 		TEST_CASE_ST(ut_setup, ut_teardown,
19164 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19165 		TEST_CASE_ST(ut_setup, ut_teardown,
19166 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19167 		TEST_CASES_END()
19168 	}
19169 };
19170 
19171 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
19172 	.suite_name = "Negative AES GCM Test Suite",
19173 	.setup = negative_aes_gcm_testsuite_setup,
19174 	.unit_test_cases = {
19175 		TEST_CASE_ST(ut_setup, ut_teardown,
19176 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
19177 		TEST_CASE_ST(ut_setup, ut_teardown,
19178 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19179 		TEST_CASE_ST(ut_setup, ut_teardown,
19180 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19181 		TEST_CASE_ST(ut_setup, ut_teardown,
19182 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19183 		TEST_CASE_ST(ut_setup, ut_teardown,
19184 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
19185 		TEST_CASE_ST(ut_setup, ut_teardown,
19186 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
19187 		TEST_CASE_ST(ut_setup, ut_teardown,
19188 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
19189 		TEST_CASE_ST(ut_setup, ut_teardown,
19190 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19191 		TEST_CASE_ST(ut_setup, ut_teardown,
19192 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19193 		TEST_CASE_ST(ut_setup, ut_teardown,
19194 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19195 		TEST_CASE_ST(ut_setup, ut_teardown,
19196 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
19197 		TEST_CASE_ST(ut_setup, ut_teardown,
19198 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
19199 
19200 		TEST_CASES_END()
19201 	}
19202 };
19203 
19204 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
19205 	.suite_name = "Negative AES GMAC Test Suite",
19206 	.setup = negative_aes_gmac_testsuite_setup,
19207 	.unit_test_cases = {
19208 		TEST_CASE_ST(ut_setup, ut_teardown,
19209 			authentication_verify_AES128_GMAC_fail_data_corrupt),
19210 		TEST_CASE_ST(ut_setup, ut_teardown,
19211 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
19212 
19213 		TEST_CASES_END()
19214 	}
19215 };
19216 
19217 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
19218 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19219 	.setup = mixed_cipher_hash_testsuite_setup,
19220 	.unit_test_cases = {
19221 		/** AUTH AES CMAC + CIPHER AES CTR */
19222 		TEST_CASE_ST(ut_setup, ut_teardown,
19223 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19224 		TEST_CASE_ST(ut_setup, ut_teardown,
19225 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19226 		TEST_CASE_ST(ut_setup, ut_teardown,
19227 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19228 		TEST_CASE_ST(ut_setup, ut_teardown,
19229 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19230 		TEST_CASE_ST(ut_setup, ut_teardown,
19231 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19232 		TEST_CASE_ST(ut_setup, ut_teardown,
19233 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19234 		TEST_CASE_ST(ut_setup, ut_teardown,
19235 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19236 		TEST_CASE_ST(ut_setup, ut_teardown,
19237 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19238 		TEST_CASE_ST(ut_setup, ut_teardown,
19239 			test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19240 		TEST_CASE_ST(ut_setup, ut_teardown,
19241 			test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19242 		TEST_CASE_ST(ut_setup, ut_teardown,
19243 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19244 		TEST_CASE_ST(ut_setup, ut_teardown,
19245 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19246 
19247 		/** AUTH ZUC + CIPHER SNOW3G */
19248 		TEST_CASE_ST(ut_setup, ut_teardown,
19249 			test_auth_zuc_cipher_snow_test_case_1),
19250 		TEST_CASE_ST(ut_setup, ut_teardown,
19251 			test_verify_auth_zuc_cipher_snow_test_case_1),
19252 		TEST_CASE_ST(ut_setup, ut_teardown,
19253 			test_auth_zuc_cipher_snow_test_case_1_inplace),
19254 		TEST_CASE_ST(ut_setup, ut_teardown,
19255 			test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19256 		/** AUTH AES CMAC + CIPHER SNOW3G */
19257 		TEST_CASE_ST(ut_setup, ut_teardown,
19258 			test_auth_aes_cmac_cipher_snow_test_case_1),
19259 		TEST_CASE_ST(ut_setup, ut_teardown,
19260 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19261 		TEST_CASE_ST(ut_setup, ut_teardown,
19262 			test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19263 		TEST_CASE_ST(ut_setup, ut_teardown,
19264 			test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19265 		/** AUTH ZUC + CIPHER AES CTR */
19266 		TEST_CASE_ST(ut_setup, ut_teardown,
19267 			test_auth_zuc_cipher_aes_ctr_test_case_1),
19268 		TEST_CASE_ST(ut_setup, ut_teardown,
19269 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19270 		TEST_CASE_ST(ut_setup, ut_teardown,
19271 			test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19272 		TEST_CASE_ST(ut_setup, ut_teardown,
19273 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19274 		/** AUTH SNOW3G + CIPHER AES CTR */
19275 		TEST_CASE_ST(ut_setup, ut_teardown,
19276 			test_auth_snow_cipher_aes_ctr_test_case_1),
19277 		TEST_CASE_ST(ut_setup, ut_teardown,
19278 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19279 		TEST_CASE_ST(ut_setup, ut_teardown,
19280 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19281 		TEST_CASE_ST(ut_setup, ut_teardown,
19282 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19283 		TEST_CASE_ST(ut_setup, ut_teardown,
19284 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19285 		TEST_CASE_ST(ut_setup, ut_teardown,
19286 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19287 		/** AUTH SNOW3G + CIPHER ZUC */
19288 		TEST_CASE_ST(ut_setup, ut_teardown,
19289 			test_auth_snow_cipher_zuc_test_case_1),
19290 		TEST_CASE_ST(ut_setup, ut_teardown,
19291 			test_verify_auth_snow_cipher_zuc_test_case_1),
19292 		TEST_CASE_ST(ut_setup, ut_teardown,
19293 			test_auth_snow_cipher_zuc_test_case_1_inplace),
19294 		TEST_CASE_ST(ut_setup, ut_teardown,
19295 			test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19296 		/** AUTH AES CMAC + CIPHER ZUC */
19297 		TEST_CASE_ST(ut_setup, ut_teardown,
19298 			test_auth_aes_cmac_cipher_zuc_test_case_1),
19299 		TEST_CASE_ST(ut_setup, ut_teardown,
19300 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19301 		TEST_CASE_ST(ut_setup, ut_teardown,
19302 			test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19303 		TEST_CASE_ST(ut_setup, ut_teardown,
19304 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19305 
19306 		/** AUTH NULL + CIPHER SNOW3G */
19307 		TEST_CASE_ST(ut_setup, ut_teardown,
19308 			test_auth_null_cipher_snow_test_case_1),
19309 		TEST_CASE_ST(ut_setup, ut_teardown,
19310 			test_verify_auth_null_cipher_snow_test_case_1),
19311 		/** AUTH NULL + CIPHER ZUC */
19312 		TEST_CASE_ST(ut_setup, ut_teardown,
19313 			test_auth_null_cipher_zuc_test_case_1),
19314 		TEST_CASE_ST(ut_setup, ut_teardown,
19315 			test_verify_auth_null_cipher_zuc_test_case_1),
19316 		/** AUTH SNOW3G + CIPHER NULL */
19317 		TEST_CASE_ST(ut_setup, ut_teardown,
19318 			test_auth_snow_cipher_null_test_case_1),
19319 		TEST_CASE_ST(ut_setup, ut_teardown,
19320 			test_verify_auth_snow_cipher_null_test_case_1),
19321 		/** AUTH ZUC + CIPHER NULL */
19322 		TEST_CASE_ST(ut_setup, ut_teardown,
19323 			test_auth_zuc_cipher_null_test_case_1),
19324 		TEST_CASE_ST(ut_setup, ut_teardown,
19325 			test_verify_auth_zuc_cipher_null_test_case_1),
19326 		/** AUTH NULL + CIPHER AES CTR */
19327 		TEST_CASE_ST(ut_setup, ut_teardown,
19328 			test_auth_null_cipher_aes_ctr_test_case_1),
19329 		TEST_CASE_ST(ut_setup, ut_teardown,
19330 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
19331 		/** AUTH AES CMAC + CIPHER NULL */
19332 		TEST_CASE_ST(ut_setup, ut_teardown,
19333 			test_auth_aes_cmac_cipher_null_test_case_1),
19334 		TEST_CASE_ST(ut_setup, ut_teardown,
19335 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
19336 		TEST_CASES_END()
19337 	}
19338 };
19339 
19340 static int
19341 run_cryptodev_testsuite(const char *pmd_name)
19342 {
19343 	uint8_t ret, j, i = 0, blk_start_idx = 0;
19344 	const enum blockcipher_test_type blk_suites[] = {
19345 		BLKCIPHER_AES_CHAIN_TYPE,
19346 		BLKCIPHER_AES_CIPHERONLY_TYPE,
19347 		BLKCIPHER_AES_DOCSIS_TYPE,
19348 		BLKCIPHER_3DES_CHAIN_TYPE,
19349 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
19350 		BLKCIPHER_DES_CIPHERONLY_TYPE,
19351 		BLKCIPHER_DES_DOCSIS_TYPE,
19352 		BLKCIPHER_SM4_CHAIN_TYPE,
19353 		BLKCIPHER_SM4_CIPHERONLY_TYPE,
19354 		BLKCIPHER_AUTHONLY_TYPE};
19355 	struct unit_test_suite *static_suites[] = {
19356 		&cryptodev_multi_session_testsuite,
19357 		&cryptodev_null_testsuite,
19358 		&cryptodev_aes_ccm_auth_testsuite,
19359 		&cryptodev_aes_gcm_auth_testsuite,
19360 		&cryptodev_aes_gmac_auth_testsuite,
19361 		&cryptodev_snow3g_testsuite,
19362 		&cryptodev_chacha20_poly1305_testsuite,
19363 		&cryptodev_zuc_testsuite,
19364 		&cryptodev_hmac_md5_auth_testsuite,
19365 		&cryptodev_kasumi_testsuite,
19366 		&cryptodev_esn_testsuite,
19367 		&cryptodev_negative_aes_gcm_testsuite,
19368 		&cryptodev_negative_aes_gmac_testsuite,
19369 		&cryptodev_mixed_cipher_hash_testsuite,
19370 		&cryptodev_negative_hmac_sha1_testsuite,
19371 		&cryptodev_gen_testsuite,
19372 #ifdef RTE_LIB_SECURITY
19373 		&ipsec_proto_testsuite,
19374 		&pdcp_proto_testsuite,
19375 		&docsis_proto_testsuite,
19376 		&tls12_record_proto_testsuite,
19377 		&dtls12_record_proto_testsuite,
19378 		&tls13_record_proto_testsuite,
19379 #endif
19380 		&end_testsuite
19381 	};
19382 	static struct unit_test_suite ts = {
19383 		.suite_name = "Cryptodev Unit Test Suite",
19384 		.setup = testsuite_setup,
19385 		.teardown = testsuite_teardown,
19386 		.unit_test_cases = {TEST_CASES_END()}
19387 	};
19388 
19389 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
19390 
19391 	if (gbl_driver_id == -1) {
19392 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
19393 		return TEST_SKIPPED;
19394 	}
19395 
19396 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19397 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
19398 
19399 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
19400 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19401 	ret = unit_test_suite_runner(&ts);
19402 
19403 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
19404 	free(ts.unit_test_suites);
19405 	return ret;
19406 }
19407 
19408 static int
19409 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
19410 {
19411 	struct rte_cryptodev_info dev_info;
19412 	uint8_t i, nb_devs;
19413 	int driver_id;
19414 
19415 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
19416 	if (driver_id == -1) {
19417 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
19418 		return TEST_SKIPPED;
19419 	}
19420 
19421 	nb_devs = rte_cryptodev_count();
19422 	if (nb_devs < 1) {
19423 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
19424 		return TEST_SKIPPED;
19425 	}
19426 
19427 	for (i = 0; i < nb_devs; i++) {
19428 		rte_cryptodev_info_get(i, &dev_info);
19429 		if (dev_info.driver_id == driver_id) {
19430 			if (!(dev_info.feature_flags & flag)) {
19431 				RTE_LOG(INFO, USER1, "%s not supported\n",
19432 						flag_name);
19433 				return TEST_SKIPPED;
19434 			}
19435 			return 0; /* found */
19436 		}
19437 	}
19438 
19439 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
19440 	return TEST_SKIPPED;
19441 }
19442 
19443 static int
19444 test_cryptodev_qat(void)
19445 {
19446 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19447 }
19448 
19449 static int
19450 test_cryptodev_uadk(void)
19451 {
19452 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
19453 }
19454 
19455 static int
19456 test_cryptodev_virtio(void)
19457 {
19458 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
19459 }
19460 
19461 static int
19462 test_cryptodev_aesni_mb(void)
19463 {
19464 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19465 }
19466 
19467 static int
19468 test_cryptodev_cpu_aesni_mb(void)
19469 {
19470 	int32_t rc;
19471 	enum rte_security_session_action_type at = gbl_action_type;
19472 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19473 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19474 	gbl_action_type = at;
19475 	return rc;
19476 }
19477 
19478 static int
19479 test_cryptodev_chacha_poly_mb(void)
19480 {
19481 	int32_t rc;
19482 	enum rte_security_session_action_type at = gbl_action_type;
19483 	rc = run_cryptodev_testsuite(
19484 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
19485 	gbl_action_type = at;
19486 	return rc;
19487 }
19488 
19489 static int
19490 test_cryptodev_openssl(void)
19491 {
19492 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
19493 }
19494 
19495 static int
19496 test_cryptodev_aesni_gcm(void)
19497 {
19498 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19499 }
19500 
19501 static int
19502 test_cryptodev_cpu_aesni_gcm(void)
19503 {
19504 	int32_t rc;
19505 	enum rte_security_session_action_type at = gbl_action_type;
19506 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19507 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19508 	gbl_action_type = at;
19509 	return rc;
19510 }
19511 
19512 static int
19513 test_cryptodev_mlx5(void)
19514 {
19515 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
19516 }
19517 
19518 static int
19519 test_cryptodev_null(void)
19520 {
19521 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
19522 }
19523 
19524 static int
19525 test_cryptodev_sw_snow3g(void)
19526 {
19527 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
19528 }
19529 
19530 static int
19531 test_cryptodev_sw_kasumi(void)
19532 {
19533 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
19534 }
19535 
19536 static int
19537 test_cryptodev_sw_zuc(void)
19538 {
19539 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
19540 }
19541 
19542 static int
19543 test_cryptodev_armv8(void)
19544 {
19545 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
19546 }
19547 
19548 static int
19549 test_cryptodev_mrvl(void)
19550 {
19551 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
19552 }
19553 
19554 #ifdef RTE_CRYPTO_SCHEDULER
19555 
19556 static int
19557 test_cryptodev_scheduler(void)
19558 {
19559 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
19560 	const enum blockcipher_test_type blk_suites[] = {
19561 		BLKCIPHER_AES_CHAIN_TYPE,
19562 		BLKCIPHER_AES_CIPHERONLY_TYPE,
19563 		BLKCIPHER_AUTHONLY_TYPE
19564 	};
19565 	static struct unit_test_suite scheduler_multicore = {
19566 		.suite_name = "Scheduler Multicore Unit Test Suite",
19567 		.setup = scheduler_multicore_testsuite_setup,
19568 		.teardown = scheduler_mode_testsuite_teardown,
19569 		.unit_test_cases = {TEST_CASES_END()}
19570 	};
19571 	static struct unit_test_suite scheduler_round_robin = {
19572 		.suite_name = "Scheduler Round Robin Unit Test Suite",
19573 		.setup = scheduler_roundrobin_testsuite_setup,
19574 		.teardown = scheduler_mode_testsuite_teardown,
19575 		.unit_test_cases = {TEST_CASES_END()}
19576 	};
19577 	static struct unit_test_suite scheduler_failover = {
19578 		.suite_name = "Scheduler Failover Unit Test Suite",
19579 		.setup = scheduler_failover_testsuite_setup,
19580 		.teardown = scheduler_mode_testsuite_teardown,
19581 		.unit_test_cases = {TEST_CASES_END()}
19582 	};
19583 	static struct unit_test_suite scheduler_pkt_size_distr = {
19584 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
19585 		.setup = scheduler_pkt_size_distr_testsuite_setup,
19586 		.teardown = scheduler_mode_testsuite_teardown,
19587 		.unit_test_cases = {TEST_CASES_END()}
19588 	};
19589 	struct unit_test_suite *sched_mode_suites[] = {
19590 		&scheduler_multicore,
19591 		&scheduler_round_robin,
19592 		&scheduler_failover,
19593 		&scheduler_pkt_size_distr
19594 	};
19595 	static struct unit_test_suite scheduler_config = {
19596 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
19597 		.unit_test_cases = {
19598 			TEST_CASE(test_scheduler_attach_worker_op),
19599 			TEST_CASE(test_scheduler_mode_multicore_op),
19600 			TEST_CASE(test_scheduler_mode_roundrobin_op),
19601 			TEST_CASE(test_scheduler_mode_failover_op),
19602 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
19603 			TEST_CASE(test_scheduler_detach_worker_op),
19604 
19605 			TEST_CASES_END() /**< NULL terminate array */
19606 		}
19607 	};
19608 	struct unit_test_suite *static_suites[] = {
19609 		&scheduler_config,
19610 		&end_testsuite
19611 	};
19612 	struct unit_test_suite *sched_mode_static_suites[] = {
19613 #ifdef RTE_LIB_SECURITY
19614 		&docsis_proto_testsuite,
19615 #endif
19616 		&end_testsuite
19617 	};
19618 	static struct unit_test_suite ts = {
19619 		.suite_name = "Scheduler Unit Test Suite",
19620 		.setup = scheduler_testsuite_setup,
19621 		.teardown = testsuite_teardown,
19622 		.unit_test_cases = {TEST_CASES_END()}
19623 	};
19624 
19625 	gbl_driver_id =	rte_cryptodev_driver_id_get(
19626 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
19627 
19628 	if (gbl_driver_id == -1) {
19629 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
19630 		return TEST_SKIPPED;
19631 	}
19632 
19633 	if (rte_cryptodev_driver_id_get(
19634 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
19635 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
19636 		return TEST_SKIPPED;
19637 	}
19638 
19639 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19640 		uint8_t blk_i = 0;
19641 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
19642 				(struct unit_test_suite *) *
19643 				(RTE_DIM(blk_suites) +
19644 				RTE_DIM(sched_mode_static_suites) + 1));
19645 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19646 				blk_suites, RTE_DIM(blk_suites));
19647 		ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19648 				sched_mode_static_suites,
19649 				RTE_DIM(sched_mode_static_suites));
19650 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
19651 	}
19652 
19653 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19654 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
19655 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
19656 			RTE_DIM(sched_mode_suites));
19657 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19658 	ret = unit_test_suite_runner(&ts);
19659 
19660 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19661 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
19662 				(*sched_mode_suites[sched_i]),
19663 				RTE_DIM(blk_suites));
19664 		free(sched_mode_suites[sched_i]->unit_test_suites);
19665 	}
19666 	free(ts.unit_test_suites);
19667 	return ret;
19668 }
19669 
19670 REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
19671 
19672 #endif
19673 
19674 static int
19675 test_cryptodev_dpaa2_sec(void)
19676 {
19677 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19678 }
19679 
19680 static int
19681 test_cryptodev_dpaa_sec(void)
19682 {
19683 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19684 }
19685 
19686 static int
19687 test_cryptodev_ccp(void)
19688 {
19689 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
19690 }
19691 
19692 static int
19693 test_cryptodev_octeontx(void)
19694 {
19695 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
19696 }
19697 
19698 static int
19699 test_cryptodev_caam_jr(void)
19700 {
19701 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
19702 }
19703 
19704 static int
19705 test_cryptodev_nitrox(void)
19706 {
19707 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
19708 }
19709 
19710 static int
19711 test_cryptodev_bcmfs(void)
19712 {
19713 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
19714 }
19715 
19716 static int
19717 run_cryptodev_raw_testsuite(const char *pmd_name)
19718 {
19719 	int ret;
19720 
19721 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
19722 	if (ret)
19723 		return ret;
19724 
19725 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
19726 	ret = run_cryptodev_testsuite(pmd_name);
19727 	global_api_test_type = CRYPTODEV_API_TEST;
19728 
19729 	return ret;
19730 }
19731 
19732 static int
19733 test_cryptodev_qat_raw_api(void)
19734 {
19735 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19736 }
19737 
19738 static int
19739 test_cryptodev_cn9k(void)
19740 {
19741 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
19742 }
19743 
19744 static int
19745 test_cryptodev_cn10k(void)
19746 {
19747 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19748 }
19749 
19750 static int
19751 test_cryptodev_cn10k_raw_api(void)
19752 {
19753 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19754 }
19755 
19756 static int
19757 test_cryptodev_dpaa2_sec_raw_api(void)
19758 {
19759 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19760 }
19761 
19762 static int
19763 test_cryptodev_dpaa_sec_raw_api(void)
19764 {
19765 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19766 }
19767 
19768 REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
19769 		test_cryptodev_cn10k_raw_api);
19770 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
19771 		test_cryptodev_dpaa2_sec_raw_api);
19772 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
19773 		test_cryptodev_dpaa_sec_raw_api);
19774 REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
19775 		test_cryptodev_qat_raw_api);
19776 REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
19777 REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
19778 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
19779 	test_cryptodev_cpu_aesni_mb);
19780 REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
19781 	test_cryptodev_chacha_poly_mb);
19782 REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
19783 REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
19784 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
19785 	test_cryptodev_cpu_aesni_gcm);
19786 REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
19787 REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
19788 REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
19789 REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
19790 REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
19791 REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
19792 REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
19793 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
19794 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
19795 REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
19796 REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
19797 REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
19798 REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
19799 REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
19800 REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
19801 REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
19802 REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
19803 REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
19804