xref: /dpdk/app/test/test_cryptodev.c (revision c7a068edaba37b38bd7bfe051bd032b08b706650)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Intel Corporation
3  * Copyright 2020 NXP
4  */
5 
6 #include <time.h>
7 
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
10 #include <rte_mbuf.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
16 #include <rte_errno.h>
17 
18 #include <rte_crypto.h>
19 #include <rte_cryptodev.h>
20 #include <rte_ethdev.h>
21 #include <rte_ip.h>
22 #include <rte_string_fns.h>
23 #include <rte_tcp.h>
24 #include <rte_tls.h>
25 #include <rte_udp.h>
26 
27 #ifdef RTE_CRYPTO_SCHEDULER
28 #include <rte_cryptodev_scheduler.h>
29 #include <rte_cryptodev_scheduler_operations.h>
30 #endif
31 
32 #include <rte_lcore.h>
33 
34 #include "test.h"
35 #include "test_cryptodev.h"
36 
37 #include "test_cryptodev_blockcipher.h"
38 #include "test_cryptodev_aes_test_vectors.h"
39 #include "test_cryptodev_des_test_vectors.h"
40 #include "test_cryptodev_hash_test_vectors.h"
41 #include "test_cryptodev_kasumi_test_vectors.h"
42 #include "test_cryptodev_kasumi_hash_test_vectors.h"
43 #include "test_cryptodev_snow3g_test_vectors.h"
44 #include "test_cryptodev_snow3g_hash_test_vectors.h"
45 #include "test_cryptodev_zuc_test_vectors.h"
46 #include "test_cryptodev_aead_test_vectors.h"
47 #include "test_cryptodev_hmac_test_vectors.h"
48 #include "test_cryptodev_mixed_test_vectors.h"
49 #include "test_cryptodev_sm4_test_vectors.h"
50 #ifdef RTE_LIB_SECURITY
51 #include "test_cryptodev_security_ipsec.h"
52 #include "test_cryptodev_security_ipsec_test_vectors.h"
53 #include "test_cryptodev_security_pdcp_test_vectors.h"
54 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
55 #include "test_cryptodev_security_pdcp_test_func.h"
56 #include "test_cryptodev_security_docsis_test_vectors.h"
57 #include "test_cryptodev_security_tls_record.h"
58 #include "test_security_proto.h"
59 
60 #define SDAP_DISABLED	0
61 #define SDAP_ENABLED	1
62 #endif
63 
64 #define VDEV_ARGS_SIZE 100
65 #define MAX_NB_SESSIONS 4
66 
67 #define MAX_DRV_SERVICE_CTX_SIZE 256
68 
69 #define MAX_RAW_DEQUEUE_COUNT	65535
70 
71 #define IN_PLACE 0
72 #define OUT_OF_PLACE 1
73 
74 static int gbl_driver_id;
75 
76 static enum rte_security_session_action_type gbl_action_type =
77 	RTE_SECURITY_ACTION_TYPE_NONE;
78 
79 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
80 
81 struct crypto_unittest_params {
82 	struct rte_crypto_sym_xform cipher_xform;
83 	struct rte_crypto_sym_xform auth_xform;
84 	struct rte_crypto_sym_xform aead_xform;
85 #ifdef RTE_LIB_SECURITY
86 	struct rte_security_docsis_xform docsis_xform;
87 #endif
88 
89 	union {
90 		void *sess;
91 #ifdef RTE_LIB_SECURITY
92 		void *sec_session;
93 #endif
94 	};
95 #ifdef RTE_LIB_SECURITY
96 	enum rte_security_session_action_type type;
97 #endif
98 	struct rte_crypto_op *op;
99 
100 	struct rte_mbuf *obuf, *ibuf;
101 
102 	uint8_t *digest;
103 };
104 
105 #define ALIGN_POW2_ROUNDUP(num, align) \
106 	(((num) + (align) - 1) & ~((align) - 1))
107 
108 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
109 	for (j = 0; j < num_child_ts; index++, j++)			\
110 		parent_ts.unit_test_suites[index] = child_ts[j]
111 
112 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
113 	for (j = 0; j < num_blk_types; index++, j++)				\
114 		parent_ts.unit_test_suites[index] =				\
115 				build_blockcipher_test_suite(blk_types[j])
116 
117 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
118 	for (j = index; j < index + num_blk_types; j++)				\
119 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
120 
121 /*
122  * Forward declarations.
123  */
124 static int
125 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
126 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
127 		uint8_t *hmac_key);
128 
129 static int
130 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
131 		struct crypto_unittest_params *ut_params,
132 		struct crypto_testsuite_params *ts_param,
133 		const uint8_t *cipher,
134 		const uint8_t *digest,
135 		const uint8_t *iv);
136 
137 static int
138 security_proto_supported(enum rte_security_session_action_type action,
139 	enum rte_security_session_protocol proto);
140 
141 static int
142 dev_configure_and_start(uint64_t ff_disable);
143 
144 static int
145 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
146 			const enum rte_crypto_cipher_algorithm cipher_algo,
147 			const uint16_t key_size, const uint16_t iv_size);
148 
149 static int
150 check_auth_capability(const struct crypto_testsuite_params *ts_params,
151 			const enum rte_crypto_auth_algorithm auth_algo,
152 			const uint16_t key_size, const uint16_t iv_size,
153 			const uint16_t tag_size);
154 
155 static struct rte_mbuf *
156 setup_test_string(struct rte_mempool *mpool,
157 		const char *string, size_t len, uint8_t blocksize)
158 {
159 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
160 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
161 
162 	if (m) {
163 		char *dst;
164 
165 		memset(m->buf_addr, 0, m->buf_len);
166 		dst = rte_pktmbuf_append(m, t_len);
167 		if (!dst) {
168 			rte_pktmbuf_free(m);
169 			return NULL;
170 		}
171 		if (string != NULL)
172 			rte_memcpy(dst, string, t_len);
173 		else
174 			memset(dst, 0, t_len);
175 	}
176 
177 	return m;
178 }
179 
180 /* Get number of bytes in X bits (rounding up) */
181 static uint32_t
182 ceil_byte_length(uint32_t num_bits)
183 {
184 	if (num_bits % 8)
185 		return ((num_bits >> 3) + 1);
186 	else
187 		return (num_bits >> 3);
188 }
189 
190 static void
191 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
192 		uint8_t is_op_success)
193 {
194 	struct rte_crypto_op *op = user_data;
195 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
196 			RTE_CRYPTO_OP_STATUS_ERROR;
197 }
198 
199 static struct crypto_testsuite_params testsuite_params = { NULL };
200 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
201 static struct crypto_unittest_params unittest_params;
202 
203 int
204 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
205 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
206 		uint8_t len_in_bits, uint8_t cipher_iv_len)
207 {
208 	struct rte_crypto_sym_op *sop = op->sym;
209 	struct rte_crypto_op *ret_op = NULL;
210 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
211 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
212 	union rte_crypto_sym_ofs ofs;
213 	struct rte_crypto_sym_vec vec;
214 	struct rte_crypto_sgl sgl, dest_sgl;
215 	uint32_t max_len;
216 	union rte_cryptodev_session_ctx sess;
217 	uint64_t auth_end_iova;
218 	uint32_t count = 0;
219 	struct rte_crypto_raw_dp_ctx *ctx;
220 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
221 			auth_len = 0;
222 	int32_t n;
223 	uint32_t n_success;
224 	int ctx_service_size;
225 	int32_t status = 0;
226 	int enqueue_status, dequeue_status;
227 	struct crypto_unittest_params *ut_params = &unittest_params;
228 	int is_sgl = sop->m_src->nb_segs > 1;
229 	int ret = TEST_SUCCESS, is_oop = 0;
230 
231 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
232 	if (ctx_service_size < 0)
233 		return TEST_SKIPPED;
234 
235 	ctx = malloc(ctx_service_size);
236 	if (ctx == NULL)
237 		return TEST_FAILED;
238 
239 	/* Both are enums, setting crypto_sess will suit any session type */
240 	sess.crypto_sess = op->sym->session;
241 
242 	ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
243 	if (ret == -ENOTSUP) {
244 		ret = TEST_SKIPPED;
245 		goto exit;
246 	} else if (ret) {
247 		ret = TEST_FAILED;
248 		goto exit;
249 	}
250 
251 	cipher_iv.iova = 0;
252 	cipher_iv.va = NULL;
253 	aad_auth_iv.iova = 0;
254 	aad_auth_iv.va = NULL;
255 	digest.iova = 0;
256 	digest.va = NULL;
257 	sgl.vec = data_vec;
258 	vec.num = 1;
259 	vec.src_sgl = &sgl;
260 	vec.iv = &cipher_iv;
261 	vec.digest = &digest;
262 	vec.aad = &aad_auth_iv;
263 	vec.status = &status;
264 
265 	ofs.raw = 0;
266 
267 	if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
268 		is_oop = 1;
269 
270 	if (is_cipher && is_auth) {
271 		cipher_offset = sop->cipher.data.offset;
272 		cipher_len = sop->cipher.data.length;
273 		auth_offset = sop->auth.data.offset;
274 		auth_len = sop->auth.data.length;
275 		max_len = RTE_MAX(cipher_offset + cipher_len,
276 				auth_offset + auth_len);
277 		if (len_in_bits) {
278 			max_len = max_len >> 3;
279 			cipher_offset = cipher_offset >> 3;
280 			auth_offset = auth_offset >> 3;
281 			cipher_len = cipher_len >> 3;
282 			auth_len = auth_len >> 3;
283 		}
284 		ofs.ofs.cipher.head = cipher_offset;
285 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
286 		ofs.ofs.auth.head = auth_offset;
287 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
288 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
289 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
290 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
291 				op, void *, IV_OFFSET + cipher_iv_len);
292 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
293 				cipher_iv_len);
294 		digest.va = (void *)sop->auth.digest.data;
295 		digest.iova = sop->auth.digest.phys_addr;
296 
297 		if (is_sgl) {
298 			uint32_t remaining_off = auth_offset + auth_len;
299 			struct rte_mbuf *sgl_buf = sop->m_src;
300 			if (is_oop)
301 				sgl_buf = sop->m_dst;
302 
303 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
304 					&& sgl_buf->next != NULL) {
305 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
306 				sgl_buf = sgl_buf->next;
307 			}
308 
309 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
310 				sgl_buf, remaining_off);
311 		} else {
312 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
313 							 auth_offset + auth_len;
314 		}
315 		/* Then check if digest-encrypted conditions are met */
316 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
317 				(digest.iova == auth_end_iova) && is_sgl)
318 			max_len = RTE_MAX(max_len,
319 				auth_offset + auth_len +
320 				ut_params->auth_xform.auth.digest_length);
321 
322 	} else if (is_cipher) {
323 		cipher_offset = sop->cipher.data.offset;
324 		cipher_len = sop->cipher.data.length;
325 		max_len = cipher_len + cipher_offset;
326 		if (len_in_bits) {
327 			max_len = max_len >> 3;
328 			cipher_offset = cipher_offset >> 3;
329 			cipher_len = cipher_len >> 3;
330 		}
331 		ofs.ofs.cipher.head = cipher_offset;
332 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
333 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
334 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
335 
336 	} else if (is_auth) {
337 		auth_offset = sop->auth.data.offset;
338 		auth_len = sop->auth.data.length;
339 		max_len = auth_len + auth_offset;
340 		if (len_in_bits) {
341 			max_len = max_len >> 3;
342 			auth_offset = auth_offset >> 3;
343 			auth_len = auth_len >> 3;
344 		}
345 		ofs.ofs.auth.head = auth_offset;
346 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
347 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
348 				op, void *, IV_OFFSET + cipher_iv_len);
349 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
350 				cipher_iv_len);
351 		digest.va = (void *)sop->auth.digest.data;
352 		digest.iova = sop->auth.digest.phys_addr;
353 
354 	} else { /* aead */
355 		cipher_offset = sop->aead.data.offset;
356 		cipher_len = sop->aead.data.length;
357 		max_len = cipher_len + cipher_offset;
358 		if (len_in_bits) {
359 			max_len = max_len >> 3;
360 			cipher_offset = cipher_offset >> 3;
361 			cipher_len = cipher_len >> 3;
362 		}
363 		ofs.ofs.cipher.head = cipher_offset;
364 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
365 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
366 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
367 		aad_auth_iv.va = (void *)sop->aead.aad.data;
368 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
369 		digest.va = (void *)sop->aead.digest.data;
370 		digest.iova = sop->aead.digest.phys_addr;
371 	}
372 
373 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
374 			data_vec, RTE_DIM(data_vec));
375 	if (n < 0 || n > sop->m_src->nb_segs) {
376 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
377 		goto exit;
378 	}
379 
380 	sgl.num = n;
381 	/* Out of place */
382 	if (is_oop) {
383 		dest_sgl.vec = dest_data_vec;
384 		vec.dest_sgl = &dest_sgl;
385 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
386 				dest_data_vec, RTE_DIM(dest_data_vec));
387 		if (n < 0 || n > sop->m_dst->nb_segs) {
388 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
389 			goto exit;
390 		}
391 		dest_sgl.num = n;
392 	} else
393 		vec.dest_sgl = NULL;
394 
395 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
396 			&enqueue_status) < 1) {
397 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
398 		goto exit;
399 	}
400 
401 	if (enqueue_status == 0) {
402 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
403 		if (status < 0) {
404 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
405 			goto exit;
406 		}
407 	} else if (enqueue_status < 0) {
408 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
409 		goto exit;
410 	}
411 
412 	n = n_success = 0;
413 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
414 		n = rte_cryptodev_raw_dequeue_burst(ctx,
415 			NULL, 1, post_process_raw_dp_op,
416 				(void **)&ret_op, 0, &n_success,
417 				&dequeue_status);
418 		if (dequeue_status < 0) {
419 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
420 			goto exit;
421 		}
422 		if (n == 0)
423 			rte_pause();
424 	}
425 
426 	if (n == 1 && dequeue_status == 0) {
427 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
428 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
429 			goto exit;
430 		}
431 	}
432 
433 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
434 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
435 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
436 					RTE_CRYPTO_OP_STATUS_SUCCESS;
437 
438 exit:
439 	free(ctx);
440 	return ret;
441 }
442 
443 static void
444 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
445 {
446 	int32_t n, st;
447 	struct rte_crypto_sym_op *sop;
448 	union rte_crypto_sym_ofs ofs;
449 	struct rte_crypto_sgl sgl;
450 	struct rte_crypto_sym_vec symvec;
451 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
452 	struct rte_crypto_vec vec[UINT8_MAX];
453 
454 	sop = op->sym;
455 
456 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
457 		sop->aead.data.length, vec, RTE_DIM(vec));
458 
459 	if (n < 0 || n != sop->m_src->nb_segs) {
460 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
461 		return;
462 	}
463 
464 	sgl.vec = vec;
465 	sgl.num = n;
466 	symvec.src_sgl = &sgl;
467 	symvec.iv = &iv_ptr;
468 	symvec.digest = &digest_ptr;
469 	symvec.aad = &aad_ptr;
470 	symvec.status = &st;
471 	symvec.num = 1;
472 
473 	/* for CPU crypto the IOVA address is not required */
474 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
475 	digest_ptr.va = (void *)sop->aead.digest.data;
476 	aad_ptr.va = (void *)sop->aead.aad.data;
477 
478 	ofs.raw = 0;
479 
480 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
481 		&symvec);
482 
483 	if (n != 1)
484 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
485 	else
486 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
487 }
488 
489 static void
490 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
491 {
492 	int32_t n, st;
493 	struct rte_crypto_sym_op *sop;
494 	union rte_crypto_sym_ofs ofs;
495 	struct rte_crypto_sgl sgl;
496 	struct rte_crypto_sym_vec symvec;
497 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
498 	struct rte_crypto_vec vec[UINT8_MAX];
499 
500 	sop = op->sym;
501 
502 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
503 		sop->auth.data.length, vec, RTE_DIM(vec));
504 
505 	if (n < 0 || n != sop->m_src->nb_segs) {
506 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
507 		return;
508 	}
509 
510 	sgl.vec = vec;
511 	sgl.num = n;
512 	symvec.src_sgl = &sgl;
513 	symvec.iv = &iv_ptr;
514 	symvec.digest = &digest_ptr;
515 	symvec.status = &st;
516 	symvec.num = 1;
517 
518 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
519 	digest_ptr.va = (void *)sop->auth.digest.data;
520 
521 	ofs.raw = 0;
522 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
523 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
524 		(sop->cipher.data.offset + sop->cipher.data.length);
525 
526 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
527 		&symvec);
528 
529 	if (n != 1)
530 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
531 	else
532 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
533 }
534 
535 static struct rte_crypto_op *
536 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
537 {
538 
539 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
540 
541 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
542 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
543 		return NULL;
544 	}
545 
546 	op = NULL;
547 
548 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
549 		rte_pause();
550 
551 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
552 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
553 		return NULL;
554 	}
555 
556 	return op;
557 }
558 
559 static int
560 testsuite_setup(void)
561 {
562 	struct crypto_testsuite_params *ts_params = &testsuite_params;
563 	struct rte_cryptodev_info info;
564 	uint32_t i = 0, nb_devs, dev_id;
565 	uint16_t qp_id;
566 
567 	memset(ts_params, 0, sizeof(*ts_params));
568 
569 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
570 	if (ts_params->mbuf_pool == NULL) {
571 		/* Not already created so create */
572 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
573 				"CRYPTO_MBUFPOOL",
574 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
575 				rte_socket_id());
576 		if (ts_params->mbuf_pool == NULL) {
577 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
578 			return TEST_FAILED;
579 		}
580 	}
581 
582 	ts_params->large_mbuf_pool = rte_mempool_lookup(
583 			"CRYPTO_LARGE_MBUFPOOL");
584 	if (ts_params->large_mbuf_pool == NULL) {
585 		/* Not already created so create */
586 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
587 				"CRYPTO_LARGE_MBUFPOOL",
588 				1, 0, 0, UINT16_MAX,
589 				rte_socket_id());
590 		if (ts_params->large_mbuf_pool == NULL) {
591 			RTE_LOG(ERR, USER1,
592 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
593 			return TEST_FAILED;
594 		}
595 	}
596 
597 	ts_params->op_mpool = rte_crypto_op_pool_create(
598 			"MBUF_CRYPTO_SYM_OP_POOL",
599 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
600 			NUM_MBUFS, MBUF_CACHE_SIZE,
601 			DEFAULT_NUM_XFORMS *
602 			sizeof(struct rte_crypto_sym_xform) +
603 			MAXIMUM_IV_LENGTH,
604 			rte_socket_id());
605 	if (ts_params->op_mpool == NULL) {
606 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
607 		return TEST_FAILED;
608 	}
609 
610 	nb_devs = rte_cryptodev_count();
611 	if (nb_devs < 1) {
612 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
613 		return TEST_SKIPPED;
614 	}
615 
616 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
617 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
618 				rte_cryptodev_driver_name_get(gbl_driver_id));
619 		return TEST_SKIPPED;
620 	}
621 
622 	/* Create list of valid crypto devs */
623 	for (i = 0; i < nb_devs; i++) {
624 		rte_cryptodev_info_get(i, &info);
625 		if (info.driver_id == gbl_driver_id)
626 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
627 	}
628 
629 	if (ts_params->valid_dev_count < 1)
630 		return TEST_FAILED;
631 
632 	/* Set up all the qps on the first of the valid devices found */
633 
634 	dev_id = ts_params->valid_devs[0];
635 
636 	rte_cryptodev_info_get(dev_id, &info);
637 
638 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
639 	ts_params->conf.socket_id = SOCKET_ID_ANY;
640 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
641 
642 	unsigned int session_size =
643 		rte_cryptodev_sym_get_private_session_size(dev_id);
644 
645 #ifdef RTE_LIB_SECURITY
646 	unsigned int security_session_size = rte_security_session_get_size(
647 			rte_cryptodev_get_sec_ctx(dev_id));
648 
649 	if (session_size < security_session_size)
650 		session_size = security_session_size;
651 #endif
652 	/*
653 	 * Create mempool with maximum number of sessions.
654 	 */
655 	if (info.sym.max_nb_sessions != 0 &&
656 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
657 		RTE_LOG(ERR, USER1, "Device does not support "
658 				"at least %u sessions\n",
659 				MAX_NB_SESSIONS);
660 		return TEST_FAILED;
661 	}
662 
663 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
664 			"test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
665 			SOCKET_ID_ANY);
666 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
667 			"session mempool allocation failed");
668 
669 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
670 			&ts_params->conf),
671 			"Failed to configure cryptodev %u with %u qps",
672 			dev_id, ts_params->conf.nb_queue_pairs);
673 
674 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
675 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
676 
677 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
678 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
679 			dev_id, qp_id, &ts_params->qp_conf,
680 			rte_cryptodev_socket_id(dev_id)),
681 			"Failed to setup queue pair %u on cryptodev %u",
682 			qp_id, dev_id);
683 	}
684 
685 	return TEST_SUCCESS;
686 }
687 
688 static void
689 testsuite_teardown(void)
690 {
691 	struct crypto_testsuite_params *ts_params = &testsuite_params;
692 	int res;
693 
694 	if (ts_params->mbuf_pool != NULL) {
695 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
696 		rte_mempool_avail_count(ts_params->mbuf_pool));
697 	}
698 
699 	if (ts_params->op_mpool != NULL) {
700 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
701 		rte_mempool_avail_count(ts_params->op_mpool));
702 	}
703 
704 	if (ts_params->session_mpool != NULL) {
705 		rte_mempool_free(ts_params->session_mpool);
706 		ts_params->session_mpool = NULL;
707 	}
708 
709 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
710 	if (res)
711 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
712 }
713 
714 static int
715 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
716 		const int *algs, uint16_t num_algs)
717 {
718 	uint8_t dev_id = testsuite_params.valid_devs[0];
719 	bool some_alg_supported = FALSE;
720 	uint16_t i;
721 
722 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
723 		struct rte_cryptodev_sym_capability_idx alg = {
724 			type, {algs[i]}
725 		};
726 		if (rte_cryptodev_sym_capability_get(dev_id,
727 				&alg) != NULL)
728 			some_alg_supported = TRUE;
729 	}
730 	if (!some_alg_supported)
731 		return TEST_SKIPPED;
732 
733 	return 0;
734 }
735 
736 int
737 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
738 		uint16_t num_ciphers)
739 {
740 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
741 			(const int *) ciphers, num_ciphers);
742 }
743 
744 int
745 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
746 		uint16_t num_auths)
747 {
748 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
749 			(const int *) auths, num_auths);
750 }
751 
752 int
753 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
754 		uint16_t num_aeads)
755 {
756 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
757 			(const int *) aeads, num_aeads);
758 }
759 
760 static int
761 null_testsuite_setup(void)
762 {
763 	struct crypto_testsuite_params *ts_params = &testsuite_params;
764 	uint8_t dev_id = ts_params->valid_devs[0];
765 	struct rte_cryptodev_info dev_info;
766 	const enum rte_crypto_cipher_algorithm ciphers[] = {
767 		RTE_CRYPTO_CIPHER_NULL
768 	};
769 	const enum rte_crypto_auth_algorithm auths[] = {
770 		RTE_CRYPTO_AUTH_NULL
771 	};
772 
773 	rte_cryptodev_info_get(dev_id, &dev_info);
774 
775 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
776 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
777 				"testsuite not met\n");
778 		return TEST_SKIPPED;
779 	}
780 
781 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
782 			&& check_auth_capabilities_supported(auths,
783 			RTE_DIM(auths)) != 0) {
784 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
785 				"testsuite not met\n");
786 		return TEST_SKIPPED;
787 	}
788 
789 	return 0;
790 }
791 
792 static int
793 crypto_gen_testsuite_setup(void)
794 {
795 	struct crypto_testsuite_params *ts_params = &testsuite_params;
796 	uint8_t dev_id = ts_params->valid_devs[0];
797 	struct rte_cryptodev_info dev_info;
798 
799 	rte_cryptodev_info_get(dev_id, &dev_info);
800 
801 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
802 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
803 				"testsuite not met\n");
804 		return TEST_SKIPPED;
805 	}
806 
807 	return 0;
808 }
809 
810 #ifdef RTE_LIB_SECURITY
811 static int
812 sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
813 {
814 	struct crypto_testsuite_params *ts_params = &testsuite_params;
815 	struct crypto_unittest_params *ut_params = &unittest_params;
816 	struct rte_cryptodev_info dev_info;
817 	int ret = 0;
818 
819 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
820 
821 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
822 		RTE_LOG(INFO, USER1,
823 			"Feature flag requirements for security protocol testsuite not met\n");
824 		return TEST_SKIPPED;
825 	}
826 
827 	/* Reconfigure to enable security */
828 	ret = dev_configure_and_start(0);
829 	if (ret != TEST_SUCCESS)
830 		return ret;
831 
832 	/* Set action type */
833 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
834 
835 	if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
836 		RTE_LOG(INFO, USER1,
837 			"Capability requirements for security protocol test not met\n");
838 		ret = TEST_SKIPPED;
839 	}
840 
841 	test_sec_alg_list_populate();
842 	test_sec_auth_only_alg_list_populate();
843 
844 	/*
845 	 * Stop the device. Device would be started again by individual test
846 	 * case setup routine.
847 	 */
848 	rte_cryptodev_stop(ts_params->valid_devs[0]);
849 
850 	return ret;
851 }
852 
853 static int
854 ipsec_proto_testsuite_setup(void)
855 {
856 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
857 }
858 
859 static int
860 tls_record_proto_testsuite_setup(void)
861 {
862 	test_sec_proto_pattern_generate();
863 
864 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
865 }
866 
867 static int
868 pdcp_proto_testsuite_setup(void)
869 {
870 	struct crypto_testsuite_params *ts_params = &testsuite_params;
871 	uint8_t dev_id = ts_params->valid_devs[0];
872 	struct rte_cryptodev_info dev_info;
873 	const enum rte_crypto_cipher_algorithm ciphers[] = {
874 		RTE_CRYPTO_CIPHER_NULL,
875 		RTE_CRYPTO_CIPHER_AES_CTR,
876 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
877 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
878 	};
879 	const enum rte_crypto_auth_algorithm auths[] = {
880 		RTE_CRYPTO_AUTH_NULL,
881 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
882 		RTE_CRYPTO_AUTH_AES_CMAC,
883 		RTE_CRYPTO_AUTH_ZUC_EIA3
884 	};
885 
886 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
887 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
888 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
889 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
890 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
891 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
892 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
893 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
894 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
895 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
896 
897 	rte_cryptodev_info_get(dev_id, &dev_info);
898 
899 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
900 			!(dev_info.feature_flags &
901 			RTE_CRYPTODEV_FF_SECURITY)) {
902 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
903 				"testsuite not met\n");
904 		return TEST_SKIPPED;
905 	}
906 
907 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
908 			&& check_auth_capabilities_supported(auths,
909 			RTE_DIM(auths)) != 0) {
910 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
911 				"testsuite not met\n");
912 		return TEST_SKIPPED;
913 	}
914 
915 	return 0;
916 }
917 
918 static int
919 docsis_proto_testsuite_setup(void)
920 {
921 	struct crypto_testsuite_params *ts_params = &testsuite_params;
922 	uint8_t dev_id = ts_params->valid_devs[0];
923 	struct rte_cryptodev_info dev_info;
924 	const enum rte_crypto_cipher_algorithm ciphers[] = {
925 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
926 	};
927 
928 	rte_cryptodev_info_get(dev_id, &dev_info);
929 
930 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
931 			!(dev_info.feature_flags &
932 			RTE_CRYPTODEV_FF_SECURITY)) {
933 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
934 				"Proto testsuite not met\n");
935 		return TEST_SKIPPED;
936 	}
937 
938 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
939 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
940 				"testsuite not met\n");
941 		return TEST_SKIPPED;
942 	}
943 
944 	return 0;
945 }
946 #endif
947 
948 static int
949 aes_ccm_auth_testsuite_setup(void)
950 {
951 	struct crypto_testsuite_params *ts_params = &testsuite_params;
952 	uint8_t dev_id = ts_params->valid_devs[0];
953 	struct rte_cryptodev_info dev_info;
954 	const enum rte_crypto_aead_algorithm aeads[] = {
955 		RTE_CRYPTO_AEAD_AES_CCM
956 	};
957 
958 	rte_cryptodev_info_get(dev_id, &dev_info);
959 
960 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
961 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
962 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
963 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
964 				"testsuite not met\n");
965 		return TEST_SKIPPED;
966 	}
967 
968 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
969 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
970 				"testsuite not met\n");
971 		return TEST_SKIPPED;
972 	}
973 
974 	return 0;
975 }
976 
977 static int
978 aes_gcm_auth_testsuite_setup(void)
979 {
980 	struct crypto_testsuite_params *ts_params = &testsuite_params;
981 	uint8_t dev_id = ts_params->valid_devs[0];
982 	struct rte_cryptodev_info dev_info;
983 	const enum rte_crypto_aead_algorithm aeads[] = {
984 		RTE_CRYPTO_AEAD_AES_GCM
985 	};
986 
987 	rte_cryptodev_info_get(dev_id, &dev_info);
988 
989 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
990 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
991 				"testsuite not met\n");
992 		return TEST_SKIPPED;
993 	}
994 
995 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
996 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
997 				"testsuite not met\n");
998 		return TEST_SKIPPED;
999 	}
1000 
1001 	return 0;
1002 }
1003 
1004 static int
1005 aes_gmac_auth_testsuite_setup(void)
1006 {
1007 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1008 	uint8_t dev_id = ts_params->valid_devs[0];
1009 	struct rte_cryptodev_info dev_info;
1010 	const enum rte_crypto_auth_algorithm auths[] = {
1011 		RTE_CRYPTO_AUTH_AES_GMAC
1012 	};
1013 
1014 	rte_cryptodev_info_get(dev_id, &dev_info);
1015 
1016 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1017 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1018 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1019 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1020 				"testsuite not met\n");
1021 		return TEST_SKIPPED;
1022 	}
1023 
1024 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1025 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1026 				"testsuite not met\n");
1027 		return TEST_SKIPPED;
1028 	}
1029 
1030 	return 0;
1031 }
1032 
1033 static int
1034 chacha20_poly1305_testsuite_setup(void)
1035 {
1036 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1037 	uint8_t dev_id = ts_params->valid_devs[0];
1038 	struct rte_cryptodev_info dev_info;
1039 	const enum rte_crypto_aead_algorithm aeads[] = {
1040 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1041 	};
1042 
1043 	rte_cryptodev_info_get(dev_id, &dev_info);
1044 
1045 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1046 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1047 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1048 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1049 				"Chacha20-Poly1305 testsuite not met\n");
1050 		return TEST_SKIPPED;
1051 	}
1052 
1053 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1054 		RTE_LOG(INFO, USER1, "Capability requirements for "
1055 				"Chacha20-Poly1305 testsuite not met\n");
1056 		return TEST_SKIPPED;
1057 	}
1058 
1059 	return 0;
1060 }
1061 
1062 static int
1063 snow3g_testsuite_setup(void)
1064 {
1065 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1066 	uint8_t dev_id = ts_params->valid_devs[0];
1067 	struct rte_cryptodev_info dev_info;
1068 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1069 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1070 
1071 	};
1072 	const enum rte_crypto_auth_algorithm auths[] = {
1073 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1074 	};
1075 
1076 	rte_cryptodev_info_get(dev_id, &dev_info);
1077 
1078 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1079 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1080 				"testsuite not met\n");
1081 		return TEST_SKIPPED;
1082 	}
1083 
1084 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1085 			&& check_auth_capabilities_supported(auths,
1086 			RTE_DIM(auths)) != 0) {
1087 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1088 				"testsuite not met\n");
1089 		return TEST_SKIPPED;
1090 	}
1091 
1092 	return 0;
1093 }
1094 
1095 static int
1096 zuc_testsuite_setup(void)
1097 {
1098 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1099 	uint8_t dev_id = ts_params->valid_devs[0];
1100 	struct rte_cryptodev_info dev_info;
1101 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1102 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1103 	};
1104 	const enum rte_crypto_auth_algorithm auths[] = {
1105 		RTE_CRYPTO_AUTH_ZUC_EIA3
1106 	};
1107 
1108 	rte_cryptodev_info_get(dev_id, &dev_info);
1109 
1110 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1111 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1112 				"testsuite not met\n");
1113 		return TEST_SKIPPED;
1114 	}
1115 
1116 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1117 			&& check_auth_capabilities_supported(auths,
1118 			RTE_DIM(auths)) != 0) {
1119 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1120 				"testsuite not met\n");
1121 		return TEST_SKIPPED;
1122 	}
1123 
1124 	return 0;
1125 }
1126 
1127 static int
1128 hmac_md5_auth_testsuite_setup(void)
1129 {
1130 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1131 	uint8_t dev_id = ts_params->valid_devs[0];
1132 	struct rte_cryptodev_info dev_info;
1133 	const enum rte_crypto_auth_algorithm auths[] = {
1134 		RTE_CRYPTO_AUTH_MD5_HMAC
1135 	};
1136 
1137 	rte_cryptodev_info_get(dev_id, &dev_info);
1138 
1139 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1140 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1141 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1142 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1143 				"Auth testsuite not met\n");
1144 		return TEST_SKIPPED;
1145 	}
1146 
1147 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1148 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1149 				"testsuite not met\n");
1150 		return TEST_SKIPPED;
1151 	}
1152 
1153 	return 0;
1154 }
1155 
1156 static int
1157 kasumi_testsuite_setup(void)
1158 {
1159 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1160 	uint8_t dev_id = ts_params->valid_devs[0];
1161 	struct rte_cryptodev_info dev_info;
1162 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1163 		RTE_CRYPTO_CIPHER_KASUMI_F8
1164 	};
1165 	const enum rte_crypto_auth_algorithm auths[] = {
1166 		RTE_CRYPTO_AUTH_KASUMI_F9
1167 	};
1168 
1169 	rte_cryptodev_info_get(dev_id, &dev_info);
1170 
1171 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1172 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1173 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1174 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1175 				"testsuite not met\n");
1176 		return TEST_SKIPPED;
1177 	}
1178 
1179 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1180 			&& check_auth_capabilities_supported(auths,
1181 			RTE_DIM(auths)) != 0) {
1182 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1183 				"testsuite not met\n");
1184 		return TEST_SKIPPED;
1185 	}
1186 
1187 	return 0;
1188 }
1189 
1190 static int
1191 negative_aes_gcm_testsuite_setup(void)
1192 {
1193 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1194 	uint8_t dev_id = ts_params->valid_devs[0];
1195 	struct rte_cryptodev_info dev_info;
1196 	const enum rte_crypto_aead_algorithm aeads[] = {
1197 		RTE_CRYPTO_AEAD_AES_GCM
1198 	};
1199 
1200 	rte_cryptodev_info_get(dev_id, &dev_info);
1201 
1202 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1203 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1204 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1205 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1206 				"AES GCM testsuite not met\n");
1207 		return TEST_SKIPPED;
1208 	}
1209 
1210 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1211 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1212 				"AES GCM testsuite not met\n");
1213 		return TEST_SKIPPED;
1214 	}
1215 
1216 	return 0;
1217 }
1218 
1219 static int
1220 negative_aes_gmac_testsuite_setup(void)
1221 {
1222 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1223 	uint8_t dev_id = ts_params->valid_devs[0];
1224 	struct rte_cryptodev_info dev_info;
1225 	const enum rte_crypto_auth_algorithm auths[] = {
1226 		RTE_CRYPTO_AUTH_AES_GMAC
1227 	};
1228 
1229 	rte_cryptodev_info_get(dev_id, &dev_info);
1230 
1231 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1232 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1233 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1234 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1235 				"AES GMAC testsuite not met\n");
1236 		return TEST_SKIPPED;
1237 	}
1238 
1239 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1240 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1241 				"AES GMAC testsuite not met\n");
1242 		return TEST_SKIPPED;
1243 	}
1244 
1245 	return 0;
1246 }
1247 
1248 static int
1249 mixed_cipher_hash_testsuite_setup(void)
1250 {
1251 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1252 	uint8_t dev_id = ts_params->valid_devs[0];
1253 	struct rte_cryptodev_info dev_info;
1254 	uint64_t feat_flags;
1255 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1256 		RTE_CRYPTO_CIPHER_NULL,
1257 		RTE_CRYPTO_CIPHER_AES_CTR,
1258 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1259 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1260 	};
1261 	const enum rte_crypto_auth_algorithm auths[] = {
1262 		RTE_CRYPTO_AUTH_NULL,
1263 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1264 		RTE_CRYPTO_AUTH_AES_CMAC,
1265 		RTE_CRYPTO_AUTH_ZUC_EIA3
1266 	};
1267 
1268 	rte_cryptodev_info_get(dev_id, &dev_info);
1269 	feat_flags = dev_info.feature_flags;
1270 
1271 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1272 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1273 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1274 				"Cipher Hash testsuite not met\n");
1275 		return TEST_SKIPPED;
1276 	}
1277 
1278 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1279 			&& check_auth_capabilities_supported(auths,
1280 			RTE_DIM(auths)) != 0) {
1281 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1282 				"Cipher Hash testsuite not met\n");
1283 		return TEST_SKIPPED;
1284 	}
1285 
1286 	return 0;
1287 }
1288 
1289 static int
1290 esn_testsuite_setup(void)
1291 {
1292 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1293 	uint8_t dev_id = ts_params->valid_devs[0];
1294 	struct rte_cryptodev_info dev_info;
1295 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1296 		RTE_CRYPTO_CIPHER_AES_CBC
1297 	};
1298 	const enum rte_crypto_auth_algorithm auths[] = {
1299 		RTE_CRYPTO_AUTH_SHA1_HMAC
1300 	};
1301 
1302 	rte_cryptodev_info_get(dev_id, &dev_info);
1303 
1304 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1305 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1306 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1307 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1308 				"testsuite not met\n");
1309 		return TEST_SKIPPED;
1310 	}
1311 
1312 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1313 			&& check_auth_capabilities_supported(auths,
1314 			RTE_DIM(auths)) != 0) {
1315 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1316 				"testsuite not met\n");
1317 		return TEST_SKIPPED;
1318 	}
1319 
1320 	return 0;
1321 }
1322 
1323 static int
1324 multi_session_testsuite_setup(void)
1325 {
1326 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1327 	uint8_t dev_id = ts_params->valid_devs[0];
1328 	struct rte_cryptodev_info dev_info;
1329 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1330 		RTE_CRYPTO_CIPHER_AES_CBC
1331 	};
1332 	const enum rte_crypto_auth_algorithm auths[] = {
1333 		RTE_CRYPTO_AUTH_SHA512_HMAC
1334 	};
1335 
1336 	rte_cryptodev_info_get(dev_id, &dev_info);
1337 
1338 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1339 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1340 				"Session testsuite not met\n");
1341 		return TEST_SKIPPED;
1342 	}
1343 
1344 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1345 			&& check_auth_capabilities_supported(auths,
1346 			RTE_DIM(auths)) != 0) {
1347 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1348 				"Session testsuite not met\n");
1349 		return TEST_SKIPPED;
1350 	}
1351 
1352 	return 0;
1353 }
1354 
1355 static int
1356 negative_hmac_sha1_testsuite_setup(void)
1357 {
1358 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1359 	uint8_t dev_id = ts_params->valid_devs[0];
1360 	struct rte_cryptodev_info dev_info;
1361 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1362 		RTE_CRYPTO_CIPHER_AES_CBC
1363 	};
1364 	const enum rte_crypto_auth_algorithm auths[] = {
1365 		RTE_CRYPTO_AUTH_SHA1_HMAC
1366 	};
1367 
1368 	rte_cryptodev_info_get(dev_id, &dev_info);
1369 
1370 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1371 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1372 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1373 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1374 				"HMAC SHA1 testsuite not met\n");
1375 		return TEST_SKIPPED;
1376 	}
1377 
1378 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1379 			&& check_auth_capabilities_supported(auths,
1380 			RTE_DIM(auths)) != 0) {
1381 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1382 				"HMAC SHA1 testsuite not met\n");
1383 		return TEST_SKIPPED;
1384 	}
1385 
1386 	return 0;
1387 }
1388 
1389 static int
1390 dev_configure_and_start(uint64_t ff_disable)
1391 {
1392 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1393 	struct crypto_unittest_params *ut_params = &unittest_params;
1394 
1395 	uint16_t qp_id;
1396 
1397 	/* Clear unit test parameters before running test */
1398 	memset(ut_params, 0, sizeof(*ut_params));
1399 
1400 	/* Reconfigure device to default parameters */
1401 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1402 	ts_params->conf.ff_disable = ff_disable;
1403 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1404 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1405 
1406 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1407 			&ts_params->conf),
1408 			"Failed to configure cryptodev %u",
1409 			ts_params->valid_devs[0]);
1410 
1411 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1412 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1413 			ts_params->valid_devs[0], qp_id,
1414 			&ts_params->qp_conf,
1415 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1416 			"Failed to setup queue pair %u on cryptodev %u",
1417 			qp_id, ts_params->valid_devs[0]);
1418 	}
1419 
1420 
1421 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1422 
1423 	/* Start the device */
1424 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1425 			"Failed to start cryptodev %u",
1426 			ts_params->valid_devs[0]);
1427 
1428 	return TEST_SUCCESS;
1429 }
1430 
1431 int
1432 ut_setup(void)
1433 {
1434 	/* Configure and start the device with security feature disabled */
1435 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1436 }
1437 
1438 static int
1439 ut_setup_security(void)
1440 {
1441 	/* Configure and start the device with no features disabled */
1442 	return dev_configure_and_start(0);
1443 }
1444 
1445 static int
1446 ut_setup_security_rx_inject(void)
1447 {
1448 	struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1449 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1450 	struct rte_eth_conf port_conf = {
1451 		.rxmode = {
1452 			.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1453 				    RTE_ETH_RX_OFFLOAD_SECURITY,
1454 		},
1455 		.txmode = {
1456 			.offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1457 		},
1458 		.lpbk_mode = 1,  /* Enable loopback */
1459 	};
1460 	struct rte_cryptodev_info dev_info;
1461 	struct rte_eth_rxconf rx_conf = {
1462 		.rx_thresh = {
1463 			.pthresh = 8,
1464 			.hthresh = 8,
1465 			.wthresh = 8,
1466 		},
1467 		.rx_free_thresh = 32,
1468 	};
1469 	uint16_t nb_ports;
1470 	void *sec_ctx;
1471 	int ret;
1472 
1473 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1474 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1475 	    !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1476 		RTE_LOG(INFO, USER1,
1477 			"Feature requirements for IPsec Rx inject test case not met\n");
1478 		return TEST_SKIPPED;
1479 	}
1480 
1481 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1482 	if (sec_ctx == NULL)
1483 		return TEST_SKIPPED;
1484 
1485 	nb_ports = rte_eth_dev_count_avail();
1486 	if (nb_ports == 0)
1487 		return TEST_SKIPPED;
1488 
1489 	ret = rte_eth_dev_configure(0 /* port_id */,
1490 				    1 /* nb_rx_queue */,
1491 				    0 /* nb_tx_queue */,
1492 				    &port_conf);
1493 	if (ret) {
1494 		printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1495 		return TEST_SKIPPED;
1496 	}
1497 
1498 	/* Rx queue setup */
1499 	ret = rte_eth_rx_queue_setup(0 /* port_id */,
1500 				     0 /* rx_queue_id */,
1501 				     1024 /* nb_rx_desc */,
1502 				     SOCKET_ID_ANY,
1503 				     &rx_conf,
1504 				     mbuf_pool);
1505 	if (ret) {
1506 		printf("Could not setup eth port 0 queue 0\n");
1507 		return TEST_SKIPPED;
1508 	}
1509 
1510 	ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1511 	if (ret) {
1512 		printf("Could not enable Rx inject offload");
1513 		return TEST_SKIPPED;
1514 	}
1515 
1516 	ret = rte_eth_dev_start(0);
1517 	if (ret) {
1518 		printf("Could not start ethdev");
1519 		return TEST_SKIPPED;
1520 	}
1521 
1522 	ret = rte_eth_promiscuous_enable(0);
1523 	if (ret) {
1524 		printf("Could not enable promiscuous mode");
1525 		return TEST_SKIPPED;
1526 	}
1527 
1528 	/* Configure and start cryptodev with no features disabled */
1529 	return dev_configure_and_start(0);
1530 }
1531 
1532 static inline void
1533 ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1534 {
1535 }
1536 
1537 static inline void
1538 ext_mbuf_memzone_free(int nb_segs)
1539 {
1540 	int i;
1541 
1542 	for (i = 0; i <= nb_segs; i++) {
1543 		char mz_name[RTE_MEMZONE_NAMESIZE];
1544 		const struct rte_memzone *memzone;
1545 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1546 		memzone = rte_memzone_lookup(mz_name);
1547 		if (memzone != NULL) {
1548 			rte_memzone_free(memzone);
1549 			memzone = NULL;
1550 		}
1551 	}
1552 }
1553 
1554 static inline struct rte_mbuf *
1555 ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1556 		int nb_segs, const void *input_text)
1557 {
1558 	struct rte_mbuf *m = NULL, *mbuf = NULL;
1559 	size_t data_off = 0;
1560 	uint8_t *dst;
1561 	int i, size;
1562 	int t_len;
1563 
1564 	if (pkt_len < 1) {
1565 		printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1566 		return NULL;
1567 	}
1568 
1569 	if (nb_segs < 1) {
1570 		printf("Number of segments must be 1 or more (is %d)\n",
1571 				nb_segs);
1572 		return NULL;
1573 	}
1574 
1575 	t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1576 	size = pkt_len;
1577 
1578 	/* Create chained mbuf_src with external buffer */
1579 	for (i = 0; size > 0; i++) {
1580 		struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1581 		uint16_t data_len = RTE_MIN(size, t_len);
1582 		char mz_name[RTE_MEMZONE_NAMESIZE];
1583 		const struct rte_memzone *memzone;
1584 		void *ext_buf_addr = NULL;
1585 		rte_iova_t buf_iova;
1586 		bool freed = false;
1587 		uint16_t buf_len;
1588 
1589 		buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1590 			sizeof(struct rte_mbuf_ext_shared_info), 8);
1591 
1592 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1593 		memzone = rte_memzone_lookup(mz_name);
1594 		if (memzone != NULL && memzone->len != buf_len) {
1595 			rte_memzone_free(memzone);
1596 			memzone = NULL;
1597 		}
1598 		if (memzone == NULL) {
1599 			memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1600 				RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1601 			if (memzone == NULL) {
1602 				printf("Can't allocate memory zone %s\n", mz_name);
1603 				return NULL;
1604 			}
1605 		}
1606 
1607 		ext_buf_addr = memzone->addr;
1608 		if (input_text)
1609 			memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1610 
1611 		/* Create buffer to hold rte_mbuf header */
1612 		m = rte_pktmbuf_alloc(mbuf_pool);
1613 		if (i == 0)
1614 			mbuf = m;
1615 
1616 		if (m == NULL) {
1617 			printf("Cannot create segment for source mbuf");
1618 			goto fail;
1619 		}
1620 
1621 		/* Save shared data (like callback function) in external buffer's end */
1622 		ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1623 			ext_mbuf_callback_fn_free, &freed);
1624 		if (ret_shinfo == NULL) {
1625 			printf("Shared mem initialization failed!\n");
1626 			goto fail;
1627 		}
1628 
1629 		buf_iova = rte_mem_virt2iova(ext_buf_addr);
1630 
1631 		/* Attach external buffer to mbuf */
1632 		rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1633 			ret_shinfo);
1634 		if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1635 			printf("External buffer is not attached to mbuf\n");
1636 			goto fail;
1637 		}
1638 
1639 		if (input_text) {
1640 			dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1641 			if (dst == NULL) {
1642 				printf("Cannot append %d bytes to the mbuf\n", data_len);
1643 				goto fail;
1644 			}
1645 		}
1646 
1647 		if (mbuf != m)
1648 			rte_pktmbuf_chain(mbuf, m);
1649 
1650 		size -= data_len;
1651 		data_off += data_len;
1652 	}
1653 
1654 	return mbuf;
1655 
1656 fail:
1657 	rte_pktmbuf_free(mbuf);
1658 	ext_mbuf_memzone_free(nb_segs);
1659 	return NULL;
1660 }
1661 
1662 void
1663 ut_teardown(void)
1664 {
1665 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 	struct crypto_unittest_params *ut_params = &unittest_params;
1667 
1668 	/* free crypto session structure */
1669 #ifdef RTE_LIB_SECURITY
1670 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1671 		if (ut_params->sec_session) {
1672 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1673 						(ts_params->valid_devs[0]),
1674 						ut_params->sec_session);
1675 			ut_params->sec_session = NULL;
1676 		}
1677 	} else
1678 #endif
1679 	{
1680 		if (ut_params->sess) {
1681 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1682 					ut_params->sess);
1683 			ut_params->sess = NULL;
1684 		}
1685 	}
1686 
1687 	/* free crypto operation structure */
1688 	rte_crypto_op_free(ut_params->op);
1689 
1690 	/*
1691 	 * free mbuf - both obuf and ibuf are usually the same,
1692 	 * so check if they point at the same address is necessary,
1693 	 * to avoid freeing the mbuf twice.
1694 	 */
1695 	if (ut_params->obuf) {
1696 		rte_pktmbuf_free(ut_params->obuf);
1697 		if (ut_params->ibuf == ut_params->obuf)
1698 			ut_params->ibuf = 0;
1699 		ut_params->obuf = 0;
1700 	}
1701 	if (ut_params->ibuf) {
1702 		ext_mbuf_memzone_free(1);
1703 		rte_pktmbuf_free(ut_params->ibuf);
1704 		ut_params->ibuf = 0;
1705 	}
1706 
1707 	if (ts_params->mbuf_pool != NULL)
1708 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1709 			rte_mempool_avail_count(ts_params->mbuf_pool));
1710 
1711 	/* Stop the device */
1712 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1713 }
1714 
1715 static void
1716 ut_teardown_rx_inject(void)
1717 {
1718 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1719 	void *sec_ctx;
1720 	int ret;
1721 
1722 	if  (rte_eth_dev_count_avail() != 0) {
1723 		ret = rte_eth_dev_reset(0);
1724 		if (ret)
1725 			printf("Could not reset eth port 0");
1726 
1727 	}
1728 
1729 	ut_teardown();
1730 
1731 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1732 	if (sec_ctx == NULL)
1733 		return;
1734 
1735 	ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1736 	if (ret) {
1737 		printf("Could not disable Rx inject offload");
1738 		return;
1739 	}
1740 }
1741 
1742 static int
1743 test_device_configure_invalid_dev_id(void)
1744 {
1745 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1746 	uint16_t dev_id, num_devs = 0;
1747 
1748 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1749 			"Need at least %d devices for test", 1);
1750 
1751 	/* valid dev_id values */
1752 	dev_id = ts_params->valid_devs[0];
1753 
1754 	/* Stop the device in case it's started so it can be configured */
1755 	rte_cryptodev_stop(dev_id);
1756 
1757 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1758 			"Failed test for rte_cryptodev_configure: "
1759 			"invalid dev_num %u", dev_id);
1760 
1761 	/* invalid dev_id values */
1762 	dev_id = num_devs;
1763 
1764 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1765 			"Failed test for rte_cryptodev_configure: "
1766 			"invalid dev_num %u", dev_id);
1767 
1768 	dev_id = 0xff;
1769 
1770 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1771 			"Failed test for rte_cryptodev_configure:"
1772 			"invalid dev_num %u", dev_id);
1773 
1774 	return TEST_SUCCESS;
1775 }
1776 
1777 static int
1778 test_device_configure_invalid_queue_pair_ids(void)
1779 {
1780 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1781 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1782 
1783 	/* Stop the device in case it's started so it can be configured */
1784 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1785 
1786 	/* valid - max value queue pairs */
1787 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1788 
1789 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1790 			&ts_params->conf),
1791 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1792 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1793 
1794 	/* valid - one queue pairs */
1795 	ts_params->conf.nb_queue_pairs = 1;
1796 
1797 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1798 			&ts_params->conf),
1799 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1800 			ts_params->valid_devs[0],
1801 			ts_params->conf.nb_queue_pairs);
1802 
1803 
1804 	/* invalid - zero queue pairs */
1805 	ts_params->conf.nb_queue_pairs = 0;
1806 
1807 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1808 			&ts_params->conf),
1809 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1810 			" invalid qps: %u",
1811 			ts_params->valid_devs[0],
1812 			ts_params->conf.nb_queue_pairs);
1813 
1814 
1815 	/* invalid - max value supported by field queue pairs */
1816 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1817 
1818 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1819 			&ts_params->conf),
1820 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1821 			" invalid qps: %u",
1822 			ts_params->valid_devs[0],
1823 			ts_params->conf.nb_queue_pairs);
1824 
1825 
1826 	/* invalid - max value + 1 queue pairs */
1827 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1828 
1829 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1830 			&ts_params->conf),
1831 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1832 			" invalid qps: %u",
1833 			ts_params->valid_devs[0],
1834 			ts_params->conf.nb_queue_pairs);
1835 
1836 	/* revert to original testsuite value */
1837 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1838 
1839 	return TEST_SUCCESS;
1840 }
1841 
1842 static int
1843 test_queue_pair_descriptor_setup(void)
1844 {
1845 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 	struct rte_cryptodev_qp_conf qp_conf = {
1847 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1848 	};
1849 	uint16_t qp_id;
1850 
1851 	/* Stop the device in case it's started so it can be configured */
1852 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1853 
1854 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1855 			&ts_params->conf),
1856 			"Failed to configure cryptodev %u",
1857 			ts_params->valid_devs[0]);
1858 
1859 	/*
1860 	 * Test various ring sizes on this device. memzones can't be
1861 	 * freed so are re-used if ring is released and re-created.
1862 	 */
1863 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1864 	qp_conf.mp_session = ts_params->session_mpool;
1865 
1866 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1867 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1868 				ts_params->valid_devs[0], qp_id, &qp_conf,
1869 				rte_cryptodev_socket_id(
1870 						ts_params->valid_devs[0])),
1871 				"Failed test for "
1872 				"rte_cryptodev_queue_pair_setup: num_inflights "
1873 				"%u on qp %u on cryptodev %u",
1874 				qp_conf.nb_descriptors, qp_id,
1875 				ts_params->valid_devs[0]);
1876 	}
1877 
1878 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1879 
1880 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1881 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1882 				ts_params->valid_devs[0], qp_id, &qp_conf,
1883 				rte_cryptodev_socket_id(
1884 						ts_params->valid_devs[0])),
1885 				"Failed test for"
1886 				" rte_cryptodev_queue_pair_setup: num_inflights"
1887 				" %u on qp %u on cryptodev %u",
1888 				qp_conf.nb_descriptors, qp_id,
1889 				ts_params->valid_devs[0]);
1890 	}
1891 
1892 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1893 
1894 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1895 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1896 				ts_params->valid_devs[0], qp_id, &qp_conf,
1897 				rte_cryptodev_socket_id(
1898 						ts_params->valid_devs[0])),
1899 				"Failed test for "
1900 				"rte_cryptodev_queue_pair_setup: num_inflights"
1901 				" %u on qp %u on cryptodev %u",
1902 				qp_conf.nb_descriptors, qp_id,
1903 				ts_params->valid_devs[0]);
1904 	}
1905 
1906 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1907 
1908 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1909 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1910 				ts_params->valid_devs[0], qp_id, &qp_conf,
1911 				rte_cryptodev_socket_id(
1912 						ts_params->valid_devs[0])),
1913 				"Failed test for"
1914 				" rte_cryptodev_queue_pair_setup:"
1915 				"num_inflights %u on qp %u on cryptodev %u",
1916 				qp_conf.nb_descriptors, qp_id,
1917 				ts_params->valid_devs[0]);
1918 	}
1919 
1920 	/* test invalid queue pair id */
1921 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1922 
1923 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1924 
1925 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1926 			ts_params->valid_devs[0],
1927 			qp_id, &qp_conf,
1928 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1929 			"Failed test for rte_cryptodev_queue_pair_setup:"
1930 			"invalid qp %u on cryptodev %u",
1931 			qp_id, ts_params->valid_devs[0]);
1932 
1933 	qp_id = 0xffff; /*invalid*/
1934 
1935 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1936 			ts_params->valid_devs[0],
1937 			qp_id, &qp_conf,
1938 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1939 			"Failed test for rte_cryptodev_queue_pair_setup:"
1940 			"invalid qp %u on cryptodev %u",
1941 			qp_id, ts_params->valid_devs[0]);
1942 
1943 	return TEST_SUCCESS;
1944 }
1945 
1946 /* ***** Plaintext data for tests ***** */
1947 
1948 const char catch_22_quote_1[] =
1949 		"There was only one catch and that was Catch-22, which "
1950 		"specified that a concern for one's safety in the face of "
1951 		"dangers that were real and immediate was the process of a "
1952 		"rational mind. Orr was crazy and could be grounded. All he "
1953 		"had to do was ask; and as soon as he did, he would no longer "
1954 		"be crazy and would have to fly more missions. Orr would be "
1955 		"crazy to fly more missions and sane if he didn't, but if he "
1956 		"was sane he had to fly them. If he flew them he was crazy "
1957 		"and didn't have to; but if he didn't want to he was sane and "
1958 		"had to. Yossarian was moved very deeply by the absolute "
1959 		"simplicity of this clause of Catch-22 and let out a "
1960 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1961 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1962 
1963 const char catch_22_quote[] =
1964 		"What a lousy earth! He wondered how many people were "
1965 		"destitute that same night even in his own prosperous country, "
1966 		"how many homes were shanties, how many husbands were drunk "
1967 		"and wives socked, and how many children were bullied, abused, "
1968 		"or abandoned. How many families hungered for food they could "
1969 		"not afford to buy? How many hearts were broken? How many "
1970 		"suicides would take place that same night, how many people "
1971 		"would go insane? How many cockroaches and landlords would "
1972 		"triumph? How many winners were losers, successes failures, "
1973 		"and rich men poor men? How many wise guys were stupid? How "
1974 		"many happy endings were unhappy endings? How many honest men "
1975 		"were liars, brave men cowards, loyal men traitors, how many "
1976 		"sainted men were corrupt, how many people in positions of "
1977 		"trust had sold their souls to bodyguards, how many had never "
1978 		"had souls? How many straight-and-narrow paths were crooked "
1979 		"paths? How many best families were worst families and how "
1980 		"many good people were bad people? When you added them all up "
1981 		"and then subtracted, you might be left with only the children, "
1982 		"and perhaps with Albert Einstein and an old violinist or "
1983 		"sculptor somewhere.";
1984 
1985 #define QUOTE_480_BYTES		(480)
1986 #define QUOTE_512_BYTES		(512)
1987 #define QUOTE_768_BYTES		(768)
1988 #define QUOTE_1024_BYTES	(1024)
1989 
1990 
1991 
1992 /* ***** SHA1 Hash Tests ***** */
1993 
1994 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1995 
1996 static uint8_t hmac_sha1_key[] = {
1997 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1998 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1999 	0xDE, 0xF4, 0xDE, 0xAD };
2000 
2001 /* ***** SHA224 Hash Tests ***** */
2002 
2003 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
2004 
2005 
2006 /* ***** AES-CBC Cipher Tests ***** */
2007 
2008 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
2009 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
2010 
2011 static uint8_t aes_cbc_key[] = {
2012 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2013 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2014 
2015 static uint8_t aes_cbc_iv[] = {
2016 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2017 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2018 
2019 
2020 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2021 
2022 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2023 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2024 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2025 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2026 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2027 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2028 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2029 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2030 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2031 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2032 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2033 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2034 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2035 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2036 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2037 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2038 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2039 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2040 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2041 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2042 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2043 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2044 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2045 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2046 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2047 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2048 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2049 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2050 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2051 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2052 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2053 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2054 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2055 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2056 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2057 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2058 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2059 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2060 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2061 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2062 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2063 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2064 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2065 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2066 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2067 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2068 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2069 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2070 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2071 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2072 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2073 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2074 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2075 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2076 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2077 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2078 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2079 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2080 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2081 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2082 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2083 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2084 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2085 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2086 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2087 };
2088 
2089 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2090 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2091 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2092 	0x18, 0x8c, 0x1d, 0x32
2093 };
2094 
2095 
2096 /* Multisession Vector context Test */
2097 /*Begin Session 0 */
2098 static uint8_t ms_aes_cbc_key0[] = {
2099 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2100 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2101 };
2102 
2103 static uint8_t ms_aes_cbc_iv0[] = {
2104 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2105 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2106 };
2107 
2108 static const uint8_t ms_aes_cbc_cipher0[] = {
2109 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2110 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2111 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2112 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2113 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2114 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2115 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2116 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2117 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2118 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2119 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2120 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2121 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2122 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2123 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2124 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2125 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2126 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2127 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2128 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2129 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2130 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2131 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2132 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2133 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2134 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2135 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2136 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2137 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2138 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2139 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2140 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2141 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2142 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2143 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2144 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2145 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2146 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2147 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2148 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2149 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2150 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2151 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2152 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2153 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2154 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2155 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2156 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2157 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2158 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2159 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2160 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2161 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2162 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2163 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2164 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2165 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2166 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2167 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2168 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2169 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2170 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2171 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2172 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2173 };
2174 
2175 
2176 static  uint8_t ms_hmac_key0[] = {
2177 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2178 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2179 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2180 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2181 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2182 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2183 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2184 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2185 };
2186 
2187 static const uint8_t ms_hmac_digest0[] = {
2188 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2189 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2190 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2191 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2192 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2193 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2194 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2195 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2196 		};
2197 
2198 /* End Session 0 */
2199 /* Begin session 1 */
2200 
2201 static  uint8_t ms_aes_cbc_key1[] = {
2202 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2203 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2204 };
2205 
2206 static  uint8_t ms_aes_cbc_iv1[] = {
2207 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2208 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2209 };
2210 
2211 static const uint8_t ms_aes_cbc_cipher1[] = {
2212 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2213 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2214 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2215 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2216 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2217 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2218 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2219 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2220 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2221 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2222 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2223 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2224 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2225 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2226 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2227 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2228 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2229 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2230 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2231 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2232 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2233 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2234 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2235 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2236 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2237 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2238 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2239 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2240 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2241 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2242 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2243 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2244 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2245 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2246 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2247 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2248 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2249 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2250 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2251 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2252 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2253 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2254 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2255 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2256 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2257 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2258 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2259 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2260 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2261 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2262 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2263 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2264 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2265 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2266 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2267 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2268 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2269 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2270 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2271 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2272 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2273 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2274 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2275 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2276 
2277 };
2278 
2279 static uint8_t ms_hmac_key1[] = {
2280 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2281 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2282 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2283 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2284 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2285 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2286 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2287 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2288 };
2289 
2290 static const uint8_t ms_hmac_digest1[] = {
2291 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2292 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2293 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2294 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2295 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2296 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2297 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2298 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2299 };
2300 /* End Session 1  */
2301 /* Begin Session 2 */
2302 static  uint8_t ms_aes_cbc_key2[] = {
2303 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2304 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2305 };
2306 
2307 static  uint8_t ms_aes_cbc_iv2[] = {
2308 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2309 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2310 };
2311 
2312 static const uint8_t ms_aes_cbc_cipher2[] = {
2313 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2314 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2315 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2316 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2317 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2318 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2319 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2320 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2321 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2322 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2323 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2324 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2325 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2326 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2327 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2328 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2329 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2330 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2331 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2332 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2333 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2334 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2335 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2336 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2337 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2338 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2339 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2340 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2341 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2342 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2343 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2344 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2345 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2346 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2347 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2348 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2349 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2350 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2351 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2352 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2353 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2354 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2355 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2356 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2357 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2358 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2359 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2360 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2361 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2362 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2363 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2364 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2365 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2366 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2367 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2368 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2369 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2370 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2371 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2372 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2373 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2374 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2375 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2376 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2377 };
2378 
2379 static  uint8_t ms_hmac_key2[] = {
2380 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2381 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2382 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2383 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2384 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2385 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2386 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2387 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2388 };
2389 
2390 static const uint8_t ms_hmac_digest2[] = {
2391 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2392 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2393 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2394 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2395 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2396 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2397 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2398 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2399 };
2400 
2401 /* End Session 2 */
2402 
2403 
2404 static int
2405 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2406 {
2407 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2408 	struct crypto_unittest_params *ut_params = &unittest_params;
2409 	/* Verify the capabilities */
2410 	struct rte_cryptodev_sym_capability_idx cap_idx;
2411 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2412 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2413 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2414 			&cap_idx) == NULL)
2415 		return TEST_SKIPPED;
2416 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2417 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2418 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2419 			&cap_idx) == NULL)
2420 		return TEST_SKIPPED;
2421 
2422 	/* Generate test mbuf data and space for digest */
2423 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2424 			catch_22_quote,	QUOTE_512_BYTES, 0);
2425 
2426 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2427 			DIGEST_BYTE_LENGTH_SHA1);
2428 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2429 
2430 	/* Setup Cipher Parameters */
2431 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2432 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2433 
2434 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2435 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2436 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2437 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2438 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2439 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2440 
2441 	/* Setup HMAC Parameters */
2442 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2443 
2444 	ut_params->auth_xform.next = NULL;
2445 
2446 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2447 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2448 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2449 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2450 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2451 
2452 	rte_errno = 0;
2453 	ut_params->sess = rte_cryptodev_sym_session_create(
2454 			ts_params->valid_devs[0], &ut_params->cipher_xform,
2455 			ts_params->session_mpool);
2456 	if (rte_errno == ENOTSUP)
2457 		return TEST_SKIPPED;
2458 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2459 
2460 	/* Generate crypto op data structure */
2461 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2462 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2463 	TEST_ASSERT_NOT_NULL(ut_params->op,
2464 			"Failed to allocate symmetric crypto operation struct");
2465 
2466 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2467 
2468 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2469 
2470 	/* set crypto operation source mbuf */
2471 	sym_op->m_src = ut_params->ibuf;
2472 
2473 	/* Set crypto operation authentication parameters */
2474 	sym_op->auth.digest.data = ut_params->digest;
2475 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2476 			ut_params->ibuf, QUOTE_512_BYTES);
2477 
2478 	sym_op->auth.data.offset = 0;
2479 	sym_op->auth.data.length = QUOTE_512_BYTES;
2480 
2481 	/* Copy IV at the end of the crypto operation */
2482 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2483 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2484 
2485 	/* Set crypto operation cipher parameters */
2486 	sym_op->cipher.data.offset = 0;
2487 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2488 
2489 	/* Process crypto operation */
2490 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2491 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2492 			ut_params->op);
2493 	else
2494 		TEST_ASSERT_NOT_NULL(
2495 			process_crypto_request(ts_params->valid_devs[0],
2496 				ut_params->op),
2497 				"failed to process sym crypto op");
2498 
2499 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2500 			"crypto op processing failed");
2501 
2502 	/* Validate obuf */
2503 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2504 			uint8_t *);
2505 
2506 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2507 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2508 			QUOTE_512_BYTES,
2509 			"ciphertext data not as expected");
2510 
2511 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2512 
2513 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2514 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2515 			gbl_driver_id == rte_cryptodev_driver_id_get(
2516 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2517 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2518 					DIGEST_BYTE_LENGTH_SHA1,
2519 			"Generated digest data not as expected");
2520 
2521 	return TEST_SUCCESS;
2522 }
2523 
2524 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2525 
2526 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2527 
2528 static uint8_t hmac_sha512_key[] = {
2529 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2530 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2531 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2532 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2533 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2534 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2535 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2536 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2537 
2538 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2539 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2540 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2541 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2542 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2543 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2544 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2545 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2546 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2547 
2548 
2549 
2550 static int
2551 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2552 		struct crypto_unittest_params *ut_params,
2553 		uint8_t *cipher_key,
2554 		uint8_t *hmac_key);
2555 
2556 static int
2557 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2558 		struct crypto_unittest_params *ut_params,
2559 		struct crypto_testsuite_params *ts_params,
2560 		const uint8_t *cipher,
2561 		const uint8_t *digest,
2562 		const uint8_t *iv);
2563 
2564 
2565 static int
2566 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2567 		struct crypto_unittest_params *ut_params,
2568 		uint8_t *cipher_key,
2569 		uint8_t *hmac_key)
2570 {
2571 
2572 	/* Setup Cipher Parameters */
2573 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2574 	ut_params->cipher_xform.next = NULL;
2575 
2576 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2577 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2578 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2579 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2580 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2581 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2582 
2583 	/* Setup HMAC Parameters */
2584 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2585 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2586 
2587 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2588 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2589 	ut_params->auth_xform.auth.key.data = hmac_key;
2590 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2591 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2592 
2593 	return TEST_SUCCESS;
2594 }
2595 
2596 
2597 static int
2598 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2599 		struct crypto_unittest_params *ut_params,
2600 		struct crypto_testsuite_params *ts_params,
2601 		const uint8_t *cipher,
2602 		const uint8_t *digest,
2603 		const uint8_t *iv)
2604 {
2605 	int ret;
2606 
2607 	/* Generate test mbuf data and digest */
2608 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2609 			(const char *)
2610 			cipher,
2611 			QUOTE_512_BYTES, 0);
2612 
2613 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2614 			DIGEST_BYTE_LENGTH_SHA512);
2615 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2616 
2617 	rte_memcpy(ut_params->digest,
2618 			digest,
2619 			DIGEST_BYTE_LENGTH_SHA512);
2620 
2621 	/* Generate Crypto op data structure */
2622 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2623 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2624 	TEST_ASSERT_NOT_NULL(ut_params->op,
2625 			"Failed to allocate symmetric crypto operation struct");
2626 
2627 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2628 
2629 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2630 
2631 	/* set crypto operation source mbuf */
2632 	sym_op->m_src = ut_params->ibuf;
2633 
2634 	sym_op->auth.digest.data = ut_params->digest;
2635 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2636 			ut_params->ibuf, QUOTE_512_BYTES);
2637 
2638 	sym_op->auth.data.offset = 0;
2639 	sym_op->auth.data.length = QUOTE_512_BYTES;
2640 
2641 	/* Copy IV at the end of the crypto operation */
2642 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2643 			iv, CIPHER_IV_LENGTH_AES_CBC);
2644 
2645 	sym_op->cipher.data.offset = 0;
2646 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2647 
2648 	/* Process crypto operation */
2649 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2650 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2651 			ut_params->op);
2652 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2653 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2654 		if (ret != TEST_SUCCESS)
2655 			return ret;
2656 	} else
2657 		TEST_ASSERT_NOT_NULL(
2658 				process_crypto_request(ts_params->valid_devs[0],
2659 					ut_params->op),
2660 					"failed to process sym crypto op");
2661 
2662 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2663 			"crypto op processing failed");
2664 
2665 	ut_params->obuf = ut_params->op->sym->m_src;
2666 
2667 	/* Validate obuf */
2668 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2669 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2670 			catch_22_quote,
2671 			QUOTE_512_BYTES,
2672 			"Plaintext data not as expected");
2673 
2674 	/* Validate obuf */
2675 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2676 			"Digest verification failed");
2677 
2678 	return TEST_SUCCESS;
2679 }
2680 
2681 /* ***** SNOW 3G Tests ***** */
2682 static int
2683 create_wireless_algo_hash_session(uint8_t dev_id,
2684 	const uint8_t *key, const uint8_t key_len,
2685 	const uint8_t iv_len, const uint8_t auth_len,
2686 	enum rte_crypto_auth_operation op,
2687 	enum rte_crypto_auth_algorithm algo)
2688 {
2689 	uint8_t hash_key[key_len];
2690 
2691 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2692 	struct crypto_unittest_params *ut_params = &unittest_params;
2693 
2694 	memcpy(hash_key, key, key_len);
2695 
2696 	debug_hexdump(stdout, "key:", key, key_len);
2697 
2698 	/* Setup Authentication Parameters */
2699 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2700 	ut_params->auth_xform.next = NULL;
2701 
2702 	ut_params->auth_xform.auth.op = op;
2703 	ut_params->auth_xform.auth.algo = algo;
2704 	ut_params->auth_xform.auth.key.length = key_len;
2705 	ut_params->auth_xform.auth.key.data = hash_key;
2706 	ut_params->auth_xform.auth.digest_length = auth_len;
2707 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2708 	ut_params->auth_xform.auth.iv.length = iv_len;
2709 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2710 			&ut_params->auth_xform, ts_params->session_mpool);
2711 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2712 		return TEST_SKIPPED;
2713 
2714 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2715 	return 0;
2716 }
2717 
2718 static int
2719 create_wireless_algo_cipher_session(uint8_t dev_id,
2720 			enum rte_crypto_cipher_operation op,
2721 			enum rte_crypto_cipher_algorithm algo,
2722 			const uint8_t *key, const uint8_t key_len,
2723 			uint8_t iv_len)
2724 {
2725 	uint8_t cipher_key[key_len];
2726 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2727 	struct crypto_unittest_params *ut_params = &unittest_params;
2728 
2729 	memcpy(cipher_key, key, key_len);
2730 
2731 	/* Setup Cipher Parameters */
2732 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2733 	ut_params->cipher_xform.next = NULL;
2734 
2735 	ut_params->cipher_xform.cipher.algo = algo;
2736 	ut_params->cipher_xform.cipher.op = op;
2737 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2738 	ut_params->cipher_xform.cipher.key.length = key_len;
2739 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2740 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2741 
2742 	debug_hexdump(stdout, "key:", key, key_len);
2743 
2744 	/* Create Crypto session */
2745 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2746 			&ut_params->cipher_xform, ts_params->session_mpool);
2747 
2748 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2749 		return TEST_SKIPPED;
2750 
2751 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2752 	return 0;
2753 }
2754 
2755 static int
2756 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2757 			unsigned int cipher_len,
2758 			unsigned int cipher_offset)
2759 {
2760 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2761 	struct crypto_unittest_params *ut_params = &unittest_params;
2762 
2763 	/* Generate Crypto op data structure */
2764 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2765 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2766 	TEST_ASSERT_NOT_NULL(ut_params->op,
2767 				"Failed to allocate pktmbuf offload");
2768 
2769 	/* Set crypto operation data parameters */
2770 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2771 
2772 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2773 
2774 	/* set crypto operation source mbuf */
2775 	sym_op->m_src = ut_params->ibuf;
2776 
2777 	/* iv */
2778 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2779 			iv, iv_len);
2780 	sym_op->cipher.data.length = cipher_len;
2781 	sym_op->cipher.data.offset = cipher_offset;
2782 	return 0;
2783 }
2784 
2785 static int
2786 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2787 			unsigned int cipher_len,
2788 			unsigned int cipher_offset)
2789 {
2790 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2791 	struct crypto_unittest_params *ut_params = &unittest_params;
2792 
2793 	/* Generate Crypto op data structure */
2794 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2795 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2796 	TEST_ASSERT_NOT_NULL(ut_params->op,
2797 				"Failed to allocate pktmbuf offload");
2798 
2799 	/* Set crypto operation data parameters */
2800 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2801 
2802 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2803 
2804 	/* set crypto operation source mbuf */
2805 	sym_op->m_src = ut_params->ibuf;
2806 	sym_op->m_dst = ut_params->obuf;
2807 
2808 	/* iv */
2809 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2810 			iv, iv_len);
2811 	sym_op->cipher.data.length = cipher_len;
2812 	sym_op->cipher.data.offset = cipher_offset;
2813 	return 0;
2814 }
2815 
2816 static int
2817 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2818 		enum rte_crypto_cipher_operation cipher_op,
2819 		enum rte_crypto_auth_operation auth_op,
2820 		enum rte_crypto_auth_algorithm auth_algo,
2821 		enum rte_crypto_cipher_algorithm cipher_algo,
2822 		const uint8_t *a_key, uint8_t a_key_len,
2823 		const uint8_t *c_key, uint8_t c_key_len,
2824 		uint8_t auth_iv_len, uint8_t auth_len,
2825 		uint8_t cipher_iv_len)
2826 
2827 {
2828 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2829 	struct crypto_unittest_params *ut_params = &unittest_params;
2830 
2831 	/* Setup Authentication Parameters */
2832 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2833 	ut_params->auth_xform.next = NULL;
2834 
2835 	ut_params->auth_xform.auth.op = auth_op;
2836 	ut_params->auth_xform.auth.algo = auth_algo;
2837 	ut_params->auth_xform.auth.key.length = a_key_len;
2838 	ut_params->auth_xform.auth.key.data = a_key;
2839 	ut_params->auth_xform.auth.digest_length = auth_len;
2840 	/* Auth IV will be after cipher IV */
2841 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2842 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2843 
2844 	/* Setup Cipher Parameters */
2845 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2846 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2847 
2848 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2849 	ut_params->cipher_xform.cipher.op = cipher_op;
2850 	ut_params->cipher_xform.cipher.key.data = c_key;
2851 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2852 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2853 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2854 
2855 	debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
2856 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2857 
2858 	/* Create Crypto session*/
2859 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2860 			&ut_params->cipher_xform, ts_params->session_mpool);
2861 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2862 		return TEST_SKIPPED;
2863 
2864 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2865 	return 0;
2866 }
2867 
2868 static int
2869 create_wireless_cipher_auth_session(uint8_t dev_id,
2870 		enum rte_crypto_cipher_operation cipher_op,
2871 		enum rte_crypto_auth_operation auth_op,
2872 		enum rte_crypto_auth_algorithm auth_algo,
2873 		enum rte_crypto_cipher_algorithm cipher_algo,
2874 		const struct wireless_test_data *tdata)
2875 {
2876 	const uint8_t key_len = tdata->key.len;
2877 	uint8_t cipher_auth_key[key_len];
2878 
2879 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2880 	struct crypto_unittest_params *ut_params = &unittest_params;
2881 	const uint8_t *key = tdata->key.data;
2882 	const uint8_t auth_len = tdata->digest.len;
2883 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2884 	uint8_t auth_iv_len = tdata->auth_iv.len;
2885 
2886 	memcpy(cipher_auth_key, key, key_len);
2887 
2888 	/* Setup Authentication Parameters */
2889 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2890 	ut_params->auth_xform.next = NULL;
2891 
2892 	ut_params->auth_xform.auth.op = auth_op;
2893 	ut_params->auth_xform.auth.algo = auth_algo;
2894 	ut_params->auth_xform.auth.key.length = key_len;
2895 	/* Hash key = cipher key */
2896 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2897 	ut_params->auth_xform.auth.digest_length = auth_len;
2898 	/* Auth IV will be after cipher IV */
2899 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2900 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2901 
2902 	/* Setup Cipher Parameters */
2903 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2904 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2905 
2906 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2907 	ut_params->cipher_xform.cipher.op = cipher_op;
2908 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2909 	ut_params->cipher_xform.cipher.key.length = key_len;
2910 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2911 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2912 
2913 
2914 	debug_hexdump(stdout, "key:", key, key_len);
2915 
2916 	/* Create Crypto session*/
2917 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2918 			&ut_params->cipher_xform, ts_params->session_mpool);
2919 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2920 		return TEST_SKIPPED;
2921 
2922 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2923 	return 0;
2924 }
2925 
2926 static int
2927 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2928 		const struct wireless_test_data *tdata)
2929 {
2930 	return create_wireless_cipher_auth_session(dev_id,
2931 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2932 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2933 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2934 }
2935 
2936 static int
2937 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2938 		enum rte_crypto_cipher_operation cipher_op,
2939 		enum rte_crypto_auth_operation auth_op,
2940 		enum rte_crypto_auth_algorithm auth_algo,
2941 		enum rte_crypto_cipher_algorithm cipher_algo,
2942 		const uint8_t *a_key, const uint8_t a_key_len,
2943 		const uint8_t *c_key, const uint8_t c_key_len,
2944 		uint8_t auth_iv_len, uint8_t auth_len,
2945 		uint8_t cipher_iv_len)
2946 {
2947 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2948 	struct crypto_unittest_params *ut_params = &unittest_params;
2949 
2950 	/* Setup Authentication Parameters */
2951 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2952 	ut_params->auth_xform.auth.op = auth_op;
2953 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2954 	ut_params->auth_xform.auth.algo = auth_algo;
2955 	ut_params->auth_xform.auth.key.length = a_key_len;
2956 	ut_params->auth_xform.auth.key.data = a_key;
2957 	ut_params->auth_xform.auth.digest_length = auth_len;
2958 	/* Auth IV will be after cipher IV */
2959 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2960 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2961 
2962 	/* Setup Cipher Parameters */
2963 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2964 	ut_params->cipher_xform.next = NULL;
2965 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2966 	ut_params->cipher_xform.cipher.op = cipher_op;
2967 	ut_params->cipher_xform.cipher.key.data = c_key;
2968 	ut_params->cipher_xform.cipher.key.length = c_key_len;
2969 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2970 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2971 
2972 	debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
2973 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2974 
2975 	/* Create Crypto session*/
2976 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2977 		ut_params->auth_xform.next = NULL;
2978 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2979 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2980 			&ut_params->cipher_xform, ts_params->session_mpool);
2981 	} else
2982 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2983 			&ut_params->auth_xform, ts_params->session_mpool);
2984 
2985 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2986 		return TEST_SKIPPED;
2987 
2988 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2989 
2990 	return 0;
2991 }
2992 
2993 static int
2994 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2995 		unsigned int auth_tag_len,
2996 		const uint8_t *iv, unsigned int iv_len,
2997 		unsigned int data_pad_len,
2998 		enum rte_crypto_auth_operation op,
2999 		unsigned int auth_len, unsigned int auth_offset)
3000 {
3001 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3002 
3003 	struct crypto_unittest_params *ut_params = &unittest_params;
3004 
3005 	/* Generate Crypto op data structure */
3006 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3007 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3008 	TEST_ASSERT_NOT_NULL(ut_params->op,
3009 		"Failed to allocate pktmbuf offload");
3010 
3011 	/* Set crypto operation data parameters */
3012 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3013 
3014 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3015 
3016 	/* set crypto operation source mbuf */
3017 	sym_op->m_src = ut_params->ibuf;
3018 
3019 	/* iv */
3020 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3021 			iv, iv_len);
3022 	/* digest */
3023 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3024 					ut_params->ibuf, auth_tag_len);
3025 
3026 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3027 				"no room to append auth tag");
3028 	ut_params->digest = sym_op->auth.digest.data;
3029 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3030 			ut_params->ibuf, data_pad_len);
3031 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3032 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3033 	else
3034 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3035 
3036 	debug_hexdump(stdout, "digest:",
3037 		sym_op->auth.digest.data,
3038 		auth_tag_len);
3039 
3040 	sym_op->auth.data.length = auth_len;
3041 	sym_op->auth.data.offset = auth_offset;
3042 
3043 	return 0;
3044 }
3045 
3046 static int
3047 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3048 	enum rte_crypto_auth_operation op)
3049 {
3050 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3051 	struct crypto_unittest_params *ut_params = &unittest_params;
3052 
3053 	const uint8_t *auth_tag = tdata->digest.data;
3054 	const unsigned int auth_tag_len = tdata->digest.len;
3055 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3056 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3057 
3058 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
3059 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3060 	const uint8_t *auth_iv = tdata->auth_iv.data;
3061 	const uint8_t auth_iv_len = tdata->auth_iv.len;
3062 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3063 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
3064 
3065 	/* Generate Crypto op data structure */
3066 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3067 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3068 	TEST_ASSERT_NOT_NULL(ut_params->op,
3069 			"Failed to allocate pktmbuf offload");
3070 	/* Set crypto operation data parameters */
3071 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3072 
3073 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3074 
3075 	/* set crypto operation source mbuf */
3076 	sym_op->m_src = ut_params->ibuf;
3077 
3078 	/* digest */
3079 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3080 			ut_params->ibuf, auth_tag_len);
3081 
3082 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3083 			"no room to append auth tag");
3084 	ut_params->digest = sym_op->auth.digest.data;
3085 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3086 			ut_params->ibuf, data_pad_len);
3087 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3088 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3089 	else
3090 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3091 
3092 	debug_hexdump(stdout, "digest:",
3093 		sym_op->auth.digest.data,
3094 		auth_tag_len);
3095 
3096 	/* Copy cipher and auth IVs at the end of the crypto operation */
3097 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3098 						IV_OFFSET);
3099 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3100 	iv_ptr += cipher_iv_len;
3101 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3102 
3103 	sym_op->cipher.data.length = cipher_len;
3104 	sym_op->cipher.data.offset = 0;
3105 	sym_op->auth.data.length = auth_len;
3106 	sym_op->auth.data.offset = 0;
3107 
3108 	return 0;
3109 }
3110 
3111 static int
3112 create_zuc_cipher_hash_generate_operation(
3113 		const struct wireless_test_data *tdata)
3114 {
3115 	return create_wireless_cipher_hash_operation(tdata,
3116 		RTE_CRYPTO_AUTH_OP_GENERATE);
3117 }
3118 
3119 static int
3120 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3121 		const unsigned auth_tag_len,
3122 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3123 		unsigned data_pad_len,
3124 		enum rte_crypto_auth_operation op,
3125 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3126 		const unsigned cipher_len, const unsigned cipher_offset,
3127 		const unsigned auth_len, const unsigned auth_offset)
3128 {
3129 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3130 	struct crypto_unittest_params *ut_params = &unittest_params;
3131 
3132 	enum rte_crypto_cipher_algorithm cipher_algo =
3133 			ut_params->cipher_xform.cipher.algo;
3134 	enum rte_crypto_auth_algorithm auth_algo =
3135 			ut_params->auth_xform.auth.algo;
3136 
3137 	/* Generate Crypto op data structure */
3138 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3139 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3140 	TEST_ASSERT_NOT_NULL(ut_params->op,
3141 			"Failed to allocate pktmbuf offload");
3142 	/* Set crypto operation data parameters */
3143 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3144 
3145 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3146 
3147 	/* set crypto operation source mbuf */
3148 	sym_op->m_src = ut_params->ibuf;
3149 
3150 	/* digest */
3151 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3152 			ut_params->ibuf, auth_tag_len);
3153 
3154 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3155 			"no room to append auth tag");
3156 	ut_params->digest = sym_op->auth.digest.data;
3157 
3158 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3159 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3160 				ut_params->ibuf, data_pad_len);
3161 	} else {
3162 		struct rte_mbuf *m = ut_params->ibuf;
3163 		unsigned int offset = data_pad_len;
3164 
3165 		while (offset > m->data_len && m->next != NULL) {
3166 			offset -= m->data_len;
3167 			m = m->next;
3168 		}
3169 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3170 			m, offset);
3171 	}
3172 
3173 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3174 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3175 	else
3176 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3177 
3178 	debug_hexdump(stdout, "digest:",
3179 		sym_op->auth.digest.data,
3180 		auth_tag_len);
3181 
3182 	/* Copy cipher and auth IVs at the end of the crypto operation */
3183 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3184 						IV_OFFSET);
3185 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3186 	iv_ptr += cipher_iv_len;
3187 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3188 
3189 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3190 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3191 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3192 		sym_op->cipher.data.length = cipher_len;
3193 		sym_op->cipher.data.offset = cipher_offset;
3194 	} else {
3195 		sym_op->cipher.data.length = cipher_len >> 3;
3196 		sym_op->cipher.data.offset = cipher_offset >> 3;
3197 	}
3198 
3199 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3200 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3201 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3202 		sym_op->auth.data.length = auth_len;
3203 		sym_op->auth.data.offset = auth_offset;
3204 	} else {
3205 		sym_op->auth.data.length = auth_len >> 3;
3206 		sym_op->auth.data.offset = auth_offset >> 3;
3207 	}
3208 
3209 	return 0;
3210 }
3211 
3212 static int
3213 create_wireless_algo_auth_cipher_operation(
3214 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3215 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3216 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3217 		unsigned int data_pad_len,
3218 		unsigned int cipher_len, unsigned int cipher_offset,
3219 		unsigned int auth_len, unsigned int auth_offset,
3220 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3221 {
3222 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3223 	struct crypto_unittest_params *ut_params = &unittest_params;
3224 
3225 	enum rte_crypto_cipher_algorithm cipher_algo =
3226 			ut_params->cipher_xform.cipher.algo;
3227 	enum rte_crypto_auth_algorithm auth_algo =
3228 			ut_params->auth_xform.auth.algo;
3229 
3230 	/* Generate Crypto op data structure */
3231 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3232 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3233 	TEST_ASSERT_NOT_NULL(ut_params->op,
3234 			"Failed to allocate pktmbuf offload");
3235 
3236 	/* Set crypto operation data parameters */
3237 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3238 
3239 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3240 
3241 	/* set crypto operation mbufs */
3242 	sym_op->m_src = ut_params->ibuf;
3243 	if (op_mode == OUT_OF_PLACE)
3244 		sym_op->m_dst = ut_params->obuf;
3245 
3246 	/* digest */
3247 	if (!do_sgl) {
3248 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3249 			(op_mode == IN_PLACE ?
3250 				ut_params->ibuf : ut_params->obuf),
3251 			uint8_t *, data_pad_len);
3252 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3253 			(op_mode == IN_PLACE ?
3254 				ut_params->ibuf : ut_params->obuf),
3255 			data_pad_len);
3256 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3257 	} else {
3258 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3259 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3260 				sym_op->m_src : sym_op->m_dst);
3261 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3262 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3263 			sgl_buf = sgl_buf->next;
3264 		}
3265 
3266 		/* The last segment should be large enough to hold full digest */
3267 		if (sgl_buf->data_len < auth_tag_len) {
3268 			rte_pktmbuf_free(sgl_buf->next);
3269 			sgl_buf->next = NULL;
3270 			TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3271 					auth_tag_len - sgl_buf->data_len),
3272 					"No room to append auth tag");
3273 		}
3274 
3275 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3276 				uint8_t *, remaining_off);
3277 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3278 				remaining_off);
3279 		memset(sym_op->auth.digest.data, 0, remaining_off);
3280 		while (sgl_buf->next != NULL) {
3281 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3282 				0, rte_pktmbuf_data_len(sgl_buf));
3283 			sgl_buf = sgl_buf->next;
3284 		}
3285 	}
3286 
3287 	/* Copy digest for the verification */
3288 	if (verify)
3289 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3290 
3291 	/* Copy cipher and auth IVs at the end of the crypto operation */
3292 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3293 			ut_params->op, uint8_t *, IV_OFFSET);
3294 
3295 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3296 	iv_ptr += cipher_iv_len;
3297 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3298 
3299 	/* Only copy over the offset data needed from src to dst in OOP,
3300 	 * if the auth and cipher offsets are not aligned
3301 	 */
3302 	if (op_mode == OUT_OF_PLACE) {
3303 		if (cipher_offset > auth_offset)
3304 			rte_memcpy(
3305 				rte_pktmbuf_mtod_offset(
3306 					sym_op->m_dst,
3307 					uint8_t *, auth_offset >> 3),
3308 				rte_pktmbuf_mtod_offset(
3309 					sym_op->m_src,
3310 					uint8_t *, auth_offset >> 3),
3311 				((cipher_offset >> 3) - (auth_offset >> 3)));
3312 	}
3313 
3314 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3315 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3316 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3317 		sym_op->cipher.data.length = cipher_len;
3318 		sym_op->cipher.data.offset = cipher_offset;
3319 	} else {
3320 		sym_op->cipher.data.length = cipher_len >> 3;
3321 		sym_op->cipher.data.offset = cipher_offset >> 3;
3322 	}
3323 
3324 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3325 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3326 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3327 		sym_op->auth.data.length = auth_len;
3328 		sym_op->auth.data.offset = auth_offset;
3329 	} else {
3330 		sym_op->auth.data.length = auth_len >> 3;
3331 		sym_op->auth.data.offset = auth_offset >> 3;
3332 	}
3333 
3334 	return 0;
3335 }
3336 
3337 static int
3338 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3339 {
3340 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3341 	struct crypto_unittest_params *ut_params = &unittest_params;
3342 
3343 	int retval;
3344 	unsigned plaintext_pad_len;
3345 	unsigned plaintext_len;
3346 	uint8_t *plaintext;
3347 	struct rte_cryptodev_info dev_info;
3348 
3349 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3350 	uint64_t feat_flags = dev_info.feature_flags;
3351 
3352 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3353 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3354 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3355 		return TEST_SKIPPED;
3356 	}
3357 
3358 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3359 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3360 		printf("Device doesn't support RAW data-path APIs.\n");
3361 		return TEST_SKIPPED;
3362 	}
3363 
3364 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3365 		return TEST_SKIPPED;
3366 
3367 	/* Verify the capabilities */
3368 	struct rte_cryptodev_sym_capability_idx cap_idx;
3369 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3370 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3371 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3372 			&cap_idx) == NULL)
3373 		return TEST_SKIPPED;
3374 
3375 	/* Create SNOW 3G session */
3376 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3377 			tdata->key.data, tdata->key.len,
3378 			tdata->auth_iv.len, tdata->digest.len,
3379 			RTE_CRYPTO_AUTH_OP_GENERATE,
3380 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3381 	if (retval < 0)
3382 		return retval;
3383 
3384 	/* alloc mbuf and set payload */
3385 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3386 
3387 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3388 	rte_pktmbuf_tailroom(ut_params->ibuf));
3389 
3390 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3391 	/* Append data which is padded to a multiple of */
3392 	/* the algorithms block size */
3393 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3394 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3395 				plaintext_pad_len);
3396 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3397 
3398 	/* Create SNOW 3G operation */
3399 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3400 			tdata->auth_iv.data, tdata->auth_iv.len,
3401 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3402 			tdata->validAuthLenInBits.len,
3403 			0);
3404 	if (retval < 0)
3405 		return retval;
3406 
3407 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3408 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3409 					       0);
3410 		if (retval != TEST_SUCCESS)
3411 			return retval;
3412 	} else
3413 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3414 				ut_params->op);
3415 	ut_params->obuf = ut_params->op->sym->m_src;
3416 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3417 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3418 						    uint8_t *,
3419 						    plaintext_pad_len);
3420 
3421 	/* Validate obuf */
3422 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3423 	ut_params->digest,
3424 	tdata->digest.data,
3425 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3426 	"SNOW 3G Generated auth tag not as expected");
3427 
3428 	return 0;
3429 }
3430 
3431 static int
3432 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3433 {
3434 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3435 	struct crypto_unittest_params *ut_params = &unittest_params;
3436 
3437 	int retval;
3438 	unsigned plaintext_pad_len;
3439 	unsigned plaintext_len;
3440 	uint8_t *plaintext;
3441 	struct rte_cryptodev_info dev_info;
3442 
3443 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3444 	uint64_t feat_flags = dev_info.feature_flags;
3445 
3446 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3447 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3448 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3449 		return TEST_SKIPPED;
3450 	}
3451 
3452 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3453 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3454 		printf("Device doesn't support RAW data-path APIs.\n");
3455 		return TEST_SKIPPED;
3456 	}
3457 
3458 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3459 		return TEST_SKIPPED;
3460 
3461 	/* Verify the capabilities */
3462 	struct rte_cryptodev_sym_capability_idx cap_idx;
3463 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3464 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3465 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3466 			&cap_idx) == NULL)
3467 		return TEST_SKIPPED;
3468 
3469 	/* Create SNOW 3G session */
3470 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3471 				tdata->key.data, tdata->key.len,
3472 				tdata->auth_iv.len, tdata->digest.len,
3473 				RTE_CRYPTO_AUTH_OP_VERIFY,
3474 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3475 	if (retval < 0)
3476 		return retval;
3477 	/* alloc mbuf and set payload */
3478 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 
3480 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3481 	rte_pktmbuf_tailroom(ut_params->ibuf));
3482 
3483 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3484 	/* Append data which is padded to a multiple of */
3485 	/* the algorithms block size */
3486 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3487 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3488 				plaintext_pad_len);
3489 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3490 
3491 	/* Create SNOW 3G operation */
3492 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3493 			tdata->digest.len,
3494 			tdata->auth_iv.data, tdata->auth_iv.len,
3495 			plaintext_pad_len,
3496 			RTE_CRYPTO_AUTH_OP_VERIFY,
3497 			tdata->validAuthLenInBits.len,
3498 			0);
3499 	if (retval < 0)
3500 		return retval;
3501 
3502 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3503 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3504 					       0);
3505 		if (retval != TEST_SUCCESS)
3506 			return retval;
3507 	} else
3508 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3509 				ut_params->op);
3510 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3511 	ut_params->obuf = ut_params->op->sym->m_src;
3512 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3513 						    uint8_t *,
3514 						    plaintext_pad_len);
3515 
3516 	/* Validate obuf */
3517 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3518 		return 0;
3519 	else
3520 		return -1;
3521 
3522 	return 0;
3523 }
3524 
3525 static int
3526 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3527 {
3528 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3529 	struct crypto_unittest_params *ut_params = &unittest_params;
3530 
3531 	int retval;
3532 	unsigned plaintext_pad_len;
3533 	unsigned plaintext_len;
3534 	uint8_t *plaintext;
3535 	struct rte_cryptodev_info dev_info;
3536 
3537 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3538 	uint64_t feat_flags = dev_info.feature_flags;
3539 
3540 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3541 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3542 		printf("Device doesn't support RAW data-path APIs.\n");
3543 		return TEST_SKIPPED;
3544 	}
3545 
3546 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3547 		return TEST_SKIPPED;
3548 
3549 	/* Verify the capabilities */
3550 	struct rte_cryptodev_sym_capability_idx cap_idx;
3551 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3552 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3553 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3554 			&cap_idx) == NULL)
3555 		return TEST_SKIPPED;
3556 
3557 	/* Create KASUMI session */
3558 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3559 			tdata->key.data, tdata->key.len,
3560 			0, tdata->digest.len,
3561 			RTE_CRYPTO_AUTH_OP_GENERATE,
3562 			RTE_CRYPTO_AUTH_KASUMI_F9);
3563 	if (retval < 0)
3564 		return retval;
3565 
3566 	/* alloc mbuf and set payload */
3567 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3568 
3569 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3570 	rte_pktmbuf_tailroom(ut_params->ibuf));
3571 
3572 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3573 	/* Append data which is padded to a multiple of */
3574 	/* the algorithms block size */
3575 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3576 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3577 				plaintext_pad_len);
3578 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3579 
3580 	/* Create KASUMI operation */
3581 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3582 			NULL, 0,
3583 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3584 			tdata->plaintext.len,
3585 			0);
3586 	if (retval < 0)
3587 		return retval;
3588 
3589 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3590 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3591 			ut_params->op);
3592 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3593 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3594 					       0);
3595 		if (retval != TEST_SUCCESS)
3596 			return retval;
3597 	} else
3598 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3599 			ut_params->op);
3600 
3601 	ut_params->obuf = ut_params->op->sym->m_src;
3602 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3603 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3604 						    uint8_t *,
3605 						    plaintext_pad_len);
3606 
3607 	/* Validate obuf */
3608 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3609 	ut_params->digest,
3610 	tdata->digest.data,
3611 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3612 	"KASUMI Generated auth tag not as expected");
3613 
3614 	return 0;
3615 }
3616 
3617 static int
3618 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3619 {
3620 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3621 	struct crypto_unittest_params *ut_params = &unittest_params;
3622 
3623 	int retval;
3624 	unsigned plaintext_pad_len;
3625 	unsigned plaintext_len;
3626 	uint8_t *plaintext;
3627 	struct rte_cryptodev_info dev_info;
3628 
3629 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3630 	uint64_t feat_flags = dev_info.feature_flags;
3631 
3632 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3633 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3634 		printf("Device doesn't support RAW data-path APIs.\n");
3635 		return TEST_SKIPPED;
3636 	}
3637 
3638 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3639 		return TEST_SKIPPED;
3640 
3641 	/* Verify the capabilities */
3642 	struct rte_cryptodev_sym_capability_idx cap_idx;
3643 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3644 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3645 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3646 			&cap_idx) == NULL)
3647 		return TEST_SKIPPED;
3648 
3649 	/* Create KASUMI session */
3650 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3651 				tdata->key.data, tdata->key.len,
3652 				0, tdata->digest.len,
3653 				RTE_CRYPTO_AUTH_OP_VERIFY,
3654 				RTE_CRYPTO_AUTH_KASUMI_F9);
3655 	if (retval < 0)
3656 		return retval;
3657 	/* alloc mbuf and set payload */
3658 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3659 
3660 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3661 	rte_pktmbuf_tailroom(ut_params->ibuf));
3662 
3663 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3664 	/* Append data which is padded to a multiple */
3665 	/* of the algorithms block size */
3666 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3667 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3668 				plaintext_pad_len);
3669 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3670 
3671 	/* Create KASUMI operation */
3672 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3673 			tdata->digest.len,
3674 			NULL, 0,
3675 			plaintext_pad_len,
3676 			RTE_CRYPTO_AUTH_OP_VERIFY,
3677 			tdata->plaintext.len,
3678 			0);
3679 	if (retval < 0)
3680 		return retval;
3681 
3682 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3683 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3684 					       0);
3685 		if (retval != TEST_SUCCESS)
3686 			return retval;
3687 	} else
3688 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3689 				ut_params->op);
3690 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3691 	ut_params->obuf = ut_params->op->sym->m_src;
3692 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3693 						    uint8_t *,
3694 						    plaintext_pad_len);
3695 
3696 	/* Validate obuf */
3697 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3698 		return 0;
3699 	else
3700 		return -1;
3701 
3702 	return 0;
3703 }
3704 
3705 static int
3706 test_snow3g_hash_generate_test_case_1(void)
3707 {
3708 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3709 }
3710 
3711 static int
3712 test_snow3g_hash_generate_test_case_2(void)
3713 {
3714 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3715 }
3716 
3717 static int
3718 test_snow3g_hash_generate_test_case_3(void)
3719 {
3720 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3721 }
3722 
3723 static int
3724 test_snow3g_hash_generate_test_case_4(void)
3725 {
3726 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3727 }
3728 
3729 static int
3730 test_snow3g_hash_generate_test_case_5(void)
3731 {
3732 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3733 }
3734 
3735 static int
3736 test_snow3g_hash_generate_test_case_6(void)
3737 {
3738 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3739 }
3740 
3741 static int
3742 test_snow3g_hash_verify_test_case_1(void)
3743 {
3744 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3745 
3746 }
3747 
3748 static int
3749 test_snow3g_hash_verify_test_case_2(void)
3750 {
3751 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3752 }
3753 
3754 static int
3755 test_snow3g_hash_verify_test_case_3(void)
3756 {
3757 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3758 }
3759 
3760 static int
3761 test_snow3g_hash_verify_test_case_4(void)
3762 {
3763 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3764 }
3765 
3766 static int
3767 test_snow3g_hash_verify_test_case_5(void)
3768 {
3769 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3770 }
3771 
3772 static int
3773 test_snow3g_hash_verify_test_case_6(void)
3774 {
3775 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3776 }
3777 
3778 static int
3779 test_kasumi_hash_generate_test_case_1(void)
3780 {
3781 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3782 }
3783 
3784 static int
3785 test_kasumi_hash_generate_test_case_2(void)
3786 {
3787 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3788 }
3789 
3790 static int
3791 test_kasumi_hash_generate_test_case_3(void)
3792 {
3793 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3794 }
3795 
3796 static int
3797 test_kasumi_hash_generate_test_case_4(void)
3798 {
3799 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3800 }
3801 
3802 static int
3803 test_kasumi_hash_generate_test_case_5(void)
3804 {
3805 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3806 }
3807 
3808 static int
3809 test_kasumi_hash_generate_test_case_6(void)
3810 {
3811 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3812 }
3813 
3814 static int
3815 test_kasumi_hash_verify_test_case_1(void)
3816 {
3817 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3818 }
3819 
3820 static int
3821 test_kasumi_hash_verify_test_case_2(void)
3822 {
3823 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3824 }
3825 
3826 static int
3827 test_kasumi_hash_verify_test_case_3(void)
3828 {
3829 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3830 }
3831 
3832 static int
3833 test_kasumi_hash_verify_test_case_4(void)
3834 {
3835 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3836 }
3837 
3838 static int
3839 test_kasumi_hash_verify_test_case_5(void)
3840 {
3841 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3842 }
3843 
3844 static int
3845 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3846 {
3847 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3848 	struct crypto_unittest_params *ut_params = &unittest_params;
3849 
3850 	int retval;
3851 	uint8_t *plaintext, *ciphertext;
3852 	unsigned plaintext_pad_len;
3853 	unsigned plaintext_len;
3854 	struct rte_cryptodev_info dev_info;
3855 
3856 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3857 	uint64_t feat_flags = dev_info.feature_flags;
3858 
3859 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3860 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3861 		printf("Device doesn't support RAW data-path APIs.\n");
3862 		return TEST_SKIPPED;
3863 	}
3864 
3865 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3866 		return TEST_SKIPPED;
3867 
3868 	/* Verify the capabilities */
3869 	struct rte_cryptodev_sym_capability_idx cap_idx;
3870 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3871 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3872 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3873 			&cap_idx) == NULL)
3874 		return TEST_SKIPPED;
3875 
3876 	/* Create KASUMI session */
3877 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3878 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3879 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3880 					tdata->key.data, tdata->key.len,
3881 					tdata->cipher_iv.len);
3882 	if (retval < 0)
3883 		return retval;
3884 
3885 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3886 
3887 	/* Clear mbuf payload */
3888 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3889 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3890 
3891 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3892 	/* Append data which is padded to a multiple */
3893 	/* of the algorithms block size */
3894 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3895 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3896 				plaintext_pad_len);
3897 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3898 
3899 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3900 
3901 	/* Create KASUMI operation */
3902 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3903 				tdata->cipher_iv.len,
3904 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3905 				tdata->validCipherOffsetInBits.len);
3906 	if (retval < 0)
3907 		return retval;
3908 
3909 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3910 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3911 					       tdata->cipher_iv.len);
3912 		if (retval != TEST_SUCCESS)
3913 			return retval;
3914 	} else
3915 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3916 				ut_params->op);
3917 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3918 
3919 	ut_params->obuf = ut_params->op->sym->m_dst;
3920 	if (ut_params->obuf)
3921 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3922 	else
3923 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3924 
3925 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3926 
3927 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3928 				(tdata->validCipherOffsetInBits.len >> 3);
3929 	/* Validate obuf */
3930 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3931 		ciphertext,
3932 		reference_ciphertext,
3933 		tdata->validCipherLenInBits.len,
3934 		"KASUMI Ciphertext data not as expected");
3935 	return 0;
3936 }
3937 
3938 static int
3939 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3940 {
3941 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3942 	struct crypto_unittest_params *ut_params = &unittest_params;
3943 
3944 	int retval;
3945 
3946 	unsigned int plaintext_pad_len;
3947 	unsigned int plaintext_len;
3948 
3949 	uint8_t buffer[10000];
3950 	const uint8_t *ciphertext;
3951 
3952 	struct rte_cryptodev_info dev_info;
3953 
3954 	/* Verify the capabilities */
3955 	struct rte_cryptodev_sym_capability_idx cap_idx;
3956 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3957 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3958 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3959 			&cap_idx) == NULL)
3960 		return TEST_SKIPPED;
3961 
3962 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3963 
3964 	uint64_t feat_flags = dev_info.feature_flags;
3965 
3966 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3967 		printf("Device doesn't support in-place scatter-gather. "
3968 				"Test Skipped.\n");
3969 		return TEST_SKIPPED;
3970 	}
3971 
3972 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3973 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3974 		printf("Device doesn't support RAW data-path APIs.\n");
3975 		return TEST_SKIPPED;
3976 	}
3977 
3978 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3979 		return TEST_SKIPPED;
3980 
3981 	/* Create KASUMI session */
3982 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3983 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3984 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3985 					tdata->key.data, tdata->key.len,
3986 					tdata->cipher_iv.len);
3987 	if (retval < 0)
3988 		return retval;
3989 
3990 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3991 
3992 
3993 	/* Append data which is padded to a multiple */
3994 	/* of the algorithms block size */
3995 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3996 
3997 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3998 			plaintext_pad_len, 10, 0);
3999 
4000 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4001 
4002 	/* Create KASUMI operation */
4003 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4004 				tdata->cipher_iv.len,
4005 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4006 				tdata->validCipherOffsetInBits.len);
4007 	if (retval < 0)
4008 		return retval;
4009 
4010 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4011 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4012 					       tdata->cipher_iv.len);
4013 		if (retval != TEST_SUCCESS)
4014 			return retval;
4015 	} else
4016 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4017 						ut_params->op);
4018 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4019 
4020 	ut_params->obuf = ut_params->op->sym->m_dst;
4021 
4022 	if (ut_params->obuf)
4023 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4024 				plaintext_len, buffer);
4025 	else
4026 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4027 				tdata->validCipherOffsetInBits.len >> 3,
4028 				plaintext_len, buffer);
4029 
4030 	/* Validate obuf */
4031 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4032 
4033 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4034 				(tdata->validCipherOffsetInBits.len >> 3);
4035 	/* Validate obuf */
4036 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4037 		ciphertext,
4038 		reference_ciphertext,
4039 		tdata->validCipherLenInBits.len,
4040 		"KASUMI Ciphertext data not as expected");
4041 	return 0;
4042 }
4043 
4044 static int
4045 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4046 {
4047 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4048 	struct crypto_unittest_params *ut_params = &unittest_params;
4049 
4050 	int retval;
4051 	uint8_t *plaintext, *ciphertext;
4052 	unsigned plaintext_pad_len;
4053 	unsigned plaintext_len;
4054 
4055 	/* Verify the capabilities */
4056 	struct rte_cryptodev_sym_capability_idx cap_idx;
4057 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4058 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4059 	/* Data-path service does not support OOP */
4060 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4061 			&cap_idx) == NULL)
4062 		return TEST_SKIPPED;
4063 
4064 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4065 		return TEST_SKIPPED;
4066 
4067 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4068 		return TEST_SKIPPED;
4069 
4070 	/* Create KASUMI session */
4071 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4072 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4073 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4074 					tdata->key.data, tdata->key.len,
4075 					tdata->cipher_iv.len);
4076 	if (retval < 0)
4077 		return retval;
4078 
4079 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4080 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4081 
4082 	/* Clear mbuf payload */
4083 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4084 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4085 
4086 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4087 	/* Append data which is padded to a multiple */
4088 	/* of the algorithms block size */
4089 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4090 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4091 				plaintext_pad_len);
4092 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4094 
4095 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4096 
4097 	/* Create KASUMI operation */
4098 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4099 				tdata->cipher_iv.len,
4100 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4101 				tdata->validCipherOffsetInBits.len);
4102 	if (retval < 0)
4103 		return retval;
4104 
4105 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4106 						ut_params->op);
4107 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4108 
4109 	ut_params->obuf = ut_params->op->sym->m_dst;
4110 	if (ut_params->obuf)
4111 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4112 	else
4113 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4114 
4115 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4116 
4117 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4118 				(tdata->validCipherOffsetInBits.len >> 3);
4119 	/* Validate obuf */
4120 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4121 		ciphertext,
4122 		reference_ciphertext,
4123 		tdata->validCipherLenInBits.len,
4124 		"KASUMI Ciphertext data not as expected");
4125 	return 0;
4126 }
4127 
4128 static int
4129 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4130 {
4131 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4132 	struct crypto_unittest_params *ut_params = &unittest_params;
4133 
4134 	int retval;
4135 	unsigned int plaintext_pad_len;
4136 	unsigned int plaintext_len;
4137 
4138 	const uint8_t *ciphertext;
4139 	uint8_t buffer[2048];
4140 
4141 	struct rte_cryptodev_info dev_info;
4142 
4143 	/* Verify the capabilities */
4144 	struct rte_cryptodev_sym_capability_idx cap_idx;
4145 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4146 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4147 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4148 			&cap_idx) == NULL)
4149 		return TEST_SKIPPED;
4150 
4151 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4152 		return TEST_SKIPPED;
4153 
4154 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4155 		return TEST_SKIPPED;
4156 
4157 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4158 
4159 	uint64_t feat_flags = dev_info.feature_flags;
4160 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4161 		printf("Device doesn't support out-of-place scatter-gather "
4162 				"in both input and output mbufs. "
4163 				"Test Skipped.\n");
4164 		return TEST_SKIPPED;
4165 	}
4166 
4167 	/* Create KASUMI session */
4168 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4169 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4170 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4171 					tdata->key.data, tdata->key.len,
4172 					tdata->cipher_iv.len);
4173 	if (retval < 0)
4174 		return retval;
4175 
4176 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4177 	/* Append data which is padded to a multiple */
4178 	/* of the algorithms block size */
4179 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4180 
4181 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4182 			plaintext_pad_len, 10, 0);
4183 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4184 			plaintext_pad_len, 3, 0);
4185 
4186 	/* Append data which is padded to a multiple */
4187 	/* of the algorithms block size */
4188 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4189 
4190 	/* Create KASUMI operation */
4191 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4192 				tdata->cipher_iv.len,
4193 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4194 				tdata->validCipherOffsetInBits.len);
4195 	if (retval < 0)
4196 		return retval;
4197 
4198 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4199 						ut_params->op);
4200 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4201 
4202 	ut_params->obuf = ut_params->op->sym->m_dst;
4203 	if (ut_params->obuf)
4204 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4205 				plaintext_pad_len, buffer);
4206 	else
4207 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4208 				tdata->validCipherOffsetInBits.len >> 3,
4209 				plaintext_pad_len, buffer);
4210 
4211 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4212 				(tdata->validCipherOffsetInBits.len >> 3);
4213 	/* Validate obuf */
4214 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4215 		ciphertext,
4216 		reference_ciphertext,
4217 		tdata->validCipherLenInBits.len,
4218 		"KASUMI Ciphertext data not as expected");
4219 	return 0;
4220 }
4221 
4222 
4223 static int
4224 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4225 {
4226 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4227 	struct crypto_unittest_params *ut_params = &unittest_params;
4228 
4229 	int retval;
4230 	uint8_t *ciphertext, *plaintext;
4231 	unsigned ciphertext_pad_len;
4232 	unsigned ciphertext_len;
4233 
4234 	/* Verify the capabilities */
4235 	struct rte_cryptodev_sym_capability_idx cap_idx;
4236 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4237 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4238 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4239 			&cap_idx) == NULL)
4240 		return TEST_SKIPPED;
4241 
4242 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4243 		return TEST_SKIPPED;
4244 
4245 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4246 		return TEST_SKIPPED;
4247 
4248 	/* Create KASUMI session */
4249 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4250 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4251 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4252 					tdata->key.data, tdata->key.len,
4253 					tdata->cipher_iv.len);
4254 	if (retval < 0)
4255 		return retval;
4256 
4257 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4258 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4259 
4260 	/* Clear mbuf payload */
4261 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4262 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4263 
4264 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4265 	/* Append data which is padded to a multiple */
4266 	/* of the algorithms block size */
4267 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4268 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4269 				ciphertext_pad_len);
4270 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4271 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4272 
4273 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4274 
4275 	/* Create KASUMI operation */
4276 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4277 				tdata->cipher_iv.len,
4278 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4279 				tdata->validCipherOffsetInBits.len);
4280 	if (retval < 0)
4281 		return retval;
4282 
4283 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4284 						ut_params->op);
4285 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4286 
4287 	ut_params->obuf = ut_params->op->sym->m_dst;
4288 	if (ut_params->obuf)
4289 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4290 	else
4291 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4292 
4293 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4294 
4295 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4296 				(tdata->validCipherOffsetInBits.len >> 3);
4297 	/* Validate obuf */
4298 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4299 		plaintext,
4300 		reference_plaintext,
4301 		tdata->validCipherLenInBits.len,
4302 		"KASUMI Plaintext data not as expected");
4303 	return 0;
4304 }
4305 
4306 static int
4307 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4308 {
4309 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4310 	struct crypto_unittest_params *ut_params = &unittest_params;
4311 
4312 	int retval;
4313 	uint8_t *ciphertext, *plaintext;
4314 	unsigned ciphertext_pad_len;
4315 	unsigned ciphertext_len;
4316 	struct rte_cryptodev_info dev_info;
4317 
4318 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4319 	uint64_t feat_flags = dev_info.feature_flags;
4320 
4321 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4322 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4323 		printf("Device doesn't support RAW data-path APIs.\n");
4324 		return TEST_SKIPPED;
4325 	}
4326 
4327 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4328 		return TEST_SKIPPED;
4329 
4330 	/* Verify the capabilities */
4331 	struct rte_cryptodev_sym_capability_idx cap_idx;
4332 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4333 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4334 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4335 			&cap_idx) == NULL)
4336 		return TEST_SKIPPED;
4337 
4338 	/* Create KASUMI session */
4339 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4340 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4341 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4342 					tdata->key.data, tdata->key.len,
4343 					tdata->cipher_iv.len);
4344 	if (retval < 0)
4345 		return retval;
4346 
4347 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4348 
4349 	/* Clear mbuf payload */
4350 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4351 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4352 
4353 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4354 	/* Append data which is padded to a multiple */
4355 	/* of the algorithms block size */
4356 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4357 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4358 				ciphertext_pad_len);
4359 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4360 
4361 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4362 
4363 	/* Create KASUMI operation */
4364 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4365 			tdata->cipher_iv.len,
4366 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4367 			tdata->validCipherOffsetInBits.len);
4368 	if (retval < 0)
4369 		return retval;
4370 
4371 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4372 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4373 					       0);
4374 		if (retval != TEST_SUCCESS)
4375 			return retval;
4376 	} else
4377 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4378 						ut_params->op);
4379 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4380 
4381 	ut_params->obuf = ut_params->op->sym->m_dst;
4382 	if (ut_params->obuf)
4383 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4384 	else
4385 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4386 
4387 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4388 
4389 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4390 				(tdata->validCipherOffsetInBits.len >> 3);
4391 	/* Validate obuf */
4392 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4393 		plaintext,
4394 		reference_plaintext,
4395 		tdata->validCipherLenInBits.len,
4396 		"KASUMI Plaintext data not as expected");
4397 	return 0;
4398 }
4399 
4400 static int
4401 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4402 {
4403 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4404 	struct crypto_unittest_params *ut_params = &unittest_params;
4405 
4406 	int retval;
4407 	uint8_t *plaintext, *ciphertext;
4408 	unsigned plaintext_pad_len;
4409 	unsigned plaintext_len;
4410 	struct rte_cryptodev_info dev_info;
4411 
4412 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4413 	uint64_t feat_flags = dev_info.feature_flags;
4414 
4415 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4416 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4417 		printf("Device doesn't support RAW data-path APIs.\n");
4418 		return TEST_SKIPPED;
4419 	}
4420 
4421 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4422 		return TEST_SKIPPED;
4423 
4424 	/* Verify the capabilities */
4425 	struct rte_cryptodev_sym_capability_idx cap_idx;
4426 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4427 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4428 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4429 			&cap_idx) == NULL)
4430 		return TEST_SKIPPED;
4431 
4432 	/* Create SNOW 3G session */
4433 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4434 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4435 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4436 					tdata->key.data, tdata->key.len,
4437 					tdata->cipher_iv.len);
4438 	if (retval < 0)
4439 		return retval;
4440 
4441 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4442 
4443 	/* Clear mbuf payload */
4444 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4445 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4446 
4447 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4448 	/* Append data which is padded to a multiple of */
4449 	/* the algorithms block size */
4450 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4451 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4452 				plaintext_pad_len);
4453 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4454 
4455 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4456 
4457 	/* Create SNOW 3G operation */
4458 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4459 					tdata->cipher_iv.len,
4460 					tdata->validCipherLenInBits.len,
4461 					0);
4462 	if (retval < 0)
4463 		return retval;
4464 
4465 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4466 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4467 					       tdata->cipher_iv.len);
4468 		if (retval != TEST_SUCCESS)
4469 			return retval;
4470 	} else
4471 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4472 						ut_params->op);
4473 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4474 
4475 	ut_params->obuf = ut_params->op->sym->m_dst;
4476 	if (ut_params->obuf)
4477 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4478 	else
4479 		ciphertext = plaintext;
4480 
4481 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4482 
4483 	/* Validate obuf */
4484 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4485 		ciphertext,
4486 		tdata->ciphertext.data,
4487 		tdata->validDataLenInBits.len,
4488 		"SNOW 3G Ciphertext data not as expected");
4489 	return 0;
4490 }
4491 
4492 
4493 static int
4494 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4495 {
4496 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4497 	struct crypto_unittest_params *ut_params = &unittest_params;
4498 	uint8_t *plaintext, *ciphertext;
4499 
4500 	int retval;
4501 	unsigned plaintext_pad_len;
4502 	unsigned plaintext_len;
4503 	struct rte_cryptodev_info dev_info;
4504 
4505 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4506 	uint64_t feat_flags = dev_info.feature_flags;
4507 
4508 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4509 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4510 		printf("Device does not support RAW data-path APIs.\n");
4511 		return -ENOTSUP;
4512 	}
4513 
4514 	/* Verify the capabilities */
4515 	struct rte_cryptodev_sym_capability_idx cap_idx;
4516 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4517 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4518 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4519 			&cap_idx) == NULL)
4520 		return TEST_SKIPPED;
4521 
4522 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4523 		return TEST_SKIPPED;
4524 
4525 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4526 		return TEST_SKIPPED;
4527 
4528 	/* Create SNOW 3G session */
4529 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4530 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4531 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4532 					tdata->key.data, tdata->key.len,
4533 					tdata->cipher_iv.len);
4534 	if (retval < 0)
4535 		return retval;
4536 
4537 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4538 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4539 
4540 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4541 			"Failed to allocate input buffer in mempool");
4542 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4543 			"Failed to allocate output buffer in mempool");
4544 
4545 	/* Clear mbuf payload */
4546 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4547 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4548 
4549 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4550 	/* Append data which is padded to a multiple of */
4551 	/* the algorithms block size */
4552 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4553 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4554 				plaintext_pad_len);
4555 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4556 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4557 
4558 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4559 
4560 	/* Create SNOW 3G operation */
4561 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4562 					tdata->cipher_iv.len,
4563 					tdata->validCipherLenInBits.len,
4564 					0);
4565 	if (retval < 0)
4566 		return retval;
4567 
4568 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4569 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4570 					       tdata->cipher_iv.len);
4571 		if (retval != TEST_SUCCESS)
4572 			return retval;
4573 	} else
4574 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4575 						ut_params->op);
4576 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4577 
4578 	ut_params->obuf = ut_params->op->sym->m_dst;
4579 	if (ut_params->obuf)
4580 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4581 	else
4582 		ciphertext = plaintext;
4583 
4584 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4585 
4586 	/* Validate obuf */
4587 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4588 		ciphertext,
4589 		tdata->ciphertext.data,
4590 		tdata->validDataLenInBits.len,
4591 		"SNOW 3G Ciphertext data not as expected");
4592 	return 0;
4593 }
4594 
4595 static int
4596 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4597 		uint8_t sgl_in, uint8_t sgl_out)
4598 {
4599 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4600 	struct crypto_unittest_params *ut_params = &unittest_params;
4601 
4602 	int retval;
4603 	unsigned int plaintext_pad_len;
4604 	unsigned int plaintext_len;
4605 	uint8_t buffer[10000];
4606 	const uint8_t *ciphertext;
4607 
4608 	struct rte_cryptodev_info dev_info;
4609 
4610 	/* Verify the capabilities */
4611 	struct rte_cryptodev_sym_capability_idx cap_idx;
4612 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4613 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4614 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4615 			&cap_idx) == NULL)
4616 		return TEST_SKIPPED;
4617 
4618 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4619 		return TEST_SKIPPED;
4620 
4621 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4622 		return TEST_SKIPPED;
4623 
4624 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4625 
4626 	uint64_t feat_flags = dev_info.feature_flags;
4627 
4628 	if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4629 			|| ((!sgl_in && sgl_out) &&
4630 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4631 			|| ((sgl_in && !sgl_out) &&
4632 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4633 		printf("Device doesn't support out-of-place scatter gather type. "
4634 				"Test Skipped.\n");
4635 		return TEST_SKIPPED;
4636 	}
4637 
4638 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4639 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4640 		printf("Device does not support RAW data-path APIs.\n");
4641 		return -ENOTSUP;
4642 	}
4643 
4644 	/* Create SNOW 3G session */
4645 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4646 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4647 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4648 					tdata->key.data, tdata->key.len,
4649 					tdata->cipher_iv.len);
4650 	if (retval < 0)
4651 		return retval;
4652 
4653 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4654 	/* Append data which is padded to a multiple of */
4655 	/* the algorithms block size */
4656 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4657 
4658 	if (sgl_in)
4659 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4660 				plaintext_pad_len, 10, 0);
4661 	else {
4662 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4663 		rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4664 	}
4665 
4666 	if (sgl_out)
4667 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4668 				plaintext_pad_len, 3, 0);
4669 	else {
4670 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4671 		rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4672 	}
4673 
4674 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4675 			"Failed to allocate input buffer in mempool");
4676 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4677 			"Failed to allocate output buffer in mempool");
4678 
4679 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4680 
4681 	/* Create SNOW 3G operation */
4682 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4683 					tdata->cipher_iv.len,
4684 					tdata->validCipherLenInBits.len,
4685 					0);
4686 	if (retval < 0)
4687 		return retval;
4688 
4689 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4690 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4691 					       tdata->cipher_iv.len);
4692 		if (retval != TEST_SUCCESS)
4693 			return retval;
4694 	} else
4695 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4696 						ut_params->op);
4697 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4698 
4699 	ut_params->obuf = ut_params->op->sym->m_dst;
4700 	if (ut_params->obuf)
4701 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4702 				plaintext_len, buffer);
4703 	else
4704 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4705 				plaintext_len, buffer);
4706 
4707 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4708 
4709 	/* Validate obuf */
4710 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4711 		ciphertext,
4712 		tdata->ciphertext.data,
4713 		tdata->validDataLenInBits.len,
4714 		"SNOW 3G Ciphertext data not as expected");
4715 
4716 	return 0;
4717 }
4718 
4719 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4720 static void
4721 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4722 {
4723 	uint8_t curr_byte, prev_byte;
4724 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4725 	uint8_t lower_byte_mask = (1 << offset) - 1;
4726 	unsigned i;
4727 
4728 	prev_byte = buffer[0];
4729 	buffer[0] >>= offset;
4730 
4731 	for (i = 1; i < length_in_bytes; i++) {
4732 		curr_byte = buffer[i];
4733 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4734 				(curr_byte >> offset);
4735 		prev_byte = curr_byte;
4736 	}
4737 }
4738 
4739 static int
4740 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4741 {
4742 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 	struct crypto_unittest_params *ut_params = &unittest_params;
4744 	uint8_t *plaintext, *ciphertext;
4745 	int retval;
4746 	uint32_t plaintext_len;
4747 	uint32_t plaintext_pad_len;
4748 	uint8_t extra_offset = 4;
4749 	uint8_t *expected_ciphertext_shifted;
4750 	struct rte_cryptodev_info dev_info;
4751 
4752 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4753 	uint64_t feat_flags = dev_info.feature_flags;
4754 
4755 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4756 			((tdata->validDataLenInBits.len % 8) != 0)) {
4757 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4758 		return TEST_SKIPPED;
4759 	}
4760 
4761 	/* Verify the capabilities */
4762 	struct rte_cryptodev_sym_capability_idx cap_idx;
4763 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4764 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4765 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4766 			&cap_idx) == NULL)
4767 		return TEST_SKIPPED;
4768 
4769 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4770 		return TEST_SKIPPED;
4771 
4772 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4773 		return TEST_SKIPPED;
4774 
4775 	/* Create SNOW 3G session */
4776 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4777 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4778 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4779 					tdata->key.data, tdata->key.len,
4780 					tdata->cipher_iv.len);
4781 	if (retval < 0)
4782 		return retval;
4783 
4784 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4785 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4786 
4787 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4788 			"Failed to allocate input buffer in mempool");
4789 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4790 			"Failed to allocate output buffer in mempool");
4791 
4792 	/* Clear mbuf payload */
4793 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4794 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4795 
4796 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4797 	/*
4798 	 * Append data which is padded to a
4799 	 * multiple of the algorithms block size
4800 	 */
4801 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4802 
4803 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4804 						plaintext_pad_len);
4805 
4806 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4807 
4808 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4809 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4810 
4811 #ifdef RTE_APP_TEST_DEBUG
4812 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4813 #endif
4814 	/* Create SNOW 3G operation */
4815 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4816 					tdata->cipher_iv.len,
4817 					tdata->validCipherLenInBits.len,
4818 					extra_offset);
4819 	if (retval < 0)
4820 		return retval;
4821 
4822 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4823 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4824 					       tdata->cipher_iv.len);
4825 		if (retval != TEST_SUCCESS)
4826 			return retval;
4827 	} else
4828 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4829 						ut_params->op);
4830 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4831 
4832 	ut_params->obuf = ut_params->op->sym->m_dst;
4833 	if (ut_params->obuf)
4834 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4835 	else
4836 		ciphertext = plaintext;
4837 
4838 #ifdef RTE_APP_TEST_DEBUG
4839 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4840 #endif
4841 
4842 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4843 
4844 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4845 			"failed to reserve memory for ciphertext shifted\n");
4846 
4847 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4848 			ceil_byte_length(tdata->ciphertext.len));
4849 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4850 			extra_offset);
4851 	/* Validate obuf */
4852 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4853 		ciphertext,
4854 		expected_ciphertext_shifted,
4855 		tdata->validDataLenInBits.len,
4856 		extra_offset,
4857 		"SNOW 3G Ciphertext data not as expected");
4858 	return 0;
4859 }
4860 
4861 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4862 {
4863 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4864 	struct crypto_unittest_params *ut_params = &unittest_params;
4865 
4866 	int retval;
4867 
4868 	uint8_t *plaintext, *ciphertext;
4869 	unsigned ciphertext_pad_len;
4870 	unsigned ciphertext_len;
4871 	struct rte_cryptodev_info dev_info;
4872 
4873 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4874 	uint64_t feat_flags = dev_info.feature_flags;
4875 
4876 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4877 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4878 		printf("Device doesn't support RAW data-path APIs.\n");
4879 		return TEST_SKIPPED;
4880 	}
4881 
4882 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4883 		return TEST_SKIPPED;
4884 
4885 	/* Verify the capabilities */
4886 	struct rte_cryptodev_sym_capability_idx cap_idx;
4887 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4888 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4889 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4890 			&cap_idx) == NULL)
4891 		return TEST_SKIPPED;
4892 
4893 	/* Create SNOW 3G session */
4894 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4895 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4896 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4897 					tdata->key.data, tdata->key.len,
4898 					tdata->cipher_iv.len);
4899 	if (retval < 0)
4900 		return retval;
4901 
4902 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4903 
4904 	/* Clear mbuf payload */
4905 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4906 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4907 
4908 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4909 	/* Append data which is padded to a multiple of */
4910 	/* the algorithms block size */
4911 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4912 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4913 				ciphertext_pad_len);
4914 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4915 
4916 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4917 
4918 	/* Create SNOW 3G operation */
4919 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4920 					tdata->cipher_iv.len,
4921 					tdata->validCipherLenInBits.len,
4922 					tdata->cipher.offset_bits);
4923 	if (retval < 0)
4924 		return retval;
4925 
4926 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4927 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4928 					       tdata->cipher_iv.len);
4929 		if (retval != TEST_SUCCESS)
4930 			return retval;
4931 	} else
4932 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4933 						ut_params->op);
4934 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4935 	ut_params->obuf = ut_params->op->sym->m_dst;
4936 	if (ut_params->obuf)
4937 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4938 	else
4939 		plaintext = ciphertext;
4940 
4941 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4942 
4943 	/* Validate obuf */
4944 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4945 				tdata->plaintext.data,
4946 				tdata->validDataLenInBits.len,
4947 				"SNOW 3G Plaintext data not as expected");
4948 	return 0;
4949 }
4950 
4951 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4952 {
4953 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4954 	struct crypto_unittest_params *ut_params = &unittest_params;
4955 
4956 	int retval;
4957 
4958 	uint8_t *plaintext, *ciphertext;
4959 	unsigned ciphertext_pad_len;
4960 	unsigned ciphertext_len;
4961 	struct rte_cryptodev_info dev_info;
4962 
4963 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4964 	uint64_t feat_flags = dev_info.feature_flags;
4965 
4966 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4967 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4968 		printf("Device does not support RAW data-path APIs.\n");
4969 		return -ENOTSUP;
4970 	}
4971 	/* Verify the capabilities */
4972 	struct rte_cryptodev_sym_capability_idx cap_idx;
4973 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4974 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4975 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4976 			&cap_idx) == NULL)
4977 		return TEST_SKIPPED;
4978 
4979 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4980 		return TEST_SKIPPED;
4981 
4982 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4983 		return TEST_SKIPPED;
4984 
4985 	/* Create SNOW 3G session */
4986 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4987 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4988 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4989 					tdata->key.data, tdata->key.len,
4990 					tdata->cipher_iv.len);
4991 	if (retval < 0)
4992 		return retval;
4993 
4994 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4995 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4996 
4997 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4998 			"Failed to allocate input buffer");
4999 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
5000 			"Failed to allocate output buffer");
5001 
5002 	/* Clear mbuf payload */
5003 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5004 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5005 
5006 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5007 		       rte_pktmbuf_tailroom(ut_params->obuf));
5008 
5009 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5010 	/* Append data which is padded to a multiple of */
5011 	/* the algorithms block size */
5012 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5013 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5014 				ciphertext_pad_len);
5015 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5016 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5017 
5018 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5019 
5020 	/* Create SNOW 3G operation */
5021 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5022 					tdata->cipher_iv.len,
5023 					tdata->validCipherLenInBits.len,
5024 					0);
5025 	if (retval < 0)
5026 		return retval;
5027 
5028 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5029 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5030 					       tdata->cipher_iv.len);
5031 		if (retval != TEST_SUCCESS)
5032 			return retval;
5033 	} else
5034 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5035 						ut_params->op);
5036 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5037 	ut_params->obuf = ut_params->op->sym->m_dst;
5038 	if (ut_params->obuf)
5039 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5040 	else
5041 		plaintext = ciphertext;
5042 
5043 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5044 
5045 	/* Validate obuf */
5046 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5047 				tdata->plaintext.data,
5048 				tdata->validDataLenInBits.len,
5049 				"SNOW 3G Plaintext data not as expected");
5050 	return 0;
5051 }
5052 
5053 static int
5054 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5055 {
5056 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5057 	struct crypto_unittest_params *ut_params = &unittest_params;
5058 
5059 	int retval;
5060 
5061 	uint8_t *plaintext, *ciphertext;
5062 	unsigned int plaintext_pad_len;
5063 	unsigned int plaintext_len;
5064 
5065 	struct rte_cryptodev_info dev_info;
5066 
5067 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5068 	uint64_t feat_flags = dev_info.feature_flags;
5069 
5070 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5071 			((tdata->validAuthLenInBits.len % 8 != 0) ||
5072 			(tdata->validDataLenInBits.len % 8 != 0))) {
5073 		printf("Device doesn't support NON-Byte Aligned Data.\n");
5074 		return TEST_SKIPPED;
5075 	}
5076 
5077 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5078 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5079 		printf("Device doesn't support RAW data-path APIs.\n");
5080 		return TEST_SKIPPED;
5081 	}
5082 
5083 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5084 		return TEST_SKIPPED;
5085 
5086 	/* Check if device supports ZUC EEA3 */
5087 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5088 			tdata->key.len, tdata->cipher_iv.len) < 0)
5089 		return TEST_SKIPPED;
5090 
5091 	/* Check if device supports ZUC EIA3 */
5092 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5093 			tdata->key.len, tdata->auth_iv.len,
5094 			tdata->digest.len) < 0)
5095 		return TEST_SKIPPED;
5096 
5097 	/* Create ZUC session */
5098 	retval = create_zuc_cipher_auth_encrypt_generate_session(
5099 			ts_params->valid_devs[0],
5100 			tdata);
5101 	if (retval != 0)
5102 		return retval;
5103 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5104 
5105 	/* clear mbuf payload */
5106 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5107 			rte_pktmbuf_tailroom(ut_params->ibuf));
5108 
5109 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5110 	/* Append data which is padded to a multiple of */
5111 	/* the algorithms block size */
5112 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5113 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5114 				plaintext_pad_len);
5115 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5116 
5117 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5118 
5119 	/* Create ZUC operation */
5120 	retval = create_zuc_cipher_hash_generate_operation(tdata);
5121 	if (retval < 0)
5122 		return retval;
5123 
5124 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5125 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5126 					       tdata->cipher_iv.len);
5127 		if (retval != TEST_SUCCESS)
5128 			return retval;
5129 	} else
5130 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5131 			ut_params->op);
5132 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5133 	ut_params->obuf = ut_params->op->sym->m_src;
5134 	if (ut_params->obuf)
5135 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5136 	else
5137 		ciphertext = plaintext;
5138 
5139 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5140 	/* Validate obuf */
5141 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5142 			ciphertext,
5143 			tdata->ciphertext.data,
5144 			tdata->validDataLenInBits.len,
5145 			"ZUC Ciphertext data not as expected");
5146 
5147 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5148 						    uint8_t *,
5149 						    plaintext_pad_len);
5150 
5151 	/* Validate obuf */
5152 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5153 			ut_params->digest,
5154 			tdata->digest.data,
5155 			tdata->digest.len,
5156 			"ZUC Generated auth tag not as expected");
5157 	return 0;
5158 }
5159 
5160 static int
5161 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5162 {
5163 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5164 	struct crypto_unittest_params *ut_params = &unittest_params;
5165 
5166 	int retval;
5167 
5168 	uint8_t *plaintext, *ciphertext;
5169 	unsigned plaintext_pad_len;
5170 	unsigned plaintext_len;
5171 	struct rte_cryptodev_info dev_info;
5172 
5173 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5174 	uint64_t feat_flags = dev_info.feature_flags;
5175 
5176 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5177 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5178 		printf("Device doesn't support RAW data-path APIs.\n");
5179 		return TEST_SKIPPED;
5180 	}
5181 
5182 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5183 		return TEST_SKIPPED;
5184 
5185 	/* Verify the capabilities */
5186 	struct rte_cryptodev_sym_capability_idx cap_idx;
5187 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5188 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5189 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5190 			&cap_idx) == NULL)
5191 		return TEST_SKIPPED;
5192 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5193 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5194 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5195 			&cap_idx) == NULL)
5196 		return TEST_SKIPPED;
5197 
5198 	/* Create SNOW 3G session */
5199 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5200 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5201 			RTE_CRYPTO_AUTH_OP_GENERATE,
5202 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5203 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5204 			tdata->key.data, tdata->key.len,
5205 			tdata->key.data, tdata->key.len,
5206 			tdata->auth_iv.len, tdata->digest.len,
5207 			tdata->cipher_iv.len);
5208 	if (retval != 0)
5209 		return retval;
5210 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5211 
5212 	/* clear mbuf payload */
5213 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5214 			rte_pktmbuf_tailroom(ut_params->ibuf));
5215 
5216 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5217 	/* Append data which is padded to a multiple of */
5218 	/* the algorithms block size */
5219 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5220 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5221 				plaintext_pad_len);
5222 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5223 
5224 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5225 
5226 	/* Create SNOW 3G operation */
5227 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5228 			tdata->digest.len, tdata->auth_iv.data,
5229 			tdata->auth_iv.len,
5230 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5231 			tdata->cipher_iv.data, tdata->cipher_iv.len,
5232 			tdata->validCipherLenInBits.len,
5233 			0,
5234 			tdata->validAuthLenInBits.len,
5235 			0
5236 			);
5237 	if (retval < 0)
5238 		return retval;
5239 
5240 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5241 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5242 					       tdata->cipher_iv.len);
5243 		if (retval != TEST_SUCCESS)
5244 			return retval;
5245 	} else
5246 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5247 			ut_params->op);
5248 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5249 	ut_params->obuf = ut_params->op->sym->m_src;
5250 	if (ut_params->obuf)
5251 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5252 	else
5253 		ciphertext = plaintext;
5254 
5255 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5256 	/* Validate obuf */
5257 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5258 			ciphertext,
5259 			tdata->ciphertext.data,
5260 			tdata->validDataLenInBits.len,
5261 			"SNOW 3G Ciphertext data not as expected");
5262 
5263 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5264 						    uint8_t *,
5265 						    plaintext_pad_len);
5266 
5267 	/* Validate obuf */
5268 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5269 			ut_params->digest,
5270 			tdata->digest.data,
5271 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5272 			"SNOW 3G Generated auth tag not as expected");
5273 	return 0;
5274 }
5275 
5276 static int
5277 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5278 	uint8_t op_mode, uint8_t verify)
5279 {
5280 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5281 	struct crypto_unittest_params *ut_params = &unittest_params;
5282 
5283 	int retval;
5284 
5285 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5286 	unsigned int plaintext_pad_len;
5287 	unsigned int plaintext_len;
5288 	unsigned int ciphertext_pad_len;
5289 	unsigned int ciphertext_len;
5290 	unsigned int digest_offset;
5291 
5292 	struct rte_cryptodev_info dev_info;
5293 
5294 	/* Verify the capabilities */
5295 	struct rte_cryptodev_sym_capability_idx cap_idx;
5296 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5297 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5298 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5299 			&cap_idx) == NULL)
5300 		return TEST_SKIPPED;
5301 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5302 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5303 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5304 			&cap_idx) == NULL)
5305 		return TEST_SKIPPED;
5306 
5307 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5308 		return TEST_SKIPPED;
5309 
5310 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5311 
5312 	uint64_t feat_flags = dev_info.feature_flags;
5313 
5314 	if (op_mode == OUT_OF_PLACE) {
5315 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5316 			printf("Device doesn't support digest encrypted.\n");
5317 			return TEST_SKIPPED;
5318 		}
5319 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5320 			return TEST_SKIPPED;
5321 	}
5322 
5323 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5324 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5325 		printf("Device doesn't support RAW data-path APIs.\n");
5326 		return TEST_SKIPPED;
5327 	}
5328 
5329 	/* Create SNOW 3G session */
5330 	retval = create_wireless_algo_auth_cipher_session(
5331 			ts_params->valid_devs[0],
5332 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5333 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5334 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5335 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5336 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5337 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5338 			tdata->key.data, tdata->key.len,
5339 			tdata->key.data, tdata->key.len,
5340 			tdata->auth_iv.len, tdata->digest.len,
5341 			tdata->cipher_iv.len);
5342 	if (retval != 0)
5343 		return retval;
5344 
5345 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5346 	if (op_mode == OUT_OF_PLACE)
5347 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5348 
5349 	/* clear mbuf payload */
5350 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5351 		rte_pktmbuf_tailroom(ut_params->ibuf));
5352 	if (op_mode == OUT_OF_PLACE)
5353 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5354 			rte_pktmbuf_tailroom(ut_params->obuf));
5355 
5356 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5357 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5358 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5359 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5360 
5361 	if (verify) {
5362 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5363 					ciphertext_pad_len);
5364 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5365 		if (op_mode == OUT_OF_PLACE)
5366 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5367 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5368 			ciphertext_len);
5369 	} else {
5370 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5371 					plaintext_pad_len);
5372 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5373 		if (op_mode == OUT_OF_PLACE)
5374 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5375 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5376 	}
5377 
5378 	/* Create SNOW 3G operation */
5379 	retval = create_wireless_algo_auth_cipher_operation(
5380 		tdata->digest.data, tdata->digest.len,
5381 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5382 		tdata->auth_iv.data, tdata->auth_iv.len,
5383 		(tdata->digest.offset_bytes == 0 ?
5384 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5385 			: tdata->digest.offset_bytes),
5386 		tdata->validCipherLenInBits.len,
5387 		tdata->cipher.offset_bits,
5388 		tdata->validAuthLenInBits.len,
5389 		tdata->auth.offset_bits,
5390 		op_mode, 0, verify);
5391 
5392 	if (retval < 0)
5393 		return retval;
5394 
5395 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5396 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5397 					       tdata->cipher_iv.len);
5398 		if (retval != TEST_SUCCESS)
5399 			return retval;
5400 	} else
5401 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5402 			ut_params->op);
5403 
5404 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5405 
5406 	ut_params->obuf = (op_mode == IN_PLACE ?
5407 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5408 
5409 	if (verify) {
5410 		if (ut_params->obuf)
5411 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5412 							uint8_t *);
5413 		else
5414 			plaintext = ciphertext +
5415 				(tdata->cipher.offset_bits >> 3);
5416 
5417 		debug_hexdump(stdout, "plaintext:", plaintext,
5418 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5419 		debug_hexdump(stdout, "plaintext expected:",
5420 			tdata->plaintext.data,
5421 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5422 	} else {
5423 		if (ut_params->obuf)
5424 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5425 							uint8_t *);
5426 		else
5427 			ciphertext = plaintext;
5428 
5429 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5430 			ciphertext_len);
5431 		debug_hexdump(stdout, "ciphertext expected:",
5432 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5433 
5434 		if (tdata->digest.offset_bytes == 0)
5435 			digest_offset = plaintext_pad_len;
5436 		else
5437 			digest_offset = tdata->digest.offset_bytes;
5438 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5439 						    uint8_t *, digest_offset);
5440 
5441 		debug_hexdump(stdout, "digest:", ut_params->digest,
5442 			tdata->digest.len);
5443 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5444 				tdata->digest.len);
5445 	}
5446 
5447 	/* Validate obuf */
5448 	if (verify) {
5449 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5450 			plaintext,
5451 			tdata->plaintext.data,
5452 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5453 			 (tdata->digest.len << 3)),
5454 			tdata->cipher.offset_bits,
5455 			"SNOW 3G Plaintext data not as expected");
5456 	} else {
5457 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5458 			ciphertext,
5459 			tdata->ciphertext.data,
5460 			(tdata->validDataLenInBits.len -
5461 			 tdata->cipher.offset_bits),
5462 			tdata->cipher.offset_bits,
5463 			"SNOW 3G Ciphertext data not as expected");
5464 
5465 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5466 			ut_params->digest,
5467 			tdata->digest.data,
5468 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5469 			"SNOW 3G Generated auth tag not as expected");
5470 	}
5471 	return 0;
5472 }
5473 
5474 static int
5475 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5476 	uint8_t op_mode, uint8_t verify)
5477 {
5478 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5479 	struct crypto_unittest_params *ut_params = &unittest_params;
5480 
5481 	int retval;
5482 
5483 	const uint8_t *plaintext = NULL;
5484 	const uint8_t *ciphertext = NULL;
5485 	const uint8_t *digest = NULL;
5486 	unsigned int plaintext_pad_len;
5487 	unsigned int plaintext_len;
5488 	unsigned int ciphertext_pad_len;
5489 	unsigned int ciphertext_len;
5490 	uint8_t buffer[10000];
5491 	uint8_t digest_buffer[10000];
5492 
5493 	struct rte_cryptodev_info dev_info;
5494 
5495 	/* Verify the capabilities */
5496 	struct rte_cryptodev_sym_capability_idx cap_idx;
5497 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5498 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5499 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5500 			&cap_idx) == NULL)
5501 		return TEST_SKIPPED;
5502 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5503 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5504 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5505 			&cap_idx) == NULL)
5506 		return TEST_SKIPPED;
5507 
5508 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5509 		return TEST_SKIPPED;
5510 
5511 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5512 
5513 	uint64_t feat_flags = dev_info.feature_flags;
5514 
5515 	if (op_mode == IN_PLACE) {
5516 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5517 			printf("Device doesn't support in-place scatter-gather "
5518 					"in both input and output mbufs.\n");
5519 			return TEST_SKIPPED;
5520 		}
5521 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5522 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5523 			printf("Device doesn't support RAW data-path APIs.\n");
5524 			return TEST_SKIPPED;
5525 		}
5526 	} else {
5527 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5528 			return TEST_SKIPPED;
5529 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5530 			printf("Device doesn't support out-of-place scatter-gather "
5531 					"in both input and output mbufs.\n");
5532 			return TEST_SKIPPED;
5533 		}
5534 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5535 			printf("Device doesn't support digest encrypted.\n");
5536 			return TEST_SKIPPED;
5537 		}
5538 	}
5539 
5540 	/* Create SNOW 3G session */
5541 	retval = create_wireless_algo_auth_cipher_session(
5542 			ts_params->valid_devs[0],
5543 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5544 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5545 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5546 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5547 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5548 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5549 			tdata->key.data, tdata->key.len,
5550 			tdata->key.data, tdata->key.len,
5551 			tdata->auth_iv.len, tdata->digest.len,
5552 			tdata->cipher_iv.len);
5553 
5554 	if (retval != 0)
5555 		return retval;
5556 
5557 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5558 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5559 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5560 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5561 
5562 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5563 			plaintext_pad_len, 15, 0);
5564 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5565 			"Failed to allocate input buffer in mempool");
5566 
5567 	if (op_mode == OUT_OF_PLACE) {
5568 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5569 				plaintext_pad_len, 15, 0);
5570 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5571 				"Failed to allocate output buffer in mempool");
5572 	}
5573 
5574 	if (verify) {
5575 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5576 			tdata->ciphertext.data);
5577 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5578 					ciphertext_len, buffer);
5579 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5580 			ciphertext_len);
5581 	} else {
5582 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5583 			tdata->plaintext.data);
5584 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5585 					plaintext_len, buffer);
5586 		debug_hexdump(stdout, "plaintext:", plaintext,
5587 			plaintext_len);
5588 	}
5589 	memset(buffer, 0, sizeof(buffer));
5590 
5591 	/* Create SNOW 3G operation */
5592 	retval = create_wireless_algo_auth_cipher_operation(
5593 		tdata->digest.data, tdata->digest.len,
5594 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5595 		tdata->auth_iv.data, tdata->auth_iv.len,
5596 		(tdata->digest.offset_bytes == 0 ?
5597 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5598 			: tdata->digest.offset_bytes),
5599 		tdata->validCipherLenInBits.len,
5600 		tdata->cipher.offset_bits,
5601 		tdata->validAuthLenInBits.len,
5602 		tdata->auth.offset_bits,
5603 		op_mode, 1, verify);
5604 
5605 	if (retval < 0)
5606 		return retval;
5607 
5608 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5609 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5610 					       tdata->cipher_iv.len);
5611 		if (retval != TEST_SUCCESS)
5612 			return retval;
5613 	} else
5614 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5615 			ut_params->op);
5616 
5617 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5618 
5619 	ut_params->obuf = (op_mode == IN_PLACE ?
5620 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5621 
5622 	if (verify) {
5623 		if (ut_params->obuf)
5624 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5625 					plaintext_len, buffer);
5626 		else
5627 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5628 					plaintext_len, buffer);
5629 
5630 		debug_hexdump(stdout, "plaintext:", plaintext,
5631 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5632 		debug_hexdump(stdout, "plaintext expected:",
5633 			tdata->plaintext.data,
5634 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5635 	} else {
5636 		if (ut_params->obuf)
5637 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5638 					ciphertext_len, buffer);
5639 		else
5640 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5641 					ciphertext_len, buffer);
5642 
5643 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5644 			ciphertext_len);
5645 		debug_hexdump(stdout, "ciphertext expected:",
5646 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5647 
5648 		if (ut_params->obuf)
5649 			digest = rte_pktmbuf_read(ut_params->obuf,
5650 				(tdata->digest.offset_bytes == 0 ?
5651 				plaintext_pad_len : tdata->digest.offset_bytes),
5652 				tdata->digest.len, digest_buffer);
5653 		else
5654 			digest = rte_pktmbuf_read(ut_params->ibuf,
5655 				(tdata->digest.offset_bytes == 0 ?
5656 				plaintext_pad_len : tdata->digest.offset_bytes),
5657 				tdata->digest.len, digest_buffer);
5658 
5659 		debug_hexdump(stdout, "digest:", digest,
5660 			tdata->digest.len);
5661 		debug_hexdump(stdout, "digest expected:",
5662 			tdata->digest.data, tdata->digest.len);
5663 	}
5664 
5665 	/* Validate obuf */
5666 	if (verify) {
5667 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5668 			plaintext,
5669 			tdata->plaintext.data,
5670 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5671 			 (tdata->digest.len << 3)),
5672 			tdata->cipher.offset_bits,
5673 			"SNOW 3G Plaintext data not as expected");
5674 	} else {
5675 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5676 			ciphertext,
5677 			tdata->ciphertext.data,
5678 			(tdata->validDataLenInBits.len -
5679 			 tdata->cipher.offset_bits),
5680 			tdata->cipher.offset_bits,
5681 			"SNOW 3G Ciphertext data not as expected");
5682 
5683 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5684 			digest,
5685 			tdata->digest.data,
5686 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5687 			"SNOW 3G Generated auth tag not as expected");
5688 	}
5689 	return 0;
5690 }
5691 
5692 static int
5693 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5694 	uint8_t op_mode, uint8_t verify)
5695 {
5696 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5697 	struct crypto_unittest_params *ut_params = &unittest_params;
5698 
5699 	int retval;
5700 
5701 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5702 	unsigned int plaintext_pad_len;
5703 	unsigned int plaintext_len;
5704 	unsigned int ciphertext_pad_len;
5705 	unsigned int ciphertext_len;
5706 	unsigned int digest_offset;
5707 
5708 	struct rte_cryptodev_info dev_info;
5709 
5710 	/* Verify the capabilities */
5711 	struct rte_cryptodev_sym_capability_idx cap_idx;
5712 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5713 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5714 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5715 			&cap_idx) == NULL)
5716 		return TEST_SKIPPED;
5717 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5718 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5719 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5720 			&cap_idx) == NULL)
5721 		return TEST_SKIPPED;
5722 
5723 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5724 
5725 	uint64_t feat_flags = dev_info.feature_flags;
5726 
5727 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5728 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5729 		printf("Device doesn't support RAW data-path APIs.\n");
5730 		return TEST_SKIPPED;
5731 	}
5732 
5733 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5734 		return TEST_SKIPPED;
5735 
5736 	if (op_mode == OUT_OF_PLACE) {
5737 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5738 			return TEST_SKIPPED;
5739 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5740 			printf("Device doesn't support digest encrypted.\n");
5741 			return TEST_SKIPPED;
5742 		}
5743 	}
5744 
5745 	/* Create KASUMI session */
5746 	retval = create_wireless_algo_auth_cipher_session(
5747 			ts_params->valid_devs[0],
5748 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5749 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5750 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5751 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5752 			RTE_CRYPTO_AUTH_KASUMI_F9,
5753 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5754 			tdata->key.data, tdata->key.len,
5755 			tdata->key.data, tdata->key.len,
5756 			0, tdata->digest.len,
5757 			tdata->cipher_iv.len);
5758 
5759 	if (retval != 0)
5760 		return retval;
5761 
5762 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5763 	if (op_mode == OUT_OF_PLACE)
5764 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5765 
5766 	/* clear mbuf payload */
5767 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5768 		rte_pktmbuf_tailroom(ut_params->ibuf));
5769 	if (op_mode == OUT_OF_PLACE)
5770 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5771 			rte_pktmbuf_tailroom(ut_params->obuf));
5772 
5773 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5774 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5775 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5776 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5777 
5778 	if (verify) {
5779 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5780 					ciphertext_pad_len);
5781 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5782 		if (op_mode == OUT_OF_PLACE)
5783 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5784 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5785 			ciphertext_len);
5786 	} else {
5787 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5788 					plaintext_pad_len);
5789 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5790 		if (op_mode == OUT_OF_PLACE)
5791 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5792 		debug_hexdump(stdout, "plaintext:", plaintext,
5793 			plaintext_len);
5794 	}
5795 
5796 	/* Create KASUMI operation */
5797 	retval = create_wireless_algo_auth_cipher_operation(
5798 		tdata->digest.data, tdata->digest.len,
5799 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5800 		NULL, 0,
5801 		(tdata->digest.offset_bytes == 0 ?
5802 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5803 			: tdata->digest.offset_bytes),
5804 		tdata->validCipherLenInBits.len,
5805 		tdata->validCipherOffsetInBits.len,
5806 		tdata->validAuthLenInBits.len,
5807 		0,
5808 		op_mode, 0, verify);
5809 
5810 	if (retval < 0)
5811 		return retval;
5812 
5813 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5814 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5815 					       tdata->cipher_iv.len);
5816 		if (retval != TEST_SUCCESS)
5817 			return retval;
5818 	} else
5819 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5820 			ut_params->op);
5821 
5822 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5823 
5824 	ut_params->obuf = (op_mode == IN_PLACE ?
5825 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5826 
5827 
5828 	if (verify) {
5829 		if (ut_params->obuf)
5830 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5831 							uint8_t *);
5832 		else
5833 			plaintext = ciphertext;
5834 
5835 		debug_hexdump(stdout, "plaintext:", plaintext,
5836 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5837 		debug_hexdump(stdout, "plaintext expected:",
5838 			tdata->plaintext.data,
5839 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5840 	} else {
5841 		if (ut_params->obuf)
5842 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5843 							uint8_t *);
5844 		else
5845 			ciphertext = plaintext;
5846 
5847 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5848 			ciphertext_len);
5849 		debug_hexdump(stdout, "ciphertext expected:",
5850 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5851 
5852 		if (tdata->digest.offset_bytes == 0)
5853 			digest_offset = plaintext_pad_len;
5854 		else
5855 			digest_offset = tdata->digest.offset_bytes;
5856 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5857 						    uint8_t *, digest_offset);
5858 
5859 		debug_hexdump(stdout, "digest:", ut_params->digest,
5860 			tdata->digest.len);
5861 		debug_hexdump(stdout, "digest expected:",
5862 			tdata->digest.data, tdata->digest.len);
5863 	}
5864 
5865 	/* Validate obuf */
5866 	if (verify) {
5867 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5868 			plaintext,
5869 			tdata->plaintext.data,
5870 			tdata->plaintext.len >> 3,
5871 			"KASUMI Plaintext data not as expected");
5872 	} else {
5873 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5874 			ciphertext,
5875 			tdata->ciphertext.data,
5876 			tdata->ciphertext.len >> 3,
5877 			"KASUMI Ciphertext data not as expected");
5878 
5879 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5880 			ut_params->digest,
5881 			tdata->digest.data,
5882 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5883 			"KASUMI Generated auth tag not as expected");
5884 	}
5885 	return 0;
5886 }
5887 
5888 static int
5889 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5890 	uint8_t op_mode, uint8_t verify)
5891 {
5892 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5893 	struct crypto_unittest_params *ut_params = &unittest_params;
5894 
5895 	int retval;
5896 
5897 	const uint8_t *plaintext = NULL;
5898 	const uint8_t *ciphertext = NULL;
5899 	const uint8_t *digest = NULL;
5900 	unsigned int plaintext_pad_len;
5901 	unsigned int plaintext_len;
5902 	unsigned int ciphertext_pad_len;
5903 	unsigned int ciphertext_len;
5904 	uint8_t buffer[10000];
5905 	uint8_t digest_buffer[10000];
5906 
5907 	struct rte_cryptodev_info dev_info;
5908 
5909 	/* Verify the capabilities */
5910 	struct rte_cryptodev_sym_capability_idx cap_idx;
5911 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5912 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5913 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5914 			&cap_idx) == NULL)
5915 		return TEST_SKIPPED;
5916 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5917 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5918 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5919 			&cap_idx) == NULL)
5920 		return TEST_SKIPPED;
5921 
5922 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5923 		return TEST_SKIPPED;
5924 
5925 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5926 
5927 	uint64_t feat_flags = dev_info.feature_flags;
5928 
5929 	if (op_mode == IN_PLACE) {
5930 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5931 			printf("Device doesn't support in-place scatter-gather "
5932 					"in both input and output mbufs.\n");
5933 			return TEST_SKIPPED;
5934 		}
5935 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5936 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5937 			printf("Device doesn't support RAW data-path APIs.\n");
5938 			return TEST_SKIPPED;
5939 		}
5940 	} else {
5941 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5942 			return TEST_SKIPPED;
5943 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5944 			printf("Device doesn't support out-of-place scatter-gather "
5945 					"in both input and output mbufs.\n");
5946 			return TEST_SKIPPED;
5947 		}
5948 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5949 			printf("Device doesn't support digest encrypted.\n");
5950 			return TEST_SKIPPED;
5951 		}
5952 	}
5953 
5954 	/* Create KASUMI session */
5955 	retval = create_wireless_algo_auth_cipher_session(
5956 			ts_params->valid_devs[0],
5957 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5958 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5959 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5960 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5961 			RTE_CRYPTO_AUTH_KASUMI_F9,
5962 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5963 			tdata->key.data, tdata->key.len,
5964 			tdata->key.data, tdata->key.len,
5965 			0, tdata->digest.len,
5966 			tdata->cipher_iv.len);
5967 
5968 	if (retval != 0)
5969 		return retval;
5970 
5971 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5972 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5973 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5974 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5975 
5976 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5977 			plaintext_pad_len, 15, 0);
5978 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5979 			"Failed to allocate input buffer in mempool");
5980 
5981 	if (op_mode == OUT_OF_PLACE) {
5982 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5983 				plaintext_pad_len, 15, 0);
5984 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5985 				"Failed to allocate output buffer in mempool");
5986 	}
5987 
5988 	if (verify) {
5989 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5990 			tdata->ciphertext.data);
5991 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5992 					ciphertext_len, buffer);
5993 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5994 			ciphertext_len);
5995 	} else {
5996 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5997 			tdata->plaintext.data);
5998 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5999 					plaintext_len, buffer);
6000 		debug_hexdump(stdout, "plaintext:", plaintext,
6001 			plaintext_len);
6002 	}
6003 	memset(buffer, 0, sizeof(buffer));
6004 
6005 	/* Create KASUMI operation */
6006 	retval = create_wireless_algo_auth_cipher_operation(
6007 		tdata->digest.data, tdata->digest.len,
6008 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6009 		NULL, 0,
6010 		(tdata->digest.offset_bytes == 0 ?
6011 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6012 			: tdata->digest.offset_bytes),
6013 		tdata->validCipherLenInBits.len,
6014 		tdata->validCipherOffsetInBits.len,
6015 		tdata->validAuthLenInBits.len,
6016 		0,
6017 		op_mode, 1, verify);
6018 
6019 	if (retval < 0)
6020 		return retval;
6021 
6022 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6023 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6024 					       tdata->cipher_iv.len);
6025 		if (retval != TEST_SUCCESS)
6026 			return retval;
6027 	} else
6028 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6029 			ut_params->op);
6030 
6031 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6032 
6033 	ut_params->obuf = (op_mode == IN_PLACE ?
6034 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6035 
6036 	if (verify) {
6037 		if (ut_params->obuf)
6038 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6039 					plaintext_len, buffer);
6040 		else
6041 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6042 					plaintext_len, buffer);
6043 
6044 		debug_hexdump(stdout, "plaintext:", plaintext,
6045 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6046 		debug_hexdump(stdout, "plaintext expected:",
6047 			tdata->plaintext.data,
6048 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6049 	} else {
6050 		if (ut_params->obuf)
6051 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6052 					ciphertext_len, buffer);
6053 		else
6054 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6055 					ciphertext_len, buffer);
6056 
6057 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6058 			ciphertext_len);
6059 		debug_hexdump(stdout, "ciphertext expected:",
6060 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6061 
6062 		if (ut_params->obuf)
6063 			digest = rte_pktmbuf_read(ut_params->obuf,
6064 				(tdata->digest.offset_bytes == 0 ?
6065 				plaintext_pad_len : tdata->digest.offset_bytes),
6066 				tdata->digest.len, digest_buffer);
6067 		else
6068 			digest = rte_pktmbuf_read(ut_params->ibuf,
6069 				(tdata->digest.offset_bytes == 0 ?
6070 				plaintext_pad_len : tdata->digest.offset_bytes),
6071 				tdata->digest.len, digest_buffer);
6072 
6073 		debug_hexdump(stdout, "digest:", digest,
6074 			tdata->digest.len);
6075 		debug_hexdump(stdout, "digest expected:",
6076 			tdata->digest.data, tdata->digest.len);
6077 	}
6078 
6079 	/* Validate obuf */
6080 	if (verify) {
6081 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6082 			plaintext,
6083 			tdata->plaintext.data,
6084 			tdata->plaintext.len >> 3,
6085 			"KASUMI Plaintext data not as expected");
6086 	} else {
6087 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6088 			ciphertext,
6089 			tdata->ciphertext.data,
6090 			tdata->validDataLenInBits.len,
6091 			"KASUMI Ciphertext data not as expected");
6092 
6093 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6094 			digest,
6095 			tdata->digest.data,
6096 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6097 			"KASUMI Generated auth tag not as expected");
6098 	}
6099 	return 0;
6100 }
6101 
6102 static int
6103 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6104 {
6105 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6106 	struct crypto_unittest_params *ut_params = &unittest_params;
6107 
6108 	int retval;
6109 
6110 	uint8_t *plaintext, *ciphertext;
6111 	unsigned plaintext_pad_len;
6112 	unsigned plaintext_len;
6113 	struct rte_cryptodev_info dev_info;
6114 
6115 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6116 	uint64_t feat_flags = dev_info.feature_flags;
6117 
6118 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6119 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6120 		printf("Device doesn't support RAW data-path APIs.\n");
6121 		return TEST_SKIPPED;
6122 	}
6123 
6124 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6125 		return TEST_SKIPPED;
6126 
6127 	/* Verify the capabilities */
6128 	struct rte_cryptodev_sym_capability_idx cap_idx;
6129 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6130 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6131 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6132 			&cap_idx) == NULL)
6133 		return TEST_SKIPPED;
6134 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6135 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6136 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6137 			&cap_idx) == NULL)
6138 		return TEST_SKIPPED;
6139 
6140 	/* Create KASUMI session */
6141 	retval = create_wireless_algo_cipher_auth_session(
6142 			ts_params->valid_devs[0],
6143 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6144 			RTE_CRYPTO_AUTH_OP_GENERATE,
6145 			RTE_CRYPTO_AUTH_KASUMI_F9,
6146 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6147 			tdata->key.data, tdata->key.len,
6148 			tdata->key.data, tdata->key.len,
6149 			0, tdata->digest.len,
6150 			tdata->cipher_iv.len);
6151 	if (retval != 0)
6152 		return retval;
6153 
6154 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6155 
6156 	/* clear mbuf payload */
6157 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6158 			rte_pktmbuf_tailroom(ut_params->ibuf));
6159 
6160 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6161 	/* Append data which is padded to a multiple of */
6162 	/* the algorithms block size */
6163 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6164 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6165 				plaintext_pad_len);
6166 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6167 
6168 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6169 
6170 	/* Create KASUMI operation */
6171 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6172 				tdata->digest.len, NULL, 0,
6173 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6174 				tdata->cipher_iv.data, tdata->cipher_iv.len,
6175 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6176 				tdata->validCipherOffsetInBits.len,
6177 				tdata->validAuthLenInBits.len,
6178 				0
6179 				);
6180 	if (retval < 0)
6181 		return retval;
6182 
6183 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6184 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6185 					       tdata->cipher_iv.len);
6186 		if (retval != TEST_SUCCESS)
6187 			return retval;
6188 	} else
6189 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6190 			ut_params->op);
6191 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6192 
6193 	if (ut_params->op->sym->m_dst)
6194 		ut_params->obuf = ut_params->op->sym->m_dst;
6195 	else
6196 		ut_params->obuf = ut_params->op->sym->m_src;
6197 
6198 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6199 				tdata->validCipherOffsetInBits.len >> 3);
6200 
6201 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6202 						    uint8_t *,
6203 						    plaintext_pad_len);
6204 
6205 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6206 				(tdata->validCipherOffsetInBits.len >> 3);
6207 	/* Validate obuf */
6208 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6209 		ciphertext,
6210 		reference_ciphertext,
6211 		tdata->validCipherLenInBits.len,
6212 		"KASUMI Ciphertext data not as expected");
6213 
6214 	/* Validate obuf */
6215 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6216 		ut_params->digest,
6217 		tdata->digest.data,
6218 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6219 		"KASUMI Generated auth tag not as expected");
6220 	return 0;
6221 }
6222 
6223 static int
6224 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6225 			const enum rte_crypto_cipher_algorithm cipher_algo,
6226 			const uint16_t key_size, const uint16_t iv_size)
6227 {
6228 	struct rte_cryptodev_sym_capability_idx cap_idx;
6229 	const struct rte_cryptodev_symmetric_capability *cap;
6230 
6231 	/* Check if device supports the algorithm */
6232 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6233 	cap_idx.algo.cipher = cipher_algo;
6234 
6235 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6236 			&cap_idx);
6237 
6238 	if (cap == NULL)
6239 		return -1;
6240 
6241 	/* Check if device supports key size and IV size */
6242 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6243 			iv_size) < 0) {
6244 		return -1;
6245 	}
6246 
6247 	return 0;
6248 }
6249 
6250 static int
6251 check_auth_capability(const struct crypto_testsuite_params *ts_params,
6252 			const enum rte_crypto_auth_algorithm auth_algo,
6253 			const uint16_t key_size, const uint16_t iv_size,
6254 			const uint16_t tag_size)
6255 {
6256 	struct rte_cryptodev_sym_capability_idx cap_idx;
6257 	const struct rte_cryptodev_symmetric_capability *cap;
6258 
6259 	/* Check if device supports the algorithm */
6260 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6261 	cap_idx.algo.auth = auth_algo;
6262 
6263 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6264 			&cap_idx);
6265 
6266 	if (cap == NULL)
6267 		return -1;
6268 
6269 	/* Check if device supports key size and IV size */
6270 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6271 			tag_size, iv_size) < 0) {
6272 		return -1;
6273 	}
6274 
6275 	return 0;
6276 }
6277 
6278 static int
6279 test_zuc_cipher(const struct wireless_test_data *tdata,
6280 		enum rte_crypto_cipher_operation direction)
6281 {
6282 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6283 	struct crypto_unittest_params *ut_params = &unittest_params;
6284 
6285 	int retval;
6286 	uint8_t *plaintext = NULL;
6287 	uint8_t *ciphertext = NULL;
6288 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6289 	unsigned int plaintext_len = 0;
6290 	unsigned int ciphertext_len = 0;
6291 	struct rte_cryptodev_info dev_info;
6292 
6293 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6294 	uint64_t feat_flags = dev_info.feature_flags;
6295 
6296 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6297 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6298 		printf("Device doesn't support RAW data-path APIs.\n");
6299 		return TEST_SKIPPED;
6300 	}
6301 
6302 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6303 		return TEST_SKIPPED;
6304 
6305 	/* Check if device supports ZUC EEA3 */
6306 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6307 			tdata->key.len, tdata->cipher_iv.len) < 0)
6308 		return TEST_SKIPPED;
6309 
6310 	/* Create ZUC session */
6311 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6312 					direction,
6313 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
6314 					tdata->key.data, tdata->key.len,
6315 					tdata->cipher_iv.len);
6316 	if (retval != 0)
6317 		return retval;
6318 
6319 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6320 
6321 	/* Clear mbuf payload */
6322 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6323 	       rte_pktmbuf_tailroom(ut_params->ibuf));
6324 
6325 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6326 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6327 		/* Append data which is padded to a multiple */
6328 		/* of the algorithms block size */
6329 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6330 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6331 				plaintext_pad_len);
6332 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6333 
6334 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6335 	} else {
6336 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6337 		/* Append data which is padded to a multiple */
6338 		/* of the algorithms block size */
6339 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6340 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6341 				ciphertext_pad_len);
6342 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6343 
6344 		debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6345 	}
6346 
6347 	/* Create ZUC operation */
6348 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6349 					tdata->cipher_iv.len,
6350 					tdata->plaintext.len,
6351 					tdata->validCipherOffsetInBits.len);
6352 	if (retval < 0)
6353 		return retval;
6354 
6355 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6356 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6357 					       tdata->cipher_iv.len);
6358 		if (retval != TEST_SUCCESS)
6359 			return retval;
6360 	} else
6361 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6362 						ut_params->op);
6363 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6364 
6365 	ut_params->obuf = ut_params->op->sym->m_dst;
6366 
6367 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6368 		if (ut_params->obuf)
6369 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6370 		else
6371 			ciphertext = plaintext;
6372 
6373 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6374 
6375 		/* Validate obuf */
6376 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6377 				ciphertext,
6378 				tdata->ciphertext.data,
6379 				tdata->validCipherLenInBits.len,
6380 				"ZUC Ciphertext data not as expected");
6381 	} else {
6382 		if (ut_params->obuf)
6383 			plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6384 		else
6385 			plaintext = ciphertext;
6386 
6387 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6388 
6389 		const uint8_t *reference_plaintext = tdata->plaintext.data +
6390 				(tdata->validCipherOffsetInBits.len >> 3);
6391 
6392 		/* Validate obuf */
6393 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6394 				plaintext,
6395 				reference_plaintext,
6396 				tdata->validCipherLenInBits.len,
6397 				"ZUC Plaintext data not as expected");
6398 	}
6399 
6400 	return 0;
6401 }
6402 
6403 static int
6404 test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6405 		enum rte_crypto_cipher_operation direction)
6406 {
6407 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6408 	struct crypto_unittest_params *ut_params = &unittest_params;
6409 
6410 	int retval;
6411 
6412 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6413 	unsigned int plaintext_len = 0;
6414 	unsigned int ciphertext_len = 0;
6415 	const uint8_t *ciphertext, *plaintext;
6416 	uint8_t buffer[2048];
6417 	struct rte_cryptodev_info dev_info;
6418 
6419 	/* Check if device supports ZUC EEA3 */
6420 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6421 			tdata->key.len, tdata->cipher_iv.len) < 0)
6422 		return TEST_SKIPPED;
6423 
6424 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6425 		return TEST_SKIPPED;
6426 
6427 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6428 
6429 	uint64_t feat_flags = dev_info.feature_flags;
6430 
6431 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6432 		printf("Device doesn't support in-place scatter-gather. "
6433 				"Test Skipped.\n");
6434 		return TEST_SKIPPED;
6435 	}
6436 
6437 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6438 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6439 		printf("Device doesn't support RAW data-path APIs.\n");
6440 		return TEST_SKIPPED;
6441 	}
6442 
6443 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6444 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6445 
6446 		/* Append data which is padded to a multiple */
6447 		/* of the algorithms block size */
6448 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6449 
6450 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6451 				plaintext_pad_len, 10, 0);
6452 
6453 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6454 				tdata->plaintext.data);
6455 	} else {
6456 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6457 
6458 		/* Append data which is padded to a multiple */
6459 		/* of the algorithms block size */
6460 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6461 
6462 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6463 				ciphertext_pad_len, 10, 0);
6464 
6465 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6466 				tdata->ciphertext.data);
6467 
6468 	}
6469 
6470 	/* Create ZUC session */
6471 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6472 			direction,
6473 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6474 			tdata->key.data, tdata->key.len,
6475 			tdata->cipher_iv.len);
6476 	if (retval < 0)
6477 		return retval;
6478 
6479 	/* Clear mbuf payload */
6480 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6481 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6482 	else
6483 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6484 
6485 	/* Create ZUC operation */
6486 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6487 			tdata->cipher_iv.len, tdata->plaintext.len,
6488 			tdata->validCipherOffsetInBits.len);
6489 	if (retval < 0)
6490 		return retval;
6491 
6492 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6493 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6494 					       tdata->cipher_iv.len);
6495 		if (retval != TEST_SUCCESS)
6496 			return retval;
6497 	} else
6498 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6499 						ut_params->op);
6500 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6501 
6502 	ut_params->obuf = ut_params->op->sym->m_dst;
6503 
6504 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6505 		if (ut_params->obuf)
6506 			ciphertext = rte_pktmbuf_read(ut_params->obuf,
6507 				0, plaintext_len, buffer);
6508 		else
6509 			ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6510 				0, plaintext_len, buffer);
6511 
6512 		/* Validate obuf */
6513 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6514 
6515 		/* Validate obuf */
6516 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6517 			ciphertext,
6518 			tdata->ciphertext.data,
6519 			tdata->validCipherLenInBits.len,
6520 			"ZUC Ciphertext data not as expected");
6521 	} else {
6522 		if (ut_params->obuf)
6523 			plaintext = rte_pktmbuf_read(ut_params->obuf,
6524 				0, ciphertext_len, buffer);
6525 		else
6526 			plaintext = rte_pktmbuf_read(ut_params->ibuf,
6527 				0, ciphertext_len, buffer);
6528 
6529 		/* Validate obuf */
6530 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6531 
6532 		/* Validate obuf */
6533 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6534 			plaintext,
6535 			tdata->plaintext.data,
6536 			tdata->validCipherLenInBits.len,
6537 			"ZUC Plaintext data not as expected");
6538 		}
6539 
6540 	return 0;
6541 }
6542 
6543 static int
6544 test_zuc_authentication(const struct wireless_test_data *tdata,
6545 		enum rte_crypto_auth_operation auth_op)
6546 {
6547 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6548 	struct crypto_unittest_params *ut_params = &unittest_params;
6549 
6550 	int retval;
6551 	unsigned plaintext_pad_len;
6552 	unsigned plaintext_len;
6553 	uint8_t *plaintext;
6554 
6555 	struct rte_cryptodev_info dev_info;
6556 
6557 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6558 	uint64_t feat_flags = dev_info.feature_flags;
6559 
6560 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6561 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6562 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6563 		return TEST_SKIPPED;
6564 	}
6565 
6566 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6567 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6568 		printf("Device doesn't support RAW data-path APIs.\n");
6569 		return TEST_SKIPPED;
6570 	}
6571 
6572 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6573 		return TEST_SKIPPED;
6574 
6575 	/* Check if device supports ZUC EIA3 */
6576 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6577 			tdata->key.len, tdata->auth_iv.len,
6578 			tdata->digest.len) < 0)
6579 		return TEST_SKIPPED;
6580 
6581 	/* Create ZUC session */
6582 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6583 			tdata->key.data, tdata->key.len,
6584 			tdata->auth_iv.len, tdata->digest.len,
6585 			auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6586 	if (retval != 0)
6587 		return retval;
6588 
6589 	/* alloc mbuf and set payload */
6590 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6591 
6592 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6593 	rte_pktmbuf_tailroom(ut_params->ibuf));
6594 
6595 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6596 	/* Append data which is padded to a multiple of */
6597 	/* the algorithms block size */
6598 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6599 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6600 				plaintext_pad_len);
6601 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6602 
6603 	/* Create ZUC operation */
6604 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
6605 			tdata->digest.len,
6606 			tdata->auth_iv.data, tdata->auth_iv.len,
6607 			plaintext_pad_len,
6608 			auth_op, tdata->validAuthLenInBits.len, 0);
6609 	if (retval < 0)
6610 		return retval;
6611 
6612 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6613 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6614 					       0);
6615 		if (retval != TEST_SUCCESS)
6616 			return retval;
6617 	} else
6618 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6619 				ut_params->op);
6620 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6621 	ut_params->obuf = ut_params->op->sym->m_src;
6622 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6623 						    uint8_t *,
6624 						    plaintext_pad_len);
6625 
6626 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6627 		/* Validate obuf */
6628 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6629 				ut_params->digest,
6630 				tdata->digest.data,
6631 				tdata->digest.len,
6632 				"ZUC Generated auth tag not as expected");
6633 		return 0;
6634 	}
6635 
6636 	/* Validate obuf */
6637 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6638 		return 0;
6639 	else
6640 		return -1;
6641 
6642 	return 0;
6643 }
6644 
6645 static int
6646 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6647 	uint8_t op_mode, uint8_t verify)
6648 {
6649 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6650 	struct crypto_unittest_params *ut_params = &unittest_params;
6651 
6652 	int retval;
6653 
6654 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6655 	unsigned int plaintext_pad_len;
6656 	unsigned int plaintext_len;
6657 	unsigned int ciphertext_pad_len;
6658 	unsigned int ciphertext_len;
6659 	unsigned int digest_offset;
6660 
6661 	struct rte_cryptodev_info dev_info;
6662 
6663 	/* Check if device supports ZUC EEA3 */
6664 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6665 			tdata->key.len, tdata->cipher_iv.len) < 0)
6666 		return TEST_SKIPPED;
6667 
6668 	/* Check if device supports ZUC EIA3 */
6669 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6670 			tdata->key.len, tdata->auth_iv.len,
6671 			tdata->digest.len) < 0)
6672 		return TEST_SKIPPED;
6673 
6674 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6675 		return TEST_SKIPPED;
6676 
6677 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6678 
6679 	uint64_t feat_flags = dev_info.feature_flags;
6680 
6681 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6682 		printf("Device doesn't support digest encrypted.\n");
6683 		return TEST_SKIPPED;
6684 	}
6685 	if (op_mode == IN_PLACE) {
6686 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6687 			printf("Device doesn't support in-place scatter-gather "
6688 					"in both input and output mbufs.\n");
6689 			return TEST_SKIPPED;
6690 		}
6691 
6692 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6693 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6694 			printf("Device doesn't support RAW data-path APIs.\n");
6695 			return TEST_SKIPPED;
6696 		}
6697 	} else {
6698 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6699 			return TEST_SKIPPED;
6700 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6701 			printf("Device doesn't support out-of-place scatter-gather "
6702 					"in both input and output mbufs.\n");
6703 			return TEST_SKIPPED;
6704 		}
6705 	}
6706 
6707 	/* Create ZUC session */
6708 	retval = create_wireless_algo_auth_cipher_session(
6709 			ts_params->valid_devs[0],
6710 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6711 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6712 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6713 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6714 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6715 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6716 			tdata->key.data, tdata->key.len,
6717 			tdata->key.data, tdata->key.len,
6718 			tdata->auth_iv.len, tdata->digest.len,
6719 			tdata->cipher_iv.len);
6720 
6721 	if (retval != 0)
6722 		return retval;
6723 
6724 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6725 	if (op_mode == OUT_OF_PLACE)
6726 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6727 
6728 	/* clear mbuf payload */
6729 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6730 		rte_pktmbuf_tailroom(ut_params->ibuf));
6731 	if (op_mode == OUT_OF_PLACE)
6732 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6733 			rte_pktmbuf_tailroom(ut_params->obuf));
6734 
6735 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6736 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6737 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6738 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6739 
6740 	if (verify) {
6741 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6742 					ciphertext_pad_len);
6743 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6744 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6745 			ciphertext_len);
6746 	} else {
6747 		/* make sure enough space to cover partial digest verify case */
6748 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6749 					ciphertext_pad_len);
6750 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6751 		debug_hexdump(stdout, "plaintext:", plaintext,
6752 			plaintext_len);
6753 	}
6754 
6755 	if (op_mode == OUT_OF_PLACE)
6756 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6757 
6758 	/* Create ZUC operation */
6759 	retval = create_wireless_algo_auth_cipher_operation(
6760 		tdata->digest.data, tdata->digest.len,
6761 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6762 		tdata->auth_iv.data, tdata->auth_iv.len,
6763 		(tdata->digest.offset_bytes == 0 ?
6764 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6765 			: tdata->digest.offset_bytes),
6766 		tdata->validCipherLenInBits.len,
6767 		tdata->validCipherOffsetInBits.len,
6768 		tdata->validAuthLenInBits.len,
6769 		0,
6770 		op_mode, 0, verify);
6771 
6772 	if (retval < 0)
6773 		return retval;
6774 
6775 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6776 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6777 					       tdata->cipher_iv.len);
6778 		if (retval != TEST_SUCCESS)
6779 			return retval;
6780 	} else
6781 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6782 			ut_params->op);
6783 
6784 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6785 
6786 	ut_params->obuf = (op_mode == IN_PLACE ?
6787 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6788 
6789 
6790 	if (verify) {
6791 		if (ut_params->obuf)
6792 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6793 							uint8_t *);
6794 		else
6795 			plaintext = ciphertext;
6796 
6797 		debug_hexdump(stdout, "plaintext:", plaintext,
6798 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6799 		debug_hexdump(stdout, "plaintext expected:",
6800 			tdata->plaintext.data,
6801 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6802 	} else {
6803 		if (ut_params->obuf)
6804 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6805 							uint8_t *);
6806 		else
6807 			ciphertext = plaintext;
6808 
6809 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6810 			ciphertext_len);
6811 		debug_hexdump(stdout, "ciphertext expected:",
6812 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6813 
6814 		if (tdata->digest.offset_bytes == 0)
6815 			digest_offset = plaintext_pad_len;
6816 		else
6817 			digest_offset =  tdata->digest.offset_bytes;
6818 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6819 					    uint8_t *, digest_offset);
6820 
6821 		debug_hexdump(stdout, "digest:", ut_params->digest,
6822 			tdata->digest.len);
6823 		debug_hexdump(stdout, "digest expected:",
6824 			tdata->digest.data, tdata->digest.len);
6825 	}
6826 
6827 	/* Validate obuf */
6828 	if (verify) {
6829 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6830 			plaintext,
6831 			tdata->plaintext.data,
6832 			tdata->plaintext.len >> 3,
6833 			"ZUC Plaintext data not as expected");
6834 	} else {
6835 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6836 			ciphertext,
6837 			tdata->ciphertext.data,
6838 			tdata->ciphertext.len >> 3,
6839 			"ZUC Ciphertext data not as expected");
6840 
6841 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6842 			ut_params->digest,
6843 			tdata->digest.data,
6844 			tdata->digest.len,
6845 			"ZUC Generated auth tag not as expected");
6846 	}
6847 	return 0;
6848 }
6849 
6850 static int
6851 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6852 	uint8_t op_mode, uint8_t verify)
6853 {
6854 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6855 	struct crypto_unittest_params *ut_params = &unittest_params;
6856 
6857 	int retval;
6858 
6859 	const uint8_t *plaintext = NULL;
6860 	const uint8_t *ciphertext = NULL;
6861 	const uint8_t *digest = NULL;
6862 	unsigned int plaintext_pad_len;
6863 	unsigned int plaintext_len;
6864 	unsigned int ciphertext_pad_len;
6865 	unsigned int ciphertext_len;
6866 	uint8_t buffer[10000];
6867 	uint8_t digest_buffer[10000];
6868 
6869 	struct rte_cryptodev_info dev_info;
6870 
6871 	/* Check if device supports ZUC EEA3 */
6872 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6873 			tdata->key.len, tdata->cipher_iv.len) < 0)
6874 		return TEST_SKIPPED;
6875 
6876 	/* Check if device supports ZUC EIA3 */
6877 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6878 			tdata->key.len, tdata->auth_iv.len,
6879 			tdata->digest.len) < 0)
6880 		return TEST_SKIPPED;
6881 
6882 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6883 		return TEST_SKIPPED;
6884 
6885 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6886 
6887 	uint64_t feat_flags = dev_info.feature_flags;
6888 
6889 	if (op_mode == IN_PLACE) {
6890 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6891 			printf("Device doesn't support in-place scatter-gather "
6892 					"in both input and output mbufs.\n");
6893 			return TEST_SKIPPED;
6894 		}
6895 
6896 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6897 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6898 			printf("Device doesn't support RAW data-path APIs.\n");
6899 			return TEST_SKIPPED;
6900 		}
6901 	} else {
6902 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6903 			return TEST_SKIPPED;
6904 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6905 			printf("Device doesn't support out-of-place scatter-gather "
6906 					"in both input and output mbufs.\n");
6907 			return TEST_SKIPPED;
6908 		}
6909 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6910 			printf("Device doesn't support digest encrypted.\n");
6911 			return TEST_SKIPPED;
6912 		}
6913 	}
6914 
6915 	/* Create ZUC session */
6916 	retval = create_wireless_algo_auth_cipher_session(
6917 			ts_params->valid_devs[0],
6918 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6919 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6920 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6921 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6922 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6923 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6924 			tdata->key.data, tdata->key.len,
6925 			tdata->key.data, tdata->key.len,
6926 			tdata->auth_iv.len, tdata->digest.len,
6927 			tdata->cipher_iv.len);
6928 
6929 	if (retval != 0)
6930 		return retval;
6931 
6932 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6933 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6934 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6935 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6936 
6937 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6938 			plaintext_pad_len, 15, 0);
6939 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6940 			"Failed to allocate input buffer in mempool");
6941 
6942 	if (op_mode == OUT_OF_PLACE) {
6943 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6944 				plaintext_pad_len, 15, 0);
6945 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6946 				"Failed to allocate output buffer in mempool");
6947 	}
6948 
6949 	if (verify) {
6950 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6951 			tdata->ciphertext.data);
6952 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6953 					ciphertext_len, buffer);
6954 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6955 			ciphertext_len);
6956 	} else {
6957 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6958 			tdata->plaintext.data);
6959 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6960 					plaintext_len, buffer);
6961 		debug_hexdump(stdout, "plaintext:", plaintext,
6962 			plaintext_len);
6963 	}
6964 	memset(buffer, 0, sizeof(buffer));
6965 
6966 	/* Create ZUC operation */
6967 	retval = create_wireless_algo_auth_cipher_operation(
6968 		tdata->digest.data, tdata->digest.len,
6969 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6970 		tdata->auth_iv.data, tdata->auth_iv.len,
6971 		(tdata->digest.offset_bytes == 0 ?
6972 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6973 			: tdata->digest.offset_bytes),
6974 		tdata->validCipherLenInBits.len,
6975 		tdata->validCipherOffsetInBits.len,
6976 		tdata->validAuthLenInBits.len,
6977 		0,
6978 		op_mode, 1, verify);
6979 
6980 	if (retval < 0)
6981 		return retval;
6982 
6983 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6984 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6985 					       tdata->cipher_iv.len);
6986 		if (retval != TEST_SUCCESS)
6987 			return retval;
6988 	} else
6989 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6990 			ut_params->op);
6991 
6992 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6993 
6994 	ut_params->obuf = (op_mode == IN_PLACE ?
6995 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6996 
6997 	if (verify) {
6998 		if (ut_params->obuf)
6999 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7000 					plaintext_len, buffer);
7001 		else
7002 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7003 					plaintext_len, buffer);
7004 
7005 		debug_hexdump(stdout, "plaintext:", plaintext,
7006 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7007 		debug_hexdump(stdout, "plaintext expected:",
7008 			tdata->plaintext.data,
7009 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7010 	} else {
7011 		if (ut_params->obuf)
7012 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7013 					ciphertext_len, buffer);
7014 		else
7015 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7016 					ciphertext_len, buffer);
7017 
7018 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7019 			ciphertext_len);
7020 		debug_hexdump(stdout, "ciphertext expected:",
7021 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7022 
7023 		if (ut_params->obuf)
7024 			digest = rte_pktmbuf_read(ut_params->obuf,
7025 				(tdata->digest.offset_bytes == 0 ?
7026 				plaintext_pad_len : tdata->digest.offset_bytes),
7027 				tdata->digest.len, digest_buffer);
7028 		else
7029 			digest = rte_pktmbuf_read(ut_params->ibuf,
7030 				(tdata->digest.offset_bytes == 0 ?
7031 				plaintext_pad_len : tdata->digest.offset_bytes),
7032 				tdata->digest.len, digest_buffer);
7033 
7034 		debug_hexdump(stdout, "digest:", digest,
7035 			tdata->digest.len);
7036 		debug_hexdump(stdout, "digest expected:",
7037 			tdata->digest.data, tdata->digest.len);
7038 	}
7039 
7040 	/* Validate obuf */
7041 	if (verify) {
7042 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7043 			plaintext,
7044 			tdata->plaintext.data,
7045 			tdata->plaintext.len >> 3,
7046 			"ZUC Plaintext data not as expected");
7047 	} else {
7048 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7049 			ciphertext,
7050 			tdata->ciphertext.data,
7051 			tdata->validDataLenInBits.len,
7052 			"ZUC Ciphertext data not as expected");
7053 
7054 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7055 			digest,
7056 			tdata->digest.data,
7057 			tdata->digest.len,
7058 			"ZUC Generated auth tag not as expected");
7059 	}
7060 	return 0;
7061 }
7062 
7063 static int
7064 test_kasumi_encryption_test_case_1(void)
7065 {
7066 	return test_kasumi_encryption(&kasumi_test_case_1);
7067 }
7068 
7069 static int
7070 test_kasumi_encryption_test_case_1_sgl(void)
7071 {
7072 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7073 }
7074 
7075 static int
7076 test_kasumi_encryption_test_case_1_oop(void)
7077 {
7078 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
7079 }
7080 
7081 static int
7082 test_kasumi_encryption_test_case_1_oop_sgl(void)
7083 {
7084 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7085 }
7086 
7087 static int
7088 test_kasumi_encryption_test_case_2(void)
7089 {
7090 	return test_kasumi_encryption(&kasumi_test_case_2);
7091 }
7092 
7093 static int
7094 test_kasumi_encryption_test_case_3(void)
7095 {
7096 	return test_kasumi_encryption(&kasumi_test_case_3);
7097 }
7098 
7099 static int
7100 test_kasumi_encryption_test_case_4(void)
7101 {
7102 	return test_kasumi_encryption(&kasumi_test_case_4);
7103 }
7104 
7105 static int
7106 test_kasumi_encryption_test_case_5(void)
7107 {
7108 	return test_kasumi_encryption(&kasumi_test_case_5);
7109 }
7110 
7111 static int
7112 test_kasumi_decryption_test_case_1(void)
7113 {
7114 	return test_kasumi_decryption(&kasumi_test_case_1);
7115 }
7116 
7117 static int
7118 test_kasumi_decryption_test_case_1_oop(void)
7119 {
7120 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
7121 }
7122 
7123 static int
7124 test_kasumi_decryption_test_case_2(void)
7125 {
7126 	return test_kasumi_decryption(&kasumi_test_case_2);
7127 }
7128 
7129 static int
7130 test_kasumi_decryption_test_case_3(void)
7131 {
7132 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7133 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7134 		return TEST_SKIPPED;
7135 	return test_kasumi_decryption(&kasumi_test_case_3);
7136 }
7137 
7138 static int
7139 test_kasumi_decryption_test_case_4(void)
7140 {
7141 	return test_kasumi_decryption(&kasumi_test_case_4);
7142 }
7143 
7144 static int
7145 test_kasumi_decryption_test_case_5(void)
7146 {
7147 	return test_kasumi_decryption(&kasumi_test_case_5);
7148 }
7149 static int
7150 test_snow3g_encryption_test_case_1(void)
7151 {
7152 	return test_snow3g_encryption(&snow3g_test_case_1);
7153 }
7154 
7155 static int
7156 test_snow3g_encryption_test_case_1_oop(void)
7157 {
7158 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
7159 }
7160 
7161 static int
7162 test_snow3g_encryption_test_case_1_oop_sgl(void)
7163 {
7164 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7165 }
7166 
7167 static int
7168 test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7169 {
7170 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7171 }
7172 
7173 static int
7174 test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7175 {
7176 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7177 }
7178 
7179 static int
7180 test_snow3g_encryption_test_case_1_offset_oop(void)
7181 {
7182 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7183 }
7184 
7185 static int
7186 test_snow3g_encryption_test_case_2(void)
7187 {
7188 	return test_snow3g_encryption(&snow3g_test_case_2);
7189 }
7190 
7191 static int
7192 test_snow3g_encryption_test_case_3(void)
7193 {
7194 	return test_snow3g_encryption(&snow3g_test_case_3);
7195 }
7196 
7197 static int
7198 test_snow3g_encryption_test_case_4(void)
7199 {
7200 	return test_snow3g_encryption(&snow3g_test_case_4);
7201 }
7202 
7203 static int
7204 test_snow3g_encryption_test_case_5(void)
7205 {
7206 	return test_snow3g_encryption(&snow3g_test_case_5);
7207 }
7208 
7209 static int
7210 test_snow3g_decryption_test_case_1(void)
7211 {
7212 	return test_snow3g_decryption(&snow3g_test_case_1);
7213 }
7214 
7215 static int
7216 test_snow3g_decryption_test_case_1_oop(void)
7217 {
7218 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
7219 }
7220 
7221 static int
7222 test_snow3g_decryption_test_case_2(void)
7223 {
7224 	return test_snow3g_decryption(&snow3g_test_case_2);
7225 }
7226 
7227 static int
7228 test_snow3g_decryption_test_case_3(void)
7229 {
7230 	return test_snow3g_decryption(&snow3g_test_case_3);
7231 }
7232 
7233 static int
7234 test_snow3g_decryption_test_case_4(void)
7235 {
7236 	return test_snow3g_decryption(&snow3g_test_case_4);
7237 }
7238 
7239 static int
7240 test_snow3g_decryption_test_case_5(void)
7241 {
7242 	return test_snow3g_decryption(&snow3g_test_case_5);
7243 }
7244 
7245 /*
7246  * Function prepares snow3g_hash_test_data from snow3g_test_data.
7247  * Pattern digest from snow3g_test_data must be allocated as
7248  * 4 last bytes in plaintext.
7249  */
7250 static void
7251 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7252 		struct snow3g_hash_test_data *output)
7253 {
7254 	if ((pattern != NULL) && (output != NULL)) {
7255 		output->key.len = pattern->key.len;
7256 
7257 		memcpy(output->key.data,
7258 		pattern->key.data, pattern->key.len);
7259 
7260 		output->auth_iv.len = pattern->auth_iv.len;
7261 
7262 		memcpy(output->auth_iv.data,
7263 		pattern->auth_iv.data, pattern->auth_iv.len);
7264 
7265 		output->plaintext.len = pattern->plaintext.len;
7266 
7267 		memcpy(output->plaintext.data,
7268 		pattern->plaintext.data, pattern->plaintext.len >> 3);
7269 
7270 		output->digest.len = pattern->digest.len;
7271 
7272 		memcpy(output->digest.data,
7273 		&pattern->plaintext.data[pattern->digest.offset_bytes],
7274 		pattern->digest.len);
7275 
7276 		output->validAuthLenInBits.len =
7277 		pattern->validAuthLenInBits.len;
7278 	}
7279 }
7280 
7281 /*
7282  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7283  */
7284 static int
7285 test_snow3g_decryption_with_digest_test_case_1(void)
7286 {
7287 	int ret;
7288 	struct snow3g_hash_test_data snow3g_hash_data;
7289 	struct rte_cryptodev_info dev_info;
7290 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7291 
7292 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7293 	uint64_t feat_flags = dev_info.feature_flags;
7294 
7295 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7296 		printf("Device doesn't support encrypted digest operations.\n");
7297 		return TEST_SKIPPED;
7298 	}
7299 
7300 	/*
7301 	 * Function prepare data for hash verification test case.
7302 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
7303 	 */
7304 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7305 
7306 	ret = test_snow3g_decryption(&snow3g_test_case_7);
7307 	if (ret != 0)
7308 		return ret;
7309 
7310 	return test_snow3g_authentication_verify(&snow3g_hash_data);
7311 }
7312 
7313 static int
7314 test_snow3g_cipher_auth_test_case_1(void)
7315 {
7316 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
7317 }
7318 
7319 static int
7320 test_snow3g_auth_cipher_test_case_1(void)
7321 {
7322 	return test_snow3g_auth_cipher(
7323 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7324 }
7325 
7326 static int
7327 test_snow3g_auth_cipher_test_case_2(void)
7328 {
7329 	return test_snow3g_auth_cipher(
7330 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7331 }
7332 
7333 static int
7334 test_snow3g_auth_cipher_test_case_2_oop(void)
7335 {
7336 	return test_snow3g_auth_cipher(
7337 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7338 }
7339 
7340 static int
7341 test_snow3g_auth_cipher_part_digest_enc(void)
7342 {
7343 	return test_snow3g_auth_cipher(
7344 		&snow3g_auth_cipher_partial_digest_encryption,
7345 			IN_PLACE, 0);
7346 }
7347 
7348 static int
7349 test_snow3g_auth_cipher_part_digest_enc_oop(void)
7350 {
7351 	return test_snow3g_auth_cipher(
7352 		&snow3g_auth_cipher_partial_digest_encryption,
7353 			OUT_OF_PLACE, 0);
7354 }
7355 
7356 static int
7357 test_snow3g_auth_cipher_test_case_3_sgl(void)
7358 {
7359 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7360 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7361 		return TEST_SKIPPED;
7362 	return test_snow3g_auth_cipher_sgl(
7363 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7364 }
7365 
7366 static int
7367 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7368 {
7369 	return test_snow3g_auth_cipher_sgl(
7370 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7371 }
7372 
7373 static int
7374 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7375 {
7376 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7377 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7378 		return TEST_SKIPPED;
7379 	return test_snow3g_auth_cipher_sgl(
7380 		&snow3g_auth_cipher_partial_digest_encryption,
7381 			IN_PLACE, 0);
7382 }
7383 
7384 static int
7385 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7386 {
7387 	return test_snow3g_auth_cipher_sgl(
7388 		&snow3g_auth_cipher_partial_digest_encryption,
7389 			OUT_OF_PLACE, 0);
7390 }
7391 
7392 static int
7393 test_snow3g_auth_cipher_total_digest_enc_1(void)
7394 {
7395 	return test_snow3g_auth_cipher(
7396 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7397 }
7398 
7399 static int
7400 test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7401 {
7402 	return test_snow3g_auth_cipher(
7403 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7404 }
7405 
7406 static int
7407 test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7408 {
7409 	return test_snow3g_auth_cipher_sgl(
7410 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7411 }
7412 
7413 static int
7414 test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7415 {
7416 	return test_snow3g_auth_cipher_sgl(
7417 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7418 }
7419 
7420 static int
7421 test_snow3g_auth_cipher_verify_test_case_1(void)
7422 {
7423 	return test_snow3g_auth_cipher(
7424 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7425 }
7426 
7427 static int
7428 test_snow3g_auth_cipher_verify_test_case_2(void)
7429 {
7430 	return test_snow3g_auth_cipher(
7431 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7432 }
7433 
7434 static int
7435 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7436 {
7437 	return test_snow3g_auth_cipher(
7438 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7439 }
7440 
7441 static int
7442 test_snow3g_auth_cipher_verify_part_digest_enc(void)
7443 {
7444 	return test_snow3g_auth_cipher(
7445 		&snow3g_auth_cipher_partial_digest_encryption,
7446 			IN_PLACE, 1);
7447 }
7448 
7449 static int
7450 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7451 {
7452 	return test_snow3g_auth_cipher(
7453 		&snow3g_auth_cipher_partial_digest_encryption,
7454 			OUT_OF_PLACE, 1);
7455 }
7456 
7457 static int
7458 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7459 {
7460 	return test_snow3g_auth_cipher_sgl(
7461 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7462 }
7463 
7464 static int
7465 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7466 {
7467 	return test_snow3g_auth_cipher_sgl(
7468 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7469 }
7470 
7471 static int
7472 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7473 {
7474 	return test_snow3g_auth_cipher_sgl(
7475 		&snow3g_auth_cipher_partial_digest_encryption,
7476 			IN_PLACE, 1);
7477 }
7478 
7479 static int
7480 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7481 {
7482 	return test_snow3g_auth_cipher_sgl(
7483 		&snow3g_auth_cipher_partial_digest_encryption,
7484 			OUT_OF_PLACE, 1);
7485 }
7486 
7487 static int
7488 test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7489 {
7490 	return test_snow3g_auth_cipher(
7491 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7492 }
7493 
7494 static int
7495 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7496 {
7497 	return test_snow3g_auth_cipher(
7498 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7499 }
7500 
7501 static int
7502 test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7503 {
7504 	return test_snow3g_auth_cipher_sgl(
7505 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7506 }
7507 
7508 static int
7509 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7510 {
7511 	return test_snow3g_auth_cipher_sgl(
7512 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7513 }
7514 
7515 static int
7516 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7517 {
7518 	return test_snow3g_auth_cipher(
7519 		&snow3g_test_case_7, IN_PLACE, 0);
7520 }
7521 
7522 static int
7523 test_kasumi_auth_cipher_test_case_1(void)
7524 {
7525 	return test_kasumi_auth_cipher(
7526 		&kasumi_test_case_3, IN_PLACE, 0);
7527 }
7528 
7529 static int
7530 test_kasumi_auth_cipher_test_case_2(void)
7531 {
7532 	return test_kasumi_auth_cipher(
7533 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7534 }
7535 
7536 static int
7537 test_kasumi_auth_cipher_test_case_2_oop(void)
7538 {
7539 	return test_kasumi_auth_cipher(
7540 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7541 }
7542 
7543 static int
7544 test_kasumi_auth_cipher_test_case_2_sgl(void)
7545 {
7546 	return test_kasumi_auth_cipher_sgl(
7547 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7548 }
7549 
7550 static int
7551 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7552 {
7553 	return test_kasumi_auth_cipher_sgl(
7554 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7555 }
7556 
7557 static int
7558 test_kasumi_auth_cipher_verify_test_case_1(void)
7559 {
7560 	return test_kasumi_auth_cipher(
7561 		&kasumi_test_case_3, IN_PLACE, 1);
7562 }
7563 
7564 static int
7565 test_kasumi_auth_cipher_verify_test_case_2(void)
7566 {
7567 	return test_kasumi_auth_cipher(
7568 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7569 }
7570 
7571 static int
7572 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7573 {
7574 	return test_kasumi_auth_cipher(
7575 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7576 }
7577 
7578 static int
7579 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7580 {
7581 	return test_kasumi_auth_cipher_sgl(
7582 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7583 }
7584 
7585 static int
7586 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7587 {
7588 	return test_kasumi_auth_cipher_sgl(
7589 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7590 }
7591 
7592 static int
7593 test_kasumi_cipher_auth_test_case_1(void)
7594 {
7595 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7596 }
7597 
7598 static int
7599 test_zuc_encryption_test_case_1(void)
7600 {
7601 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7602 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7603 }
7604 
7605 static int
7606 test_zuc_encryption_test_case_2(void)
7607 {
7608 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7609 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7610 }
7611 
7612 static int
7613 test_zuc_encryption_test_case_3(void)
7614 {
7615 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7616 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7617 }
7618 
7619 static int
7620 test_zuc_encryption_test_case_4(void)
7621 {
7622 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7623 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7624 }
7625 
7626 static int
7627 test_zuc_encryption_test_case_5(void)
7628 {
7629 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7630 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7631 }
7632 
7633 static int
7634 test_zuc_encryption_test_case_6_sgl(void)
7635 {
7636 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7637 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7638 }
7639 
7640 static int
7641 test_zuc_decryption_test_case_1(void)
7642 {
7643 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7644 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7645 }
7646 
7647 static int
7648 test_zuc_decryption_test_case_2(void)
7649 {
7650 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7651 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7652 }
7653 
7654 static int
7655 test_zuc_decryption_test_case_3(void)
7656 {
7657 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7658 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7659 }
7660 
7661 static int
7662 test_zuc_decryption_test_case_4(void)
7663 {
7664 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7665 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7666 }
7667 
7668 static int
7669 test_zuc_decryption_test_case_5(void)
7670 {
7671 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7672 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7673 }
7674 
7675 static int
7676 test_zuc_decryption_test_case_6_sgl(void)
7677 {
7678 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7679 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7680 }
7681 
7682 static int
7683 test_zuc_hash_generate_test_case_1(void)
7684 {
7685 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7686 			RTE_CRYPTO_AUTH_OP_GENERATE);
7687 }
7688 
7689 static int
7690 test_zuc_hash_generate_test_case_2(void)
7691 {
7692 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7693 			RTE_CRYPTO_AUTH_OP_GENERATE);
7694 }
7695 
7696 static int
7697 test_zuc_hash_generate_test_case_3(void)
7698 {
7699 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7700 			RTE_CRYPTO_AUTH_OP_GENERATE);
7701 }
7702 
7703 static int
7704 test_zuc_hash_generate_test_case_4(void)
7705 {
7706 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7707 			RTE_CRYPTO_AUTH_OP_GENERATE);
7708 }
7709 
7710 static int
7711 test_zuc_hash_generate_test_case_5(void)
7712 {
7713 	return test_zuc_authentication(&zuc_test_auth_5670b,
7714 			RTE_CRYPTO_AUTH_OP_GENERATE);
7715 }
7716 
7717 static int
7718 test_zuc_hash_generate_test_case_6(void)
7719 {
7720 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7721 			RTE_CRYPTO_AUTH_OP_GENERATE);
7722 }
7723 
7724 static int
7725 test_zuc_hash_generate_test_case_7(void)
7726 {
7727 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7728 			RTE_CRYPTO_AUTH_OP_GENERATE);
7729 }
7730 
7731 static int
7732 test_zuc_hash_generate_test_case_8(void)
7733 {
7734 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7735 			RTE_CRYPTO_AUTH_OP_GENERATE);
7736 }
7737 
7738 static int
7739 test_zuc_hash_verify_test_case_1(void)
7740 {
7741 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7742 			RTE_CRYPTO_AUTH_OP_VERIFY);
7743 }
7744 
7745 static int
7746 test_zuc_hash_verify_test_case_2(void)
7747 {
7748 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7749 			RTE_CRYPTO_AUTH_OP_VERIFY);
7750 }
7751 
7752 static int
7753 test_zuc_hash_verify_test_case_3(void)
7754 {
7755 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7756 			RTE_CRYPTO_AUTH_OP_VERIFY);
7757 }
7758 
7759 static int
7760 test_zuc_hash_verify_test_case_4(void)
7761 {
7762 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7763 			RTE_CRYPTO_AUTH_OP_VERIFY);
7764 }
7765 
7766 static int
7767 test_zuc_hash_verify_test_case_5(void)
7768 {
7769 	return test_zuc_authentication(&zuc_test_auth_5670b,
7770 			RTE_CRYPTO_AUTH_OP_VERIFY);
7771 }
7772 
7773 static int
7774 test_zuc_hash_verify_test_case_6(void)
7775 {
7776 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7777 			RTE_CRYPTO_AUTH_OP_VERIFY);
7778 }
7779 
7780 static int
7781 test_zuc_hash_verify_test_case_7(void)
7782 {
7783 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7784 			RTE_CRYPTO_AUTH_OP_VERIFY);
7785 }
7786 
7787 static int
7788 test_zuc_hash_verify_test_case_8(void)
7789 {
7790 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7791 			RTE_CRYPTO_AUTH_OP_VERIFY);
7792 }
7793 
7794 static int
7795 test_zuc_cipher_auth_test_case_1(void)
7796 {
7797 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7798 }
7799 
7800 static int
7801 test_zuc_cipher_auth_test_case_2(void)
7802 {
7803 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7804 }
7805 
7806 static int
7807 test_zuc_auth_cipher_test_case_1(void)
7808 {
7809 	return test_zuc_auth_cipher(
7810 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7811 }
7812 
7813 static int
7814 test_zuc_auth_cipher_test_case_1_oop(void)
7815 {
7816 	return test_zuc_auth_cipher(
7817 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7818 }
7819 
7820 static int
7821 test_zuc_auth_cipher_test_case_1_sgl(void)
7822 {
7823 	return test_zuc_auth_cipher_sgl(
7824 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7825 }
7826 
7827 static int
7828 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7829 {
7830 	return test_zuc_auth_cipher_sgl(
7831 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7832 }
7833 
7834 static int
7835 test_zuc_auth_cipher_test_case_2(void)
7836 {
7837 	return test_zuc_auth_cipher(
7838 		&zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7839 }
7840 
7841 static int
7842 test_zuc_auth_cipher_test_case_2_oop(void)
7843 {
7844 	return test_zuc_auth_cipher(
7845 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7846 }
7847 
7848 static int
7849 test_zuc_auth_cipher_verify_test_case_1(void)
7850 {
7851 	return test_zuc_auth_cipher(
7852 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7853 }
7854 
7855 static int
7856 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7857 {
7858 	return test_zuc_auth_cipher(
7859 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7860 }
7861 
7862 static int
7863 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7864 {
7865 	return test_zuc_auth_cipher_sgl(
7866 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7867 }
7868 
7869 static int
7870 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7871 {
7872 	return test_zuc_auth_cipher_sgl(
7873 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7874 }
7875 
7876 static int
7877 test_zuc_auth_cipher_verify_test_case_2(void)
7878 {
7879 	return test_zuc_auth_cipher(
7880 		&zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7881 }
7882 
7883 static int
7884 test_zuc_auth_cipher_verify_test_case_2_oop(void)
7885 {
7886 	return test_zuc_auth_cipher(
7887 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7888 }
7889 
7890 static int
7891 test_zuc256_encryption_test_case_1(void)
7892 {
7893 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7894 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7895 }
7896 
7897 static int
7898 test_zuc256_encryption_test_case_2(void)
7899 {
7900 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7901 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7902 }
7903 
7904 static int
7905 test_zuc256_decryption_test_case_1(void)
7906 {
7907 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
7908 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7909 }
7910 
7911 static int
7912 test_zuc256_decryption_test_case_2(void)
7913 {
7914 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
7915 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7916 }
7917 
7918 static int
7919 test_zuc256_hash_generate_4b_tag_test_case_1(void)
7920 {
7921 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7922 			RTE_CRYPTO_AUTH_OP_GENERATE);
7923 }
7924 
7925 static int
7926 test_zuc256_hash_generate_4b_tag_test_case_2(void)
7927 {
7928 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7929 			RTE_CRYPTO_AUTH_OP_GENERATE);
7930 }
7931 
7932 static int
7933 test_zuc256_hash_generate_4b_tag_test_case_3(void)
7934 {
7935 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7936 			RTE_CRYPTO_AUTH_OP_GENERATE);
7937 }
7938 
7939 static int
7940 test_zuc256_hash_generate_8b_tag_test_case_1(void)
7941 {
7942 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7943 			RTE_CRYPTO_AUTH_OP_GENERATE);
7944 }
7945 
7946 static int
7947 test_zuc256_hash_generate_16b_tag_test_case_1(void)
7948 {
7949 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7950 			RTE_CRYPTO_AUTH_OP_GENERATE);
7951 }
7952 
7953 static int
7954 test_zuc256_hash_verify_4b_tag_test_case_1(void)
7955 {
7956 	return test_zuc_authentication(&zuc256_test_case_auth_1,
7957 			RTE_CRYPTO_AUTH_OP_VERIFY);
7958 }
7959 
7960 static int
7961 test_zuc256_hash_verify_4b_tag_test_case_2(void)
7962 {
7963 	return test_zuc_authentication(&zuc256_test_case_auth_2,
7964 			RTE_CRYPTO_AUTH_OP_VERIFY);
7965 }
7966 
7967 static int
7968 test_zuc256_hash_verify_4b_tag_test_case_3(void)
7969 {
7970 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7971 			RTE_CRYPTO_AUTH_OP_VERIFY);
7972 }
7973 
7974 static int
7975 test_zuc256_hash_verify_8b_tag_test_case_1(void)
7976 {
7977 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7978 			RTE_CRYPTO_AUTH_OP_VERIFY);
7979 }
7980 
7981 static int
7982 test_zuc256_hash_verify_16b_tag_test_case_1(void)
7983 {
7984 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7985 			RTE_CRYPTO_AUTH_OP_VERIFY);
7986 }
7987 
7988 static int
7989 test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7990 {
7991 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7992 }
7993 
7994 static int
7995 test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7996 {
7997 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7998 }
7999 
8000 static int
8001 test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8002 {
8003 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8004 }
8005 
8006 static int
8007 test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8008 {
8009 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8010 }
8011 
8012 static int
8013 test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8014 {
8015 	return test_zuc_auth_cipher(
8016 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8017 }
8018 
8019 static int
8020 test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8021 {
8022 	return test_zuc_auth_cipher(
8023 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8024 }
8025 
8026 static int
8027 test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8028 {
8029 	return test_zuc_auth_cipher(
8030 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8031 }
8032 
8033 static int
8034 test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8035 {
8036 	return test_zuc_auth_cipher(
8037 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8038 }
8039 
8040 static int
8041 test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8042 {
8043 	return test_zuc_auth_cipher(
8044 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8045 }
8046 
8047 static int
8048 test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8049 {
8050 	return test_zuc_auth_cipher(
8051 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8052 }
8053 
8054 static int
8055 test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8056 {
8057 	return test_zuc_auth_cipher(
8058 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8059 }
8060 
8061 static int
8062 test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8063 {
8064 	return test_zuc_auth_cipher(
8065 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8066 }
8067 
8068 static int
8069 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8070 {
8071 	uint8_t dev_id = testsuite_params.valid_devs[0];
8072 
8073 	struct rte_cryptodev_sym_capability_idx cap_idx;
8074 
8075 	/* Check if device supports particular cipher algorithm */
8076 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8077 	cap_idx.algo.cipher = tdata->cipher_algo;
8078 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8079 		return TEST_SKIPPED;
8080 
8081 	/* Check if device supports particular hash algorithm */
8082 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8083 	cap_idx.algo.auth = tdata->auth_algo;
8084 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8085 		return TEST_SKIPPED;
8086 
8087 	return 0;
8088 }
8089 
8090 static int
8091 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8092 	uint8_t op_mode, uint8_t verify)
8093 {
8094 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8095 	struct crypto_unittest_params *ut_params = &unittest_params;
8096 
8097 	int retval;
8098 
8099 	uint8_t *plaintext = NULL, *ciphertext = NULL;
8100 	unsigned int plaintext_pad_len;
8101 	unsigned int plaintext_len;
8102 	unsigned int ciphertext_pad_len;
8103 	unsigned int ciphertext_len;
8104 	unsigned int digest_offset;
8105 
8106 	struct rte_cryptodev_info dev_info;
8107 	struct rte_crypto_op *op;
8108 
8109 	/* Check if device supports particular algorithms separately */
8110 	if (test_mixed_check_if_unsupported(tdata))
8111 		return TEST_SKIPPED;
8112 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8113 		return TEST_SKIPPED;
8114 
8115 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8116 		return TEST_SKIPPED;
8117 
8118 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8119 
8120 	uint64_t feat_flags = dev_info.feature_flags;
8121 
8122 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8123 		printf("Device doesn't support digest encrypted.\n");
8124 		return TEST_SKIPPED;
8125 	}
8126 
8127 	/* Create the session */
8128 	if (verify)
8129 		retval = create_wireless_algo_cipher_auth_session(
8130 				ts_params->valid_devs[0],
8131 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8132 				RTE_CRYPTO_AUTH_OP_VERIFY,
8133 				tdata->auth_algo,
8134 				tdata->cipher_algo,
8135 				tdata->auth_key.data, tdata->auth_key.len,
8136 				tdata->cipher_key.data, tdata->cipher_key.len,
8137 				tdata->auth_iv.len, tdata->digest_enc.len,
8138 				tdata->cipher_iv.len);
8139 	else
8140 		retval = create_wireless_algo_auth_cipher_session(
8141 				ts_params->valid_devs[0],
8142 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8143 				RTE_CRYPTO_AUTH_OP_GENERATE,
8144 				tdata->auth_algo,
8145 				tdata->cipher_algo,
8146 				tdata->auth_key.data, tdata->auth_key.len,
8147 				tdata->cipher_key.data, tdata->cipher_key.len,
8148 				tdata->auth_iv.len, tdata->digest_enc.len,
8149 				tdata->cipher_iv.len);
8150 	if (retval != 0)
8151 		return retval;
8152 
8153 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8154 	if (op_mode == OUT_OF_PLACE)
8155 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8156 
8157 	/* clear mbuf payload */
8158 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8159 		rte_pktmbuf_tailroom(ut_params->ibuf));
8160 	if (op_mode == OUT_OF_PLACE) {
8161 
8162 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8163 				rte_pktmbuf_tailroom(ut_params->obuf));
8164 	}
8165 
8166 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8167 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8168 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8169 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8170 
8171 	if (verify) {
8172 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8173 				ciphertext_pad_len);
8174 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8175 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8176 				ciphertext_len);
8177 	} else {
8178 		/* make sure enough space to cover partial digest verify case */
8179 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8180 				ciphertext_pad_len);
8181 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8182 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8183 	}
8184 
8185 	if (op_mode == OUT_OF_PLACE)
8186 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8187 
8188 	/* Create the operation */
8189 	retval = create_wireless_algo_auth_cipher_operation(
8190 			tdata->digest_enc.data, tdata->digest_enc.len,
8191 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8192 			tdata->auth_iv.data, tdata->auth_iv.len,
8193 			(tdata->digest_enc.offset == 0 ?
8194 				plaintext_pad_len
8195 				: tdata->digest_enc.offset),
8196 			tdata->validCipherLen.len_bits,
8197 			tdata->cipher.offset_bits,
8198 			tdata->validAuthLen.len_bits,
8199 			tdata->auth.offset_bits,
8200 			op_mode, 0, verify);
8201 
8202 	if (retval < 0)
8203 		return retval;
8204 
8205 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8206 
8207 	/* Check if the op failed because the device doesn't */
8208 	/* support this particular combination of algorithms */
8209 	if (op == NULL && ut_params->op->status ==
8210 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8211 		printf("Device doesn't support this mixed combination. "
8212 				"Test Skipped.\n");
8213 		return TEST_SKIPPED;
8214 	}
8215 	ut_params->op = op;
8216 
8217 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8218 
8219 	ut_params->obuf = (op_mode == IN_PLACE ?
8220 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8221 
8222 	if (verify) {
8223 		if (ut_params->obuf)
8224 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8225 							uint8_t *);
8226 		else
8227 			plaintext = ciphertext +
8228 					(tdata->cipher.offset_bits >> 3);
8229 
8230 		debug_hexdump(stdout, "plaintext:", plaintext,
8231 				tdata->plaintext.len_bits >> 3);
8232 		debug_hexdump(stdout, "plaintext expected:",
8233 				tdata->plaintext.data,
8234 				tdata->plaintext.len_bits >> 3);
8235 	} else {
8236 		if (ut_params->obuf)
8237 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8238 					uint8_t *);
8239 		else
8240 			ciphertext = plaintext;
8241 
8242 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8243 				ciphertext_len);
8244 		debug_hexdump(stdout, "ciphertext expected:",
8245 				tdata->ciphertext.data,
8246 				tdata->ciphertext.len_bits >> 3);
8247 
8248 		if (tdata->digest_enc.offset == 0)
8249 			digest_offset = plaintext_pad_len;
8250 		else
8251 			digest_offset = tdata->digest_enc.offset;
8252 
8253 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8254 					    uint8_t *, digest_offset);
8255 
8256 		debug_hexdump(stdout, "digest:", ut_params->digest,
8257 				tdata->digest_enc.len);
8258 		debug_hexdump(stdout, "digest expected:",
8259 				tdata->digest_enc.data,
8260 				tdata->digest_enc.len);
8261 	}
8262 
8263 	if (!verify) {
8264 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8265 				ut_params->digest,
8266 				tdata->digest_enc.data,
8267 				tdata->digest_enc.len,
8268 				"Generated auth tag not as expected");
8269 	}
8270 
8271 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8272 		if (verify) {
8273 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8274 					plaintext,
8275 					tdata->plaintext.data,
8276 					tdata->plaintext.len_bits >> 3,
8277 					"Plaintext data not as expected");
8278 		} else {
8279 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8280 					ciphertext,
8281 					tdata->ciphertext.data,
8282 					tdata->validDataLen.len_bits,
8283 					"Ciphertext data not as expected");
8284 		}
8285 	}
8286 
8287 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8288 			"crypto op processing failed");
8289 
8290 	return 0;
8291 }
8292 
8293 static int
8294 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8295 	uint8_t op_mode, uint8_t verify)
8296 {
8297 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8298 	struct crypto_unittest_params *ut_params = &unittest_params;
8299 
8300 	int retval;
8301 
8302 	const uint8_t *plaintext = NULL;
8303 	const uint8_t *ciphertext = NULL;
8304 	const uint8_t *digest = NULL;
8305 	unsigned int plaintext_pad_len;
8306 	unsigned int plaintext_len;
8307 	unsigned int ciphertext_pad_len;
8308 	unsigned int ciphertext_len;
8309 	uint8_t buffer[10000];
8310 	uint8_t digest_buffer[10000];
8311 
8312 	struct rte_cryptodev_info dev_info;
8313 	struct rte_crypto_op *op;
8314 
8315 	/* Check if device supports particular algorithms */
8316 	if (test_mixed_check_if_unsupported(tdata))
8317 		return TEST_SKIPPED;
8318 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8319 		return TEST_SKIPPED;
8320 
8321 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8322 
8323 	uint64_t feat_flags = dev_info.feature_flags;
8324 
8325 	if (op_mode == IN_PLACE) {
8326 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8327 			printf("Device doesn't support in-place scatter-gather "
8328 					"in both input and output mbufs.\n");
8329 			return TEST_SKIPPED;
8330 		}
8331 	} else {
8332 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8333 			printf("Device doesn't support out-of-place scatter-gather "
8334 					"in both input and output mbufs.\n");
8335 			return TEST_SKIPPED;
8336 		}
8337 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8338 			printf("Device doesn't support digest encrypted.\n");
8339 			return TEST_SKIPPED;
8340 		}
8341 	}
8342 
8343 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8344 		return TEST_SKIPPED;
8345 
8346 	/* Create the session */
8347 	if (verify)
8348 		retval = create_wireless_algo_cipher_auth_session(
8349 				ts_params->valid_devs[0],
8350 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8351 				RTE_CRYPTO_AUTH_OP_VERIFY,
8352 				tdata->auth_algo,
8353 				tdata->cipher_algo,
8354 				tdata->auth_key.data, tdata->auth_key.len,
8355 				tdata->cipher_key.data, tdata->cipher_key.len,
8356 				tdata->auth_iv.len, tdata->digest_enc.len,
8357 				tdata->cipher_iv.len);
8358 	else
8359 		retval = create_wireless_algo_auth_cipher_session(
8360 				ts_params->valid_devs[0],
8361 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8362 				RTE_CRYPTO_AUTH_OP_GENERATE,
8363 				tdata->auth_algo,
8364 				tdata->cipher_algo,
8365 				tdata->auth_key.data, tdata->auth_key.len,
8366 				tdata->cipher_key.data, tdata->cipher_key.len,
8367 				tdata->auth_iv.len, tdata->digest_enc.len,
8368 				tdata->cipher_iv.len);
8369 	if (retval != 0)
8370 		return retval;
8371 
8372 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8373 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8374 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8375 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8376 
8377 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8378 			ciphertext_pad_len, 15, 0);
8379 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8380 			"Failed to allocate input buffer in mempool");
8381 
8382 	if (op_mode == OUT_OF_PLACE) {
8383 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8384 				plaintext_pad_len, 15, 0);
8385 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
8386 				"Failed to allocate output buffer in mempool");
8387 	}
8388 
8389 	if (verify) {
8390 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8391 			tdata->ciphertext.data);
8392 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8393 					ciphertext_len, buffer);
8394 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8395 			ciphertext_len);
8396 	} else {
8397 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8398 			tdata->plaintext.data);
8399 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8400 					plaintext_len, buffer);
8401 		debug_hexdump(stdout, "plaintext:", plaintext,
8402 			plaintext_len);
8403 	}
8404 	memset(buffer, 0, sizeof(buffer));
8405 
8406 	/* Create the operation */
8407 	retval = create_wireless_algo_auth_cipher_operation(
8408 			tdata->digest_enc.data, tdata->digest_enc.len,
8409 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8410 			tdata->auth_iv.data, tdata->auth_iv.len,
8411 			(tdata->digest_enc.offset == 0 ?
8412 				plaintext_pad_len
8413 				: tdata->digest_enc.offset),
8414 			tdata->validCipherLen.len_bits,
8415 			tdata->cipher.offset_bits,
8416 			tdata->validAuthLen.len_bits,
8417 			tdata->auth.offset_bits,
8418 			op_mode, 1, verify);
8419 
8420 	if (retval < 0)
8421 		return retval;
8422 
8423 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8424 
8425 	/* Check if the op failed because the device doesn't */
8426 	/* support this particular combination of algorithms */
8427 	if (op == NULL && ut_params->op->status ==
8428 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8429 		printf("Device doesn't support this mixed combination. "
8430 				"Test Skipped.\n");
8431 		return TEST_SKIPPED;
8432 	}
8433 	ut_params->op = op;
8434 
8435 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8436 
8437 	ut_params->obuf = (op_mode == IN_PLACE ?
8438 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8439 
8440 	if (verify) {
8441 		if (ut_params->obuf)
8442 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8443 					plaintext_len, buffer);
8444 		else
8445 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8446 					plaintext_len, buffer);
8447 
8448 		debug_hexdump(stdout, "plaintext:", plaintext,
8449 				(tdata->plaintext.len_bits >> 3) -
8450 				tdata->digest_enc.len);
8451 		debug_hexdump(stdout, "plaintext expected:",
8452 				tdata->plaintext.data,
8453 				(tdata->plaintext.len_bits >> 3) -
8454 				tdata->digest_enc.len);
8455 	} else {
8456 		if (ut_params->obuf)
8457 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8458 					ciphertext_len, buffer);
8459 		else
8460 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8461 					ciphertext_len, buffer);
8462 
8463 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8464 			ciphertext_len);
8465 		debug_hexdump(stdout, "ciphertext expected:",
8466 			tdata->ciphertext.data,
8467 			tdata->ciphertext.len_bits >> 3);
8468 
8469 		if (ut_params->obuf)
8470 			digest = rte_pktmbuf_read(ut_params->obuf,
8471 					(tdata->digest_enc.offset == 0 ?
8472 						plaintext_pad_len :
8473 						tdata->digest_enc.offset),
8474 					tdata->digest_enc.len, digest_buffer);
8475 		else
8476 			digest = rte_pktmbuf_read(ut_params->ibuf,
8477 					(tdata->digest_enc.offset == 0 ?
8478 						plaintext_pad_len :
8479 						tdata->digest_enc.offset),
8480 					tdata->digest_enc.len, digest_buffer);
8481 
8482 		debug_hexdump(stdout, "digest:", digest,
8483 				tdata->digest_enc.len);
8484 		debug_hexdump(stdout, "digest expected:",
8485 				tdata->digest_enc.data, tdata->digest_enc.len);
8486 	}
8487 
8488 	if (!verify) {
8489 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8490 				digest,
8491 				tdata->digest_enc.data,
8492 				tdata->digest_enc.len,
8493 				"Generated auth tag not as expected");
8494 	}
8495 
8496 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8497 		if (verify) {
8498 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8499 					plaintext,
8500 					tdata->plaintext.data,
8501 					tdata->plaintext.len_bits >> 3,
8502 					"Plaintext data not as expected");
8503 		} else {
8504 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8505 					ciphertext,
8506 					tdata->ciphertext.data,
8507 					tdata->validDataLen.len_bits,
8508 					"Ciphertext data not as expected");
8509 		}
8510 	}
8511 
8512 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8513 			"crypto op processing failed");
8514 
8515 	return 0;
8516 }
8517 
8518 /** AUTH AES CMAC + CIPHER AES CTR */
8519 
8520 static int
8521 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8522 {
8523 	return test_mixed_auth_cipher(
8524 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8525 }
8526 
8527 static int
8528 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8529 {
8530 	return test_mixed_auth_cipher(
8531 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8532 }
8533 
8534 static int
8535 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8536 {
8537 	return test_mixed_auth_cipher_sgl(
8538 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8539 }
8540 
8541 static int
8542 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8543 {
8544 	return test_mixed_auth_cipher_sgl(
8545 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8546 }
8547 
8548 static int
8549 test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8550 {
8551 	return test_mixed_auth_cipher(
8552 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8553 }
8554 
8555 static int
8556 test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8557 {
8558 	return test_mixed_auth_cipher(
8559 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8560 }
8561 
8562 static int
8563 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8564 {
8565 	return test_mixed_auth_cipher(
8566 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8567 }
8568 
8569 static int
8570 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8571 {
8572 	return test_mixed_auth_cipher(
8573 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8574 }
8575 
8576 static int
8577 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8578 {
8579 	return test_mixed_auth_cipher(
8580 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8581 }
8582 
8583 static int
8584 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8585 {
8586 	return test_mixed_auth_cipher_sgl(
8587 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8588 }
8589 
8590 static int
8591 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8592 {
8593 	return test_mixed_auth_cipher_sgl(
8594 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8595 }
8596 
8597 static int
8598 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8599 {
8600 	return test_mixed_auth_cipher(
8601 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8602 }
8603 
8604 /** MIXED AUTH + CIPHER */
8605 
8606 static int
8607 test_auth_zuc_cipher_snow_test_case_1(void)
8608 {
8609 	return test_mixed_auth_cipher(
8610 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8611 }
8612 
8613 static int
8614 test_verify_auth_zuc_cipher_snow_test_case_1(void)
8615 {
8616 	return test_mixed_auth_cipher(
8617 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8618 }
8619 
8620 static int
8621 test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8622 {
8623 	return test_mixed_auth_cipher(
8624 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8625 }
8626 
8627 static int
8628 test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8629 {
8630 	return test_mixed_auth_cipher(
8631 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8632 }
8633 
8634 
8635 static int
8636 test_auth_aes_cmac_cipher_snow_test_case_1(void)
8637 {
8638 	return test_mixed_auth_cipher(
8639 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8640 }
8641 
8642 static int
8643 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8644 {
8645 	return test_mixed_auth_cipher(
8646 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8647 }
8648 
8649 static int
8650 test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8651 {
8652 	return test_mixed_auth_cipher(
8653 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8654 }
8655 
8656 static int
8657 test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8658 {
8659 	return test_mixed_auth_cipher(
8660 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8661 }
8662 
8663 static int
8664 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8665 {
8666 	return test_mixed_auth_cipher(
8667 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8668 }
8669 
8670 static int
8671 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8672 {
8673 	return test_mixed_auth_cipher(
8674 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8675 }
8676 
8677 static int
8678 test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8679 {
8680 	return test_mixed_auth_cipher(
8681 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8682 }
8683 
8684 static int
8685 test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8686 {
8687 	return test_mixed_auth_cipher(
8688 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8689 }
8690 
8691 static int
8692 test_auth_snow_cipher_aes_ctr_test_case_1(void)
8693 {
8694 	return test_mixed_auth_cipher(
8695 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8696 }
8697 
8698 static int
8699 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8700 {
8701 	return test_mixed_auth_cipher(
8702 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8703 }
8704 
8705 static int
8706 test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8707 {
8708 	return test_mixed_auth_cipher_sgl(
8709 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8710 }
8711 
8712 static int
8713 test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8714 {
8715 	return test_mixed_auth_cipher(
8716 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8717 }
8718 
8719 static int
8720 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8721 {
8722 	return test_mixed_auth_cipher_sgl(
8723 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8724 }
8725 
8726 static int
8727 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8728 {
8729 	return test_mixed_auth_cipher(
8730 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8731 }
8732 
8733 static int
8734 test_auth_snow_cipher_zuc_test_case_1(void)
8735 {
8736 	return test_mixed_auth_cipher(
8737 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8738 }
8739 
8740 static int
8741 test_verify_auth_snow_cipher_zuc_test_case_1(void)
8742 {
8743 	return test_mixed_auth_cipher(
8744 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8745 }
8746 
8747 static int
8748 test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8749 {
8750 	return test_mixed_auth_cipher(
8751 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8752 }
8753 
8754 static int
8755 test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8756 {
8757 	return test_mixed_auth_cipher(
8758 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8759 }
8760 
8761 static int
8762 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8763 {
8764 	return test_mixed_auth_cipher(
8765 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8766 }
8767 
8768 static int
8769 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8770 {
8771 	return test_mixed_auth_cipher(
8772 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8773 }
8774 static int
8775 test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8776 {
8777 	return test_mixed_auth_cipher(
8778 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8779 }
8780 
8781 static int
8782 test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8783 {
8784 	return test_mixed_auth_cipher(
8785 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8786 }
8787 
8788 static int
8789 test_auth_null_cipher_snow_test_case_1(void)
8790 {
8791 	return test_mixed_auth_cipher(
8792 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8793 }
8794 
8795 static int
8796 test_verify_auth_null_cipher_snow_test_case_1(void)
8797 {
8798 	return test_mixed_auth_cipher(
8799 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8800 }
8801 
8802 static int
8803 test_auth_null_cipher_zuc_test_case_1(void)
8804 {
8805 	return test_mixed_auth_cipher(
8806 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8807 }
8808 
8809 static int
8810 test_verify_auth_null_cipher_zuc_test_case_1(void)
8811 {
8812 	return test_mixed_auth_cipher(
8813 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8814 }
8815 
8816 static int
8817 test_auth_snow_cipher_null_test_case_1(void)
8818 {
8819 	return test_mixed_auth_cipher(
8820 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8821 }
8822 
8823 static int
8824 test_verify_auth_snow_cipher_null_test_case_1(void)
8825 {
8826 	return test_mixed_auth_cipher(
8827 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8828 }
8829 
8830 static int
8831 test_auth_zuc_cipher_null_test_case_1(void)
8832 {
8833 	return test_mixed_auth_cipher(
8834 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8835 }
8836 
8837 static int
8838 test_verify_auth_zuc_cipher_null_test_case_1(void)
8839 {
8840 	return test_mixed_auth_cipher(
8841 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8842 }
8843 
8844 static int
8845 test_auth_null_cipher_aes_ctr_test_case_1(void)
8846 {
8847 	return test_mixed_auth_cipher(
8848 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8849 }
8850 
8851 static int
8852 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8853 {
8854 	return test_mixed_auth_cipher(
8855 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8856 }
8857 
8858 static int
8859 test_auth_aes_cmac_cipher_null_test_case_1(void)
8860 {
8861 	return test_mixed_auth_cipher(
8862 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8863 }
8864 
8865 static int
8866 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8867 {
8868 	return test_mixed_auth_cipher(
8869 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8870 }
8871 
8872 /* ***** AEAD algorithm Tests ***** */
8873 
8874 static int
8875 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8876 		enum rte_crypto_aead_operation op,
8877 		const uint8_t *key, const uint8_t key_len,
8878 		const uint16_t aad_len, const uint8_t auth_len,
8879 		uint8_t iv_len)
8880 {
8881 	uint8_t aead_key[key_len];
8882 
8883 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8884 	struct crypto_unittest_params *ut_params = &unittest_params;
8885 
8886 	memcpy(aead_key, key, key_len);
8887 
8888 	/* Setup AEAD Parameters */
8889 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8890 	ut_params->aead_xform.next = NULL;
8891 	ut_params->aead_xform.aead.algo = algo;
8892 	ut_params->aead_xform.aead.op = op;
8893 	ut_params->aead_xform.aead.key.data = aead_key;
8894 	ut_params->aead_xform.aead.key.length = key_len;
8895 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8896 	ut_params->aead_xform.aead.iv.length = iv_len;
8897 	ut_params->aead_xform.aead.digest_length = auth_len;
8898 	ut_params->aead_xform.aead.aad_length = aad_len;
8899 
8900 	debug_hexdump(stdout, "key:", key, key_len);
8901 
8902 	/* Create Crypto session*/
8903 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8904 			&ut_params->aead_xform, ts_params->session_mpool);
8905 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8906 		return TEST_SKIPPED;
8907 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8908 	return 0;
8909 }
8910 
8911 static int
8912 create_aead_xform(struct rte_crypto_op *op,
8913 		enum rte_crypto_aead_algorithm algo,
8914 		enum rte_crypto_aead_operation aead_op,
8915 		uint8_t *key, const uint8_t key_len,
8916 		const uint8_t aad_len, const uint8_t auth_len,
8917 		uint8_t iv_len)
8918 {
8919 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8920 			"failed to allocate space for crypto transform");
8921 
8922 	struct rte_crypto_sym_op *sym_op = op->sym;
8923 
8924 	/* Setup AEAD Parameters */
8925 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8926 	sym_op->xform->next = NULL;
8927 	sym_op->xform->aead.algo = algo;
8928 	sym_op->xform->aead.op = aead_op;
8929 	sym_op->xform->aead.key.data = key;
8930 	sym_op->xform->aead.key.length = key_len;
8931 	sym_op->xform->aead.iv.offset = IV_OFFSET;
8932 	sym_op->xform->aead.iv.length = iv_len;
8933 	sym_op->xform->aead.digest_length = auth_len;
8934 	sym_op->xform->aead.aad_length = aad_len;
8935 
8936 	debug_hexdump(stdout, "key:", key, key_len);
8937 
8938 	return 0;
8939 }
8940 
8941 static int
8942 create_aead_operation(enum rte_crypto_aead_operation op,
8943 		const struct aead_test_data *tdata)
8944 {
8945 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8946 	struct crypto_unittest_params *ut_params = &unittest_params;
8947 
8948 	uint8_t *plaintext, *ciphertext;
8949 	unsigned int aad_pad_len, plaintext_pad_len;
8950 
8951 	/* Generate Crypto op data structure */
8952 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8953 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8954 	TEST_ASSERT_NOT_NULL(ut_params->op,
8955 			"Failed to allocate symmetric crypto operation struct");
8956 
8957 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8958 
8959 	/* Append aad data */
8960 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8961 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8962 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8963 				aad_pad_len);
8964 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8965 				"no room to append aad");
8966 
8967 		sym_op->aead.aad.phys_addr =
8968 				rte_pktmbuf_iova(ut_params->ibuf);
8969 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
8970 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8971 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8972 			tdata->aad.len);
8973 
8974 		/* Append IV at the end of the crypto operation*/
8975 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8976 				uint8_t *, IV_OFFSET);
8977 
8978 		/* Copy IV 1 byte after the IV pointer, according to the API */
8979 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8980 		debug_hexdump(stdout, "iv:", iv_ptr + 1,
8981 			tdata->iv.len);
8982 	} else {
8983 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8984 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8985 				aad_pad_len);
8986 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8987 				"no room to append aad");
8988 
8989 		sym_op->aead.aad.phys_addr =
8990 				rte_pktmbuf_iova(ut_params->ibuf);
8991 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8992 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8993 			tdata->aad.len);
8994 
8995 		/* Append IV at the end of the crypto operation*/
8996 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8997 				uint8_t *, IV_OFFSET);
8998 
8999 		if (tdata->iv.len == 0) {
9000 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9001 			debug_hexdump(stdout, "iv:", iv_ptr,
9002 				AES_GCM_J0_LENGTH);
9003 		} else {
9004 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9005 			debug_hexdump(stdout, "iv:", iv_ptr,
9006 				tdata->iv.len);
9007 		}
9008 	}
9009 
9010 	/* Append plaintext/ciphertext */
9011 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9012 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9013 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9014 				plaintext_pad_len);
9015 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9016 
9017 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9018 		debug_hexdump(stdout, "plaintext:", plaintext,
9019 				tdata->plaintext.len);
9020 
9021 		if (ut_params->obuf) {
9022 			ciphertext = (uint8_t *)rte_pktmbuf_append(
9023 					ut_params->obuf,
9024 					plaintext_pad_len + aad_pad_len);
9025 			TEST_ASSERT_NOT_NULL(ciphertext,
9026 					"no room to append ciphertext");
9027 
9028 			memset(ciphertext + aad_pad_len, 0,
9029 					tdata->ciphertext.len);
9030 		}
9031 	} else {
9032 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9033 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9034 				plaintext_pad_len);
9035 		TEST_ASSERT_NOT_NULL(ciphertext,
9036 				"no room to append ciphertext");
9037 
9038 		memcpy(ciphertext, tdata->ciphertext.data,
9039 				tdata->ciphertext.len);
9040 		debug_hexdump(stdout, "ciphertext:", ciphertext,
9041 				tdata->ciphertext.len);
9042 
9043 		if (ut_params->obuf) {
9044 			plaintext = (uint8_t *)rte_pktmbuf_append(
9045 					ut_params->obuf,
9046 					plaintext_pad_len + aad_pad_len);
9047 			TEST_ASSERT_NOT_NULL(plaintext,
9048 					"no room to append plaintext");
9049 
9050 			memset(plaintext + aad_pad_len, 0,
9051 					tdata->plaintext.len);
9052 		}
9053 	}
9054 
9055 	/* Append digest data */
9056 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9057 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9058 				ut_params->obuf ? ut_params->obuf :
9059 						ut_params->ibuf,
9060 						tdata->auth_tag.len);
9061 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9062 				"no room to append digest");
9063 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9064 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9065 				ut_params->obuf ? ut_params->obuf :
9066 						ut_params->ibuf,
9067 						plaintext_pad_len +
9068 						aad_pad_len);
9069 	} else {
9070 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9071 				ut_params->ibuf, tdata->auth_tag.len);
9072 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9073 				"no room to append digest");
9074 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9075 				ut_params->ibuf,
9076 				plaintext_pad_len + aad_pad_len);
9077 
9078 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9079 			tdata->auth_tag.len);
9080 		debug_hexdump(stdout, "digest:",
9081 			sym_op->aead.digest.data,
9082 			tdata->auth_tag.len);
9083 	}
9084 
9085 	sym_op->aead.data.length = tdata->plaintext.len;
9086 	sym_op->aead.data.offset = aad_pad_len;
9087 
9088 	return 0;
9089 }
9090 
9091 static int
9092 test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9093 {
9094 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9095 	struct crypto_unittest_params *ut_params = &unittest_params;
9096 
9097 	int retval;
9098 	uint8_t *ciphertext, *auth_tag;
9099 	uint16_t plaintext_pad_len;
9100 	uint32_t i;
9101 	struct rte_cryptodev_info dev_info;
9102 
9103 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9104 	uint64_t feat_flags = dev_info.feature_flags;
9105 
9106 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9107 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9108 		printf("Device doesn't support RAW data-path APIs.\n");
9109 		return TEST_SKIPPED;
9110 	}
9111 
9112 	/* Verify the capabilities */
9113 	struct rte_cryptodev_sym_capability_idx cap_idx;
9114 	const struct rte_cryptodev_symmetric_capability *capability;
9115 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9116 	cap_idx.algo.aead = tdata->algo;
9117 	capability = rte_cryptodev_sym_capability_get(
9118 			ts_params->valid_devs[0], &cap_idx);
9119 	if (capability == NULL)
9120 		return TEST_SKIPPED;
9121 	if (rte_cryptodev_sym_capability_check_aead(
9122 			capability, tdata->key.len, tdata->auth_tag.len,
9123 			tdata->aad.len, tdata->iv.len))
9124 		return TEST_SKIPPED;
9125 
9126 	/* Create AEAD session */
9127 	retval = create_aead_session(ts_params->valid_devs[0],
9128 			tdata->algo,
9129 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9130 			tdata->key.data, tdata->key.len,
9131 			tdata->aad.len, tdata->auth_tag.len,
9132 			tdata->iv.len);
9133 	if (retval != TEST_SUCCESS)
9134 		return retval;
9135 
9136 	if (tdata->aad.len > MBUF_SIZE) {
9137 		if (use_ext_mbuf) {
9138 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9139 							  AEAD_TEXT_MAX_LENGTH,
9140 							  1 /* nb_segs */,
9141 							  NULL);
9142 		} else {
9143 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9144 		}
9145 		/* Populate full size of add data */
9146 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9147 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9148 	} else {
9149 		if (use_ext_mbuf) {
9150 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9151 							  AEAD_TEXT_MAX_LENGTH,
9152 							  1 /* nb_segs */,
9153 							  NULL);
9154 		} else {
9155 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9156 		}
9157 	}
9158 
9159 	/* clear mbuf payload */
9160 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9161 			rte_pktmbuf_tailroom(ut_params->ibuf));
9162 
9163 	/* Create AEAD operation */
9164 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9165 	if (retval < 0)
9166 		return retval;
9167 
9168 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9169 
9170 	ut_params->op->sym->m_src = ut_params->ibuf;
9171 
9172 	/* Process crypto operation */
9173 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9174 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9175 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9176 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9177 					       0);
9178 		if (retval != TEST_SUCCESS)
9179 			return retval;
9180 	} else
9181 		TEST_ASSERT_NOT_NULL(
9182 			process_crypto_request(ts_params->valid_devs[0],
9183 			ut_params->op), "failed to process sym crypto op");
9184 
9185 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9186 			"crypto op processing failed");
9187 
9188 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9189 
9190 	if (ut_params->op->sym->m_dst) {
9191 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9192 				uint8_t *);
9193 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9194 				uint8_t *, plaintext_pad_len);
9195 	} else {
9196 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9197 				uint8_t *,
9198 				ut_params->op->sym->cipher.data.offset);
9199 		auth_tag = ciphertext + plaintext_pad_len;
9200 	}
9201 
9202 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9203 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9204 
9205 	/* Validate obuf */
9206 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9207 			ciphertext,
9208 			tdata->ciphertext.data,
9209 			tdata->ciphertext.len,
9210 			"Ciphertext data not as expected");
9211 
9212 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9213 			auth_tag,
9214 			tdata->auth_tag.data,
9215 			tdata->auth_tag.len,
9216 			"Generated auth tag not as expected");
9217 
9218 	return 0;
9219 
9220 }
9221 
9222 static int
9223 test_authenticated_encryption(const struct aead_test_data *tdata)
9224 {
9225 	return test_authenticated_encryption_helper(tdata, false);
9226 }
9227 
9228 #ifdef RTE_LIB_SECURITY
9229 static int
9230 security_proto_supported(enum rte_security_session_action_type action,
9231 	enum rte_security_session_protocol proto)
9232 {
9233 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9234 
9235 	const struct rte_security_capability *capabilities;
9236 	const struct rte_security_capability *capability;
9237 	uint16_t i = 0;
9238 
9239 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9240 
9241 
9242 	capabilities = rte_security_capabilities_get(ctx);
9243 
9244 	if (capabilities == NULL)
9245 		return -ENOTSUP;
9246 
9247 	while ((capability = &capabilities[i++])->action !=
9248 			RTE_SECURITY_ACTION_TYPE_NONE) {
9249 		if (capability->action == action &&
9250 				capability->protocol == proto)
9251 			return 0;
9252 	}
9253 
9254 	return -ENOTSUP;
9255 }
9256 
9257 /* Basic algorithm run function for async inplace mode.
9258  * Creates a session from input parameters and runs one operation
9259  * on input_vec. Checks the output of the crypto operation against
9260  * output_vec.
9261  */
9262 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9263 			   enum rte_crypto_auth_operation opa,
9264 			   const uint8_t *input_vec, unsigned int input_vec_len,
9265 			   const uint8_t *output_vec,
9266 			   unsigned int output_vec_len,
9267 			   enum rte_crypto_cipher_algorithm cipher_alg,
9268 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
9269 			   enum rte_crypto_auth_algorithm auth_alg,
9270 			   const uint8_t *auth_key, uint32_t auth_key_len,
9271 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
9272 			   uint8_t packet_direction, uint8_t sn_size,
9273 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9274 {
9275 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9276 	struct crypto_unittest_params *ut_params = &unittest_params;
9277 	uint8_t *plaintext;
9278 	int ret = TEST_SUCCESS;
9279 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9280 	struct rte_cryptodev_info dev_info;
9281 	uint64_t feat_flags;
9282 
9283 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9284 	feat_flags = dev_info.feature_flags;
9285 
9286 	/* Verify the capabilities */
9287 	struct rte_security_capability_idx sec_cap_idx;
9288 
9289 	sec_cap_idx.action = ut_params->type;
9290 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9291 	sec_cap_idx.pdcp.domain = domain;
9292 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9293 		return TEST_SKIPPED;
9294 
9295 	/* Generate test mbuf data */
9296 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9297 
9298 	/* clear mbuf payload */
9299 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9300 			rte_pktmbuf_tailroom(ut_params->ibuf));
9301 
9302 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9303 						  input_vec_len);
9304 	memcpy(plaintext, input_vec, input_vec_len);
9305 
9306 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9307 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9308 		printf("Device does not support RAW data-path APIs.\n");
9309 		return TEST_SKIPPED;
9310 	}
9311 	/* Out of place support */
9312 	if (oop) {
9313 		/*
9314 		 * For out-op-place we need to alloc another mbuf
9315 		 */
9316 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9317 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9318 	}
9319 
9320 	/* Setup Cipher Parameters */
9321 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9322 	ut_params->cipher_xform.cipher.algo = cipher_alg;
9323 	ut_params->cipher_xform.cipher.op = opc;
9324 	ut_params->cipher_xform.cipher.key.data = cipher_key;
9325 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9326 	ut_params->cipher_xform.cipher.iv.length =
9327 				packet_direction ? 4 : 0;
9328 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9329 
9330 	/* Setup HMAC Parameters if ICV header is required */
9331 	if (auth_alg != 0) {
9332 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9333 		ut_params->auth_xform.next = NULL;
9334 		ut_params->auth_xform.auth.algo = auth_alg;
9335 		ut_params->auth_xform.auth.op = opa;
9336 		ut_params->auth_xform.auth.key.data = auth_key;
9337 		ut_params->auth_xform.auth.key.length = auth_key_len;
9338 
9339 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9340 	} else {
9341 		ut_params->cipher_xform.next = NULL;
9342 	}
9343 
9344 	struct rte_security_session_conf sess_conf = {
9345 		.action_type = ut_params->type,
9346 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9347 		{.pdcp = {
9348 			.bearer = bearer,
9349 			.domain = domain,
9350 			.pkt_dir = packet_direction,
9351 			.sn_size = sn_size,
9352 			.hfn = packet_direction ? 0 : hfn,
9353 			/**
9354 			 * hfn can be set as pdcp_test_hfn[i]
9355 			 * if hfn_ovrd is not set. Here, PDCP
9356 			 * packet direction is just used to
9357 			 * run half of the cases with session
9358 			 * HFN and other half with per packet
9359 			 * HFN.
9360 			 */
9361 			.hfn_threshold = hfn_threshold,
9362 			.hfn_ovrd = packet_direction ? 1 : 0,
9363 			.sdap_enabled = sdap,
9364 		} },
9365 		.crypto_xform = &ut_params->cipher_xform
9366 	};
9367 
9368 	/* Create security session */
9369 	ut_params->sec_session = rte_security_session_create(ctx,
9370 				&sess_conf, ts_params->session_mpool);
9371 
9372 	if (!ut_params->sec_session) {
9373 		printf("TestCase %s()-%d line %d failed %s: ",
9374 			__func__, i, __LINE__, "Failed to allocate session");
9375 		ret = TEST_FAILED;
9376 		goto on_err;
9377 	}
9378 
9379 	/* Generate crypto op data structure */
9380 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9381 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9382 	if (!ut_params->op) {
9383 		printf("TestCase %s()-%d line %d failed %s: ",
9384 			__func__, i, __LINE__,
9385 			"Failed to allocate symmetric crypto operation struct");
9386 		ret = TEST_FAILED;
9387 		goto on_err;
9388 	}
9389 
9390 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9391 					uint32_t *, IV_OFFSET);
9392 	*per_pkt_hfn = packet_direction ? hfn : 0;
9393 
9394 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9395 
9396 	/* set crypto operation source mbuf */
9397 	ut_params->op->sym->m_src = ut_params->ibuf;
9398 	if (oop)
9399 		ut_params->op->sym->m_dst = ut_params->obuf;
9400 
9401 	/* Process crypto operation */
9402 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9403 		/* filling lengths */
9404 		ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9405 		ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9406 
9407 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9408 		if (ret != TEST_SUCCESS)
9409 			return ret;
9410 	} else {
9411 		ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9412 	}
9413 	if (ut_params->op == NULL) {
9414 		printf("TestCase %s()-%d line %d failed %s: ",
9415 			__func__, i, __LINE__,
9416 			"failed to process sym crypto op");
9417 		ret = TEST_FAILED;
9418 		goto on_err;
9419 	}
9420 
9421 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9422 		printf("TestCase %s()-%d line %d failed %s: ",
9423 			__func__, i, __LINE__, "crypto op processing failed");
9424 		ret = TEST_FAILED;
9425 		goto on_err;
9426 	}
9427 
9428 	/* Validate obuf */
9429 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9430 			uint8_t *);
9431 	if (oop) {
9432 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9433 				uint8_t *);
9434 	}
9435 
9436 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
9437 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9438 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9439 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9440 		ret = TEST_FAILED;
9441 		goto on_err;
9442 	}
9443 
9444 on_err:
9445 	rte_crypto_op_free(ut_params->op);
9446 	ut_params->op = NULL;
9447 
9448 	if (ut_params->sec_session)
9449 		rte_security_session_destroy(ctx, ut_params->sec_session);
9450 	ut_params->sec_session = NULL;
9451 
9452 	rte_pktmbuf_free(ut_params->ibuf);
9453 	ut_params->ibuf = NULL;
9454 	if (oop) {
9455 		rte_pktmbuf_free(ut_params->obuf);
9456 		ut_params->obuf = NULL;
9457 	}
9458 
9459 	return ret;
9460 }
9461 
9462 static int
9463 test_pdcp_proto_SGL(int i, int oop,
9464 	enum rte_crypto_cipher_operation opc,
9465 	enum rte_crypto_auth_operation opa,
9466 	uint8_t *input_vec,
9467 	unsigned int input_vec_len,
9468 	uint8_t *output_vec,
9469 	unsigned int output_vec_len,
9470 	uint32_t fragsz,
9471 	uint32_t fragsz_oop)
9472 {
9473 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9474 	struct crypto_unittest_params *ut_params = &unittest_params;
9475 	uint8_t *plaintext;
9476 	struct rte_mbuf *buf, *buf_oop = NULL;
9477 	int ret = TEST_SUCCESS;
9478 	int to_trn = 0;
9479 	int to_trn_tbl[16];
9480 	int segs = 1;
9481 	unsigned int trn_data = 0;
9482 	struct rte_cryptodev_info dev_info;
9483 	uint64_t feat_flags;
9484 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9485 	struct rte_mbuf *temp_mbuf;
9486 
9487 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9488 	feat_flags = dev_info.feature_flags;
9489 
9490 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9491 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9492 		printf("Device does not support RAW data-path APIs.\n");
9493 		return -ENOTSUP;
9494 	}
9495 	/* Verify the capabilities */
9496 	struct rte_security_capability_idx sec_cap_idx;
9497 
9498 	sec_cap_idx.action = ut_params->type;
9499 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9500 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9501 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9502 		return TEST_SKIPPED;
9503 
9504 	if (fragsz > input_vec_len)
9505 		fragsz = input_vec_len;
9506 
9507 	uint16_t plaintext_len = fragsz;
9508 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9509 
9510 	if (fragsz_oop > output_vec_len)
9511 		frag_size_oop = output_vec_len;
9512 
9513 	int ecx = 0;
9514 	if (input_vec_len % fragsz != 0) {
9515 		if (input_vec_len / fragsz + 1 > 16)
9516 			return 1;
9517 	} else if (input_vec_len / fragsz > 16)
9518 		return 1;
9519 
9520 	/* Out of place support */
9521 	if (oop) {
9522 		/*
9523 		 * For out-op-place we need to alloc another mbuf
9524 		 */
9525 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9526 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9527 		buf_oop = ut_params->obuf;
9528 	}
9529 
9530 	/* Generate test mbuf data */
9531 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9532 
9533 	/* clear mbuf payload */
9534 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9535 			rte_pktmbuf_tailroom(ut_params->ibuf));
9536 
9537 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9538 						  plaintext_len);
9539 	memcpy(plaintext, input_vec, plaintext_len);
9540 	trn_data += plaintext_len;
9541 
9542 	buf = ut_params->ibuf;
9543 
9544 	/*
9545 	 * Loop until no more fragments
9546 	 */
9547 
9548 	while (trn_data < input_vec_len) {
9549 		++segs;
9550 		to_trn = (input_vec_len - trn_data < fragsz) ?
9551 				(input_vec_len - trn_data) : fragsz;
9552 
9553 		to_trn_tbl[ecx++] = to_trn;
9554 
9555 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9556 		buf = buf->next;
9557 
9558 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9559 				rte_pktmbuf_tailroom(buf));
9560 
9561 		/* OOP */
9562 		if (oop && !fragsz_oop) {
9563 			buf_oop->next =
9564 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
9565 			buf_oop = buf_oop->next;
9566 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9567 					0, rte_pktmbuf_tailroom(buf_oop));
9568 			rte_pktmbuf_append(buf_oop, to_trn);
9569 		}
9570 
9571 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9572 				to_trn);
9573 
9574 		memcpy(plaintext, input_vec + trn_data, to_trn);
9575 		trn_data += to_trn;
9576 	}
9577 
9578 	ut_params->ibuf->nb_segs = segs;
9579 
9580 	segs = 1;
9581 	if (fragsz_oop && oop) {
9582 		to_trn = 0;
9583 		ecx = 0;
9584 
9585 		trn_data = frag_size_oop;
9586 		while (trn_data < output_vec_len) {
9587 			++segs;
9588 			to_trn =
9589 				(output_vec_len - trn_data <
9590 						frag_size_oop) ?
9591 				(output_vec_len - trn_data) :
9592 						frag_size_oop;
9593 
9594 			to_trn_tbl[ecx++] = to_trn;
9595 
9596 			buf_oop->next =
9597 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
9598 			buf_oop = buf_oop->next;
9599 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9600 					0, rte_pktmbuf_tailroom(buf_oop));
9601 			rte_pktmbuf_append(buf_oop, to_trn);
9602 
9603 			trn_data += to_trn;
9604 		}
9605 		ut_params->obuf->nb_segs = segs;
9606 	}
9607 
9608 	/* Setup Cipher Parameters */
9609 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9610 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9611 	ut_params->cipher_xform.cipher.op = opc;
9612 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9613 	ut_params->cipher_xform.cipher.key.length =
9614 					pdcp_test_params[i].cipher_key_len;
9615 	ut_params->cipher_xform.cipher.iv.length = 0;
9616 
9617 	/* Setup HMAC Parameters if ICV header is required */
9618 	if (pdcp_test_params[i].auth_alg != 0) {
9619 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9620 		ut_params->auth_xform.next = NULL;
9621 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9622 		ut_params->auth_xform.auth.op = opa;
9623 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9624 		ut_params->auth_xform.auth.key.length =
9625 					pdcp_test_params[i].auth_key_len;
9626 
9627 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9628 	} else {
9629 		ut_params->cipher_xform.next = NULL;
9630 	}
9631 
9632 	struct rte_security_session_conf sess_conf = {
9633 		.action_type = ut_params->type,
9634 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9635 		{.pdcp = {
9636 			.bearer = pdcp_test_bearer[i],
9637 			.domain = pdcp_test_params[i].domain,
9638 			.pkt_dir = pdcp_test_packet_direction[i],
9639 			.sn_size = pdcp_test_data_sn_size[i],
9640 			.hfn = pdcp_test_hfn[i],
9641 			.hfn_threshold = pdcp_test_hfn_threshold[i],
9642 			.hfn_ovrd = 0,
9643 		} },
9644 		.crypto_xform = &ut_params->cipher_xform
9645 	};
9646 
9647 	/* Create security session */
9648 	ut_params->sec_session = rte_security_session_create(ctx,
9649 				&sess_conf, ts_params->session_mpool);
9650 
9651 	if (!ut_params->sec_session) {
9652 		printf("TestCase %s()-%d line %d failed %s: ",
9653 			__func__, i, __LINE__, "Failed to allocate session");
9654 		ret = TEST_FAILED;
9655 		goto on_err;
9656 	}
9657 
9658 	/* Generate crypto op data structure */
9659 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9660 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9661 	if (!ut_params->op) {
9662 		printf("TestCase %s()-%d line %d failed %s: ",
9663 			__func__, i, __LINE__,
9664 			"Failed to allocate symmetric crypto operation struct");
9665 		ret = TEST_FAILED;
9666 		goto on_err;
9667 	}
9668 
9669 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9670 
9671 	/* set crypto operation source mbuf */
9672 	ut_params->op->sym->m_src = ut_params->ibuf;
9673 	if (oop)
9674 		ut_params->op->sym->m_dst = ut_params->obuf;
9675 
9676 	/* Process crypto operation */
9677 	temp_mbuf = ut_params->op->sym->m_src;
9678 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9679 		/* filling lengths */
9680 		while (temp_mbuf) {
9681 			ut_params->op->sym->cipher.data.length
9682 				+= temp_mbuf->pkt_len;
9683 			ut_params->op->sym->auth.data.length
9684 				+= temp_mbuf->pkt_len;
9685 			temp_mbuf = temp_mbuf->next;
9686 		}
9687 
9688 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9689 		if (ret != TEST_SUCCESS)
9690 			return ret;
9691 	} else {
9692 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9693 							ut_params->op);
9694 	}
9695 	if (ut_params->op == NULL) {
9696 		printf("TestCase %s()-%d line %d failed %s: ",
9697 			__func__, i, __LINE__,
9698 			"failed to process sym crypto op");
9699 		ret = TEST_FAILED;
9700 		goto on_err;
9701 	}
9702 
9703 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9704 		printf("TestCase %s()-%d line %d failed %s: ",
9705 			__func__, i, __LINE__, "crypto op processing failed");
9706 		ret = TEST_FAILED;
9707 		goto on_err;
9708 	}
9709 
9710 	/* Validate obuf */
9711 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9712 			uint8_t *);
9713 	if (oop) {
9714 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9715 				uint8_t *);
9716 	}
9717 	if (fragsz_oop)
9718 		fragsz = frag_size_oop;
9719 	if (memcmp(ciphertext, output_vec, fragsz)) {
9720 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9721 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9722 		rte_hexdump(stdout, "reference", output_vec, fragsz);
9723 		ret = TEST_FAILED;
9724 		goto on_err;
9725 	}
9726 
9727 	buf = ut_params->op->sym->m_src->next;
9728 	if (oop)
9729 		buf = ut_params->op->sym->m_dst->next;
9730 
9731 	unsigned int off = fragsz;
9732 
9733 	ecx = 0;
9734 	while (buf) {
9735 		ciphertext = rte_pktmbuf_mtod(buf,
9736 				uint8_t *);
9737 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9738 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9739 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9740 			rte_hexdump(stdout, "reference", output_vec + off,
9741 					to_trn_tbl[ecx]);
9742 			ret = TEST_FAILED;
9743 			goto on_err;
9744 		}
9745 		off += to_trn_tbl[ecx++];
9746 		buf = buf->next;
9747 	}
9748 on_err:
9749 	rte_crypto_op_free(ut_params->op);
9750 	ut_params->op = NULL;
9751 
9752 	if (ut_params->sec_session)
9753 		rte_security_session_destroy(ctx, ut_params->sec_session);
9754 	ut_params->sec_session = NULL;
9755 
9756 	rte_pktmbuf_free(ut_params->ibuf);
9757 	ut_params->ibuf = NULL;
9758 	if (oop) {
9759 		rte_pktmbuf_free(ut_params->obuf);
9760 		ut_params->obuf = NULL;
9761 	}
9762 
9763 	return ret;
9764 }
9765 
9766 int
9767 test_pdcp_proto_cplane_encap(int i)
9768 {
9769 	return test_pdcp_proto(
9770 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9771 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9772 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9773 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9774 		pdcp_test_params[i].cipher_key_len,
9775 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9776 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9777 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9778 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9779 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9780 }
9781 
9782 int
9783 test_pdcp_proto_uplane_encap(int i)
9784 {
9785 	return test_pdcp_proto(
9786 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9787 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9788 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9789 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9790 		pdcp_test_params[i].cipher_key_len,
9791 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9792 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9793 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9794 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9795 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9796 }
9797 
9798 int
9799 test_pdcp_proto_uplane_encap_with_int(int i)
9800 {
9801 	return test_pdcp_proto(
9802 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9803 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9804 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9805 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9806 		pdcp_test_params[i].cipher_key_len,
9807 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9808 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9809 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9810 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9811 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9812 }
9813 
9814 int
9815 test_pdcp_proto_cplane_decap(int i)
9816 {
9817 	return test_pdcp_proto(
9818 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9819 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9820 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9821 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9822 		pdcp_test_params[i].cipher_key_len,
9823 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9824 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9825 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9826 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9827 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9828 }
9829 
9830 int
9831 test_pdcp_proto_uplane_decap(int i)
9832 {
9833 	return test_pdcp_proto(
9834 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9835 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9836 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9837 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9838 		pdcp_test_params[i].cipher_key_len,
9839 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9840 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9841 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9842 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9843 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9844 }
9845 
9846 int
9847 test_pdcp_proto_uplane_decap_with_int(int i)
9848 {
9849 	return test_pdcp_proto(
9850 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9851 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9852 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9853 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9854 		pdcp_test_params[i].cipher_key_len,
9855 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9856 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9857 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9858 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9859 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9860 }
9861 
9862 static int
9863 test_PDCP_PROTO_SGL_in_place_32B(void)
9864 {
9865 	/* i can be used for running any PDCP case
9866 	 * In this case it is uplane 12-bit AES-SNOW DL encap
9867 	 */
9868 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9869 	return test_pdcp_proto_SGL(i, IN_PLACE,
9870 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9871 			RTE_CRYPTO_AUTH_OP_GENERATE,
9872 			pdcp_test_data_in[i],
9873 			pdcp_test_data_in_len[i],
9874 			pdcp_test_data_out[i],
9875 			pdcp_test_data_in_len[i]+4,
9876 			32, 0);
9877 }
9878 static int
9879 test_PDCP_PROTO_SGL_oop_32B_128B(void)
9880 {
9881 	/* i can be used for running any PDCP case
9882 	 * In this case it is uplane 18-bit NULL-NULL DL encap
9883 	 */
9884 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9885 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9886 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9887 			RTE_CRYPTO_AUTH_OP_GENERATE,
9888 			pdcp_test_data_in[i],
9889 			pdcp_test_data_in_len[i],
9890 			pdcp_test_data_out[i],
9891 			pdcp_test_data_in_len[i]+4,
9892 			32, 128);
9893 }
9894 static int
9895 test_PDCP_PROTO_SGL_oop_32B_40B(void)
9896 {
9897 	/* i can be used for running any PDCP case
9898 	 * In this case it is uplane 18-bit AES DL encap
9899 	 */
9900 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9901 			+ DOWNLINK;
9902 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9903 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9904 			RTE_CRYPTO_AUTH_OP_GENERATE,
9905 			pdcp_test_data_in[i],
9906 			pdcp_test_data_in_len[i],
9907 			pdcp_test_data_out[i],
9908 			pdcp_test_data_in_len[i],
9909 			32, 40);
9910 }
9911 static int
9912 test_PDCP_PROTO_SGL_oop_128B_32B(void)
9913 {
9914 	/* i can be used for running any PDCP case
9915 	 * In this case it is cplane 12-bit AES-ZUC DL encap
9916 	 */
9917 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9918 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9919 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9920 			RTE_CRYPTO_AUTH_OP_GENERATE,
9921 			pdcp_test_data_in[i],
9922 			pdcp_test_data_in_len[i],
9923 			pdcp_test_data_out[i],
9924 			pdcp_test_data_in_len[i]+4,
9925 			128, 32);
9926 }
9927 
9928 static int
9929 test_PDCP_SDAP_PROTO_encap_all(void)
9930 {
9931 	int i = 0, size = 0;
9932 	int err, all_err = TEST_SUCCESS;
9933 	const struct pdcp_sdap_test *cur_test;
9934 
9935 	size = RTE_DIM(list_pdcp_sdap_tests);
9936 
9937 	for (i = 0; i < size; i++) {
9938 		cur_test = &list_pdcp_sdap_tests[i];
9939 		err = test_pdcp_proto(
9940 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9941 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9942 			cur_test->in_len, cur_test->data_out,
9943 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9944 			cur_test->param.cipher_alg, cur_test->cipher_key,
9945 			cur_test->param.cipher_key_len,
9946 			cur_test->param.auth_alg,
9947 			cur_test->auth_key, cur_test->param.auth_key_len,
9948 			cur_test->bearer, cur_test->param.domain,
9949 			cur_test->packet_direction, cur_test->sn_size,
9950 			cur_test->hfn,
9951 			cur_test->hfn_threshold, SDAP_ENABLED);
9952 		if (err) {
9953 			printf("\t%d) %s: Encapsulation failed\n",
9954 					cur_test->test_idx,
9955 					cur_test->param.name);
9956 			err = TEST_FAILED;
9957 		} else {
9958 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9959 					cur_test->param.name);
9960 			err = TEST_SUCCESS;
9961 		}
9962 		all_err += err;
9963 	}
9964 
9965 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9966 
9967 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9968 }
9969 
9970 static int
9971 test_PDCP_PROTO_short_mac(void)
9972 {
9973 	int i = 0, size = 0;
9974 	int err, all_err = TEST_SUCCESS;
9975 	const struct pdcp_short_mac_test *cur_test;
9976 
9977 	size = RTE_DIM(list_pdcp_smac_tests);
9978 
9979 	for (i = 0; i < size; i++) {
9980 		cur_test = &list_pdcp_smac_tests[i];
9981 		err = test_pdcp_proto(
9982 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9983 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9984 			cur_test->in_len, cur_test->data_out,
9985 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9986 			RTE_CRYPTO_CIPHER_NULL, NULL,
9987 			0, cur_test->param.auth_alg,
9988 			cur_test->auth_key, cur_test->param.auth_key_len,
9989 			0, cur_test->param.domain, 0, 0,
9990 			0, 0, 0);
9991 		if (err) {
9992 			printf("\t%d) %s: Short MAC test failed\n",
9993 					cur_test->test_idx,
9994 					cur_test->param.name);
9995 			err = TEST_FAILED;
9996 		} else {
9997 			printf("\t%d) %s: Short MAC test PASS\n",
9998 					cur_test->test_idx,
9999 					cur_test->param.name);
10000 			rte_hexdump(stdout, "MAC I",
10001 				    cur_test->data_out + cur_test->in_len + 2,
10002 				    2);
10003 			err = TEST_SUCCESS;
10004 		}
10005 		all_err += err;
10006 	}
10007 
10008 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10009 
10010 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10011 
10012 }
10013 
10014 static int
10015 test_PDCP_SDAP_PROTO_decap_all(void)
10016 {
10017 	int i = 0, size = 0;
10018 	int err, all_err = TEST_SUCCESS;
10019 	const struct pdcp_sdap_test *cur_test;
10020 
10021 	size = RTE_DIM(list_pdcp_sdap_tests);
10022 
10023 	for (i = 0; i < size; i++) {
10024 		cur_test = &list_pdcp_sdap_tests[i];
10025 		err = test_pdcp_proto(
10026 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10027 			RTE_CRYPTO_AUTH_OP_VERIFY,
10028 			cur_test->data_out,
10029 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10030 			cur_test->data_in, cur_test->in_len,
10031 			cur_test->param.cipher_alg,
10032 			cur_test->cipher_key, cur_test->param.cipher_key_len,
10033 			cur_test->param.auth_alg, cur_test->auth_key,
10034 			cur_test->param.auth_key_len, cur_test->bearer,
10035 			cur_test->param.domain, cur_test->packet_direction,
10036 			cur_test->sn_size, cur_test->hfn,
10037 			cur_test->hfn_threshold, SDAP_ENABLED);
10038 		if (err) {
10039 			printf("\t%d) %s: Decapsulation failed\n",
10040 					cur_test->test_idx,
10041 					cur_test->param.name);
10042 			err = TEST_FAILED;
10043 		} else {
10044 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10045 					cur_test->param.name);
10046 			err = TEST_SUCCESS;
10047 		}
10048 		all_err += err;
10049 	}
10050 
10051 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10052 
10053 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10054 }
10055 
10056 static int
10057 test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10058 			       struct crypto_unittest_params *ut_params,
10059 			       struct rte_security_ipsec_xform *ipsec_xform,
10060 			       const struct ipsec_test_data *td,
10061 			       const struct ipsec_test_flags *flags,
10062 			       int pkt_num)
10063 {
10064 	uint8_t dev_id = ts_params->valid_devs[0];
10065 	enum rte_security_ipsec_sa_direction dir;
10066 	int ret;
10067 
10068 	dir = ipsec_xform->direction;
10069 
10070 	/* Generate crypto op data structure */
10071 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10072 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10073 	if (!ut_params->op) {
10074 		printf("Could not allocate crypto op");
10075 		return TEST_FAILED;
10076 	}
10077 
10078 	/* Attach session to operation */
10079 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10080 
10081 	/* Set crypto operation mbufs */
10082 	ut_params->op->sym->m_src = ut_params->ibuf;
10083 	ut_params->op->sym->m_dst = NULL;
10084 
10085 	/* Copy IV in crypto operation when IV generation is disabled */
10086 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10087 	    ipsec_xform->options.iv_gen_disable == 1) {
10088 		uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10089 							uint8_t *,
10090 							IV_OFFSET);
10091 		int len;
10092 
10093 		if (td->aead)
10094 			len = td->xform.aead.aead.iv.length;
10095 		else if (td->aes_gmac)
10096 			len = td->xform.chain.auth.auth.iv.length;
10097 		else
10098 			len = td->xform.chain.cipher.cipher.iv.length;
10099 
10100 		memcpy(iv, td->iv.data, len);
10101 	}
10102 
10103 	/* Process crypto operation */
10104 	process_crypto_request(dev_id, ut_params->op);
10105 
10106 	ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10107 
10108 	rte_crypto_op_free(ut_params->op);
10109 	ut_params->op = NULL;
10110 
10111 	return ret;
10112 }
10113 
10114 static int
10115 test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10116 			  struct crypto_unittest_params *ut_params,
10117 			  void *ctx)
10118 {
10119 	uint64_t timeout, userdata;
10120 	struct rte_ether_hdr *hdr;
10121 	struct rte_mbuf *m;
10122 	void **sec_sess;
10123 	int ret;
10124 
10125 	RTE_SET_USED(ts_params);
10126 
10127 	hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10128 	hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10129 
10130 	ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10131 	ut_params->ibuf->port = 0;
10132 
10133 	sec_sess = &ut_params->sec_session;
10134 	ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10135 
10136 	if (ret != 1)
10137 		return TEST_FAILED;
10138 
10139 	ut_params->ibuf = NULL;
10140 
10141 	/* Add a timeout for 1 s */
10142 	timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10143 
10144 	do {
10145 		/* Get packet from port 0, queue 0 */
10146 		ret = rte_eth_rx_burst(0, 0, &m, 1);
10147 	} while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10148 
10149 	if (ret == 0) {
10150 		printf("Could not receive packets from ethdev\n");
10151 		return TEST_FAILED;
10152 	}
10153 
10154 	if (m == NULL) {
10155 		printf("Received mbuf is NULL\n");
10156 		return TEST_FAILED;
10157 	}
10158 
10159 	ut_params->ibuf = m;
10160 
10161 	if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10162 		printf("Received packet is not Rx security processed\n");
10163 		return TEST_FAILED;
10164 	}
10165 
10166 	if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10167 		printf("Received packet has failed Rx security processing\n");
10168 		return TEST_FAILED;
10169 	}
10170 
10171 	/*
10172 	 * 'ut_params' is set as userdata. Verify that the field is returned
10173 	 * correctly.
10174 	 */
10175 	userdata = *(uint64_t *)rte_security_dynfield(m);
10176 	if (userdata != (uint64_t)ut_params) {
10177 		printf("Userdata retrieved not matching expected\n");
10178 		return TEST_FAILED;
10179 	}
10180 
10181 	/* Trim L2 header */
10182 	rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10183 
10184 	return TEST_SUCCESS;
10185 }
10186 
10187 static int
10188 test_ipsec_proto_process(const struct ipsec_test_data td[],
10189 			 struct ipsec_test_data res_d[],
10190 			 int nb_td,
10191 			 bool silent,
10192 			 const struct ipsec_test_flags *flags)
10193 {
10194 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10195 				0x0000, 0x001a};
10196 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10197 				0xe82c, 0x4887};
10198 	const struct rte_ipv4_hdr *ipv4 =
10199 			(const struct rte_ipv4_hdr *)td[0].output_text.data;
10200 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10201 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10202 	struct crypto_unittest_params *ut_params = &unittest_params;
10203 	struct rte_security_capability_idx sec_cap_idx;
10204 	const struct rte_security_capability *sec_cap;
10205 	struct rte_security_ipsec_xform ipsec_xform;
10206 	uint8_t dev_id = ts_params->valid_devs[0];
10207 	enum rte_security_ipsec_sa_direction dir;
10208 	struct ipsec_test_data *res_d_tmp = NULL;
10209 	uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10210 	int salt_len, i, ret = TEST_SUCCESS;
10211 	void *ctx;
10212 	uint32_t src, dst;
10213 	uint32_t verify;
10214 
10215 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10216 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10217 
10218 	/* Use first test data to create session */
10219 
10220 	/* Copy IPsec xform */
10221 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10222 
10223 	dir = ipsec_xform.direction;
10224 	verify = flags->tunnel_hdr_verify;
10225 
10226 	memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10227 	memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10228 
10229 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10230 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10231 			src += 1;
10232 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10233 			dst += 1;
10234 	}
10235 
10236 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10237 		if (td->ipsec_xform.tunnel.type ==
10238 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10239 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10240 			       sizeof(src));
10241 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10242 			       sizeof(dst));
10243 
10244 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10245 				ipsec_xform.tunnel.ipv4.df = 0;
10246 
10247 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10248 				ipsec_xform.tunnel.ipv4.df = 1;
10249 
10250 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10251 				ipsec_xform.tunnel.ipv4.dscp = 0;
10252 
10253 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10254 				ipsec_xform.tunnel.ipv4.dscp =
10255 						TEST_IPSEC_DSCP_VAL;
10256 
10257 		} else {
10258 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10259 				ipsec_xform.tunnel.ipv6.dscp = 0;
10260 
10261 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10262 				ipsec_xform.tunnel.ipv6.dscp =
10263 						TEST_IPSEC_DSCP_VAL;
10264 
10265 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10266 			       sizeof(v6_src));
10267 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10268 			       sizeof(v6_dst));
10269 		}
10270 	}
10271 
10272 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
10273 
10274 	sec_cap_idx.action = ut_params->type;
10275 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10276 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10277 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10278 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10279 
10280 	if (flags->udp_encap)
10281 		ipsec_xform.options.udp_encap = 1;
10282 
10283 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10284 	if (sec_cap == NULL)
10285 		return TEST_SKIPPED;
10286 
10287 	/* Copy cipher session parameters */
10288 	if (td[0].aead) {
10289 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10290 		       sizeof(ut_params->aead_xform));
10291 		ut_params->aead_xform.aead.key.data = td[0].key.data;
10292 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10293 
10294 		/* Verify crypto capabilities */
10295 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10296 			if (!silent)
10297 				RTE_LOG(INFO, USER1,
10298 					"Crypto capabilities not supported\n");
10299 			return TEST_SKIPPED;
10300 		}
10301 	} else if (td[0].auth_only) {
10302 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10303 		       sizeof(ut_params->auth_xform));
10304 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10305 
10306 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10307 			if (!silent)
10308 				RTE_LOG(INFO, USER1,
10309 					"Auth crypto capabilities not supported\n");
10310 			return TEST_SKIPPED;
10311 		}
10312 	} else {
10313 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10314 		       sizeof(ut_params->cipher_xform));
10315 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10316 		       sizeof(ut_params->auth_xform));
10317 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10318 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10319 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10320 
10321 		/* Verify crypto capabilities */
10322 
10323 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10324 			if (!silent)
10325 				RTE_LOG(INFO, USER1,
10326 					"Cipher crypto capabilities not supported\n");
10327 			return TEST_SKIPPED;
10328 		}
10329 
10330 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10331 			if (!silent)
10332 				RTE_LOG(INFO, USER1,
10333 					"Auth crypto capabilities not supported\n");
10334 			return TEST_SKIPPED;
10335 		}
10336 	}
10337 
10338 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10339 		return TEST_SKIPPED;
10340 
10341 	struct rte_security_session_conf sess_conf = {
10342 		.action_type = ut_params->type,
10343 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10344 	};
10345 
10346 	if (td[0].aead || td[0].aes_gmac) {
10347 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10348 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10349 	}
10350 
10351 	if (td[0].aead) {
10352 		sess_conf.ipsec = ipsec_xform;
10353 		sess_conf.crypto_xform = &ut_params->aead_xform;
10354 	} else if (td[0].auth_only) {
10355 		sess_conf.ipsec = ipsec_xform;
10356 		sess_conf.crypto_xform = &ut_params->auth_xform;
10357 	} else {
10358 		sess_conf.ipsec = ipsec_xform;
10359 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10360 			sess_conf.crypto_xform = &ut_params->cipher_xform;
10361 			ut_params->cipher_xform.next = &ut_params->auth_xform;
10362 		} else {
10363 			sess_conf.crypto_xform = &ut_params->auth_xform;
10364 			ut_params->auth_xform.next = &ut_params->cipher_xform;
10365 		}
10366 	}
10367 
10368 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10369 		sess_conf.userdata = ut_params;
10370 
10371 	/* Create security session */
10372 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10373 					ts_params->session_mpool);
10374 
10375 	if (ut_params->sec_session == NULL)
10376 		return TEST_SKIPPED;
10377 
10378 	for (i = 0; i < nb_td; i++) {
10379 		if (flags->antireplay &&
10380 		    (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10381 			sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10382 			ret = rte_security_session_update(ctx,
10383 				ut_params->sec_session, &sess_conf);
10384 			if (ret) {
10385 				printf("Could not update sequence number in "
10386 				       "session\n");
10387 				return TEST_SKIPPED;
10388 			}
10389 		}
10390 
10391 		/* Copy test data before modification */
10392 		memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10393 		if (test_ipsec_pkt_update(input_text, flags)) {
10394 			ret = TEST_FAILED;
10395 			goto mbuf_free;
10396 		}
10397 
10398 		/* Setup source mbuf payload */
10399 		if (flags->use_ext_mbuf) {
10400 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10401 					td[i].input_text.len, nb_segs, input_text);
10402 		} else {
10403 			ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10404 					td[i].input_text.len, nb_segs, 0);
10405 			pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10406 		}
10407 
10408 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10409 			ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10410 							ctx);
10411 		else
10412 			ret = test_ipsec_proto_crypto_op_enq(ts_params,
10413 							     ut_params,
10414 							     &ipsec_xform,
10415 							     &td[i], flags,
10416 							     i + 1);
10417 
10418 		if (ret != TEST_SUCCESS)
10419 			goto mbuf_free;
10420 
10421 		if (res_d != NULL)
10422 			res_d_tmp = &res_d[i];
10423 
10424 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10425 					      res_d_tmp, silent, flags);
10426 		if (ret != TEST_SUCCESS)
10427 			goto mbuf_free;
10428 
10429 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10430 					      flags, dir);
10431 		if (ret != TEST_SUCCESS)
10432 			goto mbuf_free;
10433 
10434 		rte_pktmbuf_free(ut_params->ibuf);
10435 		ut_params->ibuf = NULL;
10436 	}
10437 
10438 mbuf_free:
10439 	if (flags->use_ext_mbuf)
10440 		ext_mbuf_memzone_free(nb_segs);
10441 
10442 	rte_pktmbuf_free(ut_params->ibuf);
10443 	ut_params->ibuf = NULL;
10444 
10445 	if (ut_params->sec_session)
10446 		rte_security_session_destroy(ctx, ut_params->sec_session);
10447 	ut_params->sec_session = NULL;
10448 
10449 	return ret;
10450 }
10451 
10452 static int
10453 test_ipsec_proto_known_vec(const void *test_data)
10454 {
10455 	struct ipsec_test_data td_outb;
10456 	struct ipsec_test_flags flags;
10457 
10458 	memset(&flags, 0, sizeof(flags));
10459 
10460 	memcpy(&td_outb, test_data, sizeof(td_outb));
10461 
10462 	if (td_outb.aes_gmac || td_outb.aead ||
10463 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10464 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10465 		/* Disable IV gen to be able to test with known vectors */
10466 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10467 	}
10468 
10469 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10470 }
10471 
10472 static int
10473 test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10474 {
10475 	struct ipsec_test_data td_outb;
10476 	struct ipsec_test_flags flags;
10477 
10478 	memset(&flags, 0, sizeof(flags));
10479 	flags.use_ext_mbuf = true;
10480 
10481 	memcpy(&td_outb, test_data, sizeof(td_outb));
10482 
10483 	if (td_outb.aes_gmac || td_outb.aead ||
10484 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10485 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10486 		/* Disable IV gen to be able to test with known vectors */
10487 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10488 	}
10489 
10490 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10491 }
10492 
10493 static int
10494 test_ipsec_proto_known_vec_inb(const void *test_data)
10495 {
10496 	const struct ipsec_test_data *td = test_data;
10497 	struct ipsec_test_flags flags;
10498 	struct ipsec_test_data td_inb;
10499 
10500 	memset(&flags, 0, sizeof(flags));
10501 
10502 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10503 		test_ipsec_td_in_from_out(td, &td_inb);
10504 	else
10505 		memcpy(&td_inb, td, sizeof(td_inb));
10506 
10507 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10508 }
10509 
10510 static int
10511 test_ipsec_proto_known_vec_fragmented(const void *test_data)
10512 {
10513 	struct ipsec_test_data td_outb;
10514 	struct ipsec_test_flags flags;
10515 
10516 	memset(&flags, 0, sizeof(flags));
10517 	flags.fragment = true;
10518 
10519 	memcpy(&td_outb, test_data, sizeof(td_outb));
10520 
10521 	/* Disable IV gen to be able to test with known vectors */
10522 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
10523 
10524 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10525 }
10526 
10527 static int
10528 test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10529 {
10530 	const struct ipsec_test_data *td = test_data;
10531 	struct ipsec_test_flags flags;
10532 	struct ipsec_test_data td_inb;
10533 
10534 	memset(&flags, 0, sizeof(flags));
10535 	flags.rx_inject = true;
10536 
10537 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10538 		test_ipsec_td_in_from_out(td, &td_inb);
10539 	else
10540 		memcpy(&td_inb, td, sizeof(td_inb));
10541 
10542 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10543 }
10544 
10545 static int
10546 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10547 {
10548 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10549 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10550 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10551 	int ret;
10552 
10553 	if (flags->iv_gen ||
10554 	    flags->sa_expiry_pkts_soft ||
10555 	    flags->sa_expiry_pkts_hard)
10556 		nb_pkts = TEST_SEC_PKTS_MAX;
10557 
10558 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10559 		test_ipsec_td_prepare(sec_alg_list[i].param1,
10560 				      sec_alg_list[i].param2,
10561 				      flags,
10562 				      td_outb,
10563 				      nb_pkts);
10564 
10565 		if (!td_outb->aead) {
10566 			enum rte_crypto_cipher_algorithm cipher_alg;
10567 			enum rte_crypto_auth_algorithm auth_alg;
10568 
10569 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10570 			auth_alg = td_outb->xform.chain.auth.auth.algo;
10571 
10572 			if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10573 				continue;
10574 
10575 			/* ICV is not applicable for NULL auth */
10576 			if (flags->icv_corrupt &&
10577 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
10578 				continue;
10579 
10580 			/* IV is not applicable for NULL cipher */
10581 			if (flags->iv_gen &&
10582 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10583 				continue;
10584 		}
10585 
10586 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10587 					       flags);
10588 		if (ret == TEST_SKIPPED)
10589 			continue;
10590 
10591 		if (ret == TEST_FAILED)
10592 			return TEST_FAILED;
10593 
10594 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10595 
10596 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10597 					       flags);
10598 		if (ret == TEST_SKIPPED)
10599 			continue;
10600 
10601 		if (ret == TEST_FAILED)
10602 			return TEST_FAILED;
10603 
10604 		if (flags->display_alg)
10605 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10606 
10607 		pass_cnt++;
10608 	}
10609 
10610 	if (pass_cnt > 0)
10611 		return TEST_SUCCESS;
10612 	else
10613 		return TEST_SKIPPED;
10614 }
10615 
10616 static int
10617 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10618 {
10619 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10620 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10621 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10622 	int ret;
10623 
10624 	for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10625 		test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10626 				      sec_auth_only_alg_list[i].param2,
10627 				      flags,
10628 				      td_outb,
10629 				      nb_pkts);
10630 
10631 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10632 					       flags);
10633 		if (ret == TEST_SKIPPED)
10634 			continue;
10635 
10636 		if (ret == TEST_FAILED)
10637 			return TEST_FAILED;
10638 
10639 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10640 
10641 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10642 					       flags);
10643 		if (ret == TEST_SKIPPED)
10644 			continue;
10645 
10646 		if (ret == TEST_FAILED)
10647 			return TEST_FAILED;
10648 
10649 		if (flags->display_alg)
10650 			test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10651 					     sec_auth_only_alg_list[i].param2);
10652 
10653 		pass_cnt++;
10654 	}
10655 
10656 	if (pass_cnt > 0)
10657 		return TEST_SUCCESS;
10658 	else
10659 		return TEST_SKIPPED;
10660 }
10661 
10662 static int
10663 test_ipsec_proto_display_list(void)
10664 {
10665 	struct ipsec_test_flags flags;
10666 
10667 	memset(&flags, 0, sizeof(flags));
10668 
10669 	flags.display_alg = true;
10670 
10671 	return test_ipsec_proto_all(&flags);
10672 }
10673 
10674 static int
10675 test_ipsec_proto_ah_tunnel_ipv4(void)
10676 {
10677 	struct ipsec_test_flags flags;
10678 
10679 	memset(&flags, 0, sizeof(flags));
10680 
10681 	flags.ah = true;
10682 	flags.display_alg = true;
10683 
10684 	return test_ipsec_ah_proto_all(&flags);
10685 }
10686 
10687 static int
10688 test_ipsec_proto_ah_transport_ipv4(void)
10689 {
10690 	struct ipsec_test_flags flags;
10691 
10692 	memset(&flags, 0, sizeof(flags));
10693 
10694 	flags.ah = true;
10695 	flags.transport = true;
10696 
10697 	return test_ipsec_ah_proto_all(&flags);
10698 }
10699 
10700 static int
10701 test_ipsec_proto_iv_gen(void)
10702 {
10703 	struct ipsec_test_flags flags;
10704 
10705 	memset(&flags, 0, sizeof(flags));
10706 
10707 	flags.iv_gen = true;
10708 
10709 	return test_ipsec_proto_all(&flags);
10710 }
10711 
10712 static int
10713 test_ipsec_proto_sa_exp_pkts_soft(void)
10714 {
10715 	struct ipsec_test_flags flags;
10716 
10717 	memset(&flags, 0, sizeof(flags));
10718 
10719 	flags.sa_expiry_pkts_soft = true;
10720 
10721 	return test_ipsec_proto_all(&flags);
10722 }
10723 
10724 static int
10725 test_ipsec_proto_sa_exp_pkts_hard(void)
10726 {
10727 	struct ipsec_test_flags flags;
10728 
10729 	memset(&flags, 0, sizeof(flags));
10730 
10731 	flags.sa_expiry_pkts_hard = true;
10732 
10733 	return test_ipsec_proto_all(&flags);
10734 }
10735 
10736 static int
10737 test_ipsec_proto_err_icv_corrupt(void)
10738 {
10739 	struct ipsec_test_flags flags;
10740 
10741 	memset(&flags, 0, sizeof(flags));
10742 
10743 	flags.icv_corrupt = true;
10744 
10745 	return test_ipsec_proto_all(&flags);
10746 }
10747 
10748 static int
10749 test_ipsec_proto_udp_encap_custom_ports(void)
10750 {
10751 	struct ipsec_test_flags flags;
10752 
10753 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10754 			RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10755 		return TEST_SKIPPED;
10756 
10757 	memset(&flags, 0, sizeof(flags));
10758 
10759 	flags.udp_encap = true;
10760 	flags.udp_encap_custom_ports = true;
10761 
10762 	return test_ipsec_proto_all(&flags);
10763 }
10764 
10765 static int
10766 test_ipsec_proto_udp_encap(void)
10767 {
10768 	struct ipsec_test_flags flags;
10769 
10770 	memset(&flags, 0, sizeof(flags));
10771 
10772 	flags.udp_encap = true;
10773 
10774 	return test_ipsec_proto_all(&flags);
10775 }
10776 
10777 static int
10778 test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10779 {
10780 	struct ipsec_test_flags flags;
10781 
10782 	memset(&flags, 0, sizeof(flags));
10783 
10784 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10785 
10786 	return test_ipsec_proto_all(&flags);
10787 }
10788 
10789 static int
10790 test_ipsec_proto_tunnel_dst_addr_verify(void)
10791 {
10792 	struct ipsec_test_flags flags;
10793 
10794 	memset(&flags, 0, sizeof(flags));
10795 
10796 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10797 
10798 	return test_ipsec_proto_all(&flags);
10799 }
10800 
10801 static int
10802 test_ipsec_proto_udp_ports_verify(void)
10803 {
10804 	struct ipsec_test_flags flags;
10805 
10806 	memset(&flags, 0, sizeof(flags));
10807 
10808 	flags.udp_encap = true;
10809 	flags.udp_ports_verify = true;
10810 
10811 	return test_ipsec_proto_all(&flags);
10812 }
10813 
10814 static int
10815 test_ipsec_proto_inner_ip_csum(void)
10816 {
10817 	struct ipsec_test_flags flags;
10818 
10819 	memset(&flags, 0, sizeof(flags));
10820 
10821 	flags.ip_csum = true;
10822 
10823 	return test_ipsec_proto_all(&flags);
10824 }
10825 
10826 static int
10827 test_ipsec_proto_inner_l4_csum(void)
10828 {
10829 	struct ipsec_test_flags flags;
10830 
10831 	memset(&flags, 0, sizeof(flags));
10832 
10833 	flags.l4_csum = true;
10834 
10835 	return test_ipsec_proto_all(&flags);
10836 }
10837 
10838 static int
10839 test_ipsec_proto_tunnel_v4_in_v4(void)
10840 {
10841 	struct ipsec_test_flags flags;
10842 
10843 	memset(&flags, 0, sizeof(flags));
10844 
10845 	flags.ipv6 = false;
10846 	flags.tunnel_ipv6 = false;
10847 
10848 	return test_ipsec_proto_all(&flags);
10849 }
10850 
10851 static int
10852 test_ipsec_proto_tunnel_v6_in_v6(void)
10853 {
10854 	struct ipsec_test_flags flags;
10855 
10856 	memset(&flags, 0, sizeof(flags));
10857 
10858 	flags.ipv6 = true;
10859 	flags.tunnel_ipv6 = true;
10860 
10861 	return test_ipsec_proto_all(&flags);
10862 }
10863 
10864 static int
10865 test_ipsec_proto_tunnel_v4_in_v6(void)
10866 {
10867 	struct ipsec_test_flags flags;
10868 
10869 	memset(&flags, 0, sizeof(flags));
10870 
10871 	flags.ipv6 = false;
10872 	flags.tunnel_ipv6 = true;
10873 
10874 	return test_ipsec_proto_all(&flags);
10875 }
10876 
10877 static int
10878 test_ipsec_proto_tunnel_v6_in_v4(void)
10879 {
10880 	struct ipsec_test_flags flags;
10881 
10882 	memset(&flags, 0, sizeof(flags));
10883 
10884 	flags.ipv6 = true;
10885 	flags.tunnel_ipv6 = false;
10886 
10887 	return test_ipsec_proto_all(&flags);
10888 }
10889 
10890 static int
10891 test_ipsec_proto_transport_v4(void)
10892 {
10893 	struct ipsec_test_flags flags;
10894 
10895 	memset(&flags, 0, sizeof(flags));
10896 
10897 	flags.ipv6 = false;
10898 	flags.transport = true;
10899 
10900 	return test_ipsec_proto_all(&flags);
10901 }
10902 
10903 static int
10904 test_ipsec_proto_transport_l4_csum(void)
10905 {
10906 	struct ipsec_test_flags flags = {
10907 		.l4_csum = true,
10908 		.transport = true,
10909 	};
10910 
10911 	return test_ipsec_proto_all(&flags);
10912 }
10913 
10914 static int
10915 test_ipsec_proto_stats(void)
10916 {
10917 	struct ipsec_test_flags flags;
10918 
10919 	memset(&flags, 0, sizeof(flags));
10920 
10921 	flags.stats_success = true;
10922 
10923 	return test_ipsec_proto_all(&flags);
10924 }
10925 
10926 static int
10927 test_ipsec_proto_pkt_fragment(void)
10928 {
10929 	struct ipsec_test_flags flags;
10930 
10931 	memset(&flags, 0, sizeof(flags));
10932 
10933 	flags.fragment = true;
10934 
10935 	return test_ipsec_proto_all(&flags);
10936 
10937 }
10938 
10939 static int
10940 test_ipsec_proto_copy_df_inner_0(void)
10941 {
10942 	struct ipsec_test_flags flags;
10943 
10944 	memset(&flags, 0, sizeof(flags));
10945 
10946 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10947 
10948 	return test_ipsec_proto_all(&flags);
10949 }
10950 
10951 static int
10952 test_ipsec_proto_copy_df_inner_1(void)
10953 {
10954 	struct ipsec_test_flags flags;
10955 
10956 	memset(&flags, 0, sizeof(flags));
10957 
10958 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10959 
10960 	return test_ipsec_proto_all(&flags);
10961 }
10962 
10963 static int
10964 test_ipsec_proto_set_df_0_inner_1(void)
10965 {
10966 	struct ipsec_test_flags flags;
10967 
10968 	memset(&flags, 0, sizeof(flags));
10969 
10970 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10971 
10972 	return test_ipsec_proto_all(&flags);
10973 }
10974 
10975 static int
10976 test_ipsec_proto_set_df_1_inner_0(void)
10977 {
10978 	struct ipsec_test_flags flags;
10979 
10980 	memset(&flags, 0, sizeof(flags));
10981 
10982 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10983 
10984 	return test_ipsec_proto_all(&flags);
10985 }
10986 
10987 static int
10988 test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10989 {
10990 	struct ipsec_test_flags flags;
10991 
10992 	memset(&flags, 0, sizeof(flags));
10993 
10994 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10995 
10996 	return test_ipsec_proto_all(&flags);
10997 }
10998 
10999 static int
11000 test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11001 {
11002 	struct ipsec_test_flags flags;
11003 
11004 	memset(&flags, 0, sizeof(flags));
11005 
11006 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11007 
11008 	return test_ipsec_proto_all(&flags);
11009 }
11010 
11011 static int
11012 test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11013 {
11014 	struct ipsec_test_flags flags;
11015 
11016 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11017 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11018 		return TEST_SKIPPED;
11019 
11020 	memset(&flags, 0, sizeof(flags));
11021 
11022 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11023 
11024 	return test_ipsec_proto_all(&flags);
11025 }
11026 
11027 static int
11028 test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11029 {
11030 	struct ipsec_test_flags flags;
11031 
11032 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11033 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11034 		return TEST_SKIPPED;
11035 
11036 	memset(&flags, 0, sizeof(flags));
11037 
11038 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11039 
11040 	return test_ipsec_proto_all(&flags);
11041 }
11042 
11043 static int
11044 test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11045 {
11046 	struct ipsec_test_flags flags;
11047 
11048 	memset(&flags, 0, sizeof(flags));
11049 
11050 	flags.ipv6 = true;
11051 	flags.tunnel_ipv6 = true;
11052 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11053 
11054 	return test_ipsec_proto_all(&flags);
11055 }
11056 
11057 static int
11058 test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11059 {
11060 	struct ipsec_test_flags flags;
11061 
11062 	memset(&flags, 0, sizeof(flags));
11063 
11064 	flags.ipv6 = true;
11065 	flags.tunnel_ipv6 = true;
11066 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11067 
11068 	return test_ipsec_proto_all(&flags);
11069 }
11070 
11071 static int
11072 test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11073 {
11074 	struct ipsec_test_flags flags;
11075 
11076 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11077 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11078 		return TEST_SKIPPED;
11079 
11080 	memset(&flags, 0, sizeof(flags));
11081 
11082 	flags.ipv6 = true;
11083 	flags.tunnel_ipv6 = true;
11084 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11085 
11086 	return test_ipsec_proto_all(&flags);
11087 }
11088 
11089 static int
11090 test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11091 {
11092 	struct ipsec_test_flags flags;
11093 
11094 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11095 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11096 		return TEST_SKIPPED;
11097 
11098 	memset(&flags, 0, sizeof(flags));
11099 
11100 	flags.ipv6 = true;
11101 	flags.tunnel_ipv6 = true;
11102 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11103 
11104 	return test_ipsec_proto_all(&flags);
11105 }
11106 
11107 static int
11108 test_ipsec_proto_sgl(void)
11109 {
11110 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11111 	struct rte_cryptodev_info dev_info;
11112 
11113 	struct ipsec_test_flags flags = {
11114 		.nb_segs_in_mbuf = 5
11115 	};
11116 
11117 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11118 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11119 		printf("Device doesn't support in-place scatter-gather. "
11120 				"Test Skipped.\n");
11121 		return TEST_SKIPPED;
11122 	}
11123 
11124 	return test_ipsec_proto_all(&flags);
11125 }
11126 
11127 static int
11128 test_ipsec_proto_sgl_ext_mbuf(void)
11129 {
11130 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11131 	struct rte_cryptodev_info dev_info;
11132 
11133 	struct ipsec_test_flags flags = {
11134 		.nb_segs_in_mbuf = 5,
11135 		.use_ext_mbuf = 1
11136 	};
11137 
11138 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11139 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11140 		printf("Device doesn't support in-place scatter-gather. "
11141 				"Test Skipped.\n");
11142 		return TEST_SKIPPED;
11143 	}
11144 
11145 	return test_ipsec_proto_all(&flags);
11146 }
11147 
11148 static int
11149 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11150 		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11151 		      uint64_t winsz)
11152 {
11153 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11154 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11155 	struct ipsec_test_flags flags;
11156 	uint32_t i = 0, ret = 0;
11157 
11158 	if (nb_pkts == 0)
11159 		return TEST_FAILED;
11160 
11161 	memset(&flags, 0, sizeof(flags));
11162 	flags.antireplay = true;
11163 
11164 	for (i = 0; i < nb_pkts; i++) {
11165 		memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11166 		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11167 		td_outb[i].ipsec_xform.replay_win_sz = winsz;
11168 		td_outb[i].ipsec_xform.options.esn = esn_en;
11169 	}
11170 
11171 	for (i = 0; i < nb_pkts; i++)
11172 		td_outb[i].ipsec_xform.esn.value = esn[i];
11173 
11174 	ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11175 				       &flags);
11176 	if (ret != TEST_SUCCESS)
11177 		return ret;
11178 
11179 	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11180 
11181 	for (i = 0; i < nb_pkts; i++) {
11182 		td_inb[i].ipsec_xform.options.esn = esn_en;
11183 		/* Set antireplay flag for packets to be dropped */
11184 		td_inb[i].ar_packet = replayed_pkt[i];
11185 	}
11186 
11187 	ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11188 				       &flags);
11189 
11190 	return ret;
11191 }
11192 
11193 static int
11194 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11195 {
11196 
11197 	uint32_t nb_pkts = 5;
11198 	bool replayed_pkt[5];
11199 	uint64_t esn[5];
11200 
11201 	/* 1. Advance the TOP of the window to WS * 2 */
11202 	esn[0] = winsz * 2;
11203 	/* 2. Test sequence number within the new window(WS + 1) */
11204 	esn[1] = winsz + 1;
11205 	/* 3. Test sequence number less than the window BOTTOM */
11206 	esn[2] = winsz;
11207 	/* 4. Test sequence number in the middle of the window */
11208 	esn[3] = winsz + (winsz / 2);
11209 	/* 5. Test replay of the packet in the middle of the window */
11210 	esn[4] = winsz + (winsz / 2);
11211 
11212 	replayed_pkt[0] = false;
11213 	replayed_pkt[1] = false;
11214 	replayed_pkt[2] = true;
11215 	replayed_pkt[3] = false;
11216 	replayed_pkt[4] = true;
11217 
11218 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11219 				     false, winsz);
11220 }
11221 
11222 static int
11223 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11224 {
11225 	return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11226 }
11227 
11228 static int
11229 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11230 {
11231 	return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11232 }
11233 
11234 static int
11235 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11236 {
11237 	return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11238 }
11239 
11240 static int
11241 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11242 {
11243 
11244 	uint32_t nb_pkts = 7;
11245 	bool replayed_pkt[7];
11246 	uint64_t esn[7];
11247 
11248 	/* Set the initial sequence number */
11249 	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11250 	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11251 	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11252 	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11253 	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11254 	/* 3. Test with sequence number within window (1<<32 - 1) */
11255 	esn[3] = (uint64_t)((1ULL << 32) - 1);
11256 	/* 4. Test with sequence number within window (1<<32 - 1) */
11257 	esn[4] = (uint64_t)(1ULL << 32);
11258 	/* 5. Test with duplicate sequence number within
11259 	 * new window (1<<32 - 1)
11260 	 */
11261 	esn[5] = (uint64_t)((1ULL << 32) - 1);
11262 	/* 6. Test with duplicate sequence number within new window (1<<32) */
11263 	esn[6] = (uint64_t)(1ULL << 32);
11264 
11265 	replayed_pkt[0] = false;
11266 	replayed_pkt[1] = false;
11267 	replayed_pkt[2] = false;
11268 	replayed_pkt[3] = false;
11269 	replayed_pkt[4] = false;
11270 	replayed_pkt[5] = true;
11271 	replayed_pkt[6] = true;
11272 
11273 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11274 				     true, winsz);
11275 }
11276 
11277 static int
11278 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11279 {
11280 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11281 }
11282 
11283 static int
11284 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11285 {
11286 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11287 }
11288 
11289 static int
11290 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11291 {
11292 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11293 }
11294 
11295 static int
11296 test_PDCP_PROTO_all(void)
11297 {
11298 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11299 	struct crypto_unittest_params *ut_params = &unittest_params;
11300 	struct rte_cryptodev_info dev_info;
11301 	int status;
11302 
11303 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11304 	uint64_t feat_flags = dev_info.feature_flags;
11305 
11306 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11307 		return TEST_SKIPPED;
11308 
11309 	/* Set action type */
11310 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11311 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11312 		gbl_action_type;
11313 
11314 	if (security_proto_supported(ut_params->type,
11315 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
11316 		return TEST_SKIPPED;
11317 
11318 	status = test_PDCP_PROTO_cplane_encap_all();
11319 	status += test_PDCP_PROTO_cplane_decap_all();
11320 	status += test_PDCP_PROTO_uplane_encap_all();
11321 	status += test_PDCP_PROTO_uplane_decap_all();
11322 	status += test_PDCP_PROTO_SGL_in_place_32B();
11323 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
11324 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
11325 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
11326 	status += test_PDCP_SDAP_PROTO_encap_all();
11327 	status += test_PDCP_SDAP_PROTO_decap_all();
11328 	status += test_PDCP_PROTO_short_mac();
11329 
11330 	if (status)
11331 		return TEST_FAILED;
11332 	else
11333 		return TEST_SUCCESS;
11334 }
11335 
11336 static int
11337 test_ipsec_proto_ipv4_ttl_decrement(void)
11338 {
11339 	struct ipsec_test_flags flags = {
11340 		.dec_ttl_or_hop_limit = true
11341 	};
11342 
11343 	return test_ipsec_proto_all(&flags);
11344 }
11345 
11346 static int
11347 test_ipsec_proto_ipv6_hop_limit_decrement(void)
11348 {
11349 	struct ipsec_test_flags flags = {
11350 		.ipv6 = true,
11351 		.dec_ttl_or_hop_limit = true
11352 	};
11353 
11354 	return test_ipsec_proto_all(&flags);
11355 }
11356 
11357 static int
11358 test_docsis_proto_uplink(const void *data)
11359 {
11360 	const struct docsis_test_data *d_td = data;
11361 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11362 	struct crypto_unittest_params *ut_params = &unittest_params;
11363 	uint8_t *plaintext = NULL;
11364 	uint8_t *ciphertext = NULL;
11365 	uint8_t *iv_ptr;
11366 	int32_t cipher_len, crc_len;
11367 	uint32_t crc_data_len;
11368 	int ret = TEST_SUCCESS;
11369 
11370 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11371 
11372 	/* Verify the capabilities */
11373 	struct rte_security_capability_idx sec_cap_idx;
11374 	const struct rte_security_capability *sec_cap;
11375 	const struct rte_cryptodev_capabilities *crypto_cap;
11376 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11377 	int j = 0;
11378 
11379 	/* Set action type */
11380 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11381 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11382 		gbl_action_type;
11383 
11384 	if (security_proto_supported(ut_params->type,
11385 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11386 		return TEST_SKIPPED;
11387 
11388 	sec_cap_idx.action = ut_params->type;
11389 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11390 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11391 
11392 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11393 	if (sec_cap == NULL)
11394 		return TEST_SKIPPED;
11395 
11396 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11397 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11398 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11399 				crypto_cap->sym.xform_type ==
11400 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11401 				crypto_cap->sym.cipher.algo ==
11402 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11403 			sym_cap = &crypto_cap->sym;
11404 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11405 						d_td->key.len,
11406 						d_td->iv.len) == 0)
11407 				break;
11408 		}
11409 	}
11410 
11411 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11412 		return TEST_SKIPPED;
11413 
11414 	/* Setup source mbuf payload */
11415 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11416 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11417 			rte_pktmbuf_tailroom(ut_params->ibuf));
11418 
11419 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11420 			d_td->ciphertext.len);
11421 
11422 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11423 
11424 	/* Setup cipher session parameters */
11425 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11426 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11427 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11428 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11429 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11430 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11431 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11432 	ut_params->cipher_xform.next = NULL;
11433 
11434 	/* Setup DOCSIS session parameters */
11435 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11436 
11437 	struct rte_security_session_conf sess_conf = {
11438 		.action_type = ut_params->type,
11439 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11440 		.docsis = ut_params->docsis_xform,
11441 		.crypto_xform = &ut_params->cipher_xform,
11442 	};
11443 
11444 	/* Create security session */
11445 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11446 					ts_params->session_mpool);
11447 
11448 	if (!ut_params->sec_session) {
11449 		printf("Test function %s line %u: failed to allocate session\n",
11450 			__func__, __LINE__);
11451 		ret = TEST_FAILED;
11452 		goto on_err;
11453 	}
11454 
11455 	/* Generate crypto op data structure */
11456 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11457 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11458 	if (!ut_params->op) {
11459 		printf("Test function %s line %u: failed to allocate symmetric "
11460 			"crypto operation\n", __func__, __LINE__);
11461 		ret = TEST_FAILED;
11462 		goto on_err;
11463 	}
11464 
11465 	/* Setup CRC operation parameters */
11466 	crc_len = d_td->ciphertext.no_crc == false ?
11467 			(d_td->ciphertext.len -
11468 				d_td->ciphertext.crc_offset -
11469 				RTE_ETHER_CRC_LEN) :
11470 			0;
11471 	crc_len = crc_len > 0 ? crc_len : 0;
11472 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11473 	ut_params->op->sym->auth.data.length = crc_len;
11474 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11475 
11476 	/* Setup cipher operation parameters */
11477 	cipher_len = d_td->ciphertext.no_cipher == false ?
11478 			(d_td->ciphertext.len -
11479 				d_td->ciphertext.cipher_offset) :
11480 			0;
11481 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11482 	ut_params->op->sym->cipher.data.length = cipher_len;
11483 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11484 
11485 	/* Setup cipher IV */
11486 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11487 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11488 
11489 	/* Attach session to operation */
11490 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11491 
11492 	/* Set crypto operation mbufs */
11493 	ut_params->op->sym->m_src = ut_params->ibuf;
11494 	ut_params->op->sym->m_dst = NULL;
11495 
11496 	/* Process crypto operation */
11497 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11498 			NULL) {
11499 		printf("Test function %s line %u: failed to process security "
11500 			"crypto op\n", __func__, __LINE__);
11501 		ret = TEST_FAILED;
11502 		goto on_err;
11503 	}
11504 
11505 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11506 		printf("Test function %s line %u: failed to process crypto op\n",
11507 			__func__, __LINE__);
11508 		ret = TEST_FAILED;
11509 		goto on_err;
11510 	}
11511 
11512 	/* Validate plaintext */
11513 	plaintext = ciphertext;
11514 
11515 	if (memcmp(plaintext, d_td->plaintext.data,
11516 			d_td->plaintext.len - crc_data_len)) {
11517 		printf("Test function %s line %u: plaintext not as expected\n",
11518 			__func__, __LINE__);
11519 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
11520 				d_td->plaintext.len);
11521 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11522 		ret = TEST_FAILED;
11523 		goto on_err;
11524 	}
11525 
11526 on_err:
11527 	rte_crypto_op_free(ut_params->op);
11528 	ut_params->op = NULL;
11529 
11530 	if (ut_params->sec_session)
11531 		rte_security_session_destroy(ctx, ut_params->sec_session);
11532 	ut_params->sec_session = NULL;
11533 
11534 	rte_pktmbuf_free(ut_params->ibuf);
11535 	ut_params->ibuf = NULL;
11536 
11537 	return ret;
11538 }
11539 
11540 static int
11541 test_docsis_proto_downlink(const void *data)
11542 {
11543 	const struct docsis_test_data *d_td = data;
11544 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11545 	struct crypto_unittest_params *ut_params = &unittest_params;
11546 	uint8_t *plaintext = NULL;
11547 	uint8_t *ciphertext = NULL;
11548 	uint8_t *iv_ptr;
11549 	int32_t cipher_len, crc_len;
11550 	int ret = TEST_SUCCESS;
11551 
11552 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11553 
11554 	/* Verify the capabilities */
11555 	struct rte_security_capability_idx sec_cap_idx;
11556 	const struct rte_security_capability *sec_cap;
11557 	const struct rte_cryptodev_capabilities *crypto_cap;
11558 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11559 	int j = 0;
11560 
11561 	/* Set action type */
11562 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11563 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11564 		gbl_action_type;
11565 
11566 	if (security_proto_supported(ut_params->type,
11567 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11568 		return TEST_SKIPPED;
11569 
11570 	sec_cap_idx.action = ut_params->type;
11571 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11572 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11573 
11574 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11575 	if (sec_cap == NULL)
11576 		return TEST_SKIPPED;
11577 
11578 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11579 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11580 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11581 				crypto_cap->sym.xform_type ==
11582 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11583 				crypto_cap->sym.cipher.algo ==
11584 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11585 			sym_cap = &crypto_cap->sym;
11586 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11587 						d_td->key.len,
11588 						d_td->iv.len) == 0)
11589 				break;
11590 		}
11591 	}
11592 
11593 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11594 		return TEST_SKIPPED;
11595 
11596 	/* Setup source mbuf payload */
11597 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11598 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11599 			rte_pktmbuf_tailroom(ut_params->ibuf));
11600 
11601 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11602 			d_td->plaintext.len);
11603 
11604 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11605 
11606 	/* Setup cipher session parameters */
11607 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11608 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11609 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11610 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11611 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11612 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11613 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11614 	ut_params->cipher_xform.next = NULL;
11615 
11616 	/* Setup DOCSIS session parameters */
11617 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11618 
11619 	struct rte_security_session_conf sess_conf = {
11620 		.action_type = ut_params->type,
11621 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11622 		.docsis = ut_params->docsis_xform,
11623 		.crypto_xform = &ut_params->cipher_xform,
11624 	};
11625 
11626 	/* Create security session */
11627 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11628 					ts_params->session_mpool);
11629 
11630 	if (!ut_params->sec_session) {
11631 		printf("Test function %s line %u: failed to allocate session\n",
11632 			__func__, __LINE__);
11633 		ret = TEST_FAILED;
11634 		goto on_err;
11635 	}
11636 
11637 	/* Generate crypto op data structure */
11638 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11639 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11640 	if (!ut_params->op) {
11641 		printf("Test function %s line %u: failed to allocate symmetric "
11642 			"crypto operation\n", __func__, __LINE__);
11643 		ret = TEST_FAILED;
11644 		goto on_err;
11645 	}
11646 
11647 	/* Setup CRC operation parameters */
11648 	crc_len = d_td->plaintext.no_crc == false ?
11649 			(d_td->plaintext.len -
11650 				d_td->plaintext.crc_offset -
11651 				RTE_ETHER_CRC_LEN) :
11652 			0;
11653 	crc_len = crc_len > 0 ? crc_len : 0;
11654 	ut_params->op->sym->auth.data.length = crc_len;
11655 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11656 
11657 	/* Setup cipher operation parameters */
11658 	cipher_len = d_td->plaintext.no_cipher == false ?
11659 			(d_td->plaintext.len -
11660 				d_td->plaintext.cipher_offset) :
11661 			0;
11662 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11663 	ut_params->op->sym->cipher.data.length = cipher_len;
11664 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11665 
11666 	/* Setup cipher IV */
11667 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11668 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11669 
11670 	/* Attach session to operation */
11671 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11672 
11673 	/* Set crypto operation mbufs */
11674 	ut_params->op->sym->m_src = ut_params->ibuf;
11675 	ut_params->op->sym->m_dst = NULL;
11676 
11677 	/* Process crypto operation */
11678 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11679 			NULL) {
11680 		printf("Test function %s line %u: failed to process crypto op\n",
11681 			__func__, __LINE__);
11682 		ret = TEST_FAILED;
11683 		goto on_err;
11684 	}
11685 
11686 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11687 		printf("Test function %s line %u: crypto op processing failed\n",
11688 			__func__, __LINE__);
11689 		ret = TEST_FAILED;
11690 		goto on_err;
11691 	}
11692 
11693 	/* Validate ciphertext */
11694 	ciphertext = plaintext;
11695 
11696 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11697 		printf("Test function %s line %u: plaintext not as expected\n",
11698 			__func__, __LINE__);
11699 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11700 				d_td->ciphertext.len);
11701 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11702 		ret = TEST_FAILED;
11703 		goto on_err;
11704 	}
11705 
11706 on_err:
11707 	rte_crypto_op_free(ut_params->op);
11708 	ut_params->op = NULL;
11709 
11710 	if (ut_params->sec_session)
11711 		rte_security_session_destroy(ctx, ut_params->sec_session);
11712 	ut_params->sec_session = NULL;
11713 
11714 	rte_pktmbuf_free(ut_params->ibuf);
11715 	ut_params->ibuf = NULL;
11716 
11717 	return ret;
11718 }
11719 
11720 static void
11721 test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11722 				 struct rte_security_tls_record_xform *tls_record_xform)
11723 {
11724 	unsigned int imp_nonce_len;
11725 	uint8_t *imp_nonce;
11726 
11727 	switch (tls_record_xform->ver) {
11728 	case RTE_SECURITY_VERSION_TLS_1_2:
11729 		imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11730 		imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11731 		break;
11732 	case RTE_SECURITY_VERSION_DTLS_1_2:
11733 		imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11734 		imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11735 		break;
11736 	case RTE_SECURITY_VERSION_TLS_1_3:
11737 		imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11738 		imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11739 		break;
11740 	default:
11741 		return;
11742 	}
11743 
11744 	imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11745 	memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11746 }
11747 
11748 static int
11749 test_tls_record_proto_process(const struct tls_record_test_data td[],
11750 			      struct tls_record_test_data res_d[], int nb_td, bool silent,
11751 			      const struct tls_record_test_flags *flags)
11752 {
11753 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11754 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11755 	struct crypto_unittest_params *ut_params = &unittest_params;
11756 	struct rte_security_tls_record_xform tls_record_xform;
11757 	struct rte_security_capability_idx sec_cap_idx;
11758 	const struct rte_security_capability *sec_cap;
11759 	struct tls_record_test_data *res_d_tmp = NULL;
11760 	enum rte_security_tls_sess_type sess_type;
11761 	uint8_t dev_id = ts_params->valid_devs[0];
11762 	struct rte_security_ctx *ctx;
11763 	int i, ret = TEST_SUCCESS;
11764 
11765 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11766 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11767 
11768 	/* Use first test data to create session */
11769 
11770 	/* Copy TLS record xform */
11771 	memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11772 
11773 	sess_type = tls_record_xform.type;
11774 
11775 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
11776 
11777 	sec_cap_idx.action = ut_params->type;
11778 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11779 	sec_cap_idx.tls_record.type = tls_record_xform.type;
11780 	sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11781 
11782 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11783 	if (sec_cap == NULL)
11784 		return TEST_SKIPPED;
11785 
11786 	/* Copy cipher session parameters */
11787 	if (td[0].aead) {
11788 		memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11789 		ut_params->aead_xform.aead.key.data = td[0].key.data;
11790 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11791 
11792 		/* Verify crypto capabilities */
11793 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11794 			if (!silent)
11795 				RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11796 			return TEST_SKIPPED;
11797 		}
11798 	} else {
11799 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
11800 		       sizeof(ut_params->cipher_xform));
11801 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
11802 		       sizeof(ut_params->auth_xform));
11803 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
11804 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11805 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
11806 
11807 		/* Verify crypto capabilities */
11808 
11809 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
11810 			if (!silent)
11811 				RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
11812 			return TEST_SKIPPED;
11813 		}
11814 
11815 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
11816 			if (!silent)
11817 				RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
11818 			return TEST_SKIPPED;
11819 		}
11820 	}
11821 
11822 	if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
11823 		return TEST_SKIPPED;
11824 
11825 	struct rte_security_session_conf sess_conf = {
11826 		.action_type = ut_params->type,
11827 		.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
11828 	};
11829 
11830 	if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
11831 	    (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
11832 		sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
11833 
11834 	if (td[0].aead)
11835 		test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
11836 
11837 	sess_conf.tls_record = tls_record_xform;
11838 
11839 	if (td[0].aead) {
11840 		sess_conf.crypto_xform = &ut_params->aead_xform;
11841 	} else {
11842 		if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
11843 			sess_conf.crypto_xform = &ut_params->cipher_xform;
11844 			ut_params->cipher_xform.next = &ut_params->auth_xform;
11845 		} else {
11846 			sess_conf.crypto_xform = &ut_params->auth_xform;
11847 			ut_params->auth_xform.next = &ut_params->cipher_xform;
11848 		}
11849 	}
11850 
11851 	/* Create security session */
11852 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11853 					ts_params->session_mpool);
11854 	if (ut_params->sec_session == NULL)
11855 		return TEST_SKIPPED;
11856 
11857 	for (i = 0; i < nb_td; i++) {
11858 		if (flags->ar_win_size &&
11859 			(sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
11860 			sess_conf.tls_record.dtls_1_2.seq_no =
11861 				td[i].tls_record_xform.dtls_1_2.seq_no;
11862 			ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
11863 			if (ret) {
11864 				printf("Could not update sequence number in session\n");
11865 				return TEST_SKIPPED;
11866 			}
11867 		}
11868 
11869 		/* Setup source mbuf payload */
11870 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, td[i].input_text.len,
11871 				nb_segs, 0);
11872 		pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
11873 
11874 		/* Generate crypto op data structure */
11875 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11876 						    RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11877 		if (ut_params->op == NULL) {
11878 			printf("Could not allocate crypto op");
11879 			ret = TEST_FAILED;
11880 			goto crypto_op_free;
11881 		}
11882 
11883 		/* Attach session to operation */
11884 		rte_security_attach_session(ut_params->op, ut_params->sec_session);
11885 
11886 		/* Set crypto operation mbufs */
11887 		ut_params->op->sym->m_src = ut_params->ibuf;
11888 		ut_params->op->sym->m_dst = NULL;
11889 		ut_params->op->param1.tls_record.content_type = td[i].app_type;
11890 
11891 		/* Copy IV in crypto operation when IV generation is disabled */
11892 		if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
11893 		    (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
11894 		    (tls_record_xform.options.iv_gen_disable == 1)) {
11895 			uint8_t *iv;
11896 			int len;
11897 
11898 			iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
11899 			if (td[i].aead)
11900 				len = td[i].xform.aead.aead.iv.length - 4;
11901 			else
11902 				len = td[i].xform.chain.cipher.cipher.iv.length;
11903 			memcpy(iv, td[i].iv.data, len);
11904 		}
11905 
11906 		/* Process crypto operation */
11907 		process_crypto_request(dev_id, ut_params->op);
11908 
11909 		ret = test_tls_record_status_check(ut_params->op, &td[i]);
11910 		if (ret != TEST_SUCCESS)
11911 			goto crypto_op_free;
11912 
11913 		if (res_d != NULL)
11914 			res_d_tmp = &res_d[i];
11915 
11916 		if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
11917 			ret = test_tls_record_post_process(ut_params->ibuf, &td[i], res_d_tmp,
11918 							   silent);
11919 			if (ret != TEST_SUCCESS)
11920 				goto crypto_op_free;
11921 		}
11922 
11923 		rte_crypto_op_free(ut_params->op);
11924 		ut_params->op = NULL;
11925 
11926 		rte_pktmbuf_free(ut_params->ibuf);
11927 		ut_params->ibuf = NULL;
11928 	}
11929 
11930 crypto_op_free:
11931 	rte_crypto_op_free(ut_params->op);
11932 	ut_params->op = NULL;
11933 
11934 	rte_pktmbuf_free(ut_params->ibuf);
11935 	ut_params->ibuf = NULL;
11936 
11937 	if (ut_params->sec_session)
11938 		rte_security_session_destroy(ctx, ut_params->sec_session);
11939 	ut_params->sec_session = NULL;
11940 
11941 	RTE_SET_USED(flags);
11942 
11943 	return ret;
11944 }
11945 
11946 static int
11947 test_tls_record_proto_known_vec(const void *test_data)
11948 {
11949 	struct tls_record_test_data td_write;
11950 	struct tls_record_test_flags flags;
11951 
11952 	memset(&flags, 0, sizeof(flags));
11953 
11954 	memcpy(&td_write, test_data, sizeof(td_write));
11955 
11956 	/* Disable IV gen to be able to test with known vectors */
11957 	td_write.tls_record_xform.options.iv_gen_disable = 1;
11958 
11959 	return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
11960 }
11961 
11962 static int
11963 test_tls_record_proto_known_vec_read(const void *test_data)
11964 {
11965 	const struct tls_record_test_data *td = test_data;
11966 	struct tls_record_test_flags flags;
11967 	struct tls_record_test_data td_inb;
11968 
11969 	memset(&flags, 0, sizeof(flags));
11970 
11971 	if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
11972 		test_tls_record_td_read_from_write(td, &td_inb);
11973 	else
11974 		memcpy(&td_inb, td, sizeof(td_inb));
11975 
11976 	return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
11977 }
11978 
11979 static int
11980 test_tls_record_proto_all(const struct tls_record_test_flags *flags)
11981 {
11982 	unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
11983 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
11984 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
11985 	int ret;
11986 
11987 	switch (flags->tls_version) {
11988 	case RTE_SECURITY_VERSION_TLS_1_2:
11989 		max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
11990 		break;
11991 	case RTE_SECURITY_VERSION_TLS_1_3:
11992 		max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
11993 		break;
11994 	case RTE_SECURITY_VERSION_DTLS_1_2:
11995 		max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
11996 		break;
11997 	default:
11998 		max_payload_len = 0;
11999 	}
12000 
12001 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12002 		payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12003 		if (flags->nb_segs_in_mbuf)
12004 			payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12005 
12006 		if (flags->zero_len)
12007 			payload_len = 0;
12008 again:
12009 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12010 						 flags, td_outb, nb_pkts, payload_len);
12011 		if (ret == TEST_SKIPPED)
12012 			continue;
12013 
12014 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12015 		if (ret == TEST_SKIPPED)
12016 			continue;
12017 
12018 		if (flags->zero_len &&
12019 		    ((flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12020 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12021 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE))) {
12022 			if (ret == TEST_SUCCESS)
12023 				return TEST_FAILED;
12024 			goto skip_decrypt;
12025 		} else if (ret == TEST_FAILED) {
12026 			return TEST_FAILED;
12027 		}
12028 
12029 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12030 
12031 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12032 		if (ret == TEST_SKIPPED)
12033 			continue;
12034 
12035 		if (flags->pkt_corruption) {
12036 			if (ret == TEST_SUCCESS)
12037 				return TEST_FAILED;
12038 		} else {
12039 			if (ret == TEST_FAILED)
12040 				return TEST_FAILED;
12041 		}
12042 
12043 skip_decrypt:
12044 		if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12045 			goto again;
12046 
12047 		if (flags->display_alg)
12048 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12049 
12050 		pass_cnt++;
12051 	}
12052 
12053 	if (pass_cnt > 0)
12054 		return TEST_SUCCESS;
12055 	else
12056 		return TEST_SKIPPED;
12057 }
12058 
12059 static int
12060 test_tls_1_2_record_proto_data_walkthrough(void)
12061 {
12062 	struct tls_record_test_flags flags;
12063 
12064 	memset(&flags, 0, sizeof(flags));
12065 
12066 	flags.data_walkthrough = true;
12067 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12068 
12069 	return test_tls_record_proto_all(&flags);
12070 }
12071 
12072 static int
12073 test_tls_1_2_record_proto_display_list(void)
12074 {
12075 	struct tls_record_test_flags flags;
12076 
12077 	memset(&flags, 0, sizeof(flags));
12078 
12079 	flags.display_alg = true;
12080 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12081 
12082 	return test_tls_record_proto_all(&flags);
12083 }
12084 
12085 static int
12086 test_tls_1_2_record_proto_sgl(void)
12087 {
12088 	struct tls_record_test_flags flags = {
12089 		.nb_segs_in_mbuf = 5,
12090 		.tls_version = RTE_SECURITY_VERSION_TLS_1_2
12091 	};
12092 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12093 	struct rte_cryptodev_info dev_info;
12094 
12095 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12096 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12097 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12098 		return TEST_SKIPPED;
12099 	}
12100 
12101 	return test_tls_record_proto_all(&flags);
12102 }
12103 
12104 static int
12105 test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12106 {
12107 	struct tls_record_test_flags flags = {
12108 		.nb_segs_in_mbuf = 5,
12109 		.tls_version = tls_version,
12110 		.data_walkthrough = true
12111 	};
12112 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12113 	struct rte_cryptodev_info dev_info;
12114 
12115 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12116 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12117 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12118 		return TEST_SKIPPED;
12119 	}
12120 
12121 	return test_tls_record_proto_all(&flags);
12122 }
12123 
12124 static int
12125 test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12126 {
12127 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12128 }
12129 
12130 static int
12131 test_tls_record_proto_corrupt_pkt(void)
12132 {
12133 	struct tls_record_test_flags flags = {
12134 		.pkt_corruption = 1
12135 	};
12136 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12137 	struct rte_cryptodev_info dev_info;
12138 
12139 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12140 
12141 	return test_tls_record_proto_all(&flags);
12142 }
12143 
12144 static int
12145 test_tls_record_proto_custom_content_type(void)
12146 {
12147 	struct tls_record_test_flags flags = {
12148 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12149 	};
12150 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12151 	struct rte_cryptodev_info dev_info;
12152 
12153 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12154 
12155 	return test_tls_record_proto_all(&flags);
12156 }
12157 
12158 static int
12159 test_tls_record_proto_zero_len(void)
12160 {
12161 	struct tls_record_test_flags flags = {
12162 		.zero_len = 1
12163 	};
12164 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12165 	struct rte_cryptodev_info dev_info;
12166 
12167 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12168 
12169 	return test_tls_record_proto_all(&flags);
12170 }
12171 
12172 static int
12173 test_tls_record_proto_zero_len_non_app(void)
12174 {
12175 	struct tls_record_test_flags flags = {
12176 		.zero_len = 1,
12177 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12178 	};
12179 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12180 	struct rte_cryptodev_info dev_info;
12181 
12182 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12183 
12184 	return test_tls_record_proto_all(&flags);
12185 }
12186 
12187 static int
12188 test_dtls_1_2_record_proto_data_walkthrough(void)
12189 {
12190 	struct tls_record_test_flags flags;
12191 
12192 	memset(&flags, 0, sizeof(flags));
12193 
12194 	flags.data_walkthrough = true;
12195 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12196 
12197 	return test_tls_record_proto_all(&flags);
12198 }
12199 
12200 static int
12201 test_dtls_1_2_record_proto_display_list(void)
12202 {
12203 	struct tls_record_test_flags flags;
12204 
12205 	memset(&flags, 0, sizeof(flags));
12206 
12207 	flags.display_alg = true;
12208 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12209 
12210 	return test_tls_record_proto_all(&flags);
12211 }
12212 
12213 static int
12214 test_dtls_pkt_replay(const uint64_t seq_no[],
12215 		      bool replayed_pkt[], uint32_t nb_pkts,
12216 		      struct tls_record_test_flags *flags)
12217 {
12218 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12219 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12220 	unsigned int i, idx, pass_cnt = 0;
12221 	int ret;
12222 
12223 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12224 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12225 						 flags, td_outb, nb_pkts, 0);
12226 		if (ret == TEST_SKIPPED)
12227 			continue;
12228 
12229 		for (idx = 0; idx < nb_pkts; idx++)
12230 			td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12231 
12232 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12233 		if (ret == TEST_SKIPPED)
12234 			continue;
12235 
12236 		if (ret == TEST_FAILED)
12237 			return TEST_FAILED;
12238 
12239 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12240 
12241 		for (idx = 0; idx < nb_pkts; idx++) {
12242 			td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12243 			/* Set antireplay flag for packets to be dropped */
12244 			td_inb[idx].ar_packet = replayed_pkt[idx];
12245 		}
12246 
12247 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12248 		if (ret == TEST_SKIPPED)
12249 			continue;
12250 
12251 		if (ret == TEST_FAILED)
12252 			return TEST_FAILED;
12253 
12254 		if (flags->display_alg)
12255 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12256 
12257 		pass_cnt++;
12258 	}
12259 
12260 	if (pass_cnt > 0)
12261 		return TEST_SUCCESS;
12262 	else
12263 		return TEST_SKIPPED;
12264 }
12265 
12266 static int
12267 test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12268 {
12269 	struct tls_record_test_flags flags;
12270 	uint32_t nb_pkts = 5;
12271 	bool replayed_pkt[5];
12272 	uint64_t seq_no[5];
12273 
12274 	memset(&flags, 0, sizeof(flags));
12275 
12276 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12277 	flags.ar_win_size = winsz;
12278 
12279 	/* 1. Advance the TOP of the window to WS * 2 */
12280 	seq_no[0] = winsz * 2;
12281 	/* 2. Test sequence number within the new window(WS + 1) */
12282 	seq_no[1] = winsz + 1;
12283 	/* 3. Test sequence number less than the window BOTTOM */
12284 	seq_no[2] = winsz;
12285 	/* 4. Test sequence number in the middle of the window */
12286 	seq_no[3] = winsz + (winsz / 2);
12287 	/* 5. Test replay of the packet in the middle of the window */
12288 	seq_no[4] = winsz + (winsz / 2);
12289 
12290 	replayed_pkt[0] = false;
12291 	replayed_pkt[1] = false;
12292 	replayed_pkt[2] = true;
12293 	replayed_pkt[3] = false;
12294 	replayed_pkt[4] = true;
12295 
12296 	return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12297 }
12298 
12299 static int
12300 test_dtls_1_2_record_proto_antireplay64(void)
12301 {
12302 	return test_dtls_1_2_record_proto_antireplay(64);
12303 }
12304 
12305 static int
12306 test_dtls_1_2_record_proto_antireplay128(void)
12307 {
12308 	return test_dtls_1_2_record_proto_antireplay(128);
12309 }
12310 
12311 static int
12312 test_dtls_1_2_record_proto_antireplay256(void)
12313 {
12314 	return test_dtls_1_2_record_proto_antireplay(256);
12315 }
12316 
12317 static int
12318 test_dtls_1_2_record_proto_antireplay512(void)
12319 {
12320 	return test_dtls_1_2_record_proto_antireplay(512);
12321 }
12322 
12323 static int
12324 test_dtls_1_2_record_proto_antireplay1024(void)
12325 {
12326 	return test_dtls_1_2_record_proto_antireplay(1024);
12327 }
12328 
12329 static int
12330 test_dtls_1_2_record_proto_antireplay2048(void)
12331 {
12332 	return test_dtls_1_2_record_proto_antireplay(2048);
12333 }
12334 
12335 static int
12336 test_dtls_1_2_record_proto_antireplay4096(void)
12337 {
12338 	return test_dtls_1_2_record_proto_antireplay(4096);
12339 }
12340 
12341 static int
12342 test_dtls_1_2_record_proto_sgl(void)
12343 {
12344 	struct tls_record_test_flags flags = {
12345 		.nb_segs_in_mbuf = 5,
12346 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12347 	};
12348 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12349 	struct rte_cryptodev_info dev_info;
12350 
12351 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12352 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12353 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12354 		return TEST_SKIPPED;
12355 	}
12356 
12357 	return test_tls_record_proto_all(&flags);
12358 }
12359 
12360 static int
12361 test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12362 {
12363 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12364 }
12365 
12366 static int
12367 test_dtls_1_2_record_proto_corrupt_pkt(void)
12368 {
12369 	struct tls_record_test_flags flags = {
12370 		.pkt_corruption = 1,
12371 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12372 	};
12373 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12374 	struct rte_cryptodev_info dev_info;
12375 
12376 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12377 
12378 	return test_tls_record_proto_all(&flags);
12379 }
12380 
12381 static int
12382 test_dtls_1_2_record_proto_custom_content_type(void)
12383 {
12384 	struct tls_record_test_flags flags = {
12385 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12386 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12387 	};
12388 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12389 	struct rte_cryptodev_info dev_info;
12390 
12391 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12392 
12393 	return test_tls_record_proto_all(&flags);
12394 }
12395 
12396 static int
12397 test_dtls_1_2_record_proto_zero_len(void)
12398 {
12399 	struct tls_record_test_flags flags = {
12400 		.zero_len = 1,
12401 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12402 	};
12403 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12404 	struct rte_cryptodev_info dev_info;
12405 
12406 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12407 
12408 	return test_tls_record_proto_all(&flags);
12409 }
12410 
12411 static int
12412 test_dtls_1_2_record_proto_zero_len_non_app(void)
12413 {
12414 	struct tls_record_test_flags flags = {
12415 		.zero_len = 1,
12416 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12417 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12418 	};
12419 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12420 	struct rte_cryptodev_info dev_info;
12421 
12422 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12423 
12424 	return test_tls_record_proto_all(&flags);
12425 }
12426 
12427 static int
12428 test_tls_1_3_record_proto_corrupt_pkt(void)
12429 {
12430 	struct tls_record_test_flags flags = {
12431 		.pkt_corruption = 1,
12432 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12433 	};
12434 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12435 	struct rte_cryptodev_info dev_info;
12436 
12437 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12438 
12439 	return test_tls_record_proto_all(&flags);
12440 }
12441 #endif
12442 
12443 static int
12444 test_AES_GCM_authenticated_encryption_test_case_1(void)
12445 {
12446 	return test_authenticated_encryption(&gcm_test_case_1);
12447 }
12448 
12449 static int
12450 test_AES_GCM_authenticated_encryption_test_case_2(void)
12451 {
12452 	return test_authenticated_encryption(&gcm_test_case_2);
12453 }
12454 
12455 static int
12456 test_AES_GCM_authenticated_encryption_test_case_3(void)
12457 {
12458 	return test_authenticated_encryption(&gcm_test_case_3);
12459 }
12460 
12461 static int
12462 test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
12463 {
12464 	return test_authenticated_encryption_helper(&gcm_test_case_3, true);
12465 }
12466 
12467 static int
12468 test_AES_GCM_authenticated_encryption_test_case_4(void)
12469 {
12470 	return test_authenticated_encryption(&gcm_test_case_4);
12471 }
12472 
12473 static int
12474 test_AES_GCM_authenticated_encryption_test_case_5(void)
12475 {
12476 	return test_authenticated_encryption(&gcm_test_case_5);
12477 }
12478 
12479 static int
12480 test_AES_GCM_authenticated_encryption_test_case_6(void)
12481 {
12482 	return test_authenticated_encryption(&gcm_test_case_6);
12483 }
12484 
12485 static int
12486 test_AES_GCM_authenticated_encryption_test_case_7(void)
12487 {
12488 	return test_authenticated_encryption(&gcm_test_case_7);
12489 }
12490 
12491 static int
12492 test_AES_GCM_authenticated_encryption_test_case_8(void)
12493 {
12494 	return test_authenticated_encryption(&gcm_test_case_8);
12495 }
12496 
12497 static int
12498 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
12499 {
12500 	return test_authenticated_encryption(&gcm_J0_test_case_1);
12501 }
12502 
12503 static int
12504 test_AES_GCM_auth_encryption_test_case_192_1(void)
12505 {
12506 	return test_authenticated_encryption(&gcm_test_case_192_1);
12507 }
12508 
12509 static int
12510 test_AES_GCM_auth_encryption_test_case_192_2(void)
12511 {
12512 	return test_authenticated_encryption(&gcm_test_case_192_2);
12513 }
12514 
12515 static int
12516 test_AES_GCM_auth_encryption_test_case_192_3(void)
12517 {
12518 	return test_authenticated_encryption(&gcm_test_case_192_3);
12519 }
12520 
12521 static int
12522 test_AES_GCM_auth_encryption_test_case_192_4(void)
12523 {
12524 	return test_authenticated_encryption(&gcm_test_case_192_4);
12525 }
12526 
12527 static int
12528 test_AES_GCM_auth_encryption_test_case_192_5(void)
12529 {
12530 	return test_authenticated_encryption(&gcm_test_case_192_5);
12531 }
12532 
12533 static int
12534 test_AES_GCM_auth_encryption_test_case_192_6(void)
12535 {
12536 	return test_authenticated_encryption(&gcm_test_case_192_6);
12537 }
12538 
12539 static int
12540 test_AES_GCM_auth_encryption_test_case_192_7(void)
12541 {
12542 	return test_authenticated_encryption(&gcm_test_case_192_7);
12543 }
12544 
12545 static int
12546 test_AES_GCM_auth_encryption_test_case_256_1(void)
12547 {
12548 	return test_authenticated_encryption(&gcm_test_case_256_1);
12549 }
12550 
12551 static int
12552 test_AES_GCM_auth_encryption_test_case_256_2(void)
12553 {
12554 	return test_authenticated_encryption(&gcm_test_case_256_2);
12555 }
12556 
12557 static int
12558 test_AES_GCM_auth_encryption_test_case_256_3(void)
12559 {
12560 	return test_authenticated_encryption(&gcm_test_case_256_3);
12561 }
12562 
12563 static int
12564 test_AES_GCM_auth_encryption_test_case_256_4(void)
12565 {
12566 	return test_authenticated_encryption(&gcm_test_case_256_4);
12567 }
12568 
12569 static int
12570 test_AES_GCM_auth_encryption_test_case_256_5(void)
12571 {
12572 	return test_authenticated_encryption(&gcm_test_case_256_5);
12573 }
12574 
12575 static int
12576 test_AES_GCM_auth_encryption_test_case_256_6(void)
12577 {
12578 	return test_authenticated_encryption(&gcm_test_case_256_6);
12579 }
12580 
12581 static int
12582 test_AES_GCM_auth_encryption_test_case_256_7(void)
12583 {
12584 	return test_authenticated_encryption(&gcm_test_case_256_7);
12585 }
12586 
12587 static int
12588 test_AES_GCM_auth_encryption_test_case_aad_1(void)
12589 {
12590 	return test_authenticated_encryption(&gcm_test_case_aad_1);
12591 }
12592 
12593 static int
12594 test_AES_GCM_auth_encryption_test_case_aad_2(void)
12595 {
12596 	return test_authenticated_encryption(&gcm_test_case_aad_2);
12597 }
12598 
12599 static int
12600 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
12601 {
12602 	struct aead_test_data tdata;
12603 	int res;
12604 
12605 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12606 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12607 	tdata.iv.data[0] += 1;
12608 	res = test_authenticated_encryption(&tdata);
12609 	if (res == TEST_SKIPPED)
12610 		return res;
12611 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12612 	return TEST_SUCCESS;
12613 }
12614 
12615 static int
12616 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
12617 {
12618 	struct aead_test_data tdata;
12619 	int res;
12620 
12621 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12622 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12623 	tdata.plaintext.data[0] += 1;
12624 	res = test_authenticated_encryption(&tdata);
12625 	if (res == TEST_SKIPPED)
12626 		return res;
12627 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12628 	return TEST_SUCCESS;
12629 }
12630 
12631 static int
12632 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
12633 {
12634 	struct aead_test_data tdata;
12635 	int res;
12636 
12637 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12638 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12639 	tdata.ciphertext.data[0] += 1;
12640 	res = test_authenticated_encryption(&tdata);
12641 	if (res == TEST_SKIPPED)
12642 		return res;
12643 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12644 	return TEST_SUCCESS;
12645 }
12646 
12647 static int
12648 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
12649 {
12650 	struct aead_test_data tdata;
12651 	int res;
12652 
12653 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12654 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12655 	tdata.aad.len += 1;
12656 	res = test_authenticated_encryption(&tdata);
12657 	if (res == TEST_SKIPPED)
12658 		return res;
12659 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12660 	return TEST_SUCCESS;
12661 }
12662 
12663 static int
12664 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
12665 {
12666 	struct aead_test_data tdata;
12667 	uint8_t aad[gcm_test_case_7.aad.len];
12668 	int res;
12669 
12670 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12671 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12672 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12673 	aad[0] += 1;
12674 	tdata.aad.data = aad;
12675 	res = test_authenticated_encryption(&tdata);
12676 	if (res == TEST_SKIPPED)
12677 		return res;
12678 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12679 	return TEST_SUCCESS;
12680 }
12681 
12682 static int
12683 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
12684 {
12685 	struct aead_test_data tdata;
12686 	int res;
12687 
12688 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12689 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12690 	tdata.auth_tag.data[0] += 1;
12691 	res = test_authenticated_encryption(&tdata);
12692 	if (res == TEST_SKIPPED)
12693 		return res;
12694 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12695 	return TEST_SUCCESS;
12696 }
12697 
12698 static int
12699 test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
12700 {
12701 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12702 	struct crypto_unittest_params *ut_params = &unittest_params;
12703 
12704 	int retval;
12705 	uint8_t *plaintext;
12706 	uint32_t i;
12707 	struct rte_cryptodev_info dev_info;
12708 
12709 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12710 	uint64_t feat_flags = dev_info.feature_flags;
12711 
12712 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12713 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12714 		printf("Device doesn't support RAW data-path APIs.\n");
12715 		return TEST_SKIPPED;
12716 	}
12717 
12718 	/* Verify the capabilities */
12719 	struct rte_cryptodev_sym_capability_idx cap_idx;
12720 	const struct rte_cryptodev_symmetric_capability *capability;
12721 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12722 	cap_idx.algo.aead = tdata->algo;
12723 	capability = rte_cryptodev_sym_capability_get(
12724 			ts_params->valid_devs[0], &cap_idx);
12725 	if (capability == NULL)
12726 		return TEST_SKIPPED;
12727 	if (rte_cryptodev_sym_capability_check_aead(
12728 			capability, tdata->key.len, tdata->auth_tag.len,
12729 			tdata->aad.len, tdata->iv.len))
12730 		return TEST_SKIPPED;
12731 
12732 	/* Create AEAD session */
12733 	retval = create_aead_session(ts_params->valid_devs[0],
12734 			tdata->algo,
12735 			RTE_CRYPTO_AEAD_OP_DECRYPT,
12736 			tdata->key.data, tdata->key.len,
12737 			tdata->aad.len, tdata->auth_tag.len,
12738 			tdata->iv.len);
12739 	if (retval != TEST_SUCCESS)
12740 		return retval;
12741 
12742 	/* alloc mbuf and set payload */
12743 	if (tdata->aad.len > MBUF_SIZE) {
12744 		if (use_ext_mbuf) {
12745 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
12746 							  AEAD_TEXT_MAX_LENGTH,
12747 							  1 /* nb_segs */,
12748 							  NULL);
12749 		} else {
12750 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12751 		}
12752 		/* Populate full size of add data */
12753 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
12754 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
12755 	} else {
12756 		if (use_ext_mbuf) {
12757 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
12758 							  AEAD_TEXT_MAX_LENGTH,
12759 							  1 /* nb_segs */,
12760 							  NULL);
12761 		} else {
12762 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12763 		}
12764 	}
12765 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12766 			rte_pktmbuf_tailroom(ut_params->ibuf));
12767 
12768 	/* Create AEAD operation */
12769 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12770 	if (retval < 0)
12771 		return retval;
12772 
12773 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12774 
12775 	ut_params->op->sym->m_src = ut_params->ibuf;
12776 
12777 	/* Process crypto operation */
12778 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12779 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12780 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12781 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12782 					       0);
12783 		if (retval != TEST_SUCCESS)
12784 			return retval;
12785 	} else
12786 		TEST_ASSERT_NOT_NULL(
12787 			process_crypto_request(ts_params->valid_devs[0],
12788 			ut_params->op), "failed to process sym crypto op");
12789 
12790 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12791 			"crypto op processing failed");
12792 
12793 	if (ut_params->op->sym->m_dst)
12794 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
12795 				uint8_t *);
12796 	else
12797 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12798 				uint8_t *,
12799 				ut_params->op->sym->cipher.data.offset);
12800 
12801 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12802 
12803 	/* Validate obuf */
12804 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12805 			plaintext,
12806 			tdata->plaintext.data,
12807 			tdata->plaintext.len,
12808 			"Plaintext data not as expected");
12809 
12810 	TEST_ASSERT_EQUAL(ut_params->op->status,
12811 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12812 			"Authentication failed");
12813 
12814 	return 0;
12815 }
12816 
12817 static int
12818 test_authenticated_decryption(const struct aead_test_data *tdata)
12819 {
12820 	return test_authenticated_decryption_helper(tdata, false);
12821 }
12822 
12823 static int
12824 test_AES_GCM_authenticated_decryption_test_case_1(void)
12825 {
12826 	return test_authenticated_decryption(&gcm_test_case_1);
12827 }
12828 
12829 static int
12830 test_AES_GCM_authenticated_decryption_test_case_2(void)
12831 {
12832 	return test_authenticated_decryption(&gcm_test_case_2);
12833 }
12834 
12835 static int
12836 test_AES_GCM_authenticated_decryption_test_case_3(void)
12837 {
12838 	return test_authenticated_decryption(&gcm_test_case_3);
12839 }
12840 
12841 static int
12842 test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
12843 {
12844 	return test_authenticated_decryption_helper(&gcm_test_case_3, true);
12845 }
12846 
12847 static int
12848 test_AES_GCM_authenticated_decryption_test_case_4(void)
12849 {
12850 	return test_authenticated_decryption(&gcm_test_case_4);
12851 }
12852 
12853 static int
12854 test_AES_GCM_authenticated_decryption_test_case_5(void)
12855 {
12856 	return test_authenticated_decryption(&gcm_test_case_5);
12857 }
12858 
12859 static int
12860 test_AES_GCM_authenticated_decryption_test_case_6(void)
12861 {
12862 	return test_authenticated_decryption(&gcm_test_case_6);
12863 }
12864 
12865 static int
12866 test_AES_GCM_authenticated_decryption_test_case_7(void)
12867 {
12868 	return test_authenticated_decryption(&gcm_test_case_7);
12869 }
12870 
12871 static int
12872 test_AES_GCM_authenticated_decryption_test_case_8(void)
12873 {
12874 	return test_authenticated_decryption(&gcm_test_case_8);
12875 }
12876 
12877 static int
12878 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
12879 {
12880 	return test_authenticated_decryption(&gcm_J0_test_case_1);
12881 }
12882 
12883 static int
12884 test_AES_GCM_auth_decryption_test_case_192_1(void)
12885 {
12886 	return test_authenticated_decryption(&gcm_test_case_192_1);
12887 }
12888 
12889 static int
12890 test_AES_GCM_auth_decryption_test_case_192_2(void)
12891 {
12892 	return test_authenticated_decryption(&gcm_test_case_192_2);
12893 }
12894 
12895 static int
12896 test_AES_GCM_auth_decryption_test_case_192_3(void)
12897 {
12898 	return test_authenticated_decryption(&gcm_test_case_192_3);
12899 }
12900 
12901 static int
12902 test_AES_GCM_auth_decryption_test_case_192_4(void)
12903 {
12904 	return test_authenticated_decryption(&gcm_test_case_192_4);
12905 }
12906 
12907 static int
12908 test_AES_GCM_auth_decryption_test_case_192_5(void)
12909 {
12910 	return test_authenticated_decryption(&gcm_test_case_192_5);
12911 }
12912 
12913 static int
12914 test_AES_GCM_auth_decryption_test_case_192_6(void)
12915 {
12916 	return test_authenticated_decryption(&gcm_test_case_192_6);
12917 }
12918 
12919 static int
12920 test_AES_GCM_auth_decryption_test_case_192_7(void)
12921 {
12922 	return test_authenticated_decryption(&gcm_test_case_192_7);
12923 }
12924 
12925 static int
12926 test_AES_GCM_auth_decryption_test_case_256_1(void)
12927 {
12928 	return test_authenticated_decryption(&gcm_test_case_256_1);
12929 }
12930 
12931 static int
12932 test_AES_GCM_auth_decryption_test_case_256_2(void)
12933 {
12934 	return test_authenticated_decryption(&gcm_test_case_256_2);
12935 }
12936 
12937 static int
12938 test_AES_GCM_auth_decryption_test_case_256_3(void)
12939 {
12940 	return test_authenticated_decryption(&gcm_test_case_256_3);
12941 }
12942 
12943 static int
12944 test_AES_GCM_auth_decryption_test_case_256_4(void)
12945 {
12946 	return test_authenticated_decryption(&gcm_test_case_256_4);
12947 }
12948 
12949 static int
12950 test_AES_GCM_auth_decryption_test_case_256_5(void)
12951 {
12952 	return test_authenticated_decryption(&gcm_test_case_256_5);
12953 }
12954 
12955 static int
12956 test_AES_GCM_auth_decryption_test_case_256_6(void)
12957 {
12958 	return test_authenticated_decryption(&gcm_test_case_256_6);
12959 }
12960 
12961 static int
12962 test_AES_GCM_auth_decryption_test_case_256_7(void)
12963 {
12964 	return test_authenticated_decryption(&gcm_test_case_256_7);
12965 }
12966 
12967 static int
12968 test_AES_GCM_auth_decryption_test_case_256_8(void)
12969 {
12970 	return test_authenticated_decryption(&gcm_test_case_256_8);
12971 }
12972 
12973 static int
12974 test_AES_GCM_auth_encryption_test_case_256_8(void)
12975 {
12976 	return test_authenticated_encryption(&gcm_test_case_256_8);
12977 }
12978 
12979 static int
12980 test_AES_GCM_auth_decryption_test_case_aad_1(void)
12981 {
12982 	return test_authenticated_decryption(&gcm_test_case_aad_1);
12983 }
12984 
12985 static int
12986 test_AES_GCM_auth_decryption_test_case_aad_2(void)
12987 {
12988 	return test_authenticated_decryption(&gcm_test_case_aad_2);
12989 }
12990 
12991 static int
12992 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
12993 {
12994 	struct aead_test_data tdata;
12995 	int res;
12996 
12997 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12998 	tdata.iv.data[0] += 1;
12999 	res = test_authenticated_decryption(&tdata);
13000 	if (res == TEST_SKIPPED)
13001 		return res;
13002 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13003 	return TEST_SUCCESS;
13004 }
13005 
13006 static int
13007 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13008 {
13009 	struct aead_test_data tdata;
13010 	int res;
13011 
13012 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13013 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13014 	tdata.plaintext.data[0] += 1;
13015 	res = test_authenticated_decryption(&tdata);
13016 	if (res == TEST_SKIPPED)
13017 		return res;
13018 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13019 	return TEST_SUCCESS;
13020 }
13021 
13022 static int
13023 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13024 {
13025 	struct aead_test_data tdata;
13026 	int res;
13027 
13028 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13029 	tdata.ciphertext.data[0] += 1;
13030 	res = test_authenticated_decryption(&tdata);
13031 	if (res == TEST_SKIPPED)
13032 		return res;
13033 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13034 	return TEST_SUCCESS;
13035 }
13036 
13037 static int
13038 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13039 {
13040 	struct aead_test_data tdata;
13041 	int res;
13042 
13043 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13044 	tdata.aad.len += 1;
13045 	res = test_authenticated_decryption(&tdata);
13046 	if (res == TEST_SKIPPED)
13047 		return res;
13048 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13049 	return TEST_SUCCESS;
13050 }
13051 
13052 static int
13053 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13054 {
13055 	struct aead_test_data tdata;
13056 	uint8_t aad[gcm_test_case_7.aad.len];
13057 	int res;
13058 
13059 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13060 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13061 	aad[0] += 1;
13062 	tdata.aad.data = aad;
13063 	res = test_authenticated_decryption(&tdata);
13064 	if (res == TEST_SKIPPED)
13065 		return res;
13066 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13067 	return TEST_SUCCESS;
13068 }
13069 
13070 static int
13071 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13072 {
13073 	struct aead_test_data tdata;
13074 	int res;
13075 
13076 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13077 	tdata.auth_tag.data[0] += 1;
13078 	res = test_authenticated_decryption(&tdata);
13079 	if (res == TEST_SKIPPED)
13080 		return res;
13081 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13082 	return TEST_SUCCESS;
13083 }
13084 
13085 static int
13086 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13087 {
13088 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13089 	struct crypto_unittest_params *ut_params = &unittest_params;
13090 
13091 	int retval;
13092 	uint8_t *ciphertext, *auth_tag;
13093 	uint16_t plaintext_pad_len;
13094 	struct rte_cryptodev_info dev_info;
13095 
13096 	/* Verify the capabilities */
13097 	struct rte_cryptodev_sym_capability_idx cap_idx;
13098 	const struct rte_cryptodev_symmetric_capability *capability;
13099 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13100 	cap_idx.algo.aead = tdata->algo;
13101 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13102 	if (capability == NULL)
13103 		return TEST_SKIPPED;
13104 	if (rte_cryptodev_sym_capability_check_aead(
13105 		capability, tdata->key.len, tdata->auth_tag.len,
13106 		tdata->aad.len, tdata->iv.len))
13107 		return TEST_SKIPPED;
13108 
13109 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13110 	uint64_t feat_flags = dev_info.feature_flags;
13111 
13112 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13113 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13114 		return TEST_SKIPPED;
13115 
13116 	/* not supported with CPU crypto */
13117 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13118 		return TEST_SKIPPED;
13119 
13120 	/* Create AEAD session */
13121 	retval = create_aead_session(ts_params->valid_devs[0],
13122 			tdata->algo,
13123 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13124 			tdata->key.data, tdata->key.len,
13125 			tdata->aad.len, tdata->auth_tag.len,
13126 			tdata->iv.len);
13127 	if (retval < 0)
13128 		return retval;
13129 
13130 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13131 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13132 
13133 	/* clear mbuf payload */
13134 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13135 			rte_pktmbuf_tailroom(ut_params->ibuf));
13136 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13137 			rte_pktmbuf_tailroom(ut_params->obuf));
13138 
13139 	/* Create AEAD operation */
13140 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13141 	if (retval < 0)
13142 		return retval;
13143 
13144 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13145 
13146 	ut_params->op->sym->m_src = ut_params->ibuf;
13147 	ut_params->op->sym->m_dst = ut_params->obuf;
13148 
13149 	/* Process crypto operation */
13150 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13151 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13152 					       0);
13153 		if (retval != TEST_SUCCESS)
13154 			return retval;
13155 	} else
13156 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13157 			ut_params->op), "failed to process sym crypto op");
13158 
13159 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13160 			"crypto op processing failed");
13161 
13162 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13163 
13164 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13165 			ut_params->op->sym->cipher.data.offset);
13166 	auth_tag = ciphertext + plaintext_pad_len;
13167 
13168 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13169 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13170 
13171 	/* Validate obuf */
13172 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13173 			ciphertext,
13174 			tdata->ciphertext.data,
13175 			tdata->ciphertext.len,
13176 			"Ciphertext data not as expected");
13177 
13178 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13179 			auth_tag,
13180 			tdata->auth_tag.data,
13181 			tdata->auth_tag.len,
13182 			"Generated auth tag not as expected");
13183 
13184 	return 0;
13185 
13186 }
13187 
13188 static int
13189 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13190 {
13191 	return test_authenticated_encryption_oop(&gcm_test_case_5);
13192 }
13193 
13194 static int
13195 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13196 {
13197 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13198 	struct crypto_unittest_params *ut_params = &unittest_params;
13199 
13200 	int retval;
13201 	uint8_t *plaintext;
13202 	struct rte_cryptodev_info dev_info;
13203 
13204 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13205 	uint64_t feat_flags = dev_info.feature_flags;
13206 
13207 	/* Verify the capabilities */
13208 	struct rte_cryptodev_sym_capability_idx cap_idx;
13209 	const struct rte_cryptodev_symmetric_capability *capability;
13210 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13211 	cap_idx.algo.aead = tdata->algo;
13212 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13213 
13214 	if (capability == NULL)
13215 		return TEST_SKIPPED;
13216 
13217 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13218 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13219 		return TEST_SKIPPED;
13220 
13221 	/* not supported with CPU crypto and raw data-path APIs*/
13222 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13223 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
13224 		return TEST_SKIPPED;
13225 
13226 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13227 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13228 		printf("Device does not support RAW data-path APIs.\n");
13229 		return TEST_SKIPPED;
13230 	}
13231 
13232 	/* Create AEAD session */
13233 	retval = create_aead_session(ts_params->valid_devs[0],
13234 			tdata->algo,
13235 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13236 			tdata->key.data, tdata->key.len,
13237 			tdata->aad.len, tdata->auth_tag.len,
13238 			tdata->iv.len);
13239 	if (retval < 0)
13240 		return retval;
13241 
13242 	/* alloc mbuf and set payload */
13243 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13244 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13245 
13246 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13247 			rte_pktmbuf_tailroom(ut_params->ibuf));
13248 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13249 			rte_pktmbuf_tailroom(ut_params->obuf));
13250 
13251 	/* Create AEAD operation */
13252 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13253 	if (retval < 0)
13254 		return retval;
13255 
13256 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13257 
13258 	ut_params->op->sym->m_src = ut_params->ibuf;
13259 	ut_params->op->sym->m_dst = ut_params->obuf;
13260 
13261 	/* Process crypto operation */
13262 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13263 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13264 					       0);
13265 		if (retval != TEST_SUCCESS)
13266 			return retval;
13267 	} else
13268 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13269 			ut_params->op), "failed to process sym crypto op");
13270 
13271 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13272 			"crypto op processing failed");
13273 
13274 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13275 			ut_params->op->sym->cipher.data.offset);
13276 
13277 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13278 
13279 	/* Validate obuf */
13280 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13281 			plaintext,
13282 			tdata->plaintext.data,
13283 			tdata->plaintext.len,
13284 			"Plaintext data not as expected");
13285 
13286 	TEST_ASSERT_EQUAL(ut_params->op->status,
13287 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13288 			"Authentication failed");
13289 	return 0;
13290 }
13291 
13292 static int
13293 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
13294 {
13295 	return test_authenticated_decryption_oop(&gcm_test_case_5);
13296 }
13297 
13298 static int
13299 test_authenticated_encryption_sessionless(
13300 		const struct aead_test_data *tdata)
13301 {
13302 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13303 	struct crypto_unittest_params *ut_params = &unittest_params;
13304 
13305 	int retval;
13306 	uint8_t *ciphertext, *auth_tag;
13307 	uint16_t plaintext_pad_len;
13308 	uint8_t key[tdata->key.len + 1];
13309 	struct rte_cryptodev_info dev_info;
13310 
13311 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13312 	uint64_t feat_flags = dev_info.feature_flags;
13313 
13314 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13315 		printf("Device doesn't support Sessionless ops.\n");
13316 		return TEST_SKIPPED;
13317 	}
13318 
13319 	/* not supported with CPU crypto */
13320 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13321 		return TEST_SKIPPED;
13322 
13323 	/* Verify the capabilities */
13324 	struct rte_cryptodev_sym_capability_idx cap_idx;
13325 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13326 	cap_idx.algo.aead = tdata->algo;
13327 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13328 			&cap_idx) == NULL)
13329 		return TEST_SKIPPED;
13330 
13331 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13332 
13333 	/* clear mbuf payload */
13334 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13335 			rte_pktmbuf_tailroom(ut_params->ibuf));
13336 
13337 	/* Create AEAD operation */
13338 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13339 	if (retval < 0)
13340 		return retval;
13341 
13342 	/* Create GCM xform */
13343 	memcpy(key, tdata->key.data, tdata->key.len);
13344 	retval = create_aead_xform(ut_params->op,
13345 			tdata->algo,
13346 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13347 			key, tdata->key.len,
13348 			tdata->aad.len, tdata->auth_tag.len,
13349 			tdata->iv.len);
13350 	if (retval < 0)
13351 		return retval;
13352 
13353 	ut_params->op->sym->m_src = ut_params->ibuf;
13354 
13355 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13356 			RTE_CRYPTO_OP_SESSIONLESS,
13357 			"crypto op session type not sessionless");
13358 
13359 	/* Process crypto operation */
13360 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13361 			ut_params->op), "failed to process sym crypto op");
13362 
13363 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13364 
13365 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13366 			"crypto op status not success");
13367 
13368 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13369 
13370 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13371 			ut_params->op->sym->cipher.data.offset);
13372 	auth_tag = ciphertext + plaintext_pad_len;
13373 
13374 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13375 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13376 
13377 	/* Validate obuf */
13378 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13379 			ciphertext,
13380 			tdata->ciphertext.data,
13381 			tdata->ciphertext.len,
13382 			"Ciphertext data not as expected");
13383 
13384 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13385 			auth_tag,
13386 			tdata->auth_tag.data,
13387 			tdata->auth_tag.len,
13388 			"Generated auth tag not as expected");
13389 
13390 	return 0;
13391 
13392 }
13393 
13394 static int
13395 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
13396 {
13397 	return test_authenticated_encryption_sessionless(
13398 			&gcm_test_case_5);
13399 }
13400 
13401 static int
13402 test_authenticated_decryption_sessionless(
13403 		const struct aead_test_data *tdata)
13404 {
13405 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13406 	struct crypto_unittest_params *ut_params = &unittest_params;
13407 
13408 	int retval;
13409 	uint8_t *plaintext;
13410 	uint8_t key[tdata->key.len + 1];
13411 	struct rte_cryptodev_info dev_info;
13412 
13413 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13414 	uint64_t feat_flags = dev_info.feature_flags;
13415 
13416 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13417 		printf("Device doesn't support Sessionless ops.\n");
13418 		return TEST_SKIPPED;
13419 	}
13420 
13421 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13422 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13423 		printf("Device doesn't support RAW data-path APIs.\n");
13424 		return TEST_SKIPPED;
13425 	}
13426 
13427 	/* not supported with CPU crypto */
13428 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13429 		return TEST_SKIPPED;
13430 
13431 	/* Verify the capabilities */
13432 	struct rte_cryptodev_sym_capability_idx cap_idx;
13433 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13434 	cap_idx.algo.aead = tdata->algo;
13435 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13436 			&cap_idx) == NULL)
13437 		return TEST_SKIPPED;
13438 
13439 	/* alloc mbuf and set payload */
13440 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13441 
13442 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13443 			rte_pktmbuf_tailroom(ut_params->ibuf));
13444 
13445 	/* Create AEAD operation */
13446 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13447 	if (retval < 0)
13448 		return retval;
13449 
13450 	/* Create AEAD xform */
13451 	memcpy(key, tdata->key.data, tdata->key.len);
13452 	retval = create_aead_xform(ut_params->op,
13453 			tdata->algo,
13454 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13455 			key, tdata->key.len,
13456 			tdata->aad.len, tdata->auth_tag.len,
13457 			tdata->iv.len);
13458 	if (retval < 0)
13459 		return retval;
13460 
13461 	ut_params->op->sym->m_src = ut_params->ibuf;
13462 
13463 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13464 			RTE_CRYPTO_OP_SESSIONLESS,
13465 			"crypto op session type not sessionless");
13466 
13467 	/* Process crypto operation */
13468 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13469 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13470 					       0);
13471 		if (retval != TEST_SUCCESS)
13472 			return retval;
13473 	} else
13474 		TEST_ASSERT_NOT_NULL(process_crypto_request(
13475 			ts_params->valid_devs[0], ut_params->op),
13476 				"failed to process sym crypto op");
13477 
13478 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13479 
13480 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13481 			"crypto op status not success");
13482 
13483 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13484 			ut_params->op->sym->cipher.data.offset);
13485 
13486 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13487 
13488 	/* Validate obuf */
13489 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13490 			plaintext,
13491 			tdata->plaintext.data,
13492 			tdata->plaintext.len,
13493 			"Plaintext data not as expected");
13494 
13495 	TEST_ASSERT_EQUAL(ut_params->op->status,
13496 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13497 			"Authentication failed");
13498 	return 0;
13499 }
13500 
13501 static int
13502 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
13503 {
13504 	return test_authenticated_decryption_sessionless(
13505 			&gcm_test_case_5);
13506 }
13507 
13508 static int
13509 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
13510 {
13511 	return test_authenticated_encryption(&ccm_test_case_128_1);
13512 }
13513 
13514 static int
13515 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
13516 {
13517 	return test_authenticated_encryption(&ccm_test_case_128_2);
13518 }
13519 
13520 static int
13521 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
13522 {
13523 	return test_authenticated_encryption(&ccm_test_case_128_3);
13524 }
13525 
13526 static int
13527 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
13528 {
13529 	return test_authenticated_decryption(&ccm_test_case_128_1);
13530 }
13531 
13532 static int
13533 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
13534 {
13535 	return test_authenticated_decryption(&ccm_test_case_128_2);
13536 }
13537 
13538 static int
13539 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
13540 {
13541 	return test_authenticated_decryption(&ccm_test_case_128_3);
13542 }
13543 
13544 static int
13545 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
13546 {
13547 	return test_authenticated_encryption(&ccm_test_case_192_1);
13548 }
13549 
13550 static int
13551 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
13552 {
13553 	return test_authenticated_encryption(&ccm_test_case_192_2);
13554 }
13555 
13556 static int
13557 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
13558 {
13559 	return test_authenticated_encryption(&ccm_test_case_192_3);
13560 }
13561 
13562 static int
13563 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
13564 {
13565 	return test_authenticated_decryption(&ccm_test_case_192_1);
13566 }
13567 
13568 static int
13569 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
13570 {
13571 	return test_authenticated_decryption(&ccm_test_case_192_2);
13572 }
13573 
13574 static int
13575 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
13576 {
13577 	return test_authenticated_decryption(&ccm_test_case_192_3);
13578 }
13579 
13580 static int
13581 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
13582 {
13583 	return test_authenticated_encryption(&ccm_test_case_256_1);
13584 }
13585 
13586 static int
13587 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
13588 {
13589 	return test_authenticated_encryption(&ccm_test_case_256_2);
13590 }
13591 
13592 static int
13593 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
13594 {
13595 	return test_authenticated_encryption(&ccm_test_case_256_3);
13596 }
13597 
13598 static int
13599 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
13600 {
13601 	return test_authenticated_decryption(&ccm_test_case_256_1);
13602 }
13603 
13604 static int
13605 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
13606 {
13607 	return test_authenticated_decryption(&ccm_test_case_256_2);
13608 }
13609 
13610 static int
13611 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
13612 {
13613 	return test_authenticated_decryption(&ccm_test_case_256_3);
13614 }
13615 
13616 static int
13617 test_stats(void)
13618 {
13619 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13620 	struct rte_cryptodev_stats stats;
13621 
13622 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13623 		return TEST_SKIPPED;
13624 
13625 	/* Verify the capabilities */
13626 	struct rte_cryptodev_sym_capability_idx cap_idx;
13627 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13628 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
13629 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13630 			&cap_idx) == NULL)
13631 		return TEST_SKIPPED;
13632 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13633 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13634 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13635 			&cap_idx) == NULL)
13636 		return TEST_SKIPPED;
13637 
13638 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
13639 			== -ENOTSUP)
13640 		return TEST_SKIPPED;
13641 
13642 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13643 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
13644 			&stats) == -ENODEV),
13645 		"rte_cryptodev_stats_get invalid dev failed");
13646 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
13647 		"rte_cryptodev_stats_get invalid Param failed");
13648 
13649 	/* Test expected values */
13650 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
13651 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13652 			&stats),
13653 		"rte_cryptodev_stats_get failed");
13654 	TEST_ASSERT((stats.enqueued_count == 1),
13655 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
13656 	TEST_ASSERT((stats.dequeued_count == 1),
13657 		"rte_cryptodev_stats_get returned unexpected dequeued stat");
13658 	TEST_ASSERT((stats.enqueue_err_count == 0),
13659 		"rte_cryptodev_stats_get returned unexpected enqueued error count stat");
13660 	TEST_ASSERT((stats.dequeue_err_count == 0),
13661 		"rte_cryptodev_stats_get returned unexpected dequeued error count stat");
13662 
13663 	/* invalid device but should ignore and not reset device stats*/
13664 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
13665 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13666 			&stats),
13667 		"rte_cryptodev_stats_get failed");
13668 	TEST_ASSERT((stats.enqueued_count == 1),
13669 		"rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
13670 
13671 	/* check that a valid reset clears stats */
13672 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13673 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13674 			&stats),
13675 					  "rte_cryptodev_stats_get failed");
13676 	TEST_ASSERT((stats.enqueued_count == 0),
13677 		"rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
13678 	TEST_ASSERT((stats.dequeued_count == 0),
13679 		"rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
13680 
13681 	return TEST_SUCCESS;
13682 }
13683 
13684 static int
13685 test_device_reconfigure(void)
13686 {
13687 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13688 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
13689 	struct rte_cryptodev_qp_conf qp_conf = {
13690 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT,
13691 		.mp_session = ts_params->session_mpool
13692 	};
13693 	uint16_t qp_id, dev_id, num_devs = 0;
13694 
13695 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
13696 			"Need at least %d devices for test", 1);
13697 
13698 	dev_id = ts_params->valid_devs[0];
13699 
13700 	/* Stop the device in case it's started so it can be configured */
13701 	rte_cryptodev_stop(dev_id);
13702 
13703 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13704 			"Failed test for rte_cryptodev_configure: "
13705 			"dev_num %u", dev_id);
13706 
13707 	/* Reconfigure with same configure params */
13708 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13709 			"Failed test for rte_cryptodev_configure: "
13710 			"dev_num %u", dev_id);
13711 
13712 	/* Reconfigure with just one queue pair */
13713 	ts_params->conf.nb_queue_pairs = 1;
13714 
13715 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13716 			&ts_params->conf),
13717 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
13718 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13719 
13720 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13721 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13722 				ts_params->valid_devs[0], qp_id, &qp_conf,
13723 				rte_cryptodev_socket_id(
13724 						ts_params->valid_devs[0])),
13725 				"Failed test for "
13726 				"rte_cryptodev_queue_pair_setup: num_inflights "
13727 				"%u on qp %u on cryptodev %u",
13728 				qp_conf.nb_descriptors, qp_id,
13729 				ts_params->valid_devs[0]);
13730 	}
13731 
13732 	/* Reconfigure with max number of queue pairs */
13733 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
13734 
13735 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13736 			&ts_params->conf),
13737 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
13738 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13739 
13740 	qp_conf.mp_session = ts_params->session_mpool;
13741 
13742 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13743 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13744 				ts_params->valid_devs[0], qp_id, &qp_conf,
13745 				rte_cryptodev_socket_id(
13746 						ts_params->valid_devs[0])),
13747 				"Failed test for "
13748 				"rte_cryptodev_queue_pair_setup: num_inflights "
13749 				"%u on qp %u on cryptodev %u",
13750 				qp_conf.nb_descriptors, qp_id,
13751 				ts_params->valid_devs[0]);
13752 	}
13753 
13754 	/* Start the device */
13755 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
13756 			"Failed to start cryptodev %u",
13757 			ts_params->valid_devs[0]);
13758 
13759 	/* Test expected values */
13760 	return test_AES_CBC_HMAC_SHA1_encrypt_digest();
13761 }
13762 
13763 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
13764 				   struct crypto_unittest_params *ut_params,
13765 				   enum rte_crypto_auth_operation op,
13766 				   const struct HMAC_MD5_vector *test_case)
13767 {
13768 	uint8_t key[64];
13769 
13770 	memcpy(key, test_case->key.data, test_case->key.len);
13771 
13772 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13773 	ut_params->auth_xform.next = NULL;
13774 	ut_params->auth_xform.auth.op = op;
13775 
13776 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
13777 
13778 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
13779 	ut_params->auth_xform.auth.key.length = test_case->key.len;
13780 	ut_params->auth_xform.auth.key.data = key;
13781 
13782 	ut_params->sess = rte_cryptodev_sym_session_create(
13783 		ts_params->valid_devs[0], &ut_params->auth_xform,
13784 			ts_params->session_mpool);
13785 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13786 		return TEST_SKIPPED;
13787 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13788 
13789 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13790 
13791 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13792 			rte_pktmbuf_tailroom(ut_params->ibuf));
13793 
13794 	return 0;
13795 }
13796 
13797 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
13798 			      const struct HMAC_MD5_vector *test_case,
13799 			      uint8_t **plaintext)
13800 {
13801 	uint16_t plaintext_pad_len;
13802 
13803 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13804 
13805 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13806 				16);
13807 
13808 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13809 			plaintext_pad_len);
13810 	memcpy(*plaintext, test_case->plaintext.data,
13811 			test_case->plaintext.len);
13812 
13813 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13814 			ut_params->ibuf, MD5_DIGEST_LEN);
13815 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13816 			"no room to append digest");
13817 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13818 			ut_params->ibuf, plaintext_pad_len);
13819 
13820 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
13821 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
13822 			   test_case->auth_tag.len);
13823 	}
13824 
13825 	sym_op->auth.data.offset = 0;
13826 	sym_op->auth.data.length = test_case->plaintext.len;
13827 
13828 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13829 	ut_params->op->sym->m_src = ut_params->ibuf;
13830 
13831 	return 0;
13832 }
13833 
13834 static int
13835 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
13836 {
13837 	uint16_t plaintext_pad_len;
13838 	uint8_t *plaintext, *auth_tag;
13839 	int ret;
13840 
13841 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13842 	struct crypto_unittest_params *ut_params = &unittest_params;
13843 	struct rte_cryptodev_info dev_info;
13844 
13845 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13846 	uint64_t feat_flags = dev_info.feature_flags;
13847 
13848 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13849 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13850 		printf("Device doesn't support RAW data-path APIs.\n");
13851 		return TEST_SKIPPED;
13852 	}
13853 
13854 	/* Verify the capabilities */
13855 	struct rte_cryptodev_sym_capability_idx cap_idx;
13856 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13857 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13858 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13859 			&cap_idx) == NULL)
13860 		return TEST_SKIPPED;
13861 
13862 	if (MD5_HMAC_create_session(ts_params, ut_params,
13863 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
13864 		return TEST_FAILED;
13865 
13866 	/* Generate Crypto op data structure */
13867 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13868 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13869 	TEST_ASSERT_NOT_NULL(ut_params->op,
13870 			"Failed to allocate symmetric crypto operation struct");
13871 
13872 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13873 				16);
13874 
13875 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13876 		return TEST_FAILED;
13877 
13878 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13879 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13880 			ut_params->op);
13881 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13882 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13883 		if (ret != TEST_SUCCESS)
13884 			return ret;
13885 	} else
13886 		TEST_ASSERT_NOT_NULL(
13887 			process_crypto_request(ts_params->valid_devs[0],
13888 				ut_params->op),
13889 				"failed to process sym crypto op");
13890 
13891 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13892 			"crypto op processing failed");
13893 
13894 	if (ut_params->op->sym->m_dst) {
13895 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13896 				uint8_t *, plaintext_pad_len);
13897 	} else {
13898 		auth_tag = plaintext + plaintext_pad_len;
13899 	}
13900 
13901 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13902 			auth_tag,
13903 			test_case->auth_tag.data,
13904 			test_case->auth_tag.len,
13905 			"HMAC_MD5 generated tag not as expected");
13906 
13907 	return TEST_SUCCESS;
13908 }
13909 
13910 static int
13911 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
13912 {
13913 	uint8_t *plaintext;
13914 	int ret;
13915 
13916 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13917 	struct crypto_unittest_params *ut_params = &unittest_params;
13918 	struct rte_cryptodev_info dev_info;
13919 
13920 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13921 	uint64_t feat_flags = dev_info.feature_flags;
13922 
13923 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13924 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13925 		printf("Device doesn't support RAW data-path APIs.\n");
13926 		return TEST_SKIPPED;
13927 	}
13928 
13929 	/* Verify the capabilities */
13930 	struct rte_cryptodev_sym_capability_idx cap_idx;
13931 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13932 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
13933 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13934 			&cap_idx) == NULL)
13935 		return TEST_SKIPPED;
13936 
13937 	if (MD5_HMAC_create_session(ts_params, ut_params,
13938 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
13939 		return TEST_FAILED;
13940 	}
13941 
13942 	/* Generate Crypto op data structure */
13943 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13944 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13945 	TEST_ASSERT_NOT_NULL(ut_params->op,
13946 			"Failed to allocate symmetric crypto operation struct");
13947 
13948 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
13949 		return TEST_FAILED;
13950 
13951 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13952 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13953 			ut_params->op);
13954 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13955 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
13956 		if (ret != TEST_SUCCESS)
13957 			return ret;
13958 	} else
13959 		TEST_ASSERT_NOT_NULL(
13960 			process_crypto_request(ts_params->valid_devs[0],
13961 				ut_params->op),
13962 				"failed to process sym crypto op");
13963 
13964 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13965 			"HMAC_MD5 crypto op processing failed");
13966 
13967 	return TEST_SUCCESS;
13968 }
13969 
13970 static int
13971 test_MD5_HMAC_generate_case_1(void)
13972 {
13973 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
13974 }
13975 
13976 static int
13977 test_MD5_HMAC_verify_case_1(void)
13978 {
13979 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
13980 }
13981 
13982 static int
13983 test_MD5_HMAC_generate_case_2(void)
13984 {
13985 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
13986 }
13987 
13988 static int
13989 test_MD5_HMAC_verify_case_2(void)
13990 {
13991 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
13992 }
13993 
13994 static int
13995 test_multi_session(void)
13996 {
13997 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13998 	struct crypto_unittest_params *ut_params = &unittest_params;
13999 	struct rte_cryptodev_info dev_info;
14000 	int i, nb_sess, ret = TEST_SUCCESS;
14001 	void **sessions;
14002 
14003 	/* Verify the capabilities */
14004 	struct rte_cryptodev_sym_capability_idx cap_idx;
14005 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14006 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14007 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14008 			&cap_idx) == NULL)
14009 		return TEST_SKIPPED;
14010 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14011 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14012 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14013 			&cap_idx) == NULL)
14014 		return TEST_SKIPPED;
14015 
14016 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14017 			aes_cbc_key, hmac_sha512_key);
14018 
14019 
14020 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14021 
14022 	sessions = rte_malloc(NULL,
14023 			sizeof(void *) *
14024 			(MAX_NB_SESSIONS + 1), 0);
14025 
14026 	/* Create multiple crypto sessions*/
14027 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
14028 		sessions[i] = rte_cryptodev_sym_session_create(
14029 			ts_params->valid_devs[0], &ut_params->auth_xform,
14030 				ts_params->session_mpool);
14031 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14032 			nb_sess = i;
14033 			ret = TEST_SKIPPED;
14034 			break;
14035 		}
14036 
14037 		TEST_ASSERT_NOT_NULL(sessions[i],
14038 				"Session creation failed at session number %u",
14039 				i);
14040 
14041 		/* Attempt to send a request on each session */
14042 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14043 			sessions[i],
14044 			ut_params,
14045 			ts_params,
14046 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14047 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14048 			aes_cbc_iv);
14049 
14050 		/* free crypto operation structure */
14051 		rte_crypto_op_free(ut_params->op);
14052 
14053 		/*
14054 		 * free mbuf - both obuf and ibuf are usually the same,
14055 		 * so check if they point at the same address is necessary,
14056 		 * to avoid freeing the mbuf twice.
14057 		 */
14058 		if (ut_params->obuf) {
14059 			rte_pktmbuf_free(ut_params->obuf);
14060 			if (ut_params->ibuf == ut_params->obuf)
14061 				ut_params->ibuf = 0;
14062 			ut_params->obuf = 0;
14063 		}
14064 		if (ut_params->ibuf) {
14065 			rte_pktmbuf_free(ut_params->ibuf);
14066 			ut_params->ibuf = 0;
14067 		}
14068 
14069 		if (ret != TEST_SUCCESS) {
14070 			i++;
14071 			break;
14072 		}
14073 	}
14074 
14075 	nb_sess = i;
14076 
14077 	for (i = 0; i < nb_sess; i++) {
14078 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14079 				sessions[i]);
14080 	}
14081 
14082 	rte_free(sessions);
14083 
14084 	if (ret != TEST_SKIPPED)
14085 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14086 
14087 	return ret;
14088 }
14089 
14090 struct multi_session_params {
14091 	struct crypto_unittest_params ut_params;
14092 	uint8_t *cipher_key;
14093 	uint8_t *hmac_key;
14094 	const uint8_t *cipher;
14095 	const uint8_t *digest;
14096 	uint8_t *iv;
14097 };
14098 
14099 #define MB_SESSION_NUMBER 3
14100 
14101 static int
14102 test_multi_session_random_usage(void)
14103 {
14104 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14105 	struct rte_cryptodev_info dev_info;
14106 	int index = 0, ret = TEST_SUCCESS;
14107 	uint32_t nb_sess, i, j;
14108 	void **sessions;
14109 	struct multi_session_params ut_paramz[] = {
14110 
14111 		{
14112 			.cipher_key = ms_aes_cbc_key0,
14113 			.hmac_key = ms_hmac_key0,
14114 			.cipher = ms_aes_cbc_cipher0,
14115 			.digest = ms_hmac_digest0,
14116 			.iv = ms_aes_cbc_iv0
14117 		},
14118 		{
14119 			.cipher_key = ms_aes_cbc_key1,
14120 			.hmac_key = ms_hmac_key1,
14121 			.cipher = ms_aes_cbc_cipher1,
14122 			.digest = ms_hmac_digest1,
14123 			.iv = ms_aes_cbc_iv1
14124 		},
14125 		{
14126 			.cipher_key = ms_aes_cbc_key2,
14127 			.hmac_key = ms_hmac_key2,
14128 			.cipher = ms_aes_cbc_cipher2,
14129 			.digest = ms_hmac_digest2,
14130 			.iv = ms_aes_cbc_iv2
14131 		},
14132 
14133 	};
14134 
14135 	/* Verify the capabilities */
14136 	struct rte_cryptodev_sym_capability_idx cap_idx;
14137 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14138 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14139 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14140 			&cap_idx) == NULL)
14141 		return TEST_SKIPPED;
14142 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14143 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14144 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14145 			&cap_idx) == NULL)
14146 		return TEST_SKIPPED;
14147 
14148 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14149 
14150 	sessions = rte_malloc(NULL, (sizeof(void *)
14151 					* MAX_NB_SESSIONS) + 1, 0);
14152 
14153 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
14154 
14155 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
14156 				sizeof(struct crypto_unittest_params));
14157 
14158 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14159 				&ut_paramz[i].ut_params,
14160 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14161 
14162 		/* Create multiple crypto sessions*/
14163 		sessions[i] = rte_cryptodev_sym_session_create(
14164 				ts_params->valid_devs[0],
14165 				&ut_paramz[i].ut_params.auth_xform,
14166 				ts_params->session_mpool);
14167 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14168 			nb_sess = i;
14169 			ret = TEST_SKIPPED;
14170 			goto session_clear;
14171 		}
14172 
14173 		TEST_ASSERT_NOT_NULL(sessions[i],
14174 				"Session creation failed at session number %u",
14175 				i);
14176 	}
14177 
14178 	nb_sess = i;
14179 
14180 	srand(time(NULL));
14181 	for (i = 0; i < 40000; i++) {
14182 
14183 		j = rand() % MB_SESSION_NUMBER;
14184 
14185 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14186 					sessions[j],
14187 					&ut_paramz[j].ut_params,
14188 					ts_params, ut_paramz[j].cipher,
14189 					ut_paramz[j].digest,
14190 					ut_paramz[j].iv);
14191 
14192 		rte_crypto_op_free(ut_paramz[j].ut_params.op);
14193 
14194 		/*
14195 		 * free mbuf - both obuf and ibuf are usually the same,
14196 		 * so check if they point at the same address is necessary,
14197 		 * to avoid freeing the mbuf twice.
14198 		 */
14199 		if (ut_paramz[j].ut_params.obuf) {
14200 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14201 			if (ut_paramz[j].ut_params.ibuf
14202 					== ut_paramz[j].ut_params.obuf)
14203 				ut_paramz[j].ut_params.ibuf = 0;
14204 			ut_paramz[j].ut_params.obuf = 0;
14205 		}
14206 		if (ut_paramz[j].ut_params.ibuf) {
14207 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14208 			ut_paramz[j].ut_params.ibuf = 0;
14209 		}
14210 
14211 		if (ret != TEST_SKIPPED) {
14212 			index = i;
14213 			break;
14214 		}
14215 	}
14216 
14217 session_clear:
14218 	for (i = 0; i < nb_sess; i++) {
14219 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14220 				sessions[i]);
14221 	}
14222 
14223 	rte_free(sessions);
14224 
14225 	if (ret != TEST_SKIPPED)
14226 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14227 
14228 	return TEST_SUCCESS;
14229 }
14230 
14231 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14232 			0xab, 0xab, 0xab, 0xab,
14233 			0xab, 0xab, 0xab, 0xab,
14234 			0xab, 0xab, 0xab, 0xab};
14235 
14236 static int
14237 test_null_invalid_operation(void)
14238 {
14239 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14240 	struct crypto_unittest_params *ut_params = &unittest_params;
14241 
14242 	/* This test is for NULL PMD only */
14243 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14244 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14245 		return TEST_SKIPPED;
14246 
14247 	/* Setup Cipher Parameters */
14248 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14249 	ut_params->cipher_xform.next = NULL;
14250 
14251 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14252 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14253 
14254 	/* Create Crypto session*/
14255 	ut_params->sess = rte_cryptodev_sym_session_create(
14256 			ts_params->valid_devs[0], &ut_params->cipher_xform,
14257 			ts_params->session_mpool);
14258 	TEST_ASSERT(ut_params->sess == NULL,
14259 			"Session creation succeeded unexpectedly");
14260 
14261 	/* Setup HMAC Parameters */
14262 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14263 	ut_params->auth_xform.next = NULL;
14264 
14265 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
14266 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14267 
14268 	/* Create Crypto session*/
14269 	ut_params->sess = rte_cryptodev_sym_session_create(
14270 			ts_params->valid_devs[0], &ut_params->auth_xform,
14271 			ts_params->session_mpool);
14272 	TEST_ASSERT(ut_params->sess == NULL,
14273 			"Session creation succeeded unexpectedly");
14274 
14275 	return TEST_SUCCESS;
14276 }
14277 
14278 
14279 #define NULL_BURST_LENGTH (32)
14280 
14281 static int
14282 test_null_burst_operation(void)
14283 {
14284 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14285 	struct crypto_unittest_params *ut_params = &unittest_params;
14286 
14287 	unsigned i, burst_len = NULL_BURST_LENGTH;
14288 
14289 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
14290 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
14291 
14292 	/* This test is for NULL PMD only */
14293 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14294 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14295 		return TEST_SKIPPED;
14296 
14297 	/* Setup Cipher Parameters */
14298 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14299 	ut_params->cipher_xform.next = &ut_params->auth_xform;
14300 
14301 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
14302 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14303 
14304 	/* Setup HMAC Parameters */
14305 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14306 	ut_params->auth_xform.next = NULL;
14307 
14308 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
14309 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14310 
14311 	/* Create Crypto session*/
14312 	ut_params->sess = rte_cryptodev_sym_session_create(
14313 				ts_params->valid_devs[0],
14314 				&ut_params->auth_xform,
14315 				ts_params->session_mpool);
14316 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14317 		return TEST_SKIPPED;
14318 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14319 
14320 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
14321 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
14322 			burst_len, "failed to generate burst of crypto ops");
14323 
14324 	/* Generate an operation for each mbuf in burst */
14325 	for (i = 0; i < burst_len; i++) {
14326 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14327 
14328 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
14329 
14330 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
14331 				sizeof(unsigned));
14332 		*data = i;
14333 
14334 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
14335 
14336 		burst[i]->sym->m_src = m;
14337 	}
14338 
14339 	/* Process crypto operation */
14340 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
14341 			0, burst, burst_len),
14342 			burst_len,
14343 			"Error enqueuing burst");
14344 
14345 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
14346 			0, burst_dequeued, burst_len),
14347 			burst_len,
14348 			"Error dequeuing burst");
14349 
14350 
14351 	for (i = 0; i < burst_len; i++) {
14352 		TEST_ASSERT_EQUAL(
14353 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
14354 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
14355 					uint32_t *),
14356 			"data not as expected");
14357 
14358 		rte_pktmbuf_free(burst[i]->sym->m_src);
14359 		rte_crypto_op_free(burst[i]);
14360 	}
14361 
14362 	return TEST_SUCCESS;
14363 }
14364 
14365 static uint16_t
14366 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14367 		  uint16_t nb_ops, void *user_param)
14368 {
14369 	RTE_SET_USED(dev_id);
14370 	RTE_SET_USED(qp_id);
14371 	RTE_SET_USED(ops);
14372 	RTE_SET_USED(user_param);
14373 
14374 	printf("crypto enqueue callback called\n");
14375 	return nb_ops;
14376 }
14377 
14378 static uint16_t
14379 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14380 		  uint16_t nb_ops, void *user_param)
14381 {
14382 	RTE_SET_USED(dev_id);
14383 	RTE_SET_USED(qp_id);
14384 	RTE_SET_USED(ops);
14385 	RTE_SET_USED(user_param);
14386 
14387 	printf("crypto dequeue callback called\n");
14388 	return nb_ops;
14389 }
14390 
14391 /*
14392  * Thread using enqueue/dequeue callback with RCU.
14393  */
14394 static int
14395 test_enqdeq_callback_thread(void *arg)
14396 {
14397 	RTE_SET_USED(arg);
14398 	/* DP thread calls rte_cryptodev_enqueue_burst()/
14399 	 * rte_cryptodev_dequeue_burst() and invokes callback.
14400 	 */
14401 	test_null_burst_operation();
14402 	return 0;
14403 }
14404 
14405 static int
14406 test_enq_callback_setup(void)
14407 {
14408 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14409 	struct rte_cryptodev_info dev_info;
14410 	struct rte_cryptodev_qp_conf qp_conf = {
14411 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
14412 	};
14413 
14414 	struct rte_cryptodev_cb *cb;
14415 	uint16_t qp_id = 0;
14416 
14417 	/* Stop the device in case it's started so it can be configured */
14418 	rte_cryptodev_stop(ts_params->valid_devs[0]);
14419 
14420 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14421 
14422 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14423 			&ts_params->conf),
14424 			"Failed to configure cryptodev %u",
14425 			ts_params->valid_devs[0]);
14426 
14427 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14428 	qp_conf.mp_session = ts_params->session_mpool;
14429 
14430 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14431 			ts_params->valid_devs[0], qp_id, &qp_conf,
14432 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14433 			"Failed test for "
14434 			"rte_cryptodev_queue_pair_setup: num_inflights "
14435 			"%u on qp %u on cryptodev %u",
14436 			qp_conf.nb_descriptors, qp_id,
14437 			ts_params->valid_devs[0]);
14438 
14439 	/* Test with invalid crypto device */
14440 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
14441 			qp_id, test_enq_callback, NULL);
14442 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14443 			"cryptodev %u did not fail",
14444 			qp_id, RTE_CRYPTO_MAX_DEVS);
14445 
14446 	/* Test with invalid queue pair */
14447 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14448 			dev_info.max_nb_queue_pairs + 1,
14449 			test_enq_callback, NULL);
14450 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14451 			"cryptodev %u did not fail",
14452 			dev_info.max_nb_queue_pairs + 1,
14453 			ts_params->valid_devs[0]);
14454 
14455 	/* Test with NULL callback */
14456 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14457 			qp_id, NULL, NULL);
14458 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14459 			"cryptodev %u did not fail",
14460 			qp_id, ts_params->valid_devs[0]);
14461 
14462 	/* Test with valid configuration */
14463 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14464 			qp_id, test_enq_callback, NULL);
14465 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14466 			"qp %u on cryptodev %u",
14467 			qp_id, ts_params->valid_devs[0]);
14468 
14469 	rte_cryptodev_start(ts_params->valid_devs[0]);
14470 
14471 	/* Launch a thread */
14472 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14473 				rte_get_next_lcore(-1, 1, 0));
14474 
14475 	/* Wait until reader exited. */
14476 	rte_eal_mp_wait_lcore();
14477 
14478 	/* Test with invalid crypto device */
14479 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14480 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14481 			"Expected call to fail as crypto device is invalid");
14482 
14483 	/* Test with invalid queue pair */
14484 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14485 			ts_params->valid_devs[0],
14486 			dev_info.max_nb_queue_pairs + 1, cb),
14487 			"Expected call to fail as queue pair is invalid");
14488 
14489 	/* Test with NULL callback */
14490 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14491 			ts_params->valid_devs[0], qp_id, NULL),
14492 			"Expected call to fail as callback is NULL");
14493 
14494 	/* Test with valid configuration */
14495 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
14496 			ts_params->valid_devs[0], qp_id, cb),
14497 			"Failed test to remove callback on "
14498 			"qp %u on cryptodev %u",
14499 			qp_id, ts_params->valid_devs[0]);
14500 
14501 	return TEST_SUCCESS;
14502 }
14503 
14504 static int
14505 test_deq_callback_setup(void)
14506 {
14507 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14508 	struct rte_cryptodev_info dev_info;
14509 	struct rte_cryptodev_qp_conf qp_conf = {
14510 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
14511 	};
14512 
14513 	struct rte_cryptodev_cb *cb;
14514 	uint16_t qp_id = 0;
14515 
14516 	/* Stop the device in case it's started so it can be configured */
14517 	rte_cryptodev_stop(ts_params->valid_devs[0]);
14518 
14519 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14520 
14521 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14522 			&ts_params->conf),
14523 			"Failed to configure cryptodev %u",
14524 			ts_params->valid_devs[0]);
14525 
14526 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14527 	qp_conf.mp_session = ts_params->session_mpool;
14528 
14529 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14530 			ts_params->valid_devs[0], qp_id, &qp_conf,
14531 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14532 			"Failed test for "
14533 			"rte_cryptodev_queue_pair_setup: num_inflights "
14534 			"%u on qp %u on cryptodev %u",
14535 			qp_conf.nb_descriptors, qp_id,
14536 			ts_params->valid_devs[0]);
14537 
14538 	/* Test with invalid crypto device */
14539 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
14540 			qp_id, test_deq_callback, NULL);
14541 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14542 			"cryptodev %u did not fail",
14543 			qp_id, RTE_CRYPTO_MAX_DEVS);
14544 
14545 	/* Test with invalid queue pair */
14546 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14547 			dev_info.max_nb_queue_pairs + 1,
14548 			test_deq_callback, NULL);
14549 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14550 			"cryptodev %u did not fail",
14551 			dev_info.max_nb_queue_pairs + 1,
14552 			ts_params->valid_devs[0]);
14553 
14554 	/* Test with NULL callback */
14555 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14556 			qp_id, NULL, NULL);
14557 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14558 			"cryptodev %u did not fail",
14559 			qp_id, ts_params->valid_devs[0]);
14560 
14561 	/* Test with valid configuration */
14562 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14563 			qp_id, test_deq_callback, NULL);
14564 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14565 			"qp %u on cryptodev %u",
14566 			qp_id, ts_params->valid_devs[0]);
14567 
14568 	rte_cryptodev_start(ts_params->valid_devs[0]);
14569 
14570 	/* Launch a thread */
14571 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14572 				rte_get_next_lcore(-1, 1, 0));
14573 
14574 	/* Wait until reader exited. */
14575 	rte_eal_mp_wait_lcore();
14576 
14577 	/* Test with invalid crypto device */
14578 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14579 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14580 			"Expected call to fail as crypto device is invalid");
14581 
14582 	/* Test with invalid queue pair */
14583 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14584 			ts_params->valid_devs[0],
14585 			dev_info.max_nb_queue_pairs + 1, cb),
14586 			"Expected call to fail as queue pair is invalid");
14587 
14588 	/* Test with NULL callback */
14589 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14590 			ts_params->valid_devs[0], qp_id, NULL),
14591 			"Expected call to fail as callback is NULL");
14592 
14593 	/* Test with valid configuration */
14594 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
14595 			ts_params->valid_devs[0], qp_id, cb),
14596 			"Failed test to remove callback on "
14597 			"qp %u on cryptodev %u",
14598 			qp_id, ts_params->valid_devs[0]);
14599 
14600 	return TEST_SUCCESS;
14601 }
14602 
14603 static void
14604 generate_gmac_large_plaintext(uint8_t *data)
14605 {
14606 	uint16_t i;
14607 
14608 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
14609 		memcpy(&data[i], &data[0], 32);
14610 }
14611 
14612 static int
14613 create_gmac_operation(enum rte_crypto_auth_operation op,
14614 		const struct gmac_test_data *tdata)
14615 {
14616 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14617 	struct crypto_unittest_params *ut_params = &unittest_params;
14618 	struct rte_crypto_sym_op *sym_op;
14619 
14620 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14621 
14622 	/* Generate Crypto op data structure */
14623 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14624 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14625 	TEST_ASSERT_NOT_NULL(ut_params->op,
14626 			"Failed to allocate symmetric crypto operation struct");
14627 
14628 	sym_op = ut_params->op->sym;
14629 
14630 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14631 			ut_params->ibuf, tdata->gmac_tag.len);
14632 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14633 			"no room to append digest");
14634 
14635 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14636 			ut_params->ibuf, plaintext_pad_len);
14637 
14638 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14639 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14640 				tdata->gmac_tag.len);
14641 		debug_hexdump(stdout, "digest:",
14642 				sym_op->auth.digest.data,
14643 				tdata->gmac_tag.len);
14644 	}
14645 
14646 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14647 			uint8_t *, IV_OFFSET);
14648 
14649 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14650 
14651 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14652 
14653 	sym_op->cipher.data.length = 0;
14654 	sym_op->cipher.data.offset = 0;
14655 
14656 	sym_op->auth.data.offset = 0;
14657 	sym_op->auth.data.length = tdata->plaintext.len;
14658 
14659 	return 0;
14660 }
14661 
14662 static int
14663 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
14664 		const struct gmac_test_data *tdata,
14665 		void *digest_mem, uint64_t digest_phys)
14666 {
14667 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14668 	struct crypto_unittest_params *ut_params = &unittest_params;
14669 	struct rte_crypto_sym_op *sym_op;
14670 
14671 	/* Generate Crypto op data structure */
14672 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14673 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14674 	TEST_ASSERT_NOT_NULL(ut_params->op,
14675 			"Failed to allocate symmetric crypto operation struct");
14676 
14677 	sym_op = ut_params->op->sym;
14678 
14679 	sym_op->auth.digest.data = digest_mem;
14680 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14681 			"no room to append digest");
14682 
14683 	sym_op->auth.digest.phys_addr = digest_phys;
14684 
14685 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14686 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14687 				tdata->gmac_tag.len);
14688 		debug_hexdump(stdout, "digest:",
14689 				sym_op->auth.digest.data,
14690 				tdata->gmac_tag.len);
14691 	}
14692 
14693 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14694 			uint8_t *, IV_OFFSET);
14695 
14696 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14697 
14698 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14699 
14700 	sym_op->cipher.data.length = 0;
14701 	sym_op->cipher.data.offset = 0;
14702 
14703 	sym_op->auth.data.offset = 0;
14704 	sym_op->auth.data.length = tdata->plaintext.len;
14705 
14706 	return 0;
14707 }
14708 
14709 static int create_gmac_session(uint8_t dev_id,
14710 		const struct gmac_test_data *tdata,
14711 		enum rte_crypto_auth_operation auth_op)
14712 {
14713 	uint8_t auth_key[tdata->key.len];
14714 
14715 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14716 	struct crypto_unittest_params *ut_params = &unittest_params;
14717 
14718 	memcpy(auth_key, tdata->key.data, tdata->key.len);
14719 
14720 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14721 	ut_params->auth_xform.next = NULL;
14722 
14723 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
14724 	ut_params->auth_xform.auth.op = auth_op;
14725 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
14726 	ut_params->auth_xform.auth.key.length = tdata->key.len;
14727 	ut_params->auth_xform.auth.key.data = auth_key;
14728 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14729 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
14730 
14731 
14732 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14733 			&ut_params->auth_xform, ts_params->session_mpool);
14734 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14735 		return TEST_SKIPPED;
14736 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14737 
14738 	return 0;
14739 }
14740 
14741 static int
14742 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
14743 {
14744 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14745 	struct crypto_unittest_params *ut_params = &unittest_params;
14746 	struct rte_cryptodev_info dev_info;
14747 
14748 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14749 	uint64_t feat_flags = dev_info.feature_flags;
14750 
14751 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14752 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14753 		printf("Device doesn't support RAW data-path APIs.\n");
14754 		return TEST_SKIPPED;
14755 	}
14756 
14757 	int retval;
14758 
14759 	uint8_t *auth_tag, *plaintext;
14760 	uint16_t plaintext_pad_len;
14761 
14762 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14763 			      "No GMAC length in the source data");
14764 
14765 	/* Verify the capabilities */
14766 	struct rte_cryptodev_sym_capability_idx cap_idx;
14767 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14768 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14769 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14770 			&cap_idx) == NULL)
14771 		return TEST_SKIPPED;
14772 
14773 	retval = create_gmac_session(ts_params->valid_devs[0],
14774 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14775 
14776 	if (retval == TEST_SKIPPED)
14777 		return TEST_SKIPPED;
14778 	if (retval < 0)
14779 		return retval;
14780 
14781 	if (tdata->plaintext.len > MBUF_SIZE)
14782 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14783 	else
14784 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14785 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14786 			"Failed to allocate input buffer in mempool");
14787 
14788 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14789 			rte_pktmbuf_tailroom(ut_params->ibuf));
14790 
14791 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14792 	/*
14793 	 * Runtime generate the large plain text instead of use hard code
14794 	 * plain text vector. It is done to avoid create huge source file
14795 	 * with the test vector.
14796 	 */
14797 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14798 		generate_gmac_large_plaintext(tdata->plaintext.data);
14799 
14800 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14801 				plaintext_pad_len);
14802 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14803 
14804 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14805 	debug_hexdump(stdout, "plaintext:", plaintext,
14806 			tdata->plaintext.len);
14807 
14808 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
14809 			tdata);
14810 
14811 	if (retval < 0)
14812 		return retval;
14813 
14814 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14815 
14816 	ut_params->op->sym->m_src = ut_params->ibuf;
14817 
14818 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14819 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14820 			ut_params->op);
14821 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14822 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14823 					       0);
14824 		if (retval != TEST_SUCCESS)
14825 			return retval;
14826 	} else
14827 		TEST_ASSERT_NOT_NULL(
14828 			process_crypto_request(ts_params->valid_devs[0],
14829 			ut_params->op), "failed to process sym crypto op");
14830 
14831 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14832 			"crypto op processing failed");
14833 
14834 	if (ut_params->op->sym->m_dst) {
14835 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14836 				uint8_t *, plaintext_pad_len);
14837 	} else {
14838 		auth_tag = plaintext + plaintext_pad_len;
14839 	}
14840 
14841 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
14842 
14843 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14844 			auth_tag,
14845 			tdata->gmac_tag.data,
14846 			tdata->gmac_tag.len,
14847 			"GMAC Generated auth tag not as expected");
14848 
14849 	return 0;
14850 }
14851 
14852 static int
14853 test_AES_GMAC_authentication_test_case_1(void)
14854 {
14855 	return test_AES_GMAC_authentication(&gmac_test_case_1);
14856 }
14857 
14858 static int
14859 test_AES_GMAC_authentication_test_case_2(void)
14860 {
14861 	return test_AES_GMAC_authentication(&gmac_test_case_2);
14862 }
14863 
14864 static int
14865 test_AES_GMAC_authentication_test_case_3(void)
14866 {
14867 	return test_AES_GMAC_authentication(&gmac_test_case_3);
14868 }
14869 
14870 static int
14871 test_AES_GMAC_authentication_test_case_4(void)
14872 {
14873 	return test_AES_GMAC_authentication(&gmac_test_case_4);
14874 }
14875 
14876 static int
14877 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
14878 {
14879 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14880 	struct crypto_unittest_params *ut_params = &unittest_params;
14881 	int retval;
14882 	uint32_t plaintext_pad_len;
14883 	uint8_t *plaintext;
14884 	struct rte_cryptodev_info dev_info;
14885 
14886 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14887 	uint64_t feat_flags = dev_info.feature_flags;
14888 
14889 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14890 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14891 		printf("Device doesn't support RAW data-path APIs.\n");
14892 		return TEST_SKIPPED;
14893 	}
14894 
14895 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14896 			      "No GMAC length in the source data");
14897 
14898 	/* Verify the capabilities */
14899 	struct rte_cryptodev_sym_capability_idx cap_idx;
14900 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14901 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14902 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14903 			&cap_idx) == NULL)
14904 		return TEST_SKIPPED;
14905 
14906 	retval = create_gmac_session(ts_params->valid_devs[0],
14907 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
14908 
14909 	if (retval == TEST_SKIPPED)
14910 		return TEST_SKIPPED;
14911 	if (retval < 0)
14912 		return retval;
14913 
14914 	if (tdata->plaintext.len > MBUF_SIZE)
14915 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14916 	else
14917 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14918 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14919 			"Failed to allocate input buffer in mempool");
14920 
14921 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14922 			rte_pktmbuf_tailroom(ut_params->ibuf));
14923 
14924 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14925 
14926 	/*
14927 	 * Runtime generate the large plain text instead of use hard code
14928 	 * plain text vector. It is done to avoid create huge source file
14929 	 * with the test vector.
14930 	 */
14931 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14932 		generate_gmac_large_plaintext(tdata->plaintext.data);
14933 
14934 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14935 				plaintext_pad_len);
14936 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14937 
14938 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14939 	debug_hexdump(stdout, "plaintext:", plaintext,
14940 			tdata->plaintext.len);
14941 
14942 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
14943 			tdata);
14944 
14945 	if (retval < 0)
14946 		return retval;
14947 
14948 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14949 
14950 	ut_params->op->sym->m_src = ut_params->ibuf;
14951 
14952 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14953 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14954 			ut_params->op);
14955 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14956 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
14957 					       0);
14958 		if (retval != TEST_SUCCESS)
14959 			return retval;
14960 	} else
14961 		TEST_ASSERT_NOT_NULL(
14962 			process_crypto_request(ts_params->valid_devs[0],
14963 			ut_params->op), "failed to process sym crypto op");
14964 
14965 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14966 			"crypto op processing failed");
14967 
14968 	return 0;
14969 
14970 }
14971 
14972 static int
14973 test_AES_GMAC_authentication_verify_test_case_1(void)
14974 {
14975 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
14976 }
14977 
14978 static int
14979 test_AES_GMAC_authentication_verify_test_case_2(void)
14980 {
14981 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
14982 }
14983 
14984 static int
14985 test_AES_GMAC_authentication_verify_test_case_3(void)
14986 {
14987 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
14988 }
14989 
14990 static int
14991 test_AES_GMAC_authentication_verify_test_case_4(void)
14992 {
14993 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
14994 }
14995 
14996 static int
14997 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
14998 				uint32_t fragsz)
14999 {
15000 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15001 	struct crypto_unittest_params *ut_params = &unittest_params;
15002 	struct rte_cryptodev_info dev_info;
15003 	uint64_t feature_flags;
15004 	unsigned int trn_data = 0;
15005 	void *digest_mem = NULL;
15006 	uint32_t segs = 1;
15007 	unsigned int to_trn = 0;
15008 	struct rte_mbuf *buf = NULL;
15009 	uint8_t *auth_tag, *plaintext;
15010 	int retval;
15011 
15012 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15013 			      "No GMAC length in the source data");
15014 
15015 	/* Verify the capabilities */
15016 	struct rte_cryptodev_sym_capability_idx cap_idx;
15017 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15018 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15019 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15020 			&cap_idx) == NULL)
15021 		return TEST_SKIPPED;
15022 
15023 	/* Check for any input SGL support */
15024 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15025 	feature_flags = dev_info.feature_flags;
15026 
15027 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15028 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15029 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15030 		return TEST_SKIPPED;
15031 
15032 	if (fragsz > tdata->plaintext.len)
15033 		fragsz = tdata->plaintext.len;
15034 
15035 	uint16_t plaintext_len = fragsz;
15036 
15037 	retval = create_gmac_session(ts_params->valid_devs[0],
15038 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15039 
15040 	if (retval == TEST_SKIPPED)
15041 		return TEST_SKIPPED;
15042 	if (retval < 0)
15043 		return retval;
15044 
15045 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15046 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15047 			"Failed to allocate input buffer in mempool");
15048 
15049 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15050 			rte_pktmbuf_tailroom(ut_params->ibuf));
15051 
15052 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15053 				plaintext_len);
15054 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15055 
15056 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15057 
15058 	trn_data += plaintext_len;
15059 
15060 	buf = ut_params->ibuf;
15061 
15062 	/*
15063 	 * Loop until no more fragments
15064 	 */
15065 
15066 	while (trn_data < tdata->plaintext.len) {
15067 		++segs;
15068 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15069 				(tdata->plaintext.len - trn_data) : fragsz;
15070 
15071 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15072 		buf = buf->next;
15073 
15074 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15075 				rte_pktmbuf_tailroom(buf));
15076 
15077 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15078 				to_trn);
15079 
15080 		memcpy(plaintext, tdata->plaintext.data + trn_data,
15081 				to_trn);
15082 		trn_data += to_trn;
15083 		if (trn_data  == tdata->plaintext.len)
15084 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15085 					tdata->gmac_tag.len);
15086 	}
15087 	ut_params->ibuf->nb_segs = segs;
15088 
15089 	/*
15090 	 * Place digest at the end of the last buffer
15091 	 */
15092 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15093 
15094 	if (!digest_mem) {
15095 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15096 				+ tdata->gmac_tag.len);
15097 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15098 				tdata->plaintext.len);
15099 	}
15100 
15101 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15102 			tdata, digest_mem, digest_phys);
15103 
15104 	if (retval < 0)
15105 		return retval;
15106 
15107 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15108 
15109 	ut_params->op->sym->m_src = ut_params->ibuf;
15110 
15111 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15112 		return TEST_SKIPPED;
15113 
15114 	TEST_ASSERT_NOT_NULL(
15115 		process_crypto_request(ts_params->valid_devs[0],
15116 		ut_params->op), "failed to process sym crypto op");
15117 
15118 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15119 			"crypto op processing failed");
15120 
15121 	auth_tag = digest_mem;
15122 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15123 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15124 			auth_tag,
15125 			tdata->gmac_tag.data,
15126 			tdata->gmac_tag.len,
15127 			"GMAC Generated auth tag not as expected");
15128 
15129 	return 0;
15130 }
15131 
15132 /* Segment size not multiple of block size (16B) */
15133 static int
15134 test_AES_GMAC_authentication_SGL_40B(void)
15135 {
15136 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15137 }
15138 
15139 static int
15140 test_AES_GMAC_authentication_SGL_80B(void)
15141 {
15142 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15143 }
15144 
15145 static int
15146 test_AES_GMAC_authentication_SGL_2048B(void)
15147 {
15148 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15149 }
15150 
15151 /* Segment size not multiple of block size (16B) */
15152 static int
15153 test_AES_GMAC_authentication_SGL_2047B(void)
15154 {
15155 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15156 }
15157 
15158 struct test_crypto_vector {
15159 	enum rte_crypto_cipher_algorithm crypto_algo;
15160 	unsigned int cipher_offset;
15161 	unsigned int cipher_len;
15162 
15163 	struct {
15164 		uint8_t data[64];
15165 		unsigned int len;
15166 	} cipher_key;
15167 
15168 	struct {
15169 		uint8_t data[64];
15170 		unsigned int len;
15171 	} iv;
15172 
15173 	struct {
15174 		const uint8_t *data;
15175 		unsigned int len;
15176 	} plaintext;
15177 
15178 	struct {
15179 		const uint8_t *data;
15180 		unsigned int len;
15181 	} ciphertext;
15182 
15183 	enum rte_crypto_auth_algorithm auth_algo;
15184 	unsigned int auth_offset;
15185 
15186 	struct {
15187 		uint8_t data[128];
15188 		unsigned int len;
15189 	} auth_key;
15190 
15191 	struct {
15192 		const uint8_t *data;
15193 		unsigned int len;
15194 	} aad;
15195 
15196 	struct {
15197 		uint8_t data[128];
15198 		unsigned int len;
15199 	} digest;
15200 };
15201 
15202 static const struct test_crypto_vector
15203 hmac_sha1_test_crypto_vector = {
15204 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15205 	.plaintext = {
15206 		.data = plaintext_hash,
15207 		.len = 512
15208 	},
15209 	.auth_key = {
15210 		.data = {
15211 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15212 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15213 			0xDE, 0xF4, 0xDE, 0xAD
15214 		},
15215 		.len = 20
15216 	},
15217 	.digest = {
15218 		.data = {
15219 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
15220 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
15221 			0x3F, 0x91, 0x64, 0x59
15222 		},
15223 		.len = 20
15224 	}
15225 };
15226 
15227 static const struct test_crypto_vector
15228 aes128_gmac_test_vector = {
15229 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
15230 	.plaintext = {
15231 		.data = plaintext_hash,
15232 		.len = 512
15233 	},
15234 	.iv = {
15235 		.data = {
15236 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15237 			0x08, 0x09, 0x0A, 0x0B
15238 		},
15239 		.len = 12
15240 	},
15241 	.auth_key = {
15242 		.data = {
15243 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15244 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
15245 		},
15246 		.len = 16
15247 	},
15248 	.digest = {
15249 		.data = {
15250 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
15251 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
15252 		},
15253 		.len = 16
15254 	}
15255 };
15256 
15257 static const struct test_crypto_vector
15258 aes128cbc_hmac_sha1_test_vector = {
15259 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15260 	.cipher_offset = 0,
15261 	.cipher_len = 512,
15262 	.cipher_key = {
15263 		.data = {
15264 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15265 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15266 		},
15267 		.len = 16
15268 	},
15269 	.iv = {
15270 		.data = {
15271 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15272 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15273 		},
15274 		.len = 16
15275 	},
15276 	.plaintext = {
15277 		.data = plaintext_hash,
15278 		.len = 512
15279 	},
15280 	.ciphertext = {
15281 		.data = ciphertext512_aes128cbc,
15282 		.len = 512
15283 	},
15284 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15285 	.auth_offset = 0,
15286 	.auth_key = {
15287 		.data = {
15288 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15289 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15290 			0xDE, 0xF4, 0xDE, 0xAD
15291 		},
15292 		.len = 20
15293 	},
15294 	.digest = {
15295 		.data = {
15296 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
15297 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15298 			0x18, 0x8C, 0x1D, 0x32
15299 		},
15300 		.len = 20
15301 	}
15302 };
15303 
15304 static const struct test_crypto_vector
15305 aes128cbc_hmac_sha1_aad_test_vector = {
15306 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15307 	.cipher_offset = 8,
15308 	.cipher_len = 496,
15309 	.cipher_key = {
15310 		.data = {
15311 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15312 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15313 		},
15314 		.len = 16
15315 	},
15316 	.iv = {
15317 		.data = {
15318 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15319 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15320 		},
15321 		.len = 16
15322 	},
15323 	.plaintext = {
15324 		.data = plaintext_hash,
15325 		.len = 512
15326 	},
15327 	.ciphertext = {
15328 		.data = ciphertext512_aes128cbc_aad,
15329 		.len = 512
15330 	},
15331 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15332 	.auth_offset = 0,
15333 	.auth_key = {
15334 		.data = {
15335 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15336 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15337 			0xDE, 0xF4, 0xDE, 0xAD
15338 		},
15339 		.len = 20
15340 	},
15341 	.digest = {
15342 		.data = {
15343 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
15344 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
15345 			0x62, 0x0F, 0xFB, 0x10
15346 		},
15347 		.len = 20
15348 	}
15349 };
15350 
15351 static void
15352 data_corruption(uint8_t *data)
15353 {
15354 	data[0] += 1;
15355 }
15356 
15357 static void
15358 tag_corruption(uint8_t *data, unsigned int tag_offset)
15359 {
15360 	data[tag_offset] += 1;
15361 }
15362 
15363 static int
15364 create_auth_session(struct crypto_unittest_params *ut_params,
15365 		uint8_t dev_id,
15366 		const struct test_crypto_vector *reference,
15367 		enum rte_crypto_auth_operation auth_op)
15368 {
15369 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15370 	uint8_t auth_key[reference->auth_key.len + 1];
15371 
15372 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15373 
15374 	/* Setup Authentication Parameters */
15375 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15376 	ut_params->auth_xform.auth.op = auth_op;
15377 	ut_params->auth_xform.next = NULL;
15378 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15379 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15380 	ut_params->auth_xform.auth.key.data = auth_key;
15381 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15382 
15383 	/* Create Crypto session*/
15384 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15385 				&ut_params->auth_xform,
15386 				ts_params->session_mpool);
15387 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15388 		return TEST_SKIPPED;
15389 
15390 	return 0;
15391 }
15392 
15393 static int
15394 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
15395 		uint8_t dev_id,
15396 		const struct test_crypto_vector *reference,
15397 		enum rte_crypto_auth_operation auth_op,
15398 		enum rte_crypto_cipher_operation cipher_op)
15399 {
15400 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15401 	uint8_t cipher_key[reference->cipher_key.len + 1];
15402 	uint8_t auth_key[reference->auth_key.len + 1];
15403 
15404 	memcpy(cipher_key, reference->cipher_key.data,
15405 			reference->cipher_key.len);
15406 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15407 
15408 	/* Setup Authentication Parameters */
15409 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15410 	ut_params->auth_xform.auth.op = auth_op;
15411 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15412 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15413 	ut_params->auth_xform.auth.key.data = auth_key;
15414 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15415 
15416 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
15417 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15418 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
15419 	} else {
15420 		ut_params->auth_xform.next = &ut_params->cipher_xform;
15421 
15422 		/* Setup Cipher Parameters */
15423 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15424 		ut_params->cipher_xform.next = NULL;
15425 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15426 		ut_params->cipher_xform.cipher.op = cipher_op;
15427 		ut_params->cipher_xform.cipher.key.data = cipher_key;
15428 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15429 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15430 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15431 	}
15432 
15433 	/* Create Crypto session*/
15434 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15435 				&ut_params->auth_xform,
15436 				ts_params->session_mpool);
15437 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15438 		return TEST_SKIPPED;
15439 
15440 	return 0;
15441 }
15442 
15443 static int
15444 create_auth_operation(struct crypto_testsuite_params *ts_params,
15445 		struct crypto_unittest_params *ut_params,
15446 		const struct test_crypto_vector *reference,
15447 		unsigned int auth_generate)
15448 {
15449 	/* Generate Crypto op data structure */
15450 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15451 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15452 	TEST_ASSERT_NOT_NULL(ut_params->op,
15453 			"Failed to allocate pktmbuf offload");
15454 
15455 	/* Set crypto operation data parameters */
15456 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15457 
15458 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15459 
15460 	/* set crypto operation source mbuf */
15461 	sym_op->m_src = ut_params->ibuf;
15462 
15463 	/* digest */
15464 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15465 			ut_params->ibuf, reference->digest.len);
15466 
15467 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15468 			"no room to append auth tag");
15469 
15470 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15471 			ut_params->ibuf, reference->plaintext.len);
15472 
15473 	if (auth_generate)
15474 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15475 	else
15476 		memcpy(sym_op->auth.digest.data,
15477 				reference->digest.data,
15478 				reference->digest.len);
15479 
15480 	debug_hexdump(stdout, "digest:",
15481 			sym_op->auth.digest.data,
15482 			reference->digest.len);
15483 
15484 	sym_op->auth.data.length = reference->plaintext.len;
15485 	sym_op->auth.data.offset = 0;
15486 
15487 	return 0;
15488 }
15489 
15490 static int
15491 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
15492 		struct crypto_unittest_params *ut_params,
15493 		const struct test_crypto_vector *reference,
15494 		unsigned int auth_generate)
15495 {
15496 	/* Generate Crypto op data structure */
15497 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15498 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15499 	TEST_ASSERT_NOT_NULL(ut_params->op,
15500 			"Failed to allocate pktmbuf offload");
15501 
15502 	/* Set crypto operation data parameters */
15503 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15504 
15505 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15506 
15507 	/* set crypto operation source mbuf */
15508 	sym_op->m_src = ut_params->ibuf;
15509 
15510 	/* digest */
15511 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15512 			ut_params->ibuf, reference->digest.len);
15513 
15514 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15515 			"no room to append auth tag");
15516 
15517 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15518 			ut_params->ibuf, reference->ciphertext.len);
15519 
15520 	if (auth_generate)
15521 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15522 	else
15523 		memcpy(sym_op->auth.digest.data,
15524 				reference->digest.data,
15525 				reference->digest.len);
15526 
15527 	debug_hexdump(stdout, "digest:",
15528 			sym_op->auth.digest.data,
15529 			reference->digest.len);
15530 
15531 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15532 			reference->iv.data, reference->iv.len);
15533 
15534 	sym_op->cipher.data.length = 0;
15535 	sym_op->cipher.data.offset = 0;
15536 
15537 	sym_op->auth.data.length = reference->plaintext.len;
15538 	sym_op->auth.data.offset = 0;
15539 
15540 	return 0;
15541 }
15542 
15543 static int
15544 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
15545 		struct crypto_unittest_params *ut_params,
15546 		const struct test_crypto_vector *reference,
15547 		unsigned int auth_generate)
15548 {
15549 	/* Generate Crypto op data structure */
15550 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15551 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15552 	TEST_ASSERT_NOT_NULL(ut_params->op,
15553 			"Failed to allocate pktmbuf offload");
15554 
15555 	/* Set crypto operation data parameters */
15556 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15557 
15558 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15559 
15560 	/* set crypto operation source mbuf */
15561 	sym_op->m_src = ut_params->ibuf;
15562 
15563 	/* digest */
15564 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15565 			ut_params->ibuf, reference->digest.len);
15566 
15567 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15568 			"no room to append auth tag");
15569 
15570 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15571 			ut_params->ibuf, reference->ciphertext.len);
15572 
15573 	if (auth_generate)
15574 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
15575 	else
15576 		memcpy(sym_op->auth.digest.data,
15577 				reference->digest.data,
15578 				reference->digest.len);
15579 
15580 	debug_hexdump(stdout, "digest:",
15581 			sym_op->auth.digest.data,
15582 			reference->digest.len);
15583 
15584 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15585 			reference->iv.data, reference->iv.len);
15586 
15587 	sym_op->cipher.data.length = reference->cipher_len;
15588 	sym_op->cipher.data.offset = reference->cipher_offset;
15589 
15590 	sym_op->auth.data.length = reference->plaintext.len;
15591 	sym_op->auth.data.offset = reference->auth_offset;
15592 
15593 	return 0;
15594 }
15595 
15596 static int
15597 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15598 		struct crypto_unittest_params *ut_params,
15599 		const struct test_crypto_vector *reference)
15600 {
15601 	return create_auth_operation(ts_params, ut_params, reference, 0);
15602 }
15603 
15604 static int
15605 create_auth_verify_GMAC_operation(
15606 		struct crypto_testsuite_params *ts_params,
15607 		struct crypto_unittest_params *ut_params,
15608 		const struct test_crypto_vector *reference)
15609 {
15610 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
15611 }
15612 
15613 static int
15614 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15615 		struct crypto_unittest_params *ut_params,
15616 		const struct test_crypto_vector *reference)
15617 {
15618 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
15619 }
15620 
15621 static int
15622 test_authentication_verify_fail_when_data_corruption(
15623 		struct crypto_testsuite_params *ts_params,
15624 		struct crypto_unittest_params *ut_params,
15625 		const struct test_crypto_vector *reference,
15626 		unsigned int data_corrupted)
15627 {
15628 	int retval;
15629 
15630 	uint8_t *plaintext;
15631 	struct rte_cryptodev_info dev_info;
15632 
15633 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15634 	uint64_t feat_flags = dev_info.feature_flags;
15635 
15636 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15637 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15638 		printf("Device doesn't support RAW data-path APIs.\n");
15639 		return TEST_SKIPPED;
15640 	}
15641 
15642 	/* Verify the capabilities */
15643 	struct rte_cryptodev_sym_capability_idx cap_idx;
15644 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15645 	cap_idx.algo.auth = reference->auth_algo;
15646 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15647 			&cap_idx) == NULL)
15648 		return TEST_SKIPPED;
15649 
15650 
15651 	/* Create session */
15652 	retval = create_auth_session(ut_params,
15653 			ts_params->valid_devs[0],
15654 			reference,
15655 			RTE_CRYPTO_AUTH_OP_VERIFY);
15656 
15657 	if (retval == TEST_SKIPPED)
15658 		return TEST_SKIPPED;
15659 	if (retval < 0)
15660 		return retval;
15661 
15662 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15663 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15664 			"Failed to allocate input buffer in mempool");
15665 
15666 	/* clear mbuf payload */
15667 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15668 			rte_pktmbuf_tailroom(ut_params->ibuf));
15669 
15670 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15671 			reference->plaintext.len);
15672 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15673 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15674 
15675 	debug_hexdump(stdout, "plaintext:", plaintext,
15676 		reference->plaintext.len);
15677 
15678 	/* Create operation */
15679 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
15680 
15681 	if (retval < 0)
15682 		return retval;
15683 
15684 	if (data_corrupted)
15685 		data_corruption(plaintext);
15686 	else
15687 		tag_corruption(plaintext, reference->plaintext.len);
15688 
15689 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15690 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15691 			ut_params->op);
15692 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15693 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15694 			"authentication not failed");
15695 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15696 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15697 					       0);
15698 		if (retval != TEST_SUCCESS)
15699 			return retval;
15700 	} else {
15701 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15702 			ut_params->op);
15703 	}
15704 	if (ut_params->op == NULL)
15705 		return 0;
15706 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
15707 		return 0;
15708 
15709 	return -1;
15710 }
15711 
15712 static int
15713 test_authentication_verify_GMAC_fail_when_corruption(
15714 		struct crypto_testsuite_params *ts_params,
15715 		struct crypto_unittest_params *ut_params,
15716 		const struct test_crypto_vector *reference,
15717 		unsigned int data_corrupted)
15718 {
15719 	int retval;
15720 	uint8_t *plaintext;
15721 	struct rte_cryptodev_info dev_info;
15722 
15723 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15724 	uint64_t feat_flags = dev_info.feature_flags;
15725 
15726 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15727 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15728 		printf("Device doesn't support RAW data-path APIs.\n");
15729 		return TEST_SKIPPED;
15730 	}
15731 
15732 	/* Verify the capabilities */
15733 	struct rte_cryptodev_sym_capability_idx cap_idx;
15734 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15735 	cap_idx.algo.auth = reference->auth_algo;
15736 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15737 			&cap_idx) == NULL)
15738 		return TEST_SKIPPED;
15739 
15740 	/* Create session */
15741 	retval = create_auth_cipher_session(ut_params,
15742 			ts_params->valid_devs[0],
15743 			reference,
15744 			RTE_CRYPTO_AUTH_OP_VERIFY,
15745 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
15746 	if (retval == TEST_SKIPPED)
15747 		return TEST_SKIPPED;
15748 	if (retval < 0)
15749 		return retval;
15750 
15751 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15752 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15753 			"Failed to allocate input buffer in mempool");
15754 
15755 	/* clear mbuf payload */
15756 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15757 			rte_pktmbuf_tailroom(ut_params->ibuf));
15758 
15759 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15760 			reference->plaintext.len);
15761 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15762 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15763 
15764 	debug_hexdump(stdout, "plaintext:", plaintext,
15765 		reference->plaintext.len);
15766 
15767 	/* Create operation */
15768 	retval = create_auth_verify_GMAC_operation(ts_params,
15769 			ut_params,
15770 			reference);
15771 
15772 	if (retval < 0)
15773 		return retval;
15774 
15775 	if (data_corrupted)
15776 		data_corruption(plaintext);
15777 	else
15778 		tag_corruption(plaintext, reference->aad.len);
15779 
15780 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15781 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15782 			ut_params->op);
15783 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15784 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15785 			"authentication not failed");
15786 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15787 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15788 					       0);
15789 		if (retval != TEST_SUCCESS)
15790 			return retval;
15791 	} else {
15792 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15793 			ut_params->op);
15794 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15795 	}
15796 
15797 	return 0;
15798 }
15799 
15800 static int
15801 test_authenticated_decryption_fail_when_corruption(
15802 		struct crypto_testsuite_params *ts_params,
15803 		struct crypto_unittest_params *ut_params,
15804 		const struct test_crypto_vector *reference,
15805 		unsigned int data_corrupted)
15806 {
15807 	int retval;
15808 
15809 	uint8_t *ciphertext;
15810 	struct rte_cryptodev_info dev_info;
15811 
15812 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15813 	uint64_t feat_flags = dev_info.feature_flags;
15814 
15815 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15816 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15817 		printf("Device doesn't support RAW data-path APIs.\n");
15818 		return TEST_SKIPPED;
15819 	}
15820 
15821 	/* Verify the capabilities */
15822 	struct rte_cryptodev_sym_capability_idx cap_idx;
15823 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15824 	cap_idx.algo.auth = reference->auth_algo;
15825 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15826 			&cap_idx) == NULL)
15827 		return TEST_SKIPPED;
15828 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15829 	cap_idx.algo.cipher = reference->crypto_algo;
15830 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15831 			&cap_idx) == NULL)
15832 		return TEST_SKIPPED;
15833 
15834 	/* Create session */
15835 	retval = create_auth_cipher_session(ut_params,
15836 			ts_params->valid_devs[0],
15837 			reference,
15838 			RTE_CRYPTO_AUTH_OP_VERIFY,
15839 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
15840 	if (retval == TEST_SKIPPED)
15841 		return TEST_SKIPPED;
15842 	if (retval < 0)
15843 		return retval;
15844 
15845 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15846 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15847 			"Failed to allocate input buffer in mempool");
15848 
15849 	/* clear mbuf payload */
15850 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15851 			rte_pktmbuf_tailroom(ut_params->ibuf));
15852 
15853 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15854 			reference->ciphertext.len);
15855 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
15856 	memcpy(ciphertext, reference->ciphertext.data,
15857 			reference->ciphertext.len);
15858 
15859 	/* Create operation */
15860 	retval = create_cipher_auth_verify_operation(ts_params,
15861 			ut_params,
15862 			reference);
15863 
15864 	if (retval < 0)
15865 		return retval;
15866 
15867 	if (data_corrupted)
15868 		data_corruption(ciphertext);
15869 	else
15870 		tag_corruption(ciphertext, reference->ciphertext.len);
15871 
15872 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15873 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15874 			ut_params->op);
15875 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15876 			RTE_CRYPTO_OP_STATUS_SUCCESS,
15877 			"authentication not failed");
15878 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15879 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15880 					       0);
15881 		if (retval != TEST_SUCCESS)
15882 			return retval;
15883 	} else {
15884 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15885 			ut_params->op);
15886 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15887 	}
15888 
15889 	return 0;
15890 }
15891 
15892 static int
15893 test_authenticated_encrypt_with_esn(
15894 		struct crypto_testsuite_params *ts_params,
15895 		struct crypto_unittest_params *ut_params,
15896 		const struct test_crypto_vector *reference)
15897 {
15898 	int retval;
15899 
15900 	uint8_t *authciphertext, *plaintext, *auth_tag;
15901 	uint16_t plaintext_pad_len;
15902 	uint8_t cipher_key[reference->cipher_key.len + 1];
15903 	uint8_t auth_key[reference->auth_key.len + 1];
15904 	struct rte_cryptodev_info dev_info;
15905 
15906 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15907 	uint64_t feat_flags = dev_info.feature_flags;
15908 
15909 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15910 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15911 		printf("Device doesn't support RAW data-path APIs.\n");
15912 		return TEST_SKIPPED;
15913 	}
15914 
15915 	/* Verify the capabilities */
15916 	struct rte_cryptodev_sym_capability_idx cap_idx;
15917 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15918 	cap_idx.algo.auth = reference->auth_algo;
15919 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15920 			&cap_idx) == NULL)
15921 		return TEST_SKIPPED;
15922 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15923 	cap_idx.algo.cipher = reference->crypto_algo;
15924 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15925 			&cap_idx) == NULL)
15926 		return TEST_SKIPPED;
15927 
15928 	/* Create session */
15929 	memcpy(cipher_key, reference->cipher_key.data,
15930 			reference->cipher_key.len);
15931 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15932 
15933 	/* Setup Cipher Parameters */
15934 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15935 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15936 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
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 	ut_params->cipher_xform.next = &ut_params->auth_xform;
15943 
15944 	/* Setup Authentication Parameters */
15945 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15946 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15947 	ut_params->auth_xform.auth.algo = reference->auth_algo;
15948 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15949 	ut_params->auth_xform.auth.key.data = auth_key;
15950 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
15951 	ut_params->auth_xform.next = NULL;
15952 
15953 	/* Create Crypto session*/
15954 	ut_params->sess = rte_cryptodev_sym_session_create(
15955 			ts_params->valid_devs[0], &ut_params->cipher_xform,
15956 			ts_params->session_mpool);
15957 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15958 		return TEST_SKIPPED;
15959 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15960 
15961 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15962 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15963 			"Failed to allocate input buffer in mempool");
15964 
15965 	/* clear mbuf payload */
15966 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15967 			rte_pktmbuf_tailroom(ut_params->ibuf));
15968 
15969 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15970 			reference->plaintext.len);
15971 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15972 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15973 
15974 	/* Create operation */
15975 	retval = create_cipher_auth_operation(ts_params,
15976 			ut_params,
15977 			reference, 0);
15978 
15979 	if (retval < 0)
15980 		return retval;
15981 
15982 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15983 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15984 			ut_params->op);
15985 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15986 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
15987 					       0);
15988 		if (retval != TEST_SUCCESS)
15989 			return retval;
15990 	} else
15991 		ut_params->op = process_crypto_request(
15992 			ts_params->valid_devs[0], ut_params->op);
15993 
15994 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
15995 
15996 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15997 			"crypto op processing failed");
15998 
15999 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16000 
16001 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16002 			ut_params->op->sym->auth.data.offset);
16003 	auth_tag = authciphertext + plaintext_pad_len;
16004 	debug_hexdump(stdout, "ciphertext:", authciphertext,
16005 			reference->ciphertext.len);
16006 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16007 
16008 	/* Validate obuf */
16009 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16010 			authciphertext,
16011 			reference->ciphertext.data,
16012 			reference->ciphertext.len,
16013 			"Ciphertext data not as expected");
16014 
16015 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16016 			auth_tag,
16017 			reference->digest.data,
16018 			reference->digest.len,
16019 			"Generated digest not as expected");
16020 
16021 	return TEST_SUCCESS;
16022 
16023 }
16024 
16025 static int
16026 test_authenticated_decrypt_with_esn(
16027 		struct crypto_testsuite_params *ts_params,
16028 		struct crypto_unittest_params *ut_params,
16029 		const struct test_crypto_vector *reference)
16030 {
16031 	int retval;
16032 
16033 	uint8_t *ciphertext;
16034 	uint8_t cipher_key[reference->cipher_key.len + 1];
16035 	uint8_t auth_key[reference->auth_key.len + 1];
16036 	struct rte_cryptodev_info dev_info;
16037 
16038 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16039 	uint64_t feat_flags = dev_info.feature_flags;
16040 
16041 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16042 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16043 		printf("Device doesn't support RAW data-path APIs.\n");
16044 		return TEST_SKIPPED;
16045 	}
16046 
16047 	/* Verify the capabilities */
16048 	struct rte_cryptodev_sym_capability_idx cap_idx;
16049 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16050 	cap_idx.algo.auth = reference->auth_algo;
16051 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16052 			&cap_idx) == NULL)
16053 		return TEST_SKIPPED;
16054 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16055 	cap_idx.algo.cipher = reference->crypto_algo;
16056 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16057 			&cap_idx) == NULL)
16058 		return TEST_SKIPPED;
16059 
16060 	/* Create session */
16061 	memcpy(cipher_key, reference->cipher_key.data,
16062 			reference->cipher_key.len);
16063 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16064 
16065 	/* Setup Authentication Parameters */
16066 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16067 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16068 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16069 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16070 	ut_params->auth_xform.auth.key.data = auth_key;
16071 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16072 	ut_params->auth_xform.next = &ut_params->cipher_xform;
16073 
16074 	/* Setup Cipher Parameters */
16075 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16076 	ut_params->cipher_xform.next = NULL;
16077 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16078 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16079 	ut_params->cipher_xform.cipher.key.data = cipher_key;
16080 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16081 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16082 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16083 
16084 	/* Create Crypto session*/
16085 	ut_params->sess = rte_cryptodev_sym_session_create(
16086 			ts_params->valid_devs[0], &ut_params->auth_xform,
16087 			ts_params->session_mpool);
16088 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16089 		return TEST_SKIPPED;
16090 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16091 
16092 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16093 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16094 			"Failed to allocate input buffer in mempool");
16095 
16096 	/* clear mbuf payload */
16097 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16098 			rte_pktmbuf_tailroom(ut_params->ibuf));
16099 
16100 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16101 			reference->ciphertext.len);
16102 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16103 	memcpy(ciphertext, reference->ciphertext.data,
16104 			reference->ciphertext.len);
16105 
16106 	/* Create operation */
16107 	retval = create_cipher_auth_verify_operation(ts_params,
16108 			ut_params,
16109 			reference);
16110 
16111 	if (retval < 0)
16112 		return retval;
16113 
16114 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16115 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16116 			ut_params->op);
16117 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16118 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16119 					       0);
16120 		if (retval != TEST_SUCCESS)
16121 			return retval;
16122 	} else
16123 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16124 			ut_params->op);
16125 
16126 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16127 	TEST_ASSERT_EQUAL(ut_params->op->status,
16128 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16129 			"crypto op processing passed");
16130 
16131 	ut_params->obuf = ut_params->op->sym->m_src;
16132 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16133 
16134 	return 0;
16135 }
16136 
16137 static int
16138 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16139 		const struct aead_test_data *tdata,
16140 		void *digest_mem, uint64_t digest_phys)
16141 {
16142 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16143 	struct crypto_unittest_params *ut_params = &unittest_params;
16144 
16145 	const unsigned int auth_tag_len = tdata->auth_tag.len;
16146 	const unsigned int iv_len = tdata->iv.len;
16147 	unsigned int aad_len = tdata->aad.len;
16148 	unsigned int aad_len_pad = 0;
16149 
16150 	/* Generate Crypto op data structure */
16151 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16152 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16153 	TEST_ASSERT_NOT_NULL(ut_params->op,
16154 		"Failed to allocate symmetric crypto operation struct");
16155 
16156 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16157 
16158 	sym_op->aead.digest.data = digest_mem;
16159 
16160 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
16161 			"no room to append digest");
16162 
16163 	sym_op->aead.digest.phys_addr = digest_phys;
16164 
16165 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
16166 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
16167 				auth_tag_len);
16168 		debug_hexdump(stdout, "digest:",
16169 				sym_op->aead.digest.data,
16170 				auth_tag_len);
16171 	}
16172 
16173 	/* Append aad data */
16174 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
16175 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16176 				uint8_t *, IV_OFFSET);
16177 
16178 		/* Copy IV 1 byte after the IV pointer, according to the API */
16179 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
16180 
16181 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
16182 
16183 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16184 				ut_params->ibuf, aad_len);
16185 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16186 				"no room to prepend aad");
16187 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16188 				ut_params->ibuf);
16189 
16190 		memset(sym_op->aead.aad.data, 0, aad_len);
16191 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
16192 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16193 
16194 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16195 		debug_hexdump(stdout, "aad:",
16196 				sym_op->aead.aad.data, aad_len);
16197 	} else {
16198 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16199 				uint8_t *, IV_OFFSET);
16200 
16201 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
16202 
16203 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
16204 
16205 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16206 				ut_params->ibuf, aad_len_pad);
16207 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16208 				"no room to prepend aad");
16209 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16210 				ut_params->ibuf);
16211 
16212 		memset(sym_op->aead.aad.data, 0, aad_len);
16213 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16214 
16215 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16216 		debug_hexdump(stdout, "aad:",
16217 				sym_op->aead.aad.data, aad_len);
16218 	}
16219 
16220 	sym_op->aead.data.length = tdata->plaintext.len;
16221 	sym_op->aead.data.offset = aad_len_pad;
16222 
16223 	return 0;
16224 }
16225 
16226 #define SGL_MAX_NO	16
16227 
16228 static int
16229 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
16230 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
16231 {
16232 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16233 	struct crypto_unittest_params *ut_params = &unittest_params;
16234 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
16235 	int retval;
16236 	int to_trn = 0;
16237 	int to_trn_tbl[SGL_MAX_NO];
16238 	int segs = 1;
16239 	unsigned int trn_data = 0;
16240 	uint8_t *plaintext, *ciphertext, *auth_tag;
16241 	struct rte_cryptodev_info dev_info;
16242 
16243 	/* Verify the capabilities */
16244 	struct rte_cryptodev_sym_capability_idx cap_idx;
16245 	const struct rte_cryptodev_symmetric_capability *capability;
16246 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
16247 	cap_idx.algo.aead = tdata->algo;
16248 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
16249 	if (capability == NULL)
16250 		return TEST_SKIPPED;
16251 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
16252 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
16253 		return TEST_SKIPPED;
16254 
16255 	/*
16256 	 * SGL not supported on AESNI_MB PMD CPU crypto,
16257 	 * OOP not supported on AESNI_GCM CPU crypto
16258 	 */
16259 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
16260 			(gbl_driver_id == rte_cryptodev_driver_id_get(
16261 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
16262 		return TEST_SKIPPED;
16263 
16264 	/* Detailed check for the particular SGL support flag */
16265 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16266 	if (!oop) {
16267 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
16268 		if (sgl_in && (!(dev_info.feature_flags &
16269 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
16270 			return TEST_SKIPPED;
16271 
16272 		uint64_t feat_flags = dev_info.feature_flags;
16273 
16274 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16275 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16276 			printf("Device doesn't support RAW data-path APIs.\n");
16277 			return TEST_SKIPPED;
16278 		}
16279 	} else {
16280 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
16281 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
16282 				tdata->plaintext.len;
16283 		/* Raw data path API does not support OOP */
16284 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
16285 			return TEST_SKIPPED;
16286 		if (sgl_in && !sgl_out) {
16287 			if (!(dev_info.feature_flags &
16288 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
16289 				return TEST_SKIPPED;
16290 		} else if (!sgl_in && sgl_out) {
16291 			if (!(dev_info.feature_flags &
16292 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
16293 				return TEST_SKIPPED;
16294 		} else if (sgl_in && sgl_out) {
16295 			if (!(dev_info.feature_flags &
16296 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
16297 				return TEST_SKIPPED;
16298 		}
16299 	}
16300 
16301 	if (fragsz > tdata->plaintext.len)
16302 		fragsz = tdata->plaintext.len;
16303 
16304 	uint16_t plaintext_len = fragsz;
16305 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
16306 
16307 	if (fragsz_oop > tdata->plaintext.len)
16308 		frag_size_oop = tdata->plaintext.len;
16309 
16310 	int ecx = 0;
16311 	void *digest_mem = NULL;
16312 
16313 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
16314 
16315 	if (tdata->plaintext.len % fragsz != 0) {
16316 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
16317 			return 1;
16318 	}	else {
16319 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
16320 			return 1;
16321 	}
16322 
16323 	/*
16324 	 * For out-op-place we need to alloc another mbuf
16325 	 */
16326 	if (oop) {
16327 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16328 		rte_pktmbuf_append(ut_params->obuf,
16329 				frag_size_oop + prepend_len);
16330 		buf_oop = ut_params->obuf;
16331 	}
16332 
16333 	/* Create AEAD session */
16334 	retval = create_aead_session(ts_params->valid_devs[0],
16335 			tdata->algo,
16336 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
16337 			tdata->key.data, tdata->key.len,
16338 			tdata->aad.len, tdata->auth_tag.len,
16339 			tdata->iv.len);
16340 	if (retval < 0)
16341 		return retval;
16342 
16343 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16344 
16345 	/* clear mbuf payload */
16346 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16347 			rte_pktmbuf_tailroom(ut_params->ibuf));
16348 
16349 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16350 			plaintext_len);
16351 
16352 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
16353 
16354 	trn_data += plaintext_len;
16355 
16356 	buf = ut_params->ibuf;
16357 
16358 	/*
16359 	 * Loop until no more fragments
16360 	 */
16361 
16362 	while (trn_data < tdata->plaintext.len) {
16363 		++segs;
16364 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
16365 				(tdata->plaintext.len - trn_data) : fragsz;
16366 
16367 		to_trn_tbl[ecx++] = to_trn;
16368 
16369 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16370 		buf = buf->next;
16371 
16372 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
16373 				rte_pktmbuf_tailroom(buf));
16374 
16375 		/* OOP */
16376 		if (oop && !fragsz_oop) {
16377 			buf_last_oop = buf_oop->next =
16378 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
16379 			buf_oop = buf_oop->next;
16380 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16381 					0, rte_pktmbuf_tailroom(buf_oop));
16382 			rte_pktmbuf_append(buf_oop, to_trn);
16383 		}
16384 
16385 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
16386 				to_trn);
16387 
16388 		memcpy(plaintext, tdata->plaintext.data + trn_data,
16389 				to_trn);
16390 		trn_data += to_trn;
16391 		if (trn_data  == tdata->plaintext.len) {
16392 			if (oop) {
16393 				if (!fragsz_oop)
16394 					digest_mem = rte_pktmbuf_append(buf_oop,
16395 						tdata->auth_tag.len);
16396 			} else
16397 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
16398 					tdata->auth_tag.len);
16399 		}
16400 	}
16401 
16402 	uint64_t digest_phys = 0;
16403 
16404 	ut_params->ibuf->nb_segs = segs;
16405 
16406 	segs = 1;
16407 	if (fragsz_oop && oop) {
16408 		to_trn = 0;
16409 		ecx = 0;
16410 
16411 		if (frag_size_oop == tdata->plaintext.len) {
16412 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
16413 				tdata->auth_tag.len);
16414 
16415 			digest_phys = rte_pktmbuf_iova_offset(
16416 					ut_params->obuf,
16417 					tdata->plaintext.len + prepend_len);
16418 		}
16419 
16420 		trn_data = frag_size_oop;
16421 		while (trn_data < tdata->plaintext.len) {
16422 			++segs;
16423 			to_trn =
16424 				(tdata->plaintext.len - trn_data <
16425 						frag_size_oop) ?
16426 				(tdata->plaintext.len - trn_data) :
16427 						frag_size_oop;
16428 
16429 			to_trn_tbl[ecx++] = to_trn;
16430 
16431 			buf_last_oop = buf_oop->next =
16432 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
16433 			buf_oop = buf_oop->next;
16434 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16435 					0, rte_pktmbuf_tailroom(buf_oop));
16436 			rte_pktmbuf_append(buf_oop, to_trn);
16437 
16438 			trn_data += to_trn;
16439 
16440 			if (trn_data  == tdata->plaintext.len) {
16441 				digest_mem = rte_pktmbuf_append(buf_oop,
16442 					tdata->auth_tag.len);
16443 			}
16444 		}
16445 
16446 		ut_params->obuf->nb_segs = segs;
16447 	}
16448 
16449 	/*
16450 	 * Place digest at the end of the last buffer
16451 	 */
16452 	if (!digest_phys)
16453 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
16454 	if (oop && buf_last_oop)
16455 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
16456 
16457 	if (!digest_mem && !oop) {
16458 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16459 				+ tdata->auth_tag.len);
16460 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
16461 				tdata->plaintext.len);
16462 	}
16463 
16464 	/* Create AEAD operation */
16465 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
16466 			tdata, digest_mem, digest_phys);
16467 
16468 	if (retval < 0)
16469 		return retval;
16470 
16471 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16472 
16473 	ut_params->op->sym->m_src = ut_params->ibuf;
16474 	if (oop)
16475 		ut_params->op->sym->m_dst = ut_params->obuf;
16476 
16477 	/* Process crypto operation */
16478 	if (oop == IN_PLACE &&
16479 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16480 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
16481 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16482 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
16483 					       0);
16484 		if (retval != TEST_SUCCESS)
16485 			return retval;
16486 	} else
16487 		TEST_ASSERT_NOT_NULL(
16488 			process_crypto_request(ts_params->valid_devs[0],
16489 			ut_params->op), "failed to process sym crypto op");
16490 
16491 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16492 			"crypto op processing failed");
16493 
16494 
16495 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
16496 			uint8_t *, prepend_len);
16497 	if (oop) {
16498 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
16499 				uint8_t *, prepend_len);
16500 	}
16501 
16502 	if (fragsz_oop)
16503 		fragsz = fragsz_oop;
16504 
16505 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16506 			ciphertext,
16507 			tdata->ciphertext.data,
16508 			fragsz,
16509 			"Ciphertext data not as expected");
16510 
16511 	buf = ut_params->op->sym->m_src->next;
16512 	if (oop)
16513 		buf = ut_params->op->sym->m_dst->next;
16514 
16515 	unsigned int off = fragsz;
16516 
16517 	ecx = 0;
16518 	while (buf) {
16519 		ciphertext = rte_pktmbuf_mtod(buf,
16520 				uint8_t *);
16521 
16522 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
16523 				ciphertext,
16524 				tdata->ciphertext.data + off,
16525 				to_trn_tbl[ecx],
16526 				"Ciphertext data not as expected");
16527 
16528 		off += to_trn_tbl[ecx++];
16529 		buf = buf->next;
16530 	}
16531 
16532 	auth_tag = digest_mem;
16533 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16534 			auth_tag,
16535 			tdata->auth_tag.data,
16536 			tdata->auth_tag.len,
16537 			"Generated auth tag not as expected");
16538 
16539 	return 0;
16540 }
16541 
16542 static int
16543 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
16544 {
16545 	return test_authenticated_encryption_SGL(
16546 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
16547 }
16548 
16549 static int
16550 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
16551 {
16552 	return test_authenticated_encryption_SGL(
16553 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
16554 }
16555 
16556 static int
16557 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
16558 {
16559 	return test_authenticated_encryption_SGL(
16560 			&gcm_test_case_8, OUT_OF_PLACE, 400,
16561 			gcm_test_case_8.plaintext.len);
16562 }
16563 
16564 static int
16565 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
16566 {
16567 	/* This test is not for OPENSSL PMD */
16568 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
16569 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
16570 		return TEST_SKIPPED;
16571 
16572 	return test_authenticated_encryption_SGL(
16573 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
16574 }
16575 
16576 static int
16577 test_authentication_verify_fail_when_data_corrupted(
16578 		struct crypto_testsuite_params *ts_params,
16579 		struct crypto_unittest_params *ut_params,
16580 		const struct test_crypto_vector *reference)
16581 {
16582 	return test_authentication_verify_fail_when_data_corruption(
16583 			ts_params, ut_params, reference, 1);
16584 }
16585 
16586 static int
16587 test_authentication_verify_fail_when_tag_corrupted(
16588 		struct crypto_testsuite_params *ts_params,
16589 		struct crypto_unittest_params *ut_params,
16590 		const struct test_crypto_vector *reference)
16591 {
16592 	return test_authentication_verify_fail_when_data_corruption(
16593 			ts_params, ut_params, reference, 0);
16594 }
16595 
16596 static int
16597 test_authentication_verify_GMAC_fail_when_data_corrupted(
16598 		struct crypto_testsuite_params *ts_params,
16599 		struct crypto_unittest_params *ut_params,
16600 		const struct test_crypto_vector *reference)
16601 {
16602 	return test_authentication_verify_GMAC_fail_when_corruption(
16603 			ts_params, ut_params, reference, 1);
16604 }
16605 
16606 static int
16607 test_authentication_verify_GMAC_fail_when_tag_corrupted(
16608 		struct crypto_testsuite_params *ts_params,
16609 		struct crypto_unittest_params *ut_params,
16610 		const struct test_crypto_vector *reference)
16611 {
16612 	return test_authentication_verify_GMAC_fail_when_corruption(
16613 			ts_params, ut_params, reference, 0);
16614 }
16615 
16616 static int
16617 test_authenticated_decryption_fail_when_data_corrupted(
16618 		struct crypto_testsuite_params *ts_params,
16619 		struct crypto_unittest_params *ut_params,
16620 		const struct test_crypto_vector *reference)
16621 {
16622 	return test_authenticated_decryption_fail_when_corruption(
16623 			ts_params, ut_params, reference, 1);
16624 }
16625 
16626 static int
16627 test_authenticated_decryption_fail_when_tag_corrupted(
16628 		struct crypto_testsuite_params *ts_params,
16629 		struct crypto_unittest_params *ut_params,
16630 		const struct test_crypto_vector *reference)
16631 {
16632 	return test_authenticated_decryption_fail_when_corruption(
16633 			ts_params, ut_params, reference, 0);
16634 }
16635 
16636 static int
16637 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
16638 {
16639 	return test_authentication_verify_fail_when_data_corrupted(
16640 			&testsuite_params, &unittest_params,
16641 			&hmac_sha1_test_crypto_vector);
16642 }
16643 
16644 static int
16645 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
16646 {
16647 	return test_authentication_verify_fail_when_tag_corrupted(
16648 			&testsuite_params, &unittest_params,
16649 			&hmac_sha1_test_crypto_vector);
16650 }
16651 
16652 static int
16653 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
16654 {
16655 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
16656 			&testsuite_params, &unittest_params,
16657 			&aes128_gmac_test_vector);
16658 }
16659 
16660 static int
16661 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
16662 {
16663 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
16664 			&testsuite_params, &unittest_params,
16665 			&aes128_gmac_test_vector);
16666 }
16667 
16668 static int
16669 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
16670 {
16671 	return test_authenticated_decryption_fail_when_data_corrupted(
16672 			&testsuite_params,
16673 			&unittest_params,
16674 			&aes128cbc_hmac_sha1_test_vector);
16675 }
16676 
16677 static int
16678 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
16679 {
16680 	return test_authenticated_decryption_fail_when_tag_corrupted(
16681 			&testsuite_params,
16682 			&unittest_params,
16683 			&aes128cbc_hmac_sha1_test_vector);
16684 }
16685 
16686 static int
16687 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16688 {
16689 	return test_authenticated_encrypt_with_esn(
16690 			&testsuite_params,
16691 			&unittest_params,
16692 			&aes128cbc_hmac_sha1_aad_test_vector);
16693 }
16694 
16695 static int
16696 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16697 {
16698 	return test_authenticated_decrypt_with_esn(
16699 			&testsuite_params,
16700 			&unittest_params,
16701 			&aes128cbc_hmac_sha1_aad_test_vector);
16702 }
16703 
16704 static int
16705 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
16706 {
16707 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
16708 }
16709 
16710 static int
16711 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
16712 {
16713 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
16714 }
16715 
16716 static int
16717 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
16718 {
16719 	return test_authenticated_encryption_SGL(
16720 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
16721 		chacha20_poly1305_case_2.plaintext.len);
16722 }
16723 
16724 #ifdef RTE_CRYPTO_SCHEDULER
16725 
16726 /* global AESNI worker IDs for the scheduler test */
16727 uint8_t aesni_ids[2];
16728 
16729 static int
16730 scheduler_testsuite_setup(void)
16731 {
16732 	uint32_t i = 0;
16733 	int32_t nb_devs, ret;
16734 	char vdev_args[VDEV_ARGS_SIZE] = {""};
16735 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
16736 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
16737 	uint16_t worker_core_count = 0;
16738 	uint16_t socket_id = 0;
16739 
16740 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
16741 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
16742 
16743 		/* Identify the Worker Cores
16744 		 * Use 2 worker cores for the device args
16745 		 */
16746 		RTE_LCORE_FOREACH_WORKER(i) {
16747 			if (worker_core_count > 1)
16748 				break;
16749 			snprintf(vdev_args, sizeof(vdev_args),
16750 					"%s%d", temp_str, i);
16751 			strcpy(temp_str, vdev_args);
16752 			strlcat(temp_str, ";", sizeof(temp_str));
16753 			worker_core_count++;
16754 			socket_id = rte_lcore_to_socket_id(i);
16755 		}
16756 		if (worker_core_count != 2) {
16757 			RTE_LOG(ERR, USER1,
16758 				"Cryptodev scheduler test require at least "
16759 				"two worker cores to run. "
16760 				"Please use the correct coremask.\n");
16761 			return TEST_FAILED;
16762 		}
16763 		strcpy(temp_str, vdev_args);
16764 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
16765 				temp_str, socket_id);
16766 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
16767 		nb_devs = rte_cryptodev_device_count_by_driver(
16768 				rte_cryptodev_driver_id_get(
16769 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
16770 		if (nb_devs < 1) {
16771 			ret = rte_vdev_init(
16772 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
16773 					vdev_args);
16774 			TEST_ASSERT(ret == 0,
16775 				"Failed to create instance %u of pmd : %s",
16776 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16777 		}
16778 	}
16779 	return testsuite_setup();
16780 }
16781 
16782 static int
16783 test_scheduler_attach_worker_op(void)
16784 {
16785 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16786 	uint8_t sched_id = ts_params->valid_devs[0];
16787 	uint32_t i, nb_devs_attached = 0;
16788 	int ret;
16789 	char vdev_name[32];
16790 	unsigned int count = rte_cryptodev_count();
16791 
16792 	/* create 2 AESNI_MB vdevs on top of existing devices */
16793 	for (i = count; i < count + 2; i++) {
16794 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
16795 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
16796 				i);
16797 		ret = rte_vdev_init(vdev_name, NULL);
16798 
16799 		TEST_ASSERT(ret == 0,
16800 			"Failed to create instance %u of"
16801 			" pmd : %s",
16802 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16803 
16804 		if (ret < 0) {
16805 			RTE_LOG(ERR, USER1,
16806 				"Failed to create 2 AESNI MB PMDs.\n");
16807 			return TEST_SKIPPED;
16808 		}
16809 	}
16810 
16811 	/* attach 2 AESNI_MB cdevs */
16812 	for (i = count; i < count + 2; i++) {
16813 		struct rte_cryptodev_info info;
16814 		unsigned int session_size;
16815 
16816 		rte_cryptodev_info_get(i, &info);
16817 		if (info.driver_id != rte_cryptodev_driver_id_get(
16818 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
16819 			continue;
16820 
16821 		session_size = rte_cryptodev_sym_get_private_session_size(i);
16822 		/*
16823 		 * Create the session mempool again, since now there are new devices
16824 		 * to use the mempool.
16825 		 */
16826 		if (ts_params->session_mpool) {
16827 			rte_mempool_free(ts_params->session_mpool);
16828 			ts_params->session_mpool = NULL;
16829 		}
16830 
16831 		if (info.sym.max_nb_sessions != 0 &&
16832 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
16833 			RTE_LOG(ERR, USER1,
16834 					"Device does not support "
16835 					"at least %u sessions\n",
16836 					MAX_NB_SESSIONS);
16837 			return TEST_FAILED;
16838 		}
16839 		/*
16840 		 * Create mempool with maximum number of sessions,
16841 		 * to include the session headers
16842 		 */
16843 		if (ts_params->session_mpool == NULL) {
16844 			ts_params->session_mpool =
16845 				rte_cryptodev_sym_session_pool_create(
16846 						"test_sess_mp",
16847 						MAX_NB_SESSIONS, session_size,
16848 						0, 0, SOCKET_ID_ANY);
16849 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
16850 					"session mempool allocation failed");
16851 		}
16852 
16853 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
16854 
16855 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
16856 				(uint8_t)i);
16857 
16858 		TEST_ASSERT(ret == 0,
16859 			"Failed to attach device %u of pmd : %s", i,
16860 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16861 
16862 		aesni_ids[nb_devs_attached] = (uint8_t)i;
16863 
16864 		nb_devs_attached++;
16865 	}
16866 
16867 	return 0;
16868 }
16869 
16870 static int
16871 test_scheduler_detach_worker_op(void)
16872 {
16873 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16874 	uint8_t sched_id = ts_params->valid_devs[0];
16875 	uint32_t i;
16876 	int ret;
16877 
16878 	for (i = 0; i < 2; i++) {
16879 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
16880 				aesni_ids[i]);
16881 		TEST_ASSERT(ret == 0,
16882 			"Failed to detach device %u", aesni_ids[i]);
16883 	}
16884 
16885 	return 0;
16886 }
16887 
16888 static int
16889 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
16890 {
16891 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16892 	uint8_t sched_id = ts_params->valid_devs[0];
16893 	/* set mode */
16894 	return rte_cryptodev_scheduler_mode_set(sched_id,
16895 		scheduler_mode);
16896 }
16897 
16898 static int
16899 test_scheduler_mode_roundrobin_op(void)
16900 {
16901 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
16902 			0, "Failed to set roundrobin mode");
16903 	return 0;
16904 
16905 }
16906 
16907 static int
16908 test_scheduler_mode_multicore_op(void)
16909 {
16910 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
16911 			0, "Failed to set multicore mode");
16912 
16913 	return 0;
16914 }
16915 
16916 static int
16917 test_scheduler_mode_failover_op(void)
16918 {
16919 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
16920 			0, "Failed to set failover mode");
16921 
16922 	return 0;
16923 }
16924 
16925 static int
16926 test_scheduler_mode_pkt_size_distr_op(void)
16927 {
16928 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
16929 			0, "Failed to set pktsize mode");
16930 
16931 	return 0;
16932 }
16933 
16934 static int
16935 scheduler_multicore_testsuite_setup(void)
16936 {
16937 	if (test_scheduler_attach_worker_op() < 0)
16938 		return TEST_SKIPPED;
16939 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
16940 		return TEST_SKIPPED;
16941 	return 0;
16942 }
16943 
16944 static int
16945 scheduler_roundrobin_testsuite_setup(void)
16946 {
16947 	if (test_scheduler_attach_worker_op() < 0)
16948 		return TEST_SKIPPED;
16949 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
16950 		return TEST_SKIPPED;
16951 	return 0;
16952 }
16953 
16954 static int
16955 scheduler_failover_testsuite_setup(void)
16956 {
16957 	if (test_scheduler_attach_worker_op() < 0)
16958 		return TEST_SKIPPED;
16959 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
16960 		return TEST_SKIPPED;
16961 	return 0;
16962 }
16963 
16964 static int
16965 scheduler_pkt_size_distr_testsuite_setup(void)
16966 {
16967 	if (test_scheduler_attach_worker_op() < 0)
16968 		return TEST_SKIPPED;
16969 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
16970 		return TEST_SKIPPED;
16971 	return 0;
16972 }
16973 
16974 static void
16975 scheduler_mode_testsuite_teardown(void)
16976 {
16977 	test_scheduler_detach_worker_op();
16978 }
16979 
16980 #endif /* RTE_CRYPTO_SCHEDULER */
16981 
16982 static struct unit_test_suite end_testsuite = {
16983 	.suite_name = NULL,
16984 	.setup = NULL,
16985 	.teardown = NULL,
16986 	.unit_test_suites = NULL
16987 };
16988 
16989 #ifdef RTE_LIB_SECURITY
16990 static struct unit_test_suite ipsec_proto_testsuite  = {
16991 	.suite_name = "IPsec Proto Unit Test Suite",
16992 	.setup = ipsec_proto_testsuite_setup,
16993 	.unit_test_cases = {
16994 		TEST_CASE_NAMED_WITH_DATA(
16995 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
16996 			ut_setup_security, ut_teardown,
16997 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
16998 		TEST_CASE_NAMED_WITH_DATA(
16999 			"Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17000 			ut_setup_security, ut_teardown,
17001 			test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17002 		TEST_CASE_NAMED_WITH_DATA(
17003 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17004 			ut_setup_security, ut_teardown,
17005 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17006 		TEST_CASE_NAMED_WITH_DATA(
17007 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17008 			ut_setup_security, ut_teardown,
17009 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17010 		TEST_CASE_NAMED_WITH_DATA(
17011 			"Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17012 			ut_setup_security, ut_teardown,
17013 			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17014 		TEST_CASE_NAMED_WITH_DATA(
17015 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17016 			ut_setup_security, ut_teardown,
17017 			test_ipsec_proto_known_vec,
17018 			&pkt_aes_128_cbc_md5),
17019 		TEST_CASE_NAMED_WITH_DATA(
17020 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17021 			ut_setup_security, ut_teardown,
17022 			test_ipsec_proto_known_vec,
17023 			&pkt_aes_128_cbc_hmac_sha256),
17024 		TEST_CASE_NAMED_WITH_DATA(
17025 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17026 			ut_setup_security, ut_teardown,
17027 			test_ipsec_proto_known_vec,
17028 			&pkt_aes_128_cbc_hmac_sha384),
17029 		TEST_CASE_NAMED_WITH_DATA(
17030 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17031 			ut_setup_security, ut_teardown,
17032 			test_ipsec_proto_known_vec,
17033 			&pkt_aes_128_cbc_hmac_sha512),
17034 		TEST_CASE_NAMED_WITH_DATA(
17035 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17036 			ut_setup_security, ut_teardown,
17037 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
17038 		TEST_CASE_NAMED_WITH_DATA(
17039 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17040 			ut_setup_security, ut_teardown,
17041 			test_ipsec_proto_known_vec,
17042 			&pkt_aes_128_cbc_hmac_sha256_v6),
17043 		TEST_CASE_NAMED_WITH_DATA(
17044 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17045 			ut_setup_security, ut_teardown,
17046 			test_ipsec_proto_known_vec,
17047 			&pkt_null_aes_xcbc),
17048 		TEST_CASE_NAMED_WITH_DATA(
17049 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17050 			ut_setup_security, ut_teardown,
17051 			test_ipsec_proto_known_vec,
17052 			&pkt_des_cbc_hmac_sha256),
17053 		TEST_CASE_NAMED_WITH_DATA(
17054 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17055 			ut_setup_security, ut_teardown,
17056 			test_ipsec_proto_known_vec,
17057 			&pkt_des_cbc_hmac_sha384),
17058 		TEST_CASE_NAMED_WITH_DATA(
17059 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17060 			ut_setup_security, ut_teardown,
17061 			test_ipsec_proto_known_vec,
17062 			&pkt_des_cbc_hmac_sha512),
17063 		TEST_CASE_NAMED_WITH_DATA(
17064 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17065 			ut_setup_security, ut_teardown,
17066 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
17067 		TEST_CASE_NAMED_WITH_DATA(
17068 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17069 			ut_setup_security, ut_teardown,
17070 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
17071 		TEST_CASE_NAMED_WITH_DATA(
17072 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17073 			ut_setup_security, ut_teardown,
17074 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
17075 		TEST_CASE_NAMED_WITH_DATA(
17076 			"Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17077 			ut_setup_security, ut_teardown,
17078 			test_ipsec_proto_known_vec,
17079 			&pkt_des_cbc_hmac_sha256_v6),
17080 		TEST_CASE_NAMED_WITH_DATA(
17081 			"Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17082 			ut_setup_security, ut_teardown,
17083 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
17084 		TEST_CASE_NAMED_WITH_DATA(
17085 			"Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17086 			ut_setup_security, ut_teardown,
17087 			test_ipsec_proto_known_vec,
17088 			&pkt_ah_tunnel_sha256),
17089 		TEST_CASE_NAMED_WITH_DATA(
17090 			"Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17091 			ut_setup_security, ut_teardown,
17092 			test_ipsec_proto_known_vec,
17093 			&pkt_ah_transport_sha256),
17094 		TEST_CASE_NAMED_WITH_DATA(
17095 			"Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17096 			ut_setup_security, ut_teardown,
17097 			test_ipsec_proto_known_vec,
17098 			&pkt_ah_ipv4_aes_gmac_128),
17099 		TEST_CASE_NAMED_WITH_DATA(
17100 			"Outbound fragmented packet",
17101 			ut_setup_security, ut_teardown,
17102 			test_ipsec_proto_known_vec_fragmented,
17103 			&pkt_aes_128_gcm_frag),
17104 		TEST_CASE_NAMED_WITH_DATA(
17105 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17106 			ut_setup_security, ut_teardown,
17107 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
17108 		TEST_CASE_NAMED_WITH_DATA(
17109 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17110 			ut_setup_security, ut_teardown,
17111 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
17112 		TEST_CASE_NAMED_WITH_DATA(
17113 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17114 			ut_setup_security, ut_teardown,
17115 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
17116 		TEST_CASE_NAMED_WITH_DATA(
17117 			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17118 			ut_setup_security, ut_teardown,
17119 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
17120 		TEST_CASE_NAMED_WITH_DATA(
17121 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
17122 			ut_setup_security, ut_teardown,
17123 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
17124 		TEST_CASE_NAMED_WITH_DATA(
17125 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17126 			ut_setup_security, ut_teardown,
17127 			test_ipsec_proto_known_vec_inb,
17128 			&pkt_aes_128_cbc_md5),
17129 		TEST_CASE_NAMED_WITH_DATA(
17130 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17131 			ut_setup_security, ut_teardown,
17132 			test_ipsec_proto_known_vec_inb,
17133 			&pkt_aes_128_cbc_hmac_sha256),
17134 		TEST_CASE_NAMED_WITH_DATA(
17135 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17136 			ut_setup_security, ut_teardown,
17137 			test_ipsec_proto_known_vec_inb,
17138 			&pkt_aes_128_cbc_hmac_sha384),
17139 		TEST_CASE_NAMED_WITH_DATA(
17140 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17141 			ut_setup_security, ut_teardown,
17142 			test_ipsec_proto_known_vec_inb,
17143 			&pkt_aes_128_cbc_hmac_sha512),
17144 		TEST_CASE_NAMED_WITH_DATA(
17145 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17146 			ut_setup_security, ut_teardown,
17147 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
17148 		TEST_CASE_NAMED_WITH_DATA(
17149 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17150 			ut_setup_security, ut_teardown,
17151 			test_ipsec_proto_known_vec_inb,
17152 			&pkt_aes_128_cbc_hmac_sha256_v6),
17153 		TEST_CASE_NAMED_WITH_DATA(
17154 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17155 			ut_setup_security, ut_teardown,
17156 			test_ipsec_proto_known_vec_inb,
17157 			&pkt_null_aes_xcbc),
17158 		TEST_CASE_NAMED_WITH_DATA(
17159 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17160 			ut_setup_security, ut_teardown,
17161 			test_ipsec_proto_known_vec_inb,
17162 			&pkt_des_cbc_hmac_sha256),
17163 		TEST_CASE_NAMED_WITH_DATA(
17164 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17165 			ut_setup_security, ut_teardown,
17166 			test_ipsec_proto_known_vec_inb,
17167 			&pkt_des_cbc_hmac_sha384),
17168 		TEST_CASE_NAMED_WITH_DATA(
17169 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17170 			ut_setup_security, ut_teardown,
17171 			test_ipsec_proto_known_vec_inb,
17172 			&pkt_des_cbc_hmac_sha512),
17173 		TEST_CASE_NAMED_WITH_DATA(
17174 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17175 			ut_setup_security, ut_teardown,
17176 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
17177 		TEST_CASE_NAMED_WITH_DATA(
17178 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17179 			ut_setup_security, ut_teardown,
17180 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
17181 		TEST_CASE_NAMED_WITH_DATA(
17182 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17183 			ut_setup_security, ut_teardown,
17184 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
17185 		TEST_CASE_NAMED_WITH_DATA(
17186 			"Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17187 			ut_setup_security, ut_teardown,
17188 			test_ipsec_proto_known_vec_inb,
17189 			&pkt_des_cbc_hmac_sha256_v6),
17190 		TEST_CASE_NAMED_WITH_DATA(
17191 			"Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17192 			ut_setup_security, ut_teardown,
17193 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
17194 		TEST_CASE_NAMED_WITH_DATA(
17195 			"Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17196 			ut_setup_security, ut_teardown,
17197 			test_ipsec_proto_known_vec_inb,
17198 			&pkt_ah_tunnel_sha256),
17199 		TEST_CASE_NAMED_WITH_DATA(
17200 			"Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17201 			ut_setup_security, ut_teardown,
17202 			test_ipsec_proto_known_vec_inb,
17203 			&pkt_ah_transport_sha256),
17204 		TEST_CASE_NAMED_WITH_DATA(
17205 			"Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17206 			ut_setup_security, ut_teardown,
17207 			test_ipsec_proto_known_vec_inb,
17208 			&pkt_ah_ipv4_aes_gmac_128),
17209 		TEST_CASE_NAMED_ST(
17210 			"Combined test alg list",
17211 			ut_setup_security, ut_teardown,
17212 			test_ipsec_proto_display_list),
17213 		TEST_CASE_NAMED_ST(
17214 			"Combined test alg list (AH)",
17215 			ut_setup_security, ut_teardown,
17216 			test_ipsec_proto_ah_tunnel_ipv4),
17217 		TEST_CASE_NAMED_ST(
17218 			"IV generation",
17219 			ut_setup_security, ut_teardown,
17220 			test_ipsec_proto_iv_gen),
17221 		TEST_CASE_NAMED_ST(
17222 			"UDP encapsulation",
17223 			ut_setup_security, ut_teardown,
17224 			test_ipsec_proto_udp_encap),
17225 		TEST_CASE_NAMED_ST(
17226 			"UDP encapsulation with custom ports",
17227 			ut_setup_security, ut_teardown,
17228 			test_ipsec_proto_udp_encap_custom_ports),
17229 		TEST_CASE_NAMED_ST(
17230 			"UDP encapsulation ports verification test",
17231 			ut_setup_security, ut_teardown,
17232 			test_ipsec_proto_udp_ports_verify),
17233 		TEST_CASE_NAMED_ST(
17234 			"SA expiry packets soft",
17235 			ut_setup_security, ut_teardown,
17236 			test_ipsec_proto_sa_exp_pkts_soft),
17237 		TEST_CASE_NAMED_ST(
17238 			"SA expiry packets hard",
17239 			ut_setup_security, ut_teardown,
17240 			test_ipsec_proto_sa_exp_pkts_hard),
17241 		TEST_CASE_NAMED_ST(
17242 			"Negative test: ICV corruption",
17243 			ut_setup_security, ut_teardown,
17244 			test_ipsec_proto_err_icv_corrupt),
17245 		TEST_CASE_NAMED_ST(
17246 			"Tunnel dst addr verification",
17247 			ut_setup_security, ut_teardown,
17248 			test_ipsec_proto_tunnel_dst_addr_verify),
17249 		TEST_CASE_NAMED_ST(
17250 			"Tunnel src and dst addr verification",
17251 			ut_setup_security, ut_teardown,
17252 			test_ipsec_proto_tunnel_src_dst_addr_verify),
17253 		TEST_CASE_NAMED_ST(
17254 			"Inner IP checksum",
17255 			ut_setup_security, ut_teardown,
17256 			test_ipsec_proto_inner_ip_csum),
17257 		TEST_CASE_NAMED_ST(
17258 			"Inner L4 checksum",
17259 			ut_setup_security, ut_teardown,
17260 			test_ipsec_proto_inner_l4_csum),
17261 		TEST_CASE_NAMED_ST(
17262 			"Tunnel IPv4 in IPv4",
17263 			ut_setup_security, ut_teardown,
17264 			test_ipsec_proto_tunnel_v4_in_v4),
17265 		TEST_CASE_NAMED_ST(
17266 			"Tunnel IPv6 in IPv6",
17267 			ut_setup_security, ut_teardown,
17268 			test_ipsec_proto_tunnel_v6_in_v6),
17269 		TEST_CASE_NAMED_ST(
17270 			"Tunnel IPv4 in IPv6",
17271 			ut_setup_security, ut_teardown,
17272 			test_ipsec_proto_tunnel_v4_in_v6),
17273 		TEST_CASE_NAMED_ST(
17274 			"Tunnel IPv6 in IPv4",
17275 			ut_setup_security, ut_teardown,
17276 			test_ipsec_proto_tunnel_v6_in_v4),
17277 		TEST_CASE_NAMED_ST(
17278 			"Transport IPv4",
17279 			ut_setup_security, ut_teardown,
17280 			test_ipsec_proto_transport_v4),
17281 		TEST_CASE_NAMED_ST(
17282 			"AH transport IPv4",
17283 			ut_setup_security, ut_teardown,
17284 			test_ipsec_proto_ah_transport_ipv4),
17285 		TEST_CASE_NAMED_ST(
17286 			"Transport l4 checksum",
17287 			ut_setup_security, ut_teardown,
17288 			test_ipsec_proto_transport_l4_csum),
17289 		TEST_CASE_NAMED_ST(
17290 			"Statistics: success",
17291 			ut_setup_security, ut_teardown,
17292 			test_ipsec_proto_stats),
17293 		TEST_CASE_NAMED_ST(
17294 			"Fragmented packet",
17295 			ut_setup_security, ut_teardown,
17296 			test_ipsec_proto_pkt_fragment),
17297 		TEST_CASE_NAMED_ST(
17298 			"Tunnel header copy DF (inner 0)",
17299 			ut_setup_security, ut_teardown,
17300 			test_ipsec_proto_copy_df_inner_0),
17301 		TEST_CASE_NAMED_ST(
17302 			"Tunnel header copy DF (inner 1)",
17303 			ut_setup_security, ut_teardown,
17304 			test_ipsec_proto_copy_df_inner_1),
17305 		TEST_CASE_NAMED_ST(
17306 			"Tunnel header set DF 0 (inner 1)",
17307 			ut_setup_security, ut_teardown,
17308 			test_ipsec_proto_set_df_0_inner_1),
17309 		TEST_CASE_NAMED_ST(
17310 			"Tunnel header set DF 1 (inner 0)",
17311 			ut_setup_security, ut_teardown,
17312 			test_ipsec_proto_set_df_1_inner_0),
17313 		TEST_CASE_NAMED_ST(
17314 			"Tunnel header IPv4 copy DSCP (inner 0)",
17315 			ut_setup_security, ut_teardown,
17316 			test_ipsec_proto_ipv4_copy_dscp_inner_0),
17317 		TEST_CASE_NAMED_ST(
17318 			"Tunnel header IPv4 copy DSCP (inner 1)",
17319 			ut_setup_security, ut_teardown,
17320 			test_ipsec_proto_ipv4_copy_dscp_inner_1),
17321 		TEST_CASE_NAMED_ST(
17322 			"Tunnel header IPv4 set DSCP 0 (inner 1)",
17323 			ut_setup_security, ut_teardown,
17324 			test_ipsec_proto_ipv4_set_dscp_0_inner_1),
17325 		TEST_CASE_NAMED_ST(
17326 			"Tunnel header IPv4 set DSCP 1 (inner 0)",
17327 			ut_setup_security, ut_teardown,
17328 			test_ipsec_proto_ipv4_set_dscp_1_inner_0),
17329 		TEST_CASE_NAMED_ST(
17330 			"Tunnel header IPv6 copy DSCP (inner 0)",
17331 			ut_setup_security, ut_teardown,
17332 			test_ipsec_proto_ipv6_copy_dscp_inner_0),
17333 		TEST_CASE_NAMED_ST(
17334 			"Tunnel header IPv6 copy DSCP (inner 1)",
17335 			ut_setup_security, ut_teardown,
17336 			test_ipsec_proto_ipv6_copy_dscp_inner_1),
17337 		TEST_CASE_NAMED_ST(
17338 			"Tunnel header IPv6 set DSCP 0 (inner 1)",
17339 			ut_setup_security, ut_teardown,
17340 			test_ipsec_proto_ipv6_set_dscp_0_inner_1),
17341 		TEST_CASE_NAMED_ST(
17342 			"Tunnel header IPv6 set DSCP 1 (inner 0)",
17343 			ut_setup_security, ut_teardown,
17344 			test_ipsec_proto_ipv6_set_dscp_1_inner_0),
17345 		TEST_CASE_NAMED_WITH_DATA(
17346 			"Antireplay with window size 1024",
17347 			ut_setup_security, ut_teardown,
17348 			test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
17349 		TEST_CASE_NAMED_WITH_DATA(
17350 			"Antireplay with window size 2048",
17351 			ut_setup_security, ut_teardown,
17352 			test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
17353 		TEST_CASE_NAMED_WITH_DATA(
17354 			"Antireplay with window size 4096",
17355 			ut_setup_security, ut_teardown,
17356 			test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
17357 		TEST_CASE_NAMED_WITH_DATA(
17358 			"ESN and Antireplay with window size 1024",
17359 			ut_setup_security, ut_teardown,
17360 			test_ipsec_proto_pkt_esn_antireplay1024,
17361 			&pkt_aes_128_gcm),
17362 		TEST_CASE_NAMED_WITH_DATA(
17363 			"ESN and Antireplay with window size 2048",
17364 			ut_setup_security, ut_teardown,
17365 			test_ipsec_proto_pkt_esn_antireplay2048,
17366 			&pkt_aes_128_gcm),
17367 		TEST_CASE_NAMED_WITH_DATA(
17368 			"ESN and Antireplay with window size 4096",
17369 			ut_setup_security, ut_teardown,
17370 			test_ipsec_proto_pkt_esn_antireplay4096,
17371 			&pkt_aes_128_gcm),
17372 		TEST_CASE_NAMED_ST(
17373 			"Tunnel header IPv4 decrement inner TTL",
17374 			ut_setup_security, ut_teardown,
17375 			test_ipsec_proto_ipv4_ttl_decrement),
17376 		TEST_CASE_NAMED_ST(
17377 			"Tunnel header IPv6 decrement inner hop limit",
17378 			ut_setup_security, ut_teardown,
17379 			test_ipsec_proto_ipv6_hop_limit_decrement),
17380 		TEST_CASE_NAMED_ST(
17381 			"Multi-segmented mode",
17382 			ut_setup_security, ut_teardown,
17383 			test_ipsec_proto_sgl),
17384 		TEST_CASE_NAMED_ST(
17385 			"Multi-segmented external mbuf mode",
17386 			ut_setup_security, ut_teardown,
17387 			test_ipsec_proto_sgl_ext_mbuf),
17388 		TEST_CASE_NAMED_WITH_DATA(
17389 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
17390 			ut_setup_security_rx_inject, ut_teardown_rx_inject,
17391 			test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
17392 		TEST_CASES_END() /**< NULL terminate unit test array */
17393 	}
17394 };
17395 
17396 static struct unit_test_suite pdcp_proto_testsuite  = {
17397 	.suite_name = "PDCP Proto Unit Test Suite",
17398 	.setup = pdcp_proto_testsuite_setup,
17399 	.unit_test_cases = {
17400 		TEST_CASE_ST(ut_setup_security, ut_teardown,
17401 			test_PDCP_PROTO_all),
17402 		TEST_CASES_END() /**< NULL terminate unit test array */
17403 	}
17404 };
17405 
17406 static struct unit_test_suite tls12_record_proto_testsuite  = {
17407 	.suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
17408 	.setup = tls_record_proto_testsuite_setup,
17409 	.unit_test_cases = {
17410 		TEST_CASE_NAMED_WITH_DATA(
17411 			"Write record known vector AES-GCM-128 (vector 1)",
17412 			ut_setup_security, ut_teardown,
17413 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
17414 		TEST_CASE_NAMED_WITH_DATA(
17415 			"Write record known vector AES-GCM-128 (vector 2)",
17416 			ut_setup_security, ut_teardown,
17417 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
17418 		TEST_CASE_NAMED_WITH_DATA(
17419 			"Write record known vector AES-GCM-256",
17420 			ut_setup_security, ut_teardown,
17421 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
17422 		TEST_CASE_NAMED_WITH_DATA(
17423 			"Write record known vector AES-CBC-128-SHA1",
17424 			ut_setup_security, ut_teardown,
17425 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
17426 		TEST_CASE_NAMED_WITH_DATA(
17427 			"Write record known vector AES-128-CBC-SHA256",
17428 			ut_setup_security, ut_teardown,
17429 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
17430 		TEST_CASE_NAMED_WITH_DATA(
17431 			"Write record known vector AES-256-CBC-SHA1",
17432 			ut_setup_security, ut_teardown,
17433 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
17434 		TEST_CASE_NAMED_WITH_DATA(
17435 			"Write record known vector AES-256-CBC-SHA256",
17436 			ut_setup_security, ut_teardown,
17437 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
17438 		TEST_CASE_NAMED_WITH_DATA(
17439 			"Write record known vector AES-256-CBC-SHA384",
17440 			ut_setup_security, ut_teardown,
17441 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
17442 		TEST_CASE_NAMED_WITH_DATA(
17443 			"Write record known vector 3DES-CBC-SHA1-HMAC",
17444 			ut_setup_security, ut_teardown,
17445 			test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
17446 		TEST_CASE_NAMED_WITH_DATA(
17447 			"Write record known vector NULL-SHA1-HMAC",
17448 			ut_setup_security, ut_teardown,
17449 			test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
17450 		TEST_CASE_NAMED_WITH_DATA(
17451 			"Write record known vector CHACHA20-POLY1305",
17452 			ut_setup_security, ut_teardown,
17453 			test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
17454 
17455 		TEST_CASE_NAMED_WITH_DATA(
17456 			"Read record known vector AES-GCM-128 (vector 1)",
17457 			ut_setup_security, ut_teardown,
17458 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
17459 		TEST_CASE_NAMED_WITH_DATA(
17460 			"Read record known vector AES-GCM-128 (vector 2)",
17461 			ut_setup_security, ut_teardown,
17462 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
17463 		TEST_CASE_NAMED_WITH_DATA(
17464 			"Read record known vector AES-GCM-256",
17465 			ut_setup_security, ut_teardown,
17466 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
17467 		TEST_CASE_NAMED_WITH_DATA(
17468 			"Read record known vector AES-128-CBC-SHA1",
17469 			ut_setup_security, ut_teardown,
17470 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
17471 		TEST_CASE_NAMED_WITH_DATA(
17472 			"Read record known vector AES-128-CBC-SHA256",
17473 			ut_setup_security, ut_teardown,
17474 			test_tls_record_proto_known_vec_read,
17475 			&tls_test_data_aes_128_cbc_sha256_hmac),
17476 		TEST_CASE_NAMED_WITH_DATA(
17477 			"Read record known vector AES-256-CBC-SHA1",
17478 			ut_setup_security, ut_teardown,
17479 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
17480 		TEST_CASE_NAMED_WITH_DATA(
17481 			"Read record known vector AES-256-CBC-SHA256",
17482 			ut_setup_security, ut_teardown,
17483 			test_tls_record_proto_known_vec_read,
17484 			&tls_test_data_aes_256_cbc_sha256_hmac),
17485 		TEST_CASE_NAMED_WITH_DATA(
17486 			"Read record known vector AES-256-CBC-SHA384",
17487 			ut_setup_security, ut_teardown,
17488 			test_tls_record_proto_known_vec_read,
17489 			&tls_test_data_aes_256_cbc_sha384_hmac),
17490 		TEST_CASE_NAMED_WITH_DATA(
17491 			"Read record known vector 3DES-CBC-SHA1-HMAC",
17492 			ut_setup_security, ut_teardown,
17493 			test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
17494 		TEST_CASE_NAMED_WITH_DATA(
17495 			"Read record known vector NULL-SHA1-HMAC",
17496 			ut_setup_security, ut_teardown,
17497 			test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
17498 		TEST_CASE_NAMED_WITH_DATA(
17499 			"Read record known vector CHACHA20-POLY1305",
17500 			ut_setup_security, ut_teardown,
17501 			test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
17502 
17503 		TEST_CASE_NAMED_ST(
17504 			"Combined test alg list",
17505 			ut_setup_security, ut_teardown,
17506 			test_tls_1_2_record_proto_display_list),
17507 		TEST_CASE_NAMED_ST(
17508 			"Data walkthrough combined test alg list",
17509 			ut_setup_security, ut_teardown,
17510 			test_tls_1_2_record_proto_data_walkthrough),
17511 		TEST_CASE_NAMED_ST(
17512 			"Multi-segmented mode",
17513 			ut_setup_security, ut_teardown,
17514 			test_tls_1_2_record_proto_sgl),
17515 		TEST_CASE_NAMED_ST(
17516 			"Multi-segmented mode data walkthrough",
17517 			ut_setup_security, ut_teardown,
17518 			test_tls_1_2_record_proto_sgl_data_walkthrough),
17519 		TEST_CASE_NAMED_ST(
17520 			"TLS packet header corruption",
17521 			ut_setup_security, ut_teardown,
17522 			test_tls_record_proto_corrupt_pkt),
17523 		TEST_CASE_NAMED_ST(
17524 			"Custom content type",
17525 			ut_setup_security, ut_teardown,
17526 			test_tls_record_proto_custom_content_type),
17527 		TEST_CASE_NAMED_ST(
17528 			"Zero len TLS record with content type as app",
17529 			ut_setup_security, ut_teardown,
17530 			test_tls_record_proto_zero_len),
17531 		TEST_CASE_NAMED_ST(
17532 			"Zero len TLS record with content type as ctrl",
17533 			ut_setup_security, ut_teardown,
17534 			test_tls_record_proto_zero_len_non_app),
17535 		TEST_CASES_END() /**< NULL terminate unit test array */
17536 	}
17537 };
17538 
17539 static struct unit_test_suite dtls12_record_proto_testsuite  = {
17540 	.suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
17541 	.setup = tls_record_proto_testsuite_setup,
17542 	.unit_test_cases = {
17543 		TEST_CASE_NAMED_WITH_DATA(
17544 			"Write record known vector AES-GCM-128",
17545 			ut_setup_security, ut_teardown,
17546 			test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
17547 		TEST_CASE_NAMED_WITH_DATA(
17548 			"Write record known vector AES-GCM-256",
17549 			ut_setup_security, ut_teardown,
17550 			test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
17551 		TEST_CASE_NAMED_WITH_DATA(
17552 			"Write record known vector AES-128-CBC-SHA1",
17553 			ut_setup_security, ut_teardown,
17554 			test_tls_record_proto_known_vec,
17555 			&dtls_test_data_aes_128_cbc_sha1_hmac),
17556 		TEST_CASE_NAMED_WITH_DATA(
17557 			"Write record known vector AES-128-CBC-SHA256",
17558 			ut_setup_security, ut_teardown,
17559 			test_tls_record_proto_known_vec,
17560 			&dtls_test_data_aes_128_cbc_sha256_hmac),
17561 		TEST_CASE_NAMED_WITH_DATA(
17562 			"Write record known vector AES-256-CBC-SHA1",
17563 			ut_setup_security, ut_teardown,
17564 			test_tls_record_proto_known_vec,
17565 			&dtls_test_data_aes_256_cbc_sha1_hmac),
17566 		TEST_CASE_NAMED_WITH_DATA(
17567 			"Write record known vector AES-256-CBC-SHA256",
17568 			ut_setup_security, ut_teardown,
17569 			test_tls_record_proto_known_vec,
17570 			&dtls_test_data_aes_256_cbc_sha256_hmac),
17571 		TEST_CASE_NAMED_WITH_DATA(
17572 			"Write record known vector AES-256-CBC-SHA384",
17573 			ut_setup_security, ut_teardown,
17574 			test_tls_record_proto_known_vec,
17575 			&dtls_test_data_aes_256_cbc_sha384_hmac),
17576 		TEST_CASE_NAMED_WITH_DATA(
17577 			"Write record known vector 3DES-CBC-SHA1-HMAC",
17578 			ut_setup_security, ut_teardown,
17579 			test_tls_record_proto_known_vec,
17580 			&dtls_test_data_3des_cbc_sha1_hmac),
17581 		TEST_CASE_NAMED_WITH_DATA(
17582 			"Write record known vector NULL-SHA1-HMAC",
17583 			ut_setup_security, ut_teardown,
17584 			test_tls_record_proto_known_vec,
17585 			&dtls_test_data_null_cipher_sha1_hmac),
17586 		TEST_CASE_NAMED_WITH_DATA(
17587 			"Write record known vector CHACHA20-POLY1305",
17588 			ut_setup_security, ut_teardown,
17589 			test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
17590 		TEST_CASE_NAMED_WITH_DATA(
17591 			"Read record known vector AES-GCM-128",
17592 			ut_setup_security, ut_teardown,
17593 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
17594 		TEST_CASE_NAMED_WITH_DATA(
17595 			"Read record known vector AES-GCM-256",
17596 			ut_setup_security, ut_teardown,
17597 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
17598 		TEST_CASE_NAMED_WITH_DATA(
17599 			"Read record known vector AES-128-CBC-SHA1",
17600 			ut_setup_security, ut_teardown,
17601 			test_tls_record_proto_known_vec_read,
17602 			&dtls_test_data_aes_128_cbc_sha1_hmac),
17603 		TEST_CASE_NAMED_WITH_DATA(
17604 			"Read record known vector AES-128-CBC-SHA256",
17605 			ut_setup_security, ut_teardown,
17606 			test_tls_record_proto_known_vec_read,
17607 			&dtls_test_data_aes_128_cbc_sha256_hmac),
17608 		TEST_CASE_NAMED_WITH_DATA(
17609 			"Read record known vector AES-256-CBC-SHA1",
17610 			ut_setup_security, ut_teardown,
17611 			test_tls_record_proto_known_vec_read,
17612 			&dtls_test_data_aes_256_cbc_sha1_hmac),
17613 		TEST_CASE_NAMED_WITH_DATA(
17614 			"Read record known vector AES-256-CBC-SHA256",
17615 			ut_setup_security, ut_teardown,
17616 			test_tls_record_proto_known_vec_read,
17617 			&dtls_test_data_aes_256_cbc_sha256_hmac),
17618 		TEST_CASE_NAMED_WITH_DATA(
17619 			"Read record known vector AES-256-CBC-SHA384",
17620 			ut_setup_security, ut_teardown,
17621 			test_tls_record_proto_known_vec_read,
17622 			&dtls_test_data_aes_256_cbc_sha384_hmac),
17623 		TEST_CASE_NAMED_WITH_DATA(
17624 			"Read record known vector 3DES-CBC-SHA1-HMAC",
17625 			ut_setup_security, ut_teardown,
17626 			test_tls_record_proto_known_vec_read,
17627 			&dtls_test_data_3des_cbc_sha1_hmac),
17628 		TEST_CASE_NAMED_WITH_DATA(
17629 			"Read record known vector NULL-SHA1-HMAC",
17630 			ut_setup_security, ut_teardown,
17631 			test_tls_record_proto_known_vec_read,
17632 			&dtls_test_data_null_cipher_sha1_hmac),
17633 		TEST_CASE_NAMED_WITH_DATA(
17634 			"Read record known vector CHACHA20-POLY1305",
17635 			ut_setup_security, ut_teardown,
17636 			test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
17637 
17638 		TEST_CASE_NAMED_ST(
17639 			"Combined test alg list",
17640 			ut_setup_security, ut_teardown,
17641 			test_dtls_1_2_record_proto_display_list),
17642 		TEST_CASE_NAMED_ST(
17643 			"Data walkthrough combined test alg list",
17644 			ut_setup_security, ut_teardown,
17645 			test_dtls_1_2_record_proto_data_walkthrough),
17646 		TEST_CASE_NAMED_ST(
17647 			"Multi-segmented mode",
17648 			ut_setup_security, ut_teardown,
17649 			test_dtls_1_2_record_proto_sgl),
17650 		TEST_CASE_NAMED_ST(
17651 			"Multi-segmented mode data walkthrough",
17652 			ut_setup_security, ut_teardown,
17653 			test_dtls_1_2_record_proto_sgl_data_walkthrough),
17654 		TEST_CASE_NAMED_ST(
17655 			"Packet corruption",
17656 			ut_setup_security, ut_teardown,
17657 			test_dtls_1_2_record_proto_corrupt_pkt),
17658 		TEST_CASE_NAMED_ST(
17659 			"Custom content type",
17660 			ut_setup_security, ut_teardown,
17661 			test_dtls_1_2_record_proto_custom_content_type),
17662 		TEST_CASE_NAMED_ST(
17663 			"Zero len DTLS record with content type as app",
17664 			ut_setup_security, ut_teardown,
17665 			test_dtls_1_2_record_proto_zero_len),
17666 		TEST_CASE_NAMED_ST(
17667 			"Zero len DTLS record with content type as ctrl",
17668 			ut_setup_security, ut_teardown,
17669 			test_dtls_1_2_record_proto_zero_len_non_app),
17670 		TEST_CASE_NAMED_ST(
17671 			"Antireplay with window size 64",
17672 			ut_setup_security, ut_teardown,
17673 			test_dtls_1_2_record_proto_antireplay64),
17674 		TEST_CASE_NAMED_ST(
17675 			"Antireplay with window size 128",
17676 			ut_setup_security, ut_teardown,
17677 			test_dtls_1_2_record_proto_antireplay128),
17678 		TEST_CASE_NAMED_ST(
17679 			"Antireplay with window size 256",
17680 			ut_setup_security, ut_teardown,
17681 			test_dtls_1_2_record_proto_antireplay256),
17682 		TEST_CASE_NAMED_ST(
17683 			"Antireplay with window size 512",
17684 			ut_setup_security, ut_teardown,
17685 			test_dtls_1_2_record_proto_antireplay512),
17686 		TEST_CASE_NAMED_ST(
17687 			"Antireplay with window size 1024",
17688 			ut_setup_security, ut_teardown,
17689 			test_dtls_1_2_record_proto_antireplay1024),
17690 		TEST_CASE_NAMED_ST(
17691 			"Antireplay with window size 2048",
17692 			ut_setup_security, ut_teardown,
17693 			test_dtls_1_2_record_proto_antireplay2048),
17694 		TEST_CASE_NAMED_ST(
17695 			"Antireplay with window size 4096",
17696 			ut_setup_security, ut_teardown,
17697 			test_dtls_1_2_record_proto_antireplay4096),
17698 		TEST_CASES_END() /**< NULL terminate unit test array */
17699 	}
17700 };
17701 
17702 static struct unit_test_suite tls13_record_proto_testsuite  = {
17703 	.suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
17704 	.setup = tls_record_proto_testsuite_setup,
17705 	.unit_test_cases = {
17706 		TEST_CASE_NAMED_WITH_DATA(
17707 			"Write record known vector AES-GCM-128",
17708 			ut_setup_security, ut_teardown,
17709 			test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
17710 		TEST_CASE_NAMED_WITH_DATA(
17711 			"Write record known vector AES-GCM-256",
17712 			ut_setup_security, ut_teardown,
17713 			test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
17714 		TEST_CASE_NAMED_WITH_DATA(
17715 			"Write record known vector CHACHA20-POLY1305",
17716 			ut_setup_security, ut_teardown,
17717 			test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
17718 
17719 		TEST_CASE_NAMED_WITH_DATA(
17720 			"Read record known vector AES-GCM-128",
17721 			ut_setup_security, ut_teardown,
17722 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
17723 		TEST_CASE_NAMED_WITH_DATA(
17724 			"Read record known vector AES-GCM-256",
17725 			ut_setup_security, ut_teardown,
17726 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
17727 		TEST_CASE_NAMED_WITH_DATA(
17728 			"Read record known vector CHACHA20-POLY1305",
17729 			ut_setup_security, ut_teardown,
17730 			test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
17731 		TEST_CASE_NAMED_ST(
17732 			"TLS-1.3 record header corruption",
17733 			ut_setup_security, ut_teardown,
17734 			test_tls_1_3_record_proto_corrupt_pkt),
17735 		TEST_CASES_END() /**< NULL terminate unit test array */
17736 	}
17737 };
17738 
17739 #define ADD_UPLINK_TESTCASE(data)						\
17740 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
17741 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
17742 
17743 #define ADD_DOWNLINK_TESTCASE(data)						\
17744 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
17745 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
17746 
17747 static struct unit_test_suite docsis_proto_testsuite  = {
17748 	.suite_name = "DOCSIS Proto Unit Test Suite",
17749 	.setup = docsis_proto_testsuite_setup,
17750 	.unit_test_cases = {
17751 		/* Uplink */
17752 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
17753 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
17754 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
17755 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
17756 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
17757 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
17758 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
17759 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
17760 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
17761 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
17762 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
17763 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
17764 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
17765 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
17766 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
17767 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
17768 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
17769 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
17770 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
17771 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
17772 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
17773 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
17774 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
17775 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
17776 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
17777 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
17778 		/* Downlink */
17779 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
17780 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
17781 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
17782 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
17783 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
17784 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
17785 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
17786 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
17787 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
17788 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
17789 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
17790 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
17791 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
17792 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
17793 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
17794 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
17795 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
17796 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
17797 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
17798 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
17799 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
17800 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
17801 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
17802 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
17803 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
17804 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
17805 		TEST_CASES_END() /**< NULL terminate unit test array */
17806 	}
17807 };
17808 #endif
17809 
17810 static struct unit_test_suite cryptodev_gen_testsuite  = {
17811 	.suite_name = "Crypto General Unit Test Suite",
17812 	.setup = crypto_gen_testsuite_setup,
17813 	.unit_test_cases = {
17814 		TEST_CASE_ST(ut_setup, ut_teardown,
17815 				test_device_reconfigure),
17816 		TEST_CASE_ST(ut_setup, ut_teardown,
17817 				test_device_configure_invalid_dev_id),
17818 		TEST_CASE_ST(ut_setup, ut_teardown,
17819 				test_queue_pair_descriptor_setup),
17820 		TEST_CASE_ST(ut_setup, ut_teardown,
17821 				test_device_configure_invalid_queue_pair_ids),
17822 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
17823 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
17824 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
17825 		TEST_CASES_END() /**< NULL terminate unit test array */
17826 	}
17827 };
17828 
17829 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
17830 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
17831 	.setup = negative_hmac_sha1_testsuite_setup,
17832 	.unit_test_cases = {
17833 		/** Negative tests */
17834 		TEST_CASE_ST(ut_setup, ut_teardown,
17835 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
17836 		TEST_CASE_ST(ut_setup, ut_teardown,
17837 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
17838 		TEST_CASE_ST(ut_setup, ut_teardown,
17839 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
17840 		TEST_CASE_ST(ut_setup, ut_teardown,
17841 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
17842 
17843 		TEST_CASES_END() /**< NULL terminate unit test array */
17844 	}
17845 };
17846 
17847 static struct unit_test_suite cryptodev_multi_session_testsuite = {
17848 	.suite_name = "Multi Session Unit Test Suite",
17849 	.setup = multi_session_testsuite_setup,
17850 	.unit_test_cases = {
17851 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
17852 		TEST_CASE_ST(ut_setup, ut_teardown,
17853 				test_multi_session_random_usage),
17854 
17855 		TEST_CASES_END() /**< NULL terminate unit test array */
17856 	}
17857 };
17858 
17859 static struct unit_test_suite cryptodev_null_testsuite  = {
17860 	.suite_name = "NULL Test Suite",
17861 	.setup = null_testsuite_setup,
17862 	.unit_test_cases = {
17863 		TEST_CASE_ST(ut_setup, ut_teardown,
17864 			test_null_invalid_operation),
17865 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
17866 		TEST_CASES_END()
17867 	}
17868 };
17869 
17870 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
17871 	.suite_name = "AES CCM Authenticated Test Suite",
17872 	.setup = aes_ccm_auth_testsuite_setup,
17873 	.unit_test_cases = {
17874 		/** AES CCM Authenticated Encryption 128 bits key*/
17875 		TEST_CASE_ST(ut_setup, ut_teardown,
17876 			test_AES_CCM_authenticated_encryption_test_case_128_1),
17877 		TEST_CASE_ST(ut_setup, ut_teardown,
17878 			test_AES_CCM_authenticated_encryption_test_case_128_2),
17879 		TEST_CASE_ST(ut_setup, ut_teardown,
17880 			test_AES_CCM_authenticated_encryption_test_case_128_3),
17881 
17882 		/** AES CCM Authenticated Decryption 128 bits key*/
17883 		TEST_CASE_ST(ut_setup, ut_teardown,
17884 			test_AES_CCM_authenticated_decryption_test_case_128_1),
17885 		TEST_CASE_ST(ut_setup, ut_teardown,
17886 			test_AES_CCM_authenticated_decryption_test_case_128_2),
17887 		TEST_CASE_ST(ut_setup, ut_teardown,
17888 			test_AES_CCM_authenticated_decryption_test_case_128_3),
17889 
17890 		/** AES CCM Authenticated Encryption 192 bits key */
17891 		TEST_CASE_ST(ut_setup, ut_teardown,
17892 			test_AES_CCM_authenticated_encryption_test_case_192_1),
17893 		TEST_CASE_ST(ut_setup, ut_teardown,
17894 			test_AES_CCM_authenticated_encryption_test_case_192_2),
17895 		TEST_CASE_ST(ut_setup, ut_teardown,
17896 			test_AES_CCM_authenticated_encryption_test_case_192_3),
17897 
17898 		/** AES CCM Authenticated Decryption 192 bits key*/
17899 		TEST_CASE_ST(ut_setup, ut_teardown,
17900 			test_AES_CCM_authenticated_decryption_test_case_192_1),
17901 		TEST_CASE_ST(ut_setup, ut_teardown,
17902 			test_AES_CCM_authenticated_decryption_test_case_192_2),
17903 		TEST_CASE_ST(ut_setup, ut_teardown,
17904 			test_AES_CCM_authenticated_decryption_test_case_192_3),
17905 
17906 		/** AES CCM Authenticated Encryption 256 bits key */
17907 		TEST_CASE_ST(ut_setup, ut_teardown,
17908 			test_AES_CCM_authenticated_encryption_test_case_256_1),
17909 		TEST_CASE_ST(ut_setup, ut_teardown,
17910 			test_AES_CCM_authenticated_encryption_test_case_256_2),
17911 		TEST_CASE_ST(ut_setup, ut_teardown,
17912 			test_AES_CCM_authenticated_encryption_test_case_256_3),
17913 
17914 		/** AES CCM Authenticated Decryption 256 bits key*/
17915 		TEST_CASE_ST(ut_setup, ut_teardown,
17916 			test_AES_CCM_authenticated_decryption_test_case_256_1),
17917 		TEST_CASE_ST(ut_setup, ut_teardown,
17918 			test_AES_CCM_authenticated_decryption_test_case_256_2),
17919 		TEST_CASE_ST(ut_setup, ut_teardown,
17920 			test_AES_CCM_authenticated_decryption_test_case_256_3),
17921 		TEST_CASES_END()
17922 	}
17923 };
17924 
17925 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
17926 	.suite_name = "AES GCM Authenticated Test Suite",
17927 	.setup = aes_gcm_auth_testsuite_setup,
17928 	.unit_test_cases = {
17929 		/** AES GCM Authenticated Encryption */
17930 		TEST_CASE_ST(ut_setup, ut_teardown,
17931 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
17932 		TEST_CASE_ST(ut_setup, ut_teardown,
17933 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
17934 		TEST_CASE_ST(ut_setup, ut_teardown,
17935 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
17936 		TEST_CASE_ST(ut_setup, ut_teardown,
17937 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
17938 		TEST_CASE_ST(ut_setup, ut_teardown,
17939 			test_AES_GCM_authenticated_encryption_test_case_1),
17940 		TEST_CASE_ST(ut_setup, ut_teardown,
17941 			test_AES_GCM_authenticated_encryption_test_case_2),
17942 		TEST_CASE_ST(ut_setup, ut_teardown,
17943 			test_AES_GCM_authenticated_encryption_test_case_3),
17944 		TEST_CASE_ST(ut_setup, ut_teardown,
17945 			test_AES_GCM_authenticated_encryption_test_case_4),
17946 		TEST_CASE_ST(ut_setup, ut_teardown,
17947 			test_AES_GCM_authenticated_encryption_test_case_5),
17948 		TEST_CASE_ST(ut_setup, ut_teardown,
17949 			test_AES_GCM_authenticated_encryption_test_case_6),
17950 		TEST_CASE_ST(ut_setup, ut_teardown,
17951 			test_AES_GCM_authenticated_encryption_test_case_7),
17952 		TEST_CASE_ST(ut_setup, ut_teardown,
17953 			test_AES_GCM_authenticated_encryption_test_case_8),
17954 		TEST_CASE_ST(ut_setup, ut_teardown,
17955 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
17956 
17957 		/** AES GCM Authenticated Decryption */
17958 		TEST_CASE_ST(ut_setup, ut_teardown,
17959 			test_AES_GCM_authenticated_decryption_test_case_1),
17960 		TEST_CASE_ST(ut_setup, ut_teardown,
17961 			test_AES_GCM_authenticated_decryption_test_case_2),
17962 		TEST_CASE_ST(ut_setup, ut_teardown,
17963 			test_AES_GCM_authenticated_decryption_test_case_3),
17964 		TEST_CASE_ST(ut_setup, ut_teardown,
17965 			test_AES_GCM_authenticated_decryption_test_case_4),
17966 		TEST_CASE_ST(ut_setup, ut_teardown,
17967 			test_AES_GCM_authenticated_decryption_test_case_5),
17968 		TEST_CASE_ST(ut_setup, ut_teardown,
17969 			test_AES_GCM_authenticated_decryption_test_case_6),
17970 		TEST_CASE_ST(ut_setup, ut_teardown,
17971 			test_AES_GCM_authenticated_decryption_test_case_7),
17972 		TEST_CASE_ST(ut_setup, ut_teardown,
17973 			test_AES_GCM_authenticated_decryption_test_case_8),
17974 		TEST_CASE_ST(ut_setup, ut_teardown,
17975 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
17976 
17977 		/** AES GCM Authenticated Encryption 192 bits key */
17978 		TEST_CASE_ST(ut_setup, ut_teardown,
17979 			test_AES_GCM_auth_encryption_test_case_192_1),
17980 		TEST_CASE_ST(ut_setup, ut_teardown,
17981 			test_AES_GCM_auth_encryption_test_case_192_2),
17982 		TEST_CASE_ST(ut_setup, ut_teardown,
17983 			test_AES_GCM_auth_encryption_test_case_192_3),
17984 		TEST_CASE_ST(ut_setup, ut_teardown,
17985 			test_AES_GCM_auth_encryption_test_case_192_4),
17986 		TEST_CASE_ST(ut_setup, ut_teardown,
17987 			test_AES_GCM_auth_encryption_test_case_192_5),
17988 		TEST_CASE_ST(ut_setup, ut_teardown,
17989 			test_AES_GCM_auth_encryption_test_case_192_6),
17990 		TEST_CASE_ST(ut_setup, ut_teardown,
17991 			test_AES_GCM_auth_encryption_test_case_192_7),
17992 
17993 		/** AES GCM Authenticated Decryption 192 bits key */
17994 		TEST_CASE_ST(ut_setup, ut_teardown,
17995 			test_AES_GCM_auth_decryption_test_case_192_1),
17996 		TEST_CASE_ST(ut_setup, ut_teardown,
17997 			test_AES_GCM_auth_decryption_test_case_192_2),
17998 		TEST_CASE_ST(ut_setup, ut_teardown,
17999 			test_AES_GCM_auth_decryption_test_case_192_3),
18000 		TEST_CASE_ST(ut_setup, ut_teardown,
18001 			test_AES_GCM_auth_decryption_test_case_192_4),
18002 		TEST_CASE_ST(ut_setup, ut_teardown,
18003 			test_AES_GCM_auth_decryption_test_case_192_5),
18004 		TEST_CASE_ST(ut_setup, ut_teardown,
18005 			test_AES_GCM_auth_decryption_test_case_192_6),
18006 		TEST_CASE_ST(ut_setup, ut_teardown,
18007 			test_AES_GCM_auth_decryption_test_case_192_7),
18008 
18009 		/** AES GCM Authenticated Encryption 256 bits key */
18010 		TEST_CASE_ST(ut_setup, ut_teardown,
18011 			test_AES_GCM_auth_encryption_test_case_256_1),
18012 		TEST_CASE_ST(ut_setup, ut_teardown,
18013 			test_AES_GCM_auth_encryption_test_case_256_2),
18014 		TEST_CASE_ST(ut_setup, ut_teardown,
18015 			test_AES_GCM_auth_encryption_test_case_256_3),
18016 		TEST_CASE_ST(ut_setup, ut_teardown,
18017 			test_AES_GCM_auth_encryption_test_case_256_4),
18018 		TEST_CASE_ST(ut_setup, ut_teardown,
18019 			test_AES_GCM_auth_encryption_test_case_256_5),
18020 		TEST_CASE_ST(ut_setup, ut_teardown,
18021 			test_AES_GCM_auth_encryption_test_case_256_6),
18022 		TEST_CASE_ST(ut_setup, ut_teardown,
18023 			test_AES_GCM_auth_encryption_test_case_256_7),
18024 		TEST_CASE_ST(ut_setup, ut_teardown,
18025 			test_AES_GCM_auth_encryption_test_case_256_8),
18026 
18027 		/** AES GCM Authenticated Decryption 256 bits key */
18028 		TEST_CASE_ST(ut_setup, ut_teardown,
18029 			test_AES_GCM_auth_decryption_test_case_256_1),
18030 		TEST_CASE_ST(ut_setup, ut_teardown,
18031 			test_AES_GCM_auth_decryption_test_case_256_2),
18032 		TEST_CASE_ST(ut_setup, ut_teardown,
18033 			test_AES_GCM_auth_decryption_test_case_256_3),
18034 		TEST_CASE_ST(ut_setup, ut_teardown,
18035 			test_AES_GCM_auth_decryption_test_case_256_4),
18036 		TEST_CASE_ST(ut_setup, ut_teardown,
18037 			test_AES_GCM_auth_decryption_test_case_256_5),
18038 		TEST_CASE_ST(ut_setup, ut_teardown,
18039 			test_AES_GCM_auth_decryption_test_case_256_6),
18040 		TEST_CASE_ST(ut_setup, ut_teardown,
18041 			test_AES_GCM_auth_decryption_test_case_256_7),
18042 		TEST_CASE_ST(ut_setup, ut_teardown,
18043 			test_AES_GCM_auth_decryption_test_case_256_8),
18044 
18045 		/** AES GCM Authenticated Encryption big aad size */
18046 		TEST_CASE_ST(ut_setup, ut_teardown,
18047 			test_AES_GCM_auth_encryption_test_case_aad_1),
18048 		TEST_CASE_ST(ut_setup, ut_teardown,
18049 			test_AES_GCM_auth_encryption_test_case_aad_2),
18050 
18051 		/** AES GCM Authenticated Decryption big aad size */
18052 		TEST_CASE_ST(ut_setup, ut_teardown,
18053 			test_AES_GCM_auth_decryption_test_case_aad_1),
18054 		TEST_CASE_ST(ut_setup, ut_teardown,
18055 			test_AES_GCM_auth_decryption_test_case_aad_2),
18056 
18057 		/** Out of place tests */
18058 		TEST_CASE_ST(ut_setup, ut_teardown,
18059 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
18060 		TEST_CASE_ST(ut_setup, ut_teardown,
18061 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
18062 
18063 		/** Session-less tests */
18064 		TEST_CASE_ST(ut_setup, ut_teardown,
18065 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
18066 		TEST_CASE_ST(ut_setup, ut_teardown,
18067 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
18068 
18069 		/** AES GCM external mbuf tests */
18070 		TEST_CASE_ST(ut_setup, ut_teardown,
18071 			test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
18072 		TEST_CASE_ST(ut_setup, ut_teardown,
18073 			test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
18074 
18075 		TEST_CASES_END()
18076 	}
18077 };
18078 
18079 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
18080 	.suite_name = "AES GMAC Authentication Test Suite",
18081 	.setup = aes_gmac_auth_testsuite_setup,
18082 	.unit_test_cases = {
18083 		TEST_CASE_ST(ut_setup, ut_teardown,
18084 			test_AES_GMAC_authentication_test_case_1),
18085 		TEST_CASE_ST(ut_setup, ut_teardown,
18086 			test_AES_GMAC_authentication_verify_test_case_1),
18087 		TEST_CASE_ST(ut_setup, ut_teardown,
18088 			test_AES_GMAC_authentication_test_case_2),
18089 		TEST_CASE_ST(ut_setup, ut_teardown,
18090 			test_AES_GMAC_authentication_verify_test_case_2),
18091 		TEST_CASE_ST(ut_setup, ut_teardown,
18092 			test_AES_GMAC_authentication_test_case_3),
18093 		TEST_CASE_ST(ut_setup, ut_teardown,
18094 			test_AES_GMAC_authentication_verify_test_case_3),
18095 		TEST_CASE_ST(ut_setup, ut_teardown,
18096 			test_AES_GMAC_authentication_test_case_4),
18097 		TEST_CASE_ST(ut_setup, ut_teardown,
18098 			test_AES_GMAC_authentication_verify_test_case_4),
18099 		TEST_CASE_ST(ut_setup, ut_teardown,
18100 			test_AES_GMAC_authentication_SGL_40B),
18101 		TEST_CASE_ST(ut_setup, ut_teardown,
18102 			test_AES_GMAC_authentication_SGL_80B),
18103 		TEST_CASE_ST(ut_setup, ut_teardown,
18104 			test_AES_GMAC_authentication_SGL_2048B),
18105 		TEST_CASE_ST(ut_setup, ut_teardown,
18106 			test_AES_GMAC_authentication_SGL_2047B),
18107 
18108 		TEST_CASES_END()
18109 	}
18110 };
18111 
18112 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
18113 	.suite_name = "Chacha20-Poly1305 Test Suite",
18114 	.setup = chacha20_poly1305_testsuite_setup,
18115 	.unit_test_cases = {
18116 		TEST_CASE_ST(ut_setup, ut_teardown,
18117 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
18118 		TEST_CASE_ST(ut_setup, ut_teardown,
18119 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
18120 		TEST_CASE_ST(ut_setup, ut_teardown,
18121 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
18122 		TEST_CASES_END()
18123 	}
18124 };
18125 
18126 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
18127 	.suite_name = "SNOW 3G Test Suite",
18128 	.setup = snow3g_testsuite_setup,
18129 	.unit_test_cases = {
18130 		/** SNOW 3G encrypt only (UEA2) */
18131 		TEST_CASE_ST(ut_setup, ut_teardown,
18132 			test_snow3g_encryption_test_case_1),
18133 		TEST_CASE_ST(ut_setup, ut_teardown,
18134 			test_snow3g_encryption_test_case_2),
18135 		TEST_CASE_ST(ut_setup, ut_teardown,
18136 			test_snow3g_encryption_test_case_3),
18137 		TEST_CASE_ST(ut_setup, ut_teardown,
18138 			test_snow3g_encryption_test_case_4),
18139 		TEST_CASE_ST(ut_setup, ut_teardown,
18140 			test_snow3g_encryption_test_case_5),
18141 
18142 		TEST_CASE_ST(ut_setup, ut_teardown,
18143 			test_snow3g_encryption_test_case_1_oop),
18144 		TEST_CASE_ST(ut_setup, ut_teardown,
18145 			test_snow3g_encryption_test_case_1_oop_sgl),
18146 		TEST_CASE_ST(ut_setup, ut_teardown,
18147 			test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
18148 		TEST_CASE_ST(ut_setup, ut_teardown,
18149 			test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
18150 		TEST_CASE_ST(ut_setup, ut_teardown,
18151 			test_snow3g_encryption_test_case_1_offset_oop),
18152 		TEST_CASE_ST(ut_setup, ut_teardown,
18153 			test_snow3g_decryption_test_case_1_oop),
18154 
18155 		/** SNOW 3G generate auth, then encrypt (UEA2) */
18156 		TEST_CASE_ST(ut_setup, ut_teardown,
18157 			test_snow3g_auth_cipher_test_case_1),
18158 		TEST_CASE_ST(ut_setup, ut_teardown,
18159 			test_snow3g_auth_cipher_test_case_2),
18160 		TEST_CASE_ST(ut_setup, ut_teardown,
18161 			test_snow3g_auth_cipher_test_case_2_oop),
18162 		TEST_CASE_ST(ut_setup, ut_teardown,
18163 			test_snow3g_auth_cipher_part_digest_enc),
18164 		TEST_CASE_ST(ut_setup, ut_teardown,
18165 			test_snow3g_auth_cipher_part_digest_enc_oop),
18166 		TEST_CASE_ST(ut_setup, ut_teardown,
18167 			test_snow3g_auth_cipher_test_case_3_sgl),
18168 		TEST_CASE_ST(ut_setup, ut_teardown,
18169 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
18170 		TEST_CASE_ST(ut_setup, ut_teardown,
18171 			test_snow3g_auth_cipher_part_digest_enc_sgl),
18172 		TEST_CASE_ST(ut_setup, ut_teardown,
18173 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
18174 		TEST_CASE_ST(ut_setup, ut_teardown,
18175 			test_snow3g_auth_cipher_total_digest_enc_1),
18176 		TEST_CASE_ST(ut_setup, ut_teardown,
18177 			test_snow3g_auth_cipher_total_digest_enc_1_oop),
18178 		TEST_CASE_ST(ut_setup, ut_teardown,
18179 			test_snow3g_auth_cipher_total_digest_enc_1_sgl),
18180 		TEST_CASE_ST(ut_setup, ut_teardown,
18181 			test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
18182 
18183 		/** SNOW 3G decrypt (UEA2), then verify auth */
18184 		TEST_CASE_ST(ut_setup, ut_teardown,
18185 			test_snow3g_auth_cipher_verify_test_case_1),
18186 		TEST_CASE_ST(ut_setup, ut_teardown,
18187 			test_snow3g_auth_cipher_verify_test_case_2),
18188 		TEST_CASE_ST(ut_setup, ut_teardown,
18189 			test_snow3g_auth_cipher_verify_test_case_2_oop),
18190 		TEST_CASE_ST(ut_setup, ut_teardown,
18191 			test_snow3g_auth_cipher_verify_part_digest_enc),
18192 		TEST_CASE_ST(ut_setup, ut_teardown,
18193 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
18194 		TEST_CASE_ST(ut_setup, ut_teardown,
18195 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
18196 		TEST_CASE_ST(ut_setup, ut_teardown,
18197 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
18198 		TEST_CASE_ST(ut_setup, ut_teardown,
18199 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
18200 		TEST_CASE_ST(ut_setup, ut_teardown,
18201 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
18202 		TEST_CASE_ST(ut_setup, ut_teardown,
18203 			test_snow3g_auth_cipher_verify_total_digest_enc_1),
18204 		TEST_CASE_ST(ut_setup, ut_teardown,
18205 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
18206 		TEST_CASE_ST(ut_setup, ut_teardown,
18207 			test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
18208 		TEST_CASE_ST(ut_setup, ut_teardown,
18209 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
18210 
18211 		/** SNOW 3G decrypt only (UEA2) */
18212 		TEST_CASE_ST(ut_setup, ut_teardown,
18213 			test_snow3g_decryption_test_case_1),
18214 		TEST_CASE_ST(ut_setup, ut_teardown,
18215 			test_snow3g_decryption_test_case_2),
18216 		TEST_CASE_ST(ut_setup, ut_teardown,
18217 			test_snow3g_decryption_test_case_3),
18218 		TEST_CASE_ST(ut_setup, ut_teardown,
18219 			test_snow3g_decryption_test_case_4),
18220 		TEST_CASE_ST(ut_setup, ut_teardown,
18221 			test_snow3g_decryption_test_case_5),
18222 		TEST_CASE_ST(ut_setup, ut_teardown,
18223 			test_snow3g_decryption_with_digest_test_case_1),
18224 		TEST_CASE_ST(ut_setup, ut_teardown,
18225 			test_snow3g_hash_generate_test_case_1),
18226 		TEST_CASE_ST(ut_setup, ut_teardown,
18227 			test_snow3g_hash_generate_test_case_2),
18228 		TEST_CASE_ST(ut_setup, ut_teardown,
18229 			test_snow3g_hash_generate_test_case_3),
18230 
18231 		/* Tests with buffers which length is not byte-aligned */
18232 		TEST_CASE_ST(ut_setup, ut_teardown,
18233 			test_snow3g_hash_generate_test_case_4),
18234 		TEST_CASE_ST(ut_setup, ut_teardown,
18235 			test_snow3g_hash_generate_test_case_5),
18236 		TEST_CASE_ST(ut_setup, ut_teardown,
18237 			test_snow3g_hash_generate_test_case_6),
18238 		TEST_CASE_ST(ut_setup, ut_teardown,
18239 			test_snow3g_hash_verify_test_case_1),
18240 		TEST_CASE_ST(ut_setup, ut_teardown,
18241 			test_snow3g_hash_verify_test_case_2),
18242 		TEST_CASE_ST(ut_setup, ut_teardown,
18243 			test_snow3g_hash_verify_test_case_3),
18244 
18245 		/* Tests with buffers which length is not byte-aligned */
18246 		TEST_CASE_ST(ut_setup, ut_teardown,
18247 			test_snow3g_hash_verify_test_case_4),
18248 		TEST_CASE_ST(ut_setup, ut_teardown,
18249 			test_snow3g_hash_verify_test_case_5),
18250 		TEST_CASE_ST(ut_setup, ut_teardown,
18251 			test_snow3g_hash_verify_test_case_6),
18252 		TEST_CASE_ST(ut_setup, ut_teardown,
18253 			test_snow3g_cipher_auth_test_case_1),
18254 		TEST_CASE_ST(ut_setup, ut_teardown,
18255 			test_snow3g_auth_cipher_with_digest_test_case_1),
18256 		TEST_CASES_END()
18257 	}
18258 };
18259 
18260 static struct unit_test_suite cryptodev_zuc_testsuite  = {
18261 	.suite_name = "ZUC Test Suite",
18262 	.setup = zuc_testsuite_setup,
18263 	.unit_test_cases = {
18264 		/** ZUC encrypt only (EEA3) */
18265 		TEST_CASE_ST(ut_setup, ut_teardown,
18266 			test_zuc_encryption_test_case_1),
18267 		TEST_CASE_ST(ut_setup, ut_teardown,
18268 			test_zuc_encryption_test_case_2),
18269 		TEST_CASE_ST(ut_setup, ut_teardown,
18270 			test_zuc_encryption_test_case_3),
18271 		TEST_CASE_ST(ut_setup, ut_teardown,
18272 			test_zuc_encryption_test_case_4),
18273 		TEST_CASE_ST(ut_setup, ut_teardown,
18274 			test_zuc_encryption_test_case_5),
18275 		TEST_CASE_ST(ut_setup, ut_teardown,
18276 			test_zuc_encryption_test_case_6_sgl),
18277 
18278 		/** ZUC decrypt only (EEA3) */
18279 		TEST_CASE_ST(ut_setup, ut_teardown,
18280 			test_zuc_decryption_test_case_1),
18281 		TEST_CASE_ST(ut_setup, ut_teardown,
18282 			test_zuc_decryption_test_case_2),
18283 		TEST_CASE_ST(ut_setup, ut_teardown,
18284 			test_zuc_decryption_test_case_3),
18285 		TEST_CASE_ST(ut_setup, ut_teardown,
18286 			test_zuc_decryption_test_case_4),
18287 		TEST_CASE_ST(ut_setup, ut_teardown,
18288 			test_zuc_decryption_test_case_5),
18289 		TEST_CASE_ST(ut_setup, ut_teardown,
18290 			test_zuc_decryption_test_case_6_sgl),
18291 
18292 		/** ZUC authenticate (EIA3) */
18293 		TEST_CASE_ST(ut_setup, ut_teardown,
18294 			test_zuc_hash_generate_test_case_1),
18295 		TEST_CASE_ST(ut_setup, ut_teardown,
18296 			test_zuc_hash_generate_test_case_2),
18297 		TEST_CASE_ST(ut_setup, ut_teardown,
18298 			test_zuc_hash_generate_test_case_3),
18299 		TEST_CASE_ST(ut_setup, ut_teardown,
18300 			test_zuc_hash_generate_test_case_4),
18301 		TEST_CASE_ST(ut_setup, ut_teardown,
18302 			test_zuc_hash_generate_test_case_5),
18303 		TEST_CASE_ST(ut_setup, ut_teardown,
18304 			test_zuc_hash_generate_test_case_6),
18305 		TEST_CASE_ST(ut_setup, ut_teardown,
18306 			test_zuc_hash_generate_test_case_7),
18307 		TEST_CASE_ST(ut_setup, ut_teardown,
18308 			test_zuc_hash_generate_test_case_8),
18309 
18310 		/** ZUC verify (EIA3) */
18311 		TEST_CASE_ST(ut_setup, ut_teardown,
18312 			test_zuc_hash_verify_test_case_1),
18313 		TEST_CASE_ST(ut_setup, ut_teardown,
18314 			test_zuc_hash_verify_test_case_2),
18315 		TEST_CASE_ST(ut_setup, ut_teardown,
18316 			test_zuc_hash_verify_test_case_3),
18317 		TEST_CASE_ST(ut_setup, ut_teardown,
18318 			test_zuc_hash_verify_test_case_4),
18319 		TEST_CASE_ST(ut_setup, ut_teardown,
18320 			test_zuc_hash_verify_test_case_5),
18321 		TEST_CASE_ST(ut_setup, ut_teardown,
18322 			test_zuc_hash_verify_test_case_6),
18323 		TEST_CASE_ST(ut_setup, ut_teardown,
18324 			test_zuc_hash_verify_test_case_7),
18325 		TEST_CASE_ST(ut_setup, ut_teardown,
18326 			test_zuc_hash_verify_test_case_8),
18327 
18328 		/** ZUC alg-chain (EEA3/EIA3) */
18329 		TEST_CASE_ST(ut_setup, ut_teardown,
18330 			test_zuc_cipher_auth_test_case_1),
18331 		TEST_CASE_ST(ut_setup, ut_teardown,
18332 			test_zuc_cipher_auth_test_case_2),
18333 
18334 		/** ZUC generate auth, then encrypt (EEA3) */
18335 		TEST_CASE_ST(ut_setup, ut_teardown,
18336 			test_zuc_auth_cipher_test_case_1),
18337 		TEST_CASE_ST(ut_setup, ut_teardown,
18338 			test_zuc_auth_cipher_test_case_1_oop),
18339 		TEST_CASE_ST(ut_setup, ut_teardown,
18340 			test_zuc_auth_cipher_test_case_1_sgl),
18341 		TEST_CASE_ST(ut_setup, ut_teardown,
18342 			test_zuc_auth_cipher_test_case_1_oop_sgl),
18343 		TEST_CASE_ST(ut_setup, ut_teardown,
18344 			test_zuc_auth_cipher_test_case_2),
18345 		TEST_CASE_ST(ut_setup, ut_teardown,
18346 			test_zuc_auth_cipher_test_case_2_oop),
18347 
18348 		/** ZUC decrypt (EEA3), then verify auth */
18349 		TEST_CASE_ST(ut_setup, ut_teardown,
18350 			test_zuc_auth_cipher_verify_test_case_1),
18351 		TEST_CASE_ST(ut_setup, ut_teardown,
18352 			test_zuc_auth_cipher_verify_test_case_1_oop),
18353 		TEST_CASE_ST(ut_setup, ut_teardown,
18354 			test_zuc_auth_cipher_verify_test_case_1_sgl),
18355 		TEST_CASE_ST(ut_setup, ut_teardown,
18356 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
18357 		TEST_CASE_ST(ut_setup, ut_teardown,
18358 			test_zuc_auth_cipher_verify_test_case_2),
18359 		TEST_CASE_ST(ut_setup, ut_teardown,
18360 			test_zuc_auth_cipher_verify_test_case_2_oop),
18361 
18362 		/** ZUC-256 encrypt only **/
18363 		TEST_CASE_ST(ut_setup, ut_teardown,
18364 			test_zuc256_encryption_test_case_1),
18365 		TEST_CASE_ST(ut_setup, ut_teardown,
18366 			test_zuc256_encryption_test_case_2),
18367 
18368 		/** ZUC-256 decrypt only **/
18369 		TEST_CASE_ST(ut_setup, ut_teardown,
18370 			test_zuc256_decryption_test_case_1),
18371 		TEST_CASE_ST(ut_setup, ut_teardown,
18372 			test_zuc256_decryption_test_case_2),
18373 
18374 		/** ZUC-256 authentication only **/
18375 		TEST_CASE_ST(ut_setup, ut_teardown,
18376 			test_zuc256_hash_generate_4b_tag_test_case_1),
18377 		TEST_CASE_ST(ut_setup, ut_teardown,
18378 			test_zuc256_hash_generate_4b_tag_test_case_2),
18379 		TEST_CASE_ST(ut_setup, ut_teardown,
18380 			test_zuc256_hash_generate_4b_tag_test_case_3),
18381 		TEST_CASE_ST(ut_setup, ut_teardown,
18382 			test_zuc256_hash_generate_8b_tag_test_case_1),
18383 		TEST_CASE_ST(ut_setup, ut_teardown,
18384 			test_zuc256_hash_generate_16b_tag_test_case_1),
18385 
18386 		/** ZUC-256 authentication verify only **/
18387 		TEST_CASE_ST(ut_setup, ut_teardown,
18388 			test_zuc256_hash_verify_4b_tag_test_case_1),
18389 		TEST_CASE_ST(ut_setup, ut_teardown,
18390 			test_zuc256_hash_verify_4b_tag_test_case_2),
18391 		TEST_CASE_ST(ut_setup, ut_teardown,
18392 			test_zuc256_hash_verify_4b_tag_test_case_3),
18393 		TEST_CASE_ST(ut_setup, ut_teardown,
18394 			test_zuc256_hash_verify_8b_tag_test_case_1),
18395 		TEST_CASE_ST(ut_setup, ut_teardown,
18396 			test_zuc256_hash_verify_16b_tag_test_case_1),
18397 
18398 		/** ZUC-256 encrypt and authenticate **/
18399 		TEST_CASE_ST(ut_setup, ut_teardown,
18400 			test_zuc256_cipher_auth_4b_tag_test_case_1),
18401 		TEST_CASE_ST(ut_setup, ut_teardown,
18402 			test_zuc256_cipher_auth_4b_tag_test_case_2),
18403 		TEST_CASE_ST(ut_setup, ut_teardown,
18404 			test_zuc256_cipher_auth_8b_tag_test_case_1),
18405 		TEST_CASE_ST(ut_setup, ut_teardown,
18406 			test_zuc256_cipher_auth_16b_tag_test_case_1),
18407 
18408 		/** ZUC-256 generate auth, then encrypt */
18409 		TEST_CASE_ST(ut_setup, ut_teardown,
18410 			test_zuc256_auth_cipher_4b_tag_test_case_1),
18411 		TEST_CASE_ST(ut_setup, ut_teardown,
18412 			test_zuc256_auth_cipher_4b_tag_test_case_2),
18413 		TEST_CASE_ST(ut_setup, ut_teardown,
18414 			test_zuc256_auth_cipher_8b_tag_test_case_1),
18415 		TEST_CASE_ST(ut_setup, ut_teardown,
18416 			test_zuc256_auth_cipher_16b_tag_test_case_1),
18417 
18418 		/** ZUC-256 decrypt, then verify auth */
18419 		TEST_CASE_ST(ut_setup, ut_teardown,
18420 			test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
18421 		TEST_CASE_ST(ut_setup, ut_teardown,
18422 			test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
18423 		TEST_CASE_ST(ut_setup, ut_teardown,
18424 			test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
18425 		TEST_CASE_ST(ut_setup, ut_teardown,
18426 			test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
18427 
18428 		TEST_CASES_END()
18429 	}
18430 };
18431 
18432 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
18433 	.suite_name = "HMAC_MD5 Authentication Test Suite",
18434 	.setup = hmac_md5_auth_testsuite_setup,
18435 	.unit_test_cases = {
18436 		TEST_CASE_ST(ut_setup, ut_teardown,
18437 			test_MD5_HMAC_generate_case_1),
18438 		TEST_CASE_ST(ut_setup, ut_teardown,
18439 			test_MD5_HMAC_verify_case_1),
18440 		TEST_CASE_ST(ut_setup, ut_teardown,
18441 			test_MD5_HMAC_generate_case_2),
18442 		TEST_CASE_ST(ut_setup, ut_teardown,
18443 			test_MD5_HMAC_verify_case_2),
18444 		TEST_CASES_END()
18445 	}
18446 };
18447 
18448 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
18449 	.suite_name = "Kasumi Test Suite",
18450 	.setup = kasumi_testsuite_setup,
18451 	.unit_test_cases = {
18452 		/** KASUMI hash only (UIA1) */
18453 		TEST_CASE_ST(ut_setup, ut_teardown,
18454 			test_kasumi_hash_generate_test_case_1),
18455 		TEST_CASE_ST(ut_setup, ut_teardown,
18456 			test_kasumi_hash_generate_test_case_2),
18457 		TEST_CASE_ST(ut_setup, ut_teardown,
18458 			test_kasumi_hash_generate_test_case_3),
18459 		TEST_CASE_ST(ut_setup, ut_teardown,
18460 			test_kasumi_hash_generate_test_case_4),
18461 		TEST_CASE_ST(ut_setup, ut_teardown,
18462 			test_kasumi_hash_generate_test_case_5),
18463 		TEST_CASE_ST(ut_setup, ut_teardown,
18464 			test_kasumi_hash_generate_test_case_6),
18465 
18466 		TEST_CASE_ST(ut_setup, ut_teardown,
18467 			test_kasumi_hash_verify_test_case_1),
18468 		TEST_CASE_ST(ut_setup, ut_teardown,
18469 			test_kasumi_hash_verify_test_case_2),
18470 		TEST_CASE_ST(ut_setup, ut_teardown,
18471 			test_kasumi_hash_verify_test_case_3),
18472 		TEST_CASE_ST(ut_setup, ut_teardown,
18473 			test_kasumi_hash_verify_test_case_4),
18474 		TEST_CASE_ST(ut_setup, ut_teardown,
18475 			test_kasumi_hash_verify_test_case_5),
18476 
18477 		/** KASUMI encrypt only (UEA1) */
18478 		TEST_CASE_ST(ut_setup, ut_teardown,
18479 			test_kasumi_encryption_test_case_1),
18480 		TEST_CASE_ST(ut_setup, ut_teardown,
18481 			test_kasumi_encryption_test_case_1_sgl),
18482 		TEST_CASE_ST(ut_setup, ut_teardown,
18483 			test_kasumi_encryption_test_case_1_oop),
18484 		TEST_CASE_ST(ut_setup, ut_teardown,
18485 			test_kasumi_encryption_test_case_1_oop_sgl),
18486 		TEST_CASE_ST(ut_setup, ut_teardown,
18487 			test_kasumi_encryption_test_case_2),
18488 		TEST_CASE_ST(ut_setup, ut_teardown,
18489 			test_kasumi_encryption_test_case_3),
18490 		TEST_CASE_ST(ut_setup, ut_teardown,
18491 			test_kasumi_encryption_test_case_4),
18492 		TEST_CASE_ST(ut_setup, ut_teardown,
18493 			test_kasumi_encryption_test_case_5),
18494 
18495 		/** KASUMI decrypt only (UEA1) */
18496 		TEST_CASE_ST(ut_setup, ut_teardown,
18497 			test_kasumi_decryption_test_case_1),
18498 		TEST_CASE_ST(ut_setup, ut_teardown,
18499 			test_kasumi_decryption_test_case_2),
18500 		TEST_CASE_ST(ut_setup, ut_teardown,
18501 			test_kasumi_decryption_test_case_3),
18502 		TEST_CASE_ST(ut_setup, ut_teardown,
18503 			test_kasumi_decryption_test_case_4),
18504 		TEST_CASE_ST(ut_setup, ut_teardown,
18505 			test_kasumi_decryption_test_case_5),
18506 		TEST_CASE_ST(ut_setup, ut_teardown,
18507 			test_kasumi_decryption_test_case_1_oop),
18508 		TEST_CASE_ST(ut_setup, ut_teardown,
18509 			test_kasumi_cipher_auth_test_case_1),
18510 
18511 		/** KASUMI generate auth, then encrypt (F8) */
18512 		TEST_CASE_ST(ut_setup, ut_teardown,
18513 			test_kasumi_auth_cipher_test_case_1),
18514 		TEST_CASE_ST(ut_setup, ut_teardown,
18515 			test_kasumi_auth_cipher_test_case_2),
18516 		TEST_CASE_ST(ut_setup, ut_teardown,
18517 			test_kasumi_auth_cipher_test_case_2_oop),
18518 		TEST_CASE_ST(ut_setup, ut_teardown,
18519 			test_kasumi_auth_cipher_test_case_2_sgl),
18520 		TEST_CASE_ST(ut_setup, ut_teardown,
18521 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
18522 
18523 		/** KASUMI decrypt (F8), then verify auth */
18524 		TEST_CASE_ST(ut_setup, ut_teardown,
18525 			test_kasumi_auth_cipher_verify_test_case_1),
18526 		TEST_CASE_ST(ut_setup, ut_teardown,
18527 			test_kasumi_auth_cipher_verify_test_case_2),
18528 		TEST_CASE_ST(ut_setup, ut_teardown,
18529 			test_kasumi_auth_cipher_verify_test_case_2_oop),
18530 		TEST_CASE_ST(ut_setup, ut_teardown,
18531 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
18532 		TEST_CASE_ST(ut_setup, ut_teardown,
18533 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
18534 
18535 		TEST_CASES_END()
18536 	}
18537 };
18538 
18539 static struct unit_test_suite cryptodev_esn_testsuite  = {
18540 	.suite_name = "ESN Test Suite",
18541 	.setup = esn_testsuite_setup,
18542 	.unit_test_cases = {
18543 		TEST_CASE_ST(ut_setup, ut_teardown,
18544 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
18545 		TEST_CASE_ST(ut_setup, ut_teardown,
18546 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
18547 		TEST_CASES_END()
18548 	}
18549 };
18550 
18551 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
18552 	.suite_name = "Negative AES GCM Test Suite",
18553 	.setup = negative_aes_gcm_testsuite_setup,
18554 	.unit_test_cases = {
18555 		TEST_CASE_ST(ut_setup, ut_teardown,
18556 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
18557 		TEST_CASE_ST(ut_setup, ut_teardown,
18558 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
18559 		TEST_CASE_ST(ut_setup, ut_teardown,
18560 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
18561 		TEST_CASE_ST(ut_setup, ut_teardown,
18562 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
18563 		TEST_CASE_ST(ut_setup, ut_teardown,
18564 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
18565 		TEST_CASE_ST(ut_setup, ut_teardown,
18566 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
18567 		TEST_CASE_ST(ut_setup, ut_teardown,
18568 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
18569 		TEST_CASE_ST(ut_setup, ut_teardown,
18570 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
18571 		TEST_CASE_ST(ut_setup, ut_teardown,
18572 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
18573 		TEST_CASE_ST(ut_setup, ut_teardown,
18574 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
18575 		TEST_CASE_ST(ut_setup, ut_teardown,
18576 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
18577 		TEST_CASE_ST(ut_setup, ut_teardown,
18578 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
18579 
18580 		TEST_CASES_END()
18581 	}
18582 };
18583 
18584 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
18585 	.suite_name = "Negative AES GMAC Test Suite",
18586 	.setup = negative_aes_gmac_testsuite_setup,
18587 	.unit_test_cases = {
18588 		TEST_CASE_ST(ut_setup, ut_teardown,
18589 			authentication_verify_AES128_GMAC_fail_data_corrupt),
18590 		TEST_CASE_ST(ut_setup, ut_teardown,
18591 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
18592 
18593 		TEST_CASES_END()
18594 	}
18595 };
18596 
18597 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
18598 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
18599 	.setup = mixed_cipher_hash_testsuite_setup,
18600 	.unit_test_cases = {
18601 		/** AUTH AES CMAC + CIPHER AES CTR */
18602 		TEST_CASE_ST(ut_setup, ut_teardown,
18603 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
18604 		TEST_CASE_ST(ut_setup, ut_teardown,
18605 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18606 		TEST_CASE_ST(ut_setup, ut_teardown,
18607 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18608 		TEST_CASE_ST(ut_setup, ut_teardown,
18609 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18610 		TEST_CASE_ST(ut_setup, ut_teardown,
18611 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
18612 		TEST_CASE_ST(ut_setup, ut_teardown,
18613 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18614 		TEST_CASE_ST(ut_setup, ut_teardown,
18615 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18616 		TEST_CASE_ST(ut_setup, ut_teardown,
18617 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18618 		TEST_CASE_ST(ut_setup, ut_teardown,
18619 			test_aes_cmac_aes_ctr_digest_enc_test_case_2),
18620 		TEST_CASE_ST(ut_setup, ut_teardown,
18621 			test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18622 		TEST_CASE_ST(ut_setup, ut_teardown,
18623 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
18624 		TEST_CASE_ST(ut_setup, ut_teardown,
18625 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18626 
18627 		/** AUTH ZUC + CIPHER SNOW3G */
18628 		TEST_CASE_ST(ut_setup, ut_teardown,
18629 			test_auth_zuc_cipher_snow_test_case_1),
18630 		TEST_CASE_ST(ut_setup, ut_teardown,
18631 			test_verify_auth_zuc_cipher_snow_test_case_1),
18632 		TEST_CASE_ST(ut_setup, ut_teardown,
18633 			test_auth_zuc_cipher_snow_test_case_1_inplace),
18634 		TEST_CASE_ST(ut_setup, ut_teardown,
18635 			test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
18636 		/** AUTH AES CMAC + CIPHER SNOW3G */
18637 		TEST_CASE_ST(ut_setup, ut_teardown,
18638 			test_auth_aes_cmac_cipher_snow_test_case_1),
18639 		TEST_CASE_ST(ut_setup, ut_teardown,
18640 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
18641 		TEST_CASE_ST(ut_setup, ut_teardown,
18642 			test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18643 		TEST_CASE_ST(ut_setup, ut_teardown,
18644 			test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18645 		/** AUTH ZUC + CIPHER AES CTR */
18646 		TEST_CASE_ST(ut_setup, ut_teardown,
18647 			test_auth_zuc_cipher_aes_ctr_test_case_1),
18648 		TEST_CASE_ST(ut_setup, ut_teardown,
18649 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
18650 		TEST_CASE_ST(ut_setup, ut_teardown,
18651 			test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18652 		TEST_CASE_ST(ut_setup, ut_teardown,
18653 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18654 		/** AUTH SNOW3G + CIPHER AES CTR */
18655 		TEST_CASE_ST(ut_setup, ut_teardown,
18656 			test_auth_snow_cipher_aes_ctr_test_case_1),
18657 		TEST_CASE_ST(ut_setup, ut_teardown,
18658 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
18659 		TEST_CASE_ST(ut_setup, ut_teardown,
18660 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18661 		TEST_CASE_ST(ut_setup, ut_teardown,
18662 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18663 		TEST_CASE_ST(ut_setup, ut_teardown,
18664 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18665 		TEST_CASE_ST(ut_setup, ut_teardown,
18666 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18667 		/** AUTH SNOW3G + CIPHER ZUC */
18668 		TEST_CASE_ST(ut_setup, ut_teardown,
18669 			test_auth_snow_cipher_zuc_test_case_1),
18670 		TEST_CASE_ST(ut_setup, ut_teardown,
18671 			test_verify_auth_snow_cipher_zuc_test_case_1),
18672 		TEST_CASE_ST(ut_setup, ut_teardown,
18673 			test_auth_snow_cipher_zuc_test_case_1_inplace),
18674 		TEST_CASE_ST(ut_setup, ut_teardown,
18675 			test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
18676 		/** AUTH AES CMAC + CIPHER ZUC */
18677 		TEST_CASE_ST(ut_setup, ut_teardown,
18678 			test_auth_aes_cmac_cipher_zuc_test_case_1),
18679 		TEST_CASE_ST(ut_setup, ut_teardown,
18680 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
18681 		TEST_CASE_ST(ut_setup, ut_teardown,
18682 			test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18683 		TEST_CASE_ST(ut_setup, ut_teardown,
18684 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18685 
18686 		/** AUTH NULL + CIPHER SNOW3G */
18687 		TEST_CASE_ST(ut_setup, ut_teardown,
18688 			test_auth_null_cipher_snow_test_case_1),
18689 		TEST_CASE_ST(ut_setup, ut_teardown,
18690 			test_verify_auth_null_cipher_snow_test_case_1),
18691 		/** AUTH NULL + CIPHER ZUC */
18692 		TEST_CASE_ST(ut_setup, ut_teardown,
18693 			test_auth_null_cipher_zuc_test_case_1),
18694 		TEST_CASE_ST(ut_setup, ut_teardown,
18695 			test_verify_auth_null_cipher_zuc_test_case_1),
18696 		/** AUTH SNOW3G + CIPHER NULL */
18697 		TEST_CASE_ST(ut_setup, ut_teardown,
18698 			test_auth_snow_cipher_null_test_case_1),
18699 		TEST_CASE_ST(ut_setup, ut_teardown,
18700 			test_verify_auth_snow_cipher_null_test_case_1),
18701 		/** AUTH ZUC + CIPHER NULL */
18702 		TEST_CASE_ST(ut_setup, ut_teardown,
18703 			test_auth_zuc_cipher_null_test_case_1),
18704 		TEST_CASE_ST(ut_setup, ut_teardown,
18705 			test_verify_auth_zuc_cipher_null_test_case_1),
18706 		/** AUTH NULL + CIPHER AES CTR */
18707 		TEST_CASE_ST(ut_setup, ut_teardown,
18708 			test_auth_null_cipher_aes_ctr_test_case_1),
18709 		TEST_CASE_ST(ut_setup, ut_teardown,
18710 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
18711 		/** AUTH AES CMAC + CIPHER NULL */
18712 		TEST_CASE_ST(ut_setup, ut_teardown,
18713 			test_auth_aes_cmac_cipher_null_test_case_1),
18714 		TEST_CASE_ST(ut_setup, ut_teardown,
18715 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
18716 		TEST_CASES_END()
18717 	}
18718 };
18719 
18720 static int
18721 run_cryptodev_testsuite(const char *pmd_name)
18722 {
18723 	uint8_t ret, j, i = 0, blk_start_idx = 0;
18724 	const enum blockcipher_test_type blk_suites[] = {
18725 		BLKCIPHER_AES_CHAIN_TYPE,
18726 		BLKCIPHER_AES_CIPHERONLY_TYPE,
18727 		BLKCIPHER_AES_DOCSIS_TYPE,
18728 		BLKCIPHER_3DES_CHAIN_TYPE,
18729 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
18730 		BLKCIPHER_DES_CIPHERONLY_TYPE,
18731 		BLKCIPHER_DES_DOCSIS_TYPE,
18732 		BLKCIPHER_SM4_CHAIN_TYPE,
18733 		BLKCIPHER_SM4_CIPHERONLY_TYPE,
18734 		BLKCIPHER_AUTHONLY_TYPE};
18735 	struct unit_test_suite *static_suites[] = {
18736 		&cryptodev_multi_session_testsuite,
18737 		&cryptodev_null_testsuite,
18738 		&cryptodev_aes_ccm_auth_testsuite,
18739 		&cryptodev_aes_gcm_auth_testsuite,
18740 		&cryptodev_aes_gmac_auth_testsuite,
18741 		&cryptodev_snow3g_testsuite,
18742 		&cryptodev_chacha20_poly1305_testsuite,
18743 		&cryptodev_zuc_testsuite,
18744 		&cryptodev_hmac_md5_auth_testsuite,
18745 		&cryptodev_kasumi_testsuite,
18746 		&cryptodev_esn_testsuite,
18747 		&cryptodev_negative_aes_gcm_testsuite,
18748 		&cryptodev_negative_aes_gmac_testsuite,
18749 		&cryptodev_mixed_cipher_hash_testsuite,
18750 		&cryptodev_negative_hmac_sha1_testsuite,
18751 		&cryptodev_gen_testsuite,
18752 #ifdef RTE_LIB_SECURITY
18753 		&ipsec_proto_testsuite,
18754 		&pdcp_proto_testsuite,
18755 		&docsis_proto_testsuite,
18756 		&tls12_record_proto_testsuite,
18757 		&dtls12_record_proto_testsuite,
18758 		&tls13_record_proto_testsuite,
18759 #endif
18760 		&end_testsuite
18761 	};
18762 	static struct unit_test_suite ts = {
18763 		.suite_name = "Cryptodev Unit Test Suite",
18764 		.setup = testsuite_setup,
18765 		.teardown = testsuite_teardown,
18766 		.unit_test_cases = {TEST_CASES_END()}
18767 	};
18768 
18769 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
18770 
18771 	if (gbl_driver_id == -1) {
18772 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
18773 		return TEST_SKIPPED;
18774 	}
18775 
18776 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
18777 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
18778 
18779 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
18780 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
18781 	ret = unit_test_suite_runner(&ts);
18782 
18783 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
18784 	free(ts.unit_test_suites);
18785 	return ret;
18786 }
18787 
18788 static int
18789 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
18790 {
18791 	struct rte_cryptodev_info dev_info;
18792 	uint8_t i, nb_devs;
18793 	int driver_id;
18794 
18795 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
18796 	if (driver_id == -1) {
18797 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
18798 		return TEST_SKIPPED;
18799 	}
18800 
18801 	nb_devs = rte_cryptodev_count();
18802 	if (nb_devs < 1) {
18803 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
18804 		return TEST_SKIPPED;
18805 	}
18806 
18807 	for (i = 0; i < nb_devs; i++) {
18808 		rte_cryptodev_info_get(i, &dev_info);
18809 		if (dev_info.driver_id == driver_id) {
18810 			if (!(dev_info.feature_flags & flag)) {
18811 				RTE_LOG(INFO, USER1, "%s not supported\n",
18812 						flag_name);
18813 				return TEST_SKIPPED;
18814 			}
18815 			return 0; /* found */
18816 		}
18817 	}
18818 
18819 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
18820 	return TEST_SKIPPED;
18821 }
18822 
18823 static int
18824 test_cryptodev_qat(void)
18825 {
18826 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
18827 }
18828 
18829 static int
18830 test_cryptodev_uadk(void)
18831 {
18832 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
18833 }
18834 
18835 static int
18836 test_cryptodev_virtio(void)
18837 {
18838 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
18839 }
18840 
18841 static int
18842 test_cryptodev_aesni_mb(void)
18843 {
18844 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18845 }
18846 
18847 static int
18848 test_cryptodev_cpu_aesni_mb(void)
18849 {
18850 	int32_t rc;
18851 	enum rte_security_session_action_type at = gbl_action_type;
18852 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18853 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
18854 	gbl_action_type = at;
18855 	return rc;
18856 }
18857 
18858 static int
18859 test_cryptodev_chacha_poly_mb(void)
18860 {
18861 	int32_t rc;
18862 	enum rte_security_session_action_type at = gbl_action_type;
18863 	rc = run_cryptodev_testsuite(
18864 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
18865 	gbl_action_type = at;
18866 	return rc;
18867 }
18868 
18869 static int
18870 test_cryptodev_openssl(void)
18871 {
18872 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
18873 }
18874 
18875 static int
18876 test_cryptodev_aesni_gcm(void)
18877 {
18878 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18879 }
18880 
18881 static int
18882 test_cryptodev_cpu_aesni_gcm(void)
18883 {
18884 	int32_t rc;
18885 	enum rte_security_session_action_type at = gbl_action_type;
18886 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
18887 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
18888 	gbl_action_type = at;
18889 	return rc;
18890 }
18891 
18892 static int
18893 test_cryptodev_mlx5(void)
18894 {
18895 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
18896 }
18897 
18898 static int
18899 test_cryptodev_null(void)
18900 {
18901 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
18902 }
18903 
18904 static int
18905 test_cryptodev_sw_snow3g(void)
18906 {
18907 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
18908 }
18909 
18910 static int
18911 test_cryptodev_sw_kasumi(void)
18912 {
18913 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
18914 }
18915 
18916 static int
18917 test_cryptodev_sw_zuc(void)
18918 {
18919 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
18920 }
18921 
18922 static int
18923 test_cryptodev_armv8(void)
18924 {
18925 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
18926 }
18927 
18928 static int
18929 test_cryptodev_mrvl(void)
18930 {
18931 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
18932 }
18933 
18934 #ifdef RTE_CRYPTO_SCHEDULER
18935 
18936 static int
18937 test_cryptodev_scheduler(void)
18938 {
18939 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
18940 	const enum blockcipher_test_type blk_suites[] = {
18941 		BLKCIPHER_AES_CHAIN_TYPE,
18942 		BLKCIPHER_AES_CIPHERONLY_TYPE,
18943 		BLKCIPHER_AUTHONLY_TYPE
18944 	};
18945 	static struct unit_test_suite scheduler_multicore = {
18946 		.suite_name = "Scheduler Multicore Unit Test Suite",
18947 		.setup = scheduler_multicore_testsuite_setup,
18948 		.teardown = scheduler_mode_testsuite_teardown,
18949 		.unit_test_cases = {TEST_CASES_END()}
18950 	};
18951 	static struct unit_test_suite scheduler_round_robin = {
18952 		.suite_name = "Scheduler Round Robin Unit Test Suite",
18953 		.setup = scheduler_roundrobin_testsuite_setup,
18954 		.teardown = scheduler_mode_testsuite_teardown,
18955 		.unit_test_cases = {TEST_CASES_END()}
18956 	};
18957 	static struct unit_test_suite scheduler_failover = {
18958 		.suite_name = "Scheduler Failover Unit Test Suite",
18959 		.setup = scheduler_failover_testsuite_setup,
18960 		.teardown = scheduler_mode_testsuite_teardown,
18961 		.unit_test_cases = {TEST_CASES_END()}
18962 	};
18963 	static struct unit_test_suite scheduler_pkt_size_distr = {
18964 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
18965 		.setup = scheduler_pkt_size_distr_testsuite_setup,
18966 		.teardown = scheduler_mode_testsuite_teardown,
18967 		.unit_test_cases = {TEST_CASES_END()}
18968 	};
18969 	struct unit_test_suite *sched_mode_suites[] = {
18970 		&scheduler_multicore,
18971 		&scheduler_round_robin,
18972 		&scheduler_failover,
18973 		&scheduler_pkt_size_distr
18974 	};
18975 	static struct unit_test_suite scheduler_config = {
18976 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
18977 		.unit_test_cases = {
18978 			TEST_CASE(test_scheduler_attach_worker_op),
18979 			TEST_CASE(test_scheduler_mode_multicore_op),
18980 			TEST_CASE(test_scheduler_mode_roundrobin_op),
18981 			TEST_CASE(test_scheduler_mode_failover_op),
18982 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
18983 			TEST_CASE(test_scheduler_detach_worker_op),
18984 
18985 			TEST_CASES_END() /**< NULL terminate array */
18986 		}
18987 	};
18988 	struct unit_test_suite *static_suites[] = {
18989 		&scheduler_config,
18990 		&end_testsuite
18991 	};
18992 	struct unit_test_suite *sched_mode_static_suites[] = {
18993 #ifdef RTE_LIB_SECURITY
18994 		&docsis_proto_testsuite,
18995 #endif
18996 		&end_testsuite
18997 	};
18998 	static struct unit_test_suite ts = {
18999 		.suite_name = "Scheduler Unit Test Suite",
19000 		.setup = scheduler_testsuite_setup,
19001 		.teardown = testsuite_teardown,
19002 		.unit_test_cases = {TEST_CASES_END()}
19003 	};
19004 
19005 	gbl_driver_id =	rte_cryptodev_driver_id_get(
19006 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
19007 
19008 	if (gbl_driver_id == -1) {
19009 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
19010 		return TEST_SKIPPED;
19011 	}
19012 
19013 	if (rte_cryptodev_driver_id_get(
19014 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
19015 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
19016 		return TEST_SKIPPED;
19017 	}
19018 
19019 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19020 		uint8_t blk_i = 0;
19021 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
19022 				(struct unit_test_suite *) *
19023 				(RTE_DIM(blk_suites) +
19024 				RTE_DIM(sched_mode_static_suites) + 1));
19025 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19026 				blk_suites, RTE_DIM(blk_suites));
19027 		ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19028 				sched_mode_static_suites,
19029 				RTE_DIM(sched_mode_static_suites));
19030 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
19031 	}
19032 
19033 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19034 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
19035 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
19036 			RTE_DIM(sched_mode_suites));
19037 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19038 	ret = unit_test_suite_runner(&ts);
19039 
19040 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19041 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
19042 				(*sched_mode_suites[sched_i]),
19043 				RTE_DIM(blk_suites));
19044 		free(sched_mode_suites[sched_i]->unit_test_suites);
19045 	}
19046 	free(ts.unit_test_suites);
19047 	return ret;
19048 }
19049 
19050 REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
19051 
19052 #endif
19053 
19054 static int
19055 test_cryptodev_dpaa2_sec(void)
19056 {
19057 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19058 }
19059 
19060 static int
19061 test_cryptodev_dpaa_sec(void)
19062 {
19063 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19064 }
19065 
19066 static int
19067 test_cryptodev_ccp(void)
19068 {
19069 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
19070 }
19071 
19072 static int
19073 test_cryptodev_octeontx(void)
19074 {
19075 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
19076 }
19077 
19078 static int
19079 test_cryptodev_caam_jr(void)
19080 {
19081 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
19082 }
19083 
19084 static int
19085 test_cryptodev_nitrox(void)
19086 {
19087 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
19088 }
19089 
19090 static int
19091 test_cryptodev_bcmfs(void)
19092 {
19093 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
19094 }
19095 
19096 static int
19097 run_cryptodev_raw_testsuite(const char *pmd_name)
19098 {
19099 	int ret;
19100 
19101 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
19102 	if (ret)
19103 		return ret;
19104 
19105 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
19106 	ret = run_cryptodev_testsuite(pmd_name);
19107 	global_api_test_type = CRYPTODEV_API_TEST;
19108 
19109 	return ret;
19110 }
19111 
19112 static int
19113 test_cryptodev_qat_raw_api(void)
19114 {
19115 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19116 }
19117 
19118 static int
19119 test_cryptodev_cn9k(void)
19120 {
19121 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
19122 }
19123 
19124 static int
19125 test_cryptodev_cn10k(void)
19126 {
19127 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19128 }
19129 
19130 static int
19131 test_cryptodev_cn10k_raw_api(void)
19132 {
19133 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19134 }
19135 
19136 static int
19137 test_cryptodev_dpaa2_sec_raw_api(void)
19138 {
19139 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19140 }
19141 
19142 static int
19143 test_cryptodev_dpaa_sec_raw_api(void)
19144 {
19145 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19146 }
19147 
19148 REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
19149 		test_cryptodev_cn10k_raw_api);
19150 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
19151 		test_cryptodev_dpaa2_sec_raw_api);
19152 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
19153 		test_cryptodev_dpaa_sec_raw_api);
19154 REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
19155 		test_cryptodev_qat_raw_api);
19156 REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
19157 REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
19158 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
19159 	test_cryptodev_cpu_aesni_mb);
19160 REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
19161 	test_cryptodev_chacha_poly_mb);
19162 REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
19163 REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
19164 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
19165 	test_cryptodev_cpu_aesni_gcm);
19166 REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
19167 REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
19168 REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
19169 REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
19170 REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
19171 REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
19172 REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
19173 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
19174 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
19175 REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
19176 REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
19177 REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
19178 REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
19179 REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
19180 REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
19181 REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
19182 REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
19183 REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
19184