xref: /dpdk/app/test/test_cryptodev.c (revision b462f2737eb08b07b84da4204fbd1c9b9ba00b2d)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Intel Corporation
3  * Copyright 2020 NXP
4  */
5 
6 #include <stdbool.h>
7 #include <time.h>
8 
9 #include <rte_common.h>
10 #include <rte_hexdump.h>
11 #include <rte_mbuf.h>
12 #include <rte_malloc.h>
13 #include <rte_memcpy.h>
14 #include <rte_pause.h>
15 #include <rte_bus_vdev.h>
16 #include <rte_ether.h>
17 #include <rte_errno.h>
18 
19 #include <rte_crypto.h>
20 #include <rte_cryptodev.h>
21 #include <rte_ethdev.h>
22 #include <rte_ip.h>
23 #include <rte_string_fns.h>
24 #include <rte_tcp.h>
25 #include <rte_tls.h>
26 #include <rte_udp.h>
27 
28 #ifdef RTE_CRYPTO_SCHEDULER
29 #include <rte_cryptodev_scheduler.h>
30 #include <rte_cryptodev_scheduler_operations.h>
31 #endif
32 
33 #include <rte_lcore.h>
34 
35 #include "test.h"
36 #include "test_cryptodev.h"
37 
38 #include "test_cryptodev_blockcipher.h"
39 #include "test_cryptodev_aes_test_vectors.h"
40 #include "test_cryptodev_des_test_vectors.h"
41 #include "test_cryptodev_hash_test_vectors.h"
42 #include "test_cryptodev_kasumi_test_vectors.h"
43 #include "test_cryptodev_kasumi_hash_test_vectors.h"
44 #include "test_cryptodev_snow3g_test_vectors.h"
45 #include "test_cryptodev_snow3g_hash_test_vectors.h"
46 #include "test_cryptodev_zuc_test_vectors.h"
47 #include "test_cryptodev_aead_test_vectors.h"
48 #include "test_cryptodev_hmac_test_vectors.h"
49 #include "test_cryptodev_mixed_test_vectors.h"
50 #include "test_cryptodev_sm4_test_vectors.h"
51 #ifdef RTE_LIB_SECURITY
52 #include "test_cryptodev_security_ipsec.h"
53 #include "test_cryptodev_security_ipsec_test_vectors.h"
54 #include "test_cryptodev_security_pdcp_test_vectors.h"
55 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
56 #include "test_cryptodev_security_pdcp_test_func.h"
57 #include "test_cryptodev_security_docsis_test_vectors.h"
58 #include "test_cryptodev_security_tls_record.h"
59 #include "test_security_proto.h"
60 
61 #define SDAP_DISABLED	0
62 #define SDAP_ENABLED	1
63 #endif
64 
65 #define VDEV_ARGS_SIZE 100
66 #define MAX_NB_SESSIONS 4
67 
68 #define MAX_RAW_DEQUEUE_COUNT	65535
69 
70 #define IN_PLACE 0
71 #define OUT_OF_PLACE 1
72 
73 #define QP_DRAIN_TIMEOUT 100
74 #define HW_ERR_RECOVER_TIMEOUT 500
75 
76 static int gbl_driver_id;
77 
78 static enum rte_security_session_action_type gbl_action_type =
79 	RTE_SECURITY_ACTION_TYPE_NONE;
80 
81 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
82 
83 struct crypto_unittest_params {
84 	struct rte_crypto_sym_xform cipher_xform;
85 	struct rte_crypto_sym_xform auth_xform;
86 	struct rte_crypto_sym_xform aead_xform;
87 #ifdef RTE_LIB_SECURITY
88 	struct rte_security_docsis_xform docsis_xform;
89 #endif
90 
91 	union {
92 		void *sess;
93 #ifdef RTE_LIB_SECURITY
94 		void *sec_session;
95 #endif
96 	};
97 #ifdef RTE_LIB_SECURITY
98 	enum rte_security_session_action_type type;
99 #endif
100 	struct rte_crypto_op *op;
101 
102 	struct rte_mbuf *obuf, *ibuf;
103 
104 	uint8_t *digest;
105 };
106 
107 #define ALIGN_POW2_ROUNDUP(num, align) \
108 	(((num) + (align) - 1) & ~((align) - 1))
109 
110 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
111 	for (j = 0; j < num_child_ts; index++, j++)			\
112 		parent_ts.unit_test_suites[index] = child_ts[j]
113 
114 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
115 	for (j = 0; j < num_blk_types; index++, j++)				\
116 		parent_ts.unit_test_suites[index] =				\
117 				build_blockcipher_test_suite(blk_types[j])
118 
119 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
120 	for (j = index; j < index + num_blk_types; j++)				\
121 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
122 
123 /*
124  * Forward declarations.
125  */
126 static int
127 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
128 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
129 		uint8_t *hmac_key);
130 
131 static int
132 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
133 		struct crypto_unittest_params *ut_params,
134 		struct crypto_testsuite_params *ts_param,
135 		const uint8_t *cipher,
136 		const uint8_t *digest,
137 		const uint8_t *iv);
138 
139 static int
140 security_proto_supported(enum rte_security_session_action_type action,
141 	enum rte_security_session_protocol proto);
142 
143 static int
144 dev_configure_and_start(uint64_t ff_disable);
145 
146 static int
147 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
148 			const enum rte_crypto_cipher_algorithm cipher_algo,
149 			const uint16_t key_size, const uint16_t iv_size);
150 
151 static int
152 check_auth_capability(const struct crypto_testsuite_params *ts_params,
153 			const enum rte_crypto_auth_algorithm auth_algo,
154 			const uint16_t key_size, const uint16_t iv_size,
155 			const uint16_t tag_size);
156 
157 static struct rte_mbuf *
158 setup_test_string(struct rte_mempool *mpool,
159 		const char *string, size_t len, uint8_t blocksize)
160 {
161 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
162 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
163 
164 	if (m) {
165 		char *dst;
166 
167 		memset(m->buf_addr, 0, m->buf_len);
168 		dst = rte_pktmbuf_append(m, t_len);
169 		if (!dst) {
170 			rte_pktmbuf_free(m);
171 			return NULL;
172 		}
173 		if (string != NULL)
174 			rte_memcpy(dst, string, t_len);
175 		else
176 			memset(dst, 0, t_len);
177 	}
178 
179 	return m;
180 }
181 
182 /* Get number of bytes in X bits (rounding up) */
183 static uint32_t
184 ceil_byte_length(uint32_t num_bits)
185 {
186 	if (num_bits % 8)
187 		return ((num_bits >> 3) + 1);
188 	else
189 		return (num_bits >> 3);
190 }
191 
192 static void
193 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
194 		uint8_t is_op_success)
195 {
196 	struct rte_crypto_op *op = user_data;
197 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
198 			RTE_CRYPTO_OP_STATUS_ERROR;
199 }
200 
201 static struct crypto_testsuite_params testsuite_params = { NULL };
202 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
203 static struct crypto_unittest_params unittest_params;
204 static bool enq_cb_called;
205 static bool deq_cb_called;
206 
207 enum cryptodev_err_state {
208 	CRYPTODEV_ERR_CLEARED,
209 	CRYPTODEV_ERR_TRIGGERED,
210 	CRYPTODEV_ERR_UNRECOVERABLE,
211 };
212 
213 static enum cryptodev_err_state crypto_err = CRYPTODEV_ERR_CLEARED;
214 
215 static void
216 test_cryptodev_error_cb(uint8_t dev_id, enum rte_cryptodev_event_type event, void *cb_arg)
217 {
218 	struct crypto_testsuite_params *ts_params = &testsuite_params;
219 	uint16_t qp_id;
220 	int ticks = 0;
221 	int ret = 0;
222 
223 	RTE_SET_USED(event);
224 	RTE_SET_USED(cb_arg);
225 
226 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
227 		ret = rte_cryptodev_queue_pair_event_error_query(dev_id, qp_id);
228 		if (ret)
229 			break;
230 	}
231 	if (ret == 1) {
232 		/* Wait for the queue to be completely drained */
233 		while (rte_cryptodev_qp_depth_used(dev_id, qp_id) != 0) {
234 			rte_delay_ms(10);
235 			ticks++;
236 			if (ticks > QP_DRAIN_TIMEOUT) {
237 				crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
238 				return;
239 			}
240 		}
241 		if (rte_cryptodev_queue_pair_reset(dev_id, qp_id, NULL, 0)) {
242 			crypto_err = CRYPTODEV_ERR_UNRECOVERABLE;
243 			return;
244 		}
245 	}
246 
247 	crypto_err = CRYPTODEV_ERR_CLEARED;
248 }
249 
250 static struct rte_mbuf *
251 create_mbuf_from_heap(int pkt_len, uint8_t pattern)
252 {
253 	struct rte_mbuf *m = NULL;
254 	uint8_t *dst;
255 
256 	m = calloc(1, MBUF_SIZE);
257 	if (m == NULL) {
258 		printf("Cannot create mbuf from heap");
259 		return NULL;
260 	}
261 
262 	/* Set the default values to the mbuf */
263 	m->nb_segs = 1;
264 	m->port = RTE_MBUF_PORT_INVALID;
265 	m->buf_len = MBUF_SIZE - sizeof(struct rte_mbuf) - RTE_PKTMBUF_HEADROOM;
266 	rte_pktmbuf_reset_headroom(m);
267 	__rte_mbuf_sanity_check(m, 1);
268 
269 	m->buf_addr = (char *)m + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM;
270 
271 	memset(m->buf_addr, pattern, m->buf_len);
272 	dst = (uint8_t *)rte_pktmbuf_append(m, pkt_len);
273 	if (dst == NULL) {
274 		printf("Cannot append %d bytes to the mbuf\n", pkt_len);
275 		free(m);
276 		return NULL;
277 	}
278 
279 	return m;
280 }
281 
282 int
283 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
284 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
285 		uint8_t len_in_bits, uint8_t cipher_iv_len)
286 {
287 	struct rte_crypto_sym_op *sop = op->sym;
288 	struct rte_crypto_op *ret_op = NULL;
289 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
290 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
291 	union rte_crypto_sym_ofs ofs;
292 	struct rte_crypto_sym_vec vec;
293 	struct rte_crypto_sgl sgl, dest_sgl;
294 	uint32_t max_len;
295 	union rte_cryptodev_session_ctx sess;
296 	uint64_t auth_end_iova;
297 	uint32_t count = 0;
298 	struct rte_crypto_raw_dp_ctx *ctx;
299 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
300 			auth_len = 0;
301 	int32_t n;
302 	uint32_t n_success;
303 	int ctx_service_size;
304 	int32_t status = 0;
305 	int enqueue_status, dequeue_status;
306 	struct crypto_unittest_params *ut_params = &unittest_params;
307 	int is_sgl = sop->m_src->nb_segs > 1;
308 	int ret = TEST_SUCCESS, is_oop = 0;
309 
310 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
311 	if (ctx_service_size < 0)
312 		return TEST_SKIPPED;
313 
314 	ctx = malloc(ctx_service_size);
315 	if (ctx == NULL)
316 		return TEST_FAILED;
317 
318 	/* Both are enums, setting crypto_sess will suit any session type */
319 	sess.crypto_sess = op->sym->session;
320 
321 	ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
322 	if (ret == -ENOTSUP) {
323 		ret = TEST_SKIPPED;
324 		goto exit;
325 	} else if (ret) {
326 		ret = TEST_FAILED;
327 		goto exit;
328 	}
329 
330 	cipher_iv.iova = 0;
331 	cipher_iv.va = NULL;
332 	aad_auth_iv.iova = 0;
333 	aad_auth_iv.va = NULL;
334 	digest.iova = 0;
335 	digest.va = NULL;
336 	sgl.vec = data_vec;
337 	vec.num = 1;
338 	vec.src_sgl = &sgl;
339 	vec.iv = &cipher_iv;
340 	vec.digest = &digest;
341 	vec.aad = &aad_auth_iv;
342 	vec.status = &status;
343 
344 	ofs.raw = 0;
345 
346 	if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
347 		is_oop = 1;
348 
349 	if (is_cipher && is_auth) {
350 		cipher_offset = sop->cipher.data.offset;
351 		cipher_len = sop->cipher.data.length;
352 		auth_offset = sop->auth.data.offset;
353 		auth_len = sop->auth.data.length;
354 		max_len = RTE_MAX(cipher_offset + cipher_len,
355 				auth_offset + auth_len);
356 		if (len_in_bits) {
357 			max_len = max_len >> 3;
358 			cipher_offset = cipher_offset >> 3;
359 			auth_offset = auth_offset >> 3;
360 			cipher_len = cipher_len >> 3;
361 			auth_len = auth_len >> 3;
362 		}
363 		ofs.ofs.cipher.head = cipher_offset;
364 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
365 		ofs.ofs.auth.head = auth_offset;
366 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
367 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
368 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
369 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
370 				op, void *, IV_OFFSET + cipher_iv_len);
371 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
372 				cipher_iv_len);
373 		digest.va = (void *)sop->auth.digest.data;
374 		digest.iova = sop->auth.digest.phys_addr;
375 
376 		if (is_sgl) {
377 			uint32_t remaining_off = auth_offset + auth_len;
378 			struct rte_mbuf *sgl_buf = sop->m_src;
379 			if (is_oop)
380 				sgl_buf = sop->m_dst;
381 
382 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
383 					&& sgl_buf->next != NULL) {
384 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
385 				sgl_buf = sgl_buf->next;
386 			}
387 
388 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
389 				sgl_buf, remaining_off);
390 		} else {
391 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
392 							 auth_offset + auth_len;
393 		}
394 		/* Then check if digest-encrypted conditions are met */
395 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
396 				(digest.iova == auth_end_iova) && is_sgl)
397 			max_len = RTE_MAX(max_len,
398 				auth_offset + auth_len +
399 				ut_params->auth_xform.auth.digest_length);
400 
401 	} else if (is_cipher) {
402 		cipher_offset = sop->cipher.data.offset;
403 		cipher_len = sop->cipher.data.length;
404 		max_len = cipher_len + cipher_offset;
405 		if (len_in_bits) {
406 			max_len = max_len >> 3;
407 			cipher_offset = cipher_offset >> 3;
408 			cipher_len = cipher_len >> 3;
409 		}
410 		ofs.ofs.cipher.head = cipher_offset;
411 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
412 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
413 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
414 
415 	} else if (is_auth) {
416 		auth_offset = sop->auth.data.offset;
417 		auth_len = sop->auth.data.length;
418 		max_len = auth_len + auth_offset;
419 		if (len_in_bits) {
420 			max_len = max_len >> 3;
421 			auth_offset = auth_offset >> 3;
422 			auth_len = auth_len >> 3;
423 		}
424 		ofs.ofs.auth.head = auth_offset;
425 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
426 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
427 				op, void *, IV_OFFSET + cipher_iv_len);
428 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
429 				cipher_iv_len);
430 		digest.va = (void *)sop->auth.digest.data;
431 		digest.iova = sop->auth.digest.phys_addr;
432 
433 	} else { /* aead */
434 		cipher_offset = sop->aead.data.offset;
435 		cipher_len = sop->aead.data.length;
436 		max_len = cipher_len + cipher_offset;
437 		if (len_in_bits) {
438 			max_len = max_len >> 3;
439 			cipher_offset = cipher_offset >> 3;
440 			cipher_len = cipher_len >> 3;
441 		}
442 		ofs.ofs.cipher.head = cipher_offset;
443 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
444 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
445 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
446 		aad_auth_iv.va = (void *)sop->aead.aad.data;
447 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
448 		digest.va = (void *)sop->aead.digest.data;
449 		digest.iova = sop->aead.digest.phys_addr;
450 	}
451 
452 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
453 			data_vec, RTE_DIM(data_vec));
454 	if (n < 0 || n > sop->m_src->nb_segs) {
455 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
456 		goto exit;
457 	}
458 
459 	sgl.num = n;
460 	/* Out of place */
461 	if (is_oop) {
462 		dest_sgl.vec = dest_data_vec;
463 		vec.dest_sgl = &dest_sgl;
464 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
465 				dest_data_vec, RTE_DIM(dest_data_vec));
466 		if (n < 0 || n > sop->m_dst->nb_segs) {
467 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
468 			goto exit;
469 		}
470 		dest_sgl.num = n;
471 	} else
472 		vec.dest_sgl = NULL;
473 
474 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
475 			&enqueue_status) < 1) {
476 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
477 		goto exit;
478 	}
479 
480 	if (enqueue_status == 0) {
481 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
482 		if (status < 0) {
483 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
484 			goto exit;
485 		}
486 	} else if (enqueue_status < 0) {
487 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
488 		goto exit;
489 	}
490 
491 	n = n_success = 0;
492 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
493 		n = rte_cryptodev_raw_dequeue_burst(ctx,
494 			NULL, 1, post_process_raw_dp_op,
495 				(void **)&ret_op, 0, &n_success,
496 				&dequeue_status);
497 		if (dequeue_status < 0) {
498 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
499 			goto exit;
500 		}
501 		if (n == 0)
502 			rte_pause();
503 	}
504 
505 	if (n == 1 && dequeue_status == 0) {
506 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
507 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
508 			goto exit;
509 		}
510 	}
511 
512 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
513 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
514 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
515 					RTE_CRYPTO_OP_STATUS_SUCCESS;
516 
517 exit:
518 	free(ctx);
519 	return ret;
520 }
521 
522 static void
523 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
524 {
525 	int32_t n, st;
526 	struct rte_crypto_sym_op *sop;
527 	union rte_crypto_sym_ofs ofs;
528 	struct rte_crypto_sgl sgl;
529 	struct rte_crypto_sym_vec symvec;
530 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
531 	struct rte_crypto_vec vec[UINT8_MAX];
532 
533 	sop = op->sym;
534 
535 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
536 		sop->aead.data.length, vec, RTE_DIM(vec));
537 
538 	if (n < 0 || n != sop->m_src->nb_segs) {
539 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
540 		return;
541 	}
542 
543 	sgl.vec = vec;
544 	sgl.num = n;
545 	symvec.src_sgl = &sgl;
546 	symvec.iv = &iv_ptr;
547 	symvec.digest = &digest_ptr;
548 	symvec.aad = &aad_ptr;
549 	symvec.status = &st;
550 	symvec.num = 1;
551 
552 	/* for CPU crypto the IOVA address is not required */
553 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
554 	digest_ptr.va = (void *)sop->aead.digest.data;
555 	aad_ptr.va = (void *)sop->aead.aad.data;
556 
557 	ofs.raw = 0;
558 
559 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
560 		&symvec);
561 
562 	if (n != 1)
563 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
564 	else
565 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
566 }
567 
568 static void
569 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
570 {
571 	int32_t n, st;
572 	struct rte_crypto_sym_op *sop;
573 	union rte_crypto_sym_ofs ofs;
574 	struct rte_crypto_sgl sgl;
575 	struct rte_crypto_sym_vec symvec;
576 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
577 	struct rte_crypto_vec vec[UINT8_MAX];
578 
579 	sop = op->sym;
580 
581 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
582 		sop->auth.data.length, vec, RTE_DIM(vec));
583 
584 	if (n < 0 || n != sop->m_src->nb_segs) {
585 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
586 		return;
587 	}
588 
589 	sgl.vec = vec;
590 	sgl.num = n;
591 	symvec.src_sgl = &sgl;
592 	symvec.iv = &iv_ptr;
593 	symvec.digest = &digest_ptr;
594 	symvec.status = &st;
595 	symvec.num = 1;
596 
597 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
598 	digest_ptr.va = (void *)sop->auth.digest.data;
599 
600 	ofs.raw = 0;
601 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
602 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
603 		(sop->cipher.data.offset + sop->cipher.data.length);
604 
605 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
606 		&symvec);
607 
608 	if (n != 1)
609 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
610 	else
611 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
612 }
613 
614 static struct rte_crypto_op *
615 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
616 {
617 
618 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
619 
620 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
621 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
622 		return NULL;
623 	}
624 
625 	op = NULL;
626 
627 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
628 		rte_pause();
629 
630 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
631 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
632 		return NULL;
633 	}
634 
635 	return op;
636 }
637 
638 static int
639 testsuite_setup(void)
640 {
641 	struct crypto_testsuite_params *ts_params = &testsuite_params;
642 	struct rte_cryptodev_info info;
643 	uint32_t i = 0, nb_devs, dev_id;
644 	uint16_t qp_id;
645 
646 	memset(ts_params, 0, sizeof(*ts_params));
647 
648 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
649 	if (ts_params->mbuf_pool == NULL) {
650 		/* Not already created so create */
651 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
652 				"CRYPTO_MBUFPOOL",
653 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
654 				rte_socket_id());
655 		if (ts_params->mbuf_pool == NULL) {
656 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
657 			return TEST_FAILED;
658 		}
659 	}
660 
661 	ts_params->large_mbuf_pool = rte_mempool_lookup(
662 			"CRYPTO_LARGE_MBUFPOOL");
663 	if (ts_params->large_mbuf_pool == NULL) {
664 		/* Not already created so create */
665 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
666 				"CRYPTO_LARGE_MBUFPOOL",
667 				1, 0, 0, LARGE_MBUF_SIZE,
668 				rte_socket_id());
669 		if (ts_params->large_mbuf_pool == NULL) {
670 			RTE_LOG(ERR, USER1,
671 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
672 			return TEST_FAILED;
673 		}
674 	}
675 
676 	ts_params->op_mpool = rte_crypto_op_pool_create(
677 			"MBUF_CRYPTO_SYM_OP_POOL",
678 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
679 			NUM_MBUFS, MBUF_CACHE_SIZE,
680 			DEFAULT_NUM_XFORMS *
681 			sizeof(struct rte_crypto_sym_xform) +
682 			MAXIMUM_IV_LENGTH,
683 			rte_socket_id());
684 	if (ts_params->op_mpool == NULL) {
685 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
686 		return TEST_FAILED;
687 	}
688 
689 	nb_devs = rte_cryptodev_count();
690 	if (nb_devs < 1) {
691 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
692 		return TEST_SKIPPED;
693 	}
694 
695 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
696 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
697 				rte_cryptodev_driver_name_get(gbl_driver_id));
698 		return TEST_SKIPPED;
699 	}
700 
701 	/* Create list of valid crypto devs */
702 	for (i = 0; i < nb_devs; i++) {
703 		rte_cryptodev_info_get(i, &info);
704 		if (info.driver_id == gbl_driver_id)
705 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
706 	}
707 
708 	if (ts_params->valid_dev_count < 1)
709 		return TEST_FAILED;
710 
711 	/* Set up all the qps on the first of the valid devices found */
712 
713 	dev_id = ts_params->valid_devs[0];
714 
715 	rte_cryptodev_info_get(dev_id, &info);
716 
717 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
718 	ts_params->conf.socket_id = SOCKET_ID_ANY;
719 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
720 
721 	unsigned int session_size =
722 		rte_cryptodev_sym_get_private_session_size(dev_id);
723 
724 #ifdef RTE_LIB_SECURITY
725 	unsigned int security_session_size = rte_security_session_get_size(
726 			rte_cryptodev_get_sec_ctx(dev_id));
727 
728 	if (session_size < security_session_size)
729 		session_size = security_session_size;
730 #endif
731 	/*
732 	 * Create mempool with maximum number of sessions.
733 	 */
734 	if (info.sym.max_nb_sessions != 0 &&
735 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
736 		RTE_LOG(ERR, USER1, "Device does not support "
737 				"at least %u sessions\n",
738 				MAX_NB_SESSIONS);
739 		return TEST_FAILED;
740 	}
741 
742 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
743 			"test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
744 			SOCKET_ID_ANY);
745 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
746 			"session mempool allocation failed");
747 
748 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
749 			&ts_params->conf),
750 			"Failed to configure cryptodev %u with %u qps",
751 			dev_id, ts_params->conf.nb_queue_pairs);
752 
753 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
754 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
755 
756 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
757 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
758 			dev_id, qp_id, &ts_params->qp_conf,
759 			rte_cryptodev_socket_id(dev_id)),
760 			"Failed to setup queue pair %u on cryptodev %u",
761 			qp_id, dev_id);
762 	}
763 
764 	return TEST_SUCCESS;
765 }
766 
767 static void
768 testsuite_teardown(void)
769 {
770 	struct crypto_testsuite_params *ts_params = &testsuite_params;
771 	int res;
772 
773 	if (ts_params->large_mbuf_pool != NULL) {
774 		rte_mempool_free(ts_params->large_mbuf_pool);
775 		ts_params->large_mbuf_pool = NULL;
776 	}
777 
778 	if (ts_params->mbuf_pool != NULL) {
779 		rte_mempool_free(ts_params->mbuf_pool);
780 		ts_params->mbuf_pool = NULL;
781 	}
782 
783 	if (ts_params->op_mpool != NULL) {
784 		rte_mempool_free(ts_params->op_mpool);
785 		ts_params->op_mpool = NULL;
786 	}
787 
788 	if (ts_params->session_mpool != NULL) {
789 		rte_mempool_free(ts_params->session_mpool);
790 		ts_params->session_mpool = NULL;
791 	}
792 
793 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
794 	if (res)
795 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
796 }
797 
798 static int
799 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
800 		const int *algs, uint16_t num_algs)
801 {
802 	uint8_t dev_id = testsuite_params.valid_devs[0];
803 	bool some_alg_supported = false;
804 	uint16_t i;
805 
806 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
807 		struct rte_cryptodev_sym_capability_idx alg = {
808 			type, {algs[i]}
809 		};
810 		if (rte_cryptodev_sym_capability_get(dev_id,
811 				&alg) != NULL)
812 			some_alg_supported = true;
813 	}
814 	if (!some_alg_supported)
815 		return TEST_SKIPPED;
816 
817 	return 0;
818 }
819 
820 int
821 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
822 		uint16_t num_ciphers)
823 {
824 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
825 			(const int *) ciphers, num_ciphers);
826 }
827 
828 int
829 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
830 		uint16_t num_auths)
831 {
832 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
833 			(const int *) auths, num_auths);
834 }
835 
836 int
837 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
838 		uint16_t num_aeads)
839 {
840 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
841 			(const int *) aeads, num_aeads);
842 }
843 
844 static int
845 null_testsuite_setup(void)
846 {
847 	struct crypto_testsuite_params *ts_params = &testsuite_params;
848 	uint8_t dev_id = ts_params->valid_devs[0];
849 	struct rte_cryptodev_info dev_info;
850 	const enum rte_crypto_cipher_algorithm ciphers[] = {
851 		RTE_CRYPTO_CIPHER_NULL
852 	};
853 	const enum rte_crypto_auth_algorithm auths[] = {
854 		RTE_CRYPTO_AUTH_NULL
855 	};
856 
857 	rte_cryptodev_info_get(dev_id, &dev_info);
858 
859 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
860 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
861 				"testsuite not met\n");
862 		return TEST_SKIPPED;
863 	}
864 
865 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
866 			&& check_auth_capabilities_supported(auths,
867 			RTE_DIM(auths)) != 0) {
868 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
869 				"testsuite not met\n");
870 		return TEST_SKIPPED;
871 	}
872 
873 	return 0;
874 }
875 
876 static int
877 crypto_gen_testsuite_setup(void)
878 {
879 	struct crypto_testsuite_params *ts_params = &testsuite_params;
880 	uint8_t dev_id = ts_params->valid_devs[0];
881 	struct rte_cryptodev_info dev_info;
882 
883 	rte_cryptodev_info_get(dev_id, &dev_info);
884 
885 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
886 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
887 				"testsuite not met\n");
888 		return TEST_SKIPPED;
889 	}
890 
891 	return 0;
892 }
893 
894 #ifdef RTE_LIB_SECURITY
895 static int
896 sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
897 {
898 	struct crypto_testsuite_params *ts_params = &testsuite_params;
899 	struct crypto_unittest_params *ut_params = &unittest_params;
900 	struct rte_cryptodev_info dev_info;
901 	int ret = 0;
902 
903 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
904 
905 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
906 		RTE_LOG(INFO, USER1,
907 			"Feature flag requirements for security protocol testsuite not met\n");
908 		return TEST_SKIPPED;
909 	}
910 
911 	/* Reconfigure to enable security */
912 	ret = dev_configure_and_start(0);
913 	if (ret != TEST_SUCCESS)
914 		return ret;
915 
916 	/* Set action type */
917 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
918 
919 	if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
920 		RTE_LOG(INFO, USER1,
921 			"Capability requirements for security protocol test not met\n");
922 		ret = TEST_SKIPPED;
923 	}
924 
925 	test_sec_alg_list_populate();
926 	test_sec_auth_only_alg_list_populate();
927 
928 	/*
929 	 * Stop the device. Device would be started again by individual test
930 	 * case setup routine.
931 	 */
932 	rte_cryptodev_stop(ts_params->valid_devs[0]);
933 
934 	return ret;
935 }
936 
937 static int
938 ipsec_proto_testsuite_setup(void)
939 {
940 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
941 }
942 
943 static int
944 tls_record_proto_testsuite_setup(void)
945 {
946 	test_sec_proto_pattern_generate();
947 
948 	return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
949 }
950 
951 static int
952 pdcp_proto_testsuite_setup(void)
953 {
954 	struct crypto_testsuite_params *ts_params = &testsuite_params;
955 	uint8_t dev_id = ts_params->valid_devs[0];
956 	struct rte_cryptodev_info dev_info;
957 	const enum rte_crypto_cipher_algorithm ciphers[] = {
958 		RTE_CRYPTO_CIPHER_NULL,
959 		RTE_CRYPTO_CIPHER_AES_CTR,
960 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
961 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
962 	};
963 	const enum rte_crypto_auth_algorithm auths[] = {
964 		RTE_CRYPTO_AUTH_NULL,
965 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
966 		RTE_CRYPTO_AUTH_AES_CMAC,
967 		RTE_CRYPTO_AUTH_ZUC_EIA3
968 	};
969 
970 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
971 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
972 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
973 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
974 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
975 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
976 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
977 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
978 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
979 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
980 
981 	rte_cryptodev_info_get(dev_id, &dev_info);
982 
983 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
984 			!(dev_info.feature_flags &
985 			RTE_CRYPTODEV_FF_SECURITY)) {
986 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
987 				"testsuite not met\n");
988 		return TEST_SKIPPED;
989 	}
990 
991 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
992 			&& check_auth_capabilities_supported(auths,
993 			RTE_DIM(auths)) != 0) {
994 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
995 				"testsuite not met\n");
996 		return TEST_SKIPPED;
997 	}
998 
999 	return 0;
1000 }
1001 
1002 static int
1003 docsis_proto_testsuite_setup(void)
1004 {
1005 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1006 	uint8_t dev_id = ts_params->valid_devs[0];
1007 	struct rte_cryptodev_info dev_info;
1008 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1009 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
1010 	};
1011 
1012 	rte_cryptodev_info_get(dev_id, &dev_info);
1013 
1014 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1015 			!(dev_info.feature_flags &
1016 			RTE_CRYPTODEV_FF_SECURITY)) {
1017 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
1018 				"Proto testsuite not met\n");
1019 		return TEST_SKIPPED;
1020 	}
1021 
1022 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1023 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
1024 				"testsuite not met\n");
1025 		return TEST_SKIPPED;
1026 	}
1027 
1028 	return 0;
1029 }
1030 #endif
1031 
1032 static int
1033 aes_ccm_auth_testsuite_setup(void)
1034 {
1035 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1036 	uint8_t dev_id = ts_params->valid_devs[0];
1037 	struct rte_cryptodev_info dev_info;
1038 	const enum rte_crypto_aead_algorithm aeads[] = {
1039 		RTE_CRYPTO_AEAD_AES_CCM
1040 	};
1041 
1042 	rte_cryptodev_info_get(dev_id, &dev_info);
1043 
1044 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1045 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1046 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1047 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
1048 				"testsuite not met\n");
1049 		return TEST_SKIPPED;
1050 	}
1051 
1052 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1053 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
1054 				"testsuite not met\n");
1055 		return TEST_SKIPPED;
1056 	}
1057 
1058 	return 0;
1059 }
1060 
1061 static int
1062 aes_gcm_auth_testsuite_setup(void)
1063 {
1064 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1065 	uint8_t dev_id = ts_params->valid_devs[0];
1066 	struct rte_cryptodev_info dev_info;
1067 	const enum rte_crypto_aead_algorithm aeads[] = {
1068 		RTE_CRYPTO_AEAD_AES_GCM
1069 	};
1070 
1071 	rte_cryptodev_info_get(dev_id, &dev_info);
1072 
1073 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1074 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
1075 				"testsuite not met\n");
1076 		return TEST_SKIPPED;
1077 	}
1078 
1079 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1080 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
1081 				"testsuite not met\n");
1082 		return TEST_SKIPPED;
1083 	}
1084 
1085 	return 0;
1086 }
1087 
1088 static int
1089 aes_gmac_auth_testsuite_setup(void)
1090 {
1091 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1092 	uint8_t dev_id = ts_params->valid_devs[0];
1093 	struct rte_cryptodev_info dev_info;
1094 	const enum rte_crypto_auth_algorithm auths[] = {
1095 		RTE_CRYPTO_AUTH_AES_GMAC
1096 	};
1097 
1098 	rte_cryptodev_info_get(dev_id, &dev_info);
1099 
1100 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1101 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1102 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1103 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1104 				"testsuite not met\n");
1105 		return TEST_SKIPPED;
1106 	}
1107 
1108 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1109 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1110 				"testsuite not met\n");
1111 		return TEST_SKIPPED;
1112 	}
1113 
1114 	return 0;
1115 }
1116 
1117 static int
1118 chacha20_poly1305_testsuite_setup(void)
1119 {
1120 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1121 	uint8_t dev_id = ts_params->valid_devs[0];
1122 	struct rte_cryptodev_info dev_info;
1123 	const enum rte_crypto_aead_algorithm aeads[] = {
1124 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1125 	};
1126 
1127 	rte_cryptodev_info_get(dev_id, &dev_info);
1128 
1129 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1130 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1131 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1132 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1133 				"Chacha20-Poly1305 testsuite not met\n");
1134 		return TEST_SKIPPED;
1135 	}
1136 
1137 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1138 		RTE_LOG(INFO, USER1, "Capability requirements for "
1139 				"Chacha20-Poly1305 testsuite not met\n");
1140 		return TEST_SKIPPED;
1141 	}
1142 
1143 	return 0;
1144 }
1145 
1146 static int
1147 snow3g_testsuite_setup(void)
1148 {
1149 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1150 	uint8_t dev_id = ts_params->valid_devs[0];
1151 	struct rte_cryptodev_info dev_info;
1152 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1153 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1154 
1155 	};
1156 	const enum rte_crypto_auth_algorithm auths[] = {
1157 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1158 	};
1159 
1160 	rte_cryptodev_info_get(dev_id, &dev_info);
1161 
1162 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1163 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1164 				"testsuite not met\n");
1165 		return TEST_SKIPPED;
1166 	}
1167 
1168 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1169 			&& check_auth_capabilities_supported(auths,
1170 			RTE_DIM(auths)) != 0) {
1171 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1172 				"testsuite not met\n");
1173 		return TEST_SKIPPED;
1174 	}
1175 
1176 	return 0;
1177 }
1178 
1179 static int
1180 zuc_testsuite_setup(void)
1181 {
1182 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1183 	uint8_t dev_id = ts_params->valid_devs[0];
1184 	struct rte_cryptodev_info dev_info;
1185 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1186 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1187 	};
1188 	const enum rte_crypto_auth_algorithm auths[] = {
1189 		RTE_CRYPTO_AUTH_ZUC_EIA3
1190 	};
1191 
1192 	rte_cryptodev_info_get(dev_id, &dev_info);
1193 
1194 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1195 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1196 				"testsuite not met\n");
1197 		return TEST_SKIPPED;
1198 	}
1199 
1200 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1201 			&& check_auth_capabilities_supported(auths,
1202 			RTE_DIM(auths)) != 0) {
1203 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1204 				"testsuite not met\n");
1205 		return TEST_SKIPPED;
1206 	}
1207 
1208 	return 0;
1209 }
1210 
1211 static int
1212 hmac_md5_auth_testsuite_setup(void)
1213 {
1214 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1215 	uint8_t dev_id = ts_params->valid_devs[0];
1216 	struct rte_cryptodev_info dev_info;
1217 	const enum rte_crypto_auth_algorithm auths[] = {
1218 		RTE_CRYPTO_AUTH_MD5_HMAC
1219 	};
1220 
1221 	rte_cryptodev_info_get(dev_id, &dev_info);
1222 
1223 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1224 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1225 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1226 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1227 				"Auth testsuite not met\n");
1228 		return TEST_SKIPPED;
1229 	}
1230 
1231 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1232 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1233 				"testsuite not met\n");
1234 		return TEST_SKIPPED;
1235 	}
1236 
1237 	return 0;
1238 }
1239 
1240 static int
1241 kasumi_testsuite_setup(void)
1242 {
1243 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1244 	uint8_t dev_id = ts_params->valid_devs[0];
1245 	struct rte_cryptodev_info dev_info;
1246 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1247 		RTE_CRYPTO_CIPHER_KASUMI_F8
1248 	};
1249 	const enum rte_crypto_auth_algorithm auths[] = {
1250 		RTE_CRYPTO_AUTH_KASUMI_F9
1251 	};
1252 
1253 	rte_cryptodev_info_get(dev_id, &dev_info);
1254 
1255 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1256 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1257 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1258 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1259 				"testsuite not met\n");
1260 		return TEST_SKIPPED;
1261 	}
1262 
1263 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1264 			&& check_auth_capabilities_supported(auths,
1265 			RTE_DIM(auths)) != 0) {
1266 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1267 				"testsuite not met\n");
1268 		return TEST_SKIPPED;
1269 	}
1270 
1271 	return 0;
1272 }
1273 
1274 static int
1275 negative_aes_gcm_testsuite_setup(void)
1276 {
1277 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1278 	uint8_t dev_id = ts_params->valid_devs[0];
1279 	struct rte_cryptodev_info dev_info;
1280 	const enum rte_crypto_aead_algorithm aeads[] = {
1281 		RTE_CRYPTO_AEAD_AES_GCM
1282 	};
1283 
1284 	rte_cryptodev_info_get(dev_id, &dev_info);
1285 
1286 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1287 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1288 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1289 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1290 				"AES GCM testsuite not met\n");
1291 		return TEST_SKIPPED;
1292 	}
1293 
1294 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1295 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1296 				"AES GCM testsuite not met\n");
1297 		return TEST_SKIPPED;
1298 	}
1299 
1300 	return 0;
1301 }
1302 
1303 static int
1304 negative_aes_gmac_testsuite_setup(void)
1305 {
1306 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1307 	uint8_t dev_id = ts_params->valid_devs[0];
1308 	struct rte_cryptodev_info dev_info;
1309 	const enum rte_crypto_auth_algorithm auths[] = {
1310 		RTE_CRYPTO_AUTH_AES_GMAC
1311 	};
1312 
1313 	rte_cryptodev_info_get(dev_id, &dev_info);
1314 
1315 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1316 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1317 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1318 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1319 				"AES GMAC testsuite not met\n");
1320 		return TEST_SKIPPED;
1321 	}
1322 
1323 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1324 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1325 				"AES GMAC testsuite not met\n");
1326 		return TEST_SKIPPED;
1327 	}
1328 
1329 	return 0;
1330 }
1331 
1332 static int
1333 mixed_cipher_hash_testsuite_setup(void)
1334 {
1335 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1336 	uint8_t dev_id = ts_params->valid_devs[0];
1337 	struct rte_cryptodev_info dev_info;
1338 	uint64_t feat_flags;
1339 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1340 		RTE_CRYPTO_CIPHER_NULL,
1341 		RTE_CRYPTO_CIPHER_AES_CTR,
1342 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1343 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1344 	};
1345 	const enum rte_crypto_auth_algorithm auths[] = {
1346 		RTE_CRYPTO_AUTH_NULL,
1347 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1348 		RTE_CRYPTO_AUTH_AES_CMAC,
1349 		RTE_CRYPTO_AUTH_ZUC_EIA3
1350 	};
1351 
1352 	rte_cryptodev_info_get(dev_id, &dev_info);
1353 	feat_flags = dev_info.feature_flags;
1354 
1355 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1356 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1357 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1358 				"Cipher Hash testsuite not met\n");
1359 		return TEST_SKIPPED;
1360 	}
1361 
1362 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1363 			&& check_auth_capabilities_supported(auths,
1364 			RTE_DIM(auths)) != 0) {
1365 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1366 				"Cipher Hash testsuite not met\n");
1367 		return TEST_SKIPPED;
1368 	}
1369 
1370 	return 0;
1371 }
1372 
1373 static int
1374 esn_testsuite_setup(void)
1375 {
1376 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1377 	uint8_t dev_id = ts_params->valid_devs[0];
1378 	struct rte_cryptodev_info dev_info;
1379 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1380 		RTE_CRYPTO_CIPHER_AES_CBC
1381 	};
1382 	const enum rte_crypto_auth_algorithm auths[] = {
1383 		RTE_CRYPTO_AUTH_SHA1_HMAC
1384 	};
1385 
1386 	rte_cryptodev_info_get(dev_id, &dev_info);
1387 
1388 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1389 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1390 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1391 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1392 				"testsuite not met\n");
1393 		return TEST_SKIPPED;
1394 	}
1395 
1396 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1397 			&& check_auth_capabilities_supported(auths,
1398 			RTE_DIM(auths)) != 0) {
1399 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1400 				"testsuite not met\n");
1401 		return TEST_SKIPPED;
1402 	}
1403 
1404 	return 0;
1405 }
1406 
1407 static int
1408 multi_session_testsuite_setup(void)
1409 {
1410 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1411 	uint8_t dev_id = ts_params->valid_devs[0];
1412 	struct rte_cryptodev_info dev_info;
1413 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1414 		RTE_CRYPTO_CIPHER_AES_CBC
1415 	};
1416 	const enum rte_crypto_auth_algorithm auths[] = {
1417 		RTE_CRYPTO_AUTH_SHA512_HMAC
1418 	};
1419 
1420 	rte_cryptodev_info_get(dev_id, &dev_info);
1421 
1422 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1423 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1424 				"Session testsuite not met\n");
1425 		return TEST_SKIPPED;
1426 	}
1427 
1428 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1429 			&& check_auth_capabilities_supported(auths,
1430 			RTE_DIM(auths)) != 0) {
1431 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1432 				"Session testsuite not met\n");
1433 		return TEST_SKIPPED;
1434 	}
1435 
1436 	return 0;
1437 }
1438 
1439 static int
1440 negative_hmac_sha1_testsuite_setup(void)
1441 {
1442 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1443 	uint8_t dev_id = ts_params->valid_devs[0];
1444 	struct rte_cryptodev_info dev_info;
1445 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1446 		RTE_CRYPTO_CIPHER_AES_CBC
1447 	};
1448 	const enum rte_crypto_auth_algorithm auths[] = {
1449 		RTE_CRYPTO_AUTH_SHA1_HMAC
1450 	};
1451 
1452 	rte_cryptodev_info_get(dev_id, &dev_info);
1453 
1454 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1455 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1456 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1457 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1458 				"HMAC SHA1 testsuite not met\n");
1459 		return TEST_SKIPPED;
1460 	}
1461 
1462 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1463 			&& check_auth_capabilities_supported(auths,
1464 			RTE_DIM(auths)) != 0) {
1465 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1466 				"HMAC SHA1 testsuite not met\n");
1467 		return TEST_SKIPPED;
1468 	}
1469 
1470 	return 0;
1471 }
1472 
1473 static int
1474 dev_configure_and_start(uint64_t ff_disable)
1475 {
1476 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1477 	struct crypto_unittest_params *ut_params = &unittest_params;
1478 
1479 	uint16_t qp_id;
1480 
1481 	/* Clear unit test parameters before running test */
1482 	memset(ut_params, 0, sizeof(*ut_params));
1483 
1484 	/* Reconfigure device to default parameters */
1485 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1486 	ts_params->conf.ff_disable = ff_disable;
1487 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1488 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1489 
1490 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1491 			&ts_params->conf),
1492 			"Failed to configure cryptodev %u",
1493 			ts_params->valid_devs[0]);
1494 
1495 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1496 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1497 			ts_params->valid_devs[0], qp_id,
1498 			&ts_params->qp_conf,
1499 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1500 			"Failed to setup queue pair %u on cryptodev %u",
1501 			qp_id, ts_params->valid_devs[0]);
1502 	}
1503 
1504 
1505 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1506 
1507 	/* Start the device */
1508 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1509 			"Failed to start cryptodev %u",
1510 			ts_params->valid_devs[0]);
1511 
1512 	return TEST_SUCCESS;
1513 }
1514 
1515 int
1516 ut_setup(void)
1517 {
1518 	/* Configure and start the device with security feature disabled */
1519 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1520 }
1521 
1522 static int
1523 ut_setup_security(void)
1524 {
1525 	/* Configure and start the device with no features disabled */
1526 	return dev_configure_and_start(0);
1527 }
1528 
1529 static int
1530 ut_setup_security_rx_inject(void)
1531 {
1532 	struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1533 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1534 	struct rte_eth_conf port_conf = {
1535 		.rxmode = {
1536 			.offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1537 				    RTE_ETH_RX_OFFLOAD_SECURITY,
1538 		},
1539 		.txmode = {
1540 			.offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1541 		},
1542 		.lpbk_mode = 1,  /* Enable loopback */
1543 	};
1544 	struct rte_cryptodev_info dev_info;
1545 	struct rte_eth_rxconf rx_conf = {
1546 		.rx_thresh = {
1547 			.pthresh = 8,
1548 			.hthresh = 8,
1549 			.wthresh = 8,
1550 		},
1551 		.rx_free_thresh = 32,
1552 	};
1553 	uint16_t nb_ports;
1554 	void *sec_ctx;
1555 	int ret;
1556 
1557 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1558 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1559 	    !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1560 		RTE_LOG(INFO, USER1,
1561 			"Feature requirements for IPsec Rx inject test case not met\n");
1562 		return TEST_SKIPPED;
1563 	}
1564 
1565 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1566 	if (sec_ctx == NULL)
1567 		return TEST_SKIPPED;
1568 
1569 	nb_ports = rte_eth_dev_count_avail();
1570 	if (nb_ports == 0)
1571 		return TEST_SKIPPED;
1572 
1573 	ret = rte_eth_dev_configure(0 /* port_id */,
1574 				    1 /* nb_rx_queue */,
1575 				    0 /* nb_tx_queue */,
1576 				    &port_conf);
1577 	if (ret) {
1578 		printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1579 		return TEST_SKIPPED;
1580 	}
1581 
1582 	/* Rx queue setup */
1583 	ret = rte_eth_rx_queue_setup(0 /* port_id */,
1584 				     0 /* rx_queue_id */,
1585 				     1024 /* nb_rx_desc */,
1586 				     SOCKET_ID_ANY,
1587 				     &rx_conf,
1588 				     mbuf_pool);
1589 	if (ret) {
1590 		printf("Could not setup eth port 0 queue 0\n");
1591 		return TEST_SKIPPED;
1592 	}
1593 
1594 	ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1595 	if (ret) {
1596 		printf("Could not enable Rx inject offload");
1597 		return TEST_SKIPPED;
1598 	}
1599 
1600 	ret = rte_eth_dev_start(0);
1601 	if (ret) {
1602 		printf("Could not start ethdev");
1603 		return TEST_SKIPPED;
1604 	}
1605 
1606 	ret = rte_eth_promiscuous_enable(0);
1607 	if (ret) {
1608 		printf("Could not enable promiscuous mode");
1609 		return TEST_SKIPPED;
1610 	}
1611 
1612 	/* Configure and start cryptodev with no features disabled */
1613 	return dev_configure_and_start(0);
1614 }
1615 
1616 static inline void
1617 ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1618 {
1619 }
1620 
1621 static inline void
1622 ext_mbuf_memzone_free(int nb_segs)
1623 {
1624 	int i;
1625 
1626 	for (i = 0; i <= nb_segs; i++) {
1627 		char mz_name[RTE_MEMZONE_NAMESIZE];
1628 		const struct rte_memzone *memzone;
1629 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1630 		memzone = rte_memzone_lookup(mz_name);
1631 		if (memzone != NULL) {
1632 			rte_memzone_free(memzone);
1633 			memzone = NULL;
1634 		}
1635 	}
1636 }
1637 
1638 static inline struct rte_mbuf *
1639 ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1640 		int nb_segs, const void *input_text)
1641 {
1642 	struct rte_mbuf *m = NULL, *mbuf = NULL;
1643 	size_t data_off = 0;
1644 	uint8_t *dst;
1645 	int i, size;
1646 	int t_len;
1647 
1648 	if (pkt_len < 1) {
1649 		printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1650 		return NULL;
1651 	}
1652 
1653 	if (nb_segs < 1) {
1654 		printf("Number of segments must be 1 or more (is %d)\n",
1655 				nb_segs);
1656 		return NULL;
1657 	}
1658 
1659 	t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1660 	size = pkt_len;
1661 
1662 	/* Create chained mbuf_src with external buffer */
1663 	for (i = 0; size > 0; i++) {
1664 		struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1665 		uint16_t data_len = RTE_MIN(size, t_len);
1666 		char mz_name[RTE_MEMZONE_NAMESIZE];
1667 		const struct rte_memzone *memzone;
1668 		void *ext_buf_addr = NULL;
1669 		rte_iova_t buf_iova;
1670 		bool freed = false;
1671 		uint16_t buf_len;
1672 
1673 		buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1674 			sizeof(struct rte_mbuf_ext_shared_info), 8);
1675 
1676 		snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1677 		memzone = rte_memzone_lookup(mz_name);
1678 		if (memzone != NULL && memzone->len != buf_len) {
1679 			rte_memzone_free(memzone);
1680 			memzone = NULL;
1681 		}
1682 		if (memzone == NULL) {
1683 			memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1684 				RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1685 			if (memzone == NULL) {
1686 				printf("Can't allocate memory zone %s\n", mz_name);
1687 				return NULL;
1688 			}
1689 		}
1690 
1691 		ext_buf_addr = memzone->addr;
1692 		if (input_text)
1693 			memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1694 
1695 		/* Create buffer to hold rte_mbuf header */
1696 		m = rte_pktmbuf_alloc(mbuf_pool);
1697 		if (i == 0)
1698 			mbuf = m;
1699 
1700 		if (m == NULL) {
1701 			printf("Cannot create segment for source mbuf");
1702 			goto fail;
1703 		}
1704 
1705 		/* Save shared data (like callback function) in external buffer's end */
1706 		ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1707 			ext_mbuf_callback_fn_free, &freed);
1708 		if (ret_shinfo == NULL) {
1709 			printf("Shared mem initialization failed!\n");
1710 			goto fail;
1711 		}
1712 
1713 		buf_iova = rte_mem_virt2iova(ext_buf_addr);
1714 
1715 		/* Attach external buffer to mbuf */
1716 		rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1717 			ret_shinfo);
1718 		if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1719 			printf("External buffer is not attached to mbuf\n");
1720 			goto fail;
1721 		}
1722 
1723 		if (input_text) {
1724 			dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1725 			if (dst == NULL) {
1726 				printf("Cannot append %d bytes to the mbuf\n", data_len);
1727 				goto fail;
1728 			}
1729 		}
1730 
1731 		if (mbuf != m)
1732 			rte_pktmbuf_chain(mbuf, m);
1733 
1734 		size -= data_len;
1735 		data_off += data_len;
1736 	}
1737 
1738 	return mbuf;
1739 
1740 fail:
1741 	rte_pktmbuf_free(mbuf);
1742 	ext_mbuf_memzone_free(nb_segs);
1743 	return NULL;
1744 }
1745 
1746 void
1747 ut_teardown(void)
1748 {
1749 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1750 	struct crypto_unittest_params *ut_params = &unittest_params;
1751 
1752 	/* free crypto session structure */
1753 #ifdef RTE_LIB_SECURITY
1754 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1755 		if (ut_params->sec_session) {
1756 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1757 						(ts_params->valid_devs[0]),
1758 						ut_params->sec_session);
1759 			ut_params->sec_session = NULL;
1760 		}
1761 	} else
1762 #endif
1763 	{
1764 		if (ut_params->sess) {
1765 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1766 					ut_params->sess);
1767 			ut_params->sess = NULL;
1768 		}
1769 	}
1770 
1771 	/* free crypto operation structure */
1772 	rte_crypto_op_free(ut_params->op);
1773 
1774 	/*
1775 	 * free mbuf - both obuf and ibuf are usually the same,
1776 	 * so check if they point at the same address is necessary,
1777 	 * to avoid freeing the mbuf twice.
1778 	 */
1779 	if (ut_params->obuf) {
1780 		rte_pktmbuf_free(ut_params->obuf);
1781 		if (ut_params->ibuf == ut_params->obuf)
1782 			ut_params->ibuf = 0;
1783 		ut_params->obuf = 0;
1784 	}
1785 	if (ut_params->ibuf) {
1786 		ext_mbuf_memzone_free(1);
1787 		rte_pktmbuf_free(ut_params->ibuf);
1788 		ut_params->ibuf = 0;
1789 	}
1790 
1791 	if (ts_params->mbuf_pool != NULL)
1792 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1793 			rte_mempool_avail_count(ts_params->mbuf_pool));
1794 
1795 	/* Stop the device */
1796 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1797 }
1798 
1799 static void
1800 ut_teardown_rx_inject(void)
1801 {
1802 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1803 	void *sec_ctx;
1804 	int ret;
1805 
1806 	if  (rte_eth_dev_count_avail() != 0) {
1807 		ret = rte_eth_dev_reset(0);
1808 		if (ret)
1809 			printf("Could not reset eth port 0");
1810 
1811 	}
1812 
1813 	ut_teardown();
1814 
1815 	sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1816 	if (sec_ctx == NULL)
1817 		return;
1818 
1819 	ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1820 	if (ret) {
1821 		printf("Could not disable Rx inject offload");
1822 		return;
1823 	}
1824 }
1825 
1826 static int
1827 test_device_configure_invalid_dev_id(void)
1828 {
1829 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1830 	uint16_t dev_id, num_devs = 0;
1831 
1832 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1833 			"Need at least %d devices for test", 1);
1834 
1835 	/* valid dev_id values */
1836 	dev_id = ts_params->valid_devs[0];
1837 
1838 	/* Stop the device in case it's started so it can be configured */
1839 	rte_cryptodev_stop(dev_id);
1840 
1841 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1842 			"Failed test for rte_cryptodev_configure: "
1843 			"invalid dev_num %u", dev_id);
1844 
1845 	/* invalid dev_id values */
1846 	dev_id = num_devs;
1847 
1848 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1849 			"Failed test for rte_cryptodev_configure: "
1850 			"invalid dev_num %u", dev_id);
1851 
1852 	dev_id = 0xff;
1853 
1854 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1855 			"Failed test for rte_cryptodev_configure:"
1856 			"invalid dev_num %u", dev_id);
1857 
1858 	return TEST_SUCCESS;
1859 }
1860 
1861 static int
1862 test_device_configure_invalid_queue_pair_ids(void)
1863 {
1864 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1865 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1866 
1867 	/* Stop the device in case it's started so it can be configured */
1868 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1869 
1870 	/* valid - max value queue pairs */
1871 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1872 
1873 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1874 			&ts_params->conf),
1875 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1876 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1877 
1878 	/* valid - one queue pairs */
1879 	ts_params->conf.nb_queue_pairs = 1;
1880 
1881 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1882 			&ts_params->conf),
1883 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1884 			ts_params->valid_devs[0],
1885 			ts_params->conf.nb_queue_pairs);
1886 
1887 
1888 	/* invalid - zero queue pairs */
1889 	ts_params->conf.nb_queue_pairs = 0;
1890 
1891 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1892 			&ts_params->conf),
1893 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1894 			" invalid qps: %u",
1895 			ts_params->valid_devs[0],
1896 			ts_params->conf.nb_queue_pairs);
1897 
1898 
1899 	/* invalid - max value supported by field queue pairs */
1900 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1901 
1902 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1903 			&ts_params->conf),
1904 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1905 			" invalid qps: %u",
1906 			ts_params->valid_devs[0],
1907 			ts_params->conf.nb_queue_pairs);
1908 
1909 
1910 	/* invalid - max value + 1 queue pairs */
1911 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1912 
1913 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1914 			&ts_params->conf),
1915 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1916 			" invalid qps: %u",
1917 			ts_params->valid_devs[0],
1918 			ts_params->conf.nb_queue_pairs);
1919 
1920 	/* revert to original testsuite value */
1921 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1922 
1923 	return TEST_SUCCESS;
1924 }
1925 
1926 static int
1927 test_queue_pair_descriptor_setup(void)
1928 {
1929 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1930 	struct rte_cryptodev_qp_conf qp_conf = {
1931 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1932 	};
1933 	uint16_t qp_id;
1934 
1935 	/* Stop the device in case it's started so it can be configured */
1936 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1937 
1938 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1939 			&ts_params->conf),
1940 			"Failed to configure cryptodev %u",
1941 			ts_params->valid_devs[0]);
1942 
1943 	/*
1944 	 * Test various ring sizes on this device. memzones can't be
1945 	 * freed so are re-used if ring is released and re-created.
1946 	 */
1947 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1948 	qp_conf.mp_session = ts_params->session_mpool;
1949 
1950 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1951 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1952 				ts_params->valid_devs[0], qp_id, &qp_conf,
1953 				rte_cryptodev_socket_id(
1954 						ts_params->valid_devs[0])),
1955 				"Failed test for "
1956 				"rte_cryptodev_queue_pair_setup: num_inflights "
1957 				"%u on qp %u on cryptodev %u",
1958 				qp_conf.nb_descriptors, qp_id,
1959 				ts_params->valid_devs[0]);
1960 	}
1961 
1962 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1963 
1964 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1965 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1966 				ts_params->valid_devs[0], qp_id, &qp_conf,
1967 				rte_cryptodev_socket_id(
1968 						ts_params->valid_devs[0])),
1969 				"Failed test for"
1970 				" rte_cryptodev_queue_pair_setup: num_inflights"
1971 				" %u on qp %u on cryptodev %u",
1972 				qp_conf.nb_descriptors, qp_id,
1973 				ts_params->valid_devs[0]);
1974 	}
1975 
1976 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1977 
1978 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1979 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1980 				ts_params->valid_devs[0], qp_id, &qp_conf,
1981 				rte_cryptodev_socket_id(
1982 						ts_params->valid_devs[0])),
1983 				"Failed test for "
1984 				"rte_cryptodev_queue_pair_setup: num_inflights"
1985 				" %u on qp %u on cryptodev %u",
1986 				qp_conf.nb_descriptors, qp_id,
1987 				ts_params->valid_devs[0]);
1988 	}
1989 
1990 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1991 
1992 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1993 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1994 				ts_params->valid_devs[0], qp_id, &qp_conf,
1995 				rte_cryptodev_socket_id(
1996 						ts_params->valid_devs[0])),
1997 				"Failed test for"
1998 				" rte_cryptodev_queue_pair_setup:"
1999 				"num_inflights %u on qp %u on cryptodev %u",
2000 				qp_conf.nb_descriptors, qp_id,
2001 				ts_params->valid_devs[0]);
2002 	}
2003 
2004 	/* test invalid queue pair id */
2005 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
2006 
2007 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
2008 
2009 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2010 			ts_params->valid_devs[0],
2011 			qp_id, &qp_conf,
2012 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2013 			"Failed test for rte_cryptodev_queue_pair_setup:"
2014 			"invalid qp %u on cryptodev %u",
2015 			qp_id, ts_params->valid_devs[0]);
2016 
2017 	qp_id = 0xffff; /*invalid*/
2018 
2019 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
2020 			ts_params->valid_devs[0],
2021 			qp_id, &qp_conf,
2022 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
2023 			"Failed test for rte_cryptodev_queue_pair_setup:"
2024 			"invalid qp %u on cryptodev %u",
2025 			qp_id, ts_params->valid_devs[0]);
2026 
2027 	return TEST_SUCCESS;
2028 }
2029 
2030 /* ***** Plaintext data for tests ***** */
2031 
2032 const char catch_22_quote_1[] =
2033 		"There was only one catch and that was Catch-22, which "
2034 		"specified that a concern for one's safety in the face of "
2035 		"dangers that were real and immediate was the process of a "
2036 		"rational mind. Orr was crazy and could be grounded. All he "
2037 		"had to do was ask; and as soon as he did, he would no longer "
2038 		"be crazy and would have to fly more missions. Orr would be "
2039 		"crazy to fly more missions and sane if he didn't, but if he "
2040 		"was sane he had to fly them. If he flew them he was crazy "
2041 		"and didn't have to; but if he didn't want to he was sane and "
2042 		"had to. Yossarian was moved very deeply by the absolute "
2043 		"simplicity of this clause of Catch-22 and let out a "
2044 		"respectful whistle. \"That's some catch, that Catch-22\", he "
2045 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
2046 
2047 const char catch_22_quote[] =
2048 		"What a lousy earth! He wondered how many people were "
2049 		"destitute that same night even in his own prosperous country, "
2050 		"how many homes were shanties, how many husbands were drunk "
2051 		"and wives socked, and how many children were bullied, abused, "
2052 		"or abandoned. How many families hungered for food they could "
2053 		"not afford to buy? How many hearts were broken? How many "
2054 		"suicides would take place that same night, how many people "
2055 		"would go insane? How many cockroaches and landlords would "
2056 		"triumph? How many winners were losers, successes failures, "
2057 		"and rich men poor men? How many wise guys were stupid? How "
2058 		"many happy endings were unhappy endings? How many honest men "
2059 		"were liars, brave men cowards, loyal men traitors, how many "
2060 		"sainted men were corrupt, how many people in positions of "
2061 		"trust had sold their souls to bodyguards, how many had never "
2062 		"had souls? How many straight-and-narrow paths were crooked "
2063 		"paths? How many best families were worst families and how "
2064 		"many good people were bad people? When you added them all up "
2065 		"and then subtracted, you might be left with only the children, "
2066 		"and perhaps with Albert Einstein and an old violinist or "
2067 		"sculptor somewhere.";
2068 
2069 #define QUOTE_480_BYTES		(480)
2070 #define QUOTE_512_BYTES		(512)
2071 #define QUOTE_768_BYTES		(768)
2072 #define QUOTE_1024_BYTES	(1024)
2073 
2074 
2075 
2076 /* ***** SHA1 Hash Tests ***** */
2077 
2078 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
2079 
2080 static uint8_t hmac_sha1_key[] = {
2081 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
2082 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
2083 	0xDE, 0xF4, 0xDE, 0xAD };
2084 
2085 /* ***** SHA224 Hash Tests ***** */
2086 
2087 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
2088 
2089 
2090 /* ***** AES-CBC Cipher Tests ***** */
2091 
2092 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
2093 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
2094 
2095 static uint8_t aes_cbc_key[] = {
2096 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2097 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2098 
2099 static uint8_t aes_cbc_iv[] = {
2100 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2101 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2102 
2103 
2104 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2105 
2106 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2107 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2108 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2109 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2110 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2111 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2112 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2113 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2114 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2115 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2116 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2117 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2118 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2119 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2120 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2121 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2122 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2123 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2124 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2125 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2126 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2127 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2128 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2129 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2130 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2131 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2132 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2133 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2134 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2135 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2136 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2137 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2138 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2139 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2140 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2141 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2142 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2143 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2144 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2145 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2146 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2147 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2148 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2149 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2150 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2151 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2152 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2153 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2154 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2155 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2156 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2157 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2158 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2159 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2160 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2161 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2162 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2163 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2164 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2165 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2166 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2167 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2168 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2169 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2170 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2171 };
2172 
2173 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2174 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2175 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2176 	0x18, 0x8c, 0x1d, 0x32
2177 };
2178 
2179 
2180 /* Multisession Vector context Test */
2181 /*Begin Session 0 */
2182 static uint8_t ms_aes_cbc_key0[] = {
2183 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2184 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2185 };
2186 
2187 static uint8_t ms_aes_cbc_iv0[] = {
2188 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2189 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2190 };
2191 
2192 static const uint8_t ms_aes_cbc_cipher0[] = {
2193 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2194 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2195 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2196 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2197 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2198 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2199 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2200 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2201 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2202 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2203 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2204 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2205 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2206 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2207 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2208 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2209 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2210 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2211 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2212 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2213 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2214 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2215 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2216 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2217 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2218 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2219 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2220 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2221 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2222 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2223 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2224 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2225 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2226 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2227 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2228 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2229 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2230 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2231 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2232 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2233 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2234 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2235 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2236 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2237 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2238 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2239 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2240 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2241 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2242 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2243 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2244 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2245 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2246 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2247 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2248 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2249 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2250 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2251 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2252 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2253 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2254 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2255 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2256 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2257 };
2258 
2259 
2260 static  uint8_t ms_hmac_key0[] = {
2261 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2262 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2263 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2264 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2265 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2266 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2267 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2268 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2269 };
2270 
2271 static const uint8_t ms_hmac_digest0[] = {
2272 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2273 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2274 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2275 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2276 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2277 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2278 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2279 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2280 		};
2281 
2282 /* End Session 0 */
2283 /* Begin session 1 */
2284 
2285 static  uint8_t ms_aes_cbc_key1[] = {
2286 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2287 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2288 };
2289 
2290 static  uint8_t ms_aes_cbc_iv1[] = {
2291 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2292 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2293 };
2294 
2295 static const uint8_t ms_aes_cbc_cipher1[] = {
2296 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2297 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2298 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2299 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2300 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2301 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2302 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2303 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2304 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2305 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2306 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2307 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2308 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2309 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2310 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2311 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2312 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2313 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2314 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2315 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2316 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2317 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2318 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2319 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2320 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2321 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2322 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2323 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2324 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2325 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2326 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2327 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2328 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2329 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2330 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2331 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2332 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2333 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2334 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2335 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2336 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2337 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2338 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2339 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2340 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2341 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2342 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2343 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2344 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2345 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2346 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2347 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2348 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2349 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2350 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2351 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2352 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2353 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2354 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2355 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2356 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2357 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2358 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2359 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2360 
2361 };
2362 
2363 static uint8_t ms_hmac_key1[] = {
2364 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2365 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2366 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2367 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2368 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2369 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2370 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2371 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2372 };
2373 
2374 static const uint8_t ms_hmac_digest1[] = {
2375 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2376 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2377 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2378 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2379 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2380 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2381 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2382 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2383 };
2384 /* End Session 1  */
2385 /* Begin Session 2 */
2386 static  uint8_t ms_aes_cbc_key2[] = {
2387 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2388 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2389 };
2390 
2391 static  uint8_t ms_aes_cbc_iv2[] = {
2392 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2393 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2394 };
2395 
2396 static const uint8_t ms_aes_cbc_cipher2[] = {
2397 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2398 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2399 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2400 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2401 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2402 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2403 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2404 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2405 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2406 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2407 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2408 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2409 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2410 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2411 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2412 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2413 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2414 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2415 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2416 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2417 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2418 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2419 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2420 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2421 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2422 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2423 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2424 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2425 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2426 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2427 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2428 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2429 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2430 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2431 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2432 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2433 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2434 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2435 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2436 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2437 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2438 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2439 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2440 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2441 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2442 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2443 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2444 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2445 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2446 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2447 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2448 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2449 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2450 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2451 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2452 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2453 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2454 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2455 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2456 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2457 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2458 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2459 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2460 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2461 };
2462 
2463 static  uint8_t ms_hmac_key2[] = {
2464 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2465 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2466 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2467 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2468 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2469 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2470 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2471 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2472 };
2473 
2474 static const uint8_t ms_hmac_digest2[] = {
2475 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2476 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2477 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2478 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2479 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2480 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2481 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2482 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2483 };
2484 
2485 /* End Session 2 */
2486 
2487 #define MAX_OPS_PROCESSED (MAX_NUM_OPS_INFLIGHT - 1)
2488 static int
2489 test_queue_pair_descriptor_count(void)
2490 {
2491 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2492 	struct crypto_unittest_params *ut_params = &unittest_params;
2493 	struct rte_crypto_op *ops_deq[MAX_OPS_PROCESSED] = { NULL };
2494 	struct rte_crypto_op *ops[MAX_OPS_PROCESSED] = { NULL };
2495 	struct rte_cryptodev_sym_capability_idx cap_idx;
2496 	int qp_depth = 0;
2497 	int i;
2498 
2499 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2500 		return TEST_SKIPPED;
2501 
2502 	/* Verify if the queue pair depth API is supported by driver */
2503 	qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2504 	if (qp_depth == -ENOTSUP)
2505 		return TEST_SKIPPED;
2506 
2507 	/* Verify the capabilities */
2508 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2509 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2510 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2511 		return TEST_SKIPPED;
2512 
2513 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2514 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2515 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx) == NULL)
2516 		return TEST_SKIPPED;
2517 
2518 	/* Setup Cipher Parameters */
2519 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2520 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2521 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2522 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2523 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2524 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2525 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2526 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2527 
2528 	/* Setup HMAC Parameters */
2529 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2530 	ut_params->auth_xform.next = NULL;
2531 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2532 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2533 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2534 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2535 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2536 
2537 	rte_errno = 0;
2538 	ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
2539 			&ut_params->cipher_xform, ts_params->session_mpool);
2540 	if (rte_errno == ENOTSUP)
2541 		return TEST_SKIPPED;
2542 
2543 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2544 
2545 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
2546 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, MAX_OPS_PROCESSED),
2547 			MAX_OPS_PROCESSED, "failed to generate burst of crypto ops");
2548 
2549 	/* Generate crypto op data structure */
2550 	for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2551 		struct rte_mbuf *m;
2552 		uint8_t *digest;
2553 
2554 		/* Generate test mbuf data and space for digest */
2555 		m = setup_test_string(ts_params->mbuf_pool, catch_22_quote, QUOTE_512_BYTES, 0);
2556 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
2557 
2558 		digest = (uint8_t *)rte_pktmbuf_append(m, DIGEST_BYTE_LENGTH_SHA1);
2559 		TEST_ASSERT_NOT_NULL(digest, "no room to append digest");
2560 
2561 		rte_crypto_op_attach_sym_session(ops[i], ut_params->sess);
2562 
2563 		/* set crypto operation source mbuf */
2564 		ops[i]->sym->m_src = m;
2565 
2566 		/* Set crypto operation authentication parameters */
2567 		ops[i]->sym->auth.digest.data = digest;
2568 		ops[i]->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m, QUOTE_512_BYTES);
2569 
2570 		ops[i]->sym->auth.data.offset = 0;
2571 		ops[i]->sym->auth.data.length = QUOTE_512_BYTES;
2572 
2573 		/* Copy IV at the end of the crypto operation */
2574 		memcpy(rte_crypto_op_ctod_offset(ops[i], uint8_t *, IV_OFFSET), aes_cbc_iv,
2575 				CIPHER_IV_LENGTH_AES_CBC);
2576 
2577 		/* Set crypto operation cipher parameters */
2578 		ops[i]->sym->cipher.data.offset = 0;
2579 		ops[i]->sym->cipher.data.length = QUOTE_512_BYTES;
2580 
2581 		TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 0,
2582 					&ops[i], 1), 1, "Error enqueuing");
2583 	}
2584 
2585 	for (i = 0; i < MAX_OPS_PROCESSED; i++) {
2586 		qp_depth = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
2587 		TEST_ASSERT_EQUAL(qp_depth, MAX_OPS_PROCESSED - i,
2588 			"Crypto queue pair depth used does not match with inflight ops");
2589 
2590 		while (rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 0,
2591 					&ops_deq[i], 1) == 0)
2592 			rte_pause();
2593 
2594 		TEST_ASSERT_EQUAL(ops_deq[i]->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2595 				"crypto op processing failed");
2596 
2597 		rte_pktmbuf_free(ops_deq[i]->sym->m_src);
2598 		rte_crypto_op_free(ops_deq[i]);
2599 	}
2600 
2601 	return TEST_SUCCESS;
2602 }
2603 
2604 static int
2605 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2606 {
2607 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2608 	struct crypto_unittest_params *ut_params = &unittest_params;
2609 	/* Verify the capabilities */
2610 	struct rte_cryptodev_sym_capability_idx cap_idx;
2611 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2612 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2613 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2614 			&cap_idx) == NULL)
2615 		return TEST_SKIPPED;
2616 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2617 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2618 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2619 			&cap_idx) == NULL)
2620 		return TEST_SKIPPED;
2621 
2622 	/* Generate test mbuf data and space for digest */
2623 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2624 			catch_22_quote,	QUOTE_512_BYTES, 0);
2625 
2626 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2627 			DIGEST_BYTE_LENGTH_SHA1);
2628 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2629 
2630 	/* Setup Cipher Parameters */
2631 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2632 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2633 
2634 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2635 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2636 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2637 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2638 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2639 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2640 
2641 	/* Setup HMAC Parameters */
2642 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2643 
2644 	ut_params->auth_xform.next = NULL;
2645 
2646 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2647 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2648 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2649 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2650 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2651 
2652 	rte_errno = 0;
2653 	ut_params->sess = rte_cryptodev_sym_session_create(
2654 			ts_params->valid_devs[0], &ut_params->cipher_xform,
2655 			ts_params->session_mpool);
2656 	if (rte_errno == ENOTSUP)
2657 		return TEST_SKIPPED;
2658 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2659 
2660 	/* Generate crypto op data structure */
2661 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2662 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2663 	TEST_ASSERT_NOT_NULL(ut_params->op,
2664 			"Failed to allocate symmetric crypto operation struct");
2665 
2666 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2667 
2668 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2669 
2670 	/* set crypto operation source mbuf */
2671 	sym_op->m_src = ut_params->ibuf;
2672 
2673 	/* Set crypto operation authentication parameters */
2674 	sym_op->auth.digest.data = ut_params->digest;
2675 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2676 			ut_params->ibuf, QUOTE_512_BYTES);
2677 
2678 	sym_op->auth.data.offset = 0;
2679 	sym_op->auth.data.length = QUOTE_512_BYTES;
2680 
2681 	/* Copy IV at the end of the crypto operation */
2682 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2683 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2684 
2685 	/* Set crypto operation cipher parameters */
2686 	sym_op->cipher.data.offset = 0;
2687 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2688 
2689 	/* Process crypto operation */
2690 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2691 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2692 			ut_params->op);
2693 	else
2694 		TEST_ASSERT_NOT_NULL(
2695 			process_crypto_request(ts_params->valid_devs[0],
2696 				ut_params->op),
2697 				"failed to process sym crypto op");
2698 
2699 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2700 			"crypto op processing failed");
2701 
2702 	/* Validate obuf */
2703 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2704 			uint8_t *);
2705 
2706 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2707 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2708 			QUOTE_512_BYTES,
2709 			"ciphertext data not as expected");
2710 
2711 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2712 
2713 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2714 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2715 			gbl_driver_id == rte_cryptodev_driver_id_get(
2716 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2717 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2718 					DIGEST_BYTE_LENGTH_SHA1,
2719 			"Generated digest data not as expected");
2720 
2721 	return TEST_SUCCESS;
2722 }
2723 
2724 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2725 
2726 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2727 
2728 static uint8_t hmac_sha512_key[] = {
2729 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2730 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2731 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2732 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2733 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2734 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2735 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2736 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2737 
2738 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2739 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2740 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2741 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2742 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2743 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2744 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2745 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2746 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2747 
2748 
2749 
2750 static int
2751 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2752 		struct crypto_unittest_params *ut_params,
2753 		uint8_t *cipher_key,
2754 		uint8_t *hmac_key);
2755 
2756 static int
2757 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2758 		struct crypto_unittest_params *ut_params,
2759 		struct crypto_testsuite_params *ts_params,
2760 		const uint8_t *cipher,
2761 		const uint8_t *digest,
2762 		const uint8_t *iv);
2763 
2764 
2765 static int
2766 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2767 		struct crypto_unittest_params *ut_params,
2768 		uint8_t *cipher_key,
2769 		uint8_t *hmac_key)
2770 {
2771 
2772 	/* Setup Cipher Parameters */
2773 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2774 	ut_params->cipher_xform.next = NULL;
2775 
2776 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2777 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2778 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2779 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2780 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2781 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2782 
2783 	/* Setup HMAC Parameters */
2784 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2785 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2786 
2787 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2788 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2789 	ut_params->auth_xform.auth.key.data = hmac_key;
2790 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2791 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2792 
2793 	return TEST_SUCCESS;
2794 }
2795 
2796 
2797 static int
2798 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2799 		struct crypto_unittest_params *ut_params,
2800 		struct crypto_testsuite_params *ts_params,
2801 		const uint8_t *cipher,
2802 		const uint8_t *digest,
2803 		const uint8_t *iv)
2804 {
2805 	int ret;
2806 
2807 	/* Generate test mbuf data and digest */
2808 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2809 			(const char *)
2810 			cipher,
2811 			QUOTE_512_BYTES, 0);
2812 
2813 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2814 			DIGEST_BYTE_LENGTH_SHA512);
2815 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2816 
2817 	rte_memcpy(ut_params->digest,
2818 			digest,
2819 			DIGEST_BYTE_LENGTH_SHA512);
2820 
2821 	/* Generate Crypto op data structure */
2822 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2823 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2824 	TEST_ASSERT_NOT_NULL(ut_params->op,
2825 			"Failed to allocate symmetric crypto operation struct");
2826 
2827 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2828 
2829 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2830 
2831 	/* set crypto operation source mbuf */
2832 	sym_op->m_src = ut_params->ibuf;
2833 
2834 	sym_op->auth.digest.data = ut_params->digest;
2835 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2836 			ut_params->ibuf, QUOTE_512_BYTES);
2837 
2838 	sym_op->auth.data.offset = 0;
2839 	sym_op->auth.data.length = QUOTE_512_BYTES;
2840 
2841 	/* Copy IV at the end of the crypto operation */
2842 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2843 			iv, CIPHER_IV_LENGTH_AES_CBC);
2844 
2845 	sym_op->cipher.data.offset = 0;
2846 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2847 
2848 	/* Process crypto operation */
2849 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2850 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2851 			ut_params->op);
2852 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2853 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2854 		if (ret != TEST_SUCCESS)
2855 			return ret;
2856 	} else
2857 		TEST_ASSERT_NOT_NULL(
2858 				process_crypto_request(ts_params->valid_devs[0],
2859 					ut_params->op),
2860 					"failed to process sym crypto op");
2861 
2862 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2863 			"crypto op processing failed");
2864 
2865 	ut_params->obuf = ut_params->op->sym->m_src;
2866 
2867 	/* Validate obuf */
2868 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2869 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2870 			catch_22_quote,
2871 			QUOTE_512_BYTES,
2872 			"Plaintext data not as expected");
2873 
2874 	/* Validate obuf */
2875 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2876 			"Digest verification failed");
2877 
2878 	return TEST_SUCCESS;
2879 }
2880 
2881 /* ***** SNOW 3G Tests ***** */
2882 static int
2883 create_wireless_algo_hash_session(uint8_t dev_id,
2884 	const uint8_t *key, const uint8_t key_len,
2885 	const uint8_t iv_len, const uint8_t auth_len,
2886 	enum rte_crypto_auth_operation op,
2887 	enum rte_crypto_auth_algorithm algo)
2888 {
2889 	uint8_t hash_key[key_len];
2890 
2891 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2892 	struct crypto_unittest_params *ut_params = &unittest_params;
2893 
2894 	memcpy(hash_key, key, key_len);
2895 
2896 	debug_hexdump(stdout, "key:", key, key_len);
2897 
2898 	/* Setup Authentication Parameters */
2899 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2900 	ut_params->auth_xform.next = NULL;
2901 
2902 	ut_params->auth_xform.auth.op = op;
2903 	ut_params->auth_xform.auth.algo = algo;
2904 	ut_params->auth_xform.auth.key.length = key_len;
2905 	ut_params->auth_xform.auth.key.data = hash_key;
2906 	ut_params->auth_xform.auth.digest_length = auth_len;
2907 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2908 	ut_params->auth_xform.auth.iv.length = iv_len;
2909 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2910 			&ut_params->auth_xform, ts_params->session_mpool);
2911 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2912 		return TEST_SKIPPED;
2913 
2914 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2915 	return 0;
2916 }
2917 
2918 static int
2919 create_wireless_algo_cipher_session(uint8_t dev_id,
2920 			enum rte_crypto_cipher_operation op,
2921 			enum rte_crypto_cipher_algorithm algo,
2922 			const uint8_t *key, const uint8_t key_len,
2923 			uint8_t iv_len)
2924 {
2925 	uint8_t cipher_key[key_len];
2926 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2927 	struct crypto_unittest_params *ut_params = &unittest_params;
2928 
2929 	memcpy(cipher_key, key, key_len);
2930 
2931 	/* Setup Cipher Parameters */
2932 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2933 	ut_params->cipher_xform.next = NULL;
2934 
2935 	ut_params->cipher_xform.cipher.algo = algo;
2936 	ut_params->cipher_xform.cipher.op = op;
2937 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2938 	ut_params->cipher_xform.cipher.key.length = key_len;
2939 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2940 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2941 
2942 	debug_hexdump(stdout, "key:", key, key_len);
2943 
2944 	/* Create Crypto session */
2945 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2946 			&ut_params->cipher_xform, ts_params->session_mpool);
2947 
2948 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2949 		return TEST_SKIPPED;
2950 
2951 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2952 	return 0;
2953 }
2954 
2955 static int
2956 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2957 			unsigned int cipher_len,
2958 			unsigned int cipher_offset)
2959 {
2960 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2961 	struct crypto_unittest_params *ut_params = &unittest_params;
2962 
2963 	/* Generate Crypto op data structure */
2964 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2965 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2966 	TEST_ASSERT_NOT_NULL(ut_params->op,
2967 				"Failed to allocate pktmbuf offload");
2968 
2969 	/* Set crypto operation data parameters */
2970 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2971 
2972 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2973 
2974 	/* set crypto operation source mbuf */
2975 	sym_op->m_src = ut_params->ibuf;
2976 
2977 	/* iv */
2978 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2979 			iv, iv_len);
2980 	sym_op->cipher.data.length = cipher_len;
2981 	sym_op->cipher.data.offset = cipher_offset;
2982 	return 0;
2983 }
2984 
2985 static int
2986 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2987 			unsigned int cipher_len,
2988 			unsigned int cipher_offset)
2989 {
2990 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 	struct crypto_unittest_params *ut_params = &unittest_params;
2992 
2993 	/* Generate Crypto op data structure */
2994 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2995 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2996 	TEST_ASSERT_NOT_NULL(ut_params->op,
2997 				"Failed to allocate pktmbuf offload");
2998 
2999 	/* Set crypto operation data parameters */
3000 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3001 
3002 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3003 
3004 	/* set crypto operation source mbuf */
3005 	sym_op->m_src = ut_params->ibuf;
3006 	sym_op->m_dst = ut_params->obuf;
3007 
3008 	/* iv */
3009 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3010 			iv, iv_len);
3011 	sym_op->cipher.data.length = cipher_len;
3012 	sym_op->cipher.data.offset = cipher_offset;
3013 	return 0;
3014 }
3015 
3016 static int
3017 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
3018 		enum rte_crypto_cipher_operation cipher_op,
3019 		enum rte_crypto_auth_operation auth_op,
3020 		enum rte_crypto_auth_algorithm auth_algo,
3021 		enum rte_crypto_cipher_algorithm cipher_algo,
3022 		const uint8_t *a_key, uint8_t a_key_len,
3023 		const uint8_t *c_key, uint8_t c_key_len,
3024 		uint8_t auth_iv_len, uint8_t auth_len,
3025 		uint8_t cipher_iv_len)
3026 
3027 {
3028 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3029 	struct crypto_unittest_params *ut_params = &unittest_params;
3030 
3031 	/* Setup Authentication Parameters */
3032 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3033 	ut_params->auth_xform.next = NULL;
3034 
3035 	ut_params->auth_xform.auth.op = auth_op;
3036 	ut_params->auth_xform.auth.algo = auth_algo;
3037 	ut_params->auth_xform.auth.key.length = a_key_len;
3038 	ut_params->auth_xform.auth.key.data = a_key;
3039 	ut_params->auth_xform.auth.digest_length = auth_len;
3040 	/* Auth IV will be after cipher IV */
3041 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3042 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
3043 
3044 	/* Setup Cipher Parameters */
3045 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3046 	ut_params->cipher_xform.next = &ut_params->auth_xform;
3047 
3048 	ut_params->cipher_xform.cipher.algo = cipher_algo;
3049 	ut_params->cipher_xform.cipher.op = cipher_op;
3050 	ut_params->cipher_xform.cipher.key.data = c_key;
3051 	ut_params->cipher_xform.cipher.key.length = c_key_len;
3052 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3053 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3054 
3055 	debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
3056 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3057 
3058 	/* Create Crypto session*/
3059 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3060 			&ut_params->cipher_xform, ts_params->session_mpool);
3061 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3062 		return TEST_SKIPPED;
3063 
3064 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3065 	return 0;
3066 }
3067 
3068 static int
3069 create_wireless_cipher_auth_session(uint8_t dev_id,
3070 		enum rte_crypto_cipher_operation cipher_op,
3071 		enum rte_crypto_auth_operation auth_op,
3072 		enum rte_crypto_auth_algorithm auth_algo,
3073 		enum rte_crypto_cipher_algorithm cipher_algo,
3074 		const struct wireless_test_data *tdata)
3075 {
3076 	const uint8_t key_len = tdata->key.len;
3077 	uint8_t cipher_auth_key[key_len];
3078 
3079 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3080 	struct crypto_unittest_params *ut_params = &unittest_params;
3081 	const uint8_t *key = tdata->key.data;
3082 	const uint8_t auth_len = tdata->digest.len;
3083 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
3084 	uint8_t auth_iv_len = tdata->auth_iv.len;
3085 
3086 	memcpy(cipher_auth_key, key, key_len);
3087 
3088 	/* Setup Authentication Parameters */
3089 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3090 	ut_params->auth_xform.next = NULL;
3091 
3092 	ut_params->auth_xform.auth.op = auth_op;
3093 	ut_params->auth_xform.auth.algo = auth_algo;
3094 	ut_params->auth_xform.auth.key.length = key_len;
3095 	/* Hash key = cipher key */
3096 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
3097 	ut_params->auth_xform.auth.digest_length = auth_len;
3098 	/* Auth IV will be after cipher IV */
3099 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3100 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
3101 
3102 	/* Setup Cipher Parameters */
3103 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3104 	ut_params->cipher_xform.next = &ut_params->auth_xform;
3105 
3106 	ut_params->cipher_xform.cipher.algo = cipher_algo;
3107 	ut_params->cipher_xform.cipher.op = cipher_op;
3108 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
3109 	ut_params->cipher_xform.cipher.key.length = key_len;
3110 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3111 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3112 
3113 
3114 	debug_hexdump(stdout, "key:", key, key_len);
3115 
3116 	/* Create Crypto session*/
3117 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3118 			&ut_params->cipher_xform, ts_params->session_mpool);
3119 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3120 		return TEST_SKIPPED;
3121 
3122 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3123 	return 0;
3124 }
3125 
3126 static int
3127 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
3128 		const struct wireless_test_data *tdata)
3129 {
3130 	return create_wireless_cipher_auth_session(dev_id,
3131 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3132 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
3133 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
3134 }
3135 
3136 static int
3137 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
3138 		enum rte_crypto_cipher_operation cipher_op,
3139 		enum rte_crypto_auth_operation auth_op,
3140 		enum rte_crypto_auth_algorithm auth_algo,
3141 		enum rte_crypto_cipher_algorithm cipher_algo,
3142 		const uint8_t *a_key, const uint8_t a_key_len,
3143 		const uint8_t *c_key, const uint8_t c_key_len,
3144 		uint8_t auth_iv_len, uint8_t auth_len,
3145 		uint8_t cipher_iv_len)
3146 {
3147 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3148 	struct crypto_unittest_params *ut_params = &unittest_params;
3149 
3150 	/* Setup Authentication Parameters */
3151 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3152 	ut_params->auth_xform.auth.op = auth_op;
3153 	ut_params->auth_xform.next = &ut_params->cipher_xform;
3154 	ut_params->auth_xform.auth.algo = auth_algo;
3155 	ut_params->auth_xform.auth.key.length = a_key_len;
3156 	ut_params->auth_xform.auth.key.data = a_key;
3157 	ut_params->auth_xform.auth.digest_length = auth_len;
3158 	/* Auth IV will be after cipher IV */
3159 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
3160 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
3161 
3162 	/* Setup Cipher Parameters */
3163 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3164 	ut_params->cipher_xform.next = NULL;
3165 	ut_params->cipher_xform.cipher.algo = cipher_algo;
3166 	ut_params->cipher_xform.cipher.op = cipher_op;
3167 	ut_params->cipher_xform.cipher.key.data = c_key;
3168 	ut_params->cipher_xform.cipher.key.length = c_key_len;
3169 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
3170 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
3171 
3172 	debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
3173 	debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
3174 
3175 	/* Create Crypto session*/
3176 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3177 		ut_params->auth_xform.next = NULL;
3178 		ut_params->cipher_xform.next = &ut_params->auth_xform;
3179 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3180 			&ut_params->cipher_xform, ts_params->session_mpool);
3181 	} else
3182 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3183 			&ut_params->auth_xform, ts_params->session_mpool);
3184 
3185 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
3186 		return TEST_SKIPPED;
3187 
3188 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3189 
3190 	return 0;
3191 }
3192 
3193 static int
3194 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
3195 		unsigned int auth_tag_len,
3196 		const uint8_t *iv, unsigned int iv_len,
3197 		unsigned int data_pad_len,
3198 		enum rte_crypto_auth_operation op,
3199 		unsigned int auth_len, unsigned int auth_offset)
3200 {
3201 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3202 
3203 	struct crypto_unittest_params *ut_params = &unittest_params;
3204 
3205 	/* Generate Crypto op data structure */
3206 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3207 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3208 	TEST_ASSERT_NOT_NULL(ut_params->op,
3209 		"Failed to allocate pktmbuf offload");
3210 
3211 	/* Set crypto operation data parameters */
3212 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3213 
3214 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3215 
3216 	/* set crypto operation source mbuf */
3217 	sym_op->m_src = ut_params->ibuf;
3218 
3219 	/* iv */
3220 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3221 			iv, iv_len);
3222 	/* digest */
3223 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3224 					ut_params->ibuf, auth_tag_len);
3225 
3226 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3227 				"no room to append auth tag");
3228 	ut_params->digest = sym_op->auth.digest.data;
3229 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3230 			ut_params->ibuf, data_pad_len);
3231 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3232 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3233 	else
3234 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3235 
3236 	debug_hexdump(stdout, "digest:",
3237 		sym_op->auth.digest.data,
3238 		auth_tag_len);
3239 
3240 	sym_op->auth.data.length = auth_len;
3241 	sym_op->auth.data.offset = auth_offset;
3242 
3243 	return 0;
3244 }
3245 
3246 static int
3247 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3248 	enum rte_crypto_auth_operation op)
3249 {
3250 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3251 	struct crypto_unittest_params *ut_params = &unittest_params;
3252 
3253 	const uint8_t *auth_tag = tdata->digest.data;
3254 	const unsigned int auth_tag_len = tdata->digest.len;
3255 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3256 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3257 
3258 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
3259 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3260 	const uint8_t *auth_iv = tdata->auth_iv.data;
3261 	const uint8_t auth_iv_len = tdata->auth_iv.len;
3262 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3263 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
3264 
3265 	/* Generate Crypto op data structure */
3266 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3267 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3268 	TEST_ASSERT_NOT_NULL(ut_params->op,
3269 			"Failed to allocate pktmbuf offload");
3270 	/* Set crypto operation data parameters */
3271 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3272 
3273 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3274 
3275 	/* set crypto operation source mbuf */
3276 	sym_op->m_src = ut_params->ibuf;
3277 
3278 	/* digest */
3279 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3280 			ut_params->ibuf, auth_tag_len);
3281 
3282 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3283 			"no room to append auth tag");
3284 	ut_params->digest = sym_op->auth.digest.data;
3285 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3286 			ut_params->ibuf, data_pad_len);
3287 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3288 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3289 	else
3290 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3291 
3292 	debug_hexdump(stdout, "digest:",
3293 		sym_op->auth.digest.data,
3294 		auth_tag_len);
3295 
3296 	/* Copy cipher and auth IVs at the end of the crypto operation */
3297 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3298 						IV_OFFSET);
3299 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3300 	iv_ptr += cipher_iv_len;
3301 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3302 
3303 	sym_op->cipher.data.length = cipher_len;
3304 	sym_op->cipher.data.offset = 0;
3305 	sym_op->auth.data.length = auth_len;
3306 	sym_op->auth.data.offset = 0;
3307 
3308 	return 0;
3309 }
3310 
3311 static int
3312 create_zuc_cipher_hash_generate_operation(
3313 		const struct wireless_test_data *tdata)
3314 {
3315 	return create_wireless_cipher_hash_operation(tdata,
3316 		RTE_CRYPTO_AUTH_OP_GENERATE);
3317 }
3318 
3319 static int
3320 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3321 		const unsigned auth_tag_len,
3322 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3323 		unsigned data_pad_len,
3324 		enum rte_crypto_auth_operation op,
3325 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3326 		const unsigned cipher_len, const unsigned cipher_offset,
3327 		const unsigned auth_len, const unsigned auth_offset)
3328 {
3329 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3330 	struct crypto_unittest_params *ut_params = &unittest_params;
3331 
3332 	enum rte_crypto_cipher_algorithm cipher_algo =
3333 			ut_params->cipher_xform.cipher.algo;
3334 	enum rte_crypto_auth_algorithm auth_algo =
3335 			ut_params->auth_xform.auth.algo;
3336 
3337 	/* Generate Crypto op data structure */
3338 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3339 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3340 	TEST_ASSERT_NOT_NULL(ut_params->op,
3341 			"Failed to allocate pktmbuf offload");
3342 	/* Set crypto operation data parameters */
3343 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3344 
3345 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3346 
3347 	/* set crypto operation source mbuf */
3348 	sym_op->m_src = ut_params->ibuf;
3349 
3350 	/* digest */
3351 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3352 			ut_params->ibuf, auth_tag_len);
3353 
3354 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3355 			"no room to append auth tag");
3356 	ut_params->digest = sym_op->auth.digest.data;
3357 
3358 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3359 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3360 				ut_params->ibuf, data_pad_len);
3361 	} else {
3362 		struct rte_mbuf *m = ut_params->ibuf;
3363 		unsigned int offset = data_pad_len;
3364 
3365 		while (offset > m->data_len && m->next != NULL) {
3366 			offset -= m->data_len;
3367 			m = m->next;
3368 		}
3369 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3370 			m, offset);
3371 	}
3372 
3373 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3374 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3375 	else
3376 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3377 
3378 	debug_hexdump(stdout, "digest:",
3379 		sym_op->auth.digest.data,
3380 		auth_tag_len);
3381 
3382 	/* Copy cipher and auth IVs at the end of the crypto operation */
3383 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3384 						IV_OFFSET);
3385 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3386 	iv_ptr += cipher_iv_len;
3387 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3388 
3389 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3390 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3391 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3392 		sym_op->cipher.data.length = cipher_len;
3393 		sym_op->cipher.data.offset = cipher_offset;
3394 	} else {
3395 		sym_op->cipher.data.length = cipher_len >> 3;
3396 		sym_op->cipher.data.offset = cipher_offset >> 3;
3397 	}
3398 
3399 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3400 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3401 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3402 		sym_op->auth.data.length = auth_len;
3403 		sym_op->auth.data.offset = auth_offset;
3404 	} else {
3405 		sym_op->auth.data.length = auth_len >> 3;
3406 		sym_op->auth.data.offset = auth_offset >> 3;
3407 	}
3408 
3409 	return 0;
3410 }
3411 
3412 static int
3413 create_wireless_algo_auth_cipher_operation(
3414 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3415 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3416 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3417 		unsigned int data_pad_len,
3418 		unsigned int cipher_len, unsigned int cipher_offset,
3419 		unsigned int auth_len, unsigned int auth_offset,
3420 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3421 {
3422 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3423 	struct crypto_unittest_params *ut_params = &unittest_params;
3424 
3425 	enum rte_crypto_cipher_algorithm cipher_algo =
3426 			ut_params->cipher_xform.cipher.algo;
3427 	enum rte_crypto_auth_algorithm auth_algo =
3428 			ut_params->auth_xform.auth.algo;
3429 
3430 	/* Generate Crypto op data structure */
3431 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3432 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3433 	TEST_ASSERT_NOT_NULL(ut_params->op,
3434 			"Failed to allocate pktmbuf offload");
3435 
3436 	/* Set crypto operation data parameters */
3437 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3438 
3439 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3440 
3441 	/* set crypto operation mbufs */
3442 	sym_op->m_src = ut_params->ibuf;
3443 	if (op_mode == OUT_OF_PLACE)
3444 		sym_op->m_dst = ut_params->obuf;
3445 
3446 	/* digest */
3447 	if (!do_sgl) {
3448 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3449 			(op_mode == IN_PLACE ?
3450 				ut_params->ibuf : ut_params->obuf),
3451 			uint8_t *, data_pad_len);
3452 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3453 			(op_mode == IN_PLACE ?
3454 				ut_params->ibuf : ut_params->obuf),
3455 			data_pad_len);
3456 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3457 	} else {
3458 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3459 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3460 				sym_op->m_src : sym_op->m_dst);
3461 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3462 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3463 			sgl_buf = sgl_buf->next;
3464 		}
3465 
3466 		/* The last segment should be large enough to hold full digest */
3467 		if (sgl_buf->data_len < auth_tag_len) {
3468 			rte_pktmbuf_free(sgl_buf->next);
3469 			sgl_buf->next = NULL;
3470 			TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3471 					auth_tag_len - sgl_buf->data_len),
3472 					"No room to append auth tag");
3473 		}
3474 
3475 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3476 				uint8_t *, remaining_off);
3477 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3478 				remaining_off);
3479 		memset(sym_op->auth.digest.data, 0, remaining_off);
3480 		while (sgl_buf->next != NULL) {
3481 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3482 				0, rte_pktmbuf_data_len(sgl_buf));
3483 			sgl_buf = sgl_buf->next;
3484 		}
3485 	}
3486 
3487 	/* Copy digest for the verification */
3488 	if (verify)
3489 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3490 
3491 	/* Copy cipher and auth IVs at the end of the crypto operation */
3492 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3493 			ut_params->op, uint8_t *, IV_OFFSET);
3494 
3495 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3496 	iv_ptr += cipher_iv_len;
3497 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3498 
3499 	/* Only copy over the offset data needed from src to dst in OOP,
3500 	 * if the auth and cipher offsets are not aligned
3501 	 */
3502 	if (op_mode == OUT_OF_PLACE) {
3503 		if (cipher_offset > auth_offset)
3504 			rte_memcpy(
3505 				rte_pktmbuf_mtod_offset(
3506 					sym_op->m_dst,
3507 					uint8_t *, auth_offset >> 3),
3508 				rte_pktmbuf_mtod_offset(
3509 					sym_op->m_src,
3510 					uint8_t *, auth_offset >> 3),
3511 				((cipher_offset >> 3) - (auth_offset >> 3)));
3512 	}
3513 
3514 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3515 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3516 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3517 		sym_op->cipher.data.length = cipher_len;
3518 		sym_op->cipher.data.offset = cipher_offset;
3519 	} else {
3520 		sym_op->cipher.data.length = cipher_len >> 3;
3521 		sym_op->cipher.data.offset = cipher_offset >> 3;
3522 	}
3523 
3524 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3525 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3526 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3527 		sym_op->auth.data.length = auth_len;
3528 		sym_op->auth.data.offset = auth_offset;
3529 	} else {
3530 		sym_op->auth.data.length = auth_len >> 3;
3531 		sym_op->auth.data.offset = auth_offset >> 3;
3532 	}
3533 
3534 	return 0;
3535 }
3536 
3537 static int
3538 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3539 {
3540 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3541 	struct crypto_unittest_params *ut_params = &unittest_params;
3542 
3543 	int retval;
3544 	unsigned plaintext_pad_len;
3545 	unsigned plaintext_len;
3546 	uint8_t *plaintext;
3547 	struct rte_cryptodev_info dev_info;
3548 
3549 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3550 	uint64_t feat_flags = dev_info.feature_flags;
3551 
3552 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3553 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3554 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3555 		return TEST_SKIPPED;
3556 	}
3557 
3558 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3559 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3560 		printf("Device doesn't support RAW data-path APIs.\n");
3561 		return TEST_SKIPPED;
3562 	}
3563 
3564 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3565 		return TEST_SKIPPED;
3566 
3567 	/* Verify the capabilities */
3568 	struct rte_cryptodev_sym_capability_idx cap_idx;
3569 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3570 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3571 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3572 			&cap_idx) == NULL)
3573 		return TEST_SKIPPED;
3574 
3575 	/* Create SNOW 3G session */
3576 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3577 			tdata->key.data, tdata->key.len,
3578 			tdata->auth_iv.len, tdata->digest.len,
3579 			RTE_CRYPTO_AUTH_OP_GENERATE,
3580 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3581 	if (retval < 0)
3582 		return retval;
3583 
3584 	/* alloc mbuf and set payload */
3585 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3586 
3587 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3588 	rte_pktmbuf_tailroom(ut_params->ibuf));
3589 
3590 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3591 	/* Append data which is padded to a multiple of */
3592 	/* the algorithms block size */
3593 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3594 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3595 				plaintext_pad_len);
3596 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3597 
3598 	/* Create SNOW 3G operation */
3599 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3600 			tdata->auth_iv.data, tdata->auth_iv.len,
3601 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3602 			tdata->validAuthLenInBits.len,
3603 			0);
3604 	if (retval < 0)
3605 		return retval;
3606 
3607 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3608 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3609 					       0);
3610 		if (retval != TEST_SUCCESS)
3611 			return retval;
3612 	} else
3613 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3614 				ut_params->op);
3615 	ut_params->obuf = ut_params->op->sym->m_src;
3616 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3617 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3618 						    uint8_t *,
3619 						    plaintext_pad_len);
3620 
3621 	/* Validate obuf */
3622 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3623 	ut_params->digest,
3624 	tdata->digest.data,
3625 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3626 	"SNOW 3G Generated auth tag not as expected");
3627 
3628 	return 0;
3629 }
3630 
3631 static int
3632 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3633 {
3634 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3635 	struct crypto_unittest_params *ut_params = &unittest_params;
3636 
3637 	int retval;
3638 	unsigned plaintext_pad_len;
3639 	unsigned plaintext_len;
3640 	uint8_t *plaintext;
3641 	struct rte_cryptodev_info dev_info;
3642 
3643 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3644 	uint64_t feat_flags = dev_info.feature_flags;
3645 
3646 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3647 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3648 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3649 		return TEST_SKIPPED;
3650 	}
3651 
3652 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3653 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3654 		printf("Device doesn't support RAW data-path APIs.\n");
3655 		return TEST_SKIPPED;
3656 	}
3657 
3658 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3659 		return TEST_SKIPPED;
3660 
3661 	/* Verify the capabilities */
3662 	struct rte_cryptodev_sym_capability_idx cap_idx;
3663 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3664 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3665 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3666 			&cap_idx) == NULL)
3667 		return TEST_SKIPPED;
3668 
3669 	/* Create SNOW 3G session */
3670 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3671 				tdata->key.data, tdata->key.len,
3672 				tdata->auth_iv.len, tdata->digest.len,
3673 				RTE_CRYPTO_AUTH_OP_VERIFY,
3674 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3675 	if (retval < 0)
3676 		return retval;
3677 	/* alloc mbuf and set payload */
3678 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3679 
3680 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3681 	rte_pktmbuf_tailroom(ut_params->ibuf));
3682 
3683 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3684 	/* Append data which is padded to a multiple of */
3685 	/* the algorithms block size */
3686 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3687 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3688 				plaintext_pad_len);
3689 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3690 
3691 	/* Create SNOW 3G operation */
3692 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3693 			tdata->digest.len,
3694 			tdata->auth_iv.data, tdata->auth_iv.len,
3695 			plaintext_pad_len,
3696 			RTE_CRYPTO_AUTH_OP_VERIFY,
3697 			tdata->validAuthLenInBits.len,
3698 			0);
3699 	if (retval < 0)
3700 		return retval;
3701 
3702 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3703 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3704 					       0);
3705 		if (retval != TEST_SUCCESS)
3706 			return retval;
3707 	} else
3708 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3709 				ut_params->op);
3710 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3711 	ut_params->obuf = ut_params->op->sym->m_src;
3712 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3713 						    uint8_t *,
3714 						    plaintext_pad_len);
3715 
3716 	/* Validate obuf */
3717 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3718 		return 0;
3719 	else
3720 		return -1;
3721 
3722 	return 0;
3723 }
3724 
3725 static int
3726 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3727 {
3728 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3729 	struct crypto_unittest_params *ut_params = &unittest_params;
3730 
3731 	int retval;
3732 	unsigned plaintext_pad_len;
3733 	unsigned plaintext_len;
3734 	uint8_t *plaintext;
3735 	struct rte_cryptodev_info dev_info;
3736 
3737 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3738 	uint64_t feat_flags = dev_info.feature_flags;
3739 
3740 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3741 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3742 		printf("Device doesn't support RAW data-path APIs.\n");
3743 		return TEST_SKIPPED;
3744 	}
3745 
3746 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3747 		return TEST_SKIPPED;
3748 
3749 	/* Verify the capabilities */
3750 	struct rte_cryptodev_sym_capability_idx cap_idx;
3751 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3752 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3753 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3754 			&cap_idx) == NULL)
3755 		return TEST_SKIPPED;
3756 
3757 	/* Create KASUMI session */
3758 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3759 			tdata->key.data, tdata->key.len,
3760 			0, tdata->digest.len,
3761 			RTE_CRYPTO_AUTH_OP_GENERATE,
3762 			RTE_CRYPTO_AUTH_KASUMI_F9);
3763 	if (retval < 0)
3764 		return retval;
3765 
3766 	/* alloc mbuf and set payload */
3767 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3768 
3769 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3770 	rte_pktmbuf_tailroom(ut_params->ibuf));
3771 
3772 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3773 	/* Append data which is padded to a multiple of */
3774 	/* the algorithms block size */
3775 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3776 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3777 				plaintext_pad_len);
3778 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3779 
3780 	/* Create KASUMI operation */
3781 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3782 			NULL, 0,
3783 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3784 			tdata->plaintext.len,
3785 			0);
3786 	if (retval < 0)
3787 		return retval;
3788 
3789 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3790 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3791 			ut_params->op);
3792 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3793 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3794 					       0);
3795 		if (retval != TEST_SUCCESS)
3796 			return retval;
3797 	} else
3798 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3799 			ut_params->op);
3800 
3801 	ut_params->obuf = ut_params->op->sym->m_src;
3802 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3803 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3804 						    uint8_t *,
3805 						    plaintext_pad_len);
3806 
3807 	/* Validate obuf */
3808 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3809 	ut_params->digest,
3810 	tdata->digest.data,
3811 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3812 	"KASUMI Generated auth tag not as expected");
3813 
3814 	return 0;
3815 }
3816 
3817 static int
3818 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3819 {
3820 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3821 	struct crypto_unittest_params *ut_params = &unittest_params;
3822 
3823 	int retval;
3824 	unsigned plaintext_pad_len;
3825 	unsigned plaintext_len;
3826 	uint8_t *plaintext;
3827 	struct rte_cryptodev_info dev_info;
3828 
3829 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3830 	uint64_t feat_flags = dev_info.feature_flags;
3831 
3832 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3833 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3834 		printf("Device doesn't support RAW data-path APIs.\n");
3835 		return TEST_SKIPPED;
3836 	}
3837 
3838 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3839 		return TEST_SKIPPED;
3840 
3841 	/* Verify the capabilities */
3842 	struct rte_cryptodev_sym_capability_idx cap_idx;
3843 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3844 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3845 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3846 			&cap_idx) == NULL)
3847 		return TEST_SKIPPED;
3848 
3849 	/* Create KASUMI session */
3850 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3851 				tdata->key.data, tdata->key.len,
3852 				0, tdata->digest.len,
3853 				RTE_CRYPTO_AUTH_OP_VERIFY,
3854 				RTE_CRYPTO_AUTH_KASUMI_F9);
3855 	if (retval < 0)
3856 		return retval;
3857 	/* alloc mbuf and set payload */
3858 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3859 
3860 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3861 	rte_pktmbuf_tailroom(ut_params->ibuf));
3862 
3863 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3864 	/* Append data which is padded to a multiple */
3865 	/* of the algorithms block size */
3866 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3867 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3868 				plaintext_pad_len);
3869 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3870 
3871 	/* Create KASUMI operation */
3872 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3873 			tdata->digest.len,
3874 			NULL, 0,
3875 			plaintext_pad_len,
3876 			RTE_CRYPTO_AUTH_OP_VERIFY,
3877 			tdata->plaintext.len,
3878 			0);
3879 	if (retval < 0)
3880 		return retval;
3881 
3882 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3883 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3884 					       0);
3885 		if (retval != TEST_SUCCESS)
3886 			return retval;
3887 	} else
3888 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3889 				ut_params->op);
3890 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3891 	ut_params->obuf = ut_params->op->sym->m_src;
3892 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3893 						    uint8_t *,
3894 						    plaintext_pad_len);
3895 
3896 	/* Validate obuf */
3897 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3898 		return 0;
3899 	else
3900 		return -1;
3901 
3902 	return 0;
3903 }
3904 
3905 static int
3906 test_snow3g_hash_generate_test_case_1(void)
3907 {
3908 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3909 }
3910 
3911 static int
3912 test_snow3g_hash_generate_test_case_2(void)
3913 {
3914 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3915 }
3916 
3917 static int
3918 test_snow3g_hash_generate_test_case_3(void)
3919 {
3920 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3921 }
3922 
3923 static int
3924 test_snow3g_hash_generate_test_case_4(void)
3925 {
3926 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3927 }
3928 
3929 static int
3930 test_snow3g_hash_generate_test_case_5(void)
3931 {
3932 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3933 }
3934 
3935 static int
3936 test_snow3g_hash_generate_test_case_6(void)
3937 {
3938 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3939 }
3940 
3941 static int
3942 test_snow3g_hash_verify_test_case_1(void)
3943 {
3944 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3945 
3946 }
3947 
3948 static int
3949 test_snow3g_hash_verify_test_case_2(void)
3950 {
3951 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3952 }
3953 
3954 static int
3955 test_snow3g_hash_verify_test_case_3(void)
3956 {
3957 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3958 }
3959 
3960 static int
3961 test_snow3g_hash_verify_test_case_4(void)
3962 {
3963 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3964 }
3965 
3966 static int
3967 test_snow3g_hash_verify_test_case_5(void)
3968 {
3969 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3970 }
3971 
3972 static int
3973 test_snow3g_hash_verify_test_case_6(void)
3974 {
3975 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3976 }
3977 
3978 static int
3979 test_kasumi_hash_generate_test_case_1(void)
3980 {
3981 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3982 }
3983 
3984 static int
3985 test_kasumi_hash_generate_test_case_2(void)
3986 {
3987 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3988 }
3989 
3990 static int
3991 test_kasumi_hash_generate_test_case_3(void)
3992 {
3993 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3994 }
3995 
3996 static int
3997 test_kasumi_hash_generate_test_case_4(void)
3998 {
3999 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
4000 }
4001 
4002 static int
4003 test_kasumi_hash_generate_test_case_5(void)
4004 {
4005 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
4006 }
4007 
4008 static int
4009 test_kasumi_hash_generate_test_case_6(void)
4010 {
4011 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
4012 }
4013 
4014 static int
4015 test_kasumi_hash_verify_test_case_1(void)
4016 {
4017 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
4018 }
4019 
4020 static int
4021 test_kasumi_hash_verify_test_case_2(void)
4022 {
4023 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
4024 }
4025 
4026 static int
4027 test_kasumi_hash_verify_test_case_3(void)
4028 {
4029 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
4030 }
4031 
4032 static int
4033 test_kasumi_hash_verify_test_case_4(void)
4034 {
4035 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
4036 }
4037 
4038 static int
4039 test_kasumi_hash_verify_test_case_5(void)
4040 {
4041 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
4042 }
4043 
4044 static int
4045 test_kasumi_encryption(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 	struct rte_cryptodev_info dev_info;
4055 
4056 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4057 	uint64_t feat_flags = dev_info.feature_flags;
4058 
4059 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4060 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4061 		printf("Device doesn't support RAW data-path APIs.\n");
4062 		return TEST_SKIPPED;
4063 	}
4064 
4065 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4066 		return TEST_SKIPPED;
4067 
4068 	/* Verify the capabilities */
4069 	struct rte_cryptodev_sym_capability_idx cap_idx;
4070 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4071 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4072 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4073 			&cap_idx) == NULL)
4074 		return TEST_SKIPPED;
4075 
4076 	/* Create KASUMI session */
4077 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4078 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4079 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4080 					tdata->key.data, tdata->key.len,
4081 					tdata->cipher_iv.len);
4082 	if (retval < 0)
4083 		return retval;
4084 
4085 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4086 
4087 	/* Clear mbuf payload */
4088 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4089 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4090 
4091 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4092 	/* Append data which is padded to a multiple */
4093 	/* of the algorithms block size */
4094 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4095 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4096 				plaintext_pad_len);
4097 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4098 
4099 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4100 
4101 	/* Create KASUMI operation */
4102 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4103 				tdata->cipher_iv.len,
4104 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4105 				tdata->validCipherOffsetInBits.len);
4106 	if (retval < 0)
4107 		return retval;
4108 
4109 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4110 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4111 					       tdata->cipher_iv.len);
4112 		if (retval != TEST_SUCCESS)
4113 			return retval;
4114 	} else
4115 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4116 				ut_params->op);
4117 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4118 
4119 	ut_params->obuf = ut_params->op->sym->m_dst;
4120 	if (ut_params->obuf)
4121 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4122 	else
4123 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4124 
4125 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4126 
4127 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4128 				(tdata->validCipherOffsetInBits.len >> 3);
4129 	/* Validate obuf */
4130 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4131 		ciphertext,
4132 		reference_ciphertext,
4133 		tdata->validCipherLenInBits.len,
4134 		"KASUMI Ciphertext data not as expected");
4135 	return 0;
4136 }
4137 
4138 static int
4139 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
4140 {
4141 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4142 	struct crypto_unittest_params *ut_params = &unittest_params;
4143 
4144 	int retval;
4145 
4146 	unsigned int plaintext_pad_len;
4147 	unsigned int plaintext_len;
4148 
4149 	uint8_t buffer[10000];
4150 	const uint8_t *ciphertext;
4151 
4152 	struct rte_cryptodev_info dev_info;
4153 
4154 	/* Verify the capabilities */
4155 	struct rte_cryptodev_sym_capability_idx cap_idx;
4156 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4157 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4158 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4159 			&cap_idx) == NULL)
4160 		return TEST_SKIPPED;
4161 
4162 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4163 
4164 	uint64_t feat_flags = dev_info.feature_flags;
4165 
4166 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4167 		printf("Device doesn't support in-place scatter-gather. "
4168 				"Test Skipped.\n");
4169 		return TEST_SKIPPED;
4170 	}
4171 
4172 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4173 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4174 		printf("Device doesn't support RAW data-path APIs.\n");
4175 		return TEST_SKIPPED;
4176 	}
4177 
4178 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4179 		return TEST_SKIPPED;
4180 
4181 	/* Create KASUMI session */
4182 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4183 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4184 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4185 					tdata->key.data, tdata->key.len,
4186 					tdata->cipher_iv.len);
4187 	if (retval < 0)
4188 		return retval;
4189 
4190 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4191 
4192 
4193 	/* Append data which is padded to a multiple */
4194 	/* of the algorithms block size */
4195 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4196 
4197 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4198 			plaintext_pad_len, 10, 0);
4199 
4200 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4201 
4202 	/* Create KASUMI operation */
4203 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4204 				tdata->cipher_iv.len,
4205 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4206 				tdata->validCipherOffsetInBits.len);
4207 	if (retval < 0)
4208 		return retval;
4209 
4210 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4211 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4212 					       tdata->cipher_iv.len);
4213 		if (retval != TEST_SUCCESS)
4214 			return retval;
4215 	} else
4216 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4217 						ut_params->op);
4218 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4219 
4220 	ut_params->obuf = ut_params->op->sym->m_dst;
4221 
4222 	if (ut_params->obuf)
4223 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4224 				plaintext_len, buffer);
4225 	else
4226 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4227 				tdata->validCipherOffsetInBits.len >> 3,
4228 				plaintext_len, buffer);
4229 
4230 	/* Validate obuf */
4231 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4232 
4233 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4234 				(tdata->validCipherOffsetInBits.len >> 3);
4235 	/* Validate obuf */
4236 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4237 		ciphertext,
4238 		reference_ciphertext,
4239 		tdata->validCipherLenInBits.len,
4240 		"KASUMI Ciphertext data not as expected");
4241 	return 0;
4242 }
4243 
4244 static int
4245 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4246 {
4247 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4248 	struct crypto_unittest_params *ut_params = &unittest_params;
4249 
4250 	int retval;
4251 	uint8_t *plaintext, *ciphertext;
4252 	unsigned plaintext_pad_len;
4253 	unsigned plaintext_len;
4254 
4255 	/* Verify the capabilities */
4256 	struct rte_cryptodev_sym_capability_idx cap_idx;
4257 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4258 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4259 	/* Data-path service does not support OOP */
4260 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4261 			&cap_idx) == NULL)
4262 		return TEST_SKIPPED;
4263 
4264 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4265 		return TEST_SKIPPED;
4266 
4267 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4268 		return TEST_SKIPPED;
4269 
4270 	/* Create KASUMI session */
4271 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4272 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4273 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4274 					tdata->key.data, tdata->key.len,
4275 					tdata->cipher_iv.len);
4276 	if (retval < 0)
4277 		return retval;
4278 
4279 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4280 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4281 
4282 	/* Clear mbuf payload */
4283 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4284 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4285 
4286 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4287 	/* Append data which is padded to a multiple */
4288 	/* of the algorithms block size */
4289 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4290 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4291 				plaintext_pad_len);
4292 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4293 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4294 
4295 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4296 
4297 	/* Create KASUMI operation */
4298 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4299 				tdata->cipher_iv.len,
4300 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4301 				tdata->validCipherOffsetInBits.len);
4302 	if (retval < 0)
4303 		return retval;
4304 
4305 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4306 						ut_params->op);
4307 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4308 
4309 	ut_params->obuf = ut_params->op->sym->m_dst;
4310 	if (ut_params->obuf)
4311 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4312 	else
4313 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4314 
4315 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4316 
4317 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4318 				(tdata->validCipherOffsetInBits.len >> 3);
4319 	/* Validate obuf */
4320 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4321 		ciphertext,
4322 		reference_ciphertext,
4323 		tdata->validCipherLenInBits.len,
4324 		"KASUMI Ciphertext data not as expected");
4325 	return 0;
4326 }
4327 
4328 static int
4329 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4330 {
4331 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4332 	struct crypto_unittest_params *ut_params = &unittest_params;
4333 
4334 	int retval;
4335 	unsigned int plaintext_pad_len;
4336 	unsigned int plaintext_len;
4337 
4338 	const uint8_t *ciphertext;
4339 	uint8_t buffer[2048];
4340 
4341 	struct rte_cryptodev_info dev_info;
4342 
4343 	/* Verify the capabilities */
4344 	struct rte_cryptodev_sym_capability_idx cap_idx;
4345 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4346 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4347 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4348 			&cap_idx) == NULL)
4349 		return TEST_SKIPPED;
4350 
4351 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4352 		return TEST_SKIPPED;
4353 
4354 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4355 		return TEST_SKIPPED;
4356 
4357 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4358 
4359 	uint64_t feat_flags = dev_info.feature_flags;
4360 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4361 		printf("Device doesn't support out-of-place scatter-gather "
4362 				"in both input and output mbufs. "
4363 				"Test Skipped.\n");
4364 		return TEST_SKIPPED;
4365 	}
4366 
4367 	/* Create KASUMI session */
4368 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4369 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4370 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4371 					tdata->key.data, tdata->key.len,
4372 					tdata->cipher_iv.len);
4373 	if (retval < 0)
4374 		return retval;
4375 
4376 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4377 	/* Append data which is padded to a multiple */
4378 	/* of the algorithms block size */
4379 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4380 
4381 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4382 			plaintext_pad_len, 10, 0);
4383 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4384 			plaintext_pad_len, 3, 0);
4385 
4386 	/* Append data which is padded to a multiple */
4387 	/* of the algorithms block size */
4388 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4389 
4390 	/* Create KASUMI operation */
4391 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4392 				tdata->cipher_iv.len,
4393 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4394 				tdata->validCipherOffsetInBits.len);
4395 	if (retval < 0)
4396 		return retval;
4397 
4398 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4399 						ut_params->op);
4400 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4401 
4402 	ut_params->obuf = ut_params->op->sym->m_dst;
4403 	if (ut_params->obuf)
4404 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4405 				plaintext_pad_len, buffer);
4406 	else
4407 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4408 				tdata->validCipherOffsetInBits.len >> 3,
4409 				plaintext_pad_len, buffer);
4410 
4411 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4412 				(tdata->validCipherOffsetInBits.len >> 3);
4413 	/* Validate obuf */
4414 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4415 		ciphertext,
4416 		reference_ciphertext,
4417 		tdata->validCipherLenInBits.len,
4418 		"KASUMI Ciphertext data not as expected");
4419 	return 0;
4420 }
4421 
4422 
4423 static int
4424 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4425 {
4426 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4427 	struct crypto_unittest_params *ut_params = &unittest_params;
4428 
4429 	int retval;
4430 	uint8_t *ciphertext, *plaintext;
4431 	unsigned ciphertext_pad_len;
4432 	unsigned ciphertext_len;
4433 
4434 	/* Verify the capabilities */
4435 	struct rte_cryptodev_sym_capability_idx cap_idx;
4436 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4437 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4438 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4439 			&cap_idx) == NULL)
4440 		return TEST_SKIPPED;
4441 
4442 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4443 		return TEST_SKIPPED;
4444 
4445 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4446 		return TEST_SKIPPED;
4447 
4448 	/* Create KASUMI session */
4449 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4450 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4451 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4452 					tdata->key.data, tdata->key.len,
4453 					tdata->cipher_iv.len);
4454 	if (retval < 0)
4455 		return retval;
4456 
4457 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4458 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4459 
4460 	/* Clear mbuf payload */
4461 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4462 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4463 
4464 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4465 	/* Append data which is padded to a multiple */
4466 	/* of the algorithms block size */
4467 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4468 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4469 				ciphertext_pad_len);
4470 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4471 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4472 
4473 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4474 
4475 	/* Create KASUMI operation */
4476 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4477 				tdata->cipher_iv.len,
4478 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4479 				tdata->validCipherOffsetInBits.len);
4480 	if (retval < 0)
4481 		return retval;
4482 
4483 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4484 						ut_params->op);
4485 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4486 
4487 	ut_params->obuf = ut_params->op->sym->m_dst;
4488 	if (ut_params->obuf)
4489 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4490 	else
4491 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4492 
4493 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4494 
4495 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4496 				(tdata->validCipherOffsetInBits.len >> 3);
4497 	/* Validate obuf */
4498 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4499 		plaintext,
4500 		reference_plaintext,
4501 		tdata->validCipherLenInBits.len,
4502 		"KASUMI Plaintext data not as expected");
4503 	return 0;
4504 }
4505 
4506 static int
4507 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4508 {
4509 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4510 	struct crypto_unittest_params *ut_params = &unittest_params;
4511 
4512 	int retval;
4513 	uint8_t *ciphertext, *plaintext;
4514 	unsigned ciphertext_pad_len;
4515 	unsigned ciphertext_len;
4516 	struct rte_cryptodev_info dev_info;
4517 
4518 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4519 	uint64_t feat_flags = dev_info.feature_flags;
4520 
4521 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4522 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4523 		printf("Device doesn't support RAW data-path APIs.\n");
4524 		return TEST_SKIPPED;
4525 	}
4526 
4527 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4528 		return TEST_SKIPPED;
4529 
4530 	/* Verify the capabilities */
4531 	struct rte_cryptodev_sym_capability_idx cap_idx;
4532 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4533 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4534 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4535 			&cap_idx) == NULL)
4536 		return TEST_SKIPPED;
4537 
4538 	/* Create KASUMI session */
4539 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4540 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4541 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4542 					tdata->key.data, tdata->key.len,
4543 					tdata->cipher_iv.len);
4544 	if (retval < 0)
4545 		return retval;
4546 
4547 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4548 
4549 	/* Clear mbuf payload */
4550 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4551 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4552 
4553 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4554 	/* Append data which is padded to a multiple */
4555 	/* of the algorithms block size */
4556 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4557 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4558 				ciphertext_pad_len);
4559 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4560 
4561 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4562 
4563 	/* Create KASUMI operation */
4564 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4565 			tdata->cipher_iv.len,
4566 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4567 			tdata->validCipherOffsetInBits.len);
4568 	if (retval < 0)
4569 		return retval;
4570 
4571 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4572 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4573 					       0);
4574 		if (retval != TEST_SUCCESS)
4575 			return retval;
4576 	} else
4577 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4578 						ut_params->op);
4579 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4580 
4581 	ut_params->obuf = ut_params->op->sym->m_dst;
4582 	if (ut_params->obuf)
4583 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4584 	else
4585 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4586 
4587 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4588 
4589 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4590 				(tdata->validCipherOffsetInBits.len >> 3);
4591 	/* Validate obuf */
4592 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4593 		plaintext,
4594 		reference_plaintext,
4595 		tdata->validCipherLenInBits.len,
4596 		"KASUMI Plaintext data not as expected");
4597 	return 0;
4598 }
4599 
4600 static int
4601 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4602 {
4603 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4604 	struct crypto_unittest_params *ut_params = &unittest_params;
4605 
4606 	int retval;
4607 	uint8_t *plaintext, *ciphertext;
4608 	unsigned plaintext_pad_len;
4609 	unsigned plaintext_len;
4610 	struct rte_cryptodev_info dev_info;
4611 
4612 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4613 	uint64_t feat_flags = dev_info.feature_flags;
4614 
4615 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4616 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4617 		printf("Device doesn't support RAW data-path APIs.\n");
4618 		return TEST_SKIPPED;
4619 	}
4620 
4621 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4622 		return TEST_SKIPPED;
4623 
4624 	/* Verify the capabilities */
4625 	struct rte_cryptodev_sym_capability_idx cap_idx;
4626 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4627 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4628 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4629 			&cap_idx) == NULL)
4630 		return TEST_SKIPPED;
4631 
4632 	/* Create SNOW 3G session */
4633 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4634 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4635 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4636 					tdata->key.data, tdata->key.len,
4637 					tdata->cipher_iv.len);
4638 	if (retval < 0)
4639 		return retval;
4640 
4641 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4642 
4643 	/* Clear mbuf payload */
4644 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4645 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4646 
4647 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4648 	/* Append data which is padded to a multiple of */
4649 	/* the algorithms block size */
4650 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4651 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4652 				plaintext_pad_len);
4653 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4654 
4655 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4656 
4657 	/* Create SNOW 3G operation */
4658 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4659 					tdata->cipher_iv.len,
4660 					tdata->validCipherLenInBits.len,
4661 					0);
4662 	if (retval < 0)
4663 		return retval;
4664 
4665 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4666 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4667 					       tdata->cipher_iv.len);
4668 		if (retval != TEST_SUCCESS)
4669 			return retval;
4670 	} else
4671 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4672 						ut_params->op);
4673 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4674 
4675 	ut_params->obuf = ut_params->op->sym->m_dst;
4676 	if (ut_params->obuf)
4677 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4678 	else
4679 		ciphertext = plaintext;
4680 
4681 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4682 
4683 	/* Validate obuf */
4684 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4685 		ciphertext,
4686 		tdata->ciphertext.data,
4687 		tdata->validDataLenInBits.len,
4688 		"SNOW 3G Ciphertext data not as expected");
4689 	return 0;
4690 }
4691 
4692 
4693 static int
4694 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4695 {
4696 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4697 	struct crypto_unittest_params *ut_params = &unittest_params;
4698 	uint8_t *plaintext, *ciphertext;
4699 
4700 	int retval;
4701 	unsigned plaintext_pad_len;
4702 	unsigned plaintext_len;
4703 	struct rte_cryptodev_info dev_info;
4704 
4705 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4706 	uint64_t feat_flags = dev_info.feature_flags;
4707 
4708 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4709 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4710 		printf("Device does not support RAW data-path APIs.\n");
4711 		return -ENOTSUP;
4712 	}
4713 
4714 	/* Verify the capabilities */
4715 	struct rte_cryptodev_sym_capability_idx cap_idx;
4716 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4717 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4718 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4719 			&cap_idx) == NULL)
4720 		return TEST_SKIPPED;
4721 
4722 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4723 		return TEST_SKIPPED;
4724 
4725 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4726 		return TEST_SKIPPED;
4727 
4728 	/* Create SNOW 3G session */
4729 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4730 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4731 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4732 					tdata->key.data, tdata->key.len,
4733 					tdata->cipher_iv.len);
4734 	if (retval < 0)
4735 		return retval;
4736 
4737 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4738 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4739 
4740 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4741 			"Failed to allocate input buffer in mempool");
4742 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4743 			"Failed to allocate output buffer in mempool");
4744 
4745 	/* Clear mbuf payload */
4746 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4747 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4748 
4749 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4750 	/* Append data which is padded to a multiple of */
4751 	/* the algorithms block size */
4752 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4753 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4754 				plaintext_pad_len);
4755 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4756 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4757 
4758 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4759 
4760 	/* Create SNOW 3G operation */
4761 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4762 					tdata->cipher_iv.len,
4763 					tdata->validCipherLenInBits.len,
4764 					0);
4765 	if (retval < 0)
4766 		return retval;
4767 
4768 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4769 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4770 					       tdata->cipher_iv.len);
4771 		if (retval != TEST_SUCCESS)
4772 			return retval;
4773 	} else
4774 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4775 						ut_params->op);
4776 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4777 
4778 	ut_params->obuf = ut_params->op->sym->m_dst;
4779 	if (ut_params->obuf)
4780 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4781 	else
4782 		ciphertext = plaintext;
4783 
4784 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4785 
4786 	/* Validate obuf */
4787 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4788 		ciphertext,
4789 		tdata->ciphertext.data,
4790 		tdata->validDataLenInBits.len,
4791 		"SNOW 3G Ciphertext data not as expected");
4792 	return 0;
4793 }
4794 
4795 static int
4796 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4797 		uint8_t sgl_in, uint8_t sgl_out)
4798 {
4799 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4800 	struct crypto_unittest_params *ut_params = &unittest_params;
4801 
4802 	int retval;
4803 	unsigned int plaintext_pad_len;
4804 	unsigned int plaintext_len;
4805 	uint8_t buffer[10000];
4806 	const uint8_t *ciphertext;
4807 
4808 	struct rte_cryptodev_info dev_info;
4809 
4810 	/* Verify the capabilities */
4811 	struct rte_cryptodev_sym_capability_idx cap_idx;
4812 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4813 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4814 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4815 			&cap_idx) == NULL)
4816 		return TEST_SKIPPED;
4817 
4818 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4819 		return TEST_SKIPPED;
4820 
4821 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4822 		return TEST_SKIPPED;
4823 
4824 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4825 
4826 	uint64_t feat_flags = dev_info.feature_flags;
4827 
4828 	if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4829 			|| ((!sgl_in && sgl_out) &&
4830 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4831 			|| ((sgl_in && !sgl_out) &&
4832 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4833 		printf("Device doesn't support out-of-place scatter gather type. "
4834 				"Test Skipped.\n");
4835 		return TEST_SKIPPED;
4836 	}
4837 
4838 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4839 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4840 		printf("Device does not support RAW data-path APIs.\n");
4841 		return -ENOTSUP;
4842 	}
4843 
4844 	/* Create SNOW 3G session */
4845 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4846 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4847 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4848 					tdata->key.data, tdata->key.len,
4849 					tdata->cipher_iv.len);
4850 	if (retval < 0)
4851 		return retval;
4852 
4853 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4854 	/* Append data which is padded to a multiple of */
4855 	/* the algorithms block size */
4856 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4857 
4858 	if (sgl_in)
4859 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4860 				plaintext_pad_len, 10, 0);
4861 	else {
4862 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4863 		rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4864 	}
4865 
4866 	if (sgl_out)
4867 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4868 				plaintext_pad_len, 3, 0);
4869 	else {
4870 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4871 		rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4872 	}
4873 
4874 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4875 			"Failed to allocate input buffer in mempool");
4876 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4877 			"Failed to allocate output buffer in mempool");
4878 
4879 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4880 
4881 	/* Create SNOW 3G operation */
4882 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4883 					tdata->cipher_iv.len,
4884 					tdata->validCipherLenInBits.len,
4885 					0);
4886 	if (retval < 0)
4887 		return retval;
4888 
4889 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4890 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4891 					       tdata->cipher_iv.len);
4892 		if (retval != TEST_SUCCESS)
4893 			return retval;
4894 	} else
4895 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4896 						ut_params->op);
4897 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4898 
4899 	ut_params->obuf = ut_params->op->sym->m_dst;
4900 	if (ut_params->obuf)
4901 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4902 				plaintext_len, buffer);
4903 	else
4904 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4905 				plaintext_len, buffer);
4906 
4907 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4908 
4909 	/* Validate obuf */
4910 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4911 		ciphertext,
4912 		tdata->ciphertext.data,
4913 		tdata->validDataLenInBits.len,
4914 		"SNOW 3G Ciphertext data not as expected");
4915 
4916 	return 0;
4917 }
4918 
4919 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4920 static void
4921 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4922 {
4923 	uint8_t curr_byte, prev_byte;
4924 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4925 	uint8_t lower_byte_mask = (1 << offset) - 1;
4926 	unsigned i;
4927 
4928 	prev_byte = buffer[0];
4929 	buffer[0] >>= offset;
4930 
4931 	for (i = 1; i < length_in_bytes; i++) {
4932 		curr_byte = buffer[i];
4933 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4934 				(curr_byte >> offset);
4935 		prev_byte = curr_byte;
4936 	}
4937 }
4938 
4939 static int
4940 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4941 {
4942 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4943 	struct crypto_unittest_params *ut_params = &unittest_params;
4944 	uint8_t *plaintext, *ciphertext;
4945 	int retval;
4946 	uint32_t plaintext_len;
4947 	uint32_t plaintext_pad_len;
4948 	uint8_t extra_offset = 4;
4949 	uint8_t *expected_ciphertext_shifted;
4950 	struct rte_cryptodev_info dev_info;
4951 
4952 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4953 	uint64_t feat_flags = dev_info.feature_flags;
4954 
4955 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4956 			((tdata->validDataLenInBits.len % 8) != 0)) {
4957 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4958 		return TEST_SKIPPED;
4959 	}
4960 
4961 	/* Verify the capabilities */
4962 	struct rte_cryptodev_sym_capability_idx cap_idx;
4963 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4964 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4965 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4966 			&cap_idx) == NULL)
4967 		return TEST_SKIPPED;
4968 
4969 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4970 		return TEST_SKIPPED;
4971 
4972 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4973 		return TEST_SKIPPED;
4974 
4975 	/* Create SNOW 3G session */
4976 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4977 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4978 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4979 					tdata->key.data, tdata->key.len,
4980 					tdata->cipher_iv.len);
4981 	if (retval < 0)
4982 		return retval;
4983 
4984 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4985 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4986 
4987 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4988 			"Failed to allocate input buffer in mempool");
4989 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4990 			"Failed to allocate output buffer in mempool");
4991 
4992 	/* Clear mbuf payload */
4993 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4994 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4995 
4996 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4997 	/*
4998 	 * Append data which is padded to a
4999 	 * multiple of the algorithms block size
5000 	 */
5001 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5002 
5003 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
5004 						plaintext_pad_len);
5005 
5006 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5007 
5008 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
5009 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
5010 
5011 #ifdef RTE_APP_TEST_DEBUG
5012 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
5013 #endif
5014 	/* Create SNOW 3G operation */
5015 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5016 					tdata->cipher_iv.len,
5017 					tdata->validCipherLenInBits.len,
5018 					extra_offset);
5019 	if (retval < 0)
5020 		return retval;
5021 
5022 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5023 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5024 					       tdata->cipher_iv.len);
5025 		if (retval != TEST_SUCCESS)
5026 			return retval;
5027 	} else
5028 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5029 						ut_params->op);
5030 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5031 
5032 	ut_params->obuf = ut_params->op->sym->m_dst;
5033 	if (ut_params->obuf)
5034 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5035 	else
5036 		ciphertext = plaintext;
5037 
5038 #ifdef RTE_APP_TEST_DEBUG
5039 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5040 #endif
5041 
5042 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
5043 
5044 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
5045 			"failed to reserve memory for ciphertext shifted\n");
5046 
5047 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
5048 			ceil_byte_length(tdata->ciphertext.len));
5049 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
5050 			extra_offset);
5051 	/* Validate obuf */
5052 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5053 		ciphertext,
5054 		expected_ciphertext_shifted,
5055 		tdata->validDataLenInBits.len,
5056 		extra_offset,
5057 		"SNOW 3G Ciphertext data not as expected");
5058 	return 0;
5059 }
5060 
5061 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
5062 {
5063 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5064 	struct crypto_unittest_params *ut_params = &unittest_params;
5065 
5066 	int retval;
5067 
5068 	uint8_t *plaintext, *ciphertext;
5069 	unsigned ciphertext_pad_len;
5070 	unsigned ciphertext_len;
5071 	struct rte_cryptodev_info dev_info;
5072 
5073 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5074 	uint64_t feat_flags = dev_info.feature_flags;
5075 
5076 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5077 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5078 		printf("Device doesn't support RAW data-path APIs.\n");
5079 		return TEST_SKIPPED;
5080 	}
5081 
5082 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5083 		return TEST_SKIPPED;
5084 
5085 	/* Verify the capabilities */
5086 	struct rte_cryptodev_sym_capability_idx cap_idx;
5087 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5088 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5089 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5090 			&cap_idx) == NULL)
5091 		return TEST_SKIPPED;
5092 
5093 	/* Create SNOW 3G session */
5094 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5095 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
5096 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5097 					tdata->key.data, tdata->key.len,
5098 					tdata->cipher_iv.len);
5099 	if (retval < 0)
5100 		return retval;
5101 
5102 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5103 
5104 	/* Clear mbuf payload */
5105 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5106 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5107 
5108 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5109 	/* Append data which is padded to a multiple of */
5110 	/* the algorithms block size */
5111 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5112 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5113 				ciphertext_pad_len);
5114 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5115 
5116 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5117 
5118 	/* Create SNOW 3G operation */
5119 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5120 					tdata->cipher_iv.len,
5121 					tdata->validCipherLenInBits.len,
5122 					tdata->cipher.offset_bits);
5123 	if (retval < 0)
5124 		return retval;
5125 
5126 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5127 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5128 					       tdata->cipher_iv.len);
5129 		if (retval != TEST_SUCCESS)
5130 			return retval;
5131 	} else
5132 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5133 						ut_params->op);
5134 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5135 	ut_params->obuf = ut_params->op->sym->m_dst;
5136 	if (ut_params->obuf)
5137 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5138 	else
5139 		plaintext = ciphertext;
5140 
5141 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5142 
5143 	/* Validate obuf */
5144 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5145 				tdata->plaintext.data,
5146 				tdata->validDataLenInBits.len,
5147 				"SNOW 3G Plaintext data not as expected");
5148 	return 0;
5149 }
5150 
5151 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
5152 {
5153 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5154 	struct crypto_unittest_params *ut_params = &unittest_params;
5155 
5156 	int retval;
5157 
5158 	uint8_t *plaintext, *ciphertext;
5159 	unsigned ciphertext_pad_len;
5160 	unsigned ciphertext_len;
5161 	struct rte_cryptodev_info dev_info;
5162 
5163 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5164 	uint64_t feat_flags = dev_info.feature_flags;
5165 
5166 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5167 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5168 		printf("Device does not support RAW data-path APIs.\n");
5169 		return -ENOTSUP;
5170 	}
5171 	/* Verify the capabilities */
5172 	struct rte_cryptodev_sym_capability_idx cap_idx;
5173 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5174 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5175 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5176 			&cap_idx) == NULL)
5177 		return TEST_SKIPPED;
5178 
5179 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5180 		return TEST_SKIPPED;
5181 
5182 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5183 		return TEST_SKIPPED;
5184 
5185 	/* Create SNOW 3G session */
5186 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5187 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
5188 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5189 					tdata->key.data, tdata->key.len,
5190 					tdata->cipher_iv.len);
5191 	if (retval < 0)
5192 		return retval;
5193 
5194 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5195 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5196 
5197 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5198 			"Failed to allocate input buffer");
5199 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
5200 			"Failed to allocate output buffer");
5201 
5202 	/* Clear mbuf payload */
5203 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5204 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5205 
5206 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5207 		       rte_pktmbuf_tailroom(ut_params->obuf));
5208 
5209 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5210 	/* Append data which is padded to a multiple of */
5211 	/* the algorithms block size */
5212 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5213 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5214 				ciphertext_pad_len);
5215 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5216 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5217 
5218 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5219 
5220 	/* Create SNOW 3G operation */
5221 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5222 					tdata->cipher_iv.len,
5223 					tdata->validCipherLenInBits.len,
5224 					0);
5225 	if (retval < 0)
5226 		return retval;
5227 
5228 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5229 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5230 					       tdata->cipher_iv.len);
5231 		if (retval != TEST_SUCCESS)
5232 			return retval;
5233 	} else
5234 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5235 						ut_params->op);
5236 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5237 	ut_params->obuf = ut_params->op->sym->m_dst;
5238 	if (ut_params->obuf)
5239 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5240 	else
5241 		plaintext = ciphertext;
5242 
5243 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5244 
5245 	/* Validate obuf */
5246 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
5247 				tdata->plaintext.data,
5248 				tdata->validDataLenInBits.len,
5249 				"SNOW 3G Plaintext data not as expected");
5250 	return 0;
5251 }
5252 
5253 static int
5254 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5255 {
5256 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5257 	struct crypto_unittest_params *ut_params = &unittest_params;
5258 
5259 	int retval;
5260 
5261 	uint8_t *plaintext, *ciphertext;
5262 	unsigned int plaintext_pad_len;
5263 	unsigned int plaintext_len;
5264 
5265 	struct rte_cryptodev_info dev_info;
5266 
5267 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5268 	uint64_t feat_flags = dev_info.feature_flags;
5269 
5270 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5271 			((tdata->validAuthLenInBits.len % 8 != 0) ||
5272 			(tdata->validDataLenInBits.len % 8 != 0))) {
5273 		printf("Device doesn't support NON-Byte Aligned Data.\n");
5274 		return TEST_SKIPPED;
5275 	}
5276 
5277 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5278 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5279 		printf("Device doesn't support RAW data-path APIs.\n");
5280 		return TEST_SKIPPED;
5281 	}
5282 
5283 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5284 		return TEST_SKIPPED;
5285 
5286 	/* Check if device supports ZUC EEA3 */
5287 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5288 			tdata->key.len, tdata->cipher_iv.len) < 0)
5289 		return TEST_SKIPPED;
5290 
5291 	/* Check if device supports ZUC EIA3 */
5292 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5293 			tdata->key.len, tdata->auth_iv.len,
5294 			tdata->digest.len) < 0)
5295 		return TEST_SKIPPED;
5296 
5297 	/* Create ZUC session */
5298 	retval = create_zuc_cipher_auth_encrypt_generate_session(
5299 			ts_params->valid_devs[0],
5300 			tdata);
5301 	if (retval != 0)
5302 		return retval;
5303 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5304 
5305 	/* clear mbuf payload */
5306 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5307 			rte_pktmbuf_tailroom(ut_params->ibuf));
5308 
5309 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5310 	/* Append data which is padded to a multiple of */
5311 	/* the algorithms block size */
5312 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5313 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5314 				plaintext_pad_len);
5315 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5316 
5317 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5318 
5319 	/* Create ZUC operation */
5320 	retval = create_zuc_cipher_hash_generate_operation(tdata);
5321 	if (retval < 0)
5322 		return retval;
5323 
5324 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5325 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5326 					       tdata->cipher_iv.len);
5327 		if (retval != TEST_SUCCESS)
5328 			return retval;
5329 	} else
5330 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5331 			ut_params->op);
5332 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5333 	ut_params->obuf = ut_params->op->sym->m_src;
5334 	if (ut_params->obuf)
5335 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5336 	else
5337 		ciphertext = plaintext;
5338 
5339 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5340 	/* Validate obuf */
5341 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5342 			ciphertext,
5343 			tdata->ciphertext.data,
5344 			tdata->validDataLenInBits.len,
5345 			"ZUC Ciphertext data not as expected");
5346 
5347 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5348 						    uint8_t *,
5349 						    plaintext_pad_len);
5350 
5351 	/* Validate obuf */
5352 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5353 			ut_params->digest,
5354 			tdata->digest.data,
5355 			tdata->digest.len,
5356 			"ZUC Generated auth tag not as expected");
5357 	return 0;
5358 }
5359 
5360 static int
5361 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5362 {
5363 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5364 	struct crypto_unittest_params *ut_params = &unittest_params;
5365 
5366 	int retval;
5367 
5368 	uint8_t *plaintext, *ciphertext;
5369 	unsigned plaintext_pad_len;
5370 	unsigned plaintext_len;
5371 	struct rte_cryptodev_info dev_info;
5372 
5373 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5374 	uint64_t feat_flags = dev_info.feature_flags;
5375 
5376 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5377 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5378 		printf("Device doesn't support RAW data-path APIs.\n");
5379 		return TEST_SKIPPED;
5380 	}
5381 
5382 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5383 		return TEST_SKIPPED;
5384 
5385 	/* Verify the capabilities */
5386 	struct rte_cryptodev_sym_capability_idx cap_idx;
5387 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5388 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5389 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5390 			&cap_idx) == NULL)
5391 		return TEST_SKIPPED;
5392 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5393 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5394 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5395 			&cap_idx) == NULL)
5396 		return TEST_SKIPPED;
5397 
5398 	/* Create SNOW 3G session */
5399 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5400 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5401 			RTE_CRYPTO_AUTH_OP_GENERATE,
5402 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5403 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5404 			tdata->key.data, tdata->key.len,
5405 			tdata->key.data, tdata->key.len,
5406 			tdata->auth_iv.len, tdata->digest.len,
5407 			tdata->cipher_iv.len);
5408 	if (retval != 0)
5409 		return retval;
5410 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5411 
5412 	/* clear mbuf payload */
5413 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5414 			rte_pktmbuf_tailroom(ut_params->ibuf));
5415 
5416 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5417 	/* Append data which is padded to a multiple of */
5418 	/* the algorithms block size */
5419 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5420 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5421 				plaintext_pad_len);
5422 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5423 
5424 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5425 
5426 	/* Create SNOW 3G operation */
5427 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5428 			tdata->digest.len, tdata->auth_iv.data,
5429 			tdata->auth_iv.len,
5430 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5431 			tdata->cipher_iv.data, tdata->cipher_iv.len,
5432 			tdata->validCipherLenInBits.len,
5433 			0,
5434 			tdata->validAuthLenInBits.len,
5435 			0
5436 			);
5437 	if (retval < 0)
5438 		return retval;
5439 
5440 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5441 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5442 					       tdata->cipher_iv.len);
5443 		if (retval != TEST_SUCCESS)
5444 			return retval;
5445 	} else
5446 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5447 			ut_params->op);
5448 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5449 	ut_params->obuf = ut_params->op->sym->m_src;
5450 	if (ut_params->obuf)
5451 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5452 	else
5453 		ciphertext = plaintext;
5454 
5455 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5456 	/* Validate obuf */
5457 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5458 			ciphertext,
5459 			tdata->ciphertext.data,
5460 			tdata->validDataLenInBits.len,
5461 			"SNOW 3G Ciphertext data not as expected");
5462 
5463 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5464 						    uint8_t *,
5465 						    plaintext_pad_len);
5466 
5467 	/* Validate obuf */
5468 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5469 			ut_params->digest,
5470 			tdata->digest.data,
5471 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5472 			"SNOW 3G Generated auth tag not as expected");
5473 	return 0;
5474 }
5475 
5476 static int
5477 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5478 	uint8_t op_mode, uint8_t verify)
5479 {
5480 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5481 	struct crypto_unittest_params *ut_params = &unittest_params;
5482 
5483 	int retval;
5484 
5485 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5486 	unsigned int plaintext_pad_len;
5487 	unsigned int plaintext_len;
5488 	unsigned int ciphertext_pad_len;
5489 	unsigned int ciphertext_len;
5490 	unsigned int digest_offset;
5491 
5492 	struct rte_cryptodev_info dev_info;
5493 
5494 	/* Verify the capabilities */
5495 	struct rte_cryptodev_sym_capability_idx cap_idx;
5496 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5497 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5498 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5499 			&cap_idx) == NULL)
5500 		return TEST_SKIPPED;
5501 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5502 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5503 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5504 			&cap_idx) == NULL)
5505 		return TEST_SKIPPED;
5506 
5507 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5508 		return TEST_SKIPPED;
5509 
5510 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5511 
5512 	uint64_t feat_flags = dev_info.feature_flags;
5513 
5514 	if (op_mode == OUT_OF_PLACE) {
5515 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5516 			printf("Device doesn't support digest encrypted.\n");
5517 			return TEST_SKIPPED;
5518 		}
5519 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5520 			return TEST_SKIPPED;
5521 	}
5522 
5523 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5524 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5525 		printf("Device doesn't support RAW data-path APIs.\n");
5526 		return TEST_SKIPPED;
5527 	}
5528 
5529 	/* Create SNOW 3G session */
5530 	retval = create_wireless_algo_auth_cipher_session(
5531 			ts_params->valid_devs[0],
5532 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5533 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5534 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5535 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5536 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5537 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5538 			tdata->key.data, tdata->key.len,
5539 			tdata->key.data, tdata->key.len,
5540 			tdata->auth_iv.len, tdata->digest.len,
5541 			tdata->cipher_iv.len);
5542 	if (retval != 0)
5543 		return retval;
5544 
5545 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5546 	if (op_mode == OUT_OF_PLACE)
5547 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5548 
5549 	/* clear mbuf payload */
5550 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5551 		rte_pktmbuf_tailroom(ut_params->ibuf));
5552 	if (op_mode == OUT_OF_PLACE)
5553 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5554 			rte_pktmbuf_tailroom(ut_params->obuf));
5555 
5556 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5557 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5558 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5559 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5560 
5561 	if (verify) {
5562 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5563 					ciphertext_pad_len);
5564 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5565 		if (op_mode == OUT_OF_PLACE)
5566 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5567 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5568 			ciphertext_len);
5569 	} else {
5570 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5571 					plaintext_pad_len);
5572 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5573 		if (op_mode == OUT_OF_PLACE)
5574 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5575 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5576 	}
5577 
5578 	/* Create SNOW 3G operation */
5579 	retval = create_wireless_algo_auth_cipher_operation(
5580 		tdata->digest.data, tdata->digest.len,
5581 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5582 		tdata->auth_iv.data, tdata->auth_iv.len,
5583 		(tdata->digest.offset_bytes == 0 ?
5584 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5585 			: tdata->digest.offset_bytes),
5586 		tdata->validCipherLenInBits.len,
5587 		tdata->cipher.offset_bits,
5588 		tdata->validAuthLenInBits.len,
5589 		tdata->auth.offset_bits,
5590 		op_mode, 0, verify);
5591 
5592 	if (retval < 0)
5593 		return retval;
5594 
5595 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5596 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5597 					       tdata->cipher_iv.len);
5598 		if (retval != TEST_SUCCESS)
5599 			return retval;
5600 	} else
5601 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5602 			ut_params->op);
5603 
5604 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5605 
5606 	ut_params->obuf = (op_mode == IN_PLACE ?
5607 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5608 
5609 	if (verify) {
5610 		if (ut_params->obuf)
5611 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5612 							uint8_t *);
5613 		else
5614 			plaintext = ciphertext +
5615 				(tdata->cipher.offset_bits >> 3);
5616 
5617 		debug_hexdump(stdout, "plaintext:", plaintext,
5618 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5619 		debug_hexdump(stdout, "plaintext expected:",
5620 			tdata->plaintext.data,
5621 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5622 	} else {
5623 		if (ut_params->obuf)
5624 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5625 							uint8_t *);
5626 		else
5627 			ciphertext = plaintext;
5628 
5629 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5630 			ciphertext_len);
5631 		debug_hexdump(stdout, "ciphertext expected:",
5632 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5633 
5634 		if (tdata->digest.offset_bytes == 0)
5635 			digest_offset = plaintext_pad_len;
5636 		else
5637 			digest_offset = tdata->digest.offset_bytes;
5638 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5639 						    uint8_t *, digest_offset);
5640 
5641 		debug_hexdump(stdout, "digest:", ut_params->digest,
5642 			tdata->digest.len);
5643 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5644 				tdata->digest.len);
5645 	}
5646 
5647 	/* Validate obuf */
5648 	if (verify) {
5649 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5650 			plaintext,
5651 			tdata->plaintext.data,
5652 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5653 			 (tdata->digest.len << 3)),
5654 			tdata->cipher.offset_bits,
5655 			"SNOW 3G Plaintext data not as expected");
5656 	} else {
5657 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5658 			ciphertext,
5659 			tdata->ciphertext.data,
5660 			(tdata->validDataLenInBits.len -
5661 			 tdata->cipher.offset_bits),
5662 			tdata->cipher.offset_bits,
5663 			"SNOW 3G Ciphertext data not as expected");
5664 
5665 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5666 			ut_params->digest,
5667 			tdata->digest.data,
5668 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5669 			"SNOW 3G Generated auth tag not as expected");
5670 	}
5671 	return 0;
5672 }
5673 
5674 static int
5675 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5676 	uint8_t op_mode, uint8_t verify)
5677 {
5678 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5679 	struct crypto_unittest_params *ut_params = &unittest_params;
5680 
5681 	int retval;
5682 
5683 	const uint8_t *plaintext = NULL;
5684 	const uint8_t *ciphertext = NULL;
5685 	const uint8_t *digest = NULL;
5686 	unsigned int plaintext_pad_len;
5687 	unsigned int plaintext_len;
5688 	unsigned int ciphertext_pad_len;
5689 	unsigned int ciphertext_len;
5690 	uint8_t buffer[10000];
5691 	uint8_t digest_buffer[10000];
5692 
5693 	struct rte_cryptodev_info dev_info;
5694 
5695 	/* Verify the capabilities */
5696 	struct rte_cryptodev_sym_capability_idx cap_idx;
5697 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5698 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5699 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5700 			&cap_idx) == NULL)
5701 		return TEST_SKIPPED;
5702 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5703 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5704 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5705 			&cap_idx) == NULL)
5706 		return TEST_SKIPPED;
5707 
5708 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5709 		return TEST_SKIPPED;
5710 
5711 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5712 
5713 	uint64_t feat_flags = dev_info.feature_flags;
5714 
5715 	if (op_mode == IN_PLACE) {
5716 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5717 			printf("Device doesn't support in-place scatter-gather "
5718 					"in both input and output mbufs.\n");
5719 			return TEST_SKIPPED;
5720 		}
5721 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5722 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5723 			printf("Device doesn't support RAW data-path APIs.\n");
5724 			return TEST_SKIPPED;
5725 		}
5726 	} else {
5727 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5728 			return TEST_SKIPPED;
5729 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5730 			printf("Device doesn't support out-of-place scatter-gather "
5731 					"in both input and output mbufs.\n");
5732 			return TEST_SKIPPED;
5733 		}
5734 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5735 			printf("Device doesn't support digest encrypted.\n");
5736 			return TEST_SKIPPED;
5737 		}
5738 	}
5739 
5740 	/* Create SNOW 3G session */
5741 	retval = create_wireless_algo_auth_cipher_session(
5742 			ts_params->valid_devs[0],
5743 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5744 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5745 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5746 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5747 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5748 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5749 			tdata->key.data, tdata->key.len,
5750 			tdata->key.data, tdata->key.len,
5751 			tdata->auth_iv.len, tdata->digest.len,
5752 			tdata->cipher_iv.len);
5753 
5754 	if (retval != 0)
5755 		return retval;
5756 
5757 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5758 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5759 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5760 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5761 
5762 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5763 			plaintext_pad_len, 15, 0);
5764 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5765 			"Failed to allocate input buffer in mempool");
5766 
5767 	if (op_mode == OUT_OF_PLACE) {
5768 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5769 				plaintext_pad_len, 15, 0);
5770 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5771 				"Failed to allocate output buffer in mempool");
5772 	}
5773 
5774 	if (verify) {
5775 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5776 			tdata->ciphertext.data);
5777 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5778 					ciphertext_len, buffer);
5779 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5780 			ciphertext_len);
5781 	} else {
5782 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5783 			tdata->plaintext.data);
5784 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5785 					plaintext_len, buffer);
5786 		debug_hexdump(stdout, "plaintext:", plaintext,
5787 			plaintext_len);
5788 	}
5789 	memset(buffer, 0, sizeof(buffer));
5790 
5791 	/* Create SNOW 3G operation */
5792 	retval = create_wireless_algo_auth_cipher_operation(
5793 		tdata->digest.data, tdata->digest.len,
5794 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5795 		tdata->auth_iv.data, tdata->auth_iv.len,
5796 		(tdata->digest.offset_bytes == 0 ?
5797 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5798 			: tdata->digest.offset_bytes),
5799 		tdata->validCipherLenInBits.len,
5800 		tdata->cipher.offset_bits,
5801 		tdata->validAuthLenInBits.len,
5802 		tdata->auth.offset_bits,
5803 		op_mode, 1, verify);
5804 
5805 	if (retval < 0)
5806 		return retval;
5807 
5808 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5809 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5810 					       tdata->cipher_iv.len);
5811 		if (retval != TEST_SUCCESS)
5812 			return retval;
5813 	} else
5814 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5815 			ut_params->op);
5816 
5817 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5818 
5819 	ut_params->obuf = (op_mode == IN_PLACE ?
5820 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5821 
5822 	if (verify) {
5823 		if (ut_params->obuf)
5824 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5825 					plaintext_len, buffer);
5826 		else
5827 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5828 					plaintext_len, buffer);
5829 
5830 		debug_hexdump(stdout, "plaintext:", plaintext,
5831 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5832 		debug_hexdump(stdout, "plaintext expected:",
5833 			tdata->plaintext.data,
5834 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5835 	} else {
5836 		if (ut_params->obuf)
5837 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5838 					ciphertext_len, buffer);
5839 		else
5840 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5841 					ciphertext_len, buffer);
5842 
5843 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5844 			ciphertext_len);
5845 		debug_hexdump(stdout, "ciphertext expected:",
5846 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5847 
5848 		if (ut_params->obuf)
5849 			digest = rte_pktmbuf_read(ut_params->obuf,
5850 				(tdata->digest.offset_bytes == 0 ?
5851 				plaintext_pad_len : tdata->digest.offset_bytes),
5852 				tdata->digest.len, digest_buffer);
5853 		else
5854 			digest = rte_pktmbuf_read(ut_params->ibuf,
5855 				(tdata->digest.offset_bytes == 0 ?
5856 				plaintext_pad_len : tdata->digest.offset_bytes),
5857 				tdata->digest.len, digest_buffer);
5858 
5859 		debug_hexdump(stdout, "digest:", 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_OFFSET(
5868 			plaintext,
5869 			tdata->plaintext.data,
5870 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5871 			 (tdata->digest.len << 3)),
5872 			tdata->cipher.offset_bits,
5873 			"SNOW 3G Plaintext data not as expected");
5874 	} else {
5875 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5876 			ciphertext,
5877 			tdata->ciphertext.data,
5878 			(tdata->validDataLenInBits.len -
5879 			 tdata->cipher.offset_bits),
5880 			tdata->cipher.offset_bits,
5881 			"SNOW 3G Ciphertext data not as expected");
5882 
5883 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5884 			digest,
5885 			tdata->digest.data,
5886 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5887 			"SNOW 3G Generated auth tag not as expected");
5888 	}
5889 	return 0;
5890 }
5891 
5892 static int
5893 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5894 	uint8_t op_mode, uint8_t verify)
5895 {
5896 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5897 	struct crypto_unittest_params *ut_params = &unittest_params;
5898 
5899 	int retval;
5900 
5901 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5902 	unsigned int plaintext_pad_len;
5903 	unsigned int plaintext_len;
5904 	unsigned int ciphertext_pad_len;
5905 	unsigned int ciphertext_len;
5906 	unsigned int digest_offset;
5907 
5908 	struct rte_cryptodev_info dev_info;
5909 
5910 	/* Verify the capabilities */
5911 	struct rte_cryptodev_sym_capability_idx cap_idx;
5912 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5913 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5914 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5915 			&cap_idx) == NULL)
5916 		return TEST_SKIPPED;
5917 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5918 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5919 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5920 			&cap_idx) == NULL)
5921 		return TEST_SKIPPED;
5922 
5923 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5924 
5925 	uint64_t feat_flags = dev_info.feature_flags;
5926 
5927 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5928 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5929 		printf("Device doesn't support RAW data-path APIs.\n");
5930 		return TEST_SKIPPED;
5931 	}
5932 
5933 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5934 		return TEST_SKIPPED;
5935 
5936 	if (op_mode == OUT_OF_PLACE) {
5937 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5938 			return TEST_SKIPPED;
5939 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5940 			printf("Device doesn't support digest encrypted.\n");
5941 			return TEST_SKIPPED;
5942 		}
5943 	}
5944 
5945 	/* Create KASUMI session */
5946 	retval = create_wireless_algo_auth_cipher_session(
5947 			ts_params->valid_devs[0],
5948 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5949 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5950 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5951 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5952 			RTE_CRYPTO_AUTH_KASUMI_F9,
5953 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5954 			tdata->key.data, tdata->key.len,
5955 			tdata->key.data, tdata->key.len,
5956 			0, tdata->digest.len,
5957 			tdata->cipher_iv.len);
5958 
5959 	if (retval != 0)
5960 		return retval;
5961 
5962 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5963 	if (op_mode == OUT_OF_PLACE)
5964 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5965 
5966 	/* clear mbuf payload */
5967 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5968 		rte_pktmbuf_tailroom(ut_params->ibuf));
5969 	if (op_mode == OUT_OF_PLACE)
5970 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5971 			rte_pktmbuf_tailroom(ut_params->obuf));
5972 
5973 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5974 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5975 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5976 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5977 
5978 	if (verify) {
5979 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5980 					ciphertext_pad_len);
5981 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5982 		if (op_mode == OUT_OF_PLACE)
5983 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5984 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5985 			ciphertext_len);
5986 	} else {
5987 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5988 					plaintext_pad_len);
5989 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5990 		if (op_mode == OUT_OF_PLACE)
5991 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5992 		debug_hexdump(stdout, "plaintext:", plaintext,
5993 			plaintext_len);
5994 	}
5995 
5996 	/* Create KASUMI operation */
5997 	retval = create_wireless_algo_auth_cipher_operation(
5998 		tdata->digest.data, tdata->digest.len,
5999 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6000 		NULL, 0,
6001 		(tdata->digest.offset_bytes == 0 ?
6002 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6003 			: tdata->digest.offset_bytes),
6004 		tdata->validCipherLenInBits.len,
6005 		tdata->validCipherOffsetInBits.len,
6006 		tdata->validAuthLenInBits.len,
6007 		0,
6008 		op_mode, 0, verify);
6009 
6010 	if (retval < 0)
6011 		return retval;
6012 
6013 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6014 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6015 					       tdata->cipher_iv.len);
6016 		if (retval != TEST_SUCCESS)
6017 			return retval;
6018 	} else
6019 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6020 			ut_params->op);
6021 
6022 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6023 
6024 	ut_params->obuf = (op_mode == IN_PLACE ?
6025 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6026 
6027 
6028 	if (verify) {
6029 		if (ut_params->obuf)
6030 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6031 							uint8_t *);
6032 		else
6033 			plaintext = ciphertext;
6034 
6035 		debug_hexdump(stdout, "plaintext:", plaintext,
6036 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6037 		debug_hexdump(stdout, "plaintext expected:",
6038 			tdata->plaintext.data,
6039 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6040 	} else {
6041 		if (ut_params->obuf)
6042 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6043 							uint8_t *);
6044 		else
6045 			ciphertext = plaintext;
6046 
6047 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6048 			ciphertext_len);
6049 		debug_hexdump(stdout, "ciphertext expected:",
6050 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6051 
6052 		if (tdata->digest.offset_bytes == 0)
6053 			digest_offset = plaintext_pad_len;
6054 		else
6055 			digest_offset = tdata->digest.offset_bytes;
6056 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6057 						    uint8_t *, digest_offset);
6058 
6059 		debug_hexdump(stdout, "digest:", ut_params->digest,
6060 			tdata->digest.len);
6061 		debug_hexdump(stdout, "digest expected:",
6062 			tdata->digest.data, tdata->digest.len);
6063 	}
6064 
6065 	/* Validate obuf */
6066 	if (verify) {
6067 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6068 			plaintext,
6069 			tdata->plaintext.data,
6070 			tdata->plaintext.len >> 3,
6071 			"KASUMI Plaintext data not as expected");
6072 	} else {
6073 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6074 			ciphertext,
6075 			tdata->ciphertext.data,
6076 			tdata->ciphertext.len >> 3,
6077 			"KASUMI Ciphertext data not as expected");
6078 
6079 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6080 			ut_params->digest,
6081 			tdata->digest.data,
6082 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6083 			"KASUMI Generated auth tag not as expected");
6084 	}
6085 	return 0;
6086 }
6087 
6088 static int
6089 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
6090 	uint8_t op_mode, uint8_t verify)
6091 {
6092 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6093 	struct crypto_unittest_params *ut_params = &unittest_params;
6094 
6095 	int retval;
6096 
6097 	const uint8_t *plaintext = NULL;
6098 	const uint8_t *ciphertext = NULL;
6099 	const uint8_t *digest = NULL;
6100 	unsigned int plaintext_pad_len;
6101 	unsigned int plaintext_len;
6102 	unsigned int ciphertext_pad_len;
6103 	unsigned int ciphertext_len;
6104 	uint8_t buffer[10000];
6105 	uint8_t digest_buffer[10000];
6106 
6107 	struct rte_cryptodev_info dev_info;
6108 
6109 	/* Verify the capabilities */
6110 	struct rte_cryptodev_sym_capability_idx cap_idx;
6111 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6112 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6113 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6114 			&cap_idx) == NULL)
6115 		return TEST_SKIPPED;
6116 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6117 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6118 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6119 			&cap_idx) == NULL)
6120 		return TEST_SKIPPED;
6121 
6122 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6123 		return TEST_SKIPPED;
6124 
6125 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6126 
6127 	uint64_t feat_flags = dev_info.feature_flags;
6128 
6129 	if (op_mode == IN_PLACE) {
6130 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6131 			printf("Device doesn't support in-place scatter-gather "
6132 					"in both input and output mbufs.\n");
6133 			return TEST_SKIPPED;
6134 		}
6135 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6136 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6137 			printf("Device doesn't support RAW data-path APIs.\n");
6138 			return TEST_SKIPPED;
6139 		}
6140 	} else {
6141 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6142 			return TEST_SKIPPED;
6143 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6144 			printf("Device doesn't support out-of-place scatter-gather "
6145 					"in both input and output mbufs.\n");
6146 			return TEST_SKIPPED;
6147 		}
6148 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6149 			printf("Device doesn't support digest encrypted.\n");
6150 			return TEST_SKIPPED;
6151 		}
6152 	}
6153 
6154 	/* Create KASUMI session */
6155 	retval = create_wireless_algo_auth_cipher_session(
6156 			ts_params->valid_devs[0],
6157 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6158 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6159 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6160 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6161 			RTE_CRYPTO_AUTH_KASUMI_F9,
6162 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6163 			tdata->key.data, tdata->key.len,
6164 			tdata->key.data, tdata->key.len,
6165 			0, tdata->digest.len,
6166 			tdata->cipher_iv.len);
6167 
6168 	if (retval != 0)
6169 		return retval;
6170 
6171 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6172 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6173 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6174 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6175 
6176 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6177 			plaintext_pad_len, 15, 0);
6178 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6179 			"Failed to allocate input buffer in mempool");
6180 
6181 	if (op_mode == OUT_OF_PLACE) {
6182 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6183 				plaintext_pad_len, 15, 0);
6184 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6185 				"Failed to allocate output buffer in mempool");
6186 	}
6187 
6188 	if (verify) {
6189 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6190 			tdata->ciphertext.data);
6191 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6192 					ciphertext_len, buffer);
6193 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6194 			ciphertext_len);
6195 	} else {
6196 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6197 			tdata->plaintext.data);
6198 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6199 					plaintext_len, buffer);
6200 		debug_hexdump(stdout, "plaintext:", plaintext,
6201 			plaintext_len);
6202 	}
6203 	memset(buffer, 0, sizeof(buffer));
6204 
6205 	/* Create KASUMI operation */
6206 	retval = create_wireless_algo_auth_cipher_operation(
6207 		tdata->digest.data, tdata->digest.len,
6208 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6209 		NULL, 0,
6210 		(tdata->digest.offset_bytes == 0 ?
6211 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6212 			: tdata->digest.offset_bytes),
6213 		tdata->validCipherLenInBits.len,
6214 		tdata->validCipherOffsetInBits.len,
6215 		tdata->validAuthLenInBits.len,
6216 		0,
6217 		op_mode, 1, verify);
6218 
6219 	if (retval < 0)
6220 		return retval;
6221 
6222 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6223 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6224 					       tdata->cipher_iv.len);
6225 		if (retval != TEST_SUCCESS)
6226 			return retval;
6227 	} else
6228 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6229 			ut_params->op);
6230 
6231 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6232 
6233 	ut_params->obuf = (op_mode == IN_PLACE ?
6234 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6235 
6236 	if (verify) {
6237 		if (ut_params->obuf)
6238 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6239 					plaintext_len, buffer);
6240 		else
6241 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6242 					plaintext_len, buffer);
6243 
6244 		debug_hexdump(stdout, "plaintext:", plaintext,
6245 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6246 		debug_hexdump(stdout, "plaintext expected:",
6247 			tdata->plaintext.data,
6248 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6249 	} else {
6250 		if (ut_params->obuf)
6251 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6252 					ciphertext_len, buffer);
6253 		else
6254 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6255 					ciphertext_len, buffer);
6256 
6257 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6258 			ciphertext_len);
6259 		debug_hexdump(stdout, "ciphertext expected:",
6260 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6261 
6262 		if (ut_params->obuf)
6263 			digest = rte_pktmbuf_read(ut_params->obuf,
6264 				(tdata->digest.offset_bytes == 0 ?
6265 				plaintext_pad_len : tdata->digest.offset_bytes),
6266 				tdata->digest.len, digest_buffer);
6267 		else
6268 			digest = rte_pktmbuf_read(ut_params->ibuf,
6269 				(tdata->digest.offset_bytes == 0 ?
6270 				plaintext_pad_len : tdata->digest.offset_bytes),
6271 				tdata->digest.len, digest_buffer);
6272 
6273 		debug_hexdump(stdout, "digest:", digest,
6274 			tdata->digest.len);
6275 		debug_hexdump(stdout, "digest expected:",
6276 			tdata->digest.data, tdata->digest.len);
6277 	}
6278 
6279 	/* Validate obuf */
6280 	if (verify) {
6281 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6282 			plaintext,
6283 			tdata->plaintext.data,
6284 			tdata->plaintext.len >> 3,
6285 			"KASUMI Plaintext data not as expected");
6286 	} else {
6287 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6288 			ciphertext,
6289 			tdata->ciphertext.data,
6290 			tdata->validDataLenInBits.len,
6291 			"KASUMI Ciphertext data not as expected");
6292 
6293 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6294 			digest,
6295 			tdata->digest.data,
6296 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6297 			"KASUMI Generated auth tag not as expected");
6298 	}
6299 	return 0;
6300 }
6301 
6302 static int
6303 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6304 {
6305 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6306 	struct crypto_unittest_params *ut_params = &unittest_params;
6307 
6308 	int retval;
6309 
6310 	uint8_t *plaintext, *ciphertext;
6311 	unsigned plaintext_pad_len;
6312 	unsigned plaintext_len;
6313 	struct rte_cryptodev_info dev_info;
6314 
6315 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6316 	uint64_t feat_flags = dev_info.feature_flags;
6317 
6318 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6319 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6320 		printf("Device doesn't support RAW data-path APIs.\n");
6321 		return TEST_SKIPPED;
6322 	}
6323 
6324 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6325 		return TEST_SKIPPED;
6326 
6327 	/* Verify the capabilities */
6328 	struct rte_cryptodev_sym_capability_idx cap_idx;
6329 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6330 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6331 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6332 			&cap_idx) == NULL)
6333 		return TEST_SKIPPED;
6334 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6335 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6336 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6337 			&cap_idx) == NULL)
6338 		return TEST_SKIPPED;
6339 
6340 	/* Create KASUMI session */
6341 	retval = create_wireless_algo_cipher_auth_session(
6342 			ts_params->valid_devs[0],
6343 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6344 			RTE_CRYPTO_AUTH_OP_GENERATE,
6345 			RTE_CRYPTO_AUTH_KASUMI_F9,
6346 			RTE_CRYPTO_CIPHER_KASUMI_F8,
6347 			tdata->key.data, tdata->key.len,
6348 			tdata->key.data, tdata->key.len,
6349 			0, tdata->digest.len,
6350 			tdata->cipher_iv.len);
6351 	if (retval != 0)
6352 		return retval;
6353 
6354 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6355 
6356 	/* clear mbuf payload */
6357 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6358 			rte_pktmbuf_tailroom(ut_params->ibuf));
6359 
6360 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6361 	/* Append data which is padded to a multiple of */
6362 	/* the algorithms block size */
6363 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6364 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6365 				plaintext_pad_len);
6366 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6367 
6368 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6369 
6370 	/* Create KASUMI operation */
6371 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6372 				tdata->digest.len, NULL, 0,
6373 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6374 				tdata->cipher_iv.data, tdata->cipher_iv.len,
6375 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6376 				tdata->validCipherOffsetInBits.len,
6377 				tdata->validAuthLenInBits.len,
6378 				0
6379 				);
6380 	if (retval < 0)
6381 		return retval;
6382 
6383 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6384 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6385 					       tdata->cipher_iv.len);
6386 		if (retval != TEST_SUCCESS)
6387 			return retval;
6388 	} else
6389 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6390 			ut_params->op);
6391 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6392 
6393 	if (ut_params->op->sym->m_dst)
6394 		ut_params->obuf = ut_params->op->sym->m_dst;
6395 	else
6396 		ut_params->obuf = ut_params->op->sym->m_src;
6397 
6398 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6399 				tdata->validCipherOffsetInBits.len >> 3);
6400 
6401 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6402 						    uint8_t *,
6403 						    plaintext_pad_len);
6404 
6405 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6406 				(tdata->validCipherOffsetInBits.len >> 3);
6407 	/* Validate obuf */
6408 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6409 		ciphertext,
6410 		reference_ciphertext,
6411 		tdata->validCipherLenInBits.len,
6412 		"KASUMI Ciphertext data not as expected");
6413 
6414 	/* Validate obuf */
6415 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6416 		ut_params->digest,
6417 		tdata->digest.data,
6418 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6419 		"KASUMI Generated auth tag not as expected");
6420 	return 0;
6421 }
6422 
6423 static int
6424 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6425 			const enum rte_crypto_cipher_algorithm cipher_algo,
6426 			const uint16_t key_size, const uint16_t iv_size)
6427 {
6428 	struct rte_cryptodev_sym_capability_idx cap_idx;
6429 	const struct rte_cryptodev_symmetric_capability *cap;
6430 
6431 	/* Check if device supports the algorithm */
6432 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6433 	cap_idx.algo.cipher = cipher_algo;
6434 
6435 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6436 			&cap_idx);
6437 
6438 	if (cap == NULL)
6439 		return -1;
6440 
6441 	/* Check if device supports key size and IV size */
6442 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6443 			iv_size) < 0) {
6444 		return -1;
6445 	}
6446 
6447 	return 0;
6448 }
6449 
6450 static int
6451 check_auth_capability(const struct crypto_testsuite_params *ts_params,
6452 			const enum rte_crypto_auth_algorithm auth_algo,
6453 			const uint16_t key_size, const uint16_t iv_size,
6454 			const uint16_t tag_size)
6455 {
6456 	struct rte_cryptodev_sym_capability_idx cap_idx;
6457 	const struct rte_cryptodev_symmetric_capability *cap;
6458 
6459 	/* Check if device supports the algorithm */
6460 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6461 	cap_idx.algo.auth = auth_algo;
6462 
6463 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6464 			&cap_idx);
6465 
6466 	if (cap == NULL)
6467 		return -1;
6468 
6469 	/* Check if device supports key size and IV size */
6470 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6471 			tag_size, iv_size) < 0) {
6472 		return -1;
6473 	}
6474 
6475 	return 0;
6476 }
6477 
6478 static int
6479 test_zuc_cipher(const struct wireless_test_data *tdata,
6480 		enum rte_crypto_cipher_operation direction)
6481 {
6482 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6483 	struct crypto_unittest_params *ut_params = &unittest_params;
6484 
6485 	int retval;
6486 	uint8_t *plaintext = NULL;
6487 	uint8_t *ciphertext = NULL;
6488 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6489 	unsigned int plaintext_len = 0;
6490 	unsigned int ciphertext_len = 0;
6491 	struct rte_cryptodev_info dev_info;
6492 
6493 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6494 	uint64_t feat_flags = dev_info.feature_flags;
6495 
6496 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6497 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6498 		printf("Device doesn't support RAW data-path APIs.\n");
6499 		return TEST_SKIPPED;
6500 	}
6501 
6502 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6503 		return TEST_SKIPPED;
6504 
6505 	/* Check if device supports ZUC EEA3 */
6506 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6507 			tdata->key.len, tdata->cipher_iv.len) < 0)
6508 		return TEST_SKIPPED;
6509 
6510 	/* Create ZUC session */
6511 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6512 					direction,
6513 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
6514 					tdata->key.data, tdata->key.len,
6515 					tdata->cipher_iv.len);
6516 	if (retval != 0)
6517 		return retval;
6518 
6519 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6520 
6521 	/* Clear mbuf payload */
6522 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6523 	       rte_pktmbuf_tailroom(ut_params->ibuf));
6524 
6525 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6526 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6527 		/* Append data which is padded to a multiple */
6528 		/* of the algorithms block size */
6529 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6530 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6531 				plaintext_pad_len);
6532 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6533 
6534 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6535 	} else {
6536 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6537 		/* Append data which is padded to a multiple */
6538 		/* of the algorithms block size */
6539 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6540 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6541 				ciphertext_pad_len);
6542 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6543 
6544 		debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6545 	}
6546 
6547 	/* Create ZUC operation */
6548 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6549 					tdata->cipher_iv.len,
6550 					tdata->plaintext.len,
6551 					tdata->validCipherOffsetInBits.len);
6552 	if (retval < 0)
6553 		return retval;
6554 
6555 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6556 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6557 					       tdata->cipher_iv.len);
6558 		if (retval != TEST_SUCCESS)
6559 			return retval;
6560 	} else
6561 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6562 						ut_params->op);
6563 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6564 
6565 	ut_params->obuf = ut_params->op->sym->m_dst;
6566 
6567 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6568 		if (ut_params->obuf)
6569 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6570 		else
6571 			ciphertext = plaintext;
6572 
6573 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6574 
6575 		/* Validate obuf */
6576 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6577 				ciphertext,
6578 				tdata->ciphertext.data,
6579 				tdata->validCipherLenInBits.len,
6580 				"ZUC Ciphertext data not as expected");
6581 	} else {
6582 		if (ut_params->obuf)
6583 			plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6584 		else
6585 			plaintext = ciphertext;
6586 
6587 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6588 
6589 		const uint8_t *reference_plaintext = tdata->plaintext.data +
6590 				(tdata->validCipherOffsetInBits.len >> 3);
6591 
6592 		/* Validate obuf */
6593 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6594 				plaintext,
6595 				reference_plaintext,
6596 				tdata->validCipherLenInBits.len,
6597 				"ZUC Plaintext data not as expected");
6598 	}
6599 
6600 	return 0;
6601 }
6602 
6603 static int
6604 test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6605 		enum rte_crypto_cipher_operation direction)
6606 {
6607 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6608 	struct crypto_unittest_params *ut_params = &unittest_params;
6609 
6610 	int retval;
6611 
6612 	unsigned int plaintext_pad_len, ciphertext_pad_len;
6613 	unsigned int plaintext_len = 0;
6614 	unsigned int ciphertext_len = 0;
6615 	const uint8_t *ciphertext, *plaintext;
6616 	uint8_t buffer[2048];
6617 	struct rte_cryptodev_info dev_info;
6618 
6619 	/* Check if device supports ZUC EEA3 */
6620 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6621 			tdata->key.len, tdata->cipher_iv.len) < 0)
6622 		return TEST_SKIPPED;
6623 
6624 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6625 		return TEST_SKIPPED;
6626 
6627 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6628 
6629 	uint64_t feat_flags = dev_info.feature_flags;
6630 
6631 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6632 		printf("Device doesn't support in-place scatter-gather. "
6633 				"Test Skipped.\n");
6634 		return TEST_SKIPPED;
6635 	}
6636 
6637 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6638 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6639 		printf("Device doesn't support RAW data-path APIs.\n");
6640 		return TEST_SKIPPED;
6641 	}
6642 
6643 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6644 		plaintext_len = ceil_byte_length(tdata->plaintext.len);
6645 
6646 		/* Append data which is padded to a multiple */
6647 		/* of the algorithms block size */
6648 		plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6649 
6650 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6651 				plaintext_pad_len, 10, 0);
6652 
6653 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6654 				tdata->plaintext.data);
6655 	} else {
6656 		ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6657 
6658 		/* Append data which is padded to a multiple */
6659 		/* of the algorithms block size */
6660 		ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6661 
6662 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6663 				ciphertext_pad_len, 10, 0);
6664 
6665 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6666 				tdata->ciphertext.data);
6667 
6668 	}
6669 
6670 	/* Create ZUC session */
6671 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6672 			direction,
6673 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6674 			tdata->key.data, tdata->key.len,
6675 			tdata->cipher_iv.len);
6676 	if (retval < 0)
6677 		return retval;
6678 
6679 	/* Clear mbuf payload */
6680 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6681 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6682 	else
6683 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6684 
6685 	/* Create ZUC operation */
6686 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6687 			tdata->cipher_iv.len, tdata->plaintext.len,
6688 			tdata->validCipherOffsetInBits.len);
6689 	if (retval < 0)
6690 		return retval;
6691 
6692 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6693 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6694 					       tdata->cipher_iv.len);
6695 		if (retval != TEST_SUCCESS)
6696 			return retval;
6697 	} else
6698 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6699 						ut_params->op);
6700 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6701 
6702 	ut_params->obuf = ut_params->op->sym->m_dst;
6703 
6704 	if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6705 		if (ut_params->obuf)
6706 			ciphertext = rte_pktmbuf_read(ut_params->obuf,
6707 				0, plaintext_len, buffer);
6708 		else
6709 			ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6710 				0, plaintext_len, buffer);
6711 
6712 		/* Validate obuf */
6713 		debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6714 
6715 		/* Validate obuf */
6716 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6717 			ciphertext,
6718 			tdata->ciphertext.data,
6719 			tdata->validCipherLenInBits.len,
6720 			"ZUC Ciphertext data not as expected");
6721 	} else {
6722 		if (ut_params->obuf)
6723 			plaintext = rte_pktmbuf_read(ut_params->obuf,
6724 				0, ciphertext_len, buffer);
6725 		else
6726 			plaintext = rte_pktmbuf_read(ut_params->ibuf,
6727 				0, ciphertext_len, buffer);
6728 
6729 		/* Validate obuf */
6730 		debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6731 
6732 		/* Validate obuf */
6733 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6734 			plaintext,
6735 			tdata->plaintext.data,
6736 			tdata->validCipherLenInBits.len,
6737 			"ZUC Plaintext data not as expected");
6738 		}
6739 
6740 	return 0;
6741 }
6742 
6743 static int
6744 test_zuc_authentication(const struct wireless_test_data *tdata,
6745 		enum rte_crypto_auth_operation auth_op)
6746 {
6747 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6748 	struct crypto_unittest_params *ut_params = &unittest_params;
6749 
6750 	int retval;
6751 	unsigned plaintext_pad_len;
6752 	unsigned plaintext_len;
6753 	uint8_t *plaintext;
6754 
6755 	struct rte_cryptodev_info dev_info;
6756 
6757 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6758 	uint64_t feat_flags = dev_info.feature_flags;
6759 
6760 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6761 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6762 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6763 		return TEST_SKIPPED;
6764 	}
6765 
6766 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6767 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6768 		printf("Device doesn't support RAW data-path APIs.\n");
6769 		return TEST_SKIPPED;
6770 	}
6771 
6772 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6773 		return TEST_SKIPPED;
6774 
6775 	/* Check if device supports ZUC EIA3 */
6776 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6777 			tdata->key.len, tdata->auth_iv.len,
6778 			tdata->digest.len) < 0)
6779 		return TEST_SKIPPED;
6780 
6781 	/* Create ZUC session */
6782 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6783 			tdata->key.data, tdata->key.len,
6784 			tdata->auth_iv.len, tdata->digest.len,
6785 			auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6786 	if (retval != 0)
6787 		return retval;
6788 
6789 	/* alloc mbuf and set payload */
6790 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6791 
6792 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6793 	rte_pktmbuf_tailroom(ut_params->ibuf));
6794 
6795 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6796 	/* Append data which is padded to a multiple of */
6797 	/* the algorithms block size */
6798 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6799 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6800 				plaintext_pad_len);
6801 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6802 
6803 	/* Create ZUC operation */
6804 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
6805 			tdata->digest.len,
6806 			tdata->auth_iv.data, tdata->auth_iv.len,
6807 			plaintext_pad_len,
6808 			auth_op, tdata->validAuthLenInBits.len, 0);
6809 	if (retval < 0)
6810 		return retval;
6811 
6812 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6813 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6814 					       0);
6815 		if (retval != TEST_SUCCESS)
6816 			return retval;
6817 	} else
6818 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6819 				ut_params->op);
6820 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6821 	ut_params->obuf = ut_params->op->sym->m_src;
6822 	ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6823 						    uint8_t *,
6824 						    plaintext_pad_len);
6825 
6826 	if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6827 		/* Validate obuf */
6828 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6829 				ut_params->digest,
6830 				tdata->digest.data,
6831 				tdata->digest.len,
6832 				"ZUC Generated auth tag not as expected");
6833 		return 0;
6834 	}
6835 
6836 	/* Validate obuf */
6837 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6838 		return 0;
6839 	else
6840 		return -1;
6841 
6842 	return 0;
6843 }
6844 
6845 static int
6846 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6847 	uint8_t op_mode, uint8_t verify)
6848 {
6849 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6850 	struct crypto_unittest_params *ut_params = &unittest_params;
6851 
6852 	int retval;
6853 
6854 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6855 	unsigned int plaintext_pad_len;
6856 	unsigned int plaintext_len;
6857 	unsigned int ciphertext_pad_len;
6858 	unsigned int ciphertext_len;
6859 	unsigned int digest_offset;
6860 
6861 	struct rte_cryptodev_info dev_info;
6862 
6863 	/* Check if device supports ZUC EEA3 */
6864 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6865 			tdata->key.len, tdata->cipher_iv.len) < 0)
6866 		return TEST_SKIPPED;
6867 
6868 	/* Check if device supports ZUC EIA3 */
6869 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6870 			tdata->key.len, tdata->auth_iv.len,
6871 			tdata->digest.len) < 0)
6872 		return TEST_SKIPPED;
6873 
6874 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6875 		return TEST_SKIPPED;
6876 
6877 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6878 
6879 	uint64_t feat_flags = dev_info.feature_flags;
6880 
6881 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6882 		printf("Device doesn't support digest encrypted.\n");
6883 		return TEST_SKIPPED;
6884 	}
6885 	if (op_mode == IN_PLACE) {
6886 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6887 			printf("Device doesn't support in-place scatter-gather "
6888 					"in both input and output mbufs.\n");
6889 			return TEST_SKIPPED;
6890 		}
6891 
6892 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6893 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6894 			printf("Device doesn't support RAW data-path APIs.\n");
6895 			return TEST_SKIPPED;
6896 		}
6897 	} else {
6898 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6899 			return TEST_SKIPPED;
6900 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6901 			printf("Device doesn't support out-of-place scatter-gather "
6902 					"in both input and output mbufs.\n");
6903 			return TEST_SKIPPED;
6904 		}
6905 	}
6906 
6907 	/* Create ZUC session */
6908 	retval = create_wireless_algo_auth_cipher_session(
6909 			ts_params->valid_devs[0],
6910 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6911 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6912 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6913 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6914 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6915 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6916 			tdata->key.data, tdata->key.len,
6917 			tdata->key.data, tdata->key.len,
6918 			tdata->auth_iv.len, tdata->digest.len,
6919 			tdata->cipher_iv.len);
6920 
6921 	if (retval != 0)
6922 		return retval;
6923 
6924 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6925 	if (op_mode == OUT_OF_PLACE)
6926 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6927 
6928 	/* clear mbuf payload */
6929 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6930 		rte_pktmbuf_tailroom(ut_params->ibuf));
6931 	if (op_mode == OUT_OF_PLACE)
6932 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6933 			rte_pktmbuf_tailroom(ut_params->obuf));
6934 
6935 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6936 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6937 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6938 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6939 
6940 	if (verify) {
6941 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6942 					ciphertext_pad_len);
6943 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6944 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6945 			ciphertext_len);
6946 	} else {
6947 		/* make sure enough space to cover partial digest verify case */
6948 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6949 					ciphertext_pad_len);
6950 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6951 		debug_hexdump(stdout, "plaintext:", plaintext,
6952 			plaintext_len);
6953 	}
6954 
6955 	if (op_mode == OUT_OF_PLACE)
6956 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6957 
6958 	/* Create ZUC operation */
6959 	retval = create_wireless_algo_auth_cipher_operation(
6960 		tdata->digest.data, tdata->digest.len,
6961 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6962 		tdata->auth_iv.data, tdata->auth_iv.len,
6963 		(tdata->digest.offset_bytes == 0 ?
6964 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6965 			: tdata->digest.offset_bytes),
6966 		tdata->validCipherLenInBits.len,
6967 		tdata->validCipherOffsetInBits.len,
6968 		tdata->validAuthLenInBits.len,
6969 		0,
6970 		op_mode, 0, verify);
6971 
6972 	if (retval < 0)
6973 		return retval;
6974 
6975 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6976 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6977 					       tdata->cipher_iv.len);
6978 		if (retval != TEST_SUCCESS)
6979 			return retval;
6980 	} else
6981 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6982 			ut_params->op);
6983 
6984 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6985 
6986 	ut_params->obuf = (op_mode == IN_PLACE ?
6987 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6988 
6989 
6990 	if (verify) {
6991 		if (ut_params->obuf)
6992 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6993 							uint8_t *);
6994 		else
6995 			plaintext = ciphertext;
6996 
6997 		debug_hexdump(stdout, "plaintext:", plaintext,
6998 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6999 		debug_hexdump(stdout, "plaintext expected:",
7000 			tdata->plaintext.data,
7001 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7002 	} else {
7003 		if (ut_params->obuf)
7004 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7005 							uint8_t *);
7006 		else
7007 			ciphertext = plaintext;
7008 
7009 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7010 			ciphertext_len);
7011 		debug_hexdump(stdout, "ciphertext expected:",
7012 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7013 
7014 		if (tdata->digest.offset_bytes == 0)
7015 			digest_offset = plaintext_pad_len;
7016 		else
7017 			digest_offset =  tdata->digest.offset_bytes;
7018 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
7019 					    uint8_t *, digest_offset);
7020 
7021 		debug_hexdump(stdout, "digest:", ut_params->digest,
7022 			tdata->digest.len);
7023 		debug_hexdump(stdout, "digest expected:",
7024 			tdata->digest.data, tdata->digest.len);
7025 	}
7026 
7027 	/* Validate obuf */
7028 	if (verify) {
7029 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7030 			plaintext,
7031 			tdata->plaintext.data,
7032 			tdata->plaintext.len >> 3,
7033 			"ZUC Plaintext data not as expected");
7034 	} else {
7035 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7036 			ciphertext,
7037 			tdata->ciphertext.data,
7038 			tdata->ciphertext.len >> 3,
7039 			"ZUC Ciphertext data not as expected");
7040 
7041 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7042 			ut_params->digest,
7043 			tdata->digest.data,
7044 			tdata->digest.len,
7045 			"ZUC Generated auth tag not as expected");
7046 	}
7047 	return 0;
7048 }
7049 
7050 static int
7051 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
7052 	uint8_t op_mode, uint8_t verify)
7053 {
7054 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7055 	struct crypto_unittest_params *ut_params = &unittest_params;
7056 
7057 	int retval;
7058 
7059 	const uint8_t *plaintext = NULL;
7060 	const uint8_t *ciphertext = NULL;
7061 	const uint8_t *digest = NULL;
7062 	unsigned int plaintext_pad_len;
7063 	unsigned int plaintext_len;
7064 	unsigned int ciphertext_pad_len;
7065 	unsigned int ciphertext_len;
7066 	uint8_t buffer[10000];
7067 	uint8_t digest_buffer[10000];
7068 
7069 	struct rte_cryptodev_info dev_info;
7070 
7071 	/* Check if device supports ZUC EEA3 */
7072 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
7073 			tdata->key.len, tdata->cipher_iv.len) < 0)
7074 		return TEST_SKIPPED;
7075 
7076 	/* Check if device supports ZUC EIA3 */
7077 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
7078 			tdata->key.len, tdata->auth_iv.len,
7079 			tdata->digest.len) < 0)
7080 		return TEST_SKIPPED;
7081 
7082 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7083 		return TEST_SKIPPED;
7084 
7085 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7086 
7087 	uint64_t feat_flags = dev_info.feature_flags;
7088 
7089 	if (op_mode == IN_PLACE) {
7090 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7091 			printf("Device doesn't support in-place scatter-gather "
7092 					"in both input and output mbufs.\n");
7093 			return TEST_SKIPPED;
7094 		}
7095 
7096 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7097 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7098 			printf("Device doesn't support RAW data-path APIs.\n");
7099 			return TEST_SKIPPED;
7100 		}
7101 	} else {
7102 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7103 			return TEST_SKIPPED;
7104 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7105 			printf("Device doesn't support out-of-place scatter-gather "
7106 					"in both input and output mbufs.\n");
7107 			return TEST_SKIPPED;
7108 		}
7109 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7110 			printf("Device doesn't support digest encrypted.\n");
7111 			return TEST_SKIPPED;
7112 		}
7113 	}
7114 
7115 	/* Create ZUC session */
7116 	retval = create_wireless_algo_auth_cipher_session(
7117 			ts_params->valid_devs[0],
7118 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
7119 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
7120 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
7121 					: RTE_CRYPTO_AUTH_OP_GENERATE),
7122 			RTE_CRYPTO_AUTH_ZUC_EIA3,
7123 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
7124 			tdata->key.data, tdata->key.len,
7125 			tdata->key.data, tdata->key.len,
7126 			tdata->auth_iv.len, tdata->digest.len,
7127 			tdata->cipher_iv.len);
7128 
7129 	if (retval != 0)
7130 		return retval;
7131 
7132 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
7133 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
7134 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7135 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7136 
7137 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7138 			plaintext_pad_len, 15, 0);
7139 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7140 			"Failed to allocate input buffer in mempool");
7141 
7142 	if (op_mode == OUT_OF_PLACE) {
7143 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7144 				plaintext_pad_len, 15, 0);
7145 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
7146 				"Failed to allocate output buffer in mempool");
7147 	}
7148 
7149 	if (verify) {
7150 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7151 			tdata->ciphertext.data);
7152 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7153 					ciphertext_len, buffer);
7154 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7155 			ciphertext_len);
7156 	} else {
7157 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7158 			tdata->plaintext.data);
7159 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7160 					plaintext_len, buffer);
7161 		debug_hexdump(stdout, "plaintext:", plaintext,
7162 			plaintext_len);
7163 	}
7164 	memset(buffer, 0, sizeof(buffer));
7165 
7166 	/* Create ZUC operation */
7167 	retval = create_wireless_algo_auth_cipher_operation(
7168 		tdata->digest.data, tdata->digest.len,
7169 		tdata->cipher_iv.data, tdata->cipher_iv.len,
7170 		tdata->auth_iv.data, tdata->auth_iv.len,
7171 		(tdata->digest.offset_bytes == 0 ?
7172 		(verify ? ciphertext_pad_len : plaintext_pad_len)
7173 			: tdata->digest.offset_bytes),
7174 		tdata->validCipherLenInBits.len,
7175 		tdata->validCipherOffsetInBits.len,
7176 		tdata->validAuthLenInBits.len,
7177 		0,
7178 		op_mode, 1, verify);
7179 
7180 	if (retval < 0)
7181 		return retval;
7182 
7183 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
7184 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
7185 					       tdata->cipher_iv.len);
7186 		if (retval != TEST_SUCCESS)
7187 			return retval;
7188 	} else
7189 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7190 			ut_params->op);
7191 
7192 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7193 
7194 	ut_params->obuf = (op_mode == IN_PLACE ?
7195 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7196 
7197 	if (verify) {
7198 		if (ut_params->obuf)
7199 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7200 					plaintext_len, buffer);
7201 		else
7202 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7203 					plaintext_len, buffer);
7204 
7205 		debug_hexdump(stdout, "plaintext:", plaintext,
7206 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7207 		debug_hexdump(stdout, "plaintext expected:",
7208 			tdata->plaintext.data,
7209 			(tdata->plaintext.len >> 3) - tdata->digest.len);
7210 	} else {
7211 		if (ut_params->obuf)
7212 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7213 					ciphertext_len, buffer);
7214 		else
7215 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7216 					ciphertext_len, buffer);
7217 
7218 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7219 			ciphertext_len);
7220 		debug_hexdump(stdout, "ciphertext expected:",
7221 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7222 
7223 		if (ut_params->obuf)
7224 			digest = rte_pktmbuf_read(ut_params->obuf,
7225 				(tdata->digest.offset_bytes == 0 ?
7226 				plaintext_pad_len : tdata->digest.offset_bytes),
7227 				tdata->digest.len, digest_buffer);
7228 		else
7229 			digest = rte_pktmbuf_read(ut_params->ibuf,
7230 				(tdata->digest.offset_bytes == 0 ?
7231 				plaintext_pad_len : tdata->digest.offset_bytes),
7232 				tdata->digest.len, digest_buffer);
7233 
7234 		debug_hexdump(stdout, "digest:", digest,
7235 			tdata->digest.len);
7236 		debug_hexdump(stdout, "digest expected:",
7237 			tdata->digest.data, tdata->digest.len);
7238 	}
7239 
7240 	/* Validate obuf */
7241 	if (verify) {
7242 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7243 			plaintext,
7244 			tdata->plaintext.data,
7245 			tdata->plaintext.len >> 3,
7246 			"ZUC Plaintext data not as expected");
7247 	} else {
7248 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7249 			ciphertext,
7250 			tdata->ciphertext.data,
7251 			tdata->validDataLenInBits.len,
7252 			"ZUC Ciphertext data not as expected");
7253 
7254 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7255 			digest,
7256 			tdata->digest.data,
7257 			tdata->digest.len,
7258 			"ZUC Generated auth tag not as expected");
7259 	}
7260 	return 0;
7261 }
7262 
7263 static int
7264 test_kasumi_encryption_test_case_1(void)
7265 {
7266 	return test_kasumi_encryption(&kasumi_test_case_1);
7267 }
7268 
7269 static int
7270 test_kasumi_encryption_test_case_1_sgl(void)
7271 {
7272 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7273 }
7274 
7275 static int
7276 test_kasumi_encryption_test_case_1_oop(void)
7277 {
7278 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
7279 }
7280 
7281 static int
7282 test_kasumi_encryption_test_case_1_oop_sgl(void)
7283 {
7284 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7285 }
7286 
7287 static int
7288 test_kasumi_encryption_test_case_2(void)
7289 {
7290 	return test_kasumi_encryption(&kasumi_test_case_2);
7291 }
7292 
7293 static int
7294 test_kasumi_encryption_test_case_3(void)
7295 {
7296 	return test_kasumi_encryption(&kasumi_test_case_3);
7297 }
7298 
7299 static int
7300 test_kasumi_encryption_test_case_4(void)
7301 {
7302 	return test_kasumi_encryption(&kasumi_test_case_4);
7303 }
7304 
7305 static int
7306 test_kasumi_encryption_test_case_5(void)
7307 {
7308 	return test_kasumi_encryption(&kasumi_test_case_5);
7309 }
7310 
7311 static int
7312 test_kasumi_decryption_test_case_1(void)
7313 {
7314 	return test_kasumi_decryption(&kasumi_test_case_1);
7315 }
7316 
7317 static int
7318 test_kasumi_decryption_test_case_1_oop(void)
7319 {
7320 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
7321 }
7322 
7323 static int
7324 test_kasumi_decryption_test_case_2(void)
7325 {
7326 	return test_kasumi_decryption(&kasumi_test_case_2);
7327 }
7328 
7329 static int
7330 test_kasumi_decryption_test_case_3(void)
7331 {
7332 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7333 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7334 		return TEST_SKIPPED;
7335 	return test_kasumi_decryption(&kasumi_test_case_3);
7336 }
7337 
7338 static int
7339 test_kasumi_decryption_test_case_4(void)
7340 {
7341 	return test_kasumi_decryption(&kasumi_test_case_4);
7342 }
7343 
7344 static int
7345 test_kasumi_decryption_test_case_5(void)
7346 {
7347 	return test_kasumi_decryption(&kasumi_test_case_5);
7348 }
7349 static int
7350 test_snow3g_encryption_test_case_1(void)
7351 {
7352 	return test_snow3g_encryption(&snow3g_test_case_1);
7353 }
7354 
7355 static int
7356 test_snow3g_encryption_test_case_1_oop(void)
7357 {
7358 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
7359 }
7360 
7361 static int
7362 test_snow3g_encryption_test_case_1_oop_sgl(void)
7363 {
7364 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7365 }
7366 
7367 static int
7368 test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7369 {
7370 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7371 }
7372 
7373 static int
7374 test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7375 {
7376 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7377 }
7378 
7379 static int
7380 test_snow3g_encryption_test_case_1_offset_oop(void)
7381 {
7382 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7383 }
7384 
7385 static int
7386 test_snow3g_encryption_test_case_2(void)
7387 {
7388 	return test_snow3g_encryption(&snow3g_test_case_2);
7389 }
7390 
7391 static int
7392 test_snow3g_encryption_test_case_3(void)
7393 {
7394 	return test_snow3g_encryption(&snow3g_test_case_3);
7395 }
7396 
7397 static int
7398 test_snow3g_encryption_test_case_4(void)
7399 {
7400 	return test_snow3g_encryption(&snow3g_test_case_4);
7401 }
7402 
7403 static int
7404 test_snow3g_encryption_test_case_5(void)
7405 {
7406 	return test_snow3g_encryption(&snow3g_test_case_5);
7407 }
7408 
7409 static int
7410 test_snow3g_decryption_test_case_1(void)
7411 {
7412 	return test_snow3g_decryption(&snow3g_test_case_1);
7413 }
7414 
7415 static int
7416 test_snow3g_decryption_test_case_1_oop(void)
7417 {
7418 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
7419 }
7420 
7421 static int
7422 test_snow3g_decryption_test_case_2(void)
7423 {
7424 	return test_snow3g_decryption(&snow3g_test_case_2);
7425 }
7426 
7427 static int
7428 test_snow3g_decryption_test_case_3(void)
7429 {
7430 	return test_snow3g_decryption(&snow3g_test_case_3);
7431 }
7432 
7433 static int
7434 test_snow3g_decryption_test_case_4(void)
7435 {
7436 	return test_snow3g_decryption(&snow3g_test_case_4);
7437 }
7438 
7439 static int
7440 test_snow3g_decryption_test_case_5(void)
7441 {
7442 	return test_snow3g_decryption(&snow3g_test_case_5);
7443 }
7444 
7445 /*
7446  * Function prepares snow3g_hash_test_data from snow3g_test_data.
7447  * Pattern digest from snow3g_test_data must be allocated as
7448  * 4 last bytes in plaintext.
7449  */
7450 static void
7451 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7452 		struct snow3g_hash_test_data *output)
7453 {
7454 	if ((pattern != NULL) && (output != NULL)) {
7455 		output->key.len = pattern->key.len;
7456 
7457 		memcpy(output->key.data,
7458 		pattern->key.data, pattern->key.len);
7459 
7460 		output->auth_iv.len = pattern->auth_iv.len;
7461 
7462 		memcpy(output->auth_iv.data,
7463 		pattern->auth_iv.data, pattern->auth_iv.len);
7464 
7465 		output->plaintext.len = pattern->plaintext.len;
7466 
7467 		memcpy(output->plaintext.data,
7468 		pattern->plaintext.data, pattern->plaintext.len >> 3);
7469 
7470 		output->digest.len = pattern->digest.len;
7471 
7472 		memcpy(output->digest.data,
7473 		&pattern->plaintext.data[pattern->digest.offset_bytes],
7474 		pattern->digest.len);
7475 
7476 		output->validAuthLenInBits.len =
7477 		pattern->validAuthLenInBits.len;
7478 	}
7479 }
7480 
7481 /*
7482  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7483  */
7484 static int
7485 test_snow3g_decryption_with_digest_test_case_1(void)
7486 {
7487 	int ret;
7488 	struct snow3g_hash_test_data snow3g_hash_data;
7489 	struct rte_cryptodev_info dev_info;
7490 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7491 
7492 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7493 	uint64_t feat_flags = dev_info.feature_flags;
7494 
7495 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7496 		printf("Device doesn't support encrypted digest operations.\n");
7497 		return TEST_SKIPPED;
7498 	}
7499 
7500 	/*
7501 	 * Function prepare data for hash verification test case.
7502 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
7503 	 */
7504 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7505 
7506 	ret = test_snow3g_decryption(&snow3g_test_case_7);
7507 	if (ret != 0)
7508 		return ret;
7509 
7510 	return test_snow3g_authentication_verify(&snow3g_hash_data);
7511 }
7512 
7513 static int
7514 test_snow3g_cipher_auth_test_case_1(void)
7515 {
7516 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
7517 }
7518 
7519 static int
7520 test_snow3g_auth_cipher_test_case_1(void)
7521 {
7522 	return test_snow3g_auth_cipher(
7523 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7524 }
7525 
7526 static int
7527 test_snow3g_auth_cipher_test_case_2(void)
7528 {
7529 	return test_snow3g_auth_cipher(
7530 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7531 }
7532 
7533 static int
7534 test_snow3g_auth_cipher_test_case_2_oop(void)
7535 {
7536 	return test_snow3g_auth_cipher(
7537 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7538 }
7539 
7540 static int
7541 test_snow3g_auth_cipher_part_digest_enc(void)
7542 {
7543 	return test_snow3g_auth_cipher(
7544 		&snow3g_auth_cipher_partial_digest_encryption,
7545 			IN_PLACE, 0);
7546 }
7547 
7548 static int
7549 test_snow3g_auth_cipher_part_digest_enc_oop(void)
7550 {
7551 	return test_snow3g_auth_cipher(
7552 		&snow3g_auth_cipher_partial_digest_encryption,
7553 			OUT_OF_PLACE, 0);
7554 }
7555 
7556 static int
7557 test_snow3g_auth_cipher_test_case_3_sgl(void)
7558 {
7559 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7560 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7561 		return TEST_SKIPPED;
7562 	return test_snow3g_auth_cipher_sgl(
7563 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7564 }
7565 
7566 static int
7567 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7568 {
7569 	return test_snow3g_auth_cipher_sgl(
7570 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7571 }
7572 
7573 static int
7574 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7575 {
7576 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7577 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7578 		return TEST_SKIPPED;
7579 	return test_snow3g_auth_cipher_sgl(
7580 		&snow3g_auth_cipher_partial_digest_encryption,
7581 			IN_PLACE, 0);
7582 }
7583 
7584 static int
7585 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7586 {
7587 	return test_snow3g_auth_cipher_sgl(
7588 		&snow3g_auth_cipher_partial_digest_encryption,
7589 			OUT_OF_PLACE, 0);
7590 }
7591 
7592 static int
7593 test_snow3g_auth_cipher_total_digest_enc_1(void)
7594 {
7595 	return test_snow3g_auth_cipher(
7596 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7597 }
7598 
7599 static int
7600 test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7601 {
7602 	return test_snow3g_auth_cipher(
7603 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7604 }
7605 
7606 static int
7607 test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7608 {
7609 	return test_snow3g_auth_cipher_sgl(
7610 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7611 }
7612 
7613 static int
7614 test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7615 {
7616 	return test_snow3g_auth_cipher_sgl(
7617 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7618 }
7619 
7620 static int
7621 test_snow3g_auth_cipher_verify_test_case_1(void)
7622 {
7623 	return test_snow3g_auth_cipher(
7624 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7625 }
7626 
7627 static int
7628 test_snow3g_auth_cipher_verify_test_case_2(void)
7629 {
7630 	return test_snow3g_auth_cipher(
7631 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7632 }
7633 
7634 static int
7635 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7636 {
7637 	return test_snow3g_auth_cipher(
7638 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7639 }
7640 
7641 static int
7642 test_snow3g_auth_cipher_verify_part_digest_enc(void)
7643 {
7644 	return test_snow3g_auth_cipher(
7645 		&snow3g_auth_cipher_partial_digest_encryption,
7646 			IN_PLACE, 1);
7647 }
7648 
7649 static int
7650 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7651 {
7652 	return test_snow3g_auth_cipher(
7653 		&snow3g_auth_cipher_partial_digest_encryption,
7654 			OUT_OF_PLACE, 1);
7655 }
7656 
7657 static int
7658 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7659 {
7660 	return test_snow3g_auth_cipher_sgl(
7661 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7662 }
7663 
7664 static int
7665 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7666 {
7667 	return test_snow3g_auth_cipher_sgl(
7668 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7669 }
7670 
7671 static int
7672 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7673 {
7674 	return test_snow3g_auth_cipher_sgl(
7675 		&snow3g_auth_cipher_partial_digest_encryption,
7676 			IN_PLACE, 1);
7677 }
7678 
7679 static int
7680 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7681 {
7682 	return test_snow3g_auth_cipher_sgl(
7683 		&snow3g_auth_cipher_partial_digest_encryption,
7684 			OUT_OF_PLACE, 1);
7685 }
7686 
7687 static int
7688 test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7689 {
7690 	return test_snow3g_auth_cipher(
7691 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7692 }
7693 
7694 static int
7695 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7696 {
7697 	return test_snow3g_auth_cipher(
7698 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7699 }
7700 
7701 static int
7702 test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7703 {
7704 	return test_snow3g_auth_cipher_sgl(
7705 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7706 }
7707 
7708 static int
7709 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7710 {
7711 	return test_snow3g_auth_cipher_sgl(
7712 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7713 }
7714 
7715 static int
7716 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7717 {
7718 	return test_snow3g_auth_cipher(
7719 		&snow3g_test_case_7, IN_PLACE, 0);
7720 }
7721 
7722 static int
7723 test_kasumi_auth_cipher_test_case_1(void)
7724 {
7725 	return test_kasumi_auth_cipher(
7726 		&kasumi_test_case_3, IN_PLACE, 0);
7727 }
7728 
7729 static int
7730 test_kasumi_auth_cipher_test_case_2(void)
7731 {
7732 	return test_kasumi_auth_cipher(
7733 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7734 }
7735 
7736 static int
7737 test_kasumi_auth_cipher_test_case_2_oop(void)
7738 {
7739 	return test_kasumi_auth_cipher(
7740 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7741 }
7742 
7743 static int
7744 test_kasumi_auth_cipher_test_case_2_sgl(void)
7745 {
7746 	return test_kasumi_auth_cipher_sgl(
7747 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7748 }
7749 
7750 static int
7751 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7752 {
7753 	return test_kasumi_auth_cipher_sgl(
7754 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7755 }
7756 
7757 static int
7758 test_kasumi_auth_cipher_verify_test_case_1(void)
7759 {
7760 	return test_kasumi_auth_cipher(
7761 		&kasumi_test_case_3, IN_PLACE, 1);
7762 }
7763 
7764 static int
7765 test_kasumi_auth_cipher_verify_test_case_2(void)
7766 {
7767 	return test_kasumi_auth_cipher(
7768 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7769 }
7770 
7771 static int
7772 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7773 {
7774 	return test_kasumi_auth_cipher(
7775 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7776 }
7777 
7778 static int
7779 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7780 {
7781 	return test_kasumi_auth_cipher_sgl(
7782 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7783 }
7784 
7785 static int
7786 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7787 {
7788 	return test_kasumi_auth_cipher_sgl(
7789 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7790 }
7791 
7792 static int
7793 test_kasumi_cipher_auth_test_case_1(void)
7794 {
7795 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7796 }
7797 
7798 static int
7799 test_zuc_encryption_test_case_1(void)
7800 {
7801 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7802 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7803 }
7804 
7805 static int
7806 test_zuc_encryption_test_case_2(void)
7807 {
7808 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7809 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7810 }
7811 
7812 static int
7813 test_zuc_encryption_test_case_3(void)
7814 {
7815 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7816 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7817 }
7818 
7819 static int
7820 test_zuc_encryption_test_case_4(void)
7821 {
7822 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7823 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7824 }
7825 
7826 static int
7827 test_zuc_encryption_test_case_5(void)
7828 {
7829 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7830 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7831 }
7832 
7833 static int
7834 test_zuc_encryption_test_case_6_sgl(void)
7835 {
7836 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7837 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7838 }
7839 
7840 static int
7841 test_zuc_decryption_test_case_1(void)
7842 {
7843 	return test_zuc_cipher(&zuc_test_case_cipher_193b,
7844 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7845 }
7846 
7847 static int
7848 test_zuc_decryption_test_case_2(void)
7849 {
7850 	return test_zuc_cipher(&zuc_test_case_cipher_800b,
7851 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7852 }
7853 
7854 static int
7855 test_zuc_decryption_test_case_3(void)
7856 {
7857 	return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7858 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7859 }
7860 
7861 static int
7862 test_zuc_decryption_test_case_4(void)
7863 {
7864 	return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7865 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7866 }
7867 
7868 static int
7869 test_zuc_decryption_test_case_5(void)
7870 {
7871 	return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7872 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7873 }
7874 
7875 static int
7876 test_zuc_decryption_test_case_6_sgl(void)
7877 {
7878 	return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7879 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
7880 }
7881 
7882 static int
7883 test_zuc_hash_generate_test_case_1(void)
7884 {
7885 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7886 			RTE_CRYPTO_AUTH_OP_GENERATE);
7887 }
7888 
7889 static int
7890 test_zuc_hash_generate_test_case_2(void)
7891 {
7892 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7893 			RTE_CRYPTO_AUTH_OP_GENERATE);
7894 }
7895 
7896 static int
7897 test_zuc_hash_generate_test_case_3(void)
7898 {
7899 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7900 			RTE_CRYPTO_AUTH_OP_GENERATE);
7901 }
7902 
7903 static int
7904 test_zuc_hash_generate_test_case_4(void)
7905 {
7906 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7907 			RTE_CRYPTO_AUTH_OP_GENERATE);
7908 }
7909 
7910 static int
7911 test_zuc_hash_generate_test_case_5(void)
7912 {
7913 	return test_zuc_authentication(&zuc_test_auth_5670b,
7914 			RTE_CRYPTO_AUTH_OP_GENERATE);
7915 }
7916 
7917 static int
7918 test_zuc_hash_generate_test_case_6(void)
7919 {
7920 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7921 			RTE_CRYPTO_AUTH_OP_GENERATE);
7922 }
7923 
7924 static int
7925 test_zuc_hash_generate_test_case_7(void)
7926 {
7927 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7928 			RTE_CRYPTO_AUTH_OP_GENERATE);
7929 }
7930 
7931 static int
7932 test_zuc_hash_generate_test_case_8(void)
7933 {
7934 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7935 			RTE_CRYPTO_AUTH_OP_GENERATE);
7936 }
7937 
7938 static int
7939 test_zuc_hash_verify_test_case_1(void)
7940 {
7941 	return test_zuc_authentication(&zuc_test_case_auth_1b,
7942 			RTE_CRYPTO_AUTH_OP_VERIFY);
7943 }
7944 
7945 static int
7946 test_zuc_hash_verify_test_case_2(void)
7947 {
7948 	return test_zuc_authentication(&zuc_test_case_auth_90b,
7949 			RTE_CRYPTO_AUTH_OP_VERIFY);
7950 }
7951 
7952 static int
7953 test_zuc_hash_verify_test_case_3(void)
7954 {
7955 	return test_zuc_authentication(&zuc_test_case_auth_577b,
7956 			RTE_CRYPTO_AUTH_OP_VERIFY);
7957 }
7958 
7959 static int
7960 test_zuc_hash_verify_test_case_4(void)
7961 {
7962 	return test_zuc_authentication(&zuc_test_case_auth_2079b,
7963 			RTE_CRYPTO_AUTH_OP_VERIFY);
7964 }
7965 
7966 static int
7967 test_zuc_hash_verify_test_case_5(void)
7968 {
7969 	return test_zuc_authentication(&zuc_test_auth_5670b,
7970 			RTE_CRYPTO_AUTH_OP_VERIFY);
7971 }
7972 
7973 static int
7974 test_zuc_hash_verify_test_case_6(void)
7975 {
7976 	return test_zuc_authentication(&zuc_test_case_auth_128b,
7977 			RTE_CRYPTO_AUTH_OP_VERIFY);
7978 }
7979 
7980 static int
7981 test_zuc_hash_verify_test_case_7(void)
7982 {
7983 	return test_zuc_authentication(&zuc_test_case_auth_2080b,
7984 			RTE_CRYPTO_AUTH_OP_VERIFY);
7985 }
7986 
7987 static int
7988 test_zuc_hash_verify_test_case_8(void)
7989 {
7990 	return test_zuc_authentication(&zuc_test_case_auth_584b,
7991 			RTE_CRYPTO_AUTH_OP_VERIFY);
7992 }
7993 
7994 static int
7995 test_zuc_cipher_auth_test_case_1(void)
7996 {
7997 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7998 }
7999 
8000 static int
8001 test_zuc_cipher_auth_test_case_2(void)
8002 {
8003 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
8004 }
8005 
8006 static int
8007 test_zuc_auth_cipher_test_case_1(void)
8008 {
8009 	return test_zuc_auth_cipher(
8010 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8011 }
8012 
8013 static int
8014 test_zuc_auth_cipher_test_case_1_oop(void)
8015 {
8016 	return test_zuc_auth_cipher(
8017 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8018 }
8019 
8020 static int
8021 test_zuc_auth_cipher_test_case_1_sgl(void)
8022 {
8023 	return test_zuc_auth_cipher_sgl(
8024 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
8025 }
8026 
8027 static int
8028 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
8029 {
8030 	return test_zuc_auth_cipher_sgl(
8031 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
8032 }
8033 
8034 static int
8035 test_zuc_auth_cipher_test_case_2(void)
8036 {
8037 	return test_zuc_auth_cipher(
8038 		&zuc_auth_cipher_test_case_2, IN_PLACE, 0);
8039 }
8040 
8041 static int
8042 test_zuc_auth_cipher_test_case_2_oop(void)
8043 {
8044 	return test_zuc_auth_cipher(
8045 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
8046 }
8047 
8048 static int
8049 test_zuc_auth_cipher_verify_test_case_1(void)
8050 {
8051 	return test_zuc_auth_cipher(
8052 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8053 }
8054 
8055 static int
8056 test_zuc_auth_cipher_verify_test_case_1_oop(void)
8057 {
8058 	return test_zuc_auth_cipher(
8059 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8060 }
8061 
8062 static int
8063 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
8064 {
8065 	return test_zuc_auth_cipher_sgl(
8066 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
8067 }
8068 
8069 static int
8070 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
8071 {
8072 	return test_zuc_auth_cipher_sgl(
8073 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
8074 }
8075 
8076 static int
8077 test_zuc_auth_cipher_verify_test_case_2(void)
8078 {
8079 	return test_zuc_auth_cipher(
8080 		&zuc_auth_cipher_test_case_2, IN_PLACE, 1);
8081 }
8082 
8083 static int
8084 test_zuc_auth_cipher_verify_test_case_2_oop(void)
8085 {
8086 	return test_zuc_auth_cipher(
8087 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
8088 }
8089 
8090 static int
8091 test_zuc256_encryption_test_case_1(void)
8092 {
8093 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
8094 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8095 }
8096 
8097 static int
8098 test_zuc256_encryption_test_case_2(void)
8099 {
8100 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
8101 			RTE_CRYPTO_CIPHER_OP_ENCRYPT);
8102 }
8103 
8104 static int
8105 test_zuc256_decryption_test_case_1(void)
8106 {
8107 	return test_zuc_cipher(&zuc256_test_case_cipher_1,
8108 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
8109 }
8110 
8111 static int
8112 test_zuc256_decryption_test_case_2(void)
8113 {
8114 	return test_zuc_cipher(&zuc256_test_case_cipher_2,
8115 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
8116 }
8117 
8118 static int
8119 test_zuc256_hash_generate_4b_tag_test_case_1(void)
8120 {
8121 	return test_zuc_authentication(&zuc256_test_case_auth_1,
8122 			RTE_CRYPTO_AUTH_OP_GENERATE);
8123 }
8124 
8125 static int
8126 test_zuc256_hash_generate_4b_tag_test_case_2(void)
8127 {
8128 	return test_zuc_authentication(&zuc256_test_case_auth_2,
8129 			RTE_CRYPTO_AUTH_OP_GENERATE);
8130 }
8131 
8132 static int
8133 test_zuc256_hash_generate_4b_tag_test_case_3(void)
8134 {
8135 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8136 			RTE_CRYPTO_AUTH_OP_GENERATE);
8137 }
8138 
8139 static int
8140 test_zuc256_hash_generate_8b_tag_test_case_1(void)
8141 {
8142 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8143 			RTE_CRYPTO_AUTH_OP_GENERATE);
8144 }
8145 
8146 static int
8147 test_zuc256_hash_generate_16b_tag_test_case_1(void)
8148 {
8149 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8150 			RTE_CRYPTO_AUTH_OP_GENERATE);
8151 }
8152 
8153 static int
8154 test_zuc256_hash_verify_4b_tag_test_case_1(void)
8155 {
8156 	return test_zuc_authentication(&zuc256_test_case_auth_1,
8157 			RTE_CRYPTO_AUTH_OP_VERIFY);
8158 }
8159 
8160 static int
8161 test_zuc256_hash_verify_4b_tag_test_case_2(void)
8162 {
8163 	return test_zuc_authentication(&zuc256_test_case_auth_2,
8164 			RTE_CRYPTO_AUTH_OP_VERIFY);
8165 }
8166 
8167 static int
8168 test_zuc256_hash_verify_4b_tag_test_case_3(void)
8169 {
8170 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
8171 			RTE_CRYPTO_AUTH_OP_VERIFY);
8172 }
8173 
8174 static int
8175 test_zuc256_hash_verify_8b_tag_test_case_1(void)
8176 {
8177 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
8178 			RTE_CRYPTO_AUTH_OP_VERIFY);
8179 }
8180 
8181 static int
8182 test_zuc256_hash_verify_16b_tag_test_case_1(void)
8183 {
8184 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
8185 			RTE_CRYPTO_AUTH_OP_VERIFY);
8186 }
8187 
8188 static int
8189 test_zuc256_cipher_auth_4b_tag_test_case_1(void)
8190 {
8191 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
8192 }
8193 
8194 static int
8195 test_zuc256_cipher_auth_4b_tag_test_case_2(void)
8196 {
8197 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
8198 }
8199 
8200 static int
8201 test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8202 {
8203 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8204 }
8205 
8206 static int
8207 test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8208 {
8209 	return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8210 }
8211 
8212 static int
8213 test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8214 {
8215 	return test_zuc_auth_cipher(
8216 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8217 }
8218 
8219 static int
8220 test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8221 {
8222 	return test_zuc_auth_cipher(
8223 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8224 }
8225 
8226 static int
8227 test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8228 {
8229 	return test_zuc_auth_cipher(
8230 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8231 }
8232 
8233 static int
8234 test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8235 {
8236 	return test_zuc_auth_cipher(
8237 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8238 }
8239 
8240 static int
8241 test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8242 {
8243 	return test_zuc_auth_cipher(
8244 		&zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8245 }
8246 
8247 static int
8248 test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8249 {
8250 	return test_zuc_auth_cipher(
8251 		&zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8252 }
8253 
8254 static int
8255 test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8256 {
8257 	return test_zuc_auth_cipher(
8258 		&zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8259 }
8260 
8261 static int
8262 test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8263 {
8264 	return test_zuc_auth_cipher(
8265 		&zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8266 }
8267 
8268 static int
8269 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8270 {
8271 	uint8_t dev_id = testsuite_params.valid_devs[0];
8272 
8273 	struct rte_cryptodev_sym_capability_idx cap_idx;
8274 
8275 	/* Check if device supports particular cipher algorithm */
8276 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8277 	cap_idx.algo.cipher = tdata->cipher_algo;
8278 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8279 		return TEST_SKIPPED;
8280 
8281 	/* Check if device supports particular hash algorithm */
8282 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8283 	cap_idx.algo.auth = tdata->auth_algo;
8284 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8285 		return TEST_SKIPPED;
8286 
8287 	return 0;
8288 }
8289 
8290 static int
8291 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8292 	uint8_t op_mode, uint8_t verify)
8293 {
8294 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8295 	struct crypto_unittest_params *ut_params = &unittest_params;
8296 
8297 	int retval;
8298 
8299 	uint8_t *plaintext = NULL, *ciphertext = NULL;
8300 	unsigned int plaintext_pad_len;
8301 	unsigned int plaintext_len;
8302 	unsigned int ciphertext_pad_len;
8303 	unsigned int ciphertext_len;
8304 	unsigned int digest_offset;
8305 
8306 	struct rte_cryptodev_info dev_info;
8307 	struct rte_crypto_op *op;
8308 
8309 	/* Check if device supports particular algorithms separately */
8310 	if (test_mixed_check_if_unsupported(tdata))
8311 		return TEST_SKIPPED;
8312 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8313 		return TEST_SKIPPED;
8314 
8315 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8316 		return TEST_SKIPPED;
8317 
8318 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8319 
8320 	uint64_t feat_flags = dev_info.feature_flags;
8321 
8322 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8323 		printf("Device doesn't support digest encrypted.\n");
8324 		return TEST_SKIPPED;
8325 	}
8326 
8327 	/* Create the session */
8328 	if (verify)
8329 		retval = create_wireless_algo_cipher_auth_session(
8330 				ts_params->valid_devs[0],
8331 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8332 				RTE_CRYPTO_AUTH_OP_VERIFY,
8333 				tdata->auth_algo,
8334 				tdata->cipher_algo,
8335 				tdata->auth_key.data, tdata->auth_key.len,
8336 				tdata->cipher_key.data, tdata->cipher_key.len,
8337 				tdata->auth_iv.len, tdata->digest_enc.len,
8338 				tdata->cipher_iv.len);
8339 	else
8340 		retval = create_wireless_algo_auth_cipher_session(
8341 				ts_params->valid_devs[0],
8342 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8343 				RTE_CRYPTO_AUTH_OP_GENERATE,
8344 				tdata->auth_algo,
8345 				tdata->cipher_algo,
8346 				tdata->auth_key.data, tdata->auth_key.len,
8347 				tdata->cipher_key.data, tdata->cipher_key.len,
8348 				tdata->auth_iv.len, tdata->digest_enc.len,
8349 				tdata->cipher_iv.len);
8350 	if (retval != 0)
8351 		return retval;
8352 
8353 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8354 	if (op_mode == OUT_OF_PLACE)
8355 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8356 
8357 	/* clear mbuf payload */
8358 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8359 		rte_pktmbuf_tailroom(ut_params->ibuf));
8360 	if (op_mode == OUT_OF_PLACE) {
8361 
8362 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8363 				rte_pktmbuf_tailroom(ut_params->obuf));
8364 	}
8365 
8366 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8367 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8368 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8369 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8370 
8371 	if (verify) {
8372 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8373 				ciphertext_pad_len);
8374 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8375 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8376 				ciphertext_len);
8377 	} else {
8378 		/* make sure enough space to cover partial digest verify case */
8379 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8380 				ciphertext_pad_len);
8381 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8382 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8383 	}
8384 
8385 	if (op_mode == OUT_OF_PLACE)
8386 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8387 
8388 	/* Create the operation */
8389 	retval = create_wireless_algo_auth_cipher_operation(
8390 			tdata->digest_enc.data, tdata->digest_enc.len,
8391 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8392 			tdata->auth_iv.data, tdata->auth_iv.len,
8393 			(tdata->digest_enc.offset == 0 ?
8394 				plaintext_pad_len
8395 				: tdata->digest_enc.offset),
8396 			tdata->validCipherLen.len_bits,
8397 			tdata->cipher.offset_bits,
8398 			tdata->validAuthLen.len_bits,
8399 			tdata->auth.offset_bits,
8400 			op_mode, 0, verify);
8401 
8402 	if (retval < 0)
8403 		return retval;
8404 
8405 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8406 
8407 	/* Check if the op failed because the device doesn't */
8408 	/* support this particular combination of algorithms */
8409 	if (op == NULL && ut_params->op->status ==
8410 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8411 		printf("Device doesn't support this mixed combination. "
8412 				"Test Skipped.\n");
8413 		return TEST_SKIPPED;
8414 	}
8415 	ut_params->op = op;
8416 
8417 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8418 
8419 	ut_params->obuf = (op_mode == IN_PLACE ?
8420 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8421 
8422 	if (verify) {
8423 		if (ut_params->obuf)
8424 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8425 							uint8_t *);
8426 		else
8427 			plaintext = ciphertext +
8428 					(tdata->cipher.offset_bits >> 3);
8429 
8430 		debug_hexdump(stdout, "plaintext:", plaintext,
8431 				tdata->plaintext.len_bits >> 3);
8432 		debug_hexdump(stdout, "plaintext expected:",
8433 				tdata->plaintext.data,
8434 				tdata->plaintext.len_bits >> 3);
8435 	} else {
8436 		if (ut_params->obuf)
8437 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8438 					uint8_t *);
8439 		else
8440 			ciphertext = plaintext;
8441 
8442 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8443 				ciphertext_len);
8444 		debug_hexdump(stdout, "ciphertext expected:",
8445 				tdata->ciphertext.data,
8446 				tdata->ciphertext.len_bits >> 3);
8447 
8448 		if (tdata->digest_enc.offset == 0)
8449 			digest_offset = plaintext_pad_len;
8450 		else
8451 			digest_offset = tdata->digest_enc.offset;
8452 
8453 		ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8454 					    uint8_t *, digest_offset);
8455 
8456 		debug_hexdump(stdout, "digest:", ut_params->digest,
8457 				tdata->digest_enc.len);
8458 		debug_hexdump(stdout, "digest expected:",
8459 				tdata->digest_enc.data,
8460 				tdata->digest_enc.len);
8461 	}
8462 
8463 	if (!verify) {
8464 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8465 				ut_params->digest,
8466 				tdata->digest_enc.data,
8467 				tdata->digest_enc.len,
8468 				"Generated auth tag not as expected");
8469 	}
8470 
8471 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8472 		if (verify) {
8473 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8474 					plaintext,
8475 					tdata->plaintext.data,
8476 					tdata->plaintext.len_bits >> 3,
8477 					"Plaintext data not as expected");
8478 		} else {
8479 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8480 					ciphertext,
8481 					tdata->ciphertext.data,
8482 					tdata->validDataLen.len_bits,
8483 					"Ciphertext data not as expected");
8484 		}
8485 	}
8486 
8487 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8488 			"crypto op processing failed");
8489 
8490 	return 0;
8491 }
8492 
8493 static int
8494 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8495 	uint8_t op_mode, uint8_t verify)
8496 {
8497 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8498 	struct crypto_unittest_params *ut_params = &unittest_params;
8499 
8500 	int retval;
8501 
8502 	const uint8_t *plaintext = NULL;
8503 	const uint8_t *ciphertext = NULL;
8504 	const uint8_t *digest = NULL;
8505 	unsigned int plaintext_pad_len;
8506 	unsigned int plaintext_len;
8507 	unsigned int ciphertext_pad_len;
8508 	unsigned int ciphertext_len;
8509 	uint8_t buffer[10000];
8510 	uint8_t digest_buffer[10000];
8511 
8512 	struct rte_cryptodev_info dev_info;
8513 	struct rte_crypto_op *op;
8514 
8515 	/* Check if device supports particular algorithms */
8516 	if (test_mixed_check_if_unsupported(tdata))
8517 		return TEST_SKIPPED;
8518 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8519 		return TEST_SKIPPED;
8520 
8521 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8522 
8523 	uint64_t feat_flags = dev_info.feature_flags;
8524 
8525 	if (op_mode == IN_PLACE) {
8526 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8527 			printf("Device doesn't support in-place scatter-gather "
8528 					"in both input and output mbufs.\n");
8529 			return TEST_SKIPPED;
8530 		}
8531 	} else {
8532 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8533 			printf("Device doesn't support out-of-place scatter-gather "
8534 					"in both input and output mbufs.\n");
8535 			return TEST_SKIPPED;
8536 		}
8537 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8538 			printf("Device doesn't support digest encrypted.\n");
8539 			return TEST_SKIPPED;
8540 		}
8541 	}
8542 
8543 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8544 		return TEST_SKIPPED;
8545 
8546 	/* Create the session */
8547 	if (verify)
8548 		retval = create_wireless_algo_cipher_auth_session(
8549 				ts_params->valid_devs[0],
8550 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
8551 				RTE_CRYPTO_AUTH_OP_VERIFY,
8552 				tdata->auth_algo,
8553 				tdata->cipher_algo,
8554 				tdata->auth_key.data, tdata->auth_key.len,
8555 				tdata->cipher_key.data, tdata->cipher_key.len,
8556 				tdata->auth_iv.len, tdata->digest_enc.len,
8557 				tdata->cipher_iv.len);
8558 	else
8559 		retval = create_wireless_algo_auth_cipher_session(
8560 				ts_params->valid_devs[0],
8561 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8562 				RTE_CRYPTO_AUTH_OP_GENERATE,
8563 				tdata->auth_algo,
8564 				tdata->cipher_algo,
8565 				tdata->auth_key.data, tdata->auth_key.len,
8566 				tdata->cipher_key.data, tdata->cipher_key.len,
8567 				tdata->auth_iv.len, tdata->digest_enc.len,
8568 				tdata->cipher_iv.len);
8569 	if (retval != 0)
8570 		return retval;
8571 
8572 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8573 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8574 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8575 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8576 
8577 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8578 			ciphertext_pad_len, 15, 0);
8579 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8580 			"Failed to allocate input buffer in mempool");
8581 
8582 	if (op_mode == OUT_OF_PLACE) {
8583 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8584 				plaintext_pad_len, 15, 0);
8585 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
8586 				"Failed to allocate output buffer in mempool");
8587 	}
8588 
8589 	if (verify) {
8590 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8591 			tdata->ciphertext.data);
8592 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8593 					ciphertext_len, buffer);
8594 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8595 			ciphertext_len);
8596 	} else {
8597 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8598 			tdata->plaintext.data);
8599 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8600 					plaintext_len, buffer);
8601 		debug_hexdump(stdout, "plaintext:", plaintext,
8602 			plaintext_len);
8603 	}
8604 	memset(buffer, 0, sizeof(buffer));
8605 
8606 	/* Create the operation */
8607 	retval = create_wireless_algo_auth_cipher_operation(
8608 			tdata->digest_enc.data, tdata->digest_enc.len,
8609 			tdata->cipher_iv.data, tdata->cipher_iv.len,
8610 			tdata->auth_iv.data, tdata->auth_iv.len,
8611 			(tdata->digest_enc.offset == 0 ?
8612 				plaintext_pad_len
8613 				: tdata->digest_enc.offset),
8614 			tdata->validCipherLen.len_bits,
8615 			tdata->cipher.offset_bits,
8616 			tdata->validAuthLen.len_bits,
8617 			tdata->auth.offset_bits,
8618 			op_mode, 1, verify);
8619 
8620 	if (retval < 0)
8621 		return retval;
8622 
8623 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8624 
8625 	/* Check if the op failed because the device doesn't */
8626 	/* support this particular combination of algorithms */
8627 	if (op == NULL && ut_params->op->status ==
8628 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8629 		printf("Device doesn't support this mixed combination. "
8630 				"Test Skipped.\n");
8631 		return TEST_SKIPPED;
8632 	}
8633 	ut_params->op = op;
8634 
8635 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8636 
8637 	ut_params->obuf = (op_mode == IN_PLACE ?
8638 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8639 
8640 	if (verify) {
8641 		if (ut_params->obuf)
8642 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8643 					plaintext_len, buffer);
8644 		else
8645 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8646 					plaintext_len, buffer);
8647 
8648 		debug_hexdump(stdout, "plaintext:", plaintext,
8649 				(tdata->plaintext.len_bits >> 3) -
8650 				tdata->digest_enc.len);
8651 		debug_hexdump(stdout, "plaintext expected:",
8652 				tdata->plaintext.data,
8653 				(tdata->plaintext.len_bits >> 3) -
8654 				tdata->digest_enc.len);
8655 	} else {
8656 		if (ut_params->obuf)
8657 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8658 					ciphertext_len, buffer);
8659 		else
8660 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8661 					ciphertext_len, buffer);
8662 
8663 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8664 			ciphertext_len);
8665 		debug_hexdump(stdout, "ciphertext expected:",
8666 			tdata->ciphertext.data,
8667 			tdata->ciphertext.len_bits >> 3);
8668 
8669 		if (ut_params->obuf)
8670 			digest = rte_pktmbuf_read(ut_params->obuf,
8671 					(tdata->digest_enc.offset == 0 ?
8672 						plaintext_pad_len :
8673 						tdata->digest_enc.offset),
8674 					tdata->digest_enc.len, digest_buffer);
8675 		else
8676 			digest = rte_pktmbuf_read(ut_params->ibuf,
8677 					(tdata->digest_enc.offset == 0 ?
8678 						plaintext_pad_len :
8679 						tdata->digest_enc.offset),
8680 					tdata->digest_enc.len, digest_buffer);
8681 
8682 		debug_hexdump(stdout, "digest:", digest,
8683 				tdata->digest_enc.len);
8684 		debug_hexdump(stdout, "digest expected:",
8685 				tdata->digest_enc.data, tdata->digest_enc.len);
8686 	}
8687 
8688 	if (!verify) {
8689 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8690 				digest,
8691 				tdata->digest_enc.data,
8692 				tdata->digest_enc.len,
8693 				"Generated auth tag not as expected");
8694 	}
8695 
8696 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8697 		if (verify) {
8698 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8699 					plaintext,
8700 					tdata->plaintext.data,
8701 					tdata->plaintext.len_bits >> 3,
8702 					"Plaintext data not as expected");
8703 		} else {
8704 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
8705 					ciphertext,
8706 					tdata->ciphertext.data,
8707 					tdata->validDataLen.len_bits,
8708 					"Ciphertext data not as expected");
8709 		}
8710 	}
8711 
8712 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8713 			"crypto op processing failed");
8714 
8715 	return 0;
8716 }
8717 
8718 /** AUTH AES CMAC + CIPHER AES CTR */
8719 
8720 static int
8721 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8722 {
8723 	return test_mixed_auth_cipher(
8724 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8725 }
8726 
8727 static int
8728 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8729 {
8730 	return test_mixed_auth_cipher(
8731 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8732 }
8733 
8734 static int
8735 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8736 {
8737 	return test_mixed_auth_cipher_sgl(
8738 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8739 }
8740 
8741 static int
8742 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8743 {
8744 	return test_mixed_auth_cipher_sgl(
8745 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8746 }
8747 
8748 static int
8749 test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8750 {
8751 	return test_mixed_auth_cipher(
8752 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8753 }
8754 
8755 static int
8756 test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8757 {
8758 	return test_mixed_auth_cipher(
8759 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8760 }
8761 
8762 static int
8763 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8764 {
8765 	return test_mixed_auth_cipher(
8766 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8767 }
8768 
8769 static int
8770 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8771 {
8772 	return test_mixed_auth_cipher(
8773 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8774 }
8775 
8776 static int
8777 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8778 {
8779 	return test_mixed_auth_cipher(
8780 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8781 }
8782 
8783 static int
8784 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8785 {
8786 	return test_mixed_auth_cipher_sgl(
8787 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8788 }
8789 
8790 static int
8791 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8792 {
8793 	return test_mixed_auth_cipher_sgl(
8794 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8795 }
8796 
8797 static int
8798 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8799 {
8800 	return test_mixed_auth_cipher(
8801 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8802 }
8803 
8804 /** MIXED AUTH + CIPHER */
8805 
8806 static int
8807 test_auth_zuc_cipher_snow_test_case_1(void)
8808 {
8809 	return test_mixed_auth_cipher(
8810 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8811 }
8812 
8813 static int
8814 test_verify_auth_zuc_cipher_snow_test_case_1(void)
8815 {
8816 	return test_mixed_auth_cipher(
8817 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8818 }
8819 
8820 static int
8821 test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8822 {
8823 	return test_mixed_auth_cipher(
8824 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8825 }
8826 
8827 static int
8828 test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8829 {
8830 	return test_mixed_auth_cipher(
8831 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8832 }
8833 
8834 
8835 static int
8836 test_auth_aes_cmac_cipher_snow_test_case_1(void)
8837 {
8838 	return test_mixed_auth_cipher(
8839 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8840 }
8841 
8842 static int
8843 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8844 {
8845 	return test_mixed_auth_cipher(
8846 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8847 }
8848 
8849 static int
8850 test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8851 {
8852 	return test_mixed_auth_cipher(
8853 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8854 }
8855 
8856 static int
8857 test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8858 {
8859 	return test_mixed_auth_cipher(
8860 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8861 }
8862 
8863 static int
8864 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8865 {
8866 	return test_mixed_auth_cipher(
8867 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8868 }
8869 
8870 static int
8871 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8872 {
8873 	return test_mixed_auth_cipher(
8874 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8875 }
8876 
8877 static int
8878 test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8879 {
8880 	return test_mixed_auth_cipher(
8881 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8882 }
8883 
8884 static int
8885 test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8886 {
8887 	return test_mixed_auth_cipher(
8888 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8889 }
8890 
8891 static int
8892 test_auth_snow_cipher_aes_ctr_test_case_1(void)
8893 {
8894 	return test_mixed_auth_cipher(
8895 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8896 }
8897 
8898 static int
8899 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8900 {
8901 	return test_mixed_auth_cipher(
8902 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8903 }
8904 
8905 static int
8906 test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8907 {
8908 	return test_mixed_auth_cipher_sgl(
8909 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8910 }
8911 
8912 static int
8913 test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8914 {
8915 	return test_mixed_auth_cipher(
8916 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8917 }
8918 
8919 static int
8920 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8921 {
8922 	return test_mixed_auth_cipher_sgl(
8923 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8924 }
8925 
8926 static int
8927 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8928 {
8929 	return test_mixed_auth_cipher(
8930 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8931 }
8932 
8933 static int
8934 test_auth_snow_cipher_zuc_test_case_1(void)
8935 {
8936 	return test_mixed_auth_cipher(
8937 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8938 }
8939 
8940 static int
8941 test_verify_auth_snow_cipher_zuc_test_case_1(void)
8942 {
8943 	return test_mixed_auth_cipher(
8944 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8945 }
8946 
8947 static int
8948 test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8949 {
8950 	return test_mixed_auth_cipher(
8951 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8952 }
8953 
8954 static int
8955 test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8956 {
8957 	return test_mixed_auth_cipher(
8958 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8959 }
8960 
8961 static int
8962 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8963 {
8964 	return test_mixed_auth_cipher(
8965 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8966 }
8967 
8968 static int
8969 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8970 {
8971 	return test_mixed_auth_cipher(
8972 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8973 }
8974 static int
8975 test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8976 {
8977 	return test_mixed_auth_cipher(
8978 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8979 }
8980 
8981 static int
8982 test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8983 {
8984 	return test_mixed_auth_cipher(
8985 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8986 }
8987 
8988 static int
8989 test_auth_null_cipher_snow_test_case_1(void)
8990 {
8991 	return test_mixed_auth_cipher(
8992 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8993 }
8994 
8995 static int
8996 test_verify_auth_null_cipher_snow_test_case_1(void)
8997 {
8998 	return test_mixed_auth_cipher(
8999 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
9000 }
9001 
9002 static int
9003 test_auth_null_cipher_zuc_test_case_1(void)
9004 {
9005 	return test_mixed_auth_cipher(
9006 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
9007 }
9008 
9009 static int
9010 test_verify_auth_null_cipher_zuc_test_case_1(void)
9011 {
9012 	return test_mixed_auth_cipher(
9013 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
9014 }
9015 
9016 static int
9017 test_auth_snow_cipher_null_test_case_1(void)
9018 {
9019 	return test_mixed_auth_cipher(
9020 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9021 }
9022 
9023 static int
9024 test_verify_auth_snow_cipher_null_test_case_1(void)
9025 {
9026 	return test_mixed_auth_cipher(
9027 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9028 }
9029 
9030 static int
9031 test_auth_zuc_cipher_null_test_case_1(void)
9032 {
9033 	return test_mixed_auth_cipher(
9034 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9035 }
9036 
9037 static int
9038 test_verify_auth_zuc_cipher_null_test_case_1(void)
9039 {
9040 	return test_mixed_auth_cipher(
9041 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9042 }
9043 
9044 static int
9045 test_auth_null_cipher_aes_ctr_test_case_1(void)
9046 {
9047 	return test_mixed_auth_cipher(
9048 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
9049 }
9050 
9051 static int
9052 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
9053 {
9054 	return test_mixed_auth_cipher(
9055 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
9056 }
9057 
9058 static int
9059 test_auth_aes_cmac_cipher_null_test_case_1(void)
9060 {
9061 	return test_mixed_auth_cipher(
9062 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
9063 }
9064 
9065 static int
9066 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
9067 {
9068 	return test_mixed_auth_cipher(
9069 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
9070 }
9071 
9072 /* ***** AEAD algorithm Tests ***** */
9073 
9074 static int
9075 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
9076 		enum rte_crypto_aead_operation op,
9077 		const uint8_t *key, const uint8_t key_len,
9078 		const uint16_t aad_len, const uint8_t auth_len,
9079 		uint8_t iv_len)
9080 {
9081 	uint8_t aead_key[key_len];
9082 
9083 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9084 	struct crypto_unittest_params *ut_params = &unittest_params;
9085 
9086 	memcpy(aead_key, key, key_len);
9087 
9088 	/* Setup AEAD Parameters */
9089 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9090 	ut_params->aead_xform.next = NULL;
9091 	ut_params->aead_xform.aead.algo = algo;
9092 	ut_params->aead_xform.aead.op = op;
9093 	ut_params->aead_xform.aead.key.data = aead_key;
9094 	ut_params->aead_xform.aead.key.length = key_len;
9095 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9096 	ut_params->aead_xform.aead.iv.length = iv_len;
9097 	ut_params->aead_xform.aead.digest_length = auth_len;
9098 	ut_params->aead_xform.aead.aad_length = aad_len;
9099 
9100 	debug_hexdump(stdout, "key:", key, key_len);
9101 
9102 	/* Create Crypto session*/
9103 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
9104 			&ut_params->aead_xform, ts_params->session_mpool);
9105 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
9106 		return TEST_SKIPPED;
9107 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9108 	return 0;
9109 }
9110 
9111 static int
9112 create_aead_xform(struct rte_crypto_op *op,
9113 		enum rte_crypto_aead_algorithm algo,
9114 		enum rte_crypto_aead_operation aead_op,
9115 		uint8_t *key, const uint8_t key_len,
9116 		const uint8_t aad_len, const uint8_t auth_len,
9117 		uint8_t iv_len)
9118 {
9119 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
9120 			"failed to allocate space for crypto transform");
9121 
9122 	struct rte_crypto_sym_op *sym_op = op->sym;
9123 
9124 	/* Setup AEAD Parameters */
9125 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
9126 	sym_op->xform->next = NULL;
9127 	sym_op->xform->aead.algo = algo;
9128 	sym_op->xform->aead.op = aead_op;
9129 	sym_op->xform->aead.key.data = key;
9130 	sym_op->xform->aead.key.length = key_len;
9131 	sym_op->xform->aead.iv.offset = IV_OFFSET;
9132 	sym_op->xform->aead.iv.length = iv_len;
9133 	sym_op->xform->aead.digest_length = auth_len;
9134 	sym_op->xform->aead.aad_length = aad_len;
9135 
9136 	debug_hexdump(stdout, "key:", key, key_len);
9137 
9138 	return 0;
9139 }
9140 
9141 static int
9142 create_aead_operation(enum rte_crypto_aead_operation op,
9143 		const struct aead_test_data *tdata)
9144 {
9145 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9146 	struct crypto_unittest_params *ut_params = &unittest_params;
9147 
9148 	uint8_t *plaintext, *ciphertext;
9149 	unsigned int aad_pad_len, plaintext_pad_len;
9150 
9151 	/* Generate Crypto op data structure */
9152 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9153 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9154 	TEST_ASSERT_NOT_NULL(ut_params->op,
9155 			"Failed to allocate symmetric crypto operation struct");
9156 
9157 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9158 
9159 	/* Append aad data */
9160 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
9161 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
9162 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9163 				aad_pad_len);
9164 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9165 				"no room to append aad");
9166 
9167 		sym_op->aead.aad.phys_addr =
9168 				rte_pktmbuf_iova(ut_params->ibuf);
9169 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
9170 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
9171 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
9172 			tdata->aad.len);
9173 
9174 		/* Append IV at the end of the crypto operation*/
9175 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9176 				uint8_t *, IV_OFFSET);
9177 
9178 		/* Copy IV 1 byte after the IV pointer, according to the API */
9179 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
9180 		debug_hexdump(stdout, "iv:", iv_ptr + 1,
9181 			tdata->iv.len);
9182 	} else {
9183 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
9184 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9185 				aad_pad_len);
9186 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
9187 				"no room to append aad");
9188 
9189 		sym_op->aead.aad.phys_addr =
9190 				rte_pktmbuf_iova(ut_params->ibuf);
9191 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
9192 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
9193 			tdata->aad.len);
9194 
9195 		/* Append IV at the end of the crypto operation*/
9196 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9197 				uint8_t *, IV_OFFSET);
9198 
9199 		if (tdata->iv.len == 0) {
9200 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9201 			debug_hexdump(stdout, "iv:", iv_ptr,
9202 				AES_GCM_J0_LENGTH);
9203 		} else {
9204 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9205 			debug_hexdump(stdout, "iv:", iv_ptr,
9206 				tdata->iv.len);
9207 		}
9208 	}
9209 
9210 	/* Append plaintext/ciphertext */
9211 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9212 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9213 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9214 				plaintext_pad_len);
9215 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9216 
9217 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9218 		debug_hexdump(stdout, "plaintext:", plaintext,
9219 				tdata->plaintext.len);
9220 
9221 		if (ut_params->obuf) {
9222 			ciphertext = (uint8_t *)rte_pktmbuf_append(
9223 					ut_params->obuf,
9224 					plaintext_pad_len + aad_pad_len);
9225 			TEST_ASSERT_NOT_NULL(ciphertext,
9226 					"no room to append ciphertext");
9227 
9228 			memset(ciphertext + aad_pad_len, 0,
9229 					tdata->ciphertext.len);
9230 		}
9231 	} else {
9232 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9233 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9234 				plaintext_pad_len);
9235 		TEST_ASSERT_NOT_NULL(ciphertext,
9236 				"no room to append ciphertext");
9237 
9238 		memcpy(ciphertext, tdata->ciphertext.data,
9239 				tdata->ciphertext.len);
9240 		debug_hexdump(stdout, "ciphertext:", ciphertext,
9241 				tdata->ciphertext.len);
9242 
9243 		if (ut_params->obuf) {
9244 			plaintext = (uint8_t *)rte_pktmbuf_append(
9245 					ut_params->obuf,
9246 					plaintext_pad_len + aad_pad_len);
9247 			TEST_ASSERT_NOT_NULL(plaintext,
9248 					"no room to append plaintext");
9249 
9250 			memset(plaintext + aad_pad_len, 0,
9251 					tdata->plaintext.len);
9252 		}
9253 	}
9254 
9255 	/* Append digest data */
9256 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9257 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9258 				ut_params->obuf ? ut_params->obuf :
9259 						ut_params->ibuf,
9260 						tdata->auth_tag.len);
9261 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9262 				"no room to append digest");
9263 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9264 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9265 				ut_params->obuf ? ut_params->obuf :
9266 						ut_params->ibuf,
9267 						plaintext_pad_len +
9268 						aad_pad_len);
9269 	} else {
9270 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9271 				ut_params->ibuf, tdata->auth_tag.len);
9272 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9273 				"no room to append digest");
9274 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9275 				ut_params->ibuf,
9276 				plaintext_pad_len + aad_pad_len);
9277 
9278 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9279 			tdata->auth_tag.len);
9280 		debug_hexdump(stdout, "digest:",
9281 			sym_op->aead.digest.data,
9282 			tdata->auth_tag.len);
9283 	}
9284 
9285 	sym_op->aead.data.length = tdata->plaintext.len;
9286 	sym_op->aead.data.offset = aad_pad_len;
9287 
9288 	return 0;
9289 }
9290 
9291 static int
9292 test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9293 {
9294 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9295 	struct crypto_unittest_params *ut_params = &unittest_params;
9296 
9297 	int retval;
9298 	uint8_t *ciphertext, *auth_tag;
9299 	uint16_t plaintext_pad_len;
9300 	uint32_t i;
9301 	struct rte_cryptodev_info dev_info;
9302 
9303 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9304 	uint64_t feat_flags = dev_info.feature_flags;
9305 
9306 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9307 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9308 		printf("Device doesn't support RAW data-path APIs.\n");
9309 		return TEST_SKIPPED;
9310 	}
9311 
9312 	/* Verify the capabilities */
9313 	struct rte_cryptodev_sym_capability_idx cap_idx;
9314 	const struct rte_cryptodev_symmetric_capability *capability;
9315 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9316 	cap_idx.algo.aead = tdata->algo;
9317 	capability = rte_cryptodev_sym_capability_get(
9318 			ts_params->valid_devs[0], &cap_idx);
9319 	if (capability == NULL)
9320 		return TEST_SKIPPED;
9321 	if (rte_cryptodev_sym_capability_check_aead(
9322 			capability, tdata->key.len, tdata->auth_tag.len,
9323 			tdata->aad.len, tdata->iv.len))
9324 		return TEST_SKIPPED;
9325 
9326 	/* Create AEAD session */
9327 	retval = create_aead_session(ts_params->valid_devs[0],
9328 			tdata->algo,
9329 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9330 			tdata->key.data, tdata->key.len,
9331 			tdata->aad.len, tdata->auth_tag.len,
9332 			tdata->iv.len);
9333 	if (retval != TEST_SUCCESS)
9334 		return retval;
9335 
9336 	if (tdata->aad.len > MBUF_SIZE) {
9337 		if (use_ext_mbuf) {
9338 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9339 							  AEAD_TEXT_MAX_LENGTH,
9340 							  1 /* nb_segs */,
9341 							  NULL);
9342 		} else {
9343 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9344 		}
9345 		/* Populate full size of add data */
9346 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9347 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9348 	} else {
9349 		if (use_ext_mbuf) {
9350 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9351 							  AEAD_TEXT_MAX_LENGTH,
9352 							  1 /* nb_segs */,
9353 							  NULL);
9354 		} else {
9355 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9356 		}
9357 	}
9358 
9359 	/* clear mbuf payload */
9360 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9361 			rte_pktmbuf_tailroom(ut_params->ibuf));
9362 
9363 	/* Create AEAD operation */
9364 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9365 	if (retval < 0)
9366 		return retval;
9367 
9368 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9369 
9370 	ut_params->op->sym->m_src = ut_params->ibuf;
9371 
9372 	/* Process crypto operation */
9373 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9374 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9375 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9376 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9377 					       0);
9378 		if (retval != TEST_SUCCESS)
9379 			return retval;
9380 	} else
9381 		TEST_ASSERT_NOT_NULL(
9382 			process_crypto_request(ts_params->valid_devs[0],
9383 			ut_params->op), "failed to process sym crypto op");
9384 
9385 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9386 			"crypto op processing failed");
9387 
9388 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9389 
9390 	if (ut_params->op->sym->m_dst) {
9391 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9392 				uint8_t *);
9393 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9394 				uint8_t *, plaintext_pad_len);
9395 	} else {
9396 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9397 				uint8_t *,
9398 				ut_params->op->sym->cipher.data.offset);
9399 		auth_tag = ciphertext + plaintext_pad_len;
9400 	}
9401 
9402 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9403 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9404 
9405 	/* Validate obuf */
9406 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9407 			ciphertext,
9408 			tdata->ciphertext.data,
9409 			tdata->ciphertext.len,
9410 			"Ciphertext data not as expected");
9411 
9412 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9413 			auth_tag,
9414 			tdata->auth_tag.data,
9415 			tdata->auth_tag.len,
9416 			"Generated auth tag not as expected");
9417 
9418 	return 0;
9419 
9420 }
9421 
9422 static int
9423 test_authenticated_encryption(const struct aead_test_data *tdata)
9424 {
9425 	return test_authenticated_encryption_helper(tdata, false);
9426 }
9427 
9428 #ifdef RTE_LIB_SECURITY
9429 static int
9430 security_proto_supported(enum rte_security_session_action_type action,
9431 	enum rte_security_session_protocol proto)
9432 {
9433 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9434 
9435 	const struct rte_security_capability *capabilities;
9436 	const struct rte_security_capability *capability;
9437 	uint16_t i = 0;
9438 
9439 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9440 
9441 
9442 	capabilities = rte_security_capabilities_get(ctx);
9443 
9444 	if (capabilities == NULL)
9445 		return -ENOTSUP;
9446 
9447 	while ((capability = &capabilities[i++])->action !=
9448 			RTE_SECURITY_ACTION_TYPE_NONE) {
9449 		if (capability->action == action &&
9450 				capability->protocol == proto)
9451 			return 0;
9452 	}
9453 
9454 	return -ENOTSUP;
9455 }
9456 
9457 /* Basic algorithm run function for async inplace mode.
9458  * Creates a session from input parameters and runs one operation
9459  * on input_vec. Checks the output of the crypto operation against
9460  * output_vec.
9461  */
9462 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9463 			   enum rte_crypto_auth_operation opa,
9464 			   const uint8_t *input_vec, unsigned int input_vec_len,
9465 			   const uint8_t *output_vec,
9466 			   unsigned int output_vec_len,
9467 			   enum rte_crypto_cipher_algorithm cipher_alg,
9468 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
9469 			   enum rte_crypto_auth_algorithm auth_alg,
9470 			   const uint8_t *auth_key, uint32_t auth_key_len,
9471 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
9472 			   uint8_t packet_direction, uint8_t sn_size,
9473 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9474 {
9475 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9476 	struct crypto_unittest_params *ut_params = &unittest_params;
9477 	uint8_t *plaintext;
9478 	int ret = TEST_SUCCESS;
9479 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9480 	struct rte_cryptodev_info dev_info;
9481 	uint64_t feat_flags;
9482 
9483 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9484 	feat_flags = dev_info.feature_flags;
9485 
9486 	/* Verify the capabilities */
9487 	struct rte_security_capability_idx sec_cap_idx;
9488 
9489 	sec_cap_idx.action = ut_params->type;
9490 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9491 	sec_cap_idx.pdcp.domain = domain;
9492 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9493 		return TEST_SKIPPED;
9494 
9495 	/* Generate test mbuf data */
9496 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9497 
9498 	/* clear mbuf payload */
9499 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9500 			rte_pktmbuf_tailroom(ut_params->ibuf));
9501 
9502 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9503 						  input_vec_len);
9504 	memcpy(plaintext, input_vec, input_vec_len);
9505 
9506 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9507 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9508 		printf("Device does not support RAW data-path APIs.\n");
9509 		return TEST_SKIPPED;
9510 	}
9511 	/* Out of place support */
9512 	if (oop) {
9513 		/*
9514 		 * For out-of-place we need to alloc another mbuf
9515 		 */
9516 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9517 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9518 	}
9519 
9520 	/* Setup Cipher Parameters */
9521 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9522 	ut_params->cipher_xform.cipher.algo = cipher_alg;
9523 	ut_params->cipher_xform.cipher.op = opc;
9524 	ut_params->cipher_xform.cipher.key.data = cipher_key;
9525 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9526 	ut_params->cipher_xform.cipher.iv.length =
9527 				packet_direction ? 4 : 0;
9528 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9529 
9530 	/* Setup HMAC Parameters if ICV header is required */
9531 	if (auth_alg != 0) {
9532 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9533 		ut_params->auth_xform.next = NULL;
9534 		ut_params->auth_xform.auth.algo = auth_alg;
9535 		ut_params->auth_xform.auth.op = opa;
9536 		ut_params->auth_xform.auth.key.data = auth_key;
9537 		ut_params->auth_xform.auth.key.length = auth_key_len;
9538 
9539 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9540 	} else {
9541 		ut_params->cipher_xform.next = NULL;
9542 	}
9543 
9544 	struct rte_security_session_conf sess_conf = {
9545 		.action_type = ut_params->type,
9546 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9547 		{.pdcp = {
9548 			.bearer = bearer,
9549 			.domain = domain,
9550 			.pkt_dir = packet_direction,
9551 			.sn_size = sn_size,
9552 			.hfn = packet_direction ? 0 : hfn,
9553 			/**
9554 			 * hfn can be set as pdcp_test_hfn[i]
9555 			 * if hfn_ovrd is not set. Here, PDCP
9556 			 * packet direction is just used to
9557 			 * run half of the cases with session
9558 			 * HFN and other half with per packet
9559 			 * HFN.
9560 			 */
9561 			.hfn_threshold = hfn_threshold,
9562 			.hfn_ovrd = packet_direction ? 1 : 0,
9563 			.sdap_enabled = sdap,
9564 		} },
9565 		.crypto_xform = &ut_params->cipher_xform
9566 	};
9567 
9568 	/* Create security session */
9569 	ut_params->sec_session = rte_security_session_create(ctx,
9570 				&sess_conf, ts_params->session_mpool);
9571 
9572 	if (!ut_params->sec_session) {
9573 		printf("TestCase %s()-%d line %d failed %s: ",
9574 			__func__, i, __LINE__, "Failed to allocate session");
9575 		ret = TEST_FAILED;
9576 		goto on_err;
9577 	}
9578 
9579 	/* Generate crypto op data structure */
9580 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9581 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9582 	if (!ut_params->op) {
9583 		printf("TestCase %s()-%d line %d failed %s: ",
9584 			__func__, i, __LINE__,
9585 			"Failed to allocate symmetric crypto operation struct");
9586 		ret = TEST_FAILED;
9587 		goto on_err;
9588 	}
9589 
9590 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9591 					uint32_t *, IV_OFFSET);
9592 	*per_pkt_hfn = packet_direction ? hfn : 0;
9593 
9594 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9595 
9596 	/* set crypto operation source mbuf */
9597 	ut_params->op->sym->m_src = ut_params->ibuf;
9598 	if (oop)
9599 		ut_params->op->sym->m_dst = ut_params->obuf;
9600 
9601 	/* Process crypto operation */
9602 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9603 		/* filling lengths */
9604 		ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9605 		ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9606 
9607 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9608 		if (ret != TEST_SUCCESS)
9609 			return ret;
9610 	} else {
9611 		ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9612 	}
9613 	if (ut_params->op == NULL) {
9614 		printf("TestCase %s()-%d line %d failed %s: ",
9615 			__func__, i, __LINE__,
9616 			"failed to process sym crypto op");
9617 		ret = TEST_FAILED;
9618 		goto on_err;
9619 	}
9620 
9621 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9622 		printf("TestCase %s()-%d line %d failed %s: ",
9623 			__func__, i, __LINE__, "crypto op processing failed");
9624 		ret = TEST_FAILED;
9625 		goto on_err;
9626 	}
9627 
9628 	/* Validate obuf */
9629 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9630 			uint8_t *);
9631 	if (oop) {
9632 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9633 				uint8_t *);
9634 	}
9635 
9636 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
9637 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9638 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9639 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9640 		ret = TEST_FAILED;
9641 		goto on_err;
9642 	}
9643 
9644 on_err:
9645 	rte_crypto_op_free(ut_params->op);
9646 	ut_params->op = NULL;
9647 
9648 	if (ut_params->sec_session)
9649 		rte_security_session_destroy(ctx, ut_params->sec_session);
9650 	ut_params->sec_session = NULL;
9651 
9652 	rte_pktmbuf_free(ut_params->ibuf);
9653 	ut_params->ibuf = NULL;
9654 	if (oop) {
9655 		rte_pktmbuf_free(ut_params->obuf);
9656 		ut_params->obuf = NULL;
9657 	}
9658 
9659 	return ret;
9660 }
9661 
9662 static int
9663 test_pdcp_proto_SGL(int i, int oop,
9664 	enum rte_crypto_cipher_operation opc,
9665 	enum rte_crypto_auth_operation opa,
9666 	uint8_t *input_vec,
9667 	unsigned int input_vec_len,
9668 	uint8_t *output_vec,
9669 	unsigned int output_vec_len,
9670 	uint32_t fragsz,
9671 	uint32_t fragsz_oop)
9672 {
9673 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9674 	struct crypto_unittest_params *ut_params = &unittest_params;
9675 	uint8_t *plaintext;
9676 	struct rte_mbuf *buf, *buf_oop = NULL;
9677 	int ret = TEST_SUCCESS;
9678 	int to_trn = 0;
9679 	int to_trn_tbl[16];
9680 	int segs = 1;
9681 	unsigned int trn_data = 0;
9682 	struct rte_cryptodev_info dev_info;
9683 	uint64_t feat_flags;
9684 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9685 	struct rte_mbuf *temp_mbuf;
9686 
9687 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9688 	feat_flags = dev_info.feature_flags;
9689 
9690 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9691 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9692 		printf("Device does not support RAW data-path APIs.\n");
9693 		return -ENOTSUP;
9694 	}
9695 	/* Verify the capabilities */
9696 	struct rte_security_capability_idx sec_cap_idx;
9697 
9698 	sec_cap_idx.action = ut_params->type;
9699 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9700 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9701 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9702 		return TEST_SKIPPED;
9703 
9704 	if (fragsz > input_vec_len)
9705 		fragsz = input_vec_len;
9706 
9707 	uint16_t plaintext_len = fragsz;
9708 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9709 
9710 	if (fragsz_oop > output_vec_len)
9711 		frag_size_oop = output_vec_len;
9712 
9713 	int ecx = 0;
9714 	if (input_vec_len % fragsz != 0) {
9715 		if (input_vec_len / fragsz + 1 > 16)
9716 			return 1;
9717 	} else if (input_vec_len / fragsz > 16)
9718 		return 1;
9719 
9720 	/* Out of place support */
9721 	if (oop) {
9722 		/*
9723 		 * For out-of-place we need to alloc another mbuf
9724 		 */
9725 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9726 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9727 		buf_oop = ut_params->obuf;
9728 	}
9729 
9730 	/* Generate test mbuf data */
9731 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9732 
9733 	/* clear mbuf payload */
9734 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9735 			rte_pktmbuf_tailroom(ut_params->ibuf));
9736 
9737 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9738 						  plaintext_len);
9739 	memcpy(plaintext, input_vec, plaintext_len);
9740 	trn_data += plaintext_len;
9741 
9742 	buf = ut_params->ibuf;
9743 
9744 	/*
9745 	 * Loop until no more fragments
9746 	 */
9747 
9748 	while (trn_data < input_vec_len) {
9749 		++segs;
9750 		to_trn = (input_vec_len - trn_data < fragsz) ?
9751 				(input_vec_len - trn_data) : fragsz;
9752 
9753 		to_trn_tbl[ecx++] = to_trn;
9754 
9755 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9756 		buf = buf->next;
9757 
9758 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9759 				rte_pktmbuf_tailroom(buf));
9760 
9761 		/* OOP */
9762 		if (oop && !fragsz_oop) {
9763 			buf_oop->next =
9764 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
9765 			buf_oop = buf_oop->next;
9766 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9767 					0, rte_pktmbuf_tailroom(buf_oop));
9768 			rte_pktmbuf_append(buf_oop, to_trn);
9769 		}
9770 
9771 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9772 				to_trn);
9773 
9774 		memcpy(plaintext, input_vec + trn_data, to_trn);
9775 		trn_data += to_trn;
9776 	}
9777 
9778 	ut_params->ibuf->nb_segs = segs;
9779 
9780 	segs = 1;
9781 	if (fragsz_oop && oop) {
9782 		to_trn = 0;
9783 		ecx = 0;
9784 
9785 		trn_data = frag_size_oop;
9786 		while (trn_data < output_vec_len) {
9787 			++segs;
9788 			to_trn =
9789 				(output_vec_len - trn_data <
9790 						frag_size_oop) ?
9791 				(output_vec_len - trn_data) :
9792 						frag_size_oop;
9793 
9794 			to_trn_tbl[ecx++] = to_trn;
9795 
9796 			buf_oop->next =
9797 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
9798 			buf_oop = buf_oop->next;
9799 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9800 					0, rte_pktmbuf_tailroom(buf_oop));
9801 			rte_pktmbuf_append(buf_oop, to_trn);
9802 
9803 			trn_data += to_trn;
9804 		}
9805 		ut_params->obuf->nb_segs = segs;
9806 	}
9807 
9808 	/* Setup Cipher Parameters */
9809 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9810 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9811 	ut_params->cipher_xform.cipher.op = opc;
9812 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9813 	ut_params->cipher_xform.cipher.key.length =
9814 					pdcp_test_params[i].cipher_key_len;
9815 	ut_params->cipher_xform.cipher.iv.length = 0;
9816 
9817 	/* Setup HMAC Parameters if ICV header is required */
9818 	if (pdcp_test_params[i].auth_alg != 0) {
9819 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9820 		ut_params->auth_xform.next = NULL;
9821 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9822 		ut_params->auth_xform.auth.op = opa;
9823 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9824 		ut_params->auth_xform.auth.key.length =
9825 					pdcp_test_params[i].auth_key_len;
9826 
9827 		ut_params->cipher_xform.next = &ut_params->auth_xform;
9828 	} else {
9829 		ut_params->cipher_xform.next = NULL;
9830 	}
9831 
9832 	struct rte_security_session_conf sess_conf = {
9833 		.action_type = ut_params->type,
9834 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
9835 		{.pdcp = {
9836 			.bearer = pdcp_test_bearer[i],
9837 			.domain = pdcp_test_params[i].domain,
9838 			.pkt_dir = pdcp_test_packet_direction[i],
9839 			.sn_size = pdcp_test_data_sn_size[i],
9840 			.hfn = pdcp_test_hfn[i],
9841 			.hfn_threshold = pdcp_test_hfn_threshold[i],
9842 			.hfn_ovrd = 0,
9843 		} },
9844 		.crypto_xform = &ut_params->cipher_xform
9845 	};
9846 
9847 	/* Create security session */
9848 	ut_params->sec_session = rte_security_session_create(ctx,
9849 				&sess_conf, ts_params->session_mpool);
9850 
9851 	if (!ut_params->sec_session) {
9852 		printf("TestCase %s()-%d line %d failed %s: ",
9853 			__func__, i, __LINE__, "Failed to allocate session");
9854 		ret = TEST_FAILED;
9855 		goto on_err;
9856 	}
9857 
9858 	/* Generate crypto op data structure */
9859 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9860 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9861 	if (!ut_params->op) {
9862 		printf("TestCase %s()-%d line %d failed %s: ",
9863 			__func__, i, __LINE__,
9864 			"Failed to allocate symmetric crypto operation struct");
9865 		ret = TEST_FAILED;
9866 		goto on_err;
9867 	}
9868 
9869 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9870 
9871 	/* set crypto operation source mbuf */
9872 	ut_params->op->sym->m_src = ut_params->ibuf;
9873 	if (oop)
9874 		ut_params->op->sym->m_dst = ut_params->obuf;
9875 
9876 	/* Process crypto operation */
9877 	temp_mbuf = ut_params->op->sym->m_src;
9878 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9879 		/* filling lengths */
9880 		while (temp_mbuf) {
9881 			ut_params->op->sym->cipher.data.length
9882 				+= temp_mbuf->pkt_len;
9883 			ut_params->op->sym->auth.data.length
9884 				+= temp_mbuf->pkt_len;
9885 			temp_mbuf = temp_mbuf->next;
9886 		}
9887 
9888 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9889 		if (ret != TEST_SUCCESS)
9890 			return ret;
9891 	} else {
9892 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9893 							ut_params->op);
9894 	}
9895 	if (ut_params->op == NULL) {
9896 		printf("TestCase %s()-%d line %d failed %s: ",
9897 			__func__, i, __LINE__,
9898 			"failed to process sym crypto op");
9899 		ret = TEST_FAILED;
9900 		goto on_err;
9901 	}
9902 
9903 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9904 		printf("TestCase %s()-%d line %d failed %s: ",
9905 			__func__, i, __LINE__, "crypto op processing failed");
9906 		ret = TEST_FAILED;
9907 		goto on_err;
9908 	}
9909 
9910 	/* Validate obuf */
9911 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9912 			uint8_t *);
9913 	if (oop) {
9914 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9915 				uint8_t *);
9916 	}
9917 	if (fragsz_oop)
9918 		fragsz = frag_size_oop;
9919 	if (memcmp(ciphertext, output_vec, fragsz)) {
9920 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9921 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9922 		rte_hexdump(stdout, "reference", output_vec, fragsz);
9923 		ret = TEST_FAILED;
9924 		goto on_err;
9925 	}
9926 
9927 	buf = ut_params->op->sym->m_src->next;
9928 	if (oop)
9929 		buf = ut_params->op->sym->m_dst->next;
9930 
9931 	unsigned int off = fragsz;
9932 
9933 	ecx = 0;
9934 	while (buf) {
9935 		ciphertext = rte_pktmbuf_mtod(buf,
9936 				uint8_t *);
9937 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9938 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9939 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9940 			rte_hexdump(stdout, "reference", output_vec + off,
9941 					to_trn_tbl[ecx]);
9942 			ret = TEST_FAILED;
9943 			goto on_err;
9944 		}
9945 		off += to_trn_tbl[ecx++];
9946 		buf = buf->next;
9947 	}
9948 on_err:
9949 	rte_crypto_op_free(ut_params->op);
9950 	ut_params->op = NULL;
9951 
9952 	if (ut_params->sec_session)
9953 		rte_security_session_destroy(ctx, ut_params->sec_session);
9954 	ut_params->sec_session = NULL;
9955 
9956 	rte_pktmbuf_free(ut_params->ibuf);
9957 	ut_params->ibuf = NULL;
9958 	if (oop) {
9959 		rte_pktmbuf_free(ut_params->obuf);
9960 		ut_params->obuf = NULL;
9961 	}
9962 
9963 	return ret;
9964 }
9965 
9966 int
9967 test_pdcp_proto_cplane_encap(int i)
9968 {
9969 	return test_pdcp_proto(
9970 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9971 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9972 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9973 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9974 		pdcp_test_params[i].cipher_key_len,
9975 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9976 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9977 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9978 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9979 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9980 }
9981 
9982 int
9983 test_pdcp_proto_uplane_encap(int i)
9984 {
9985 	return test_pdcp_proto(
9986 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9987 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9988 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9989 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9990 		pdcp_test_params[i].cipher_key_len,
9991 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9992 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9993 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9994 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9995 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9996 }
9997 
9998 int
9999 test_pdcp_proto_uplane_encap_with_int(int i)
10000 {
10001 	return test_pdcp_proto(
10002 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
10003 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10004 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10005 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10006 		pdcp_test_params[i].cipher_key_len,
10007 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10008 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10009 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10010 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10011 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10012 }
10013 
10014 int
10015 test_pdcp_proto_cplane_decap(int i)
10016 {
10017 	return test_pdcp_proto(
10018 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10019 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10020 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10021 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10022 		pdcp_test_params[i].cipher_key_len,
10023 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10024 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10025 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10026 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10027 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10028 }
10029 
10030 int
10031 test_pdcp_proto_uplane_decap(int i)
10032 {
10033 	return test_pdcp_proto(
10034 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10035 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
10036 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10037 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10038 		pdcp_test_params[i].cipher_key_len,
10039 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10040 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10041 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10042 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10043 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10044 }
10045 
10046 int
10047 test_pdcp_proto_uplane_decap_with_int(int i)
10048 {
10049 	return test_pdcp_proto(
10050 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
10051 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
10052 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
10053 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
10054 		pdcp_test_params[i].cipher_key_len,
10055 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
10056 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
10057 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
10058 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
10059 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
10060 }
10061 
10062 static int
10063 test_PDCP_PROTO_SGL_in_place_32B(void)
10064 {
10065 	/* i can be used for running any PDCP case
10066 	 * In this case it is uplane 12-bit AES-SNOW DL encap
10067 	 */
10068 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
10069 	return test_pdcp_proto_SGL(i, IN_PLACE,
10070 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10071 			RTE_CRYPTO_AUTH_OP_GENERATE,
10072 			pdcp_test_data_in[i],
10073 			pdcp_test_data_in_len[i],
10074 			pdcp_test_data_out[i],
10075 			pdcp_test_data_in_len[i]+4,
10076 			32, 0);
10077 }
10078 static int
10079 test_PDCP_PROTO_SGL_oop_32B_128B(void)
10080 {
10081 	/* i can be used for running any PDCP case
10082 	 * In this case it is uplane 18-bit NULL-NULL DL encap
10083 	 */
10084 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
10085 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10086 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10087 			RTE_CRYPTO_AUTH_OP_GENERATE,
10088 			pdcp_test_data_in[i],
10089 			pdcp_test_data_in_len[i],
10090 			pdcp_test_data_out[i],
10091 			pdcp_test_data_in_len[i]+4,
10092 			32, 128);
10093 }
10094 static int
10095 test_PDCP_PROTO_SGL_oop_32B_40B(void)
10096 {
10097 	/* i can be used for running any PDCP case
10098 	 * In this case it is uplane 18-bit AES DL encap
10099 	 */
10100 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
10101 			+ DOWNLINK;
10102 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10103 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10104 			RTE_CRYPTO_AUTH_OP_GENERATE,
10105 			pdcp_test_data_in[i],
10106 			pdcp_test_data_in_len[i],
10107 			pdcp_test_data_out[i],
10108 			pdcp_test_data_in_len[i],
10109 			32, 40);
10110 }
10111 static int
10112 test_PDCP_PROTO_SGL_oop_128B_32B(void)
10113 {
10114 	/* i can be used for running any PDCP case
10115 	 * In this case it is cplane 12-bit AES-ZUC DL encap
10116 	 */
10117 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
10118 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
10119 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10120 			RTE_CRYPTO_AUTH_OP_GENERATE,
10121 			pdcp_test_data_in[i],
10122 			pdcp_test_data_in_len[i],
10123 			pdcp_test_data_out[i],
10124 			pdcp_test_data_in_len[i]+4,
10125 			128, 32);
10126 }
10127 
10128 static int
10129 test_PDCP_SDAP_PROTO_encap_all(void)
10130 {
10131 	int i = 0, size = 0;
10132 	int err, all_err = TEST_SUCCESS;
10133 	const struct pdcp_sdap_test *cur_test;
10134 
10135 	size = RTE_DIM(list_pdcp_sdap_tests);
10136 
10137 	for (i = 0; i < size; i++) {
10138 		cur_test = &list_pdcp_sdap_tests[i];
10139 		err = test_pdcp_proto(
10140 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10141 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10142 			cur_test->in_len, cur_test->data_out,
10143 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10144 			cur_test->param.cipher_alg, cur_test->cipher_key,
10145 			cur_test->param.cipher_key_len,
10146 			cur_test->param.auth_alg,
10147 			cur_test->auth_key, cur_test->param.auth_key_len,
10148 			cur_test->bearer, cur_test->param.domain,
10149 			cur_test->packet_direction, cur_test->sn_size,
10150 			cur_test->hfn,
10151 			cur_test->hfn_threshold, SDAP_ENABLED);
10152 		if (err) {
10153 			printf("\t%d) %s: Encapsulation failed\n",
10154 					cur_test->test_idx,
10155 					cur_test->param.name);
10156 			err = TEST_FAILED;
10157 		} else {
10158 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
10159 					cur_test->param.name);
10160 			err = TEST_SUCCESS;
10161 		}
10162 		all_err += err;
10163 	}
10164 
10165 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10166 
10167 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10168 }
10169 
10170 static int
10171 test_PDCP_PROTO_short_mac(void)
10172 {
10173 	int i = 0, size = 0;
10174 	int err, all_err = TEST_SUCCESS;
10175 	const struct pdcp_short_mac_test *cur_test;
10176 
10177 	size = RTE_DIM(list_pdcp_smac_tests);
10178 
10179 	for (i = 0; i < size; i++) {
10180 		cur_test = &list_pdcp_smac_tests[i];
10181 		err = test_pdcp_proto(
10182 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
10183 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
10184 			cur_test->in_len, cur_test->data_out,
10185 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10186 			RTE_CRYPTO_CIPHER_NULL, NULL,
10187 			0, cur_test->param.auth_alg,
10188 			cur_test->auth_key, cur_test->param.auth_key_len,
10189 			0, cur_test->param.domain, 0, 0,
10190 			0, 0, 0);
10191 		if (err) {
10192 			printf("\t%d) %s: Short MAC test failed\n",
10193 					cur_test->test_idx,
10194 					cur_test->param.name);
10195 			err = TEST_FAILED;
10196 		} else {
10197 			printf("\t%d) %s: Short MAC test PASS\n",
10198 					cur_test->test_idx,
10199 					cur_test->param.name);
10200 			rte_hexdump(stdout, "MAC I",
10201 				    cur_test->data_out + cur_test->in_len + 2,
10202 				    2);
10203 			err = TEST_SUCCESS;
10204 		}
10205 		all_err += err;
10206 	}
10207 
10208 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10209 
10210 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10211 
10212 }
10213 
10214 static int
10215 test_PDCP_SDAP_PROTO_decap_all(void)
10216 {
10217 	int i = 0, size = 0;
10218 	int err, all_err = TEST_SUCCESS;
10219 	const struct pdcp_sdap_test *cur_test;
10220 
10221 	size = RTE_DIM(list_pdcp_sdap_tests);
10222 
10223 	for (i = 0; i < size; i++) {
10224 		cur_test = &list_pdcp_sdap_tests[i];
10225 		err = test_pdcp_proto(
10226 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10227 			RTE_CRYPTO_AUTH_OP_VERIFY,
10228 			cur_test->data_out,
10229 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10230 			cur_test->data_in, cur_test->in_len,
10231 			cur_test->param.cipher_alg,
10232 			cur_test->cipher_key, cur_test->param.cipher_key_len,
10233 			cur_test->param.auth_alg, cur_test->auth_key,
10234 			cur_test->param.auth_key_len, cur_test->bearer,
10235 			cur_test->param.domain, cur_test->packet_direction,
10236 			cur_test->sn_size, cur_test->hfn,
10237 			cur_test->hfn_threshold, SDAP_ENABLED);
10238 		if (err) {
10239 			printf("\t%d) %s: Decapsulation failed\n",
10240 					cur_test->test_idx,
10241 					cur_test->param.name);
10242 			err = TEST_FAILED;
10243 		} else {
10244 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10245 					cur_test->param.name);
10246 			err = TEST_SUCCESS;
10247 		}
10248 		all_err += err;
10249 	}
10250 
10251 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10252 
10253 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10254 }
10255 
10256 static int
10257 test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10258 			       struct crypto_unittest_params *ut_params,
10259 			       struct rte_security_ipsec_xform *ipsec_xform,
10260 			       const struct ipsec_test_data *td,
10261 			       const struct ipsec_test_flags *flags,
10262 			       int pkt_num)
10263 {
10264 	uint8_t dev_id = ts_params->valid_devs[0];
10265 	enum rte_security_ipsec_sa_direction dir;
10266 	int ret;
10267 
10268 	dir = ipsec_xform->direction;
10269 
10270 	/* Generate crypto op data structure */
10271 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10272 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10273 	if (!ut_params->op) {
10274 		printf("Could not allocate crypto op");
10275 		return TEST_FAILED;
10276 	}
10277 
10278 	/* Attach session to operation */
10279 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10280 
10281 	/* Set crypto operation mbufs */
10282 	ut_params->op->sym->m_src = ut_params->ibuf;
10283 	ut_params->op->sym->m_dst = NULL;
10284 
10285 	/* Copy IV in crypto operation when IV generation is disabled */
10286 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10287 	    ipsec_xform->options.iv_gen_disable == 1) {
10288 		uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10289 							uint8_t *,
10290 							IV_OFFSET);
10291 		int len;
10292 
10293 		if (td->aead)
10294 			len = td->xform.aead.aead.iv.length;
10295 		else if (td->aes_gmac)
10296 			len = td->xform.chain.auth.auth.iv.length;
10297 		else
10298 			len = td->xform.chain.cipher.cipher.iv.length;
10299 
10300 		memcpy(iv, td->iv.data, len);
10301 	}
10302 
10303 	/* Process crypto operation */
10304 	process_crypto_request(dev_id, ut_params->op);
10305 
10306 	ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10307 
10308 	rte_crypto_op_free(ut_params->op);
10309 	ut_params->op = NULL;
10310 
10311 	return ret;
10312 }
10313 
10314 static int
10315 test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10316 			  struct crypto_unittest_params *ut_params,
10317 			  void *ctx)
10318 {
10319 	uint64_t timeout, userdata;
10320 	struct rte_ether_hdr *hdr;
10321 	struct rte_mbuf *m;
10322 	void **sec_sess;
10323 	int ret;
10324 
10325 	RTE_SET_USED(ts_params);
10326 
10327 	hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10328 	hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10329 
10330 	ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10331 	ut_params->ibuf->port = 0;
10332 
10333 	sec_sess = &ut_params->sec_session;
10334 	ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10335 
10336 	if (ret != 1)
10337 		return TEST_FAILED;
10338 
10339 	ut_params->ibuf = NULL;
10340 
10341 	/* Add a timeout for 1 s */
10342 	timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10343 
10344 	do {
10345 		/* Get packet from port 0, queue 0 */
10346 		ret = rte_eth_rx_burst(0, 0, &m, 1);
10347 	} while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10348 
10349 	if (ret == 0) {
10350 		printf("Could not receive packets from ethdev\n");
10351 		return TEST_FAILED;
10352 	}
10353 
10354 	if (m == NULL) {
10355 		printf("Received mbuf is NULL\n");
10356 		return TEST_FAILED;
10357 	}
10358 
10359 	ut_params->ibuf = m;
10360 
10361 	if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10362 		printf("Received packet is not Rx security processed\n");
10363 		return TEST_FAILED;
10364 	}
10365 
10366 	if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10367 		printf("Received packet has failed Rx security processing\n");
10368 		return TEST_FAILED;
10369 	}
10370 
10371 	/*
10372 	 * 'ut_params' is set as userdata. Verify that the field is returned
10373 	 * correctly.
10374 	 */
10375 	userdata = *(uint64_t *)rte_security_dynfield(m);
10376 	if (userdata != (uint64_t)ut_params) {
10377 		printf("Userdata retrieved not matching expected\n");
10378 		return TEST_FAILED;
10379 	}
10380 
10381 	/* Trim L2 header */
10382 	rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10383 
10384 	return TEST_SUCCESS;
10385 }
10386 
10387 static int
10388 test_ipsec_proto_process(const struct ipsec_test_data td[],
10389 			 struct ipsec_test_data res_d[],
10390 			 int nb_td,
10391 			 bool silent,
10392 			 const struct ipsec_test_flags *flags)
10393 {
10394 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10395 				0x0000, 0x001a};
10396 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10397 				0xe82c, 0x4887};
10398 	const struct rte_ipv4_hdr *ipv4 =
10399 			(const struct rte_ipv4_hdr *)td[0].output_text.data;
10400 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10401 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10402 	struct crypto_unittest_params *ut_params = &unittest_params;
10403 	struct rte_security_capability_idx sec_cap_idx;
10404 	const struct rte_security_capability *sec_cap;
10405 	struct rte_security_ipsec_xform ipsec_xform;
10406 	uint8_t dev_id = ts_params->valid_devs[0];
10407 	enum rte_security_ipsec_sa_direction dir;
10408 	struct ipsec_test_data *res_d_tmp = NULL;
10409 	uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10410 	int salt_len, i, ret = TEST_SUCCESS;
10411 	void *ctx;
10412 	uint32_t src, dst;
10413 	uint32_t verify;
10414 
10415 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10416 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10417 
10418 	/* Use first test data to create session */
10419 
10420 	/* Copy IPsec xform */
10421 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10422 
10423 	dir = ipsec_xform.direction;
10424 	verify = flags->tunnel_hdr_verify;
10425 
10426 	memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10427 	memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10428 
10429 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10430 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10431 			src += 1;
10432 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10433 			dst += 1;
10434 	}
10435 
10436 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10437 		if (td->ipsec_xform.tunnel.type ==
10438 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10439 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10440 			       sizeof(src));
10441 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10442 			       sizeof(dst));
10443 
10444 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10445 				ipsec_xform.tunnel.ipv4.df = 0;
10446 
10447 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10448 				ipsec_xform.tunnel.ipv4.df = 1;
10449 
10450 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10451 				ipsec_xform.tunnel.ipv4.dscp = 0;
10452 
10453 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10454 				ipsec_xform.tunnel.ipv4.dscp =
10455 						TEST_IPSEC_DSCP_VAL;
10456 
10457 		} else {
10458 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10459 				ipsec_xform.tunnel.ipv6.dscp = 0;
10460 
10461 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10462 				ipsec_xform.tunnel.ipv6.dscp =
10463 						TEST_IPSEC_DSCP_VAL;
10464 
10465 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10466 			       sizeof(v6_src));
10467 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10468 			       sizeof(v6_dst));
10469 		}
10470 	}
10471 
10472 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
10473 
10474 	sec_cap_idx.action = ut_params->type;
10475 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10476 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10477 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10478 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10479 
10480 	if (flags->udp_encap)
10481 		ipsec_xform.options.udp_encap = 1;
10482 
10483 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10484 	if (sec_cap == NULL)
10485 		return TEST_SKIPPED;
10486 
10487 	/* Copy cipher session parameters */
10488 	if (td[0].aead) {
10489 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10490 		       sizeof(ut_params->aead_xform));
10491 		ut_params->aead_xform.aead.key.data = td[0].key.data;
10492 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10493 
10494 		/* Verify crypto capabilities */
10495 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10496 			if (!silent)
10497 				RTE_LOG(INFO, USER1,
10498 					"Crypto capabilities not supported\n");
10499 			return TEST_SKIPPED;
10500 		}
10501 	} else if (td[0].auth_only) {
10502 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10503 		       sizeof(ut_params->auth_xform));
10504 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10505 
10506 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10507 			if (!silent)
10508 				RTE_LOG(INFO, USER1,
10509 					"Auth crypto capabilities not supported\n");
10510 			return TEST_SKIPPED;
10511 		}
10512 	} else {
10513 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10514 		       sizeof(ut_params->cipher_xform));
10515 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10516 		       sizeof(ut_params->auth_xform));
10517 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10518 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10519 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10520 
10521 		/* Verify crypto capabilities */
10522 
10523 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10524 			if (!silent)
10525 				RTE_LOG(INFO, USER1,
10526 					"Cipher crypto capabilities not supported\n");
10527 			return TEST_SKIPPED;
10528 		}
10529 
10530 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10531 			if (!silent)
10532 				RTE_LOG(INFO, USER1,
10533 					"Auth crypto capabilities not supported\n");
10534 			return TEST_SKIPPED;
10535 		}
10536 	}
10537 
10538 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10539 		return TEST_SKIPPED;
10540 
10541 	struct rte_security_session_conf sess_conf = {
10542 		.action_type = ut_params->type,
10543 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10544 	};
10545 
10546 	if (td[0].aead || td[0].aes_gmac) {
10547 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10548 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10549 	}
10550 
10551 	if (td[0].aead) {
10552 		sess_conf.ipsec = ipsec_xform;
10553 		sess_conf.crypto_xform = &ut_params->aead_xform;
10554 	} else if (td[0].auth_only) {
10555 		sess_conf.ipsec = ipsec_xform;
10556 		sess_conf.crypto_xform = &ut_params->auth_xform;
10557 	} else {
10558 		sess_conf.ipsec = ipsec_xform;
10559 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10560 			sess_conf.crypto_xform = &ut_params->cipher_xform;
10561 			ut_params->cipher_xform.next = &ut_params->auth_xform;
10562 		} else {
10563 			sess_conf.crypto_xform = &ut_params->auth_xform;
10564 			ut_params->auth_xform.next = &ut_params->cipher_xform;
10565 		}
10566 	}
10567 
10568 	if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10569 		sess_conf.userdata = ut_params;
10570 
10571 	/* Create security session */
10572 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10573 					ts_params->session_mpool);
10574 
10575 	if (ut_params->sec_session == NULL)
10576 		return TEST_SKIPPED;
10577 
10578 	for (i = 0; i < nb_td; i++) {
10579 		if (flags->antireplay &&
10580 		    (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10581 			sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10582 			ret = rte_security_session_update(ctx,
10583 				ut_params->sec_session, &sess_conf);
10584 			if (ret) {
10585 				printf("Could not update sequence number in "
10586 				       "session\n");
10587 				return TEST_SKIPPED;
10588 			}
10589 		}
10590 
10591 		/* Copy test data before modification */
10592 		memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10593 		if (test_ipsec_pkt_update(input_text, flags)) {
10594 			ret = TEST_FAILED;
10595 			goto mbuf_free;
10596 		}
10597 
10598 		/* Setup source mbuf payload */
10599 		if (flags->use_ext_mbuf) {
10600 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10601 					td[i].input_text.len, nb_segs, input_text);
10602 		} else {
10603 			ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10604 					td[i].input_text.len, nb_segs, 0);
10605 			pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10606 		}
10607 
10608 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10609 			ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10610 							ctx);
10611 		else
10612 			ret = test_ipsec_proto_crypto_op_enq(ts_params,
10613 							     ut_params,
10614 							     &ipsec_xform,
10615 							     &td[i], flags,
10616 							     i + 1);
10617 
10618 		if (ret != TEST_SUCCESS)
10619 			goto mbuf_free;
10620 
10621 		if (res_d != NULL)
10622 			res_d_tmp = &res_d[i];
10623 
10624 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10625 					      res_d_tmp, silent, flags);
10626 		if (ret != TEST_SUCCESS)
10627 			goto mbuf_free;
10628 
10629 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10630 					      flags, dir);
10631 		if (ret != TEST_SUCCESS)
10632 			goto mbuf_free;
10633 
10634 		rte_pktmbuf_free(ut_params->ibuf);
10635 		ut_params->ibuf = NULL;
10636 	}
10637 
10638 mbuf_free:
10639 	if (flags->use_ext_mbuf)
10640 		ext_mbuf_memzone_free(nb_segs);
10641 
10642 	rte_pktmbuf_free(ut_params->ibuf);
10643 	ut_params->ibuf = NULL;
10644 
10645 	if (ut_params->sec_session)
10646 		rte_security_session_destroy(ctx, ut_params->sec_session);
10647 	ut_params->sec_session = NULL;
10648 
10649 	return ret;
10650 }
10651 
10652 static int
10653 test_ipsec_proto_known_vec(const void *test_data)
10654 {
10655 	struct ipsec_test_data td_outb;
10656 	struct ipsec_test_flags flags;
10657 
10658 	memset(&flags, 0, sizeof(flags));
10659 
10660 	memcpy(&td_outb, test_data, sizeof(td_outb));
10661 
10662 	if (td_outb.aes_gmac || td_outb.aead ||
10663 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10664 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10665 		/* Disable IV gen to be able to test with known vectors */
10666 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10667 	}
10668 
10669 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10670 }
10671 
10672 static int
10673 test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10674 {
10675 	struct ipsec_test_data td_outb;
10676 	struct ipsec_test_flags flags;
10677 
10678 	memset(&flags, 0, sizeof(flags));
10679 	flags.use_ext_mbuf = true;
10680 
10681 	memcpy(&td_outb, test_data, sizeof(td_outb));
10682 
10683 	if (td_outb.aes_gmac || td_outb.aead ||
10684 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10685 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10686 		/* Disable IV gen to be able to test with known vectors */
10687 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
10688 	}
10689 
10690 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10691 }
10692 
10693 static int
10694 test_ipsec_proto_known_vec_inb(const void *test_data)
10695 {
10696 	const struct ipsec_test_data *td = test_data;
10697 	struct ipsec_test_flags flags;
10698 	struct ipsec_test_data td_inb;
10699 
10700 	memset(&flags, 0, sizeof(flags));
10701 
10702 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10703 		test_ipsec_td_in_from_out(td, &td_inb);
10704 	else
10705 		memcpy(&td_inb, td, sizeof(td_inb));
10706 
10707 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10708 }
10709 
10710 static int
10711 test_ipsec_proto_known_vec_fragmented(const void *test_data)
10712 {
10713 	struct ipsec_test_data td_outb;
10714 	struct ipsec_test_flags flags;
10715 
10716 	memset(&flags, 0, sizeof(flags));
10717 	flags.fragment = true;
10718 
10719 	memcpy(&td_outb, test_data, sizeof(td_outb));
10720 
10721 	/* Disable IV gen to be able to test with known vectors */
10722 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
10723 
10724 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10725 }
10726 
10727 static int
10728 test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10729 {
10730 	const struct ipsec_test_data *td = test_data;
10731 	struct ipsec_test_flags flags;
10732 	struct ipsec_test_data td_inb;
10733 
10734 	memset(&flags, 0, sizeof(flags));
10735 	flags.rx_inject = true;
10736 
10737 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10738 		test_ipsec_td_in_from_out(td, &td_inb);
10739 	else
10740 		memcpy(&td_inb, td, sizeof(td_inb));
10741 
10742 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10743 }
10744 
10745 static int
10746 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10747 {
10748 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10749 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10750 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10751 	int ret;
10752 
10753 	if (flags->iv_gen ||
10754 	    flags->sa_expiry_pkts_soft ||
10755 	    flags->sa_expiry_pkts_hard)
10756 		nb_pkts = TEST_SEC_PKTS_MAX;
10757 
10758 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10759 		test_ipsec_td_prepare(sec_alg_list[i].param1,
10760 				      sec_alg_list[i].param2,
10761 				      flags,
10762 				      td_outb,
10763 				      nb_pkts);
10764 
10765 		if (!td_outb->aead) {
10766 			enum rte_crypto_cipher_algorithm cipher_alg;
10767 			enum rte_crypto_auth_algorithm auth_alg;
10768 
10769 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10770 			auth_alg = td_outb->xform.chain.auth.auth.algo;
10771 
10772 			if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10773 				continue;
10774 
10775 			/* ICV is not applicable for NULL auth */
10776 			if (flags->icv_corrupt &&
10777 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
10778 				continue;
10779 
10780 			/* IV is not applicable for NULL cipher */
10781 			if (flags->iv_gen &&
10782 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10783 				continue;
10784 		}
10785 
10786 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10787 					       flags);
10788 		if (ret == TEST_SKIPPED)
10789 			continue;
10790 
10791 		if (ret == TEST_FAILED)
10792 			return TEST_FAILED;
10793 
10794 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10795 
10796 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10797 					       flags);
10798 		if (ret == TEST_SKIPPED)
10799 			continue;
10800 
10801 		if (ret == TEST_FAILED)
10802 			return TEST_FAILED;
10803 
10804 		if (flags->display_alg)
10805 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10806 
10807 		pass_cnt++;
10808 	}
10809 
10810 	if (pass_cnt > 0)
10811 		return TEST_SUCCESS;
10812 	else
10813 		return TEST_SKIPPED;
10814 }
10815 
10816 static int
10817 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10818 {
10819 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10820 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10821 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
10822 	int ret;
10823 
10824 	for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10825 		test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10826 				      sec_auth_only_alg_list[i].param2,
10827 				      flags,
10828 				      td_outb,
10829 				      nb_pkts);
10830 
10831 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10832 					       flags);
10833 		if (ret == TEST_SKIPPED)
10834 			continue;
10835 
10836 		if (ret == TEST_FAILED)
10837 			return TEST_FAILED;
10838 
10839 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10840 
10841 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10842 					       flags);
10843 		if (ret == TEST_SKIPPED)
10844 			continue;
10845 
10846 		if (ret == TEST_FAILED)
10847 			return TEST_FAILED;
10848 
10849 		if (flags->display_alg)
10850 			test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10851 					     sec_auth_only_alg_list[i].param2);
10852 
10853 		pass_cnt++;
10854 	}
10855 
10856 	if (pass_cnt > 0)
10857 		return TEST_SUCCESS;
10858 	else
10859 		return TEST_SKIPPED;
10860 }
10861 
10862 static int
10863 test_ipsec_proto_display_list(void)
10864 {
10865 	struct ipsec_test_flags flags;
10866 
10867 	memset(&flags, 0, sizeof(flags));
10868 
10869 	flags.display_alg = true;
10870 
10871 	return test_ipsec_proto_all(&flags);
10872 }
10873 
10874 static int
10875 test_ipsec_proto_ah_tunnel_ipv4(void)
10876 {
10877 	struct ipsec_test_flags flags;
10878 
10879 	memset(&flags, 0, sizeof(flags));
10880 
10881 	flags.ah = true;
10882 	flags.display_alg = true;
10883 
10884 	return test_ipsec_ah_proto_all(&flags);
10885 }
10886 
10887 static int
10888 test_ipsec_proto_ah_transport_ipv4(void)
10889 {
10890 	struct ipsec_test_flags flags;
10891 
10892 	memset(&flags, 0, sizeof(flags));
10893 
10894 	flags.ah = true;
10895 	flags.transport = true;
10896 
10897 	return test_ipsec_ah_proto_all(&flags);
10898 }
10899 
10900 static int
10901 test_ipsec_proto_iv_gen(void)
10902 {
10903 	struct ipsec_test_flags flags;
10904 
10905 	memset(&flags, 0, sizeof(flags));
10906 
10907 	flags.iv_gen = true;
10908 
10909 	return test_ipsec_proto_all(&flags);
10910 }
10911 
10912 static int
10913 test_ipsec_proto_sa_exp_pkts_soft(void)
10914 {
10915 	struct ipsec_test_flags flags;
10916 
10917 	memset(&flags, 0, sizeof(flags));
10918 
10919 	flags.sa_expiry_pkts_soft = true;
10920 
10921 	return test_ipsec_proto_all(&flags);
10922 }
10923 
10924 static int
10925 test_ipsec_proto_sa_exp_pkts_hard(void)
10926 {
10927 	struct ipsec_test_flags flags;
10928 
10929 	memset(&flags, 0, sizeof(flags));
10930 
10931 	flags.sa_expiry_pkts_hard = true;
10932 
10933 	return test_ipsec_proto_all(&flags);
10934 }
10935 
10936 static int
10937 test_ipsec_proto_err_icv_corrupt(void)
10938 {
10939 	struct ipsec_test_flags flags;
10940 
10941 	memset(&flags, 0, sizeof(flags));
10942 
10943 	flags.icv_corrupt = true;
10944 
10945 	return test_ipsec_proto_all(&flags);
10946 }
10947 
10948 static int
10949 test_ipsec_proto_udp_encap_custom_ports(void)
10950 {
10951 	struct ipsec_test_flags flags;
10952 
10953 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10954 			RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10955 		return TEST_SKIPPED;
10956 
10957 	memset(&flags, 0, sizeof(flags));
10958 
10959 	flags.udp_encap = true;
10960 	flags.udp_encap_custom_ports = true;
10961 
10962 	return test_ipsec_proto_all(&flags);
10963 }
10964 
10965 static int
10966 test_ipsec_proto_udp_encap(void)
10967 {
10968 	struct ipsec_test_flags flags;
10969 
10970 	memset(&flags, 0, sizeof(flags));
10971 
10972 	flags.udp_encap = true;
10973 
10974 	return test_ipsec_proto_all(&flags);
10975 }
10976 
10977 static int
10978 test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10979 {
10980 	struct ipsec_test_flags flags;
10981 
10982 	memset(&flags, 0, sizeof(flags));
10983 
10984 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10985 
10986 	return test_ipsec_proto_all(&flags);
10987 }
10988 
10989 static int
10990 test_ipsec_proto_tunnel_dst_addr_verify(void)
10991 {
10992 	struct ipsec_test_flags flags;
10993 
10994 	memset(&flags, 0, sizeof(flags));
10995 
10996 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10997 
10998 	return test_ipsec_proto_all(&flags);
10999 }
11000 
11001 static int
11002 test_ipsec_proto_udp_ports_verify(void)
11003 {
11004 	struct ipsec_test_flags flags;
11005 
11006 	memset(&flags, 0, sizeof(flags));
11007 
11008 	flags.udp_encap = true;
11009 	flags.udp_ports_verify = true;
11010 
11011 	return test_ipsec_proto_all(&flags);
11012 }
11013 
11014 static int
11015 test_ipsec_proto_inner_ip_csum(void)
11016 {
11017 	struct ipsec_test_flags flags;
11018 
11019 	memset(&flags, 0, sizeof(flags));
11020 
11021 	flags.ip_csum = true;
11022 
11023 	return test_ipsec_proto_all(&flags);
11024 }
11025 
11026 static int
11027 test_ipsec_proto_inner_l4_csum(void)
11028 {
11029 	struct ipsec_test_flags flags;
11030 
11031 	memset(&flags, 0, sizeof(flags));
11032 
11033 	flags.l4_csum = true;
11034 
11035 	return test_ipsec_proto_all(&flags);
11036 }
11037 
11038 static int
11039 test_ipsec_proto_tunnel_v4_in_v4(void)
11040 {
11041 	struct ipsec_test_flags flags;
11042 
11043 	memset(&flags, 0, sizeof(flags));
11044 
11045 	flags.ipv6 = false;
11046 	flags.tunnel_ipv6 = false;
11047 
11048 	return test_ipsec_proto_all(&flags);
11049 }
11050 
11051 static int
11052 test_ipsec_proto_tunnel_v6_in_v6(void)
11053 {
11054 	struct ipsec_test_flags flags;
11055 
11056 	memset(&flags, 0, sizeof(flags));
11057 
11058 	flags.ipv6 = true;
11059 	flags.tunnel_ipv6 = true;
11060 
11061 	return test_ipsec_proto_all(&flags);
11062 }
11063 
11064 static int
11065 test_ipsec_proto_tunnel_v4_in_v6(void)
11066 {
11067 	struct ipsec_test_flags flags;
11068 
11069 	memset(&flags, 0, sizeof(flags));
11070 
11071 	flags.ipv6 = false;
11072 	flags.tunnel_ipv6 = true;
11073 
11074 	return test_ipsec_proto_all(&flags);
11075 }
11076 
11077 static int
11078 test_ipsec_proto_tunnel_v6_in_v4(void)
11079 {
11080 	struct ipsec_test_flags flags;
11081 
11082 	memset(&flags, 0, sizeof(flags));
11083 
11084 	flags.ipv6 = true;
11085 	flags.tunnel_ipv6 = false;
11086 
11087 	return test_ipsec_proto_all(&flags);
11088 }
11089 
11090 static int
11091 test_ipsec_proto_transport_v4(void)
11092 {
11093 	struct ipsec_test_flags flags;
11094 
11095 	memset(&flags, 0, sizeof(flags));
11096 
11097 	flags.ipv6 = false;
11098 	flags.transport = true;
11099 
11100 	return test_ipsec_proto_all(&flags);
11101 }
11102 
11103 static int
11104 test_ipsec_proto_transport_l4_csum(void)
11105 {
11106 	struct ipsec_test_flags flags = {
11107 		.l4_csum = true,
11108 		.transport = true,
11109 	};
11110 
11111 	return test_ipsec_proto_all(&flags);
11112 }
11113 
11114 static int
11115 test_ipsec_proto_stats(void)
11116 {
11117 	struct ipsec_test_flags flags;
11118 
11119 	memset(&flags, 0, sizeof(flags));
11120 
11121 	flags.stats_success = true;
11122 
11123 	return test_ipsec_proto_all(&flags);
11124 }
11125 
11126 static int
11127 test_ipsec_proto_pkt_fragment(void)
11128 {
11129 	struct ipsec_test_flags flags;
11130 
11131 	memset(&flags, 0, sizeof(flags));
11132 
11133 	flags.fragment = true;
11134 
11135 	return test_ipsec_proto_all(&flags);
11136 
11137 }
11138 
11139 static int
11140 test_ipsec_proto_copy_df_inner_0(void)
11141 {
11142 	struct ipsec_test_flags flags;
11143 
11144 	memset(&flags, 0, sizeof(flags));
11145 
11146 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
11147 
11148 	return test_ipsec_proto_all(&flags);
11149 }
11150 
11151 static int
11152 test_ipsec_proto_copy_df_inner_1(void)
11153 {
11154 	struct ipsec_test_flags flags;
11155 
11156 	memset(&flags, 0, sizeof(flags));
11157 
11158 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
11159 
11160 	return test_ipsec_proto_all(&flags);
11161 }
11162 
11163 static int
11164 test_ipsec_proto_set_df_0_inner_1(void)
11165 {
11166 	struct ipsec_test_flags flags;
11167 
11168 	memset(&flags, 0, sizeof(flags));
11169 
11170 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
11171 
11172 	return test_ipsec_proto_all(&flags);
11173 }
11174 
11175 static int
11176 test_ipsec_proto_set_df_1_inner_0(void)
11177 {
11178 	struct ipsec_test_flags flags;
11179 
11180 	memset(&flags, 0, sizeof(flags));
11181 
11182 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
11183 
11184 	return test_ipsec_proto_all(&flags);
11185 }
11186 
11187 static int
11188 test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
11189 {
11190 	struct ipsec_test_flags flags;
11191 
11192 	memset(&flags, 0, sizeof(flags));
11193 
11194 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11195 
11196 	return test_ipsec_proto_all(&flags);
11197 }
11198 
11199 static int
11200 test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11201 {
11202 	struct ipsec_test_flags flags;
11203 
11204 	memset(&flags, 0, sizeof(flags));
11205 
11206 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11207 
11208 	return test_ipsec_proto_all(&flags);
11209 }
11210 
11211 static int
11212 test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11213 {
11214 	struct ipsec_test_flags flags;
11215 
11216 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11217 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11218 		return TEST_SKIPPED;
11219 
11220 	memset(&flags, 0, sizeof(flags));
11221 
11222 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11223 
11224 	return test_ipsec_proto_all(&flags);
11225 }
11226 
11227 static int
11228 test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11229 {
11230 	struct ipsec_test_flags flags;
11231 
11232 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11233 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11234 		return TEST_SKIPPED;
11235 
11236 	memset(&flags, 0, sizeof(flags));
11237 
11238 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11239 
11240 	return test_ipsec_proto_all(&flags);
11241 }
11242 
11243 static int
11244 test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11245 {
11246 	struct ipsec_test_flags flags;
11247 
11248 	memset(&flags, 0, sizeof(flags));
11249 
11250 	flags.ipv6 = true;
11251 	flags.tunnel_ipv6 = true;
11252 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11253 
11254 	return test_ipsec_proto_all(&flags);
11255 }
11256 
11257 static int
11258 test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11259 {
11260 	struct ipsec_test_flags flags;
11261 
11262 	memset(&flags, 0, sizeof(flags));
11263 
11264 	flags.ipv6 = true;
11265 	flags.tunnel_ipv6 = true;
11266 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11267 
11268 	return test_ipsec_proto_all(&flags);
11269 }
11270 
11271 static int
11272 test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11273 {
11274 	struct ipsec_test_flags flags;
11275 
11276 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11277 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11278 		return TEST_SKIPPED;
11279 
11280 	memset(&flags, 0, sizeof(flags));
11281 
11282 	flags.ipv6 = true;
11283 	flags.tunnel_ipv6 = true;
11284 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11285 
11286 	return test_ipsec_proto_all(&flags);
11287 }
11288 
11289 static int
11290 test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11291 {
11292 	struct ipsec_test_flags flags;
11293 
11294 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
11295 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11296 		return TEST_SKIPPED;
11297 
11298 	memset(&flags, 0, sizeof(flags));
11299 
11300 	flags.ipv6 = true;
11301 	flags.tunnel_ipv6 = true;
11302 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11303 
11304 	return test_ipsec_proto_all(&flags);
11305 }
11306 
11307 static int
11308 test_ipsec_proto_sgl(void)
11309 {
11310 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11311 	struct rte_cryptodev_info dev_info;
11312 
11313 	struct ipsec_test_flags flags = {
11314 		.nb_segs_in_mbuf = 5
11315 	};
11316 
11317 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11318 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11319 		printf("Device doesn't support in-place scatter-gather. "
11320 				"Test Skipped.\n");
11321 		return TEST_SKIPPED;
11322 	}
11323 
11324 	return test_ipsec_proto_all(&flags);
11325 }
11326 
11327 static int
11328 test_ipsec_proto_sgl_ext_mbuf(void)
11329 {
11330 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11331 	struct rte_cryptodev_info dev_info;
11332 
11333 	struct ipsec_test_flags flags = {
11334 		.nb_segs_in_mbuf = 5,
11335 		.use_ext_mbuf = 1
11336 	};
11337 
11338 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11339 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11340 		printf("Device doesn't support in-place scatter-gather. "
11341 				"Test Skipped.\n");
11342 		return TEST_SKIPPED;
11343 	}
11344 
11345 	return test_ipsec_proto_all(&flags);
11346 }
11347 
11348 static int
11349 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11350 		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11351 		      uint64_t winsz)
11352 {
11353 	struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11354 	struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11355 	struct ipsec_test_flags flags;
11356 	uint32_t i = 0, ret = 0;
11357 
11358 	if (nb_pkts == 0)
11359 		return TEST_FAILED;
11360 
11361 	memset(&flags, 0, sizeof(flags));
11362 	flags.antireplay = true;
11363 
11364 	for (i = 0; i < nb_pkts; i++) {
11365 		memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11366 		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11367 		td_outb[i].ipsec_xform.replay_win_sz = winsz;
11368 		td_outb[i].ipsec_xform.options.esn = esn_en;
11369 	}
11370 
11371 	for (i = 0; i < nb_pkts; i++)
11372 		td_outb[i].ipsec_xform.esn.value = esn[i];
11373 
11374 	ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11375 				       &flags);
11376 	if (ret != TEST_SUCCESS)
11377 		return ret;
11378 
11379 	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11380 
11381 	for (i = 0; i < nb_pkts; i++) {
11382 		td_inb[i].ipsec_xform.options.esn = esn_en;
11383 		/* Set antireplay flag for packets to be dropped */
11384 		td_inb[i].ar_packet = replayed_pkt[i];
11385 	}
11386 
11387 	ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11388 				       &flags);
11389 
11390 	return ret;
11391 }
11392 
11393 static int
11394 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11395 {
11396 
11397 	uint32_t nb_pkts = 5;
11398 	bool replayed_pkt[5];
11399 	uint64_t esn[5];
11400 
11401 	/* 1. Advance the TOP of the window to WS * 2 */
11402 	esn[0] = winsz * 2;
11403 	/* 2. Test sequence number within the new window(WS + 1) */
11404 	esn[1] = winsz + 1;
11405 	/* 3. Test sequence number less than the window BOTTOM */
11406 	esn[2] = winsz;
11407 	/* 4. Test sequence number in the middle of the window */
11408 	esn[3] = winsz + (winsz / 2);
11409 	/* 5. Test replay of the packet in the middle of the window */
11410 	esn[4] = winsz + (winsz / 2);
11411 
11412 	replayed_pkt[0] = false;
11413 	replayed_pkt[1] = false;
11414 	replayed_pkt[2] = true;
11415 	replayed_pkt[3] = false;
11416 	replayed_pkt[4] = true;
11417 
11418 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11419 				     false, winsz);
11420 }
11421 
11422 static int
11423 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11424 {
11425 	return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11426 }
11427 
11428 static int
11429 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11430 {
11431 	return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11432 }
11433 
11434 static int
11435 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11436 {
11437 	return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11438 }
11439 
11440 static int
11441 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11442 {
11443 
11444 	uint32_t nb_pkts = 7;
11445 	bool replayed_pkt[7];
11446 	uint64_t esn[7];
11447 
11448 	/* Set the initial sequence number */
11449 	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11450 	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11451 	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11452 	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11453 	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11454 	/* 3. Test with sequence number within window (1<<32 - 1) */
11455 	esn[3] = (uint64_t)((1ULL << 32) - 1);
11456 	/* 4. Test with sequence number within window (1<<32 - 1) */
11457 	esn[4] = (uint64_t)(1ULL << 32);
11458 	/* 5. Test with duplicate sequence number within
11459 	 * new window (1<<32 - 1)
11460 	 */
11461 	esn[5] = (uint64_t)((1ULL << 32) - 1);
11462 	/* 6. Test with duplicate sequence number within new window (1<<32) */
11463 	esn[6] = (uint64_t)(1ULL << 32);
11464 
11465 	replayed_pkt[0] = false;
11466 	replayed_pkt[1] = false;
11467 	replayed_pkt[2] = false;
11468 	replayed_pkt[3] = false;
11469 	replayed_pkt[4] = false;
11470 	replayed_pkt[5] = true;
11471 	replayed_pkt[6] = true;
11472 
11473 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11474 				     true, winsz);
11475 }
11476 
11477 static int
11478 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11479 {
11480 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11481 }
11482 
11483 static int
11484 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11485 {
11486 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11487 }
11488 
11489 static int
11490 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11491 {
11492 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11493 }
11494 
11495 static int
11496 test_PDCP_PROTO_all(void)
11497 {
11498 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11499 	struct crypto_unittest_params *ut_params = &unittest_params;
11500 	struct rte_cryptodev_info dev_info;
11501 	int status;
11502 
11503 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11504 	uint64_t feat_flags = dev_info.feature_flags;
11505 
11506 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11507 		return TEST_SKIPPED;
11508 
11509 	/* Set action type */
11510 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11511 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11512 		gbl_action_type;
11513 
11514 	if (security_proto_supported(ut_params->type,
11515 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
11516 		return TEST_SKIPPED;
11517 
11518 	status = test_PDCP_PROTO_cplane_encap_all();
11519 	status += test_PDCP_PROTO_cplane_decap_all();
11520 	status += test_PDCP_PROTO_uplane_encap_all();
11521 	status += test_PDCP_PROTO_uplane_decap_all();
11522 	status += test_PDCP_PROTO_SGL_in_place_32B();
11523 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
11524 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
11525 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
11526 	status += test_PDCP_SDAP_PROTO_encap_all();
11527 	status += test_PDCP_SDAP_PROTO_decap_all();
11528 	status += test_PDCP_PROTO_short_mac();
11529 
11530 	if (status)
11531 		return TEST_FAILED;
11532 	else
11533 		return TEST_SUCCESS;
11534 }
11535 
11536 static int
11537 test_ipsec_proto_ipv4_ttl_decrement(void)
11538 {
11539 	struct ipsec_test_flags flags = {
11540 		.dec_ttl_or_hop_limit = true
11541 	};
11542 
11543 	return test_ipsec_proto_all(&flags);
11544 }
11545 
11546 static int
11547 test_ipsec_proto_ipv6_hop_limit_decrement(void)
11548 {
11549 	struct ipsec_test_flags flags = {
11550 		.ipv6 = true,
11551 		.dec_ttl_or_hop_limit = true
11552 	};
11553 
11554 	return test_ipsec_proto_all(&flags);
11555 }
11556 
11557 static int
11558 test_docsis_proto_uplink(const void *data)
11559 {
11560 	const struct docsis_test_data *d_td = data;
11561 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11562 	struct crypto_unittest_params *ut_params = &unittest_params;
11563 	uint8_t *plaintext = NULL;
11564 	uint8_t *ciphertext = NULL;
11565 	uint8_t *iv_ptr;
11566 	int32_t cipher_len, crc_len;
11567 	uint32_t crc_data_len;
11568 	int ret = TEST_SUCCESS;
11569 
11570 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11571 
11572 	/* Verify the capabilities */
11573 	struct rte_security_capability_idx sec_cap_idx;
11574 	const struct rte_security_capability *sec_cap;
11575 	const struct rte_cryptodev_capabilities *crypto_cap;
11576 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11577 	int j = 0;
11578 
11579 	/* Set action type */
11580 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11581 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11582 		gbl_action_type;
11583 
11584 	if (security_proto_supported(ut_params->type,
11585 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11586 		return TEST_SKIPPED;
11587 
11588 	sec_cap_idx.action = ut_params->type;
11589 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11590 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11591 
11592 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11593 	if (sec_cap == NULL)
11594 		return TEST_SKIPPED;
11595 
11596 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11597 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11598 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11599 				crypto_cap->sym.xform_type ==
11600 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11601 				crypto_cap->sym.cipher.algo ==
11602 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11603 			sym_cap = &crypto_cap->sym;
11604 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11605 						d_td->key.len,
11606 						d_td->iv.len) == 0)
11607 				break;
11608 		}
11609 	}
11610 
11611 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11612 		return TEST_SKIPPED;
11613 
11614 	/* Setup source mbuf payload */
11615 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11616 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11617 			rte_pktmbuf_tailroom(ut_params->ibuf));
11618 
11619 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11620 			d_td->ciphertext.len);
11621 
11622 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11623 
11624 	/* Setup cipher session parameters */
11625 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11626 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11627 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11628 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11629 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11630 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11631 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11632 	ut_params->cipher_xform.next = NULL;
11633 
11634 	/* Setup DOCSIS session parameters */
11635 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11636 
11637 	struct rte_security_session_conf sess_conf = {
11638 		.action_type = ut_params->type,
11639 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11640 		.docsis = ut_params->docsis_xform,
11641 		.crypto_xform = &ut_params->cipher_xform,
11642 	};
11643 
11644 	/* Create security session */
11645 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11646 					ts_params->session_mpool);
11647 
11648 	if (!ut_params->sec_session) {
11649 		printf("Test function %s line %u: failed to allocate session\n",
11650 			__func__, __LINE__);
11651 		ret = TEST_FAILED;
11652 		goto on_err;
11653 	}
11654 
11655 	/* Generate crypto op data structure */
11656 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11657 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11658 	if (!ut_params->op) {
11659 		printf("Test function %s line %u: failed to allocate symmetric "
11660 			"crypto operation\n", __func__, __LINE__);
11661 		ret = TEST_FAILED;
11662 		goto on_err;
11663 	}
11664 
11665 	/* Setup CRC operation parameters */
11666 	crc_len = d_td->ciphertext.no_crc == false ?
11667 			(d_td->ciphertext.len -
11668 				d_td->ciphertext.crc_offset -
11669 				RTE_ETHER_CRC_LEN) :
11670 			0;
11671 	crc_len = crc_len > 0 ? crc_len : 0;
11672 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11673 	ut_params->op->sym->auth.data.length = crc_len;
11674 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11675 
11676 	/* Setup cipher operation parameters */
11677 	cipher_len = d_td->ciphertext.no_cipher == false ?
11678 			(d_td->ciphertext.len -
11679 				d_td->ciphertext.cipher_offset) :
11680 			0;
11681 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11682 	ut_params->op->sym->cipher.data.length = cipher_len;
11683 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11684 
11685 	/* Setup cipher IV */
11686 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11687 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11688 
11689 	/* Attach session to operation */
11690 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11691 
11692 	/* Set crypto operation mbufs */
11693 	ut_params->op->sym->m_src = ut_params->ibuf;
11694 	ut_params->op->sym->m_dst = NULL;
11695 
11696 	/* Process crypto operation */
11697 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11698 			NULL) {
11699 		printf("Test function %s line %u: failed to process security "
11700 			"crypto op\n", __func__, __LINE__);
11701 		ret = TEST_FAILED;
11702 		goto on_err;
11703 	}
11704 
11705 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11706 		printf("Test function %s line %u: failed to process crypto op\n",
11707 			__func__, __LINE__);
11708 		ret = TEST_FAILED;
11709 		goto on_err;
11710 	}
11711 
11712 	/* Validate plaintext */
11713 	plaintext = ciphertext;
11714 
11715 	if (memcmp(plaintext, d_td->plaintext.data,
11716 			d_td->plaintext.len - crc_data_len)) {
11717 		printf("Test function %s line %u: plaintext not as expected\n",
11718 			__func__, __LINE__);
11719 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
11720 				d_td->plaintext.len);
11721 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11722 		ret = TEST_FAILED;
11723 		goto on_err;
11724 	}
11725 
11726 on_err:
11727 	rte_crypto_op_free(ut_params->op);
11728 	ut_params->op = NULL;
11729 
11730 	if (ut_params->sec_session)
11731 		rte_security_session_destroy(ctx, ut_params->sec_session);
11732 	ut_params->sec_session = NULL;
11733 
11734 	rte_pktmbuf_free(ut_params->ibuf);
11735 	ut_params->ibuf = NULL;
11736 
11737 	return ret;
11738 }
11739 
11740 static int
11741 test_docsis_proto_downlink(const void *data)
11742 {
11743 	const struct docsis_test_data *d_td = data;
11744 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11745 	struct crypto_unittest_params *ut_params = &unittest_params;
11746 	uint8_t *plaintext = NULL;
11747 	uint8_t *ciphertext = NULL;
11748 	uint8_t *iv_ptr;
11749 	int32_t cipher_len, crc_len;
11750 	int ret = TEST_SUCCESS;
11751 
11752 	void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11753 
11754 	/* Verify the capabilities */
11755 	struct rte_security_capability_idx sec_cap_idx;
11756 	const struct rte_security_capability *sec_cap;
11757 	const struct rte_cryptodev_capabilities *crypto_cap;
11758 	const struct rte_cryptodev_symmetric_capability *sym_cap;
11759 	int j = 0;
11760 
11761 	/* Set action type */
11762 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11763 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11764 		gbl_action_type;
11765 
11766 	if (security_proto_supported(ut_params->type,
11767 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11768 		return TEST_SKIPPED;
11769 
11770 	sec_cap_idx.action = ut_params->type;
11771 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11772 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11773 
11774 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11775 	if (sec_cap == NULL)
11776 		return TEST_SKIPPED;
11777 
11778 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11779 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11780 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11781 				crypto_cap->sym.xform_type ==
11782 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
11783 				crypto_cap->sym.cipher.algo ==
11784 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11785 			sym_cap = &crypto_cap->sym;
11786 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11787 						d_td->key.len,
11788 						d_td->iv.len) == 0)
11789 				break;
11790 		}
11791 	}
11792 
11793 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11794 		return TEST_SKIPPED;
11795 
11796 	/* Setup source mbuf payload */
11797 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11798 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11799 			rte_pktmbuf_tailroom(ut_params->ibuf));
11800 
11801 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11802 			d_td->plaintext.len);
11803 
11804 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11805 
11806 	/* Setup cipher session parameters */
11807 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11808 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11809 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11810 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11811 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11812 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11813 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11814 	ut_params->cipher_xform.next = NULL;
11815 
11816 	/* Setup DOCSIS session parameters */
11817 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11818 
11819 	struct rte_security_session_conf sess_conf = {
11820 		.action_type = ut_params->type,
11821 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11822 		.docsis = ut_params->docsis_xform,
11823 		.crypto_xform = &ut_params->cipher_xform,
11824 	};
11825 
11826 	/* Create security session */
11827 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11828 					ts_params->session_mpool);
11829 
11830 	if (!ut_params->sec_session) {
11831 		printf("Test function %s line %u: failed to allocate session\n",
11832 			__func__, __LINE__);
11833 		ret = TEST_FAILED;
11834 		goto on_err;
11835 	}
11836 
11837 	/* Generate crypto op data structure */
11838 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11839 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11840 	if (!ut_params->op) {
11841 		printf("Test function %s line %u: failed to allocate symmetric "
11842 			"crypto operation\n", __func__, __LINE__);
11843 		ret = TEST_FAILED;
11844 		goto on_err;
11845 	}
11846 
11847 	/* Setup CRC operation parameters */
11848 	crc_len = d_td->plaintext.no_crc == false ?
11849 			(d_td->plaintext.len -
11850 				d_td->plaintext.crc_offset -
11851 				RTE_ETHER_CRC_LEN) :
11852 			0;
11853 	crc_len = crc_len > 0 ? crc_len : 0;
11854 	ut_params->op->sym->auth.data.length = crc_len;
11855 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11856 
11857 	/* Setup cipher operation parameters */
11858 	cipher_len = d_td->plaintext.no_cipher == false ?
11859 			(d_td->plaintext.len -
11860 				d_td->plaintext.cipher_offset) :
11861 			0;
11862 	cipher_len = cipher_len > 0 ? cipher_len : 0;
11863 	ut_params->op->sym->cipher.data.length = cipher_len;
11864 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11865 
11866 	/* Setup cipher IV */
11867 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11868 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11869 
11870 	/* Attach session to operation */
11871 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
11872 
11873 	/* Set crypto operation mbufs */
11874 	ut_params->op->sym->m_src = ut_params->ibuf;
11875 	ut_params->op->sym->m_dst = NULL;
11876 
11877 	/* Process crypto operation */
11878 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11879 			NULL) {
11880 		printf("Test function %s line %u: failed to process crypto op\n",
11881 			__func__, __LINE__);
11882 		ret = TEST_FAILED;
11883 		goto on_err;
11884 	}
11885 
11886 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11887 		printf("Test function %s line %u: crypto op processing failed\n",
11888 			__func__, __LINE__);
11889 		ret = TEST_FAILED;
11890 		goto on_err;
11891 	}
11892 
11893 	/* Validate ciphertext */
11894 	ciphertext = plaintext;
11895 
11896 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11897 		printf("Test function %s line %u: plaintext not as expected\n",
11898 			__func__, __LINE__);
11899 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11900 				d_td->ciphertext.len);
11901 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11902 		ret = TEST_FAILED;
11903 		goto on_err;
11904 	}
11905 
11906 on_err:
11907 	rte_crypto_op_free(ut_params->op);
11908 	ut_params->op = NULL;
11909 
11910 	if (ut_params->sec_session)
11911 		rte_security_session_destroy(ctx, ut_params->sec_session);
11912 	ut_params->sec_session = NULL;
11913 
11914 	rte_pktmbuf_free(ut_params->ibuf);
11915 	ut_params->ibuf = NULL;
11916 
11917 	return ret;
11918 }
11919 
11920 static void
11921 test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11922 				 struct rte_security_tls_record_xform *tls_record_xform)
11923 {
11924 	unsigned int imp_nonce_len;
11925 	uint8_t *imp_nonce;
11926 
11927 	switch (tls_record_xform->ver) {
11928 	case RTE_SECURITY_VERSION_TLS_1_2:
11929 		imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11930 		imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11931 		break;
11932 	case RTE_SECURITY_VERSION_DTLS_1_2:
11933 		imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11934 		imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11935 		break;
11936 	case RTE_SECURITY_VERSION_TLS_1_3:
11937 		imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11938 		imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11939 		break;
11940 	default:
11941 		return;
11942 	}
11943 
11944 	imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11945 	memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11946 }
11947 
11948 static int
11949 test_tls_record_proto_process(const struct tls_record_test_data td[],
11950 			      struct tls_record_test_data res_d[], int nb_td, bool silent,
11951 			      const struct tls_record_test_flags *flags)
11952 {
11953 	int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11954 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11955 	struct crypto_unittest_params *ut_params = &unittest_params;
11956 	struct rte_security_tls_record_xform tls_record_xform;
11957 	struct rte_security_capability_idx sec_cap_idx;
11958 	const struct rte_security_capability *sec_cap;
11959 	struct tls_record_test_data *res_d_tmp = NULL;
11960 	enum rte_security_tls_sess_type sess_type;
11961 	uint8_t dev_id = ts_params->valid_devs[0];
11962 	struct rte_security_ctx *ctx;
11963 	int i, ret = TEST_SUCCESS;
11964 
11965 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11966 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11967 
11968 	/* Use first test data to create session */
11969 
11970 	/* Copy TLS record xform */
11971 	memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11972 
11973 	sess_type = tls_record_xform.type;
11974 
11975 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
11976 
11977 	sec_cap_idx.action = ut_params->type;
11978 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11979 	sec_cap_idx.tls_record.type = tls_record_xform.type;
11980 	sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11981 
11982 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11983 	if (sec_cap == NULL)
11984 		return TEST_SKIPPED;
11985 
11986 	/* Copy cipher session parameters */
11987 	if (td[0].aead) {
11988 		memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11989 		ut_params->aead_xform.aead.key.data = td[0].key.data;
11990 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11991 
11992 		/* Verify crypto capabilities */
11993 		if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11994 			if (!silent)
11995 				RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11996 			return TEST_SKIPPED;
11997 		}
11998 	} else {
11999 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
12000 		       sizeof(ut_params->cipher_xform));
12001 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
12002 		       sizeof(ut_params->auth_xform));
12003 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
12004 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12005 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
12006 
12007 		/* Verify crypto capabilities */
12008 
12009 		if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
12010 			if (!silent)
12011 				RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
12012 			return TEST_SKIPPED;
12013 		}
12014 
12015 		if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
12016 			if (!silent)
12017 				RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
12018 			return TEST_SKIPPED;
12019 		}
12020 	}
12021 
12022 	if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
12023 		return TEST_SKIPPED;
12024 
12025 	struct rte_security_session_conf sess_conf = {
12026 		.action_type = ut_params->type,
12027 		.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
12028 	};
12029 
12030 	if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
12031 	    (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
12032 		sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
12033 
12034 	if (td[0].aead)
12035 		test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
12036 
12037 	if (flags->opt_padding)
12038 		tls_record_xform.options.extra_padding_enable = 1;
12039 
12040 	sess_conf.tls_record = tls_record_xform;
12041 
12042 	if (td[0].aead) {
12043 		sess_conf.crypto_xform = &ut_params->aead_xform;
12044 	} else {
12045 		if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
12046 			sess_conf.crypto_xform = &ut_params->cipher_xform;
12047 			ut_params->cipher_xform.next = &ut_params->auth_xform;
12048 		} else {
12049 			sess_conf.crypto_xform = &ut_params->auth_xform;
12050 			ut_params->auth_xform.next = &ut_params->cipher_xform;
12051 		}
12052 	}
12053 
12054 	if (ut_params->sec_session == NULL) {
12055 		/* Create security session */
12056 		ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
12057 				ts_params->session_mpool);
12058 	}
12059 
12060 	if (ut_params->sec_session == NULL)
12061 		return TEST_SKIPPED;
12062 
12063 	for (i = 0; i < nb_td; i++) {
12064 		if (flags->ar_win_size &&
12065 			(sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
12066 			sess_conf.tls_record.dtls_1_2.seq_no =
12067 				td[i].tls_record_xform.dtls_1_2.seq_no;
12068 			ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
12069 			if (ret) {
12070 				printf("Could not update sequence number in session\n");
12071 				return TEST_SKIPPED;
12072 			}
12073 		}
12074 
12075 		/* Setup source mbuf payload */
12076 		ut_params->ibuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12077 				ts_params->large_mbuf_pool, td[i].input_text.len, nb_segs, 0);
12078 		pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
12079 		if (flags->out_of_place)
12080 			ut_params->obuf = create_segmented_mbuf_multi_pool(ts_params->mbuf_pool,
12081 					ts_params->large_mbuf_pool, td[i].output_text.len, nb_segs,
12082 					0);
12083 		else
12084 			ut_params->obuf = NULL;
12085 
12086 		/* Generate crypto op data structure */
12087 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12088 						    RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12089 		if (ut_params->op == NULL) {
12090 			printf("Could not allocate crypto op");
12091 			ret = TEST_FAILED;
12092 			goto crypto_op_free;
12093 		}
12094 
12095 		/* Attach session to operation */
12096 		rte_security_attach_session(ut_params->op, ut_params->sec_session);
12097 
12098 		/* Set crypto operation mbufs */
12099 		ut_params->op->sym->m_src = ut_params->ibuf;
12100 		ut_params->op->sym->m_dst = ut_params->obuf;
12101 		ut_params->op->param1.tls_record.content_type = td[i].app_type;
12102 
12103 		if (flags->opt_padding)
12104 			ut_params->op->aux_flags = flags->opt_padding;
12105 
12106 		/* Copy IV in crypto operation when IV generation is disabled */
12107 		if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
12108 		    (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
12109 		    (tls_record_xform.options.iv_gen_disable == 1)) {
12110 			uint8_t *iv;
12111 			int len;
12112 
12113 			iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
12114 			if (td[i].aead)
12115 				len = td[i].xform.aead.aead.iv.length - 4;
12116 			else
12117 				len = td[i].xform.chain.cipher.cipher.iv.length;
12118 			memcpy(iv, td[i].iv.data, len);
12119 		}
12120 
12121 		/* Process crypto operation */
12122 		process_crypto_request(dev_id, ut_params->op);
12123 
12124 		ret = test_tls_record_status_check(ut_params->op, &td[i]);
12125 		if (ret != TEST_SUCCESS)
12126 			goto crypto_op_free;
12127 
12128 		if (res_d != NULL)
12129 			res_d_tmp = &res_d[i];
12130 
12131 		if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
12132 			struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
12133 						ut_params->ibuf;
12134 
12135 			ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
12136 							   silent, flags);
12137 			if (ret != TEST_SUCCESS)
12138 				goto crypto_op_free;
12139 		}
12140 
12141 		rte_crypto_op_free(ut_params->op);
12142 		ut_params->op = NULL;
12143 
12144 		if (flags->out_of_place) {
12145 			rte_pktmbuf_free(ut_params->obuf);
12146 			ut_params->obuf = NULL;
12147 		}
12148 
12149 		rte_pktmbuf_free(ut_params->ibuf);
12150 		ut_params->ibuf = NULL;
12151 	}
12152 
12153 crypto_op_free:
12154 	rte_crypto_op_free(ut_params->op);
12155 	ut_params->op = NULL;
12156 
12157 	if (flags->out_of_place) {
12158 		rte_pktmbuf_free(ut_params->obuf);
12159 		ut_params->obuf = NULL;
12160 	}
12161 
12162 	rte_pktmbuf_free(ut_params->ibuf);
12163 	ut_params->ibuf = NULL;
12164 
12165 	if (ut_params->sec_session != NULL && !flags->skip_sess_destroy) {
12166 		rte_security_session_destroy(ctx, ut_params->sec_session);
12167 		ut_params->sec_session = NULL;
12168 	}
12169 
12170 	RTE_SET_USED(flags);
12171 
12172 	return ret;
12173 }
12174 
12175 static int
12176 test_tls_record_proto_known_vec(const void *test_data)
12177 {
12178 	struct tls_record_test_data td_write;
12179 	struct tls_record_test_flags flags;
12180 
12181 	memset(&flags, 0, sizeof(flags));
12182 
12183 	memcpy(&td_write, test_data, sizeof(td_write));
12184 
12185 	/* Disable IV gen to be able to test with known vectors */
12186 	td_write.tls_record_xform.options.iv_gen_disable = 1;
12187 
12188 	return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
12189 }
12190 
12191 static int
12192 test_tls_record_proto_known_vec_read(const void *test_data)
12193 {
12194 	const struct tls_record_test_data *td = test_data;
12195 	struct tls_record_test_flags flags;
12196 	struct tls_record_test_data td_inb;
12197 
12198 	memset(&flags, 0, sizeof(flags));
12199 
12200 	if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
12201 		test_tls_record_td_read_from_write(td, &td_inb);
12202 	else
12203 		memcpy(&td_inb, td, sizeof(td_inb));
12204 
12205 	return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12206 }
12207 
12208 static int
12209 test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12210 {
12211 	unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12212 	struct crypto_unittest_params *ut_params = &unittest_params;
12213 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12214 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12215 	void *sec_session_outb = NULL;
12216 	void *sec_session_inb = NULL;
12217 	int ret;
12218 
12219 	switch (flags->tls_version) {
12220 	case RTE_SECURITY_VERSION_TLS_1_2:
12221 		max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12222 		break;
12223 	case RTE_SECURITY_VERSION_TLS_1_3:
12224 		max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12225 		break;
12226 	case RTE_SECURITY_VERSION_DTLS_1_2:
12227 		max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12228 		break;
12229 	default:
12230 		max_payload_len = 0;
12231 	}
12232 
12233 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12234 		payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12235 		if (flags->nb_segs_in_mbuf)
12236 			payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12237 
12238 		if (flags->zero_len)
12239 			payload_len = 0;
12240 again:
12241 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12242 						 flags, td_outb, nb_pkts, payload_len);
12243 		if (ret == TEST_SKIPPED)
12244 			continue;
12245 
12246 		if (flags->skip_sess_destroy)
12247 			ut_params->sec_session = sec_session_outb;
12248 
12249 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12250 		if (ret == TEST_SKIPPED)
12251 			continue;
12252 
12253 		if (flags->skip_sess_destroy && sec_session_outb == NULL)
12254 			sec_session_outb = ut_params->sec_session;
12255 
12256 		if (flags->zero_len &&
12257 		    ((flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12258 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12259 		    (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE))) {
12260 			if (ret == TEST_SUCCESS)
12261 				return TEST_FAILED;
12262 			goto skip_decrypt;
12263 		} else if (ret == TEST_FAILED) {
12264 			return TEST_FAILED;
12265 		}
12266 
12267 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12268 
12269 		if (flags->skip_sess_destroy)
12270 			ut_params->sec_session = sec_session_inb;
12271 
12272 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12273 		if (ret == TEST_SKIPPED)
12274 			continue;
12275 
12276 		if (flags->skip_sess_destroy && sec_session_inb == NULL)
12277 			sec_session_inb = ut_params->sec_session;
12278 
12279 		if (flags->pkt_corruption || flags->padding_corruption) {
12280 			if (ret == TEST_SUCCESS)
12281 				return TEST_FAILED;
12282 		} else {
12283 			if (ret == TEST_FAILED)
12284 				return TEST_FAILED;
12285 		}
12286 
12287 skip_decrypt:
12288 		if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12289 			goto again;
12290 
12291 		if (flags->display_alg)
12292 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12293 
12294 		if (flags->skip_sess_destroy) {
12295 			uint8_t dev_id = testsuite_params.valid_devs[0];
12296 			struct rte_security_ctx *ctx;
12297 
12298 			ctx = rte_cryptodev_get_sec_ctx(dev_id);
12299 			if (sec_session_inb != NULL) {
12300 				rte_security_session_destroy(ctx, sec_session_inb);
12301 				sec_session_inb = NULL;
12302 			}
12303 			if (sec_session_outb != NULL) {
12304 				rte_security_session_destroy(ctx, sec_session_outb);
12305 				sec_session_outb = NULL;
12306 			}
12307 			ut_params->sec_session = NULL;
12308 		}
12309 
12310 		pass_cnt++;
12311 	}
12312 
12313 	if (flags->data_walkthrough)
12314 		printf("\t Min payload size: %d, Max payload size: %d\n",
12315 				TLS_RECORD_PLAINTEXT_MIN_LEN, max_payload_len);
12316 
12317 	if (pass_cnt > 0)
12318 		return TEST_SUCCESS;
12319 	else
12320 		return TEST_SKIPPED;
12321 }
12322 
12323 static int
12324 test_tls_1_2_record_proto_data_walkthrough(void)
12325 {
12326 	struct tls_record_test_flags flags;
12327 
12328 	memset(&flags, 0, sizeof(flags));
12329 
12330 	flags.data_walkthrough = true;
12331 	flags.skip_sess_destroy = true;
12332 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12333 
12334 	return test_tls_record_proto_all(&flags);
12335 }
12336 
12337 static int
12338 test_tls_1_2_record_proto_display_list(void)
12339 {
12340 	struct tls_record_test_flags flags;
12341 
12342 	memset(&flags, 0, sizeof(flags));
12343 
12344 	flags.display_alg = true;
12345 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12346 
12347 	return test_tls_record_proto_all(&flags);
12348 }
12349 
12350 static int
12351 test_tls_record_proto_sgl(enum rte_security_tls_version tls_version)
12352 {
12353 	struct tls_record_test_flags flags = {
12354 		.nb_segs_in_mbuf = 5,
12355 		.tls_version = tls_version
12356 	};
12357 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12358 	struct rte_cryptodev_info dev_info;
12359 
12360 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12361 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12362 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12363 		return TEST_SKIPPED;
12364 	}
12365 
12366 	return test_tls_record_proto_all(&flags);
12367 }
12368 
12369 static int
12370 test_tls_1_2_record_proto_sgl(void)
12371 {
12372 	return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_2);
12373 }
12374 
12375 static int
12376 test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12377 {
12378 	struct tls_record_test_flags flags = {
12379 		.nb_segs_in_mbuf = 5,
12380 		.tls_version = tls_version,
12381 		.skip_sess_destroy = true,
12382 		.data_walkthrough = true
12383 	};
12384 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12385 	struct rte_cryptodev_info dev_info;
12386 
12387 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12388 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12389 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12390 		return TEST_SKIPPED;
12391 	}
12392 
12393 	return test_tls_record_proto_all(&flags);
12394 }
12395 
12396 static int
12397 test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12398 {
12399 	struct tls_record_test_flags flags = {
12400 		.nb_segs_in_mbuf = 5,
12401 		.out_of_place = true,
12402 		.tls_version = tls_version
12403 	};
12404 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12405 	struct rte_cryptodev_info dev_info;
12406 
12407 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12408 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12409 		printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12410 		return TEST_SKIPPED;
12411 	}
12412 
12413 	return test_tls_record_proto_all(&flags);
12414 }
12415 
12416 static int
12417 test_tls_1_2_record_proto_sgl_oop(void)
12418 {
12419 	return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12420 }
12421 
12422 static int
12423 test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12424 {
12425 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12426 }
12427 
12428 static int
12429 test_tls_record_proto_corrupt_pkt(void)
12430 {
12431 	struct tls_record_test_flags flags = {
12432 		.pkt_corruption = 1
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 
12442 static int
12443 test_tls_record_proto_custom_content_type(void)
12444 {
12445 	struct tls_record_test_flags flags = {
12446 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12447 	};
12448 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12449 	struct rte_cryptodev_info dev_info;
12450 
12451 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12452 
12453 	return test_tls_record_proto_all(&flags);
12454 }
12455 
12456 static int
12457 test_tls_record_proto_zero_len(void)
12458 {
12459 	struct tls_record_test_flags flags = {
12460 		.zero_len = 1
12461 	};
12462 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12463 	struct rte_cryptodev_info dev_info;
12464 
12465 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12466 
12467 	return test_tls_record_proto_all(&flags);
12468 }
12469 
12470 static int
12471 test_tls_record_proto_zero_len_non_app(void)
12472 {
12473 	struct tls_record_test_flags flags = {
12474 		.zero_len = 1,
12475 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12476 	};
12477 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12478 	struct rte_cryptodev_info dev_info;
12479 
12480 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12481 
12482 	return test_tls_record_proto_all(&flags);
12483 }
12484 
12485 static int
12486 test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12487 				  enum rte_security_tls_version tls_version)
12488 {
12489 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12490 	struct rte_cryptodev_info dev_info;
12491 	struct tls_record_test_flags flags = {
12492 		.nb_segs_in_mbuf = num_segs,
12493 		.tls_version = tls_version,
12494 		.opt_padding = padding
12495 	};
12496 
12497 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12498 
12499 	return test_tls_record_proto_all(&flags);
12500 }
12501 
12502 static int
12503 test_tls_record_proto_dm_opt_padding(void)
12504 {
12505 	return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12506 }
12507 
12508 static int
12509 test_tls_record_proto_dm_opt_padding_1(void)
12510 {
12511 	return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12512 }
12513 
12514 static int
12515 test_tls_record_proto_sg_opt_padding(void)
12516 {
12517 	return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12518 }
12519 
12520 static int
12521 test_tls_record_proto_sg_opt_padding_1(void)
12522 {
12523 	return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12524 }
12525 
12526 static int
12527 test_tls_record_proto_sg_opt_padding_2(void)
12528 {
12529 	return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12530 }
12531 
12532 static int
12533 test_tls_record_proto_sg_opt_padding_max(void)
12534 {
12535 	return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12536 }
12537 
12538 static int
12539 test_tls_record_proto_sg_opt_padding_corrupt(void)
12540 {
12541 	struct tls_record_test_flags flags = {
12542 		.opt_padding = 8,
12543 		.padding_corruption = true,
12544 		.nb_segs_in_mbuf = 4,
12545 	};
12546 
12547 	return test_tls_record_proto_all(&flags);
12548 }
12549 
12550 static int
12551 test_dtls_1_2_record_proto_data_walkthrough(void)
12552 {
12553 	struct tls_record_test_flags flags;
12554 
12555 	memset(&flags, 0, sizeof(flags));
12556 
12557 	flags.data_walkthrough = true;
12558 	flags.skip_sess_destroy = true;
12559 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12560 
12561 	return test_tls_record_proto_all(&flags);
12562 }
12563 
12564 static int
12565 test_dtls_1_2_record_proto_display_list(void)
12566 {
12567 	struct tls_record_test_flags flags;
12568 
12569 	memset(&flags, 0, sizeof(flags));
12570 
12571 	flags.display_alg = true;
12572 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12573 
12574 	return test_tls_record_proto_all(&flags);
12575 }
12576 
12577 static int
12578 test_dtls_pkt_replay(const uint64_t seq_no[],
12579 		      bool replayed_pkt[], uint32_t nb_pkts,
12580 		      struct tls_record_test_flags *flags)
12581 {
12582 	struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12583 	struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12584 	unsigned int i, idx, pass_cnt = 0;
12585 	int ret;
12586 
12587 	for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12588 		ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12589 						 flags, td_outb, nb_pkts, 0);
12590 		if (ret == TEST_SKIPPED)
12591 			continue;
12592 
12593 		for (idx = 0; idx < nb_pkts; idx++)
12594 			td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12595 
12596 		ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12597 		if (ret == TEST_SKIPPED)
12598 			continue;
12599 
12600 		if (ret == TEST_FAILED)
12601 			return TEST_FAILED;
12602 
12603 		test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12604 
12605 		for (idx = 0; idx < nb_pkts; idx++) {
12606 			td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12607 			/* Set antireplay flag for packets to be dropped */
12608 			td_inb[idx].ar_packet = replayed_pkt[idx];
12609 		}
12610 
12611 		ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12612 		if (ret == TEST_SKIPPED)
12613 			continue;
12614 
12615 		if (ret == TEST_FAILED)
12616 			return TEST_FAILED;
12617 
12618 		if (flags->display_alg)
12619 			test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12620 
12621 		pass_cnt++;
12622 	}
12623 
12624 	if (pass_cnt > 0)
12625 		return TEST_SUCCESS;
12626 	else
12627 		return TEST_SKIPPED;
12628 }
12629 
12630 static int
12631 test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12632 {
12633 	struct tls_record_test_flags flags;
12634 	uint32_t nb_pkts = 5;
12635 	bool replayed_pkt[5];
12636 	uint64_t seq_no[5];
12637 
12638 	memset(&flags, 0, sizeof(flags));
12639 
12640 	flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12641 	flags.ar_win_size = winsz;
12642 
12643 	/* 1. Advance the TOP of the window to WS * 2 */
12644 	seq_no[0] = winsz * 2;
12645 	/* 2. Test sequence number within the new window(WS + 1) */
12646 	seq_no[1] = winsz + 1;
12647 	/* 3. Test sequence number less than the window BOTTOM */
12648 	seq_no[2] = winsz;
12649 	/* 4. Test sequence number in the middle of the window */
12650 	seq_no[3] = winsz + (winsz / 2);
12651 	/* 5. Test replay of the packet in the middle of the window */
12652 	seq_no[4] = winsz + (winsz / 2);
12653 
12654 	replayed_pkt[0] = false;
12655 	replayed_pkt[1] = false;
12656 	replayed_pkt[2] = true;
12657 	replayed_pkt[3] = false;
12658 	replayed_pkt[4] = true;
12659 
12660 	return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12661 }
12662 
12663 static int
12664 test_dtls_1_2_record_proto_antireplay64(void)
12665 {
12666 	return test_dtls_1_2_record_proto_antireplay(64);
12667 }
12668 
12669 static int
12670 test_dtls_1_2_record_proto_antireplay128(void)
12671 {
12672 	return test_dtls_1_2_record_proto_antireplay(128);
12673 }
12674 
12675 static int
12676 test_dtls_1_2_record_proto_antireplay256(void)
12677 {
12678 	return test_dtls_1_2_record_proto_antireplay(256);
12679 }
12680 
12681 static int
12682 test_dtls_1_2_record_proto_antireplay512(void)
12683 {
12684 	return test_dtls_1_2_record_proto_antireplay(512);
12685 }
12686 
12687 static int
12688 test_dtls_1_2_record_proto_antireplay1024(void)
12689 {
12690 	return test_dtls_1_2_record_proto_antireplay(1024);
12691 }
12692 
12693 static int
12694 test_dtls_1_2_record_proto_antireplay2048(void)
12695 {
12696 	return test_dtls_1_2_record_proto_antireplay(2048);
12697 }
12698 
12699 static int
12700 test_dtls_1_2_record_proto_antireplay4096(void)
12701 {
12702 	return test_dtls_1_2_record_proto_antireplay(4096);
12703 }
12704 
12705 static int
12706 test_dtls_1_2_record_proto_sgl(void)
12707 {
12708 	return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_DTLS_1_2);
12709 }
12710 
12711 static int
12712 test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12713 {
12714 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12715 }
12716 
12717 static int
12718 test_dtls_1_2_record_proto_sgl_oop(void)
12719 {
12720 	return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_DTLS_1_2);
12721 }
12722 
12723 static int
12724 test_dtls_1_2_record_proto_corrupt_pkt(void)
12725 {
12726 	struct tls_record_test_flags flags = {
12727 		.pkt_corruption = 1,
12728 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12729 	};
12730 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12731 	struct rte_cryptodev_info dev_info;
12732 
12733 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12734 
12735 	return test_tls_record_proto_all(&flags);
12736 }
12737 
12738 static int
12739 test_dtls_1_2_record_proto_custom_content_type(void)
12740 {
12741 	struct tls_record_test_flags flags = {
12742 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12743 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12744 	};
12745 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12746 	struct rte_cryptodev_info dev_info;
12747 
12748 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12749 
12750 	return test_tls_record_proto_all(&flags);
12751 }
12752 
12753 static int
12754 test_dtls_1_2_record_proto_zero_len(void)
12755 {
12756 	struct tls_record_test_flags flags = {
12757 		.zero_len = 1,
12758 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12759 	};
12760 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12761 	struct rte_cryptodev_info dev_info;
12762 
12763 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12764 
12765 	return test_tls_record_proto_all(&flags);
12766 }
12767 
12768 static int
12769 test_dtls_1_2_record_proto_zero_len_non_app(void)
12770 {
12771 	struct tls_record_test_flags flags = {
12772 		.zero_len = 1,
12773 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12774 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12775 	};
12776 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12777 	struct rte_cryptodev_info dev_info;
12778 
12779 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12780 
12781 	return test_tls_record_proto_all(&flags);
12782 }
12783 
12784 static int
12785 test_dtls_1_2_record_proto_dm_opt_padding(void)
12786 {
12787 	return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12788 }
12789 
12790 static int
12791 test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12792 {
12793 	return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12794 }
12795 
12796 static int
12797 test_dtls_1_2_record_proto_sg_opt_padding(void)
12798 {
12799 	return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12800 }
12801 
12802 static int
12803 test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12804 {
12805 	return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12806 }
12807 
12808 static int
12809 test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12810 {
12811 	return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12812 }
12813 
12814 static int
12815 test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12816 {
12817 	return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12818 }
12819 
12820 static int
12821 test_tls_1_3_record_proto_display_list(void)
12822 {
12823 	struct tls_record_test_flags flags;
12824 
12825 	memset(&flags, 0, sizeof(flags));
12826 
12827 	flags.display_alg = true;
12828 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12829 
12830 	return test_tls_record_proto_all(&flags);
12831 }
12832 
12833 static int
12834 test_dtls_1_2_record_proto_sg_opt_padding_corrupt(void)
12835 {
12836 	struct tls_record_test_flags flags = {
12837 		.opt_padding = 8,
12838 		.padding_corruption = true,
12839 		.nb_segs_in_mbuf = 4,
12840 		.tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12841 	};
12842 
12843 	return test_tls_record_proto_all(&flags);
12844 }
12845 
12846 static int
12847 test_tls_1_3_record_proto_corrupt_pkt(void)
12848 {
12849 	struct tls_record_test_flags flags = {
12850 		.pkt_corruption = 1,
12851 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12852 	};
12853 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12854 	struct rte_cryptodev_info dev_info;
12855 
12856 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12857 
12858 	return test_tls_record_proto_all(&flags);
12859 }
12860 
12861 static int
12862 test_tls_1_3_record_proto_custom_content_type(void)
12863 {
12864 	struct tls_record_test_flags flags = {
12865 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12866 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12867 	};
12868 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12869 	struct rte_cryptodev_info dev_info;
12870 
12871 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12872 
12873 	return test_tls_record_proto_all(&flags);
12874 }
12875 
12876 static int
12877 test_tls_1_3_record_proto_zero_len(void)
12878 {
12879 	struct tls_record_test_flags flags = {
12880 		.zero_len = 1,
12881 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12882 	};
12883 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12884 	struct rte_cryptodev_info dev_info;
12885 
12886 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12887 
12888 	return test_tls_record_proto_all(&flags);
12889 }
12890 
12891 static int
12892 test_tls_1_3_record_proto_zero_len_non_app(void)
12893 {
12894 	struct tls_record_test_flags flags = {
12895 		.zero_len = 1,
12896 		.content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12897 		.tls_version = RTE_SECURITY_VERSION_TLS_1_3
12898 	};
12899 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12900 	struct rte_cryptodev_info dev_info;
12901 
12902 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12903 
12904 	return test_tls_record_proto_all(&flags);
12905 }
12906 
12907 static int
12908 test_tls_1_3_record_proto_dm_opt_padding(void)
12909 {
12910 	return test_tls_record_proto_opt_padding(6, 0, RTE_SECURITY_VERSION_TLS_1_3);
12911 }
12912 
12913 static int
12914 test_tls_1_3_record_proto_sg_opt_padding(void)
12915 {
12916 	return test_tls_record_proto_opt_padding(25, 5, RTE_SECURITY_VERSION_TLS_1_3);
12917 }
12918 
12919 static int
12920 test_tls_1_3_record_proto_sg_opt_padding_1(void)
12921 {
12922 	return test_tls_record_proto_opt_padding(25, 4, RTE_SECURITY_VERSION_TLS_1_3);
12923 }
12924 
12925 static int
12926 test_tls_1_3_record_proto_data_walkthrough(void)
12927 {
12928 	struct tls_record_test_flags flags;
12929 
12930 	memset(&flags, 0, sizeof(flags));
12931 
12932 	flags.data_walkthrough = true;
12933 	flags.skip_sess_destroy = true;
12934 	flags.tls_version = RTE_SECURITY_VERSION_TLS_1_3;
12935 
12936 	return test_tls_record_proto_all(&flags);
12937 }
12938 
12939 static int
12940 test_tls_1_3_record_proto_sgl(void)
12941 {
12942 	return test_tls_record_proto_sgl(RTE_SECURITY_VERSION_TLS_1_3);
12943 }
12944 
12945 static int
12946 test_tls_1_3_record_proto_sgl_data_walkthrough(void)
12947 {
12948 	return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_3);
12949 }
12950 
12951 static int
12952 test_tls_1_3_record_proto_sgl_oop(void)
12953 {
12954 	return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_3);
12955 }
12956 
12957 #endif
12958 
12959 static int
12960 test_cryptodev_error_recover_helper_check(void)
12961 {
12962 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12963 	struct rte_cryptodev_info dev_info;
12964 	uint64_t feat_flags;
12965 	int ret;
12966 
12967 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12968 	feat_flags = dev_info.feature_flags;
12969 
12970 	/* Skip the test if queue pair reset is not supported */
12971 	ret = rte_cryptodev_queue_pair_reset(ts_params->valid_devs[0], 0, NULL, 0);
12972 	if (ret == -ENOTSUP)
12973 		return TEST_SKIPPED;
12974 
12975 	ret = rte_cryptodev_qp_depth_used(ts_params->valid_devs[0], 0);
12976 	if (ret == -ENOTSUP)
12977 		return TEST_SKIPPED;
12978 
12979 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
12980 	    ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12981 	     !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12982 		RTE_LOG(INFO, USER1, "Feature flag req for AES Cipheronly, testsuite not met\n");
12983 		return TEST_SKIPPED;
12984 	}
12985 
12986 	return 0;
12987 }
12988 
12989 static int
12990 test_cryptodev_error_recover_helper(uint8_t dev_id, const void *test_data, bool generate_err)
12991 {
12992 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12993 	struct crypto_unittest_params *ut_params = &unittest_params;
12994 	const struct blockcipher_test_data *tdata = test_data;
12995 	uint8_t cipher_key[tdata->cipher_key.len];
12996 	struct rte_crypto_sym_op *sym_op = NULL;
12997 	struct rte_crypto_op *op = NULL;
12998 	char *dst;
12999 
13000 	memcpy(cipher_key, tdata->cipher_key.data, tdata->cipher_key.len);
13001 	ut_params->cipher_xform.next = NULL;
13002 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13003 	ut_params->cipher_xform.cipher.algo = tdata->crypto_algo;
13004 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13005 	ut_params->cipher_xform.cipher.key.data = cipher_key;
13006 	ut_params->cipher_xform.cipher.key.length = tdata->cipher_key.len;
13007 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13008 	ut_params->cipher_xform.cipher.iv.length = tdata->iv.len;
13009 
13010 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id, &ut_params->cipher_xform,
13011 							   ts_params->session_mpool);
13012 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13013 
13014 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13015 	TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
13016 
13017 	memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), tdata->iv.data,
13018 	       tdata->iv.len);
13019 	sym_op = ut_params->op->sym;
13020 	sym_op->cipher.data.offset = tdata->cipher_offset;
13021 	sym_op->cipher.data.length = tdata->ciphertext.len - tdata->cipher_offset;
13022 
13023 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13024 
13025 	if (generate_err) {
13026 		ut_params->ibuf = create_mbuf_from_heap(tdata->ciphertext.len, 0);
13027 		if (ut_params->ibuf == NULL)
13028 			return TEST_FAILED;
13029 		crypto_err = CRYPTODEV_ERR_TRIGGERED;
13030 	} else {
13031 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13032 	}
13033 
13034 	/* clear mbuf payload */
13035 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13036 	       rte_pktmbuf_tailroom(ut_params->ibuf));
13037 
13038 	dst = rte_pktmbuf_mtod_offset(ut_params->ibuf, char *, 0);
13039 	memcpy(dst, tdata->plaintext.data, tdata->plaintext.len);
13040 
13041 	sym_op->m_src = ut_params->ibuf;
13042 	sym_op->m_dst = NULL;
13043 
13044 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
13045 
13046 	if (generate_err) {
13047 		free(ut_params->ibuf);
13048 		ut_params->ibuf = NULL;
13049 		if (op == NULL) {
13050 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13051 			ut_params->sess = NULL;
13052 			return TEST_SUCCESS;
13053 		} else {
13054 			return TEST_FAILED;
13055 		}
13056 	}
13057 
13058 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13059 			  "crypto op processing failed");
13060 
13061 	TEST_ASSERT_BUFFERS_ARE_EQUAL(dst, tdata->ciphertext.data + tdata->cipher_offset,
13062 				      tdata->ciphertext.len - tdata->cipher_offset,
13063 				      "Data not as expected");
13064 
13065 	rte_cryptodev_sym_session_free(ts_params->valid_devs[0], ut_params->sess);
13066 	ut_params->sess = NULL;
13067 
13068 	return TEST_SUCCESS;
13069 }
13070 
13071 /*
13072  * This unit test verifies the recovery of the cryptodev from any fatal error.
13073  * It verifies a single test data multiple times in a iteration. It uses a flag and flips its value
13074  * for every call to helper function.
13075  *
13076  * When the flag is set to 0, the helper function verifies the test data without generating any
13077  * errors, i.e: verifies the default behaviour of the cryptodev.
13078  *
13079  * When the flag is set to 1, the helper function allocates a pointer from heap or non-DMAble
13080  * memory and passes the pointer to cryptodev PMD inorder to generate a fatal error. Once the error
13081  * is generated, it waits till the cryptodev is recoverd from the error.
13082  *
13083  * Iterates the above steps multiple times, to verify the error recovery of cryptodev and behaviour
13084  * of cryptodev after the recovery.
13085  */
13086 static int
13087 test_cryptodev_verify_error_recover(const void *test_data)
13088 {
13089 	int ret = TEST_FAILED;
13090 	int i, num_itr = 5;
13091 
13092 	ret = test_cryptodev_error_recover_helper_check();
13093 	if (ret)
13094 		return ret;
13095 
13096 	TEST_ASSERT_SUCCESS(rte_cryptodev_callback_register(p_testsuite_params->valid_devs[0],
13097 							    RTE_CRYPTODEV_EVENT_ERROR,
13098 							    test_cryptodev_error_cb, NULL),
13099 			    "Failed to register Cryptodev callback");
13100 
13101 	for (i = 0; i < num_itr; i++) {
13102 		int ticks = 0;
13103 
13104 		ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13105 							  test_data, false);
13106 		TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13107 
13108 		/* Generate Error */
13109 		ret = test_cryptodev_error_recover_helper(p_testsuite_params->valid_devs[0],
13110 							  test_data, true);
13111 		TEST_ASSERT_EQUAL(ret, TEST_SUCCESS, "encryption failed");
13112 
13113 		/* Wait till cryptodev recovered from error */
13114 		while (crypto_err == CRYPTODEV_ERR_TRIGGERED) {
13115 			rte_delay_ms(10);
13116 			if (ticks++ > HW_ERR_RECOVER_TIMEOUT)
13117 				return TEST_FAILED;
13118 		}
13119 	}
13120 	TEST_ASSERT_EQUAL(crypto_err, CRYPTODEV_ERR_CLEARED, "cryptodev error recovery failed");
13121 
13122 	return ret;
13123 }
13124 
13125 static int
13126 test_AES_GCM_authenticated_encryption_test_case_1(void)
13127 {
13128 	return test_authenticated_encryption(&gcm_test_case_1);
13129 }
13130 
13131 static int
13132 test_AES_GCM_authenticated_encryption_test_case_2(void)
13133 {
13134 	return test_authenticated_encryption(&gcm_test_case_2);
13135 }
13136 
13137 static int
13138 test_AES_GCM_authenticated_encryption_test_case_3(void)
13139 {
13140 	return test_authenticated_encryption(&gcm_test_case_3);
13141 }
13142 
13143 static int
13144 test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
13145 {
13146 	return test_authenticated_encryption_helper(&gcm_test_case_3, true);
13147 }
13148 
13149 static int
13150 test_AES_GCM_authenticated_encryption_test_case_4(void)
13151 {
13152 	return test_authenticated_encryption(&gcm_test_case_4);
13153 }
13154 
13155 static int
13156 test_AES_GCM_authenticated_encryption_test_case_5(void)
13157 {
13158 	return test_authenticated_encryption(&gcm_test_case_5);
13159 }
13160 
13161 static int
13162 test_AES_GCM_authenticated_encryption_test_case_6(void)
13163 {
13164 	return test_authenticated_encryption(&gcm_test_case_6);
13165 }
13166 
13167 static int
13168 test_AES_GCM_authenticated_encryption_test_case_7(void)
13169 {
13170 	return test_authenticated_encryption(&gcm_test_case_7);
13171 }
13172 
13173 static int
13174 test_AES_GCM_authenticated_encryption_test_case_8(void)
13175 {
13176 	return test_authenticated_encryption(&gcm_test_case_8);
13177 }
13178 
13179 static int
13180 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
13181 {
13182 	return test_authenticated_encryption(&gcm_J0_test_case_1);
13183 }
13184 
13185 static int
13186 test_AES_GCM_auth_encryption_test_case_192_1(void)
13187 {
13188 	return test_authenticated_encryption(&gcm_test_case_192_1);
13189 }
13190 
13191 static int
13192 test_AES_GCM_auth_encryption_test_case_192_2(void)
13193 {
13194 	return test_authenticated_encryption(&gcm_test_case_192_2);
13195 }
13196 
13197 static int
13198 test_AES_GCM_auth_encryption_test_case_192_3(void)
13199 {
13200 	return test_authenticated_encryption(&gcm_test_case_192_3);
13201 }
13202 
13203 static int
13204 test_AES_GCM_auth_encryption_test_case_192_4(void)
13205 {
13206 	return test_authenticated_encryption(&gcm_test_case_192_4);
13207 }
13208 
13209 static int
13210 test_AES_GCM_auth_encryption_test_case_192_5(void)
13211 {
13212 	return test_authenticated_encryption(&gcm_test_case_192_5);
13213 }
13214 
13215 static int
13216 test_AES_GCM_auth_encryption_test_case_192_6(void)
13217 {
13218 	return test_authenticated_encryption(&gcm_test_case_192_6);
13219 }
13220 
13221 static int
13222 test_AES_GCM_auth_encryption_test_case_192_7(void)
13223 {
13224 	return test_authenticated_encryption(&gcm_test_case_192_7);
13225 }
13226 
13227 static int
13228 test_AES_GCM_auth_encryption_test_case_256_1(void)
13229 {
13230 	return test_authenticated_encryption(&gcm_test_case_256_1);
13231 }
13232 
13233 static int
13234 test_AES_GCM_auth_encryption_test_case_256_2(void)
13235 {
13236 	return test_authenticated_encryption(&gcm_test_case_256_2);
13237 }
13238 
13239 static int
13240 test_AES_GCM_auth_encryption_test_case_256_3(void)
13241 {
13242 	return test_authenticated_encryption(&gcm_test_case_256_3);
13243 }
13244 
13245 static int
13246 test_AES_GCM_auth_encryption_test_case_256_4(void)
13247 {
13248 	return test_authenticated_encryption(&gcm_test_case_256_4);
13249 }
13250 
13251 static int
13252 test_AES_GCM_auth_encryption_test_case_256_5(void)
13253 {
13254 	return test_authenticated_encryption(&gcm_test_case_256_5);
13255 }
13256 
13257 static int
13258 test_AES_GCM_auth_encryption_test_case_256_6(void)
13259 {
13260 	return test_authenticated_encryption(&gcm_test_case_256_6);
13261 }
13262 
13263 static int
13264 test_AES_GCM_auth_encryption_test_case_256_7(void)
13265 {
13266 	return test_authenticated_encryption(&gcm_test_case_256_7);
13267 }
13268 
13269 static int
13270 test_AES_GCM_auth_encryption_test_case_aad_1(void)
13271 {
13272 	return test_authenticated_encryption(&gcm_test_case_aad_1);
13273 }
13274 
13275 static int
13276 test_AES_GCM_auth_encryption_test_case_aad_2(void)
13277 {
13278 	return test_authenticated_encryption(&gcm_test_case_aad_2);
13279 }
13280 
13281 static int
13282 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
13283 {
13284 	struct aead_test_data tdata;
13285 	int res;
13286 
13287 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13288 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13289 	tdata.iv.data[0] += 1;
13290 	res = test_authenticated_encryption(&tdata);
13291 	if (res == TEST_SKIPPED)
13292 		return res;
13293 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13294 	return TEST_SUCCESS;
13295 }
13296 
13297 static int
13298 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
13299 {
13300 	struct aead_test_data tdata;
13301 	int res;
13302 
13303 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13304 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13305 	tdata.plaintext.data[0] += 1;
13306 	res = test_authenticated_encryption(&tdata);
13307 	if (res == TEST_SKIPPED)
13308 		return res;
13309 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13310 	return TEST_SUCCESS;
13311 }
13312 
13313 static int
13314 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
13315 {
13316 	struct aead_test_data tdata;
13317 	int res;
13318 
13319 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13320 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13321 	tdata.ciphertext.data[0] += 1;
13322 	res = test_authenticated_encryption(&tdata);
13323 	if (res == TEST_SKIPPED)
13324 		return res;
13325 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13326 	return TEST_SUCCESS;
13327 }
13328 
13329 static int
13330 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
13331 {
13332 	struct aead_test_data tdata;
13333 	int res;
13334 
13335 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13336 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13337 	tdata.aad.len += 1;
13338 	res = test_authenticated_encryption(&tdata);
13339 	if (res == TEST_SKIPPED)
13340 		return res;
13341 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13342 	return TEST_SUCCESS;
13343 }
13344 
13345 static int
13346 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
13347 {
13348 	struct aead_test_data tdata;
13349 	uint8_t aad[gcm_test_case_7.aad.len];
13350 	int res;
13351 
13352 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13353 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13354 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13355 	aad[0] += 1;
13356 	tdata.aad.data = aad;
13357 	res = test_authenticated_encryption(&tdata);
13358 	if (res == TEST_SKIPPED)
13359 		return res;
13360 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13361 	return TEST_SUCCESS;
13362 }
13363 
13364 static int
13365 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
13366 {
13367 	struct aead_test_data tdata;
13368 	int res;
13369 
13370 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13371 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13372 	tdata.auth_tag.data[0] += 1;
13373 	res = test_authenticated_encryption(&tdata);
13374 	if (res == TEST_SKIPPED)
13375 		return res;
13376 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
13377 	return TEST_SUCCESS;
13378 }
13379 
13380 static int
13381 test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
13382 {
13383 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13384 	struct crypto_unittest_params *ut_params = &unittest_params;
13385 
13386 	int retval;
13387 	uint8_t *plaintext;
13388 	uint32_t i;
13389 	struct rte_cryptodev_info dev_info;
13390 
13391 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13392 	uint64_t feat_flags = dev_info.feature_flags;
13393 
13394 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13395 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13396 		printf("Device doesn't support RAW data-path APIs.\n");
13397 		return TEST_SKIPPED;
13398 	}
13399 
13400 	/* Verify the capabilities */
13401 	struct rte_cryptodev_sym_capability_idx cap_idx;
13402 	const struct rte_cryptodev_symmetric_capability *capability;
13403 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13404 	cap_idx.algo.aead = tdata->algo;
13405 	capability = rte_cryptodev_sym_capability_get(
13406 			ts_params->valid_devs[0], &cap_idx);
13407 	if (capability == NULL)
13408 		return TEST_SKIPPED;
13409 	if (rte_cryptodev_sym_capability_check_aead(
13410 			capability, tdata->key.len, tdata->auth_tag.len,
13411 			tdata->aad.len, tdata->iv.len))
13412 		return TEST_SKIPPED;
13413 
13414 	/* Create AEAD session */
13415 	retval = create_aead_session(ts_params->valid_devs[0],
13416 			tdata->algo,
13417 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13418 			tdata->key.data, tdata->key.len,
13419 			tdata->aad.len, tdata->auth_tag.len,
13420 			tdata->iv.len);
13421 	if (retval != TEST_SUCCESS)
13422 		return retval;
13423 
13424 	/* alloc mbuf and set payload */
13425 	if (tdata->aad.len > MBUF_SIZE) {
13426 		if (use_ext_mbuf) {
13427 			ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
13428 							  AEAD_TEXT_MAX_LENGTH,
13429 							  1 /* nb_segs */,
13430 							  NULL);
13431 		} else {
13432 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13433 		}
13434 		/* Populate full size of add data */
13435 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
13436 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
13437 	} else {
13438 		if (use_ext_mbuf) {
13439 			ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
13440 							  AEAD_TEXT_MAX_LENGTH,
13441 							  1 /* nb_segs */,
13442 							  NULL);
13443 		} else {
13444 			ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13445 		}
13446 	}
13447 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13448 			rte_pktmbuf_tailroom(ut_params->ibuf));
13449 
13450 	/* Create AEAD operation */
13451 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13452 	if (retval < 0)
13453 		return retval;
13454 
13455 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13456 
13457 	ut_params->op->sym->m_src = ut_params->ibuf;
13458 
13459 	/* Process crypto operation */
13460 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13461 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13462 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13463 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13464 					       0);
13465 		if (retval != TEST_SUCCESS)
13466 			return retval;
13467 	} else
13468 		TEST_ASSERT_NOT_NULL(
13469 			process_crypto_request(ts_params->valid_devs[0],
13470 			ut_params->op), "failed to process sym crypto op");
13471 
13472 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13473 			"crypto op processing failed");
13474 
13475 	if (ut_params->op->sym->m_dst)
13476 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
13477 				uint8_t *);
13478 	else
13479 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13480 				uint8_t *,
13481 				ut_params->op->sym->cipher.data.offset);
13482 
13483 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13484 
13485 	/* Validate obuf */
13486 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13487 			plaintext,
13488 			tdata->plaintext.data,
13489 			tdata->plaintext.len,
13490 			"Plaintext data not as expected");
13491 
13492 	TEST_ASSERT_EQUAL(ut_params->op->status,
13493 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13494 			"Authentication failed");
13495 
13496 	return 0;
13497 }
13498 
13499 static int
13500 test_authenticated_decryption(const struct aead_test_data *tdata)
13501 {
13502 	return test_authenticated_decryption_helper(tdata, false);
13503 }
13504 
13505 static int
13506 test_AES_GCM_authenticated_decryption_test_case_1(void)
13507 {
13508 	return test_authenticated_decryption(&gcm_test_case_1);
13509 }
13510 
13511 static int
13512 test_AES_GCM_authenticated_decryption_test_case_2(void)
13513 {
13514 	return test_authenticated_decryption(&gcm_test_case_2);
13515 }
13516 
13517 static int
13518 test_AES_GCM_authenticated_decryption_test_case_3(void)
13519 {
13520 	return test_authenticated_decryption(&gcm_test_case_3);
13521 }
13522 
13523 static int
13524 test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13525 {
13526 	return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13527 }
13528 
13529 static int
13530 test_AES_GCM_authenticated_decryption_test_case_4(void)
13531 {
13532 	return test_authenticated_decryption(&gcm_test_case_4);
13533 }
13534 
13535 static int
13536 test_AES_GCM_authenticated_decryption_test_case_5(void)
13537 {
13538 	return test_authenticated_decryption(&gcm_test_case_5);
13539 }
13540 
13541 static int
13542 test_AES_GCM_authenticated_decryption_test_case_6(void)
13543 {
13544 	return test_authenticated_decryption(&gcm_test_case_6);
13545 }
13546 
13547 static int
13548 test_AES_GCM_authenticated_decryption_test_case_7(void)
13549 {
13550 	return test_authenticated_decryption(&gcm_test_case_7);
13551 }
13552 
13553 static int
13554 test_AES_GCM_authenticated_decryption_test_case_8(void)
13555 {
13556 	return test_authenticated_decryption(&gcm_test_case_8);
13557 }
13558 
13559 static int
13560 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13561 {
13562 	return test_authenticated_decryption(&gcm_J0_test_case_1);
13563 }
13564 
13565 static int
13566 test_AES_GCM_auth_decryption_test_case_192_1(void)
13567 {
13568 	return test_authenticated_decryption(&gcm_test_case_192_1);
13569 }
13570 
13571 static int
13572 test_AES_GCM_auth_decryption_test_case_192_2(void)
13573 {
13574 	return test_authenticated_decryption(&gcm_test_case_192_2);
13575 }
13576 
13577 static int
13578 test_AES_GCM_auth_decryption_test_case_192_3(void)
13579 {
13580 	return test_authenticated_decryption(&gcm_test_case_192_3);
13581 }
13582 
13583 static int
13584 test_AES_GCM_auth_decryption_test_case_192_4(void)
13585 {
13586 	return test_authenticated_decryption(&gcm_test_case_192_4);
13587 }
13588 
13589 static int
13590 test_AES_GCM_auth_decryption_test_case_192_5(void)
13591 {
13592 	return test_authenticated_decryption(&gcm_test_case_192_5);
13593 }
13594 
13595 static int
13596 test_AES_GCM_auth_decryption_test_case_192_6(void)
13597 {
13598 	return test_authenticated_decryption(&gcm_test_case_192_6);
13599 }
13600 
13601 static int
13602 test_AES_GCM_auth_decryption_test_case_192_7(void)
13603 {
13604 	return test_authenticated_decryption(&gcm_test_case_192_7);
13605 }
13606 
13607 static int
13608 test_AES_GCM_auth_decryption_test_case_256_1(void)
13609 {
13610 	return test_authenticated_decryption(&gcm_test_case_256_1);
13611 }
13612 
13613 static int
13614 test_AES_GCM_auth_decryption_test_case_256_2(void)
13615 {
13616 	return test_authenticated_decryption(&gcm_test_case_256_2);
13617 }
13618 
13619 static int
13620 test_AES_GCM_auth_decryption_test_case_256_3(void)
13621 {
13622 	return test_authenticated_decryption(&gcm_test_case_256_3);
13623 }
13624 
13625 static int
13626 test_AES_GCM_auth_decryption_test_case_256_4(void)
13627 {
13628 	return test_authenticated_decryption(&gcm_test_case_256_4);
13629 }
13630 
13631 static int
13632 test_AES_GCM_auth_decryption_test_case_256_5(void)
13633 {
13634 	return test_authenticated_decryption(&gcm_test_case_256_5);
13635 }
13636 
13637 static int
13638 test_AES_GCM_auth_decryption_test_case_256_6(void)
13639 {
13640 	return test_authenticated_decryption(&gcm_test_case_256_6);
13641 }
13642 
13643 static int
13644 test_AES_GCM_auth_decryption_test_case_256_7(void)
13645 {
13646 	return test_authenticated_decryption(&gcm_test_case_256_7);
13647 }
13648 
13649 static int
13650 test_AES_GCM_auth_decryption_test_case_256_8(void)
13651 {
13652 	return test_authenticated_decryption(&gcm_test_case_256_8);
13653 }
13654 
13655 static int
13656 test_AES_GCM_auth_encryption_test_case_256_8(void)
13657 {
13658 	return test_authenticated_encryption(&gcm_test_case_256_8);
13659 }
13660 
13661 static int
13662 test_AES_GCM_auth_decryption_test_case_aad_1(void)
13663 {
13664 	return test_authenticated_decryption(&gcm_test_case_aad_1);
13665 }
13666 
13667 static int
13668 test_AES_GCM_auth_decryption_test_case_aad_2(void)
13669 {
13670 	return test_authenticated_decryption(&gcm_test_case_aad_2);
13671 }
13672 
13673 static int
13674 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13675 {
13676 	struct aead_test_data tdata;
13677 	int res;
13678 
13679 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13680 	tdata.iv.data[0] += 1;
13681 	res = test_authenticated_decryption(&tdata);
13682 	if (res == TEST_SKIPPED)
13683 		return res;
13684 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13685 	return TEST_SUCCESS;
13686 }
13687 
13688 static int
13689 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13690 {
13691 	struct aead_test_data tdata;
13692 	int res;
13693 
13694 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13695 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13696 	tdata.plaintext.data[0] += 1;
13697 	res = test_authenticated_decryption(&tdata);
13698 	if (res == TEST_SKIPPED)
13699 		return res;
13700 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13701 	return TEST_SUCCESS;
13702 }
13703 
13704 static int
13705 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13706 {
13707 	struct aead_test_data tdata;
13708 	int res;
13709 
13710 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13711 	tdata.ciphertext.data[0] += 1;
13712 	res = test_authenticated_decryption(&tdata);
13713 	if (res == TEST_SKIPPED)
13714 		return res;
13715 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13716 	return TEST_SUCCESS;
13717 }
13718 
13719 static int
13720 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13721 {
13722 	struct aead_test_data tdata;
13723 	int res;
13724 
13725 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13726 	tdata.aad.len += 1;
13727 	res = test_authenticated_decryption(&tdata);
13728 	if (res == TEST_SKIPPED)
13729 		return res;
13730 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13731 	return TEST_SUCCESS;
13732 }
13733 
13734 static int
13735 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13736 {
13737 	struct aead_test_data tdata;
13738 	uint8_t aad[gcm_test_case_7.aad.len];
13739 	int res;
13740 
13741 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13742 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13743 	aad[0] += 1;
13744 	tdata.aad.data = aad;
13745 	res = test_authenticated_decryption(&tdata);
13746 	if (res == TEST_SKIPPED)
13747 		return res;
13748 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13749 	return TEST_SUCCESS;
13750 }
13751 
13752 static int
13753 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13754 {
13755 	struct aead_test_data tdata;
13756 	int res;
13757 
13758 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13759 	tdata.auth_tag.data[0] += 1;
13760 	res = test_authenticated_decryption(&tdata);
13761 	if (res == TEST_SKIPPED)
13762 		return res;
13763 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13764 	return TEST_SUCCESS;
13765 }
13766 
13767 static int
13768 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13769 {
13770 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13771 	struct crypto_unittest_params *ut_params = &unittest_params;
13772 
13773 	int retval;
13774 	uint8_t *ciphertext, *auth_tag;
13775 	uint16_t plaintext_pad_len;
13776 	struct rte_cryptodev_info dev_info;
13777 
13778 	/* Verify the capabilities */
13779 	struct rte_cryptodev_sym_capability_idx cap_idx;
13780 	const struct rte_cryptodev_symmetric_capability *capability;
13781 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13782 	cap_idx.algo.aead = tdata->algo;
13783 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13784 	if (capability == NULL)
13785 		return TEST_SKIPPED;
13786 	if (rte_cryptodev_sym_capability_check_aead(
13787 		capability, tdata->key.len, tdata->auth_tag.len,
13788 		tdata->aad.len, tdata->iv.len))
13789 		return TEST_SKIPPED;
13790 
13791 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13792 	uint64_t feat_flags = dev_info.feature_flags;
13793 
13794 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13795 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13796 		return TEST_SKIPPED;
13797 
13798 	/* not supported with CPU crypto */
13799 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13800 		return TEST_SKIPPED;
13801 
13802 	/* Create AEAD session */
13803 	retval = create_aead_session(ts_params->valid_devs[0],
13804 			tdata->algo,
13805 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13806 			tdata->key.data, tdata->key.len,
13807 			tdata->aad.len, tdata->auth_tag.len,
13808 			tdata->iv.len);
13809 	if (retval < 0)
13810 		return retval;
13811 
13812 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13813 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13814 
13815 	/* clear mbuf payload */
13816 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13817 			rte_pktmbuf_tailroom(ut_params->ibuf));
13818 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13819 			rte_pktmbuf_tailroom(ut_params->obuf));
13820 
13821 	/* Create AEAD operation */
13822 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13823 	if (retval < 0)
13824 		return retval;
13825 
13826 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13827 
13828 	ut_params->op->sym->m_src = ut_params->ibuf;
13829 	ut_params->op->sym->m_dst = ut_params->obuf;
13830 
13831 	/* Process crypto operation */
13832 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13833 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13834 					       0);
13835 		if (retval != TEST_SUCCESS)
13836 			return retval;
13837 	} else
13838 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13839 			ut_params->op), "failed to process sym crypto op");
13840 
13841 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13842 			"crypto op processing failed");
13843 
13844 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13845 
13846 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13847 			ut_params->op->sym->cipher.data.offset);
13848 	auth_tag = ciphertext + plaintext_pad_len;
13849 
13850 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13851 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13852 
13853 	/* Validate obuf */
13854 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13855 			ciphertext,
13856 			tdata->ciphertext.data,
13857 			tdata->ciphertext.len,
13858 			"Ciphertext data not as expected");
13859 
13860 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13861 			auth_tag,
13862 			tdata->auth_tag.data,
13863 			tdata->auth_tag.len,
13864 			"Generated auth tag not as expected");
13865 
13866 	return 0;
13867 
13868 }
13869 
13870 static int
13871 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13872 {
13873 	return test_authenticated_encryption_oop(&gcm_test_case_5);
13874 }
13875 
13876 static int
13877 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13878 {
13879 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13880 	struct crypto_unittest_params *ut_params = &unittest_params;
13881 
13882 	int retval;
13883 	uint8_t *plaintext;
13884 	struct rte_cryptodev_info dev_info;
13885 
13886 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13887 	uint64_t feat_flags = dev_info.feature_flags;
13888 
13889 	/* Verify the capabilities */
13890 	struct rte_cryptodev_sym_capability_idx cap_idx;
13891 	const struct rte_cryptodev_symmetric_capability *capability;
13892 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13893 	cap_idx.algo.aead = tdata->algo;
13894 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13895 
13896 	if (capability == NULL)
13897 		return TEST_SKIPPED;
13898 
13899 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13900 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13901 		return TEST_SKIPPED;
13902 
13903 	/* not supported with CPU crypto and raw data-path APIs*/
13904 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13905 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
13906 		return TEST_SKIPPED;
13907 
13908 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13909 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13910 		printf("Device does not support RAW data-path APIs.\n");
13911 		return TEST_SKIPPED;
13912 	}
13913 
13914 	/* Create AEAD session */
13915 	retval = create_aead_session(ts_params->valid_devs[0],
13916 			tdata->algo,
13917 			RTE_CRYPTO_AEAD_OP_DECRYPT,
13918 			tdata->key.data, tdata->key.len,
13919 			tdata->aad.len, tdata->auth_tag.len,
13920 			tdata->iv.len);
13921 	if (retval < 0)
13922 		return retval;
13923 
13924 	/* alloc mbuf and set payload */
13925 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13926 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13927 
13928 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13929 			rte_pktmbuf_tailroom(ut_params->ibuf));
13930 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13931 			rte_pktmbuf_tailroom(ut_params->obuf));
13932 
13933 	/* Create AEAD operation */
13934 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13935 	if (retval < 0)
13936 		return retval;
13937 
13938 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13939 
13940 	ut_params->op->sym->m_src = ut_params->ibuf;
13941 	ut_params->op->sym->m_dst = ut_params->obuf;
13942 
13943 	/* Process crypto operation */
13944 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13945 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13946 					       0);
13947 		if (retval != TEST_SUCCESS)
13948 			return retval;
13949 	} else
13950 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13951 			ut_params->op), "failed to process sym crypto op");
13952 
13953 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13954 			"crypto op processing failed");
13955 
13956 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13957 			ut_params->op->sym->cipher.data.offset);
13958 
13959 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13960 
13961 	/* Validate obuf */
13962 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13963 			plaintext,
13964 			tdata->plaintext.data,
13965 			tdata->plaintext.len,
13966 			"Plaintext data not as expected");
13967 
13968 	TEST_ASSERT_EQUAL(ut_params->op->status,
13969 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13970 			"Authentication failed");
13971 	return 0;
13972 }
13973 
13974 static int
13975 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
13976 {
13977 	return test_authenticated_decryption_oop(&gcm_test_case_5);
13978 }
13979 
13980 static int
13981 test_authenticated_encryption_sessionless(
13982 		const struct aead_test_data *tdata)
13983 {
13984 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13985 	struct crypto_unittest_params *ut_params = &unittest_params;
13986 
13987 	int retval;
13988 	uint8_t *ciphertext, *auth_tag;
13989 	uint16_t plaintext_pad_len;
13990 	uint8_t key[tdata->key.len + 1];
13991 	struct rte_cryptodev_info dev_info;
13992 
13993 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13994 	uint64_t feat_flags = dev_info.feature_flags;
13995 
13996 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13997 		printf("Device doesn't support Sessionless ops.\n");
13998 		return TEST_SKIPPED;
13999 	}
14000 
14001 	/* not supported with CPU crypto */
14002 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14003 		return TEST_SKIPPED;
14004 
14005 	/* Verify the capabilities */
14006 	struct rte_cryptodev_sym_capability_idx cap_idx;
14007 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14008 	cap_idx.algo.aead = tdata->algo;
14009 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14010 			&cap_idx) == NULL)
14011 		return TEST_SKIPPED;
14012 
14013 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14014 
14015 	/* clear mbuf payload */
14016 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14017 			rte_pktmbuf_tailroom(ut_params->ibuf));
14018 
14019 	/* Create AEAD operation */
14020 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
14021 	if (retval < 0)
14022 		return retval;
14023 
14024 	/* Create GCM xform */
14025 	memcpy(key, tdata->key.data, tdata->key.len);
14026 	retval = create_aead_xform(ut_params->op,
14027 			tdata->algo,
14028 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
14029 			key, tdata->key.len,
14030 			tdata->aad.len, tdata->auth_tag.len,
14031 			tdata->iv.len);
14032 	if (retval < 0)
14033 		return retval;
14034 
14035 	ut_params->op->sym->m_src = ut_params->ibuf;
14036 
14037 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14038 			RTE_CRYPTO_OP_SESSIONLESS,
14039 			"crypto op session type not sessionless");
14040 
14041 	/* Process crypto operation */
14042 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
14043 			ut_params->op), "failed to process sym crypto op");
14044 
14045 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14046 
14047 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14048 			"crypto op status not success");
14049 
14050 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14051 
14052 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14053 			ut_params->op->sym->cipher.data.offset);
14054 	auth_tag = ciphertext + plaintext_pad_len;
14055 
14056 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
14057 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
14058 
14059 	/* Validate obuf */
14060 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14061 			ciphertext,
14062 			tdata->ciphertext.data,
14063 			tdata->ciphertext.len,
14064 			"Ciphertext data not as expected");
14065 
14066 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14067 			auth_tag,
14068 			tdata->auth_tag.data,
14069 			tdata->auth_tag.len,
14070 			"Generated auth tag not as expected");
14071 
14072 	return 0;
14073 
14074 }
14075 
14076 static int
14077 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
14078 {
14079 	return test_authenticated_encryption_sessionless(
14080 			&gcm_test_case_5);
14081 }
14082 
14083 static int
14084 test_authenticated_decryption_sessionless(
14085 		const struct aead_test_data *tdata)
14086 {
14087 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14088 	struct crypto_unittest_params *ut_params = &unittest_params;
14089 
14090 	int retval;
14091 	uint8_t *plaintext;
14092 	uint8_t key[tdata->key.len + 1];
14093 	struct rte_cryptodev_info dev_info;
14094 
14095 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14096 	uint64_t feat_flags = dev_info.feature_flags;
14097 
14098 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
14099 		printf("Device doesn't support Sessionless ops.\n");
14100 		return TEST_SKIPPED;
14101 	}
14102 
14103 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14104 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14105 		printf("Device doesn't support RAW data-path APIs.\n");
14106 		return TEST_SKIPPED;
14107 	}
14108 
14109 	/* not supported with CPU crypto */
14110 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14111 		return TEST_SKIPPED;
14112 
14113 	/* Verify the capabilities */
14114 	struct rte_cryptodev_sym_capability_idx cap_idx;
14115 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14116 	cap_idx.algo.aead = tdata->algo;
14117 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14118 			&cap_idx) == NULL)
14119 		return TEST_SKIPPED;
14120 
14121 	/* alloc mbuf and set payload */
14122 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14123 
14124 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14125 			rte_pktmbuf_tailroom(ut_params->ibuf));
14126 
14127 	/* Create AEAD operation */
14128 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
14129 	if (retval < 0)
14130 		return retval;
14131 
14132 	/* Create AEAD xform */
14133 	memcpy(key, tdata->key.data, tdata->key.len);
14134 	retval = create_aead_xform(ut_params->op,
14135 			tdata->algo,
14136 			RTE_CRYPTO_AEAD_OP_DECRYPT,
14137 			key, tdata->key.len,
14138 			tdata->aad.len, tdata->auth_tag.len,
14139 			tdata->iv.len);
14140 	if (retval < 0)
14141 		return retval;
14142 
14143 	ut_params->op->sym->m_src = ut_params->ibuf;
14144 
14145 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
14146 			RTE_CRYPTO_OP_SESSIONLESS,
14147 			"crypto op session type not sessionless");
14148 
14149 	/* Process crypto operation */
14150 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14151 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
14152 					       0);
14153 		if (retval != TEST_SUCCESS)
14154 			return retval;
14155 	} else
14156 		TEST_ASSERT_NOT_NULL(process_crypto_request(
14157 			ts_params->valid_devs[0], ut_params->op),
14158 				"failed to process sym crypto op");
14159 
14160 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14161 
14162 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14163 			"crypto op status not success");
14164 
14165 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14166 			ut_params->op->sym->cipher.data.offset);
14167 
14168 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
14169 
14170 	/* Validate obuf */
14171 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14172 			plaintext,
14173 			tdata->plaintext.data,
14174 			tdata->plaintext.len,
14175 			"Plaintext data not as expected");
14176 
14177 	TEST_ASSERT_EQUAL(ut_params->op->status,
14178 			RTE_CRYPTO_OP_STATUS_SUCCESS,
14179 			"Authentication failed");
14180 	return 0;
14181 }
14182 
14183 static int
14184 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
14185 {
14186 	return test_authenticated_decryption_sessionless(
14187 			&gcm_test_case_5);
14188 }
14189 
14190 static int
14191 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
14192 {
14193 	return test_authenticated_encryption(&ccm_test_case_128_1);
14194 }
14195 
14196 static int
14197 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
14198 {
14199 	return test_authenticated_encryption(&ccm_test_case_128_2);
14200 }
14201 
14202 static int
14203 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
14204 {
14205 	return test_authenticated_encryption(&ccm_test_case_128_3);
14206 }
14207 
14208 static int
14209 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
14210 {
14211 	return test_authenticated_decryption(&ccm_test_case_128_1);
14212 }
14213 
14214 static int
14215 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
14216 {
14217 	return test_authenticated_decryption(&ccm_test_case_128_2);
14218 }
14219 
14220 static int
14221 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
14222 {
14223 	return test_authenticated_decryption(&ccm_test_case_128_3);
14224 }
14225 
14226 static int
14227 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
14228 {
14229 	return test_authenticated_encryption(&ccm_test_case_192_1);
14230 }
14231 
14232 static int
14233 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
14234 {
14235 	return test_authenticated_encryption(&ccm_test_case_192_2);
14236 }
14237 
14238 static int
14239 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
14240 {
14241 	return test_authenticated_encryption(&ccm_test_case_192_3);
14242 }
14243 
14244 static int
14245 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
14246 {
14247 	return test_authenticated_decryption(&ccm_test_case_192_1);
14248 }
14249 
14250 static int
14251 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
14252 {
14253 	return test_authenticated_decryption(&ccm_test_case_192_2);
14254 }
14255 
14256 static int
14257 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
14258 {
14259 	return test_authenticated_decryption(&ccm_test_case_192_3);
14260 }
14261 
14262 static int
14263 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
14264 {
14265 	return test_authenticated_encryption(&ccm_test_case_256_1);
14266 }
14267 
14268 static int
14269 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
14270 {
14271 	return test_authenticated_encryption(&ccm_test_case_256_2);
14272 }
14273 
14274 static int
14275 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
14276 {
14277 	return test_authenticated_encryption(&ccm_test_case_256_3);
14278 }
14279 
14280 static int
14281 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
14282 {
14283 	return test_authenticated_decryption(&ccm_test_case_256_1);
14284 }
14285 
14286 static int
14287 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
14288 {
14289 	return test_authenticated_decryption(&ccm_test_case_256_2);
14290 }
14291 
14292 static int
14293 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
14294 {
14295 	return test_authenticated_decryption(&ccm_test_case_256_3);
14296 }
14297 
14298 static int
14299 test_stats(void)
14300 {
14301 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14302 	struct rte_cryptodev_stats stats;
14303 
14304 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14305 		return TEST_SKIPPED;
14306 
14307 	/* Verify the capabilities */
14308 	struct rte_cryptodev_sym_capability_idx cap_idx;
14309 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14310 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
14311 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14312 			&cap_idx) == NULL)
14313 		return TEST_SKIPPED;
14314 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14315 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14316 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14317 			&cap_idx) == NULL)
14318 		return TEST_SKIPPED;
14319 
14320 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
14321 			== -ENOTSUP)
14322 		return TEST_SKIPPED;
14323 
14324 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14325 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
14326 			&stats) == -ENODEV),
14327 		"rte_cryptodev_stats_get invalid dev failed");
14328 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
14329 		"rte_cryptodev_stats_get invalid Param failed");
14330 
14331 	/* Test expected values */
14332 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
14333 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14334 			&stats),
14335 		"rte_cryptodev_stats_get failed");
14336 	TEST_ASSERT((stats.enqueued_count == 1),
14337 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
14338 	TEST_ASSERT((stats.dequeued_count == 1),
14339 		"rte_cryptodev_stats_get returned unexpected dequeued stat");
14340 	TEST_ASSERT((stats.enqueue_err_count == 0),
14341 		"rte_cryptodev_stats_get returned unexpected enqueued error count stat");
14342 	TEST_ASSERT((stats.dequeue_err_count == 0),
14343 		"rte_cryptodev_stats_get returned unexpected dequeued error count stat");
14344 
14345 	/* invalid device but should ignore and not reset device stats*/
14346 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
14347 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14348 			&stats),
14349 		"rte_cryptodev_stats_get failed");
14350 	TEST_ASSERT((stats.enqueued_count == 1),
14351 		"rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
14352 
14353 	/* check that a valid reset clears stats */
14354 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
14355 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
14356 			&stats),
14357 					  "rte_cryptodev_stats_get failed");
14358 	TEST_ASSERT((stats.enqueued_count == 0),
14359 		"rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
14360 	TEST_ASSERT((stats.dequeued_count == 0),
14361 		"rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
14362 
14363 	return TEST_SUCCESS;
14364 }
14365 
14366 static int
14367 test_device_reconfigure(void)
14368 {
14369 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14370 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
14371 	struct rte_cryptodev_qp_conf qp_conf = {
14372 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT,
14373 		.mp_session = ts_params->session_mpool
14374 	};
14375 	uint16_t qp_id, dev_id, num_devs = 0;
14376 
14377 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
14378 			"Need at least %d devices for test", 1);
14379 
14380 	dev_id = ts_params->valid_devs[0];
14381 
14382 	/* Stop the device in case it's started so it can be configured */
14383 	rte_cryptodev_stop(dev_id);
14384 
14385 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14386 			"Failed test for rte_cryptodev_configure: "
14387 			"dev_num %u", dev_id);
14388 
14389 	/* Reconfigure with same configure params */
14390 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
14391 			"Failed test for rte_cryptodev_configure: "
14392 			"dev_num %u", dev_id);
14393 
14394 	/* Reconfigure with just one queue pair */
14395 	ts_params->conf.nb_queue_pairs = 1;
14396 
14397 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14398 			&ts_params->conf),
14399 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
14400 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14401 
14402 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14403 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14404 				ts_params->valid_devs[0], qp_id, &qp_conf,
14405 				rte_cryptodev_socket_id(
14406 						ts_params->valid_devs[0])),
14407 				"Failed test for "
14408 				"rte_cryptodev_queue_pair_setup: num_inflights "
14409 				"%u on qp %u on cryptodev %u",
14410 				qp_conf.nb_descriptors, qp_id,
14411 				ts_params->valid_devs[0]);
14412 	}
14413 
14414 	/* Reconfigure with max number of queue pairs */
14415 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
14416 
14417 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14418 			&ts_params->conf),
14419 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
14420 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
14421 
14422 	qp_conf.mp_session = ts_params->session_mpool;
14423 
14424 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
14425 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14426 				ts_params->valid_devs[0], qp_id, &qp_conf,
14427 				rte_cryptodev_socket_id(
14428 						ts_params->valid_devs[0])),
14429 				"Failed test for "
14430 				"rte_cryptodev_queue_pair_setup: num_inflights "
14431 				"%u on qp %u on cryptodev %u",
14432 				qp_conf.nb_descriptors, qp_id,
14433 				ts_params->valid_devs[0]);
14434 	}
14435 
14436 	/* Start the device */
14437 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
14438 			"Failed to start cryptodev %u",
14439 			ts_params->valid_devs[0]);
14440 
14441 	/* Test expected values */
14442 	return test_AES_CBC_HMAC_SHA1_encrypt_digest();
14443 }
14444 
14445 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
14446 				   struct crypto_unittest_params *ut_params,
14447 				   enum rte_crypto_auth_operation op,
14448 				   const struct HMAC_MD5_vector *test_case)
14449 {
14450 	uint8_t key[64];
14451 
14452 	memcpy(key, test_case->key.data, test_case->key.len);
14453 
14454 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14455 	ut_params->auth_xform.next = NULL;
14456 	ut_params->auth_xform.auth.op = op;
14457 
14458 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
14459 
14460 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
14461 	ut_params->auth_xform.auth.key.length = test_case->key.len;
14462 	ut_params->auth_xform.auth.key.data = key;
14463 
14464 	ut_params->sess = rte_cryptodev_sym_session_create(
14465 		ts_params->valid_devs[0], &ut_params->auth_xform,
14466 			ts_params->session_mpool);
14467 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14468 		return TEST_SKIPPED;
14469 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14470 
14471 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14472 
14473 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14474 			rte_pktmbuf_tailroom(ut_params->ibuf));
14475 
14476 	return 0;
14477 }
14478 
14479 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
14480 			      const struct HMAC_MD5_vector *test_case,
14481 			      uint8_t **plaintext)
14482 {
14483 	uint16_t plaintext_pad_len;
14484 
14485 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14486 
14487 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14488 				16);
14489 
14490 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14491 			plaintext_pad_len);
14492 	memcpy(*plaintext, test_case->plaintext.data,
14493 			test_case->plaintext.len);
14494 
14495 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14496 			ut_params->ibuf, MD5_DIGEST_LEN);
14497 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14498 			"no room to append digest");
14499 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14500 			ut_params->ibuf, plaintext_pad_len);
14501 
14502 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14503 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14504 			   test_case->auth_tag.len);
14505 	}
14506 
14507 	sym_op->auth.data.offset = 0;
14508 	sym_op->auth.data.length = test_case->plaintext.len;
14509 
14510 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14511 	ut_params->op->sym->m_src = ut_params->ibuf;
14512 
14513 	return 0;
14514 }
14515 
14516 static int
14517 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14518 {
14519 	uint16_t plaintext_pad_len;
14520 	uint8_t *plaintext, *auth_tag;
14521 	int ret;
14522 
14523 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14524 	struct crypto_unittest_params *ut_params = &unittest_params;
14525 	struct rte_cryptodev_info dev_info;
14526 
14527 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14528 	uint64_t feat_flags = dev_info.feature_flags;
14529 
14530 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14531 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14532 		printf("Device doesn't support RAW data-path APIs.\n");
14533 		return TEST_SKIPPED;
14534 	}
14535 
14536 	/* Verify the capabilities */
14537 	struct rte_cryptodev_sym_capability_idx cap_idx;
14538 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14539 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14540 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14541 			&cap_idx) == NULL)
14542 		return TEST_SKIPPED;
14543 
14544 	if (MD5_HMAC_create_session(ts_params, ut_params,
14545 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14546 		return TEST_FAILED;
14547 
14548 	/* Generate Crypto op data structure */
14549 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14550 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14551 	TEST_ASSERT_NOT_NULL(ut_params->op,
14552 			"Failed to allocate symmetric crypto operation struct");
14553 
14554 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14555 				16);
14556 
14557 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14558 		return TEST_FAILED;
14559 
14560 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14561 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14562 			ut_params->op);
14563 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14564 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14565 		if (ret != TEST_SUCCESS)
14566 			return ret;
14567 	} else
14568 		TEST_ASSERT_NOT_NULL(
14569 			process_crypto_request(ts_params->valid_devs[0],
14570 				ut_params->op),
14571 				"failed to process sym crypto op");
14572 
14573 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14574 			"crypto op processing failed");
14575 
14576 	if (ut_params->op->sym->m_dst) {
14577 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14578 				uint8_t *, plaintext_pad_len);
14579 	} else {
14580 		auth_tag = plaintext + plaintext_pad_len;
14581 	}
14582 
14583 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14584 			auth_tag,
14585 			test_case->auth_tag.data,
14586 			test_case->auth_tag.len,
14587 			"HMAC_MD5 generated tag not as expected");
14588 
14589 	return TEST_SUCCESS;
14590 }
14591 
14592 static int
14593 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14594 {
14595 	uint8_t *plaintext;
14596 	int ret;
14597 
14598 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14599 	struct crypto_unittest_params *ut_params = &unittest_params;
14600 	struct rte_cryptodev_info dev_info;
14601 
14602 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14603 	uint64_t feat_flags = dev_info.feature_flags;
14604 
14605 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14606 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14607 		printf("Device doesn't support RAW data-path APIs.\n");
14608 		return TEST_SKIPPED;
14609 	}
14610 
14611 	/* Verify the capabilities */
14612 	struct rte_cryptodev_sym_capability_idx cap_idx;
14613 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14614 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14615 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14616 			&cap_idx) == NULL)
14617 		return TEST_SKIPPED;
14618 
14619 	if (MD5_HMAC_create_session(ts_params, ut_params,
14620 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14621 		return TEST_FAILED;
14622 	}
14623 
14624 	/* Generate Crypto op data structure */
14625 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14626 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14627 	TEST_ASSERT_NOT_NULL(ut_params->op,
14628 			"Failed to allocate symmetric crypto operation struct");
14629 
14630 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14631 		return TEST_FAILED;
14632 
14633 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14634 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14635 			ut_params->op);
14636 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14637 		ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14638 		if (ret != TEST_SUCCESS)
14639 			return ret;
14640 	} else
14641 		TEST_ASSERT_NOT_NULL(
14642 			process_crypto_request(ts_params->valid_devs[0],
14643 				ut_params->op),
14644 				"failed to process sym crypto op");
14645 
14646 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14647 			"HMAC_MD5 crypto op processing failed");
14648 
14649 	return TEST_SUCCESS;
14650 }
14651 
14652 static int
14653 test_MD5_HMAC_generate_case_1(void)
14654 {
14655 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14656 }
14657 
14658 static int
14659 test_MD5_HMAC_verify_case_1(void)
14660 {
14661 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14662 }
14663 
14664 static int
14665 test_MD5_HMAC_generate_case_2(void)
14666 {
14667 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14668 }
14669 
14670 static int
14671 test_MD5_HMAC_verify_case_2(void)
14672 {
14673 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14674 }
14675 
14676 static int
14677 test_multi_session(void)
14678 {
14679 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14680 	struct crypto_unittest_params *ut_params = &unittest_params;
14681 	struct rte_cryptodev_info dev_info;
14682 	int i, nb_sess, ret = TEST_SUCCESS;
14683 	void **sessions;
14684 
14685 	/* Verify the capabilities */
14686 	struct rte_cryptodev_sym_capability_idx cap_idx;
14687 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14688 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14689 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14690 			&cap_idx) == NULL)
14691 		return TEST_SKIPPED;
14692 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14693 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14694 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14695 			&cap_idx) == NULL)
14696 		return TEST_SKIPPED;
14697 
14698 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14699 			aes_cbc_key, hmac_sha512_key);
14700 
14701 
14702 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14703 
14704 	sessions = rte_malloc(NULL,
14705 			sizeof(void *) *
14706 			(MAX_NB_SESSIONS + 1), 0);
14707 
14708 	/* Create multiple crypto sessions*/
14709 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
14710 		sessions[i] = rte_cryptodev_sym_session_create(
14711 			ts_params->valid_devs[0], &ut_params->auth_xform,
14712 				ts_params->session_mpool);
14713 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14714 			nb_sess = i;
14715 			ret = TEST_SKIPPED;
14716 			break;
14717 		}
14718 
14719 		TEST_ASSERT_NOT_NULL(sessions[i],
14720 				"Session creation failed at session number %u",
14721 				i);
14722 
14723 		/* Attempt to send a request on each session */
14724 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14725 			sessions[i],
14726 			ut_params,
14727 			ts_params,
14728 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14729 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14730 			aes_cbc_iv);
14731 
14732 		/* free crypto operation structure */
14733 		rte_crypto_op_free(ut_params->op);
14734 
14735 		/*
14736 		 * free mbuf - both obuf and ibuf are usually the same,
14737 		 * so check if they point at the same address is necessary,
14738 		 * to avoid freeing the mbuf twice.
14739 		 */
14740 		if (ut_params->obuf) {
14741 			rte_pktmbuf_free(ut_params->obuf);
14742 			if (ut_params->ibuf == ut_params->obuf)
14743 				ut_params->ibuf = 0;
14744 			ut_params->obuf = 0;
14745 		}
14746 		if (ut_params->ibuf) {
14747 			rte_pktmbuf_free(ut_params->ibuf);
14748 			ut_params->ibuf = 0;
14749 		}
14750 
14751 		if (ret != TEST_SUCCESS) {
14752 			i++;
14753 			break;
14754 		}
14755 	}
14756 
14757 	nb_sess = i;
14758 
14759 	for (i = 0; i < nb_sess; i++) {
14760 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14761 				sessions[i]);
14762 	}
14763 
14764 	rte_free(sessions);
14765 
14766 	if (ret != TEST_SKIPPED)
14767 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14768 
14769 	return ret;
14770 }
14771 
14772 struct multi_session_params {
14773 	struct crypto_unittest_params ut_params;
14774 	uint8_t *cipher_key;
14775 	uint8_t *hmac_key;
14776 	const uint8_t *cipher;
14777 	const uint8_t *digest;
14778 	uint8_t *iv;
14779 };
14780 
14781 #define MB_SESSION_NUMBER 3
14782 
14783 static int
14784 test_multi_session_random_usage(void)
14785 {
14786 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14787 	struct rte_cryptodev_info dev_info;
14788 	int index = 0, ret = TEST_SUCCESS;
14789 	uint32_t nb_sess, i, j;
14790 	void **sessions;
14791 	struct multi_session_params ut_paramz[] = {
14792 
14793 		{
14794 			.cipher_key = ms_aes_cbc_key0,
14795 			.hmac_key = ms_hmac_key0,
14796 			.cipher = ms_aes_cbc_cipher0,
14797 			.digest = ms_hmac_digest0,
14798 			.iv = ms_aes_cbc_iv0
14799 		},
14800 		{
14801 			.cipher_key = ms_aes_cbc_key1,
14802 			.hmac_key = ms_hmac_key1,
14803 			.cipher = ms_aes_cbc_cipher1,
14804 			.digest = ms_hmac_digest1,
14805 			.iv = ms_aes_cbc_iv1
14806 		},
14807 		{
14808 			.cipher_key = ms_aes_cbc_key2,
14809 			.hmac_key = ms_hmac_key2,
14810 			.cipher = ms_aes_cbc_cipher2,
14811 			.digest = ms_hmac_digest2,
14812 			.iv = ms_aes_cbc_iv2
14813 		},
14814 
14815 	};
14816 
14817 	/* Verify the capabilities */
14818 	struct rte_cryptodev_sym_capability_idx cap_idx;
14819 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14820 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14821 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14822 			&cap_idx) == NULL)
14823 		return TEST_SKIPPED;
14824 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14825 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14826 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14827 			&cap_idx) == NULL)
14828 		return TEST_SKIPPED;
14829 
14830 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14831 
14832 	sessions = rte_malloc(NULL, (sizeof(void *)
14833 					* MAX_NB_SESSIONS) + 1, 0);
14834 
14835 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
14836 
14837 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
14838 				sizeof(struct crypto_unittest_params));
14839 
14840 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14841 				&ut_paramz[i].ut_params,
14842 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14843 
14844 		/* Create multiple crypto sessions*/
14845 		sessions[i] = rte_cryptodev_sym_session_create(
14846 				ts_params->valid_devs[0],
14847 				&ut_paramz[i].ut_params.auth_xform,
14848 				ts_params->session_mpool);
14849 		if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14850 			nb_sess = i;
14851 			ret = TEST_SKIPPED;
14852 			goto session_clear;
14853 		}
14854 
14855 		TEST_ASSERT_NOT_NULL(sessions[i],
14856 				"Session creation failed at session number %u",
14857 				i);
14858 	}
14859 
14860 	nb_sess = i;
14861 
14862 	srand(time(NULL));
14863 	for (i = 0; i < 40000; i++) {
14864 
14865 		j = rand() % MB_SESSION_NUMBER;
14866 
14867 		ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14868 					sessions[j],
14869 					&ut_paramz[j].ut_params,
14870 					ts_params, ut_paramz[j].cipher,
14871 					ut_paramz[j].digest,
14872 					ut_paramz[j].iv);
14873 
14874 		rte_crypto_op_free(ut_paramz[j].ut_params.op);
14875 
14876 		/*
14877 		 * free mbuf - both obuf and ibuf are usually the same,
14878 		 * so check if they point at the same address is necessary,
14879 		 * to avoid freeing the mbuf twice.
14880 		 */
14881 		if (ut_paramz[j].ut_params.obuf) {
14882 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14883 			if (ut_paramz[j].ut_params.ibuf
14884 					== ut_paramz[j].ut_params.obuf)
14885 				ut_paramz[j].ut_params.ibuf = 0;
14886 			ut_paramz[j].ut_params.obuf = 0;
14887 		}
14888 		if (ut_paramz[j].ut_params.ibuf) {
14889 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14890 			ut_paramz[j].ut_params.ibuf = 0;
14891 		}
14892 
14893 		if (ret != TEST_SKIPPED) {
14894 			index = i;
14895 			break;
14896 		}
14897 	}
14898 
14899 session_clear:
14900 	for (i = 0; i < nb_sess; i++) {
14901 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14902 				sessions[i]);
14903 	}
14904 
14905 	rte_free(sessions);
14906 
14907 	if (ret != TEST_SKIPPED)
14908 		TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14909 
14910 	return TEST_SUCCESS;
14911 }
14912 
14913 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14914 			0xab, 0xab, 0xab, 0xab,
14915 			0xab, 0xab, 0xab, 0xab,
14916 			0xab, 0xab, 0xab, 0xab};
14917 
14918 static int
14919 test_null_invalid_operation(void)
14920 {
14921 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14922 	struct crypto_unittest_params *ut_params = &unittest_params;
14923 
14924 	/* This test is for NULL PMD only */
14925 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14926 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14927 		return TEST_SKIPPED;
14928 
14929 	/* Setup Cipher Parameters */
14930 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14931 	ut_params->cipher_xform.next = NULL;
14932 
14933 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14934 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14935 
14936 	/* Create Crypto session*/
14937 	ut_params->sess = rte_cryptodev_sym_session_create(
14938 			ts_params->valid_devs[0], &ut_params->cipher_xform,
14939 			ts_params->session_mpool);
14940 	TEST_ASSERT(ut_params->sess == NULL,
14941 			"Session creation succeeded unexpectedly");
14942 
14943 	/* Setup HMAC Parameters */
14944 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14945 	ut_params->auth_xform.next = NULL;
14946 
14947 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
14948 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14949 
14950 	/* Create Crypto session*/
14951 	ut_params->sess = rte_cryptodev_sym_session_create(
14952 			ts_params->valid_devs[0], &ut_params->auth_xform,
14953 			ts_params->session_mpool);
14954 	TEST_ASSERT(ut_params->sess == NULL,
14955 			"Session creation succeeded unexpectedly");
14956 
14957 	return TEST_SUCCESS;
14958 }
14959 
14960 
14961 #define NULL_BURST_LENGTH (32)
14962 
14963 static int
14964 test_null_burst_operation(void)
14965 {
14966 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14967 	struct crypto_unittest_params *ut_params = &unittest_params;
14968 
14969 	unsigned i, burst_len = NULL_BURST_LENGTH;
14970 
14971 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
14972 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
14973 
14974 	/* This test is for NULL PMD only */
14975 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
14976 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14977 		return TEST_SKIPPED;
14978 
14979 	/* Setup Cipher Parameters */
14980 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14981 	ut_params->cipher_xform.next = &ut_params->auth_xform;
14982 
14983 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
14984 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14985 
14986 	/* Setup HMAC Parameters */
14987 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14988 	ut_params->auth_xform.next = NULL;
14989 
14990 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
14991 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14992 
14993 	/* Create Crypto session*/
14994 	ut_params->sess = rte_cryptodev_sym_session_create(
14995 				ts_params->valid_devs[0],
14996 				&ut_params->auth_xform,
14997 				ts_params->session_mpool);
14998 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14999 		return TEST_SKIPPED;
15000 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15001 
15002 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
15003 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
15004 			burst_len, "failed to generate burst of crypto ops");
15005 
15006 	/* Generate an operation for each mbuf in burst */
15007 	for (i = 0; i < burst_len; i++) {
15008 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15009 
15010 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
15011 
15012 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
15013 				sizeof(unsigned));
15014 		*data = i;
15015 
15016 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
15017 
15018 		burst[i]->sym->m_src = m;
15019 	}
15020 
15021 	/* Process crypto operation */
15022 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
15023 			0, burst, burst_len),
15024 			burst_len,
15025 			"Error enqueuing burst");
15026 
15027 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
15028 			0, burst_dequeued, burst_len),
15029 			burst_len,
15030 			"Error dequeuing burst");
15031 
15032 
15033 	for (i = 0; i < burst_len; i++) {
15034 		TEST_ASSERT_EQUAL(
15035 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
15036 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
15037 					uint32_t *),
15038 			"data not as expected");
15039 
15040 		rte_pktmbuf_free(burst[i]->sym->m_src);
15041 		rte_crypto_op_free(burst[i]);
15042 	}
15043 
15044 	return TEST_SUCCESS;
15045 }
15046 
15047 static uint16_t
15048 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15049 		  uint16_t nb_ops, void *user_param)
15050 {
15051 	RTE_SET_USED(dev_id);
15052 	RTE_SET_USED(qp_id);
15053 	RTE_SET_USED(ops);
15054 	RTE_SET_USED(user_param);
15055 
15056 	enq_cb_called = true;
15057 	printf("crypto enqueue callback called\n");
15058 	return nb_ops;
15059 }
15060 
15061 static uint16_t
15062 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
15063 		  uint16_t nb_ops, void *user_param)
15064 {
15065 	RTE_SET_USED(dev_id);
15066 	RTE_SET_USED(qp_id);
15067 	RTE_SET_USED(ops);
15068 	RTE_SET_USED(user_param);
15069 
15070 	deq_cb_called = true;
15071 	printf("crypto dequeue callback called\n");
15072 	return nb_ops;
15073 }
15074 
15075 /*
15076  * Process enqueue/dequeue NULL crypto request to verify callback with RCU.
15077  */
15078 static int
15079 test_enqdeq_callback_null_cipher(void)
15080 {
15081 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15082 	struct crypto_unittest_params *ut_params = &unittest_params;
15083 
15084 	/* Setup Cipher Parameters */
15085 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15086 	ut_params->cipher_xform.next = &ut_params->auth_xform;
15087 
15088 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
15089 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
15090 
15091 	/* Setup Auth Parameters */
15092 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15093 	ut_params->auth_xform.next = NULL;
15094 
15095 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
15096 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
15097 
15098 	/* Create Crypto session */
15099 	ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
15100 				&ut_params->auth_xform, ts_params->session_mpool);
15101 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15102 
15103 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15104 	TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op");
15105 
15106 	/* Allocate mbuf */
15107 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15108 	TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf");
15109 
15110 	/* Append some random data */
15111 	TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)),
15112 			"no room to append data");
15113 
15114 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15115 
15116 	ut_params->op->sym->m_src = ut_params->ibuf;
15117 
15118 	/* Process crypto operation */
15119 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op),
15120 			"failed to process sym crypto op");
15121 
15122 	return 0;
15123 }
15124 
15125 static int
15126 test_enq_callback_setup(void)
15127 {
15128 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15129 	struct rte_cryptodev_sym_capability_idx cap_idx;
15130 	struct rte_cryptodev_info dev_info;
15131 	struct rte_cryptodev_qp_conf qp_conf = {
15132 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
15133 	};
15134 
15135 	struct rte_cryptodev_cb *cb;
15136 	uint16_t qp_id = 0;
15137 	int j = 0;
15138 
15139 	/* Skip test if synchronous API is used */
15140 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15141 		return TEST_SKIPPED;
15142 
15143 	/* Verify the crypto capabilities for which enqueue/dequeue is done. */
15144 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15145 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15146 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15147 			&cap_idx) == NULL)
15148 		return TEST_SKIPPED;
15149 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15150 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15151 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15152 			&cap_idx) == NULL)
15153 		return TEST_SKIPPED;
15154 
15155 	/* Stop the device in case it's started so it can be configured */
15156 	rte_cryptodev_stop(ts_params->valid_devs[0]);
15157 
15158 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15159 
15160 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15161 			&ts_params->conf),
15162 			"Failed to configure cryptodev %u",
15163 			ts_params->valid_devs[0]);
15164 
15165 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15166 	qp_conf.mp_session = ts_params->session_mpool;
15167 
15168 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15169 			ts_params->valid_devs[0], qp_id, &qp_conf,
15170 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15171 			"Failed test for "
15172 			"rte_cryptodev_queue_pair_setup: num_inflights "
15173 			"%u on qp %u on cryptodev %u",
15174 			qp_conf.nb_descriptors, qp_id,
15175 			ts_params->valid_devs[0]);
15176 
15177 	enq_cb_called = false;
15178 	/* Test with invalid crypto device */
15179 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
15180 			qp_id, test_enq_callback, NULL);
15181 	if (rte_errno == ENOTSUP) {
15182 		RTE_LOG(ERR, USER1, "%s line %d: "
15183 			"rte_cryptodev_add_enq_callback() "
15184 			"Not supported, skipped\n", __func__, __LINE__);
15185 		return TEST_SKIPPED;
15186 	}
15187 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15188 			"cryptodev %u did not fail",
15189 			qp_id, RTE_CRYPTO_MAX_DEVS);
15190 
15191 	/* Test with invalid queue pair */
15192 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15193 			dev_info.max_nb_queue_pairs + 1,
15194 			test_enq_callback, NULL);
15195 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15196 			"cryptodev %u did not fail",
15197 			dev_info.max_nb_queue_pairs + 1,
15198 			ts_params->valid_devs[0]);
15199 
15200 	/* Test with NULL callback */
15201 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15202 			qp_id, NULL, NULL);
15203 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15204 			"cryptodev %u did not fail",
15205 			qp_id, ts_params->valid_devs[0]);
15206 
15207 	/* Test with valid configuration */
15208 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
15209 			qp_id, test_enq_callback, NULL);
15210 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15211 			"qp %u on cryptodev %u",
15212 			qp_id, ts_params->valid_devs[0]);
15213 
15214 	rte_cryptodev_start(ts_params->valid_devs[0]);
15215 
15216 	TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed");
15217 
15218 	/* Wait until callback not called. */
15219 	while (!enq_cb_called && (j++ < 10))
15220 		rte_delay_ms(10);
15221 
15222 	/* Test with invalid crypto device */
15223 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15224 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15225 			"Expected call to fail as crypto device is invalid");
15226 
15227 	/* Test with invalid queue pair */
15228 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15229 			ts_params->valid_devs[0],
15230 			dev_info.max_nb_queue_pairs + 1, cb),
15231 			"Expected call to fail as queue pair is invalid");
15232 
15233 	/* Test with NULL callback */
15234 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
15235 			ts_params->valid_devs[0], qp_id, NULL),
15236 			"Expected call to fail as callback is NULL");
15237 
15238 	/* Test with valid configuration */
15239 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
15240 			ts_params->valid_devs[0], qp_id, cb),
15241 			"Failed test to remove callback on "
15242 			"qp %u on cryptodev %u",
15243 			qp_id, ts_params->valid_devs[0]);
15244 
15245 	TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called");
15246 
15247 	return TEST_SUCCESS;
15248 }
15249 
15250 static int
15251 test_deq_callback_setup(void)
15252 {
15253 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15254 	struct rte_cryptodev_sym_capability_idx cap_idx;
15255 	struct rte_cryptodev_info dev_info;
15256 	struct rte_cryptodev_qp_conf qp_conf = {
15257 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
15258 	};
15259 
15260 	struct rte_cryptodev_cb *cb;
15261 	uint16_t qp_id = 0;
15262 	int j = 0;
15263 
15264 	/* Skip test if synchronous API is used */
15265 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15266 		return TEST_SKIPPED;
15267 
15268 	/* Verify the crypto capabilities for which enqueue/dequeue is done. */
15269 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15270 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL;
15271 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15272 			&cap_idx) == NULL)
15273 		return TEST_SKIPPED;
15274 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15275 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL;
15276 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15277 			&cap_idx) == NULL)
15278 		return TEST_SKIPPED;
15279 
15280 	/* Stop the device in case it's started so it can be configured */
15281 	rte_cryptodev_stop(ts_params->valid_devs[0]);
15282 
15283 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15284 
15285 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
15286 			&ts_params->conf),
15287 			"Failed to configure cryptodev %u",
15288 			ts_params->valid_devs[0]);
15289 
15290 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
15291 	qp_conf.mp_session = ts_params->session_mpool;
15292 
15293 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
15294 			ts_params->valid_devs[0], qp_id, &qp_conf,
15295 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
15296 			"Failed test for "
15297 			"rte_cryptodev_queue_pair_setup: num_inflights "
15298 			"%u on qp %u on cryptodev %u",
15299 			qp_conf.nb_descriptors, qp_id,
15300 			ts_params->valid_devs[0]);
15301 
15302 	deq_cb_called = false;
15303 	/* Test with invalid crypto device */
15304 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
15305 			qp_id, test_deq_callback, NULL);
15306 	if (rte_errno == ENOTSUP) {
15307 		RTE_LOG(ERR, USER1, "%s line %d: "
15308 			"rte_cryptodev_add_deq_callback() "
15309 			"Not supported, skipped\n", __func__, __LINE__);
15310 		return TEST_SKIPPED;
15311 	}
15312 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15313 			"cryptodev %u did not fail",
15314 			qp_id, RTE_CRYPTO_MAX_DEVS);
15315 
15316 	/* Test with invalid queue pair */
15317 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15318 			dev_info.max_nb_queue_pairs + 1,
15319 			test_deq_callback, NULL);
15320 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15321 			"cryptodev %u did not fail",
15322 			dev_info.max_nb_queue_pairs + 1,
15323 			ts_params->valid_devs[0]);
15324 
15325 	/* Test with NULL callback */
15326 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15327 			qp_id, NULL, NULL);
15328 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
15329 			"cryptodev %u did not fail",
15330 			qp_id, ts_params->valid_devs[0]);
15331 
15332 	/* Test with valid configuration */
15333 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
15334 			qp_id, test_deq_callback, NULL);
15335 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
15336 			"qp %u on cryptodev %u",
15337 			qp_id, ts_params->valid_devs[0]);
15338 
15339 	rte_cryptodev_start(ts_params->valid_devs[0]);
15340 
15341 	TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed");
15342 
15343 	/* Wait until callback not called. */
15344 	while (!deq_cb_called && (j++ < 10))
15345 		rte_delay_ms(10);
15346 
15347 	/* Test with invalid crypto device */
15348 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15349 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
15350 			"Expected call to fail as crypto device is invalid");
15351 
15352 	/* Test with invalid queue pair */
15353 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15354 			ts_params->valid_devs[0],
15355 			dev_info.max_nb_queue_pairs + 1, cb),
15356 			"Expected call to fail as queue pair is invalid");
15357 
15358 	/* Test with NULL callback */
15359 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
15360 			ts_params->valid_devs[0], qp_id, NULL),
15361 			"Expected call to fail as callback is NULL");
15362 
15363 	/* Test with valid configuration */
15364 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
15365 			ts_params->valid_devs[0], qp_id, cb),
15366 			"Failed test to remove callback on "
15367 			"qp %u on cryptodev %u",
15368 			qp_id, ts_params->valid_devs[0]);
15369 
15370 	TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called");
15371 
15372 	return TEST_SUCCESS;
15373 }
15374 
15375 static void
15376 generate_gmac_large_plaintext(uint8_t *data)
15377 {
15378 	uint16_t i;
15379 
15380 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
15381 		memcpy(&data[i], &data[0], 32);
15382 }
15383 
15384 static int
15385 create_gmac_operation(enum rte_crypto_auth_operation op,
15386 		const struct gmac_test_data *tdata)
15387 {
15388 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15389 	struct crypto_unittest_params *ut_params = &unittest_params;
15390 	struct rte_crypto_sym_op *sym_op;
15391 
15392 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15393 
15394 	/* Generate Crypto op data structure */
15395 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15396 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15397 	TEST_ASSERT_NOT_NULL(ut_params->op,
15398 			"Failed to allocate symmetric crypto operation struct");
15399 
15400 	sym_op = ut_params->op->sym;
15401 
15402 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15403 			ut_params->ibuf, tdata->gmac_tag.len);
15404 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15405 			"no room to append digest");
15406 
15407 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15408 			ut_params->ibuf, plaintext_pad_len);
15409 
15410 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15411 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15412 				tdata->gmac_tag.len);
15413 		debug_hexdump(stdout, "digest:",
15414 				sym_op->auth.digest.data,
15415 				tdata->gmac_tag.len);
15416 	}
15417 
15418 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15419 			uint8_t *, IV_OFFSET);
15420 
15421 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15422 
15423 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15424 
15425 	sym_op->cipher.data.length = 0;
15426 	sym_op->cipher.data.offset = 0;
15427 
15428 	sym_op->auth.data.offset = 0;
15429 	sym_op->auth.data.length = tdata->plaintext.len;
15430 
15431 	return 0;
15432 }
15433 
15434 static int
15435 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
15436 		const struct gmac_test_data *tdata,
15437 		void *digest_mem, uint64_t digest_phys)
15438 {
15439 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15440 	struct crypto_unittest_params *ut_params = &unittest_params;
15441 	struct rte_crypto_sym_op *sym_op;
15442 
15443 	/* Generate Crypto op data structure */
15444 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15445 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15446 	TEST_ASSERT_NOT_NULL(ut_params->op,
15447 			"Failed to allocate symmetric crypto operation struct");
15448 
15449 	sym_op = ut_params->op->sym;
15450 
15451 	sym_op->auth.digest.data = digest_mem;
15452 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15453 			"no room to append digest");
15454 
15455 	sym_op->auth.digest.phys_addr = digest_phys;
15456 
15457 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
15458 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
15459 				tdata->gmac_tag.len);
15460 		debug_hexdump(stdout, "digest:",
15461 				sym_op->auth.digest.data,
15462 				tdata->gmac_tag.len);
15463 	}
15464 
15465 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
15466 			uint8_t *, IV_OFFSET);
15467 
15468 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
15469 
15470 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
15471 
15472 	sym_op->cipher.data.length = 0;
15473 	sym_op->cipher.data.offset = 0;
15474 
15475 	sym_op->auth.data.offset = 0;
15476 	sym_op->auth.data.length = tdata->plaintext.len;
15477 
15478 	return 0;
15479 }
15480 
15481 static int create_gmac_session(uint8_t dev_id,
15482 		const struct gmac_test_data *tdata,
15483 		enum rte_crypto_auth_operation auth_op)
15484 {
15485 	uint8_t auth_key[tdata->key.len];
15486 
15487 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15488 	struct crypto_unittest_params *ut_params = &unittest_params;
15489 
15490 	memcpy(auth_key, tdata->key.data, tdata->key.len);
15491 
15492 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15493 	ut_params->auth_xform.next = NULL;
15494 
15495 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
15496 	ut_params->auth_xform.auth.op = auth_op;
15497 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
15498 	ut_params->auth_xform.auth.key.length = tdata->key.len;
15499 	ut_params->auth_xform.auth.key.data = auth_key;
15500 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15501 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
15502 
15503 
15504 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15505 			&ut_params->auth_xform, ts_params->session_mpool);
15506 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15507 		return TEST_SKIPPED;
15508 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
15509 
15510 	return 0;
15511 }
15512 
15513 static int
15514 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
15515 {
15516 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15517 	struct crypto_unittest_params *ut_params = &unittest_params;
15518 	struct rte_cryptodev_info dev_info;
15519 
15520 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15521 	uint64_t feat_flags = dev_info.feature_flags;
15522 
15523 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15524 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15525 		printf("Device doesn't support RAW data-path APIs.\n");
15526 		return TEST_SKIPPED;
15527 	}
15528 
15529 	int retval;
15530 
15531 	uint8_t *auth_tag, *plaintext;
15532 	uint16_t plaintext_pad_len;
15533 
15534 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15535 			      "No GMAC length in the source data");
15536 
15537 	/* Verify the capabilities */
15538 	struct rte_cryptodev_sym_capability_idx cap_idx;
15539 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15540 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15541 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15542 			&cap_idx) == NULL)
15543 		return TEST_SKIPPED;
15544 
15545 	retval = create_gmac_session(ts_params->valid_devs[0],
15546 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15547 
15548 	if (retval == TEST_SKIPPED)
15549 		return TEST_SKIPPED;
15550 	if (retval < 0)
15551 		return retval;
15552 
15553 	if (tdata->plaintext.len > MBUF_SIZE)
15554 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15555 	else
15556 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15557 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15558 			"Failed to allocate input buffer in mempool");
15559 
15560 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15561 			rte_pktmbuf_tailroom(ut_params->ibuf));
15562 
15563 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15564 	/*
15565 	 * Runtime generate the large plain text instead of use hard code
15566 	 * plain text vector. It is done to avoid create huge source file
15567 	 * with the test vector.
15568 	 */
15569 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15570 		generate_gmac_large_plaintext(tdata->plaintext.data);
15571 
15572 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15573 				plaintext_pad_len);
15574 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15575 
15576 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15577 	debug_hexdump(stdout, "plaintext:", plaintext,
15578 			tdata->plaintext.len);
15579 
15580 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
15581 			tdata);
15582 
15583 	if (retval < 0)
15584 		return retval;
15585 
15586 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15587 
15588 	ut_params->op->sym->m_src = ut_params->ibuf;
15589 
15590 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15591 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15592 			ut_params->op);
15593 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15594 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15595 					       0);
15596 		if (retval != TEST_SUCCESS)
15597 			return retval;
15598 	} else
15599 		TEST_ASSERT_NOT_NULL(
15600 			process_crypto_request(ts_params->valid_devs[0],
15601 			ut_params->op), "failed to process sym crypto op");
15602 
15603 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15604 			"crypto op processing failed");
15605 
15606 	if (ut_params->op->sym->m_dst) {
15607 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15608 				uint8_t *, plaintext_pad_len);
15609 	} else {
15610 		auth_tag = plaintext + plaintext_pad_len;
15611 	}
15612 
15613 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15614 
15615 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15616 			auth_tag,
15617 			tdata->gmac_tag.data,
15618 			tdata->gmac_tag.len,
15619 			"GMAC Generated auth tag not as expected");
15620 
15621 	return 0;
15622 }
15623 
15624 static int
15625 test_AES_GMAC_authentication_test_case_1(void)
15626 {
15627 	return test_AES_GMAC_authentication(&gmac_test_case_1);
15628 }
15629 
15630 static int
15631 test_AES_GMAC_authentication_test_case_2(void)
15632 {
15633 	return test_AES_GMAC_authentication(&gmac_test_case_2);
15634 }
15635 
15636 static int
15637 test_AES_GMAC_authentication_test_case_3(void)
15638 {
15639 	return test_AES_GMAC_authentication(&gmac_test_case_3);
15640 }
15641 
15642 static int
15643 test_AES_GMAC_authentication_test_case_4(void)
15644 {
15645 	return test_AES_GMAC_authentication(&gmac_test_case_4);
15646 }
15647 
15648 static int
15649 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15650 {
15651 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15652 	struct crypto_unittest_params *ut_params = &unittest_params;
15653 	int retval;
15654 	uint32_t plaintext_pad_len;
15655 	uint8_t *plaintext;
15656 	struct rte_cryptodev_info dev_info;
15657 
15658 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15659 	uint64_t feat_flags = dev_info.feature_flags;
15660 
15661 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15662 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15663 		printf("Device doesn't support RAW data-path APIs.\n");
15664 		return TEST_SKIPPED;
15665 	}
15666 
15667 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15668 			      "No GMAC length in the source data");
15669 
15670 	/* Verify the capabilities */
15671 	struct rte_cryptodev_sym_capability_idx cap_idx;
15672 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15673 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15674 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15675 			&cap_idx) == NULL)
15676 		return TEST_SKIPPED;
15677 
15678 	retval = create_gmac_session(ts_params->valid_devs[0],
15679 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15680 
15681 	if (retval == TEST_SKIPPED)
15682 		return TEST_SKIPPED;
15683 	if (retval < 0)
15684 		return retval;
15685 
15686 	if (tdata->plaintext.len > MBUF_SIZE)
15687 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15688 	else
15689 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15690 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15691 			"Failed to allocate input buffer in mempool");
15692 
15693 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15694 			rte_pktmbuf_tailroom(ut_params->ibuf));
15695 
15696 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15697 
15698 	/*
15699 	 * Runtime generate the large plain text instead of use hard code
15700 	 * plain text vector. It is done to avoid create huge source file
15701 	 * with the test vector.
15702 	 */
15703 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15704 		generate_gmac_large_plaintext(tdata->plaintext.data);
15705 
15706 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15707 				plaintext_pad_len);
15708 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15709 
15710 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15711 	debug_hexdump(stdout, "plaintext:", plaintext,
15712 			tdata->plaintext.len);
15713 
15714 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15715 			tdata);
15716 
15717 	if (retval < 0)
15718 		return retval;
15719 
15720 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15721 
15722 	ut_params->op->sym->m_src = ut_params->ibuf;
15723 
15724 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15725 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15726 			ut_params->op);
15727 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15728 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15729 					       0);
15730 		if (retval != TEST_SUCCESS)
15731 			return retval;
15732 	} else
15733 		TEST_ASSERT_NOT_NULL(
15734 			process_crypto_request(ts_params->valid_devs[0],
15735 			ut_params->op), "failed to process sym crypto op");
15736 
15737 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15738 			"crypto op processing failed");
15739 
15740 	return 0;
15741 
15742 }
15743 
15744 static int
15745 test_AES_GMAC_authentication_verify_test_case_1(void)
15746 {
15747 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15748 }
15749 
15750 static int
15751 test_AES_GMAC_authentication_verify_test_case_2(void)
15752 {
15753 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15754 }
15755 
15756 static int
15757 test_AES_GMAC_authentication_verify_test_case_3(void)
15758 {
15759 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15760 }
15761 
15762 static int
15763 test_AES_GMAC_authentication_verify_test_case_4(void)
15764 {
15765 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15766 }
15767 
15768 static int
15769 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15770 				uint32_t fragsz)
15771 {
15772 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15773 	struct crypto_unittest_params *ut_params = &unittest_params;
15774 	struct rte_cryptodev_info dev_info;
15775 	uint64_t feature_flags;
15776 	unsigned int trn_data = 0;
15777 	void *digest_mem = NULL;
15778 	uint32_t segs = 1;
15779 	unsigned int to_trn = 0;
15780 	struct rte_mbuf *buf = NULL;
15781 	uint8_t *auth_tag, *plaintext;
15782 	int retval;
15783 
15784 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15785 			      "No GMAC length in the source data");
15786 
15787 	/* Verify the capabilities */
15788 	struct rte_cryptodev_sym_capability_idx cap_idx;
15789 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15790 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15791 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15792 			&cap_idx) == NULL)
15793 		return TEST_SKIPPED;
15794 
15795 	/* Check for any input SGL support */
15796 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15797 	feature_flags = dev_info.feature_flags;
15798 
15799 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15800 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15801 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15802 		return TEST_SKIPPED;
15803 
15804 	if (fragsz > tdata->plaintext.len)
15805 		fragsz = tdata->plaintext.len;
15806 
15807 	uint16_t plaintext_len = fragsz;
15808 
15809 	retval = create_gmac_session(ts_params->valid_devs[0],
15810 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15811 
15812 	if (retval == TEST_SKIPPED)
15813 		return TEST_SKIPPED;
15814 	if (retval < 0)
15815 		return retval;
15816 
15817 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15818 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15819 			"Failed to allocate input buffer in mempool");
15820 
15821 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15822 			rte_pktmbuf_tailroom(ut_params->ibuf));
15823 
15824 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15825 				plaintext_len);
15826 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15827 
15828 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15829 
15830 	trn_data += plaintext_len;
15831 
15832 	buf = ut_params->ibuf;
15833 
15834 	/*
15835 	 * Loop until no more fragments
15836 	 */
15837 
15838 	while (trn_data < tdata->plaintext.len) {
15839 		++segs;
15840 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15841 				(tdata->plaintext.len - trn_data) : fragsz;
15842 
15843 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15844 		buf = buf->next;
15845 
15846 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15847 				rte_pktmbuf_tailroom(buf));
15848 
15849 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15850 				to_trn);
15851 
15852 		memcpy(plaintext, tdata->plaintext.data + trn_data,
15853 				to_trn);
15854 		trn_data += to_trn;
15855 		if (trn_data  == tdata->plaintext.len)
15856 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15857 					tdata->gmac_tag.len);
15858 	}
15859 	ut_params->ibuf->nb_segs = segs;
15860 
15861 	/*
15862 	 * Place digest at the end of the last buffer
15863 	 */
15864 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15865 
15866 	if (!digest_mem) {
15867 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15868 				+ tdata->gmac_tag.len);
15869 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15870 				tdata->plaintext.len);
15871 	}
15872 
15873 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15874 			tdata, digest_mem, digest_phys);
15875 
15876 	if (retval < 0)
15877 		return retval;
15878 
15879 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15880 
15881 	ut_params->op->sym->m_src = ut_params->ibuf;
15882 
15883 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15884 		return TEST_SKIPPED;
15885 
15886 	TEST_ASSERT_NOT_NULL(
15887 		process_crypto_request(ts_params->valid_devs[0],
15888 		ut_params->op), "failed to process sym crypto op");
15889 
15890 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15891 			"crypto op processing failed");
15892 
15893 	auth_tag = digest_mem;
15894 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15895 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
15896 			auth_tag,
15897 			tdata->gmac_tag.data,
15898 			tdata->gmac_tag.len,
15899 			"GMAC Generated auth tag not as expected");
15900 
15901 	return 0;
15902 }
15903 
15904 /* Segment size not multiple of block size (16B) */
15905 static int
15906 test_AES_GMAC_authentication_SGL_40B(void)
15907 {
15908 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15909 }
15910 
15911 static int
15912 test_AES_GMAC_authentication_SGL_80B(void)
15913 {
15914 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15915 }
15916 
15917 static int
15918 test_AES_GMAC_authentication_SGL_2048B(void)
15919 {
15920 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15921 }
15922 
15923 /* Segment size not multiple of block size (16B) */
15924 static int
15925 test_AES_GMAC_authentication_SGL_2047B(void)
15926 {
15927 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15928 }
15929 
15930 struct test_crypto_vector {
15931 	enum rte_crypto_cipher_algorithm crypto_algo;
15932 	unsigned int cipher_offset;
15933 	unsigned int cipher_len;
15934 
15935 	struct {
15936 		uint8_t data[64];
15937 		unsigned int len;
15938 	} cipher_key;
15939 
15940 	struct {
15941 		uint8_t data[64];
15942 		unsigned int len;
15943 	} iv;
15944 
15945 	struct {
15946 		const uint8_t *data;
15947 		unsigned int len;
15948 	} plaintext;
15949 
15950 	struct {
15951 		const uint8_t *data;
15952 		unsigned int len;
15953 	} ciphertext;
15954 
15955 	enum rte_crypto_auth_algorithm auth_algo;
15956 	unsigned int auth_offset;
15957 
15958 	struct {
15959 		uint8_t data[128];
15960 		unsigned int len;
15961 	} auth_key;
15962 
15963 	struct {
15964 		const uint8_t *data;
15965 		unsigned int len;
15966 	} aad;
15967 
15968 	struct {
15969 		uint8_t data[128];
15970 		unsigned int len;
15971 	} digest;
15972 };
15973 
15974 static const struct test_crypto_vector
15975 hmac_sha1_test_crypto_vector = {
15976 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15977 	.plaintext = {
15978 		.data = plaintext_hash,
15979 		.len = 512
15980 	},
15981 	.auth_key = {
15982 		.data = {
15983 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15984 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15985 			0xDE, 0xF4, 0xDE, 0xAD
15986 		},
15987 		.len = 20
15988 	},
15989 	.digest = {
15990 		.data = {
15991 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
15992 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
15993 			0x3F, 0x91, 0x64, 0x59
15994 		},
15995 		.len = 20
15996 	}
15997 };
15998 
15999 static const struct test_crypto_vector
16000 aes128_gmac_test_vector = {
16001 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
16002 	.plaintext = {
16003 		.data = plaintext_hash,
16004 		.len = 512
16005 	},
16006 	.iv = {
16007 		.data = {
16008 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16009 			0x08, 0x09, 0x0A, 0x0B
16010 		},
16011 		.len = 12
16012 	},
16013 	.auth_key = {
16014 		.data = {
16015 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16016 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
16017 		},
16018 		.len = 16
16019 	},
16020 	.digest = {
16021 		.data = {
16022 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
16023 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
16024 		},
16025 		.len = 16
16026 	}
16027 };
16028 
16029 static const struct test_crypto_vector
16030 aes128cbc_hmac_sha1_test_vector = {
16031 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16032 	.cipher_offset = 0,
16033 	.cipher_len = 512,
16034 	.cipher_key = {
16035 		.data = {
16036 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16037 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16038 		},
16039 		.len = 16
16040 	},
16041 	.iv = {
16042 		.data = {
16043 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16044 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16045 		},
16046 		.len = 16
16047 	},
16048 	.plaintext = {
16049 		.data = plaintext_hash,
16050 		.len = 512
16051 	},
16052 	.ciphertext = {
16053 		.data = ciphertext512_aes128cbc,
16054 		.len = 512
16055 	},
16056 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16057 	.auth_offset = 0,
16058 	.auth_key = {
16059 		.data = {
16060 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16061 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16062 			0xDE, 0xF4, 0xDE, 0xAD
16063 		},
16064 		.len = 20
16065 	},
16066 	.digest = {
16067 		.data = {
16068 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
16069 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
16070 			0x18, 0x8C, 0x1D, 0x32
16071 		},
16072 		.len = 20
16073 	}
16074 };
16075 
16076 static const struct test_crypto_vector
16077 aes128cbc_hmac_sha1_aad_test_vector = {
16078 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
16079 	.cipher_offset = 8,
16080 	.cipher_len = 496,
16081 	.cipher_key = {
16082 		.data = {
16083 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
16084 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
16085 		},
16086 		.len = 16
16087 	},
16088 	.iv = {
16089 		.data = {
16090 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
16091 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
16092 		},
16093 		.len = 16
16094 	},
16095 	.plaintext = {
16096 		.data = plaintext_hash,
16097 		.len = 512
16098 	},
16099 	.ciphertext = {
16100 		.data = ciphertext512_aes128cbc_aad,
16101 		.len = 512
16102 	},
16103 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
16104 	.auth_offset = 0,
16105 	.auth_key = {
16106 		.data = {
16107 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
16108 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
16109 			0xDE, 0xF4, 0xDE, 0xAD
16110 		},
16111 		.len = 20
16112 	},
16113 	.digest = {
16114 		.data = {
16115 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
16116 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
16117 			0x62, 0x0F, 0xFB, 0x10
16118 		},
16119 		.len = 20
16120 	}
16121 };
16122 
16123 static void
16124 data_corruption(uint8_t *data)
16125 {
16126 	data[0] += 1;
16127 }
16128 
16129 static void
16130 tag_corruption(uint8_t *data, unsigned int tag_offset)
16131 {
16132 	data[tag_offset] += 1;
16133 }
16134 
16135 static int
16136 create_auth_session(struct crypto_unittest_params *ut_params,
16137 		uint8_t dev_id,
16138 		const struct test_crypto_vector *reference,
16139 		enum rte_crypto_auth_operation auth_op)
16140 {
16141 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16142 	uint8_t auth_key[reference->auth_key.len + 1];
16143 
16144 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16145 
16146 	/* Setup Authentication Parameters */
16147 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16148 	ut_params->auth_xform.auth.op = auth_op;
16149 	ut_params->auth_xform.next = NULL;
16150 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16151 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16152 	ut_params->auth_xform.auth.key.data = auth_key;
16153 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16154 
16155 	/* Create Crypto session*/
16156 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16157 				&ut_params->auth_xform,
16158 				ts_params->session_mpool);
16159 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16160 		return TEST_SKIPPED;
16161 
16162 	return 0;
16163 }
16164 
16165 static int
16166 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
16167 		uint8_t dev_id,
16168 		const struct test_crypto_vector *reference,
16169 		enum rte_crypto_auth_operation auth_op,
16170 		enum rte_crypto_cipher_operation cipher_op)
16171 {
16172 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16173 	uint8_t cipher_key[reference->cipher_key.len + 1];
16174 	uint8_t auth_key[reference->auth_key.len + 1];
16175 
16176 	memcpy(cipher_key, reference->cipher_key.data,
16177 			reference->cipher_key.len);
16178 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16179 
16180 	/* Setup Authentication Parameters */
16181 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16182 	ut_params->auth_xform.auth.op = auth_op;
16183 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16184 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16185 	ut_params->auth_xform.auth.key.data = auth_key;
16186 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16187 
16188 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
16189 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
16190 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
16191 	} else {
16192 		ut_params->auth_xform.next = &ut_params->cipher_xform;
16193 
16194 		/* Setup Cipher Parameters */
16195 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16196 		ut_params->cipher_xform.next = NULL;
16197 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16198 		ut_params->cipher_xform.cipher.op = cipher_op;
16199 		ut_params->cipher_xform.cipher.key.data = cipher_key;
16200 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16201 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16202 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16203 	}
16204 
16205 	/* Create Crypto session*/
16206 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
16207 				&ut_params->auth_xform,
16208 				ts_params->session_mpool);
16209 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16210 		return TEST_SKIPPED;
16211 
16212 	return 0;
16213 }
16214 
16215 static int
16216 create_auth_operation(struct crypto_testsuite_params *ts_params,
16217 		struct crypto_unittest_params *ut_params,
16218 		const struct test_crypto_vector *reference,
16219 		unsigned int auth_generate)
16220 {
16221 	/* Generate Crypto op data structure */
16222 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16223 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16224 	TEST_ASSERT_NOT_NULL(ut_params->op,
16225 			"Failed to allocate pktmbuf offload");
16226 
16227 	/* Set crypto operation data parameters */
16228 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16229 
16230 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16231 
16232 	/* set crypto operation source mbuf */
16233 	sym_op->m_src = ut_params->ibuf;
16234 
16235 	/* digest */
16236 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16237 			ut_params->ibuf, reference->digest.len);
16238 
16239 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16240 			"no room to append auth tag");
16241 
16242 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16243 			ut_params->ibuf, reference->plaintext.len);
16244 
16245 	if (auth_generate)
16246 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
16247 	else
16248 		memcpy(sym_op->auth.digest.data,
16249 				reference->digest.data,
16250 				reference->digest.len);
16251 
16252 	debug_hexdump(stdout, "digest:",
16253 			sym_op->auth.digest.data,
16254 			reference->digest.len);
16255 
16256 	sym_op->auth.data.length = reference->plaintext.len;
16257 	sym_op->auth.data.offset = 0;
16258 
16259 	return 0;
16260 }
16261 
16262 static int
16263 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
16264 		struct crypto_unittest_params *ut_params,
16265 		const struct test_crypto_vector *reference,
16266 		unsigned int auth_generate)
16267 {
16268 	/* Generate Crypto op data structure */
16269 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16270 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16271 	TEST_ASSERT_NOT_NULL(ut_params->op,
16272 			"Failed to allocate pktmbuf offload");
16273 
16274 	/* Set crypto operation data parameters */
16275 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16276 
16277 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16278 
16279 	/* set crypto operation source mbuf */
16280 	sym_op->m_src = ut_params->ibuf;
16281 
16282 	/* digest */
16283 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16284 			ut_params->ibuf, reference->digest.len);
16285 
16286 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16287 			"no room to append auth tag");
16288 
16289 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16290 			ut_params->ibuf, reference->ciphertext.len);
16291 
16292 	if (auth_generate)
16293 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
16294 	else
16295 		memcpy(sym_op->auth.digest.data,
16296 				reference->digest.data,
16297 				reference->digest.len);
16298 
16299 	debug_hexdump(stdout, "digest:",
16300 			sym_op->auth.digest.data,
16301 			reference->digest.len);
16302 
16303 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16304 			reference->iv.data, reference->iv.len);
16305 
16306 	sym_op->cipher.data.length = 0;
16307 	sym_op->cipher.data.offset = 0;
16308 
16309 	sym_op->auth.data.length = reference->plaintext.len;
16310 	sym_op->auth.data.offset = 0;
16311 
16312 	return 0;
16313 }
16314 
16315 static int
16316 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
16317 		struct crypto_unittest_params *ut_params,
16318 		const struct test_crypto_vector *reference,
16319 		unsigned int auth_generate)
16320 {
16321 	/* Generate Crypto op data structure */
16322 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16323 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16324 	TEST_ASSERT_NOT_NULL(ut_params->op,
16325 			"Failed to allocate pktmbuf offload");
16326 
16327 	/* Set crypto operation data parameters */
16328 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16329 
16330 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16331 
16332 	/* set crypto operation source mbuf */
16333 	sym_op->m_src = ut_params->ibuf;
16334 
16335 	/* digest */
16336 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
16337 			ut_params->ibuf, reference->digest.len);
16338 
16339 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
16340 			"no room to append auth tag");
16341 
16342 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
16343 			ut_params->ibuf, reference->ciphertext.len);
16344 
16345 	if (auth_generate)
16346 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
16347 	else
16348 		memcpy(sym_op->auth.digest.data,
16349 				reference->digest.data,
16350 				reference->digest.len);
16351 
16352 	debug_hexdump(stdout, "digest:",
16353 			sym_op->auth.digest.data,
16354 			reference->digest.len);
16355 
16356 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
16357 			reference->iv.data, reference->iv.len);
16358 
16359 	sym_op->cipher.data.length = reference->cipher_len;
16360 	sym_op->cipher.data.offset = reference->cipher_offset;
16361 
16362 	sym_op->auth.data.length = reference->plaintext.len;
16363 	sym_op->auth.data.offset = reference->auth_offset;
16364 
16365 	return 0;
16366 }
16367 
16368 static int
16369 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16370 		struct crypto_unittest_params *ut_params,
16371 		const struct test_crypto_vector *reference)
16372 {
16373 	return create_auth_operation(ts_params, ut_params, reference, 0);
16374 }
16375 
16376 static int
16377 create_auth_verify_GMAC_operation(
16378 		struct crypto_testsuite_params *ts_params,
16379 		struct crypto_unittest_params *ut_params,
16380 		const struct test_crypto_vector *reference)
16381 {
16382 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
16383 }
16384 
16385 static int
16386 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
16387 		struct crypto_unittest_params *ut_params,
16388 		const struct test_crypto_vector *reference)
16389 {
16390 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
16391 }
16392 
16393 static int
16394 test_authentication_verify_fail_when_data_corruption(
16395 		struct crypto_testsuite_params *ts_params,
16396 		struct crypto_unittest_params *ut_params,
16397 		const struct test_crypto_vector *reference,
16398 		unsigned int data_corrupted)
16399 {
16400 	int retval;
16401 
16402 	uint8_t *plaintext;
16403 	struct rte_cryptodev_info dev_info;
16404 
16405 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16406 	uint64_t feat_flags = dev_info.feature_flags;
16407 
16408 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16409 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16410 		printf("Device doesn't support RAW data-path APIs.\n");
16411 		return TEST_SKIPPED;
16412 	}
16413 
16414 	/* Verify the capabilities */
16415 	struct rte_cryptodev_sym_capability_idx cap_idx;
16416 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16417 	cap_idx.algo.auth = reference->auth_algo;
16418 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16419 			&cap_idx) == NULL)
16420 		return TEST_SKIPPED;
16421 
16422 
16423 	/* Create session */
16424 	retval = create_auth_session(ut_params,
16425 			ts_params->valid_devs[0],
16426 			reference,
16427 			RTE_CRYPTO_AUTH_OP_VERIFY);
16428 
16429 	if (retval == TEST_SKIPPED)
16430 		return TEST_SKIPPED;
16431 	if (retval < 0)
16432 		return retval;
16433 
16434 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16435 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16436 			"Failed to allocate input buffer in mempool");
16437 
16438 	/* clear mbuf payload */
16439 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16440 			rte_pktmbuf_tailroom(ut_params->ibuf));
16441 
16442 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16443 			reference->plaintext.len);
16444 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16445 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16446 
16447 	debug_hexdump(stdout, "plaintext:", plaintext,
16448 		reference->plaintext.len);
16449 
16450 	/* Create operation */
16451 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
16452 
16453 	if (retval < 0)
16454 		return retval;
16455 
16456 	if (data_corrupted)
16457 		data_corruption(plaintext);
16458 	else
16459 		tag_corruption(plaintext, reference->plaintext.len);
16460 
16461 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16462 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16463 			ut_params->op);
16464 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16465 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16466 			"authentication not failed");
16467 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16468 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16469 					       0);
16470 		if (retval != TEST_SUCCESS)
16471 			return retval;
16472 	} else {
16473 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16474 			ut_params->op);
16475 	}
16476 	if (ut_params->op == NULL)
16477 		return 0;
16478 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
16479 		return 0;
16480 
16481 	return -1;
16482 }
16483 
16484 static int
16485 test_authentication_verify_GMAC_fail_when_corruption(
16486 		struct crypto_testsuite_params *ts_params,
16487 		struct crypto_unittest_params *ut_params,
16488 		const struct test_crypto_vector *reference,
16489 		unsigned int data_corrupted)
16490 {
16491 	int retval;
16492 	uint8_t *plaintext;
16493 	struct rte_cryptodev_info dev_info;
16494 
16495 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16496 	uint64_t feat_flags = dev_info.feature_flags;
16497 
16498 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16499 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16500 		printf("Device doesn't support RAW data-path APIs.\n");
16501 		return TEST_SKIPPED;
16502 	}
16503 
16504 	/* Verify the capabilities */
16505 	struct rte_cryptodev_sym_capability_idx cap_idx;
16506 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16507 	cap_idx.algo.auth = reference->auth_algo;
16508 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16509 			&cap_idx) == NULL)
16510 		return TEST_SKIPPED;
16511 
16512 	/* Create session */
16513 	retval = create_auth_cipher_session(ut_params,
16514 			ts_params->valid_devs[0],
16515 			reference,
16516 			RTE_CRYPTO_AUTH_OP_VERIFY,
16517 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
16518 	if (retval == TEST_SKIPPED)
16519 		return TEST_SKIPPED;
16520 	if (retval < 0)
16521 		return retval;
16522 
16523 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16524 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16525 			"Failed to allocate input buffer in mempool");
16526 
16527 	/* clear mbuf payload */
16528 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16529 			rte_pktmbuf_tailroom(ut_params->ibuf));
16530 
16531 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16532 			reference->plaintext.len);
16533 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16534 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16535 
16536 	debug_hexdump(stdout, "plaintext:", plaintext,
16537 		reference->plaintext.len);
16538 
16539 	/* Create operation */
16540 	retval = create_auth_verify_GMAC_operation(ts_params,
16541 			ut_params,
16542 			reference);
16543 
16544 	if (retval < 0)
16545 		return retval;
16546 
16547 	if (data_corrupted)
16548 		data_corruption(plaintext);
16549 	else
16550 		tag_corruption(plaintext, reference->aad.len);
16551 
16552 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16553 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16554 			ut_params->op);
16555 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16556 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16557 			"authentication not failed");
16558 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16559 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
16560 					       0);
16561 		if (retval != TEST_SUCCESS)
16562 			return retval;
16563 	} else {
16564 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16565 			ut_params->op);
16566 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16567 	}
16568 
16569 	return 0;
16570 }
16571 
16572 static int
16573 test_authenticated_decryption_fail_when_corruption(
16574 		struct crypto_testsuite_params *ts_params,
16575 		struct crypto_unittest_params *ut_params,
16576 		const struct test_crypto_vector *reference,
16577 		unsigned int data_corrupted)
16578 {
16579 	int retval;
16580 
16581 	uint8_t *ciphertext;
16582 	struct rte_cryptodev_info dev_info;
16583 
16584 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16585 	uint64_t feat_flags = dev_info.feature_flags;
16586 
16587 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16588 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16589 		printf("Device doesn't support RAW data-path APIs.\n");
16590 		return TEST_SKIPPED;
16591 	}
16592 
16593 	/* Verify the capabilities */
16594 	struct rte_cryptodev_sym_capability_idx cap_idx;
16595 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16596 	cap_idx.algo.auth = reference->auth_algo;
16597 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16598 			&cap_idx) == NULL)
16599 		return TEST_SKIPPED;
16600 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16601 	cap_idx.algo.cipher = reference->crypto_algo;
16602 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16603 			&cap_idx) == NULL)
16604 		return TEST_SKIPPED;
16605 
16606 	/* Create session */
16607 	retval = create_auth_cipher_session(ut_params,
16608 			ts_params->valid_devs[0],
16609 			reference,
16610 			RTE_CRYPTO_AUTH_OP_VERIFY,
16611 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
16612 	if (retval == TEST_SKIPPED)
16613 		return TEST_SKIPPED;
16614 	if (retval < 0)
16615 		return retval;
16616 
16617 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16618 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16619 			"Failed to allocate input buffer in mempool");
16620 
16621 	/* clear mbuf payload */
16622 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16623 			rte_pktmbuf_tailroom(ut_params->ibuf));
16624 
16625 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16626 			reference->ciphertext.len);
16627 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16628 	memcpy(ciphertext, reference->ciphertext.data,
16629 			reference->ciphertext.len);
16630 
16631 	/* Create operation */
16632 	retval = create_cipher_auth_verify_operation(ts_params,
16633 			ut_params,
16634 			reference);
16635 
16636 	if (retval < 0)
16637 		return retval;
16638 
16639 	if (data_corrupted)
16640 		data_corruption(ciphertext);
16641 	else
16642 		tag_corruption(ciphertext, reference->ciphertext.len);
16643 
16644 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16645 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16646 			ut_params->op);
16647 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16648 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16649 			"authentication not failed");
16650 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16651 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16652 					       0);
16653 		if (retval != TEST_SUCCESS)
16654 			return retval;
16655 	} else {
16656 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16657 			ut_params->op);
16658 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16659 	}
16660 
16661 	return 0;
16662 }
16663 
16664 static int
16665 test_authenticated_encrypt_with_esn(
16666 		struct crypto_testsuite_params *ts_params,
16667 		struct crypto_unittest_params *ut_params,
16668 		const struct test_crypto_vector *reference)
16669 {
16670 	int retval;
16671 
16672 	uint8_t *authciphertext, *plaintext, *auth_tag;
16673 	uint16_t plaintext_pad_len;
16674 	uint8_t cipher_key[reference->cipher_key.len + 1];
16675 	uint8_t auth_key[reference->auth_key.len + 1];
16676 	struct rte_cryptodev_info dev_info;
16677 
16678 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16679 	uint64_t feat_flags = dev_info.feature_flags;
16680 
16681 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16682 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16683 		printf("Device doesn't support RAW data-path APIs.\n");
16684 		return TEST_SKIPPED;
16685 	}
16686 
16687 	/* Verify the capabilities */
16688 	struct rte_cryptodev_sym_capability_idx cap_idx;
16689 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16690 	cap_idx.algo.auth = reference->auth_algo;
16691 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16692 			&cap_idx) == NULL)
16693 		return TEST_SKIPPED;
16694 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16695 	cap_idx.algo.cipher = reference->crypto_algo;
16696 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16697 			&cap_idx) == NULL)
16698 		return TEST_SKIPPED;
16699 
16700 	/* Create session */
16701 	memcpy(cipher_key, reference->cipher_key.data,
16702 			reference->cipher_key.len);
16703 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16704 
16705 	/* Setup Cipher Parameters */
16706 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16707 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16708 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16709 	ut_params->cipher_xform.cipher.key.data = cipher_key;
16710 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16711 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16712 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16713 
16714 	ut_params->cipher_xform.next = &ut_params->auth_xform;
16715 
16716 	/* Setup Authentication Parameters */
16717 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16718 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16719 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16720 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16721 	ut_params->auth_xform.auth.key.data = auth_key;
16722 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16723 	ut_params->auth_xform.next = NULL;
16724 
16725 	/* Create Crypto session*/
16726 	ut_params->sess = rte_cryptodev_sym_session_create(
16727 			ts_params->valid_devs[0], &ut_params->cipher_xform,
16728 			ts_params->session_mpool);
16729 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16730 		return TEST_SKIPPED;
16731 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16732 
16733 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16734 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16735 			"Failed to allocate input buffer in mempool");
16736 
16737 	/* clear mbuf payload */
16738 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16739 			rte_pktmbuf_tailroom(ut_params->ibuf));
16740 
16741 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16742 			reference->plaintext.len);
16743 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16744 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16745 
16746 	/* Create operation */
16747 	retval = create_cipher_auth_operation(ts_params,
16748 			ut_params,
16749 			reference, 0);
16750 
16751 	if (retval < 0)
16752 		return retval;
16753 
16754 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16755 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16756 			ut_params->op);
16757 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16758 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16759 					       0);
16760 		if (retval != TEST_SUCCESS)
16761 			return retval;
16762 	} else
16763 		ut_params->op = process_crypto_request(
16764 			ts_params->valid_devs[0], ut_params->op);
16765 
16766 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16767 
16768 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16769 			"crypto op processing failed");
16770 
16771 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16772 
16773 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16774 			ut_params->op->sym->auth.data.offset);
16775 	auth_tag = authciphertext + plaintext_pad_len;
16776 	debug_hexdump(stdout, "ciphertext:", authciphertext,
16777 			reference->ciphertext.len);
16778 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16779 
16780 	/* Validate obuf */
16781 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16782 			authciphertext,
16783 			reference->ciphertext.data,
16784 			reference->ciphertext.len,
16785 			"Ciphertext data not as expected");
16786 
16787 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
16788 			auth_tag,
16789 			reference->digest.data,
16790 			reference->digest.len,
16791 			"Generated digest not as expected");
16792 
16793 	return TEST_SUCCESS;
16794 
16795 }
16796 
16797 static int
16798 test_authenticated_decrypt_with_esn(
16799 		struct crypto_testsuite_params *ts_params,
16800 		struct crypto_unittest_params *ut_params,
16801 		const struct test_crypto_vector *reference)
16802 {
16803 	int retval;
16804 
16805 	uint8_t *ciphertext;
16806 	uint8_t cipher_key[reference->cipher_key.len + 1];
16807 	uint8_t auth_key[reference->auth_key.len + 1];
16808 	struct rte_cryptodev_info dev_info;
16809 
16810 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16811 	uint64_t feat_flags = dev_info.feature_flags;
16812 
16813 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16814 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16815 		printf("Device doesn't support RAW data-path APIs.\n");
16816 		return TEST_SKIPPED;
16817 	}
16818 
16819 	/* Verify the capabilities */
16820 	struct rte_cryptodev_sym_capability_idx cap_idx;
16821 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16822 	cap_idx.algo.auth = reference->auth_algo;
16823 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16824 			&cap_idx) == NULL)
16825 		return TEST_SKIPPED;
16826 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16827 	cap_idx.algo.cipher = reference->crypto_algo;
16828 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16829 			&cap_idx) == NULL)
16830 		return TEST_SKIPPED;
16831 
16832 	/* Create session */
16833 	memcpy(cipher_key, reference->cipher_key.data,
16834 			reference->cipher_key.len);
16835 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16836 
16837 	/* Setup Authentication Parameters */
16838 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16839 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16840 	ut_params->auth_xform.auth.algo = reference->auth_algo;
16841 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16842 	ut_params->auth_xform.auth.key.data = auth_key;
16843 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
16844 	ut_params->auth_xform.next = &ut_params->cipher_xform;
16845 
16846 	/* Setup Cipher Parameters */
16847 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16848 	ut_params->cipher_xform.next = NULL;
16849 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16850 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16851 	ut_params->cipher_xform.cipher.key.data = cipher_key;
16852 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16853 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16854 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16855 
16856 	/* Create Crypto session*/
16857 	ut_params->sess = rte_cryptodev_sym_session_create(
16858 			ts_params->valid_devs[0], &ut_params->auth_xform,
16859 			ts_params->session_mpool);
16860 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16861 		return TEST_SKIPPED;
16862 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16863 
16864 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16865 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16866 			"Failed to allocate input buffer in mempool");
16867 
16868 	/* clear mbuf payload */
16869 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16870 			rte_pktmbuf_tailroom(ut_params->ibuf));
16871 
16872 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16873 			reference->ciphertext.len);
16874 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16875 	memcpy(ciphertext, reference->ciphertext.data,
16876 			reference->ciphertext.len);
16877 
16878 	/* Create operation */
16879 	retval = create_cipher_auth_verify_operation(ts_params,
16880 			ut_params,
16881 			reference);
16882 
16883 	if (retval < 0)
16884 		return retval;
16885 
16886 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16887 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16888 			ut_params->op);
16889 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16890 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16891 					       0);
16892 		if (retval != TEST_SUCCESS)
16893 			return retval;
16894 	} else
16895 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16896 			ut_params->op);
16897 
16898 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16899 	TEST_ASSERT_EQUAL(ut_params->op->status,
16900 			RTE_CRYPTO_OP_STATUS_SUCCESS,
16901 			"crypto op processing passed");
16902 
16903 	ut_params->obuf = ut_params->op->sym->m_src;
16904 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16905 
16906 	return 0;
16907 }
16908 
16909 static int
16910 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16911 		const struct aead_test_data *tdata,
16912 		void *digest_mem, uint64_t digest_phys)
16913 {
16914 	struct crypto_testsuite_params *ts_params = &testsuite_params;
16915 	struct crypto_unittest_params *ut_params = &unittest_params;
16916 
16917 	const unsigned int auth_tag_len = tdata->auth_tag.len;
16918 	const unsigned int iv_len = tdata->iv.len;
16919 	unsigned int aad_len = tdata->aad.len;
16920 	unsigned int aad_len_pad = 0;
16921 
16922 	/* Generate Crypto op data structure */
16923 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16924 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16925 	TEST_ASSERT_NOT_NULL(ut_params->op,
16926 		"Failed to allocate symmetric crypto operation struct");
16927 
16928 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16929 
16930 	sym_op->aead.digest.data = digest_mem;
16931 
16932 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
16933 			"no room to append digest");
16934 
16935 	sym_op->aead.digest.phys_addr = digest_phys;
16936 
16937 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
16938 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
16939 				auth_tag_len);
16940 		debug_hexdump(stdout, "digest:",
16941 				sym_op->aead.digest.data,
16942 				auth_tag_len);
16943 	}
16944 
16945 	/* Append aad data */
16946 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
16947 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16948 				uint8_t *, IV_OFFSET);
16949 
16950 		/* Copy IV 1 byte after the IV pointer, according to the API */
16951 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
16952 
16953 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
16954 
16955 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16956 				ut_params->ibuf, aad_len);
16957 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16958 				"no room to prepend aad");
16959 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16960 				ut_params->ibuf);
16961 
16962 		memset(sym_op->aead.aad.data, 0, aad_len);
16963 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
16964 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16965 
16966 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16967 		debug_hexdump(stdout, "aad:",
16968 				sym_op->aead.aad.data, aad_len);
16969 	} else {
16970 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16971 				uint8_t *, IV_OFFSET);
16972 
16973 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
16974 
16975 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
16976 
16977 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16978 				ut_params->ibuf, aad_len_pad);
16979 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16980 				"no room to prepend aad");
16981 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16982 				ut_params->ibuf);
16983 
16984 		memset(sym_op->aead.aad.data, 0, aad_len);
16985 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16986 
16987 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16988 		debug_hexdump(stdout, "aad:",
16989 				sym_op->aead.aad.data, aad_len);
16990 	}
16991 
16992 	sym_op->aead.data.length = tdata->plaintext.len;
16993 	sym_op->aead.data.offset = aad_len_pad;
16994 
16995 	return 0;
16996 }
16997 
16998 #define SGL_MAX_NO	16
16999 
17000 static int
17001 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
17002 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
17003 {
17004 	struct crypto_testsuite_params *ts_params = &testsuite_params;
17005 	struct crypto_unittest_params *ut_params = &unittest_params;
17006 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
17007 	int retval;
17008 	int to_trn = 0;
17009 	int to_trn_tbl[SGL_MAX_NO];
17010 	int segs = 1;
17011 	unsigned int trn_data = 0;
17012 	uint8_t *plaintext, *ciphertext, *auth_tag;
17013 	struct rte_cryptodev_info dev_info;
17014 
17015 	/* Verify the capabilities */
17016 	struct rte_cryptodev_sym_capability_idx cap_idx;
17017 	const struct rte_cryptodev_symmetric_capability *capability;
17018 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
17019 	cap_idx.algo.aead = tdata->algo;
17020 	capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
17021 	if (capability == NULL)
17022 		return TEST_SKIPPED;
17023 	if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
17024 			tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
17025 		return TEST_SKIPPED;
17026 
17027 	/*
17028 	 * SGL not supported on AESNI_MB PMD CPU crypto,
17029 	 * OOP not supported on AESNI_GCM CPU crypto
17030 	 */
17031 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
17032 			(gbl_driver_id == rte_cryptodev_driver_id_get(
17033 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
17034 		return TEST_SKIPPED;
17035 
17036 	/* Detailed check for the particular SGL support flag */
17037 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
17038 	if (!oop) {
17039 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
17040 		if (sgl_in && (!(dev_info.feature_flags &
17041 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
17042 			return TEST_SKIPPED;
17043 
17044 		uint64_t feat_flags = dev_info.feature_flags;
17045 
17046 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
17047 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
17048 			printf("Device doesn't support RAW data-path APIs.\n");
17049 			return TEST_SKIPPED;
17050 		}
17051 	} else {
17052 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
17053 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
17054 				tdata->plaintext.len;
17055 		/* Raw data path API does not support OOP */
17056 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
17057 			return TEST_SKIPPED;
17058 		if (sgl_in && !sgl_out) {
17059 			if (!(dev_info.feature_flags &
17060 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
17061 				return TEST_SKIPPED;
17062 		} else if (!sgl_in && sgl_out) {
17063 			if (!(dev_info.feature_flags &
17064 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
17065 				return TEST_SKIPPED;
17066 		} else if (sgl_in && sgl_out) {
17067 			if (!(dev_info.feature_flags &
17068 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
17069 				return TEST_SKIPPED;
17070 		}
17071 	}
17072 
17073 	if (fragsz > tdata->plaintext.len)
17074 		fragsz = tdata->plaintext.len;
17075 
17076 	uint16_t plaintext_len = fragsz;
17077 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
17078 
17079 	if (fragsz_oop > tdata->plaintext.len)
17080 		frag_size_oop = tdata->plaintext.len;
17081 
17082 	int ecx = 0;
17083 	void *digest_mem = NULL;
17084 
17085 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
17086 
17087 	if (tdata->plaintext.len % fragsz != 0) {
17088 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
17089 			return 1;
17090 	}	else {
17091 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
17092 			return 1;
17093 	}
17094 
17095 	/*
17096 	 * For out-of-place we need to alloc another mbuf
17097 	 */
17098 	if (oop) {
17099 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17100 		rte_pktmbuf_append(ut_params->obuf,
17101 				frag_size_oop + prepend_len);
17102 		buf_oop = ut_params->obuf;
17103 	}
17104 
17105 	/* Create AEAD session */
17106 	retval = create_aead_session(ts_params->valid_devs[0],
17107 			tdata->algo,
17108 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
17109 			tdata->key.data, tdata->key.len,
17110 			tdata->aad.len, tdata->auth_tag.len,
17111 			tdata->iv.len);
17112 	if (retval < 0)
17113 		return retval;
17114 
17115 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17116 
17117 	/* clear mbuf payload */
17118 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
17119 			rte_pktmbuf_tailroom(ut_params->ibuf));
17120 
17121 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17122 			plaintext_len);
17123 
17124 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
17125 
17126 	trn_data += plaintext_len;
17127 
17128 	buf = ut_params->ibuf;
17129 
17130 	/*
17131 	 * Loop until no more fragments
17132 	 */
17133 
17134 	while (trn_data < tdata->plaintext.len) {
17135 		++segs;
17136 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
17137 				(tdata->plaintext.len - trn_data) : fragsz;
17138 
17139 		to_trn_tbl[ecx++] = to_trn;
17140 
17141 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
17142 		buf = buf->next;
17143 
17144 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
17145 				rte_pktmbuf_tailroom(buf));
17146 
17147 		/* OOP */
17148 		if (oop && !fragsz_oop) {
17149 			buf_last_oop = buf_oop->next =
17150 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
17151 			buf_oop = buf_oop->next;
17152 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17153 					0, rte_pktmbuf_tailroom(buf_oop));
17154 			rte_pktmbuf_append(buf_oop, to_trn);
17155 		}
17156 
17157 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
17158 				to_trn);
17159 
17160 		memcpy(plaintext, tdata->plaintext.data + trn_data,
17161 				to_trn);
17162 		trn_data += to_trn;
17163 		if (trn_data  == tdata->plaintext.len) {
17164 			if (oop) {
17165 				if (!fragsz_oop)
17166 					digest_mem = rte_pktmbuf_append(buf_oop,
17167 						tdata->auth_tag.len);
17168 			} else
17169 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
17170 					tdata->auth_tag.len);
17171 		}
17172 	}
17173 
17174 	uint64_t digest_phys = 0;
17175 
17176 	ut_params->ibuf->nb_segs = segs;
17177 
17178 	segs = 1;
17179 	if (fragsz_oop && oop) {
17180 		to_trn = 0;
17181 		ecx = 0;
17182 
17183 		if (frag_size_oop == tdata->plaintext.len) {
17184 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
17185 				tdata->auth_tag.len);
17186 
17187 			digest_phys = rte_pktmbuf_iova_offset(
17188 					ut_params->obuf,
17189 					tdata->plaintext.len + prepend_len);
17190 		}
17191 
17192 		trn_data = frag_size_oop;
17193 		while (trn_data < tdata->plaintext.len) {
17194 			++segs;
17195 			to_trn =
17196 				(tdata->plaintext.len - trn_data <
17197 						frag_size_oop) ?
17198 				(tdata->plaintext.len - trn_data) :
17199 						frag_size_oop;
17200 
17201 			to_trn_tbl[ecx++] = to_trn;
17202 
17203 			buf_last_oop = buf_oop->next =
17204 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
17205 			buf_oop = buf_oop->next;
17206 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
17207 					0, rte_pktmbuf_tailroom(buf_oop));
17208 			rte_pktmbuf_append(buf_oop, to_trn);
17209 
17210 			trn_data += to_trn;
17211 
17212 			if (trn_data  == tdata->plaintext.len) {
17213 				digest_mem = rte_pktmbuf_append(buf_oop,
17214 					tdata->auth_tag.len);
17215 			}
17216 		}
17217 
17218 		ut_params->obuf->nb_segs = segs;
17219 	}
17220 
17221 	/*
17222 	 * Place digest at the end of the last buffer
17223 	 */
17224 	if (!digest_phys)
17225 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
17226 	if (oop && buf_last_oop)
17227 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
17228 
17229 	if (!digest_mem && !oop) {
17230 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
17231 				+ tdata->auth_tag.len);
17232 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
17233 				tdata->plaintext.len);
17234 	}
17235 
17236 	/* Create AEAD operation */
17237 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
17238 			tdata, digest_mem, digest_phys);
17239 
17240 	if (retval < 0)
17241 		return retval;
17242 
17243 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
17244 
17245 	ut_params->op->sym->m_src = ut_params->ibuf;
17246 	if (oop)
17247 		ut_params->op->sym->m_dst = ut_params->obuf;
17248 
17249 	/* Process crypto operation */
17250 	if (oop == IN_PLACE &&
17251 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
17252 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
17253 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
17254 		retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
17255 					       0);
17256 		if (retval != TEST_SUCCESS)
17257 			return retval;
17258 	} else
17259 		TEST_ASSERT_NOT_NULL(
17260 			process_crypto_request(ts_params->valid_devs[0],
17261 			ut_params->op), "failed to process sym crypto op");
17262 
17263 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
17264 			"crypto op processing failed");
17265 
17266 
17267 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
17268 			uint8_t *, prepend_len);
17269 	if (oop) {
17270 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
17271 				uint8_t *, prepend_len);
17272 	}
17273 
17274 	if (fragsz_oop)
17275 		fragsz = fragsz_oop;
17276 
17277 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
17278 			ciphertext,
17279 			tdata->ciphertext.data,
17280 			fragsz,
17281 			"Ciphertext data not as expected");
17282 
17283 	buf = ut_params->op->sym->m_src->next;
17284 	if (oop)
17285 		buf = ut_params->op->sym->m_dst->next;
17286 
17287 	unsigned int off = fragsz;
17288 
17289 	ecx = 0;
17290 	while (buf) {
17291 		ciphertext = rte_pktmbuf_mtod(buf,
17292 				uint8_t *);
17293 
17294 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
17295 				ciphertext,
17296 				tdata->ciphertext.data + off,
17297 				to_trn_tbl[ecx],
17298 				"Ciphertext data not as expected");
17299 
17300 		off += to_trn_tbl[ecx++];
17301 		buf = buf->next;
17302 	}
17303 
17304 	auth_tag = digest_mem;
17305 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
17306 			auth_tag,
17307 			tdata->auth_tag.data,
17308 			tdata->auth_tag.len,
17309 			"Generated auth tag not as expected");
17310 
17311 	return 0;
17312 }
17313 
17314 static int
17315 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
17316 {
17317 	return test_authenticated_encryption_SGL(
17318 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
17319 }
17320 
17321 static int
17322 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
17323 {
17324 	return test_authenticated_encryption_SGL(
17325 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
17326 }
17327 
17328 static int
17329 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
17330 {
17331 	return test_authenticated_encryption_SGL(
17332 			&gcm_test_case_8, OUT_OF_PLACE, 400,
17333 			gcm_test_case_8.plaintext.len);
17334 }
17335 
17336 static int
17337 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
17338 {
17339 	/* This test is not for OPENSSL PMD */
17340 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
17341 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
17342 		return TEST_SKIPPED;
17343 
17344 	return test_authenticated_encryption_SGL(
17345 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
17346 }
17347 
17348 static int
17349 test_authentication_verify_fail_when_data_corrupted(
17350 		struct crypto_testsuite_params *ts_params,
17351 		struct crypto_unittest_params *ut_params,
17352 		const struct test_crypto_vector *reference)
17353 {
17354 	return test_authentication_verify_fail_when_data_corruption(
17355 			ts_params, ut_params, reference, 1);
17356 }
17357 
17358 static int
17359 test_authentication_verify_fail_when_tag_corrupted(
17360 		struct crypto_testsuite_params *ts_params,
17361 		struct crypto_unittest_params *ut_params,
17362 		const struct test_crypto_vector *reference)
17363 {
17364 	return test_authentication_verify_fail_when_data_corruption(
17365 			ts_params, ut_params, reference, 0);
17366 }
17367 
17368 static int
17369 test_authentication_verify_GMAC_fail_when_data_corrupted(
17370 		struct crypto_testsuite_params *ts_params,
17371 		struct crypto_unittest_params *ut_params,
17372 		const struct test_crypto_vector *reference)
17373 {
17374 	return test_authentication_verify_GMAC_fail_when_corruption(
17375 			ts_params, ut_params, reference, 1);
17376 }
17377 
17378 static int
17379 test_authentication_verify_GMAC_fail_when_tag_corrupted(
17380 		struct crypto_testsuite_params *ts_params,
17381 		struct crypto_unittest_params *ut_params,
17382 		const struct test_crypto_vector *reference)
17383 {
17384 	return test_authentication_verify_GMAC_fail_when_corruption(
17385 			ts_params, ut_params, reference, 0);
17386 }
17387 
17388 static int
17389 test_authenticated_decryption_fail_when_data_corrupted(
17390 		struct crypto_testsuite_params *ts_params,
17391 		struct crypto_unittest_params *ut_params,
17392 		const struct test_crypto_vector *reference)
17393 {
17394 	return test_authenticated_decryption_fail_when_corruption(
17395 			ts_params, ut_params, reference, 1);
17396 }
17397 
17398 static int
17399 test_authenticated_decryption_fail_when_tag_corrupted(
17400 		struct crypto_testsuite_params *ts_params,
17401 		struct crypto_unittest_params *ut_params,
17402 		const struct test_crypto_vector *reference)
17403 {
17404 	return test_authenticated_decryption_fail_when_corruption(
17405 			ts_params, ut_params, reference, 0);
17406 }
17407 
17408 static int
17409 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
17410 {
17411 	return test_authentication_verify_fail_when_data_corrupted(
17412 			&testsuite_params, &unittest_params,
17413 			&hmac_sha1_test_crypto_vector);
17414 }
17415 
17416 static int
17417 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
17418 {
17419 	return test_authentication_verify_fail_when_tag_corrupted(
17420 			&testsuite_params, &unittest_params,
17421 			&hmac_sha1_test_crypto_vector);
17422 }
17423 
17424 static int
17425 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
17426 {
17427 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
17428 			&testsuite_params, &unittest_params,
17429 			&aes128_gmac_test_vector);
17430 }
17431 
17432 static int
17433 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
17434 {
17435 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
17436 			&testsuite_params, &unittest_params,
17437 			&aes128_gmac_test_vector);
17438 }
17439 
17440 static int
17441 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
17442 {
17443 	return test_authenticated_decryption_fail_when_data_corrupted(
17444 			&testsuite_params,
17445 			&unittest_params,
17446 			&aes128cbc_hmac_sha1_test_vector);
17447 }
17448 
17449 static int
17450 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
17451 {
17452 	return test_authenticated_decryption_fail_when_tag_corrupted(
17453 			&testsuite_params,
17454 			&unittest_params,
17455 			&aes128cbc_hmac_sha1_test_vector);
17456 }
17457 
17458 static int
17459 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17460 {
17461 	return test_authenticated_encrypt_with_esn(
17462 			&testsuite_params,
17463 			&unittest_params,
17464 			&aes128cbc_hmac_sha1_aad_test_vector);
17465 }
17466 
17467 static int
17468 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
17469 {
17470 	return test_authenticated_decrypt_with_esn(
17471 			&testsuite_params,
17472 			&unittest_params,
17473 			&aes128cbc_hmac_sha1_aad_test_vector);
17474 }
17475 
17476 static int
17477 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
17478 {
17479 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
17480 }
17481 
17482 static int
17483 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
17484 {
17485 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
17486 }
17487 
17488 static int
17489 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
17490 {
17491 	return test_authenticated_encryption_SGL(
17492 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
17493 		chacha20_poly1305_case_2.plaintext.len);
17494 }
17495 
17496 #ifdef RTE_CRYPTO_SCHEDULER
17497 
17498 /* global AESNI worker IDs for the scheduler test */
17499 uint8_t aesni_ids[2];
17500 
17501 static int
17502 scheduler_testsuite_setup(void)
17503 {
17504 	uint32_t i = 0;
17505 	int32_t nb_devs, ret;
17506 	char vdev_args[VDEV_ARGS_SIZE] = {""};
17507 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
17508 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
17509 	uint16_t worker_core_count = 0;
17510 	uint16_t socket_id = 0;
17511 
17512 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
17513 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
17514 
17515 		/* Identify the Worker Cores
17516 		 * Use 2 worker cores for the device args
17517 		 */
17518 		RTE_LCORE_FOREACH_WORKER(i) {
17519 			if (worker_core_count > 1)
17520 				break;
17521 			snprintf(vdev_args, sizeof(vdev_args),
17522 					"%s%d", temp_str, i);
17523 			strcpy(temp_str, vdev_args);
17524 			strlcat(temp_str, ";", sizeof(temp_str));
17525 			worker_core_count++;
17526 			socket_id = rte_lcore_to_socket_id(i);
17527 		}
17528 		if (worker_core_count != 2) {
17529 			RTE_LOG(ERR, USER1,
17530 				"Cryptodev scheduler test require at least "
17531 				"two worker cores to run. "
17532 				"Please use the correct coremask.\n");
17533 			return TEST_FAILED;
17534 		}
17535 		strcpy(temp_str, vdev_args);
17536 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
17537 				temp_str, socket_id);
17538 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
17539 		nb_devs = rte_cryptodev_device_count_by_driver(
17540 				rte_cryptodev_driver_id_get(
17541 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
17542 		if (nb_devs < 1) {
17543 			ret = rte_vdev_init(
17544 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
17545 					vdev_args);
17546 			TEST_ASSERT(ret == 0,
17547 				"Failed to create instance %u of pmd : %s",
17548 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
17549 		}
17550 	}
17551 	return testsuite_setup();
17552 }
17553 
17554 static int
17555 test_scheduler_attach_worker_op(void)
17556 {
17557 	struct crypto_testsuite_params *ts_params = &testsuite_params;
17558 	uint8_t sched_id = ts_params->valid_devs[0];
17559 	uint32_t i, nb_devs_attached = 0;
17560 	int ret;
17561 	char vdev_name[32];
17562 	unsigned int count = rte_cryptodev_count();
17563 
17564 	/* create 2 AESNI_MB vdevs on top of existing devices */
17565 	for (i = count; i < count + 2; i++) {
17566 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
17567 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
17568 				i);
17569 		ret = rte_vdev_init(vdev_name, NULL);
17570 
17571 		TEST_ASSERT(ret == 0,
17572 			"Failed to create instance %u of"
17573 			" pmd : %s",
17574 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17575 
17576 		if (ret < 0) {
17577 			RTE_LOG(ERR, USER1,
17578 				"Failed to create 2 AESNI MB PMDs.\n");
17579 			return TEST_SKIPPED;
17580 		}
17581 	}
17582 
17583 	/* attach 2 AESNI_MB cdevs */
17584 	for (i = count; i < count + 2; i++) {
17585 		struct rte_cryptodev_info info;
17586 		unsigned int session_size;
17587 
17588 		rte_cryptodev_info_get(i, &info);
17589 		if (info.driver_id != rte_cryptodev_driver_id_get(
17590 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17591 			continue;
17592 
17593 		session_size = rte_cryptodev_sym_get_private_session_size(i);
17594 		/*
17595 		 * Create the session mempool again, since now there are new devices
17596 		 * to use the mempool.
17597 		 */
17598 		if (ts_params->session_mpool) {
17599 			rte_mempool_free(ts_params->session_mpool);
17600 			ts_params->session_mpool = NULL;
17601 		}
17602 
17603 		if (info.sym.max_nb_sessions != 0 &&
17604 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17605 			RTE_LOG(ERR, USER1,
17606 					"Device does not support "
17607 					"at least %u sessions\n",
17608 					MAX_NB_SESSIONS);
17609 			return TEST_FAILED;
17610 		}
17611 		/*
17612 		 * Create mempool with maximum number of sessions,
17613 		 * to include the session headers
17614 		 */
17615 		if (ts_params->session_mpool == NULL) {
17616 			ts_params->session_mpool =
17617 				rte_cryptodev_sym_session_pool_create(
17618 						"test_sess_mp",
17619 						MAX_NB_SESSIONS, session_size,
17620 						0, 0, SOCKET_ID_ANY);
17621 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17622 					"session mempool allocation failed");
17623 		}
17624 
17625 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
17626 
17627 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17628 				(uint8_t)i);
17629 
17630 		TEST_ASSERT(ret == 0,
17631 			"Failed to attach device %u of pmd : %s", i,
17632 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17633 
17634 		aesni_ids[nb_devs_attached] = (uint8_t)i;
17635 
17636 		nb_devs_attached++;
17637 	}
17638 
17639 	return 0;
17640 }
17641 
17642 static int
17643 test_scheduler_detach_worker_op(void)
17644 {
17645 	struct crypto_testsuite_params *ts_params = &testsuite_params;
17646 	uint8_t sched_id = ts_params->valid_devs[0];
17647 	uint32_t i;
17648 	int ret;
17649 
17650 	for (i = 0; i < 2; i++) {
17651 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17652 				aesni_ids[i]);
17653 		TEST_ASSERT(ret == 0,
17654 			"Failed to detach device %u", aesni_ids[i]);
17655 	}
17656 
17657 	return 0;
17658 }
17659 
17660 static int
17661 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17662 {
17663 	struct crypto_testsuite_params *ts_params = &testsuite_params;
17664 	uint8_t sched_id = ts_params->valid_devs[0];
17665 	/* set mode */
17666 	return rte_cryptodev_scheduler_mode_set(sched_id,
17667 		scheduler_mode);
17668 }
17669 
17670 static int
17671 test_scheduler_mode_roundrobin_op(void)
17672 {
17673 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17674 			0, "Failed to set roundrobin mode");
17675 	return 0;
17676 
17677 }
17678 
17679 static int
17680 test_scheduler_mode_multicore_op(void)
17681 {
17682 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17683 			0, "Failed to set multicore mode");
17684 
17685 	return 0;
17686 }
17687 
17688 static int
17689 test_scheduler_mode_failover_op(void)
17690 {
17691 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17692 			0, "Failed to set failover mode");
17693 
17694 	return 0;
17695 }
17696 
17697 static int
17698 test_scheduler_mode_pkt_size_distr_op(void)
17699 {
17700 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17701 			0, "Failed to set pktsize mode");
17702 
17703 	return 0;
17704 }
17705 
17706 static int
17707 scheduler_multicore_testsuite_setup(void)
17708 {
17709 	if (test_scheduler_attach_worker_op() < 0)
17710 		return TEST_SKIPPED;
17711 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17712 		return TEST_SKIPPED;
17713 	return 0;
17714 }
17715 
17716 static int
17717 scheduler_roundrobin_testsuite_setup(void)
17718 {
17719 	if (test_scheduler_attach_worker_op() < 0)
17720 		return TEST_SKIPPED;
17721 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17722 		return TEST_SKIPPED;
17723 	return 0;
17724 }
17725 
17726 static int
17727 scheduler_failover_testsuite_setup(void)
17728 {
17729 	if (test_scheduler_attach_worker_op() < 0)
17730 		return TEST_SKIPPED;
17731 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17732 		return TEST_SKIPPED;
17733 	return 0;
17734 }
17735 
17736 static int
17737 scheduler_pkt_size_distr_testsuite_setup(void)
17738 {
17739 	if (test_scheduler_attach_worker_op() < 0)
17740 		return TEST_SKIPPED;
17741 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17742 		return TEST_SKIPPED;
17743 	return 0;
17744 }
17745 
17746 static void
17747 scheduler_mode_testsuite_teardown(void)
17748 {
17749 	test_scheduler_detach_worker_op();
17750 }
17751 
17752 #endif /* RTE_CRYPTO_SCHEDULER */
17753 
17754 static struct unit_test_suite end_testsuite = {
17755 	.suite_name = NULL,
17756 	.setup = NULL,
17757 	.teardown = NULL,
17758 	.unit_test_suites = NULL
17759 };
17760 
17761 #ifdef RTE_LIB_SECURITY
17762 static struct unit_test_suite ipsec_proto_testsuite  = {
17763 	.suite_name = "IPsec Proto Unit Test Suite",
17764 	.setup = ipsec_proto_testsuite_setup,
17765 	.unit_test_cases = {
17766 		TEST_CASE_NAMED_WITH_DATA(
17767 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17768 			ut_setup_security, ut_teardown,
17769 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17770 		TEST_CASE_NAMED_WITH_DATA(
17771 			"Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17772 			ut_setup_security, ut_teardown,
17773 			test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17774 		TEST_CASE_NAMED_WITH_DATA(
17775 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17776 			ut_setup_security, ut_teardown,
17777 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17778 		TEST_CASE_NAMED_WITH_DATA(
17779 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17780 			ut_setup_security, ut_teardown,
17781 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17782 		TEST_CASE_NAMED_WITH_DATA(
17783 			"Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17784 			ut_setup_security, ut_teardown,
17785 			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17786 		TEST_CASE_NAMED_WITH_DATA(
17787 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17788 			ut_setup_security, ut_teardown,
17789 			test_ipsec_proto_known_vec,
17790 			&pkt_aes_128_cbc_md5),
17791 		TEST_CASE_NAMED_WITH_DATA(
17792 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17793 			ut_setup_security, ut_teardown,
17794 			test_ipsec_proto_known_vec,
17795 			&pkt_aes_128_cbc_hmac_sha256),
17796 		TEST_CASE_NAMED_WITH_DATA(
17797 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17798 			ut_setup_security, ut_teardown,
17799 			test_ipsec_proto_known_vec,
17800 			&pkt_aes_128_cbc_hmac_sha384),
17801 		TEST_CASE_NAMED_WITH_DATA(
17802 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17803 			ut_setup_security, ut_teardown,
17804 			test_ipsec_proto_known_vec,
17805 			&pkt_aes_128_cbc_hmac_sha512),
17806 		TEST_CASE_NAMED_WITH_DATA(
17807 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17808 			ut_setup_security, ut_teardown,
17809 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
17810 		TEST_CASE_NAMED_WITH_DATA(
17811 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17812 			ut_setup_security, ut_teardown,
17813 			test_ipsec_proto_known_vec,
17814 			&pkt_aes_128_cbc_hmac_sha256_v6),
17815 		TEST_CASE_NAMED_WITH_DATA(
17816 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17817 			ut_setup_security, ut_teardown,
17818 			test_ipsec_proto_known_vec,
17819 			&pkt_null_aes_xcbc),
17820 		TEST_CASE_NAMED_WITH_DATA(
17821 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17822 			ut_setup_security, ut_teardown,
17823 			test_ipsec_proto_known_vec,
17824 			&pkt_des_cbc_hmac_sha256),
17825 		TEST_CASE_NAMED_WITH_DATA(
17826 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17827 			ut_setup_security, ut_teardown,
17828 			test_ipsec_proto_known_vec,
17829 			&pkt_des_cbc_hmac_sha384),
17830 		TEST_CASE_NAMED_WITH_DATA(
17831 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17832 			ut_setup_security, ut_teardown,
17833 			test_ipsec_proto_known_vec,
17834 			&pkt_des_cbc_hmac_sha512),
17835 		TEST_CASE_NAMED_WITH_DATA(
17836 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17837 			ut_setup_security, ut_teardown,
17838 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
17839 		TEST_CASE_NAMED_WITH_DATA(
17840 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17841 			ut_setup_security, ut_teardown,
17842 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
17843 		TEST_CASE_NAMED_WITH_DATA(
17844 			"Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17845 			ut_setup_security, ut_teardown,
17846 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
17847 		TEST_CASE_NAMED_WITH_DATA(
17848 			"Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17849 			ut_setup_security, ut_teardown,
17850 			test_ipsec_proto_known_vec,
17851 			&pkt_des_cbc_hmac_sha256_v6),
17852 		TEST_CASE_NAMED_WITH_DATA(
17853 			"Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17854 			ut_setup_security, ut_teardown,
17855 			test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
17856 		TEST_CASE_NAMED_WITH_DATA(
17857 			"Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17858 			ut_setup_security, ut_teardown,
17859 			test_ipsec_proto_known_vec,
17860 			&pkt_ah_tunnel_sha256),
17861 		TEST_CASE_NAMED_WITH_DATA(
17862 			"Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17863 			ut_setup_security, ut_teardown,
17864 			test_ipsec_proto_known_vec,
17865 			&pkt_ah_transport_sha256),
17866 		TEST_CASE_NAMED_WITH_DATA(
17867 			"Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17868 			ut_setup_security, ut_teardown,
17869 			test_ipsec_proto_known_vec,
17870 			&pkt_ah_ipv4_aes_gmac_128),
17871 		TEST_CASE_NAMED_WITH_DATA(
17872 			"Outbound fragmented packet",
17873 			ut_setup_security, ut_teardown,
17874 			test_ipsec_proto_known_vec_fragmented,
17875 			&pkt_aes_128_gcm_frag),
17876 		TEST_CASE_NAMED_WITH_DATA(
17877 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17878 			ut_setup_security, ut_teardown,
17879 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
17880 		TEST_CASE_NAMED_WITH_DATA(
17881 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17882 			ut_setup_security, ut_teardown,
17883 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
17884 		TEST_CASE_NAMED_WITH_DATA(
17885 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17886 			ut_setup_security, ut_teardown,
17887 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
17888 		TEST_CASE_NAMED_WITH_DATA(
17889 			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17890 			ut_setup_security, ut_teardown,
17891 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
17892 		TEST_CASE_NAMED_WITH_DATA(
17893 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
17894 			ut_setup_security, ut_teardown,
17895 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
17896 		TEST_CASE_NAMED_WITH_DATA(
17897 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17898 			ut_setup_security, ut_teardown,
17899 			test_ipsec_proto_known_vec_inb,
17900 			&pkt_aes_128_cbc_md5),
17901 		TEST_CASE_NAMED_WITH_DATA(
17902 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17903 			ut_setup_security, ut_teardown,
17904 			test_ipsec_proto_known_vec_inb,
17905 			&pkt_aes_128_cbc_hmac_sha256),
17906 		TEST_CASE_NAMED_WITH_DATA(
17907 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17908 			ut_setup_security, ut_teardown,
17909 			test_ipsec_proto_known_vec_inb,
17910 			&pkt_aes_128_cbc_hmac_sha384),
17911 		TEST_CASE_NAMED_WITH_DATA(
17912 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17913 			ut_setup_security, ut_teardown,
17914 			test_ipsec_proto_known_vec_inb,
17915 			&pkt_aes_128_cbc_hmac_sha512),
17916 		TEST_CASE_NAMED_WITH_DATA(
17917 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17918 			ut_setup_security, ut_teardown,
17919 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
17920 		TEST_CASE_NAMED_WITH_DATA(
17921 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17922 			ut_setup_security, ut_teardown,
17923 			test_ipsec_proto_known_vec_inb,
17924 			&pkt_aes_128_cbc_hmac_sha256_v6),
17925 		TEST_CASE_NAMED_WITH_DATA(
17926 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17927 			ut_setup_security, ut_teardown,
17928 			test_ipsec_proto_known_vec_inb,
17929 			&pkt_null_aes_xcbc),
17930 		TEST_CASE_NAMED_WITH_DATA(
17931 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17932 			ut_setup_security, ut_teardown,
17933 			test_ipsec_proto_known_vec_inb,
17934 			&pkt_des_cbc_hmac_sha256),
17935 		TEST_CASE_NAMED_WITH_DATA(
17936 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17937 			ut_setup_security, ut_teardown,
17938 			test_ipsec_proto_known_vec_inb,
17939 			&pkt_des_cbc_hmac_sha384),
17940 		TEST_CASE_NAMED_WITH_DATA(
17941 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17942 			ut_setup_security, ut_teardown,
17943 			test_ipsec_proto_known_vec_inb,
17944 			&pkt_des_cbc_hmac_sha512),
17945 		TEST_CASE_NAMED_WITH_DATA(
17946 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17947 			ut_setup_security, ut_teardown,
17948 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
17949 		TEST_CASE_NAMED_WITH_DATA(
17950 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17951 			ut_setup_security, ut_teardown,
17952 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
17953 		TEST_CASE_NAMED_WITH_DATA(
17954 			"Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17955 			ut_setup_security, ut_teardown,
17956 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
17957 		TEST_CASE_NAMED_WITH_DATA(
17958 			"Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17959 			ut_setup_security, ut_teardown,
17960 			test_ipsec_proto_known_vec_inb,
17961 			&pkt_des_cbc_hmac_sha256_v6),
17962 		TEST_CASE_NAMED_WITH_DATA(
17963 			"Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17964 			ut_setup_security, ut_teardown,
17965 			test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
17966 		TEST_CASE_NAMED_WITH_DATA(
17967 			"Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17968 			ut_setup_security, ut_teardown,
17969 			test_ipsec_proto_known_vec_inb,
17970 			&pkt_ah_tunnel_sha256),
17971 		TEST_CASE_NAMED_WITH_DATA(
17972 			"Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17973 			ut_setup_security, ut_teardown,
17974 			test_ipsec_proto_known_vec_inb,
17975 			&pkt_ah_transport_sha256),
17976 		TEST_CASE_NAMED_WITH_DATA(
17977 			"Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17978 			ut_setup_security, ut_teardown,
17979 			test_ipsec_proto_known_vec_inb,
17980 			&pkt_ah_ipv4_aes_gmac_128),
17981 		TEST_CASE_NAMED_ST(
17982 			"Combined test alg list",
17983 			ut_setup_security, ut_teardown,
17984 			test_ipsec_proto_display_list),
17985 		TEST_CASE_NAMED_ST(
17986 			"Combined test alg list (AH)",
17987 			ut_setup_security, ut_teardown,
17988 			test_ipsec_proto_ah_tunnel_ipv4),
17989 		TEST_CASE_NAMED_ST(
17990 			"IV generation",
17991 			ut_setup_security, ut_teardown,
17992 			test_ipsec_proto_iv_gen),
17993 		TEST_CASE_NAMED_ST(
17994 			"UDP encapsulation",
17995 			ut_setup_security, ut_teardown,
17996 			test_ipsec_proto_udp_encap),
17997 		TEST_CASE_NAMED_ST(
17998 			"UDP encapsulation with custom ports",
17999 			ut_setup_security, ut_teardown,
18000 			test_ipsec_proto_udp_encap_custom_ports),
18001 		TEST_CASE_NAMED_ST(
18002 			"UDP encapsulation ports verification test",
18003 			ut_setup_security, ut_teardown,
18004 			test_ipsec_proto_udp_ports_verify),
18005 		TEST_CASE_NAMED_ST(
18006 			"SA expiry packets soft",
18007 			ut_setup_security, ut_teardown,
18008 			test_ipsec_proto_sa_exp_pkts_soft),
18009 		TEST_CASE_NAMED_ST(
18010 			"SA expiry packets hard",
18011 			ut_setup_security, ut_teardown,
18012 			test_ipsec_proto_sa_exp_pkts_hard),
18013 		TEST_CASE_NAMED_ST(
18014 			"Negative test: ICV corruption",
18015 			ut_setup_security, ut_teardown,
18016 			test_ipsec_proto_err_icv_corrupt),
18017 		TEST_CASE_NAMED_ST(
18018 			"Tunnel dst addr verification",
18019 			ut_setup_security, ut_teardown,
18020 			test_ipsec_proto_tunnel_dst_addr_verify),
18021 		TEST_CASE_NAMED_ST(
18022 			"Tunnel src and dst addr verification",
18023 			ut_setup_security, ut_teardown,
18024 			test_ipsec_proto_tunnel_src_dst_addr_verify),
18025 		TEST_CASE_NAMED_ST(
18026 			"Inner IP checksum",
18027 			ut_setup_security, ut_teardown,
18028 			test_ipsec_proto_inner_ip_csum),
18029 		TEST_CASE_NAMED_ST(
18030 			"Inner L4 checksum",
18031 			ut_setup_security, ut_teardown,
18032 			test_ipsec_proto_inner_l4_csum),
18033 		TEST_CASE_NAMED_ST(
18034 			"Tunnel IPv4 in IPv4",
18035 			ut_setup_security, ut_teardown,
18036 			test_ipsec_proto_tunnel_v4_in_v4),
18037 		TEST_CASE_NAMED_ST(
18038 			"Tunnel IPv6 in IPv6",
18039 			ut_setup_security, ut_teardown,
18040 			test_ipsec_proto_tunnel_v6_in_v6),
18041 		TEST_CASE_NAMED_ST(
18042 			"Tunnel IPv4 in IPv6",
18043 			ut_setup_security, ut_teardown,
18044 			test_ipsec_proto_tunnel_v4_in_v6),
18045 		TEST_CASE_NAMED_ST(
18046 			"Tunnel IPv6 in IPv4",
18047 			ut_setup_security, ut_teardown,
18048 			test_ipsec_proto_tunnel_v6_in_v4),
18049 		TEST_CASE_NAMED_ST(
18050 			"Transport IPv4",
18051 			ut_setup_security, ut_teardown,
18052 			test_ipsec_proto_transport_v4),
18053 		TEST_CASE_NAMED_ST(
18054 			"AH transport IPv4",
18055 			ut_setup_security, ut_teardown,
18056 			test_ipsec_proto_ah_transport_ipv4),
18057 		TEST_CASE_NAMED_ST(
18058 			"Transport l4 checksum",
18059 			ut_setup_security, ut_teardown,
18060 			test_ipsec_proto_transport_l4_csum),
18061 		TEST_CASE_NAMED_ST(
18062 			"Statistics: success",
18063 			ut_setup_security, ut_teardown,
18064 			test_ipsec_proto_stats),
18065 		TEST_CASE_NAMED_ST(
18066 			"Fragmented packet",
18067 			ut_setup_security, ut_teardown,
18068 			test_ipsec_proto_pkt_fragment),
18069 		TEST_CASE_NAMED_ST(
18070 			"Tunnel header copy DF (inner 0)",
18071 			ut_setup_security, ut_teardown,
18072 			test_ipsec_proto_copy_df_inner_0),
18073 		TEST_CASE_NAMED_ST(
18074 			"Tunnel header copy DF (inner 1)",
18075 			ut_setup_security, ut_teardown,
18076 			test_ipsec_proto_copy_df_inner_1),
18077 		TEST_CASE_NAMED_ST(
18078 			"Tunnel header set DF 0 (inner 1)",
18079 			ut_setup_security, ut_teardown,
18080 			test_ipsec_proto_set_df_0_inner_1),
18081 		TEST_CASE_NAMED_ST(
18082 			"Tunnel header set DF 1 (inner 0)",
18083 			ut_setup_security, ut_teardown,
18084 			test_ipsec_proto_set_df_1_inner_0),
18085 		TEST_CASE_NAMED_ST(
18086 			"Tunnel header IPv4 copy DSCP (inner 0)",
18087 			ut_setup_security, ut_teardown,
18088 			test_ipsec_proto_ipv4_copy_dscp_inner_0),
18089 		TEST_CASE_NAMED_ST(
18090 			"Tunnel header IPv4 copy DSCP (inner 1)",
18091 			ut_setup_security, ut_teardown,
18092 			test_ipsec_proto_ipv4_copy_dscp_inner_1),
18093 		TEST_CASE_NAMED_ST(
18094 			"Tunnel header IPv4 set DSCP 0 (inner 1)",
18095 			ut_setup_security, ut_teardown,
18096 			test_ipsec_proto_ipv4_set_dscp_0_inner_1),
18097 		TEST_CASE_NAMED_ST(
18098 			"Tunnel header IPv4 set DSCP 1 (inner 0)",
18099 			ut_setup_security, ut_teardown,
18100 			test_ipsec_proto_ipv4_set_dscp_1_inner_0),
18101 		TEST_CASE_NAMED_ST(
18102 			"Tunnel header IPv6 copy DSCP (inner 0)",
18103 			ut_setup_security, ut_teardown,
18104 			test_ipsec_proto_ipv6_copy_dscp_inner_0),
18105 		TEST_CASE_NAMED_ST(
18106 			"Tunnel header IPv6 copy DSCP (inner 1)",
18107 			ut_setup_security, ut_teardown,
18108 			test_ipsec_proto_ipv6_copy_dscp_inner_1),
18109 		TEST_CASE_NAMED_ST(
18110 			"Tunnel header IPv6 set DSCP 0 (inner 1)",
18111 			ut_setup_security, ut_teardown,
18112 			test_ipsec_proto_ipv6_set_dscp_0_inner_1),
18113 		TEST_CASE_NAMED_ST(
18114 			"Tunnel header IPv6 set DSCP 1 (inner 0)",
18115 			ut_setup_security, ut_teardown,
18116 			test_ipsec_proto_ipv6_set_dscp_1_inner_0),
18117 		TEST_CASE_NAMED_WITH_DATA(
18118 			"Antireplay with window size 1024",
18119 			ut_setup_security, ut_teardown,
18120 			test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
18121 		TEST_CASE_NAMED_WITH_DATA(
18122 			"Antireplay with window size 2048",
18123 			ut_setup_security, ut_teardown,
18124 			test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
18125 		TEST_CASE_NAMED_WITH_DATA(
18126 			"Antireplay with window size 4096",
18127 			ut_setup_security, ut_teardown,
18128 			test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
18129 		TEST_CASE_NAMED_WITH_DATA(
18130 			"ESN and Antireplay with window size 1024",
18131 			ut_setup_security, ut_teardown,
18132 			test_ipsec_proto_pkt_esn_antireplay1024,
18133 			&pkt_aes_128_gcm),
18134 		TEST_CASE_NAMED_WITH_DATA(
18135 			"ESN and Antireplay with window size 2048",
18136 			ut_setup_security, ut_teardown,
18137 			test_ipsec_proto_pkt_esn_antireplay2048,
18138 			&pkt_aes_128_gcm),
18139 		TEST_CASE_NAMED_WITH_DATA(
18140 			"ESN and Antireplay with window size 4096",
18141 			ut_setup_security, ut_teardown,
18142 			test_ipsec_proto_pkt_esn_antireplay4096,
18143 			&pkt_aes_128_gcm),
18144 		TEST_CASE_NAMED_ST(
18145 			"Tunnel header IPv4 decrement inner TTL",
18146 			ut_setup_security, ut_teardown,
18147 			test_ipsec_proto_ipv4_ttl_decrement),
18148 		TEST_CASE_NAMED_ST(
18149 			"Tunnel header IPv6 decrement inner hop limit",
18150 			ut_setup_security, ut_teardown,
18151 			test_ipsec_proto_ipv6_hop_limit_decrement),
18152 		TEST_CASE_NAMED_ST(
18153 			"Multi-segmented mode",
18154 			ut_setup_security, ut_teardown,
18155 			test_ipsec_proto_sgl),
18156 		TEST_CASE_NAMED_ST(
18157 			"Multi-segmented external mbuf mode",
18158 			ut_setup_security, ut_teardown,
18159 			test_ipsec_proto_sgl_ext_mbuf),
18160 		TEST_CASE_NAMED_WITH_DATA(
18161 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
18162 			ut_setup_security_rx_inject, ut_teardown_rx_inject,
18163 			test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
18164 		TEST_CASES_END() /**< NULL terminate unit test array */
18165 	}
18166 };
18167 
18168 static struct unit_test_suite pdcp_proto_testsuite  = {
18169 	.suite_name = "PDCP Proto Unit Test Suite",
18170 	.setup = pdcp_proto_testsuite_setup,
18171 	.unit_test_cases = {
18172 		TEST_CASE_ST(ut_setup_security, ut_teardown,
18173 			test_PDCP_PROTO_all),
18174 		TEST_CASES_END() /**< NULL terminate unit test array */
18175 	}
18176 };
18177 
18178 static struct unit_test_suite tls12_record_proto_testsuite  = {
18179 	.suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
18180 	.setup = tls_record_proto_testsuite_setup,
18181 	.unit_test_cases = {
18182 		TEST_CASE_NAMED_WITH_DATA(
18183 			"Write record known vector AES-GCM-128 (vector 1)",
18184 			ut_setup_security, ut_teardown,
18185 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
18186 		TEST_CASE_NAMED_WITH_DATA(
18187 			"Write record known vector AES-GCM-128 (vector 2)",
18188 			ut_setup_security, ut_teardown,
18189 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
18190 		TEST_CASE_NAMED_WITH_DATA(
18191 			"Write record known vector AES-GCM-256",
18192 			ut_setup_security, ut_teardown,
18193 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
18194 		TEST_CASE_NAMED_WITH_DATA(
18195 			"Write record known vector AES-CBC-128-SHA1",
18196 			ut_setup_security, ut_teardown,
18197 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
18198 		TEST_CASE_NAMED_WITH_DATA(
18199 			"Write record known vector AES-128-CBC-SHA256",
18200 			ut_setup_security, ut_teardown,
18201 			test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
18202 		TEST_CASE_NAMED_WITH_DATA(
18203 			"Write record known vector AES-256-CBC-SHA1",
18204 			ut_setup_security, ut_teardown,
18205 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
18206 		TEST_CASE_NAMED_WITH_DATA(
18207 			"Write record known vector AES-256-CBC-SHA256",
18208 			ut_setup_security, ut_teardown,
18209 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
18210 		TEST_CASE_NAMED_WITH_DATA(
18211 			"Write record known vector AES-256-CBC-SHA384",
18212 			ut_setup_security, ut_teardown,
18213 			test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
18214 		TEST_CASE_NAMED_WITH_DATA(
18215 			"Write record known vector 3DES-CBC-SHA1-HMAC",
18216 			ut_setup_security, ut_teardown,
18217 			test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
18218 		TEST_CASE_NAMED_WITH_DATA(
18219 			"Write record known vector NULL-SHA1-HMAC",
18220 			ut_setup_security, ut_teardown,
18221 			test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
18222 		TEST_CASE_NAMED_WITH_DATA(
18223 			"Write record known vector CHACHA20-POLY1305",
18224 			ut_setup_security, ut_teardown,
18225 			test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
18226 
18227 		TEST_CASE_NAMED_WITH_DATA(
18228 			"Read record known vector AES-GCM-128 (vector 1)",
18229 			ut_setup_security, ut_teardown,
18230 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
18231 		TEST_CASE_NAMED_WITH_DATA(
18232 			"Read record known vector AES-GCM-128 (vector 2)",
18233 			ut_setup_security, ut_teardown,
18234 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
18235 		TEST_CASE_NAMED_WITH_DATA(
18236 			"Read record known vector AES-GCM-256",
18237 			ut_setup_security, ut_teardown,
18238 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
18239 		TEST_CASE_NAMED_WITH_DATA(
18240 			"Read record known vector AES-128-CBC-SHA1",
18241 			ut_setup_security, ut_teardown,
18242 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
18243 		TEST_CASE_NAMED_WITH_DATA(
18244 			"Read record known vector AES-128-CBC-SHA256",
18245 			ut_setup_security, ut_teardown,
18246 			test_tls_record_proto_known_vec_read,
18247 			&tls_test_data_aes_128_cbc_sha256_hmac),
18248 		TEST_CASE_NAMED_WITH_DATA(
18249 			"Read record known vector AES-256-CBC-SHA1",
18250 			ut_setup_security, ut_teardown,
18251 			test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
18252 		TEST_CASE_NAMED_WITH_DATA(
18253 			"Read record known vector AES-256-CBC-SHA256",
18254 			ut_setup_security, ut_teardown,
18255 			test_tls_record_proto_known_vec_read,
18256 			&tls_test_data_aes_256_cbc_sha256_hmac),
18257 		TEST_CASE_NAMED_WITH_DATA(
18258 			"Read record known vector AES-256-CBC-SHA384",
18259 			ut_setup_security, ut_teardown,
18260 			test_tls_record_proto_known_vec_read,
18261 			&tls_test_data_aes_256_cbc_sha384_hmac),
18262 		TEST_CASE_NAMED_WITH_DATA(
18263 			"Read record known vector 3DES-CBC-SHA1-HMAC",
18264 			ut_setup_security, ut_teardown,
18265 			test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
18266 		TEST_CASE_NAMED_WITH_DATA(
18267 			"Read record known vector NULL-SHA1-HMAC",
18268 			ut_setup_security, ut_teardown,
18269 			test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
18270 		TEST_CASE_NAMED_WITH_DATA(
18271 			"Read record known vector CHACHA20-POLY1305",
18272 			ut_setup_security, ut_teardown,
18273 			test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
18274 
18275 		TEST_CASE_NAMED_ST(
18276 			"Combined test alg list",
18277 			ut_setup_security, ut_teardown,
18278 			test_tls_1_2_record_proto_display_list),
18279 		TEST_CASE_NAMED_ST(
18280 			"Data walkthrough combined test alg list",
18281 			ut_setup_security, ut_teardown,
18282 			test_tls_1_2_record_proto_data_walkthrough),
18283 		TEST_CASE_NAMED_ST(
18284 			"Multi-segmented mode",
18285 			ut_setup_security, ut_teardown,
18286 			test_tls_1_2_record_proto_sgl),
18287 		TEST_CASE_NAMED_ST(
18288 			"Multi-segmented mode data walkthrough",
18289 			ut_setup_security, ut_teardown,
18290 			test_tls_1_2_record_proto_sgl_data_walkthrough),
18291 		TEST_CASE_NAMED_ST(
18292 			"Multi-segmented mode out of place",
18293 			ut_setup_security, ut_teardown,
18294 			test_tls_1_2_record_proto_sgl_oop),
18295 		TEST_CASE_NAMED_ST(
18296 			"TLS packet header corruption",
18297 			ut_setup_security, ut_teardown,
18298 			test_tls_record_proto_corrupt_pkt),
18299 		TEST_CASE_NAMED_ST(
18300 			"Custom content type",
18301 			ut_setup_security, ut_teardown,
18302 			test_tls_record_proto_custom_content_type),
18303 		TEST_CASE_NAMED_ST(
18304 			"Zero len TLS record with content type as app",
18305 			ut_setup_security, ut_teardown,
18306 			test_tls_record_proto_zero_len),
18307 		TEST_CASE_NAMED_ST(
18308 			"Zero len TLS record with content type as ctrl",
18309 			ut_setup_security, ut_teardown,
18310 			test_tls_record_proto_zero_len_non_app),
18311 		TEST_CASE_NAMED_ST(
18312 			"TLS record DM mode with optional padding < 2 blocks",
18313 			ut_setup_security, ut_teardown,
18314 			test_tls_record_proto_dm_opt_padding),
18315 		TEST_CASE_NAMED_ST(
18316 			"TLS record DM mode with optional padding > 2 blocks",
18317 			ut_setup_security, ut_teardown,
18318 			test_tls_record_proto_dm_opt_padding_1),
18319 		TEST_CASE_NAMED_ST(
18320 			"TLS record SG mode with optional padding < 2 blocks",
18321 			ut_setup_security, ut_teardown,
18322 			test_tls_record_proto_sg_opt_padding),
18323 		TEST_CASE_NAMED_ST(
18324 			"TLS record SG mode with optional padding > 2 blocks",
18325 			ut_setup_security, ut_teardown,
18326 			test_tls_record_proto_sg_opt_padding_1),
18327 		TEST_CASE_NAMED_ST(
18328 			"TLS record SG mode with optional padding > 2 blocks",
18329 			ut_setup_security, ut_teardown,
18330 			test_tls_record_proto_sg_opt_padding_2),
18331 		TEST_CASE_NAMED_ST(
18332 			"TLS record SG mode with optional padding > max range",
18333 			ut_setup_security, ut_teardown,
18334 			test_tls_record_proto_sg_opt_padding_max),
18335 		TEST_CASE_NAMED_ST(
18336 			"TLS record SG mode with padding corruption",
18337 			ut_setup_security, ut_teardown,
18338 			test_tls_record_proto_sg_opt_padding_corrupt),
18339 		TEST_CASES_END() /**< NULL terminate unit test array */
18340 	}
18341 };
18342 
18343 static struct unit_test_suite dtls12_record_proto_testsuite  = {
18344 	.suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
18345 	.setup = tls_record_proto_testsuite_setup,
18346 	.unit_test_cases = {
18347 		TEST_CASE_NAMED_WITH_DATA(
18348 			"Write record known vector AES-GCM-128",
18349 			ut_setup_security, ut_teardown,
18350 			test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
18351 		TEST_CASE_NAMED_WITH_DATA(
18352 			"Write record known vector AES-GCM-256",
18353 			ut_setup_security, ut_teardown,
18354 			test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
18355 		TEST_CASE_NAMED_WITH_DATA(
18356 			"Write record known vector AES-128-CBC-SHA1",
18357 			ut_setup_security, ut_teardown,
18358 			test_tls_record_proto_known_vec,
18359 			&dtls_test_data_aes_128_cbc_sha1_hmac),
18360 		TEST_CASE_NAMED_WITH_DATA(
18361 			"Write record known vector AES-128-CBC-SHA256",
18362 			ut_setup_security, ut_teardown,
18363 			test_tls_record_proto_known_vec,
18364 			&dtls_test_data_aes_128_cbc_sha256_hmac),
18365 		TEST_CASE_NAMED_WITH_DATA(
18366 			"Write record known vector AES-256-CBC-SHA1",
18367 			ut_setup_security, ut_teardown,
18368 			test_tls_record_proto_known_vec,
18369 			&dtls_test_data_aes_256_cbc_sha1_hmac),
18370 		TEST_CASE_NAMED_WITH_DATA(
18371 			"Write record known vector AES-256-CBC-SHA256",
18372 			ut_setup_security, ut_teardown,
18373 			test_tls_record_proto_known_vec,
18374 			&dtls_test_data_aes_256_cbc_sha256_hmac),
18375 		TEST_CASE_NAMED_WITH_DATA(
18376 			"Write record known vector AES-256-CBC-SHA384",
18377 			ut_setup_security, ut_teardown,
18378 			test_tls_record_proto_known_vec,
18379 			&dtls_test_data_aes_256_cbc_sha384_hmac),
18380 		TEST_CASE_NAMED_WITH_DATA(
18381 			"Write record known vector 3DES-CBC-SHA1-HMAC",
18382 			ut_setup_security, ut_teardown,
18383 			test_tls_record_proto_known_vec,
18384 			&dtls_test_data_3des_cbc_sha1_hmac),
18385 		TEST_CASE_NAMED_WITH_DATA(
18386 			"Write record known vector NULL-SHA1-HMAC",
18387 			ut_setup_security, ut_teardown,
18388 			test_tls_record_proto_known_vec,
18389 			&dtls_test_data_null_cipher_sha1_hmac),
18390 		TEST_CASE_NAMED_WITH_DATA(
18391 			"Write record known vector CHACHA20-POLY1305",
18392 			ut_setup_security, ut_teardown,
18393 			test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
18394 		TEST_CASE_NAMED_WITH_DATA(
18395 			"Read record known vector AES-GCM-128",
18396 			ut_setup_security, ut_teardown,
18397 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
18398 		TEST_CASE_NAMED_WITH_DATA(
18399 			"Read record known vector AES-GCM-256",
18400 			ut_setup_security, ut_teardown,
18401 			test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
18402 		TEST_CASE_NAMED_WITH_DATA(
18403 			"Read record known vector AES-128-CBC-SHA1",
18404 			ut_setup_security, ut_teardown,
18405 			test_tls_record_proto_known_vec_read,
18406 			&dtls_test_data_aes_128_cbc_sha1_hmac),
18407 		TEST_CASE_NAMED_WITH_DATA(
18408 			"Read record known vector AES-128-CBC-SHA256",
18409 			ut_setup_security, ut_teardown,
18410 			test_tls_record_proto_known_vec_read,
18411 			&dtls_test_data_aes_128_cbc_sha256_hmac),
18412 		TEST_CASE_NAMED_WITH_DATA(
18413 			"Read record known vector AES-256-CBC-SHA1",
18414 			ut_setup_security, ut_teardown,
18415 			test_tls_record_proto_known_vec_read,
18416 			&dtls_test_data_aes_256_cbc_sha1_hmac),
18417 		TEST_CASE_NAMED_WITH_DATA(
18418 			"Read record known vector AES-256-CBC-SHA256",
18419 			ut_setup_security, ut_teardown,
18420 			test_tls_record_proto_known_vec_read,
18421 			&dtls_test_data_aes_256_cbc_sha256_hmac),
18422 		TEST_CASE_NAMED_WITH_DATA(
18423 			"Read record known vector AES-256-CBC-SHA384",
18424 			ut_setup_security, ut_teardown,
18425 			test_tls_record_proto_known_vec_read,
18426 			&dtls_test_data_aes_256_cbc_sha384_hmac),
18427 		TEST_CASE_NAMED_WITH_DATA(
18428 			"Read record known vector 3DES-CBC-SHA1-HMAC",
18429 			ut_setup_security, ut_teardown,
18430 			test_tls_record_proto_known_vec_read,
18431 			&dtls_test_data_3des_cbc_sha1_hmac),
18432 		TEST_CASE_NAMED_WITH_DATA(
18433 			"Read record known vector NULL-SHA1-HMAC",
18434 			ut_setup_security, ut_teardown,
18435 			test_tls_record_proto_known_vec_read,
18436 			&dtls_test_data_null_cipher_sha1_hmac),
18437 		TEST_CASE_NAMED_WITH_DATA(
18438 			"Read record known vector CHACHA20-POLY1305",
18439 			ut_setup_security, ut_teardown,
18440 			test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
18441 
18442 		TEST_CASE_NAMED_ST(
18443 			"Combined test alg list",
18444 			ut_setup_security, ut_teardown,
18445 			test_dtls_1_2_record_proto_display_list),
18446 		TEST_CASE_NAMED_ST(
18447 			"Data walkthrough combined test alg list",
18448 			ut_setup_security, ut_teardown,
18449 			test_dtls_1_2_record_proto_data_walkthrough),
18450 		TEST_CASE_NAMED_ST(
18451 			"Multi-segmented mode",
18452 			ut_setup_security, ut_teardown,
18453 			test_dtls_1_2_record_proto_sgl),
18454 		TEST_CASE_NAMED_ST(
18455 			"Multi-segmented mode data walkthrough",
18456 			ut_setup_security, ut_teardown,
18457 			test_dtls_1_2_record_proto_sgl_data_walkthrough),
18458 		TEST_CASE_NAMED_ST(
18459 			"Multi-segmented mode out of place",
18460 			ut_setup_security, ut_teardown,
18461 			test_dtls_1_2_record_proto_sgl_oop),
18462 		TEST_CASE_NAMED_ST(
18463 			"Packet corruption",
18464 			ut_setup_security, ut_teardown,
18465 			test_dtls_1_2_record_proto_corrupt_pkt),
18466 		TEST_CASE_NAMED_ST(
18467 			"Custom content type",
18468 			ut_setup_security, ut_teardown,
18469 			test_dtls_1_2_record_proto_custom_content_type),
18470 		TEST_CASE_NAMED_ST(
18471 			"Zero len DTLS record with content type as app",
18472 			ut_setup_security, ut_teardown,
18473 			test_dtls_1_2_record_proto_zero_len),
18474 		TEST_CASE_NAMED_ST(
18475 			"Zero len DTLS record with content type as ctrl",
18476 			ut_setup_security, ut_teardown,
18477 			test_dtls_1_2_record_proto_zero_len_non_app),
18478 		TEST_CASE_NAMED_ST(
18479 			"Antireplay with window size 64",
18480 			ut_setup_security, ut_teardown,
18481 			test_dtls_1_2_record_proto_antireplay64),
18482 		TEST_CASE_NAMED_ST(
18483 			"Antireplay with window size 128",
18484 			ut_setup_security, ut_teardown,
18485 			test_dtls_1_2_record_proto_antireplay128),
18486 		TEST_CASE_NAMED_ST(
18487 			"Antireplay with window size 256",
18488 			ut_setup_security, ut_teardown,
18489 			test_dtls_1_2_record_proto_antireplay256),
18490 		TEST_CASE_NAMED_ST(
18491 			"Antireplay with window size 512",
18492 			ut_setup_security, ut_teardown,
18493 			test_dtls_1_2_record_proto_antireplay512),
18494 		TEST_CASE_NAMED_ST(
18495 			"Antireplay with window size 1024",
18496 			ut_setup_security, ut_teardown,
18497 			test_dtls_1_2_record_proto_antireplay1024),
18498 		TEST_CASE_NAMED_ST(
18499 			"Antireplay with window size 2048",
18500 			ut_setup_security, ut_teardown,
18501 			test_dtls_1_2_record_proto_antireplay2048),
18502 		TEST_CASE_NAMED_ST(
18503 			"Antireplay with window size 4096",
18504 			ut_setup_security, ut_teardown,
18505 			test_dtls_1_2_record_proto_antireplay4096),
18506 		TEST_CASE_NAMED_ST(
18507 			"DTLS record DM mode with optional padding < 2 blocks",
18508 			ut_setup_security, ut_teardown,
18509 			test_dtls_1_2_record_proto_dm_opt_padding),
18510 		TEST_CASE_NAMED_ST(
18511 			"DTLS record DM mode with optional padding > 2 blocks",
18512 			ut_setup_security, ut_teardown,
18513 			test_dtls_1_2_record_proto_dm_opt_padding_1),
18514 		TEST_CASE_NAMED_ST(
18515 			"DTLS record SG mode with optional padding < 2 blocks",
18516 			ut_setup_security, ut_teardown,
18517 			test_dtls_1_2_record_proto_sg_opt_padding),
18518 		TEST_CASE_NAMED_ST(
18519 			"DTLS record SG mode with optional padding > 2 blocks",
18520 			ut_setup_security, ut_teardown,
18521 			test_dtls_1_2_record_proto_sg_opt_padding_1),
18522 		TEST_CASE_NAMED_ST(
18523 			"DTLS record SG mode with optional padding > 2 blocks",
18524 			ut_setup_security, ut_teardown,
18525 			test_dtls_1_2_record_proto_sg_opt_padding_2),
18526 		TEST_CASE_NAMED_ST(
18527 			"DTLS record SG mode with optional padding > max range",
18528 			ut_setup_security, ut_teardown,
18529 			test_dtls_1_2_record_proto_sg_opt_padding_max),
18530 		TEST_CASE_NAMED_ST(
18531 			"DTLS record SG mode with padding corruption",
18532 			ut_setup_security, ut_teardown,
18533 			test_dtls_1_2_record_proto_sg_opt_padding_corrupt),
18534 		TEST_CASES_END() /**< NULL terminate unit test array */
18535 	}
18536 };
18537 
18538 static struct unit_test_suite tls13_record_proto_testsuite  = {
18539 	.suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
18540 	.setup = tls_record_proto_testsuite_setup,
18541 	.unit_test_cases = {
18542 		TEST_CASE_NAMED_WITH_DATA(
18543 			"Write record known vector AES-GCM-128",
18544 			ut_setup_security, ut_teardown,
18545 			test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
18546 		TEST_CASE_NAMED_WITH_DATA(
18547 			"Write record known vector AES-GCM-256",
18548 			ut_setup_security, ut_teardown,
18549 			test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
18550 		TEST_CASE_NAMED_WITH_DATA(
18551 			"Write record known vector CHACHA20-POLY1305",
18552 			ut_setup_security, ut_teardown,
18553 			test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
18554 
18555 		TEST_CASE_NAMED_WITH_DATA(
18556 			"Read record known vector AES-GCM-128",
18557 			ut_setup_security, ut_teardown,
18558 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
18559 		TEST_CASE_NAMED_WITH_DATA(
18560 			"Read record known vector AES-GCM-256",
18561 			ut_setup_security, ut_teardown,
18562 			test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
18563 		TEST_CASE_NAMED_WITH_DATA(
18564 			"Read record known vector CHACHA20-POLY1305",
18565 			ut_setup_security, ut_teardown,
18566 			test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
18567 		TEST_CASE_NAMED_ST(
18568 			"TLS-1.3 record header corruption",
18569 			ut_setup_security, ut_teardown,
18570 			test_tls_1_3_record_proto_corrupt_pkt),
18571 		TEST_CASE_NAMED_ST(
18572 			"TLS-1.3 record header with custom content type",
18573 			ut_setup_security, ut_teardown,
18574 			test_tls_1_3_record_proto_custom_content_type),
18575 		TEST_CASE_NAMED_ST(
18576 			"TLS-1.3 record with zero len and content type as app",
18577 			ut_setup_security, ut_teardown,
18578 			test_tls_1_3_record_proto_zero_len),
18579 		TEST_CASE_NAMED_ST(
18580 			"TLS-1.3 record with zero len and content type as ctrl",
18581 			ut_setup_security, ut_teardown,
18582 			test_tls_1_3_record_proto_zero_len_non_app),
18583 		TEST_CASE_NAMED_ST(
18584 			"TLS-1.3 record DM mode with optional padding",
18585 			ut_setup_security, ut_teardown,
18586 			test_tls_1_3_record_proto_dm_opt_padding),
18587 		TEST_CASE_NAMED_ST(
18588 			"TLS-1.3 record SG mode with optional padding - 1",
18589 			ut_setup_security, ut_teardown,
18590 			test_tls_1_3_record_proto_sg_opt_padding),
18591 		TEST_CASE_NAMED_ST(
18592 			"TLS-1.3 record SG mode with optional padding",
18593 			ut_setup_security, ut_teardown,
18594 			test_tls_1_3_record_proto_sg_opt_padding_1),
18595 		TEST_CASE_NAMED_ST(
18596 			"Combined test alg list",
18597 			ut_setup_security, ut_teardown,
18598 			test_tls_1_3_record_proto_display_list),
18599 		TEST_CASE_NAMED_ST(
18600 			"Data walkthrough combined test alg list",
18601 			ut_setup_security, ut_teardown,
18602 			test_tls_1_3_record_proto_data_walkthrough),
18603 		TEST_CASE_NAMED_ST(
18604 			"Multi-segmented mode",
18605 			ut_setup_security, ut_teardown,
18606 			test_tls_1_3_record_proto_sgl),
18607 		TEST_CASE_NAMED_ST(
18608 			"Multi-segmented mode data walkthrough",
18609 			ut_setup_security, ut_teardown,
18610 			test_tls_1_3_record_proto_sgl_data_walkthrough),
18611 		TEST_CASE_NAMED_ST(
18612 			"Multi-segmented mode out of place",
18613 			ut_setup_security, ut_teardown,
18614 			test_tls_1_3_record_proto_sgl_oop),
18615 		TEST_CASES_END() /**< NULL terminate unit test array */
18616 	}
18617 };
18618 
18619 #define ADD_UPLINK_TESTCASE(data)						\
18620 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
18621 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
18622 
18623 #define ADD_DOWNLINK_TESTCASE(data)						\
18624 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
18625 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
18626 
18627 static struct unit_test_suite docsis_proto_testsuite  = {
18628 	.suite_name = "DOCSIS Proto Unit Test Suite",
18629 	.setup = docsis_proto_testsuite_setup,
18630 	.unit_test_cases = {
18631 		/* Uplink */
18632 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
18633 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
18634 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
18635 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
18636 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
18637 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
18638 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
18639 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
18640 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
18641 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
18642 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
18643 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
18644 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
18645 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
18646 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
18647 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
18648 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
18649 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
18650 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
18651 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
18652 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
18653 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
18654 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
18655 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
18656 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
18657 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
18658 		/* Downlink */
18659 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18660 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18661 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18662 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18663 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18664 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18665 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18666 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18667 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18668 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18669 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18670 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18671 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18672 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18673 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18674 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18675 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18676 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18677 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18678 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18679 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18680 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18681 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18682 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18683 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18684 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18685 		TEST_CASES_END() /**< NULL terminate unit test array */
18686 	}
18687 };
18688 #endif
18689 
18690 static struct unit_test_suite cryptodev_gen_testsuite  = {
18691 	.suite_name = "Crypto General Unit Test Suite",
18692 	.setup = crypto_gen_testsuite_setup,
18693 	.unit_test_cases = {
18694 		TEST_CASE_ST(ut_setup, ut_teardown,
18695 				test_device_reconfigure),
18696 		TEST_CASE_ST(ut_setup, ut_teardown,
18697 				test_device_configure_invalid_dev_id),
18698 		TEST_CASE_ST(ut_setup, ut_teardown,
18699 				test_queue_pair_descriptor_setup),
18700 		TEST_CASE_ST(ut_setup, ut_teardown,
18701 				test_device_configure_invalid_queue_pair_ids),
18702 		TEST_CASE_ST(ut_setup, ut_teardown,
18703 				test_queue_pair_descriptor_count),
18704 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18705 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18706 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18707 		TEST_CASE_NAMED_WITH_DATA("Verify cryptodev error recover", ut_setup, ut_teardown,
18708 					  test_cryptodev_verify_error_recover, &aes_test_data_4),
18709 		TEST_CASES_END() /**< NULL terminate unit test array */
18710 	}
18711 };
18712 
18713 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18714 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
18715 	.setup = negative_hmac_sha1_testsuite_setup,
18716 	.unit_test_cases = {
18717 		/** Negative tests */
18718 		TEST_CASE_ST(ut_setup, ut_teardown,
18719 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
18720 		TEST_CASE_ST(ut_setup, ut_teardown,
18721 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18722 		TEST_CASE_ST(ut_setup, ut_teardown,
18723 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18724 		TEST_CASE_ST(ut_setup, ut_teardown,
18725 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18726 
18727 		TEST_CASES_END() /**< NULL terminate unit test array */
18728 	}
18729 };
18730 
18731 static struct unit_test_suite cryptodev_multi_session_testsuite = {
18732 	.suite_name = "Multi Session Unit Test Suite",
18733 	.setup = multi_session_testsuite_setup,
18734 	.unit_test_cases = {
18735 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18736 		TEST_CASE_ST(ut_setup, ut_teardown,
18737 				test_multi_session_random_usage),
18738 
18739 		TEST_CASES_END() /**< NULL terminate unit test array */
18740 	}
18741 };
18742 
18743 static struct unit_test_suite cryptodev_null_testsuite  = {
18744 	.suite_name = "NULL Test Suite",
18745 	.setup = null_testsuite_setup,
18746 	.unit_test_cases = {
18747 		TEST_CASE_ST(ut_setup, ut_teardown,
18748 			test_null_invalid_operation),
18749 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
18750 		TEST_CASES_END()
18751 	}
18752 };
18753 
18754 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
18755 	.suite_name = "AES CCM Authenticated Test Suite",
18756 	.setup = aes_ccm_auth_testsuite_setup,
18757 	.unit_test_cases = {
18758 		/** AES CCM Authenticated Encryption 128 bits key*/
18759 		TEST_CASE_ST(ut_setup, ut_teardown,
18760 			test_AES_CCM_authenticated_encryption_test_case_128_1),
18761 		TEST_CASE_ST(ut_setup, ut_teardown,
18762 			test_AES_CCM_authenticated_encryption_test_case_128_2),
18763 		TEST_CASE_ST(ut_setup, ut_teardown,
18764 			test_AES_CCM_authenticated_encryption_test_case_128_3),
18765 
18766 		/** AES CCM Authenticated Decryption 128 bits key*/
18767 		TEST_CASE_ST(ut_setup, ut_teardown,
18768 			test_AES_CCM_authenticated_decryption_test_case_128_1),
18769 		TEST_CASE_ST(ut_setup, ut_teardown,
18770 			test_AES_CCM_authenticated_decryption_test_case_128_2),
18771 		TEST_CASE_ST(ut_setup, ut_teardown,
18772 			test_AES_CCM_authenticated_decryption_test_case_128_3),
18773 
18774 		/** AES CCM Authenticated Encryption 192 bits key */
18775 		TEST_CASE_ST(ut_setup, ut_teardown,
18776 			test_AES_CCM_authenticated_encryption_test_case_192_1),
18777 		TEST_CASE_ST(ut_setup, ut_teardown,
18778 			test_AES_CCM_authenticated_encryption_test_case_192_2),
18779 		TEST_CASE_ST(ut_setup, ut_teardown,
18780 			test_AES_CCM_authenticated_encryption_test_case_192_3),
18781 
18782 		/** AES CCM Authenticated Decryption 192 bits key*/
18783 		TEST_CASE_ST(ut_setup, ut_teardown,
18784 			test_AES_CCM_authenticated_decryption_test_case_192_1),
18785 		TEST_CASE_ST(ut_setup, ut_teardown,
18786 			test_AES_CCM_authenticated_decryption_test_case_192_2),
18787 		TEST_CASE_ST(ut_setup, ut_teardown,
18788 			test_AES_CCM_authenticated_decryption_test_case_192_3),
18789 
18790 		/** AES CCM Authenticated Encryption 256 bits key */
18791 		TEST_CASE_ST(ut_setup, ut_teardown,
18792 			test_AES_CCM_authenticated_encryption_test_case_256_1),
18793 		TEST_CASE_ST(ut_setup, ut_teardown,
18794 			test_AES_CCM_authenticated_encryption_test_case_256_2),
18795 		TEST_CASE_ST(ut_setup, ut_teardown,
18796 			test_AES_CCM_authenticated_encryption_test_case_256_3),
18797 
18798 		/** AES CCM Authenticated Decryption 256 bits key*/
18799 		TEST_CASE_ST(ut_setup, ut_teardown,
18800 			test_AES_CCM_authenticated_decryption_test_case_256_1),
18801 		TEST_CASE_ST(ut_setup, ut_teardown,
18802 			test_AES_CCM_authenticated_decryption_test_case_256_2),
18803 		TEST_CASE_ST(ut_setup, ut_teardown,
18804 			test_AES_CCM_authenticated_decryption_test_case_256_3),
18805 		TEST_CASES_END()
18806 	}
18807 };
18808 
18809 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
18810 	.suite_name = "AES GCM Authenticated Test Suite",
18811 	.setup = aes_gcm_auth_testsuite_setup,
18812 	.unit_test_cases = {
18813 		/** AES GCM Authenticated Encryption */
18814 		TEST_CASE_ST(ut_setup, ut_teardown,
18815 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
18816 		TEST_CASE_ST(ut_setup, ut_teardown,
18817 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
18818 		TEST_CASE_ST(ut_setup, ut_teardown,
18819 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
18820 		TEST_CASE_ST(ut_setup, ut_teardown,
18821 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
18822 		TEST_CASE_ST(ut_setup, ut_teardown,
18823 			test_AES_GCM_authenticated_encryption_test_case_1),
18824 		TEST_CASE_ST(ut_setup, ut_teardown,
18825 			test_AES_GCM_authenticated_encryption_test_case_2),
18826 		TEST_CASE_ST(ut_setup, ut_teardown,
18827 			test_AES_GCM_authenticated_encryption_test_case_3),
18828 		TEST_CASE_ST(ut_setup, ut_teardown,
18829 			test_AES_GCM_authenticated_encryption_test_case_4),
18830 		TEST_CASE_ST(ut_setup, ut_teardown,
18831 			test_AES_GCM_authenticated_encryption_test_case_5),
18832 		TEST_CASE_ST(ut_setup, ut_teardown,
18833 			test_AES_GCM_authenticated_encryption_test_case_6),
18834 		TEST_CASE_ST(ut_setup, ut_teardown,
18835 			test_AES_GCM_authenticated_encryption_test_case_7),
18836 		TEST_CASE_ST(ut_setup, ut_teardown,
18837 			test_AES_GCM_authenticated_encryption_test_case_8),
18838 		TEST_CASE_ST(ut_setup, ut_teardown,
18839 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
18840 
18841 		/** AES GCM Authenticated Decryption */
18842 		TEST_CASE_ST(ut_setup, ut_teardown,
18843 			test_AES_GCM_authenticated_decryption_test_case_1),
18844 		TEST_CASE_ST(ut_setup, ut_teardown,
18845 			test_AES_GCM_authenticated_decryption_test_case_2),
18846 		TEST_CASE_ST(ut_setup, ut_teardown,
18847 			test_AES_GCM_authenticated_decryption_test_case_3),
18848 		TEST_CASE_ST(ut_setup, ut_teardown,
18849 			test_AES_GCM_authenticated_decryption_test_case_4),
18850 		TEST_CASE_ST(ut_setup, ut_teardown,
18851 			test_AES_GCM_authenticated_decryption_test_case_5),
18852 		TEST_CASE_ST(ut_setup, ut_teardown,
18853 			test_AES_GCM_authenticated_decryption_test_case_6),
18854 		TEST_CASE_ST(ut_setup, ut_teardown,
18855 			test_AES_GCM_authenticated_decryption_test_case_7),
18856 		TEST_CASE_ST(ut_setup, ut_teardown,
18857 			test_AES_GCM_authenticated_decryption_test_case_8),
18858 		TEST_CASE_ST(ut_setup, ut_teardown,
18859 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
18860 
18861 		/** AES GCM Authenticated Encryption 192 bits key */
18862 		TEST_CASE_ST(ut_setup, ut_teardown,
18863 			test_AES_GCM_auth_encryption_test_case_192_1),
18864 		TEST_CASE_ST(ut_setup, ut_teardown,
18865 			test_AES_GCM_auth_encryption_test_case_192_2),
18866 		TEST_CASE_ST(ut_setup, ut_teardown,
18867 			test_AES_GCM_auth_encryption_test_case_192_3),
18868 		TEST_CASE_ST(ut_setup, ut_teardown,
18869 			test_AES_GCM_auth_encryption_test_case_192_4),
18870 		TEST_CASE_ST(ut_setup, ut_teardown,
18871 			test_AES_GCM_auth_encryption_test_case_192_5),
18872 		TEST_CASE_ST(ut_setup, ut_teardown,
18873 			test_AES_GCM_auth_encryption_test_case_192_6),
18874 		TEST_CASE_ST(ut_setup, ut_teardown,
18875 			test_AES_GCM_auth_encryption_test_case_192_7),
18876 
18877 		/** AES GCM Authenticated Decryption 192 bits key */
18878 		TEST_CASE_ST(ut_setup, ut_teardown,
18879 			test_AES_GCM_auth_decryption_test_case_192_1),
18880 		TEST_CASE_ST(ut_setup, ut_teardown,
18881 			test_AES_GCM_auth_decryption_test_case_192_2),
18882 		TEST_CASE_ST(ut_setup, ut_teardown,
18883 			test_AES_GCM_auth_decryption_test_case_192_3),
18884 		TEST_CASE_ST(ut_setup, ut_teardown,
18885 			test_AES_GCM_auth_decryption_test_case_192_4),
18886 		TEST_CASE_ST(ut_setup, ut_teardown,
18887 			test_AES_GCM_auth_decryption_test_case_192_5),
18888 		TEST_CASE_ST(ut_setup, ut_teardown,
18889 			test_AES_GCM_auth_decryption_test_case_192_6),
18890 		TEST_CASE_ST(ut_setup, ut_teardown,
18891 			test_AES_GCM_auth_decryption_test_case_192_7),
18892 
18893 		/** AES GCM Authenticated Encryption 256 bits key */
18894 		TEST_CASE_ST(ut_setup, ut_teardown,
18895 			test_AES_GCM_auth_encryption_test_case_256_1),
18896 		TEST_CASE_ST(ut_setup, ut_teardown,
18897 			test_AES_GCM_auth_encryption_test_case_256_2),
18898 		TEST_CASE_ST(ut_setup, ut_teardown,
18899 			test_AES_GCM_auth_encryption_test_case_256_3),
18900 		TEST_CASE_ST(ut_setup, ut_teardown,
18901 			test_AES_GCM_auth_encryption_test_case_256_4),
18902 		TEST_CASE_ST(ut_setup, ut_teardown,
18903 			test_AES_GCM_auth_encryption_test_case_256_5),
18904 		TEST_CASE_ST(ut_setup, ut_teardown,
18905 			test_AES_GCM_auth_encryption_test_case_256_6),
18906 		TEST_CASE_ST(ut_setup, ut_teardown,
18907 			test_AES_GCM_auth_encryption_test_case_256_7),
18908 		TEST_CASE_ST(ut_setup, ut_teardown,
18909 			test_AES_GCM_auth_encryption_test_case_256_8),
18910 
18911 		/** AES GCM Authenticated Decryption 256 bits key */
18912 		TEST_CASE_ST(ut_setup, ut_teardown,
18913 			test_AES_GCM_auth_decryption_test_case_256_1),
18914 		TEST_CASE_ST(ut_setup, ut_teardown,
18915 			test_AES_GCM_auth_decryption_test_case_256_2),
18916 		TEST_CASE_ST(ut_setup, ut_teardown,
18917 			test_AES_GCM_auth_decryption_test_case_256_3),
18918 		TEST_CASE_ST(ut_setup, ut_teardown,
18919 			test_AES_GCM_auth_decryption_test_case_256_4),
18920 		TEST_CASE_ST(ut_setup, ut_teardown,
18921 			test_AES_GCM_auth_decryption_test_case_256_5),
18922 		TEST_CASE_ST(ut_setup, ut_teardown,
18923 			test_AES_GCM_auth_decryption_test_case_256_6),
18924 		TEST_CASE_ST(ut_setup, ut_teardown,
18925 			test_AES_GCM_auth_decryption_test_case_256_7),
18926 		TEST_CASE_ST(ut_setup, ut_teardown,
18927 			test_AES_GCM_auth_decryption_test_case_256_8),
18928 
18929 		/** AES GCM Authenticated Encryption big aad size */
18930 		TEST_CASE_ST(ut_setup, ut_teardown,
18931 			test_AES_GCM_auth_encryption_test_case_aad_1),
18932 		TEST_CASE_ST(ut_setup, ut_teardown,
18933 			test_AES_GCM_auth_encryption_test_case_aad_2),
18934 
18935 		/** AES GCM Authenticated Decryption big aad size */
18936 		TEST_CASE_ST(ut_setup, ut_teardown,
18937 			test_AES_GCM_auth_decryption_test_case_aad_1),
18938 		TEST_CASE_ST(ut_setup, ut_teardown,
18939 			test_AES_GCM_auth_decryption_test_case_aad_2),
18940 
18941 		/** Out of place tests */
18942 		TEST_CASE_ST(ut_setup, ut_teardown,
18943 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
18944 		TEST_CASE_ST(ut_setup, ut_teardown,
18945 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
18946 
18947 		/** Session-less tests */
18948 		TEST_CASE_ST(ut_setup, ut_teardown,
18949 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
18950 		TEST_CASE_ST(ut_setup, ut_teardown,
18951 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
18952 
18953 		/** AES GCM external mbuf tests */
18954 		TEST_CASE_ST(ut_setup, ut_teardown,
18955 			test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
18956 		TEST_CASE_ST(ut_setup, ut_teardown,
18957 			test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
18958 
18959 		TEST_CASES_END()
18960 	}
18961 };
18962 
18963 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
18964 	.suite_name = "AES GMAC Authentication Test Suite",
18965 	.setup = aes_gmac_auth_testsuite_setup,
18966 	.unit_test_cases = {
18967 		TEST_CASE_ST(ut_setup, ut_teardown,
18968 			test_AES_GMAC_authentication_test_case_1),
18969 		TEST_CASE_ST(ut_setup, ut_teardown,
18970 			test_AES_GMAC_authentication_verify_test_case_1),
18971 		TEST_CASE_ST(ut_setup, ut_teardown,
18972 			test_AES_GMAC_authentication_test_case_2),
18973 		TEST_CASE_ST(ut_setup, ut_teardown,
18974 			test_AES_GMAC_authentication_verify_test_case_2),
18975 		TEST_CASE_ST(ut_setup, ut_teardown,
18976 			test_AES_GMAC_authentication_test_case_3),
18977 		TEST_CASE_ST(ut_setup, ut_teardown,
18978 			test_AES_GMAC_authentication_verify_test_case_3),
18979 		TEST_CASE_ST(ut_setup, ut_teardown,
18980 			test_AES_GMAC_authentication_test_case_4),
18981 		TEST_CASE_ST(ut_setup, ut_teardown,
18982 			test_AES_GMAC_authentication_verify_test_case_4),
18983 		TEST_CASE_ST(ut_setup, ut_teardown,
18984 			test_AES_GMAC_authentication_SGL_40B),
18985 		TEST_CASE_ST(ut_setup, ut_teardown,
18986 			test_AES_GMAC_authentication_SGL_80B),
18987 		TEST_CASE_ST(ut_setup, ut_teardown,
18988 			test_AES_GMAC_authentication_SGL_2048B),
18989 		TEST_CASE_ST(ut_setup, ut_teardown,
18990 			test_AES_GMAC_authentication_SGL_2047B),
18991 
18992 		TEST_CASES_END()
18993 	}
18994 };
18995 
18996 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
18997 	.suite_name = "Chacha20-Poly1305 Test Suite",
18998 	.setup = chacha20_poly1305_testsuite_setup,
18999 	.unit_test_cases = {
19000 		TEST_CASE_ST(ut_setup, ut_teardown,
19001 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
19002 		TEST_CASE_ST(ut_setup, ut_teardown,
19003 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
19004 		TEST_CASE_ST(ut_setup, ut_teardown,
19005 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
19006 		TEST_CASES_END()
19007 	}
19008 };
19009 
19010 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
19011 	.suite_name = "SNOW 3G Test Suite",
19012 	.setup = snow3g_testsuite_setup,
19013 	.unit_test_cases = {
19014 		/** SNOW 3G encrypt only (UEA2) */
19015 		TEST_CASE_ST(ut_setup, ut_teardown,
19016 			test_snow3g_encryption_test_case_1),
19017 		TEST_CASE_ST(ut_setup, ut_teardown,
19018 			test_snow3g_encryption_test_case_2),
19019 		TEST_CASE_ST(ut_setup, ut_teardown,
19020 			test_snow3g_encryption_test_case_3),
19021 		TEST_CASE_ST(ut_setup, ut_teardown,
19022 			test_snow3g_encryption_test_case_4),
19023 		TEST_CASE_ST(ut_setup, ut_teardown,
19024 			test_snow3g_encryption_test_case_5),
19025 
19026 		TEST_CASE_ST(ut_setup, ut_teardown,
19027 			test_snow3g_encryption_test_case_1_oop),
19028 		TEST_CASE_ST(ut_setup, ut_teardown,
19029 			test_snow3g_encryption_test_case_1_oop_sgl),
19030 		TEST_CASE_ST(ut_setup, ut_teardown,
19031 			test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
19032 		TEST_CASE_ST(ut_setup, ut_teardown,
19033 			test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
19034 		TEST_CASE_ST(ut_setup, ut_teardown,
19035 			test_snow3g_encryption_test_case_1_offset_oop),
19036 		TEST_CASE_ST(ut_setup, ut_teardown,
19037 			test_snow3g_decryption_test_case_1_oop),
19038 
19039 		/** SNOW 3G generate auth, then encrypt (UEA2) */
19040 		TEST_CASE_ST(ut_setup, ut_teardown,
19041 			test_snow3g_auth_cipher_test_case_1),
19042 		TEST_CASE_ST(ut_setup, ut_teardown,
19043 			test_snow3g_auth_cipher_test_case_2),
19044 		TEST_CASE_ST(ut_setup, ut_teardown,
19045 			test_snow3g_auth_cipher_test_case_2_oop),
19046 		TEST_CASE_ST(ut_setup, ut_teardown,
19047 			test_snow3g_auth_cipher_part_digest_enc),
19048 		TEST_CASE_ST(ut_setup, ut_teardown,
19049 			test_snow3g_auth_cipher_part_digest_enc_oop),
19050 		TEST_CASE_ST(ut_setup, ut_teardown,
19051 			test_snow3g_auth_cipher_test_case_3_sgl),
19052 		TEST_CASE_ST(ut_setup, ut_teardown,
19053 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
19054 		TEST_CASE_ST(ut_setup, ut_teardown,
19055 			test_snow3g_auth_cipher_part_digest_enc_sgl),
19056 		TEST_CASE_ST(ut_setup, ut_teardown,
19057 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
19058 		TEST_CASE_ST(ut_setup, ut_teardown,
19059 			test_snow3g_auth_cipher_total_digest_enc_1),
19060 		TEST_CASE_ST(ut_setup, ut_teardown,
19061 			test_snow3g_auth_cipher_total_digest_enc_1_oop),
19062 		TEST_CASE_ST(ut_setup, ut_teardown,
19063 			test_snow3g_auth_cipher_total_digest_enc_1_sgl),
19064 		TEST_CASE_ST(ut_setup, ut_teardown,
19065 			test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
19066 
19067 		/** SNOW 3G decrypt (UEA2), then verify auth */
19068 		TEST_CASE_ST(ut_setup, ut_teardown,
19069 			test_snow3g_auth_cipher_verify_test_case_1),
19070 		TEST_CASE_ST(ut_setup, ut_teardown,
19071 			test_snow3g_auth_cipher_verify_test_case_2),
19072 		TEST_CASE_ST(ut_setup, ut_teardown,
19073 			test_snow3g_auth_cipher_verify_test_case_2_oop),
19074 		TEST_CASE_ST(ut_setup, ut_teardown,
19075 			test_snow3g_auth_cipher_verify_part_digest_enc),
19076 		TEST_CASE_ST(ut_setup, ut_teardown,
19077 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
19078 		TEST_CASE_ST(ut_setup, ut_teardown,
19079 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
19080 		TEST_CASE_ST(ut_setup, ut_teardown,
19081 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
19082 		TEST_CASE_ST(ut_setup, ut_teardown,
19083 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
19084 		TEST_CASE_ST(ut_setup, ut_teardown,
19085 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
19086 		TEST_CASE_ST(ut_setup, ut_teardown,
19087 			test_snow3g_auth_cipher_verify_total_digest_enc_1),
19088 		TEST_CASE_ST(ut_setup, ut_teardown,
19089 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
19090 		TEST_CASE_ST(ut_setup, ut_teardown,
19091 			test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
19092 		TEST_CASE_ST(ut_setup, ut_teardown,
19093 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
19094 
19095 		/** SNOW 3G decrypt only (UEA2) */
19096 		TEST_CASE_ST(ut_setup, ut_teardown,
19097 			test_snow3g_decryption_test_case_1),
19098 		TEST_CASE_ST(ut_setup, ut_teardown,
19099 			test_snow3g_decryption_test_case_2),
19100 		TEST_CASE_ST(ut_setup, ut_teardown,
19101 			test_snow3g_decryption_test_case_3),
19102 		TEST_CASE_ST(ut_setup, ut_teardown,
19103 			test_snow3g_decryption_test_case_4),
19104 		TEST_CASE_ST(ut_setup, ut_teardown,
19105 			test_snow3g_decryption_test_case_5),
19106 		TEST_CASE_ST(ut_setup, ut_teardown,
19107 			test_snow3g_decryption_with_digest_test_case_1),
19108 		TEST_CASE_ST(ut_setup, ut_teardown,
19109 			test_snow3g_hash_generate_test_case_1),
19110 		TEST_CASE_ST(ut_setup, ut_teardown,
19111 			test_snow3g_hash_generate_test_case_2),
19112 		TEST_CASE_ST(ut_setup, ut_teardown,
19113 			test_snow3g_hash_generate_test_case_3),
19114 
19115 		/* Tests with buffers which length is not byte-aligned */
19116 		TEST_CASE_ST(ut_setup, ut_teardown,
19117 			test_snow3g_hash_generate_test_case_4),
19118 		TEST_CASE_ST(ut_setup, ut_teardown,
19119 			test_snow3g_hash_generate_test_case_5),
19120 		TEST_CASE_ST(ut_setup, ut_teardown,
19121 			test_snow3g_hash_generate_test_case_6),
19122 		TEST_CASE_ST(ut_setup, ut_teardown,
19123 			test_snow3g_hash_verify_test_case_1),
19124 		TEST_CASE_ST(ut_setup, ut_teardown,
19125 			test_snow3g_hash_verify_test_case_2),
19126 		TEST_CASE_ST(ut_setup, ut_teardown,
19127 			test_snow3g_hash_verify_test_case_3),
19128 
19129 		/* Tests with buffers which length is not byte-aligned */
19130 		TEST_CASE_ST(ut_setup, ut_teardown,
19131 			test_snow3g_hash_verify_test_case_4),
19132 		TEST_CASE_ST(ut_setup, ut_teardown,
19133 			test_snow3g_hash_verify_test_case_5),
19134 		TEST_CASE_ST(ut_setup, ut_teardown,
19135 			test_snow3g_hash_verify_test_case_6),
19136 		TEST_CASE_ST(ut_setup, ut_teardown,
19137 			test_snow3g_cipher_auth_test_case_1),
19138 		TEST_CASE_ST(ut_setup, ut_teardown,
19139 			test_snow3g_auth_cipher_with_digest_test_case_1),
19140 		TEST_CASES_END()
19141 	}
19142 };
19143 
19144 static struct unit_test_suite cryptodev_zuc_testsuite  = {
19145 	.suite_name = "ZUC Test Suite",
19146 	.setup = zuc_testsuite_setup,
19147 	.unit_test_cases = {
19148 		/** ZUC encrypt only (EEA3) */
19149 		TEST_CASE_ST(ut_setup, ut_teardown,
19150 			test_zuc_encryption_test_case_1),
19151 		TEST_CASE_ST(ut_setup, ut_teardown,
19152 			test_zuc_encryption_test_case_2),
19153 		TEST_CASE_ST(ut_setup, ut_teardown,
19154 			test_zuc_encryption_test_case_3),
19155 		TEST_CASE_ST(ut_setup, ut_teardown,
19156 			test_zuc_encryption_test_case_4),
19157 		TEST_CASE_ST(ut_setup, ut_teardown,
19158 			test_zuc_encryption_test_case_5),
19159 		TEST_CASE_ST(ut_setup, ut_teardown,
19160 			test_zuc_encryption_test_case_6_sgl),
19161 
19162 		/** ZUC decrypt only (EEA3) */
19163 		TEST_CASE_ST(ut_setup, ut_teardown,
19164 			test_zuc_decryption_test_case_1),
19165 		TEST_CASE_ST(ut_setup, ut_teardown,
19166 			test_zuc_decryption_test_case_2),
19167 		TEST_CASE_ST(ut_setup, ut_teardown,
19168 			test_zuc_decryption_test_case_3),
19169 		TEST_CASE_ST(ut_setup, ut_teardown,
19170 			test_zuc_decryption_test_case_4),
19171 		TEST_CASE_ST(ut_setup, ut_teardown,
19172 			test_zuc_decryption_test_case_5),
19173 		TEST_CASE_ST(ut_setup, ut_teardown,
19174 			test_zuc_decryption_test_case_6_sgl),
19175 
19176 		/** ZUC authenticate (EIA3) */
19177 		TEST_CASE_ST(ut_setup, ut_teardown,
19178 			test_zuc_hash_generate_test_case_1),
19179 		TEST_CASE_ST(ut_setup, ut_teardown,
19180 			test_zuc_hash_generate_test_case_2),
19181 		TEST_CASE_ST(ut_setup, ut_teardown,
19182 			test_zuc_hash_generate_test_case_3),
19183 		TEST_CASE_ST(ut_setup, ut_teardown,
19184 			test_zuc_hash_generate_test_case_4),
19185 		TEST_CASE_ST(ut_setup, ut_teardown,
19186 			test_zuc_hash_generate_test_case_5),
19187 		TEST_CASE_ST(ut_setup, ut_teardown,
19188 			test_zuc_hash_generate_test_case_6),
19189 		TEST_CASE_ST(ut_setup, ut_teardown,
19190 			test_zuc_hash_generate_test_case_7),
19191 		TEST_CASE_ST(ut_setup, ut_teardown,
19192 			test_zuc_hash_generate_test_case_8),
19193 
19194 		/** ZUC verify (EIA3) */
19195 		TEST_CASE_ST(ut_setup, ut_teardown,
19196 			test_zuc_hash_verify_test_case_1),
19197 		TEST_CASE_ST(ut_setup, ut_teardown,
19198 			test_zuc_hash_verify_test_case_2),
19199 		TEST_CASE_ST(ut_setup, ut_teardown,
19200 			test_zuc_hash_verify_test_case_3),
19201 		TEST_CASE_ST(ut_setup, ut_teardown,
19202 			test_zuc_hash_verify_test_case_4),
19203 		TEST_CASE_ST(ut_setup, ut_teardown,
19204 			test_zuc_hash_verify_test_case_5),
19205 		TEST_CASE_ST(ut_setup, ut_teardown,
19206 			test_zuc_hash_verify_test_case_6),
19207 		TEST_CASE_ST(ut_setup, ut_teardown,
19208 			test_zuc_hash_verify_test_case_7),
19209 		TEST_CASE_ST(ut_setup, ut_teardown,
19210 			test_zuc_hash_verify_test_case_8),
19211 
19212 		/** ZUC alg-chain (EEA3/EIA3) */
19213 		TEST_CASE_ST(ut_setup, ut_teardown,
19214 			test_zuc_cipher_auth_test_case_1),
19215 		TEST_CASE_ST(ut_setup, ut_teardown,
19216 			test_zuc_cipher_auth_test_case_2),
19217 
19218 		/** ZUC generate auth, then encrypt (EEA3) */
19219 		TEST_CASE_ST(ut_setup, ut_teardown,
19220 			test_zuc_auth_cipher_test_case_1),
19221 		TEST_CASE_ST(ut_setup, ut_teardown,
19222 			test_zuc_auth_cipher_test_case_1_oop),
19223 		TEST_CASE_ST(ut_setup, ut_teardown,
19224 			test_zuc_auth_cipher_test_case_1_sgl),
19225 		TEST_CASE_ST(ut_setup, ut_teardown,
19226 			test_zuc_auth_cipher_test_case_1_oop_sgl),
19227 		TEST_CASE_ST(ut_setup, ut_teardown,
19228 			test_zuc_auth_cipher_test_case_2),
19229 		TEST_CASE_ST(ut_setup, ut_teardown,
19230 			test_zuc_auth_cipher_test_case_2_oop),
19231 
19232 		/** ZUC decrypt (EEA3), then verify auth */
19233 		TEST_CASE_ST(ut_setup, ut_teardown,
19234 			test_zuc_auth_cipher_verify_test_case_1),
19235 		TEST_CASE_ST(ut_setup, ut_teardown,
19236 			test_zuc_auth_cipher_verify_test_case_1_oop),
19237 		TEST_CASE_ST(ut_setup, ut_teardown,
19238 			test_zuc_auth_cipher_verify_test_case_1_sgl),
19239 		TEST_CASE_ST(ut_setup, ut_teardown,
19240 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
19241 		TEST_CASE_ST(ut_setup, ut_teardown,
19242 			test_zuc_auth_cipher_verify_test_case_2),
19243 		TEST_CASE_ST(ut_setup, ut_teardown,
19244 			test_zuc_auth_cipher_verify_test_case_2_oop),
19245 
19246 		/** ZUC-256 encrypt only **/
19247 		TEST_CASE_ST(ut_setup, ut_teardown,
19248 			test_zuc256_encryption_test_case_1),
19249 		TEST_CASE_ST(ut_setup, ut_teardown,
19250 			test_zuc256_encryption_test_case_2),
19251 
19252 		/** ZUC-256 decrypt only **/
19253 		TEST_CASE_ST(ut_setup, ut_teardown,
19254 			test_zuc256_decryption_test_case_1),
19255 		TEST_CASE_ST(ut_setup, ut_teardown,
19256 			test_zuc256_decryption_test_case_2),
19257 
19258 		/** ZUC-256 authentication only **/
19259 		TEST_CASE_ST(ut_setup, ut_teardown,
19260 			test_zuc256_hash_generate_4b_tag_test_case_1),
19261 		TEST_CASE_ST(ut_setup, ut_teardown,
19262 			test_zuc256_hash_generate_4b_tag_test_case_2),
19263 		TEST_CASE_ST(ut_setup, ut_teardown,
19264 			test_zuc256_hash_generate_4b_tag_test_case_3),
19265 		TEST_CASE_ST(ut_setup, ut_teardown,
19266 			test_zuc256_hash_generate_8b_tag_test_case_1),
19267 		TEST_CASE_ST(ut_setup, ut_teardown,
19268 			test_zuc256_hash_generate_16b_tag_test_case_1),
19269 
19270 		/** ZUC-256 authentication verify only **/
19271 		TEST_CASE_ST(ut_setup, ut_teardown,
19272 			test_zuc256_hash_verify_4b_tag_test_case_1),
19273 		TEST_CASE_ST(ut_setup, ut_teardown,
19274 			test_zuc256_hash_verify_4b_tag_test_case_2),
19275 		TEST_CASE_ST(ut_setup, ut_teardown,
19276 			test_zuc256_hash_verify_4b_tag_test_case_3),
19277 		TEST_CASE_ST(ut_setup, ut_teardown,
19278 			test_zuc256_hash_verify_8b_tag_test_case_1),
19279 		TEST_CASE_ST(ut_setup, ut_teardown,
19280 			test_zuc256_hash_verify_16b_tag_test_case_1),
19281 
19282 		/** ZUC-256 encrypt and authenticate **/
19283 		TEST_CASE_ST(ut_setup, ut_teardown,
19284 			test_zuc256_cipher_auth_4b_tag_test_case_1),
19285 		TEST_CASE_ST(ut_setup, ut_teardown,
19286 			test_zuc256_cipher_auth_4b_tag_test_case_2),
19287 		TEST_CASE_ST(ut_setup, ut_teardown,
19288 			test_zuc256_cipher_auth_8b_tag_test_case_1),
19289 		TEST_CASE_ST(ut_setup, ut_teardown,
19290 			test_zuc256_cipher_auth_16b_tag_test_case_1),
19291 
19292 		/** ZUC-256 generate auth, then encrypt */
19293 		TEST_CASE_ST(ut_setup, ut_teardown,
19294 			test_zuc256_auth_cipher_4b_tag_test_case_1),
19295 		TEST_CASE_ST(ut_setup, ut_teardown,
19296 			test_zuc256_auth_cipher_4b_tag_test_case_2),
19297 		TEST_CASE_ST(ut_setup, ut_teardown,
19298 			test_zuc256_auth_cipher_8b_tag_test_case_1),
19299 		TEST_CASE_ST(ut_setup, ut_teardown,
19300 			test_zuc256_auth_cipher_16b_tag_test_case_1),
19301 
19302 		/** ZUC-256 decrypt, then verify auth */
19303 		TEST_CASE_ST(ut_setup, ut_teardown,
19304 			test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
19305 		TEST_CASE_ST(ut_setup, ut_teardown,
19306 			test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
19307 		TEST_CASE_ST(ut_setup, ut_teardown,
19308 			test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
19309 		TEST_CASE_ST(ut_setup, ut_teardown,
19310 			test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
19311 
19312 		TEST_CASES_END()
19313 	}
19314 };
19315 
19316 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
19317 	.suite_name = "HMAC_MD5 Authentication Test Suite",
19318 	.setup = hmac_md5_auth_testsuite_setup,
19319 	.unit_test_cases = {
19320 		TEST_CASE_ST(ut_setup, ut_teardown,
19321 			test_MD5_HMAC_generate_case_1),
19322 		TEST_CASE_ST(ut_setup, ut_teardown,
19323 			test_MD5_HMAC_verify_case_1),
19324 		TEST_CASE_ST(ut_setup, ut_teardown,
19325 			test_MD5_HMAC_generate_case_2),
19326 		TEST_CASE_ST(ut_setup, ut_teardown,
19327 			test_MD5_HMAC_verify_case_2),
19328 		TEST_CASES_END()
19329 	}
19330 };
19331 
19332 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
19333 	.suite_name = "Kasumi Test Suite",
19334 	.setup = kasumi_testsuite_setup,
19335 	.unit_test_cases = {
19336 		/** KASUMI hash only (UIA1) */
19337 		TEST_CASE_ST(ut_setup, ut_teardown,
19338 			test_kasumi_hash_generate_test_case_1),
19339 		TEST_CASE_ST(ut_setup, ut_teardown,
19340 			test_kasumi_hash_generate_test_case_2),
19341 		TEST_CASE_ST(ut_setup, ut_teardown,
19342 			test_kasumi_hash_generate_test_case_3),
19343 		TEST_CASE_ST(ut_setup, ut_teardown,
19344 			test_kasumi_hash_generate_test_case_4),
19345 		TEST_CASE_ST(ut_setup, ut_teardown,
19346 			test_kasumi_hash_generate_test_case_5),
19347 		TEST_CASE_ST(ut_setup, ut_teardown,
19348 			test_kasumi_hash_generate_test_case_6),
19349 
19350 		TEST_CASE_ST(ut_setup, ut_teardown,
19351 			test_kasumi_hash_verify_test_case_1),
19352 		TEST_CASE_ST(ut_setup, ut_teardown,
19353 			test_kasumi_hash_verify_test_case_2),
19354 		TEST_CASE_ST(ut_setup, ut_teardown,
19355 			test_kasumi_hash_verify_test_case_3),
19356 		TEST_CASE_ST(ut_setup, ut_teardown,
19357 			test_kasumi_hash_verify_test_case_4),
19358 		TEST_CASE_ST(ut_setup, ut_teardown,
19359 			test_kasumi_hash_verify_test_case_5),
19360 
19361 		/** KASUMI encrypt only (UEA1) */
19362 		TEST_CASE_ST(ut_setup, ut_teardown,
19363 			test_kasumi_encryption_test_case_1),
19364 		TEST_CASE_ST(ut_setup, ut_teardown,
19365 			test_kasumi_encryption_test_case_1_sgl),
19366 		TEST_CASE_ST(ut_setup, ut_teardown,
19367 			test_kasumi_encryption_test_case_1_oop),
19368 		TEST_CASE_ST(ut_setup, ut_teardown,
19369 			test_kasumi_encryption_test_case_1_oop_sgl),
19370 		TEST_CASE_ST(ut_setup, ut_teardown,
19371 			test_kasumi_encryption_test_case_2),
19372 		TEST_CASE_ST(ut_setup, ut_teardown,
19373 			test_kasumi_encryption_test_case_3),
19374 		TEST_CASE_ST(ut_setup, ut_teardown,
19375 			test_kasumi_encryption_test_case_4),
19376 		TEST_CASE_ST(ut_setup, ut_teardown,
19377 			test_kasumi_encryption_test_case_5),
19378 
19379 		/** KASUMI decrypt only (UEA1) */
19380 		TEST_CASE_ST(ut_setup, ut_teardown,
19381 			test_kasumi_decryption_test_case_1),
19382 		TEST_CASE_ST(ut_setup, ut_teardown,
19383 			test_kasumi_decryption_test_case_2),
19384 		TEST_CASE_ST(ut_setup, ut_teardown,
19385 			test_kasumi_decryption_test_case_3),
19386 		TEST_CASE_ST(ut_setup, ut_teardown,
19387 			test_kasumi_decryption_test_case_4),
19388 		TEST_CASE_ST(ut_setup, ut_teardown,
19389 			test_kasumi_decryption_test_case_5),
19390 		TEST_CASE_ST(ut_setup, ut_teardown,
19391 			test_kasumi_decryption_test_case_1_oop),
19392 		TEST_CASE_ST(ut_setup, ut_teardown,
19393 			test_kasumi_cipher_auth_test_case_1),
19394 
19395 		/** KASUMI generate auth, then encrypt (F8) */
19396 		TEST_CASE_ST(ut_setup, ut_teardown,
19397 			test_kasumi_auth_cipher_test_case_1),
19398 		TEST_CASE_ST(ut_setup, ut_teardown,
19399 			test_kasumi_auth_cipher_test_case_2),
19400 		TEST_CASE_ST(ut_setup, ut_teardown,
19401 			test_kasumi_auth_cipher_test_case_2_oop),
19402 		TEST_CASE_ST(ut_setup, ut_teardown,
19403 			test_kasumi_auth_cipher_test_case_2_sgl),
19404 		TEST_CASE_ST(ut_setup, ut_teardown,
19405 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
19406 
19407 		/** KASUMI decrypt (F8), then verify auth */
19408 		TEST_CASE_ST(ut_setup, ut_teardown,
19409 			test_kasumi_auth_cipher_verify_test_case_1),
19410 		TEST_CASE_ST(ut_setup, ut_teardown,
19411 			test_kasumi_auth_cipher_verify_test_case_2),
19412 		TEST_CASE_ST(ut_setup, ut_teardown,
19413 			test_kasumi_auth_cipher_verify_test_case_2_oop),
19414 		TEST_CASE_ST(ut_setup, ut_teardown,
19415 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
19416 		TEST_CASE_ST(ut_setup, ut_teardown,
19417 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
19418 
19419 		TEST_CASES_END()
19420 	}
19421 };
19422 
19423 static struct unit_test_suite cryptodev_esn_testsuite  = {
19424 	.suite_name = "ESN Test Suite",
19425 	.setup = esn_testsuite_setup,
19426 	.unit_test_cases = {
19427 		TEST_CASE_ST(ut_setup, ut_teardown,
19428 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
19429 		TEST_CASE_ST(ut_setup, ut_teardown,
19430 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
19431 		TEST_CASES_END()
19432 	}
19433 };
19434 
19435 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
19436 	.suite_name = "Negative AES GCM Test Suite",
19437 	.setup = negative_aes_gcm_testsuite_setup,
19438 	.unit_test_cases = {
19439 		TEST_CASE_ST(ut_setup, ut_teardown,
19440 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
19441 		TEST_CASE_ST(ut_setup, ut_teardown,
19442 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
19443 		TEST_CASE_ST(ut_setup, ut_teardown,
19444 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
19445 		TEST_CASE_ST(ut_setup, ut_teardown,
19446 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
19447 		TEST_CASE_ST(ut_setup, ut_teardown,
19448 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
19449 		TEST_CASE_ST(ut_setup, ut_teardown,
19450 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
19451 		TEST_CASE_ST(ut_setup, ut_teardown,
19452 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
19453 		TEST_CASE_ST(ut_setup, ut_teardown,
19454 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
19455 		TEST_CASE_ST(ut_setup, ut_teardown,
19456 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
19457 		TEST_CASE_ST(ut_setup, ut_teardown,
19458 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
19459 		TEST_CASE_ST(ut_setup, ut_teardown,
19460 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
19461 		TEST_CASE_ST(ut_setup, ut_teardown,
19462 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
19463 
19464 		TEST_CASES_END()
19465 	}
19466 };
19467 
19468 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
19469 	.suite_name = "Negative AES GMAC Test Suite",
19470 	.setup = negative_aes_gmac_testsuite_setup,
19471 	.unit_test_cases = {
19472 		TEST_CASE_ST(ut_setup, ut_teardown,
19473 			authentication_verify_AES128_GMAC_fail_data_corrupt),
19474 		TEST_CASE_ST(ut_setup, ut_teardown,
19475 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
19476 
19477 		TEST_CASES_END()
19478 	}
19479 };
19480 
19481 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
19482 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
19483 	.setup = mixed_cipher_hash_testsuite_setup,
19484 	.unit_test_cases = {
19485 		/** AUTH AES CMAC + CIPHER AES CTR */
19486 		TEST_CASE_ST(ut_setup, ut_teardown,
19487 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
19488 		TEST_CASE_ST(ut_setup, ut_teardown,
19489 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19490 		TEST_CASE_ST(ut_setup, ut_teardown,
19491 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19492 		TEST_CASE_ST(ut_setup, ut_teardown,
19493 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19494 		TEST_CASE_ST(ut_setup, ut_teardown,
19495 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
19496 		TEST_CASE_ST(ut_setup, ut_teardown,
19497 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
19498 		TEST_CASE_ST(ut_setup, ut_teardown,
19499 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
19500 		TEST_CASE_ST(ut_setup, ut_teardown,
19501 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
19502 		TEST_CASE_ST(ut_setup, ut_teardown,
19503 			test_aes_cmac_aes_ctr_digest_enc_test_case_2),
19504 		TEST_CASE_ST(ut_setup, ut_teardown,
19505 			test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19506 		TEST_CASE_ST(ut_setup, ut_teardown,
19507 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
19508 		TEST_CASE_ST(ut_setup, ut_teardown,
19509 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
19510 
19511 		/** AUTH ZUC + CIPHER SNOW3G */
19512 		TEST_CASE_ST(ut_setup, ut_teardown,
19513 			test_auth_zuc_cipher_snow_test_case_1),
19514 		TEST_CASE_ST(ut_setup, ut_teardown,
19515 			test_verify_auth_zuc_cipher_snow_test_case_1),
19516 		TEST_CASE_ST(ut_setup, ut_teardown,
19517 			test_auth_zuc_cipher_snow_test_case_1_inplace),
19518 		TEST_CASE_ST(ut_setup, ut_teardown,
19519 			test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
19520 		/** AUTH AES CMAC + CIPHER SNOW3G */
19521 		TEST_CASE_ST(ut_setup, ut_teardown,
19522 			test_auth_aes_cmac_cipher_snow_test_case_1),
19523 		TEST_CASE_ST(ut_setup, ut_teardown,
19524 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
19525 		TEST_CASE_ST(ut_setup, ut_teardown,
19526 			test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19527 		TEST_CASE_ST(ut_setup, ut_teardown,
19528 			test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
19529 		/** AUTH ZUC + CIPHER AES CTR */
19530 		TEST_CASE_ST(ut_setup, ut_teardown,
19531 			test_auth_zuc_cipher_aes_ctr_test_case_1),
19532 		TEST_CASE_ST(ut_setup, ut_teardown,
19533 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
19534 		TEST_CASE_ST(ut_setup, ut_teardown,
19535 			test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19536 		TEST_CASE_ST(ut_setup, ut_teardown,
19537 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
19538 		/** AUTH SNOW3G + CIPHER AES CTR */
19539 		TEST_CASE_ST(ut_setup, ut_teardown,
19540 			test_auth_snow_cipher_aes_ctr_test_case_1),
19541 		TEST_CASE_ST(ut_setup, ut_teardown,
19542 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
19543 		TEST_CASE_ST(ut_setup, ut_teardown,
19544 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19545 		TEST_CASE_ST(ut_setup, ut_teardown,
19546 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19547 		TEST_CASE_ST(ut_setup, ut_teardown,
19548 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
19549 		TEST_CASE_ST(ut_setup, ut_teardown,
19550 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
19551 		/** AUTH SNOW3G + CIPHER ZUC */
19552 		TEST_CASE_ST(ut_setup, ut_teardown,
19553 			test_auth_snow_cipher_zuc_test_case_1),
19554 		TEST_CASE_ST(ut_setup, ut_teardown,
19555 			test_verify_auth_snow_cipher_zuc_test_case_1),
19556 		TEST_CASE_ST(ut_setup, ut_teardown,
19557 			test_auth_snow_cipher_zuc_test_case_1_inplace),
19558 		TEST_CASE_ST(ut_setup, ut_teardown,
19559 			test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
19560 		/** AUTH AES CMAC + CIPHER ZUC */
19561 		TEST_CASE_ST(ut_setup, ut_teardown,
19562 			test_auth_aes_cmac_cipher_zuc_test_case_1),
19563 		TEST_CASE_ST(ut_setup, ut_teardown,
19564 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
19565 		TEST_CASE_ST(ut_setup, ut_teardown,
19566 			test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19567 		TEST_CASE_ST(ut_setup, ut_teardown,
19568 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
19569 
19570 		/** AUTH NULL + CIPHER SNOW3G */
19571 		TEST_CASE_ST(ut_setup, ut_teardown,
19572 			test_auth_null_cipher_snow_test_case_1),
19573 		TEST_CASE_ST(ut_setup, ut_teardown,
19574 			test_verify_auth_null_cipher_snow_test_case_1),
19575 		/** AUTH NULL + CIPHER ZUC */
19576 		TEST_CASE_ST(ut_setup, ut_teardown,
19577 			test_auth_null_cipher_zuc_test_case_1),
19578 		TEST_CASE_ST(ut_setup, ut_teardown,
19579 			test_verify_auth_null_cipher_zuc_test_case_1),
19580 		/** AUTH SNOW3G + CIPHER NULL */
19581 		TEST_CASE_ST(ut_setup, ut_teardown,
19582 			test_auth_snow_cipher_null_test_case_1),
19583 		TEST_CASE_ST(ut_setup, ut_teardown,
19584 			test_verify_auth_snow_cipher_null_test_case_1),
19585 		/** AUTH ZUC + CIPHER NULL */
19586 		TEST_CASE_ST(ut_setup, ut_teardown,
19587 			test_auth_zuc_cipher_null_test_case_1),
19588 		TEST_CASE_ST(ut_setup, ut_teardown,
19589 			test_verify_auth_zuc_cipher_null_test_case_1),
19590 		/** AUTH NULL + CIPHER AES CTR */
19591 		TEST_CASE_ST(ut_setup, ut_teardown,
19592 			test_auth_null_cipher_aes_ctr_test_case_1),
19593 		TEST_CASE_ST(ut_setup, ut_teardown,
19594 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
19595 		/** AUTH AES CMAC + CIPHER NULL */
19596 		TEST_CASE_ST(ut_setup, ut_teardown,
19597 			test_auth_aes_cmac_cipher_null_test_case_1),
19598 		TEST_CASE_ST(ut_setup, ut_teardown,
19599 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
19600 		TEST_CASES_END()
19601 	}
19602 };
19603 
19604 static int
19605 run_cryptodev_testsuite(const char *pmd_name)
19606 {
19607 	uint8_t ret, j, i = 0, blk_start_idx = 0;
19608 	const enum blockcipher_test_type blk_suites[] = {
19609 		BLKCIPHER_AES_CHAIN_TYPE,
19610 		BLKCIPHER_AES_CIPHERONLY_TYPE,
19611 		BLKCIPHER_AES_DOCSIS_TYPE,
19612 		BLKCIPHER_3DES_CHAIN_TYPE,
19613 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
19614 		BLKCIPHER_DES_CIPHERONLY_TYPE,
19615 		BLKCIPHER_DES_DOCSIS_TYPE,
19616 		BLKCIPHER_SM4_CHAIN_TYPE,
19617 		BLKCIPHER_SM4_CIPHERONLY_TYPE,
19618 		BLKCIPHER_AUTHONLY_TYPE};
19619 	struct unit_test_suite *static_suites[] = {
19620 		&cryptodev_multi_session_testsuite,
19621 		&cryptodev_null_testsuite,
19622 		&cryptodev_aes_ccm_auth_testsuite,
19623 		&cryptodev_aes_gcm_auth_testsuite,
19624 		&cryptodev_aes_gmac_auth_testsuite,
19625 		&cryptodev_snow3g_testsuite,
19626 		&cryptodev_chacha20_poly1305_testsuite,
19627 		&cryptodev_zuc_testsuite,
19628 		&cryptodev_hmac_md5_auth_testsuite,
19629 		&cryptodev_kasumi_testsuite,
19630 		&cryptodev_esn_testsuite,
19631 		&cryptodev_negative_aes_gcm_testsuite,
19632 		&cryptodev_negative_aes_gmac_testsuite,
19633 		&cryptodev_mixed_cipher_hash_testsuite,
19634 		&cryptodev_negative_hmac_sha1_testsuite,
19635 		&cryptodev_gen_testsuite,
19636 #ifdef RTE_LIB_SECURITY
19637 		&ipsec_proto_testsuite,
19638 		&pdcp_proto_testsuite,
19639 		&docsis_proto_testsuite,
19640 		&tls12_record_proto_testsuite,
19641 		&dtls12_record_proto_testsuite,
19642 		&tls13_record_proto_testsuite,
19643 #endif
19644 		&end_testsuite
19645 	};
19646 	static struct unit_test_suite ts = {
19647 		.suite_name = "Cryptodev Unit Test Suite",
19648 		.setup = testsuite_setup,
19649 		.teardown = testsuite_teardown,
19650 		.unit_test_cases = {TEST_CASES_END()}
19651 	};
19652 
19653 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
19654 
19655 	if (gbl_driver_id == -1) {
19656 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
19657 		return TEST_SKIPPED;
19658 	}
19659 
19660 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19661 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
19662 
19663 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
19664 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19665 	ret = unit_test_suite_runner(&ts);
19666 
19667 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
19668 	free(ts.unit_test_suites);
19669 	return ret;
19670 }
19671 
19672 static int
19673 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
19674 {
19675 	struct rte_cryptodev_info dev_info;
19676 	uint8_t i, nb_devs;
19677 	int driver_id;
19678 
19679 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
19680 	if (driver_id == -1) {
19681 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
19682 		return TEST_SKIPPED;
19683 	}
19684 
19685 	nb_devs = rte_cryptodev_count();
19686 	if (nb_devs < 1) {
19687 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
19688 		return TEST_SKIPPED;
19689 	}
19690 
19691 	for (i = 0; i < nb_devs; i++) {
19692 		rte_cryptodev_info_get(i, &dev_info);
19693 		if (dev_info.driver_id == driver_id) {
19694 			if (!(dev_info.feature_flags & flag)) {
19695 				RTE_LOG(INFO, USER1, "%s not supported\n",
19696 						flag_name);
19697 				return TEST_SKIPPED;
19698 			}
19699 			return 0; /* found */
19700 		}
19701 	}
19702 
19703 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
19704 	return TEST_SKIPPED;
19705 }
19706 
19707 static int
19708 test_cryptodev_qat(void)
19709 {
19710 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19711 }
19712 
19713 static int
19714 test_cryptodev_uadk(void)
19715 {
19716 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
19717 }
19718 
19719 static int
19720 test_cryptodev_virtio(void)
19721 {
19722 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
19723 }
19724 
19725 static int
19726 test_cryptodev_aesni_mb(void)
19727 {
19728 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19729 }
19730 
19731 static int
19732 test_cryptodev_cpu_aesni_mb(void)
19733 {
19734 	int32_t rc;
19735 	enum rte_security_session_action_type at = gbl_action_type;
19736 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19737 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19738 	gbl_action_type = at;
19739 	return rc;
19740 }
19741 
19742 static int
19743 test_cryptodev_chacha_poly_mb(void)
19744 {
19745 	int32_t rc;
19746 	enum rte_security_session_action_type at = gbl_action_type;
19747 	rc = run_cryptodev_testsuite(
19748 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
19749 	gbl_action_type = at;
19750 	return rc;
19751 }
19752 
19753 static int
19754 test_cryptodev_openssl(void)
19755 {
19756 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
19757 }
19758 
19759 static int
19760 test_cryptodev_aesni_gcm(void)
19761 {
19762 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19763 }
19764 
19765 static int
19766 test_cryptodev_cpu_aesni_gcm(void)
19767 {
19768 	int32_t rc;
19769 	enum rte_security_session_action_type at = gbl_action_type;
19770 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19771 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19772 	gbl_action_type = at;
19773 	return rc;
19774 }
19775 
19776 static int
19777 test_cryptodev_mlx5(void)
19778 {
19779 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
19780 }
19781 
19782 static int
19783 test_cryptodev_null(void)
19784 {
19785 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
19786 }
19787 
19788 static int
19789 test_cryptodev_sw_snow3g(void)
19790 {
19791 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
19792 }
19793 
19794 static int
19795 test_cryptodev_sw_kasumi(void)
19796 {
19797 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
19798 }
19799 
19800 static int
19801 test_cryptodev_sw_zuc(void)
19802 {
19803 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
19804 }
19805 
19806 static int
19807 test_cryptodev_armv8(void)
19808 {
19809 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
19810 }
19811 
19812 static int
19813 test_cryptodev_mrvl(void)
19814 {
19815 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
19816 }
19817 
19818 #ifdef RTE_CRYPTO_SCHEDULER
19819 
19820 static int
19821 test_cryptodev_scheduler(void)
19822 {
19823 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
19824 	const enum blockcipher_test_type blk_suites[] = {
19825 		BLKCIPHER_AES_CHAIN_TYPE,
19826 		BLKCIPHER_AES_CIPHERONLY_TYPE,
19827 		BLKCIPHER_AUTHONLY_TYPE
19828 	};
19829 	static struct unit_test_suite scheduler_multicore = {
19830 		.suite_name = "Scheduler Multicore Unit Test Suite",
19831 		.setup = scheduler_multicore_testsuite_setup,
19832 		.teardown = scheduler_mode_testsuite_teardown,
19833 		.unit_test_cases = {TEST_CASES_END()}
19834 	};
19835 	static struct unit_test_suite scheduler_round_robin = {
19836 		.suite_name = "Scheduler Round Robin Unit Test Suite",
19837 		.setup = scheduler_roundrobin_testsuite_setup,
19838 		.teardown = scheduler_mode_testsuite_teardown,
19839 		.unit_test_cases = {TEST_CASES_END()}
19840 	};
19841 	static struct unit_test_suite scheduler_failover = {
19842 		.suite_name = "Scheduler Failover Unit Test Suite",
19843 		.setup = scheduler_failover_testsuite_setup,
19844 		.teardown = scheduler_mode_testsuite_teardown,
19845 		.unit_test_cases = {TEST_CASES_END()}
19846 	};
19847 	static struct unit_test_suite scheduler_pkt_size_distr = {
19848 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
19849 		.setup = scheduler_pkt_size_distr_testsuite_setup,
19850 		.teardown = scheduler_mode_testsuite_teardown,
19851 		.unit_test_cases = {TEST_CASES_END()}
19852 	};
19853 	struct unit_test_suite *sched_mode_suites[] = {
19854 		&scheduler_multicore,
19855 		&scheduler_round_robin,
19856 		&scheduler_failover,
19857 		&scheduler_pkt_size_distr
19858 	};
19859 	static struct unit_test_suite scheduler_config = {
19860 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
19861 		.unit_test_cases = {
19862 			TEST_CASE(test_scheduler_attach_worker_op),
19863 			TEST_CASE(test_scheduler_mode_multicore_op),
19864 			TEST_CASE(test_scheduler_mode_roundrobin_op),
19865 			TEST_CASE(test_scheduler_mode_failover_op),
19866 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
19867 			TEST_CASE(test_scheduler_detach_worker_op),
19868 
19869 			TEST_CASES_END() /**< NULL terminate array */
19870 		}
19871 	};
19872 	struct unit_test_suite *static_suites[] = {
19873 		&scheduler_config,
19874 		&end_testsuite
19875 	};
19876 	struct unit_test_suite *sched_mode_static_suites[] = {
19877 #ifdef RTE_LIB_SECURITY
19878 		&docsis_proto_testsuite,
19879 #endif
19880 		&end_testsuite
19881 	};
19882 	static struct unit_test_suite ts = {
19883 		.suite_name = "Scheduler Unit Test Suite",
19884 		.setup = scheduler_testsuite_setup,
19885 		.teardown = testsuite_teardown,
19886 		.unit_test_cases = {TEST_CASES_END()}
19887 	};
19888 
19889 	gbl_driver_id =	rte_cryptodev_driver_id_get(
19890 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
19891 
19892 	if (gbl_driver_id == -1) {
19893 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
19894 		return TEST_SKIPPED;
19895 	}
19896 
19897 	if (rte_cryptodev_driver_id_get(
19898 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
19899 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
19900 		return TEST_SKIPPED;
19901 	}
19902 
19903 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19904 		uint8_t blk_i = 0;
19905 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
19906 				(struct unit_test_suite *) *
19907 				(RTE_DIM(blk_suites) +
19908 				RTE_DIM(sched_mode_static_suites) + 1));
19909 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19910 				blk_suites, RTE_DIM(blk_suites));
19911 		ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19912 				sched_mode_static_suites,
19913 				RTE_DIM(sched_mode_static_suites));
19914 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
19915 	}
19916 
19917 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19918 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
19919 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
19920 			RTE_DIM(sched_mode_suites));
19921 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19922 	ret = unit_test_suite_runner(&ts);
19923 
19924 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19925 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
19926 				(*sched_mode_suites[sched_i]),
19927 				RTE_DIM(blk_suites));
19928 		free(sched_mode_suites[sched_i]->unit_test_suites);
19929 	}
19930 	free(ts.unit_test_suites);
19931 	return ret;
19932 }
19933 
19934 REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
19935 
19936 #endif
19937 
19938 static int
19939 test_cryptodev_dpaa2_sec(void)
19940 {
19941 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19942 }
19943 
19944 static int
19945 test_cryptodev_dpaa_sec(void)
19946 {
19947 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19948 }
19949 
19950 static int
19951 test_cryptodev_ccp(void)
19952 {
19953 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
19954 }
19955 
19956 static int
19957 test_cryptodev_octeontx(void)
19958 {
19959 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
19960 }
19961 
19962 static int
19963 test_cryptodev_caam_jr(void)
19964 {
19965 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
19966 }
19967 
19968 static int
19969 test_cryptodev_nitrox(void)
19970 {
19971 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
19972 }
19973 
19974 static int
19975 test_cryptodev_bcmfs(void)
19976 {
19977 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
19978 }
19979 
19980 static int
19981 run_cryptodev_raw_testsuite(const char *pmd_name)
19982 {
19983 	int ret;
19984 
19985 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
19986 	if (ret)
19987 		return ret;
19988 
19989 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
19990 	ret = run_cryptodev_testsuite(pmd_name);
19991 	global_api_test_type = CRYPTODEV_API_TEST;
19992 
19993 	return ret;
19994 }
19995 
19996 static int
19997 test_cryptodev_qat_raw_api(void)
19998 {
19999 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
20000 }
20001 
20002 static int
20003 test_cryptodev_cn9k(void)
20004 {
20005 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
20006 }
20007 
20008 static int
20009 test_cryptodev_cn10k(void)
20010 {
20011 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20012 }
20013 
20014 static int
20015 test_cryptodev_cn10k_raw_api(void)
20016 {
20017 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
20018 }
20019 
20020 static int
20021 test_cryptodev_dpaa2_sec_raw_api(void)
20022 {
20023 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
20024 }
20025 
20026 static int
20027 test_cryptodev_dpaa_sec_raw_api(void)
20028 {
20029 	return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
20030 }
20031 
20032 REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
20033 		test_cryptodev_cn10k_raw_api);
20034 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
20035 		test_cryptodev_dpaa2_sec_raw_api);
20036 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
20037 		test_cryptodev_dpaa_sec_raw_api);
20038 REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
20039 		test_cryptodev_qat_raw_api);
20040 REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
20041 REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
20042 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
20043 	test_cryptodev_cpu_aesni_mb);
20044 REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
20045 	test_cryptodev_chacha_poly_mb);
20046 REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
20047 REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
20048 REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
20049 	test_cryptodev_cpu_aesni_gcm);
20050 REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
20051 REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
20052 REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
20053 REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
20054 REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
20055 REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
20056 REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
20057 REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
20058 REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
20059 REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
20060 REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
20061 REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
20062 REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
20063 REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
20064 REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
20065 REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
20066 REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
20067 REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
20068