xref: /dpdk/app/test/test_cryptodev.c (revision 4b53e9802b6b6040ad5622b1414aaa93d9581d0c)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Intel Corporation
3  * Copyright 2020 NXP
4  */
5 
6 #include <time.h>
7 
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
10 #include <rte_mbuf.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
16 #include <rte_errno.h>
17 
18 #include <rte_crypto.h>
19 #include <rte_cryptodev.h>
20 #include <rte_ip.h>
21 #include <rte_string_fns.h>
22 #include <rte_tcp.h>
23 #include <rte_udp.h>
24 
25 #ifdef RTE_CRYPTO_SCHEDULER
26 #include <rte_cryptodev_scheduler.h>
27 #include <rte_cryptodev_scheduler_operations.h>
28 #endif
29 
30 #include <rte_lcore.h>
31 
32 #include "test.h"
33 #include "test_cryptodev.h"
34 
35 #include "test_cryptodev_blockcipher.h"
36 #include "test_cryptodev_aes_test_vectors.h"
37 #include "test_cryptodev_des_test_vectors.h"
38 #include "test_cryptodev_hash_test_vectors.h"
39 #include "test_cryptodev_kasumi_test_vectors.h"
40 #include "test_cryptodev_kasumi_hash_test_vectors.h"
41 #include "test_cryptodev_snow3g_test_vectors.h"
42 #include "test_cryptodev_snow3g_hash_test_vectors.h"
43 #include "test_cryptodev_zuc_test_vectors.h"
44 #include "test_cryptodev_aead_test_vectors.h"
45 #include "test_cryptodev_hmac_test_vectors.h"
46 #include "test_cryptodev_mixed_test_vectors.h"
47 #ifdef RTE_LIB_SECURITY
48 #include "test_cryptodev_security_ipsec.h"
49 #include "test_cryptodev_security_ipsec_test_vectors.h"
50 #include "test_cryptodev_security_pdcp_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
52 #include "test_cryptodev_security_pdcp_test_func.h"
53 #include "test_cryptodev_security_docsis_test_vectors.h"
54 
55 #define SDAP_DISABLED	0
56 #define SDAP_ENABLED	1
57 #endif
58 
59 #define VDEV_ARGS_SIZE 100
60 #define MAX_NB_SESSIONS 4
61 
62 #define MAX_DRV_SERVICE_CTX_SIZE 256
63 
64 #define MAX_RAW_DEQUEUE_COUNT	65535
65 
66 #define IN_PLACE 0
67 #define OUT_OF_PLACE 1
68 
69 static int gbl_driver_id;
70 
71 static enum rte_security_session_action_type gbl_action_type =
72 	RTE_SECURITY_ACTION_TYPE_NONE;
73 
74 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 
76 struct crypto_unittest_params {
77 	struct rte_crypto_sym_xform cipher_xform;
78 	struct rte_crypto_sym_xform auth_xform;
79 	struct rte_crypto_sym_xform aead_xform;
80 #ifdef RTE_LIB_SECURITY
81 	struct rte_security_docsis_xform docsis_xform;
82 #endif
83 
84 	union {
85 		void *sess;
86 #ifdef RTE_LIB_SECURITY
87 		void *sec_session;
88 #endif
89 	};
90 #ifdef RTE_LIB_SECURITY
91 	enum rte_security_session_action_type type;
92 #endif
93 	struct rte_crypto_op *op;
94 
95 	struct rte_mbuf *obuf, *ibuf;
96 
97 	uint8_t *digest;
98 };
99 
100 #define ALIGN_POW2_ROUNDUP(num, align) \
101 	(((num) + (align) - 1) & ~((align) - 1))
102 
103 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
104 	for (j = 0; j < num_child_ts; index++, j++)			\
105 		parent_ts.unit_test_suites[index] = child_ts[j]
106 
107 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
108 	for (j = 0; j < num_blk_types; index++, j++)				\
109 		parent_ts.unit_test_suites[index] =				\
110 				build_blockcipher_test_suite(blk_types[j])
111 
112 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
113 	for (j = index; j < index + num_blk_types; j++)				\
114 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
115 
116 /*
117  * Forward declarations.
118  */
119 static int
120 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
121 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
122 		uint8_t *hmac_key);
123 
124 static int
125 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
126 		struct crypto_unittest_params *ut_params,
127 		struct crypto_testsuite_params *ts_param,
128 		const uint8_t *cipher,
129 		const uint8_t *digest,
130 		const uint8_t *iv);
131 
132 static int
133 security_proto_supported(enum rte_security_session_action_type action,
134 	enum rte_security_session_protocol proto);
135 
136 static int
137 dev_configure_and_start(uint64_t ff_disable);
138 
139 static struct rte_mbuf *
140 setup_test_string(struct rte_mempool *mpool,
141 		const char *string, size_t len, uint8_t blocksize)
142 {
143 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
144 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
145 
146 	if (m) {
147 		char *dst;
148 
149 		memset(m->buf_addr, 0, m->buf_len);
150 		dst = rte_pktmbuf_append(m, t_len);
151 		if (!dst) {
152 			rte_pktmbuf_free(m);
153 			return NULL;
154 		}
155 		if (string != NULL)
156 			rte_memcpy(dst, string, t_len);
157 		else
158 			memset(dst, 0, t_len);
159 	}
160 
161 	return m;
162 }
163 
164 /* Get number of bytes in X bits (rounding up) */
165 static uint32_t
166 ceil_byte_length(uint32_t num_bits)
167 {
168 	if (num_bits % 8)
169 		return ((num_bits >> 3) + 1);
170 	else
171 		return (num_bits >> 3);
172 }
173 
174 static void
175 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
176 		uint8_t is_op_success)
177 {
178 	struct rte_crypto_op *op = user_data;
179 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
180 			RTE_CRYPTO_OP_STATUS_ERROR;
181 }
182 
183 static struct crypto_testsuite_params testsuite_params = { NULL };
184 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
185 static struct crypto_unittest_params unittest_params;
186 
187 void
188 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
189 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
190 		uint8_t len_in_bits, uint8_t cipher_iv_len)
191 {
192 	struct rte_crypto_sym_op *sop = op->sym;
193 	struct rte_crypto_op *ret_op = NULL;
194 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
195 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
196 	union rte_crypto_sym_ofs ofs;
197 	struct rte_crypto_sym_vec vec;
198 	struct rte_crypto_sgl sgl, dest_sgl;
199 	uint32_t max_len;
200 	union rte_cryptodev_session_ctx sess;
201 	uint64_t auth_end_iova;
202 	uint32_t count = 0;
203 	struct rte_crypto_raw_dp_ctx *ctx;
204 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
205 			auth_len = 0;
206 	int32_t n;
207 	uint32_t n_success;
208 	int ctx_service_size;
209 	int32_t status = 0;
210 	int enqueue_status, dequeue_status;
211 	struct crypto_unittest_params *ut_params = &unittest_params;
212 	int is_sgl = sop->m_src->nb_segs > 1;
213 	int is_oop = 0;
214 
215 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
216 	if (ctx_service_size < 0) {
217 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
218 		return;
219 	}
220 
221 	ctx = malloc(ctx_service_size);
222 	if (!ctx) {
223 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
224 		return;
225 	}
226 
227 	/* Both are enums, setting crypto_sess will suit any session type */
228 	sess.crypto_sess = op->sym->session;
229 
230 	if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
231 			op->sess_type, sess, 0) < 0) {
232 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
233 		goto exit;
234 	}
235 
236 	cipher_iv.iova = 0;
237 	cipher_iv.va = NULL;
238 	aad_auth_iv.iova = 0;
239 	aad_auth_iv.va = NULL;
240 	digest.iova = 0;
241 	digest.va = NULL;
242 	sgl.vec = data_vec;
243 	vec.num = 1;
244 	vec.src_sgl = &sgl;
245 	vec.iv = &cipher_iv;
246 	vec.digest = &digest;
247 	vec.aad = &aad_auth_iv;
248 	vec.status = &status;
249 
250 	ofs.raw = 0;
251 
252 	if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
253 		is_oop = 1;
254 
255 	if (is_cipher && is_auth) {
256 		cipher_offset = sop->cipher.data.offset;
257 		cipher_len = sop->cipher.data.length;
258 		auth_offset = sop->auth.data.offset;
259 		auth_len = sop->auth.data.length;
260 		max_len = RTE_MAX(cipher_offset + cipher_len,
261 				auth_offset + auth_len);
262 		if (len_in_bits) {
263 			max_len = max_len >> 3;
264 			cipher_offset = cipher_offset >> 3;
265 			auth_offset = auth_offset >> 3;
266 			cipher_len = cipher_len >> 3;
267 			auth_len = auth_len >> 3;
268 		}
269 		ofs.ofs.cipher.head = cipher_offset;
270 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
271 		ofs.ofs.auth.head = auth_offset;
272 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
273 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
274 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
275 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
276 				op, void *, IV_OFFSET + cipher_iv_len);
277 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
278 				cipher_iv_len);
279 		digest.va = (void *)sop->auth.digest.data;
280 		digest.iova = sop->auth.digest.phys_addr;
281 
282 		if (is_sgl) {
283 			uint32_t remaining_off = auth_offset + auth_len;
284 			struct rte_mbuf *sgl_buf = sop->m_src;
285 			if (is_oop)
286 				sgl_buf = sop->m_dst;
287 
288 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
289 					&& sgl_buf->next != NULL) {
290 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
291 				sgl_buf = sgl_buf->next;
292 			}
293 
294 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
295 				sgl_buf, remaining_off);
296 		} else {
297 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
298 							 auth_offset + auth_len;
299 		}
300 		/* Then check if digest-encrypted conditions are met */
301 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
302 				(digest.iova == auth_end_iova) && is_sgl)
303 			max_len = RTE_MAX(max_len,
304 				auth_offset + auth_len +
305 				ut_params->auth_xform.auth.digest_length);
306 
307 	} else if (is_cipher) {
308 		cipher_offset = sop->cipher.data.offset;
309 		cipher_len = sop->cipher.data.length;
310 		max_len = cipher_len + cipher_offset;
311 		if (len_in_bits) {
312 			max_len = max_len >> 3;
313 			cipher_offset = cipher_offset >> 3;
314 			cipher_len = cipher_len >> 3;
315 		}
316 		ofs.ofs.cipher.head = cipher_offset;
317 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
318 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
319 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
320 
321 	} else if (is_auth) {
322 		auth_offset = sop->auth.data.offset;
323 		auth_len = sop->auth.data.length;
324 		max_len = auth_len + auth_offset;
325 		if (len_in_bits) {
326 			max_len = max_len >> 3;
327 			auth_offset = auth_offset >> 3;
328 			auth_len = auth_len >> 3;
329 		}
330 		ofs.ofs.auth.head = auth_offset;
331 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
332 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
333 				op, void *, IV_OFFSET + cipher_iv_len);
334 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
335 				cipher_iv_len);
336 		digest.va = (void *)sop->auth.digest.data;
337 		digest.iova = sop->auth.digest.phys_addr;
338 
339 	} else { /* aead */
340 		cipher_offset = sop->aead.data.offset;
341 		cipher_len = sop->aead.data.length;
342 		max_len = cipher_len + cipher_offset;
343 		if (len_in_bits) {
344 			max_len = max_len >> 3;
345 			cipher_offset = cipher_offset >> 3;
346 			cipher_len = cipher_len >> 3;
347 		}
348 		ofs.ofs.cipher.head = cipher_offset;
349 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
350 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
351 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
352 		aad_auth_iv.va = (void *)sop->aead.aad.data;
353 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
354 		digest.va = (void *)sop->aead.digest.data;
355 		digest.iova = sop->aead.digest.phys_addr;
356 	}
357 
358 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
359 			data_vec, RTE_DIM(data_vec));
360 	if (n < 0 || n > sop->m_src->nb_segs) {
361 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
362 		goto exit;
363 	}
364 
365 	sgl.num = n;
366 	/* Out of place */
367 	if (is_oop) {
368 		dest_sgl.vec = dest_data_vec;
369 		vec.dest_sgl = &dest_sgl;
370 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
371 				dest_data_vec, RTE_DIM(dest_data_vec));
372 		if (n < 0 || n > sop->m_dst->nb_segs) {
373 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
374 			goto exit;
375 		}
376 		dest_sgl.num = n;
377 	} else
378 		vec.dest_sgl = NULL;
379 
380 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
381 			&enqueue_status) < 1) {
382 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
383 		goto exit;
384 	}
385 
386 	if (enqueue_status == 0) {
387 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
388 		if (status < 0) {
389 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
390 			goto exit;
391 		}
392 	} else if (enqueue_status < 0) {
393 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
394 		goto exit;
395 	}
396 
397 	n = n_success = 0;
398 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
399 		n = rte_cryptodev_raw_dequeue_burst(ctx,
400 			NULL, 1, post_process_raw_dp_op,
401 				(void **)&ret_op, 0, &n_success,
402 				&dequeue_status);
403 		if (dequeue_status < 0) {
404 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
405 			goto exit;
406 		}
407 		if (n == 0)
408 			rte_pause();
409 	}
410 
411 	if (n == 1 && dequeue_status == 0) {
412 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
413 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
414 			goto exit;
415 		}
416 	}
417 
418 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
419 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
420 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
421 					RTE_CRYPTO_OP_STATUS_SUCCESS;
422 
423 exit:
424 	free(ctx);
425 }
426 
427 static void
428 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
429 {
430 	int32_t n, st;
431 	struct rte_crypto_sym_op *sop;
432 	union rte_crypto_sym_ofs ofs;
433 	struct rte_crypto_sgl sgl;
434 	struct rte_crypto_sym_vec symvec;
435 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
436 	struct rte_crypto_vec vec[UINT8_MAX];
437 
438 	sop = op->sym;
439 
440 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
441 		sop->aead.data.length, vec, RTE_DIM(vec));
442 
443 	if (n < 0 || n != sop->m_src->nb_segs) {
444 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
445 		return;
446 	}
447 
448 	sgl.vec = vec;
449 	sgl.num = n;
450 	symvec.src_sgl = &sgl;
451 	symvec.iv = &iv_ptr;
452 	symvec.digest = &digest_ptr;
453 	symvec.aad = &aad_ptr;
454 	symvec.status = &st;
455 	symvec.num = 1;
456 
457 	/* for CPU crypto the IOVA address is not required */
458 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
459 	digest_ptr.va = (void *)sop->aead.digest.data;
460 	aad_ptr.va = (void *)sop->aead.aad.data;
461 
462 	ofs.raw = 0;
463 
464 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
465 		&symvec);
466 
467 	if (n != 1)
468 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
469 	else
470 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
471 }
472 
473 static void
474 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
475 {
476 	int32_t n, st;
477 	struct rte_crypto_sym_op *sop;
478 	union rte_crypto_sym_ofs ofs;
479 	struct rte_crypto_sgl sgl;
480 	struct rte_crypto_sym_vec symvec;
481 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
482 	struct rte_crypto_vec vec[UINT8_MAX];
483 
484 	sop = op->sym;
485 
486 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
487 		sop->auth.data.length, vec, RTE_DIM(vec));
488 
489 	if (n < 0 || n != sop->m_src->nb_segs) {
490 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
491 		return;
492 	}
493 
494 	sgl.vec = vec;
495 	sgl.num = n;
496 	symvec.src_sgl = &sgl;
497 	symvec.iv = &iv_ptr;
498 	symvec.digest = &digest_ptr;
499 	symvec.status = &st;
500 	symvec.num = 1;
501 
502 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
503 	digest_ptr.va = (void *)sop->auth.digest.data;
504 
505 	ofs.raw = 0;
506 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
507 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
508 		(sop->cipher.data.offset + sop->cipher.data.length);
509 
510 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
511 		&symvec);
512 
513 	if (n != 1)
514 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
515 	else
516 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
517 }
518 
519 static struct rte_crypto_op *
520 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
521 {
522 
523 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
524 
525 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
526 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
527 		return NULL;
528 	}
529 
530 	op = NULL;
531 
532 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
533 		rte_pause();
534 
535 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
536 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
537 		return NULL;
538 	}
539 
540 	return op;
541 }
542 
543 static int
544 testsuite_setup(void)
545 {
546 	struct crypto_testsuite_params *ts_params = &testsuite_params;
547 	struct rte_cryptodev_info info;
548 	uint32_t i = 0, nb_devs, dev_id;
549 	uint16_t qp_id;
550 
551 	memset(ts_params, 0, sizeof(*ts_params));
552 
553 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
554 	if (ts_params->mbuf_pool == NULL) {
555 		/* Not already created so create */
556 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
557 				"CRYPTO_MBUFPOOL",
558 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
559 				rte_socket_id());
560 		if (ts_params->mbuf_pool == NULL) {
561 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
562 			return TEST_FAILED;
563 		}
564 	}
565 
566 	ts_params->large_mbuf_pool = rte_mempool_lookup(
567 			"CRYPTO_LARGE_MBUFPOOL");
568 	if (ts_params->large_mbuf_pool == NULL) {
569 		/* Not already created so create */
570 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
571 				"CRYPTO_LARGE_MBUFPOOL",
572 				1, 0, 0, UINT16_MAX,
573 				rte_socket_id());
574 		if (ts_params->large_mbuf_pool == NULL) {
575 			RTE_LOG(ERR, USER1,
576 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
577 			return TEST_FAILED;
578 		}
579 	}
580 
581 	ts_params->op_mpool = rte_crypto_op_pool_create(
582 			"MBUF_CRYPTO_SYM_OP_POOL",
583 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
584 			NUM_MBUFS, MBUF_CACHE_SIZE,
585 			DEFAULT_NUM_XFORMS *
586 			sizeof(struct rte_crypto_sym_xform) +
587 			MAXIMUM_IV_LENGTH,
588 			rte_socket_id());
589 	if (ts_params->op_mpool == NULL) {
590 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
591 		return TEST_FAILED;
592 	}
593 
594 	nb_devs = rte_cryptodev_count();
595 	if (nb_devs < 1) {
596 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
597 		return TEST_SKIPPED;
598 	}
599 
600 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
601 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
602 				rte_cryptodev_driver_name_get(gbl_driver_id));
603 		return TEST_SKIPPED;
604 	}
605 
606 	/* Create list of valid crypto devs */
607 	for (i = 0; i < nb_devs; i++) {
608 		rte_cryptodev_info_get(i, &info);
609 		if (info.driver_id == gbl_driver_id)
610 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
611 	}
612 
613 	if (ts_params->valid_dev_count < 1)
614 		return TEST_FAILED;
615 
616 	/* Set up all the qps on the first of the valid devices found */
617 
618 	dev_id = ts_params->valid_devs[0];
619 
620 	rte_cryptodev_info_get(dev_id, &info);
621 
622 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
623 	ts_params->conf.socket_id = SOCKET_ID_ANY;
624 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
625 
626 	unsigned int session_size =
627 		rte_cryptodev_sym_get_private_session_size(dev_id);
628 
629 #ifdef RTE_LIB_SECURITY
630 	unsigned int security_session_size = rte_security_session_get_size(
631 			rte_cryptodev_get_sec_ctx(dev_id));
632 
633 	if (session_size < security_session_size)
634 		session_size = security_session_size;
635 #endif
636 	/*
637 	 * Create mempool with maximum number of sessions.
638 	 */
639 	if (info.sym.max_nb_sessions != 0 &&
640 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
641 		RTE_LOG(ERR, USER1, "Device does not support "
642 				"at least %u sessions\n",
643 				MAX_NB_SESSIONS);
644 		return TEST_FAILED;
645 	}
646 
647 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
648 			"test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
649 			SOCKET_ID_ANY);
650 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
651 			"session mempool allocation failed");
652 
653 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
654 			&ts_params->conf),
655 			"Failed to configure cryptodev %u with %u qps",
656 			dev_id, ts_params->conf.nb_queue_pairs);
657 
658 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
659 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
660 
661 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
662 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
663 			dev_id, qp_id, &ts_params->qp_conf,
664 			rte_cryptodev_socket_id(dev_id)),
665 			"Failed to setup queue pair %u on cryptodev %u",
666 			qp_id, dev_id);
667 	}
668 
669 	return TEST_SUCCESS;
670 }
671 
672 static void
673 testsuite_teardown(void)
674 {
675 	struct crypto_testsuite_params *ts_params = &testsuite_params;
676 	int res;
677 
678 	if (ts_params->mbuf_pool != NULL) {
679 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
680 		rte_mempool_avail_count(ts_params->mbuf_pool));
681 	}
682 
683 	if (ts_params->op_mpool != NULL) {
684 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
685 		rte_mempool_avail_count(ts_params->op_mpool));
686 	}
687 
688 	if (ts_params->session_mpool != NULL) {
689 		rte_mempool_free(ts_params->session_mpool);
690 		ts_params->session_mpool = NULL;
691 	}
692 
693 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
694 	if (res)
695 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
696 }
697 
698 static int
699 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
700 		const int *algs, uint16_t num_algs)
701 {
702 	uint8_t dev_id = testsuite_params.valid_devs[0];
703 	bool some_alg_supported = FALSE;
704 	uint16_t i;
705 
706 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
707 		struct rte_cryptodev_sym_capability_idx alg = {
708 			type, {algs[i]}
709 		};
710 		if (rte_cryptodev_sym_capability_get(dev_id,
711 				&alg) != NULL)
712 			some_alg_supported = TRUE;
713 	}
714 	if (!some_alg_supported)
715 		return TEST_SKIPPED;
716 
717 	return 0;
718 }
719 
720 int
721 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
722 		uint16_t num_ciphers)
723 {
724 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
725 			(const int *) ciphers, num_ciphers);
726 }
727 
728 int
729 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
730 		uint16_t num_auths)
731 {
732 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
733 			(const int *) auths, num_auths);
734 }
735 
736 int
737 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
738 		uint16_t num_aeads)
739 {
740 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
741 			(const int *) aeads, num_aeads);
742 }
743 
744 static int
745 null_testsuite_setup(void)
746 {
747 	struct crypto_testsuite_params *ts_params = &testsuite_params;
748 	uint8_t dev_id = ts_params->valid_devs[0];
749 	struct rte_cryptodev_info dev_info;
750 	const enum rte_crypto_cipher_algorithm ciphers[] = {
751 		RTE_CRYPTO_CIPHER_NULL
752 	};
753 	const enum rte_crypto_auth_algorithm auths[] = {
754 		RTE_CRYPTO_AUTH_NULL
755 	};
756 
757 	rte_cryptodev_info_get(dev_id, &dev_info);
758 
759 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
760 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
761 				"testsuite not met\n");
762 		return TEST_SKIPPED;
763 	}
764 
765 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
766 			&& check_auth_capabilities_supported(auths,
767 			RTE_DIM(auths)) != 0) {
768 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
769 				"testsuite not met\n");
770 		return TEST_SKIPPED;
771 	}
772 
773 	return 0;
774 }
775 
776 static int
777 crypto_gen_testsuite_setup(void)
778 {
779 	struct crypto_testsuite_params *ts_params = &testsuite_params;
780 	uint8_t dev_id = ts_params->valid_devs[0];
781 	struct rte_cryptodev_info dev_info;
782 
783 	rte_cryptodev_info_get(dev_id, &dev_info);
784 
785 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
786 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
787 				"testsuite not met\n");
788 		return TEST_SKIPPED;
789 	}
790 
791 	return 0;
792 }
793 
794 #ifdef RTE_LIB_SECURITY
795 static int
796 ipsec_proto_testsuite_setup(void)
797 {
798 	struct crypto_testsuite_params *ts_params = &testsuite_params;
799 	struct crypto_unittest_params *ut_params = &unittest_params;
800 	struct rte_cryptodev_info dev_info;
801 	int ret = 0;
802 
803 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
804 
805 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
806 		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
807 				"testsuite not met\n");
808 		return TEST_SKIPPED;
809 	}
810 
811 	/* Reconfigure to enable security */
812 	ret = dev_configure_and_start(0);
813 	if (ret != TEST_SUCCESS)
814 		return ret;
815 
816 	/* Set action type */
817 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
818 
819 	if (security_proto_supported(
820 			RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
821 			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
822 		RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
823 				"test not met\n");
824 		ret = TEST_SKIPPED;
825 	}
826 
827 	test_ipsec_alg_list_populate();
828 	test_ipsec_ah_alg_list_populate();
829 
830 	/*
831 	 * Stop the device. Device would be started again by individual test
832 	 * case setup routine.
833 	 */
834 	rte_cryptodev_stop(ts_params->valid_devs[0]);
835 
836 	return ret;
837 }
838 
839 static int
840 pdcp_proto_testsuite_setup(void)
841 {
842 	struct crypto_testsuite_params *ts_params = &testsuite_params;
843 	uint8_t dev_id = ts_params->valid_devs[0];
844 	struct rte_cryptodev_info dev_info;
845 	const enum rte_crypto_cipher_algorithm ciphers[] = {
846 		RTE_CRYPTO_CIPHER_NULL,
847 		RTE_CRYPTO_CIPHER_AES_CTR,
848 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
849 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
850 	};
851 	const enum rte_crypto_auth_algorithm auths[] = {
852 		RTE_CRYPTO_AUTH_NULL,
853 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
854 		RTE_CRYPTO_AUTH_AES_CMAC,
855 		RTE_CRYPTO_AUTH_ZUC_EIA3
856 	};
857 
858 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
859 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
860 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
861 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
862 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
863 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
864 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
865 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
866 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
867 	RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
868 
869 	rte_cryptodev_info_get(dev_id, &dev_info);
870 
871 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
872 			!(dev_info.feature_flags &
873 			RTE_CRYPTODEV_FF_SECURITY)) {
874 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
875 				"testsuite not met\n");
876 		return TEST_SKIPPED;
877 	}
878 
879 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
880 			&& check_auth_capabilities_supported(auths,
881 			RTE_DIM(auths)) != 0) {
882 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
883 				"testsuite not met\n");
884 		return TEST_SKIPPED;
885 	}
886 
887 	return 0;
888 }
889 
890 static int
891 docsis_proto_testsuite_setup(void)
892 {
893 	struct crypto_testsuite_params *ts_params = &testsuite_params;
894 	uint8_t dev_id = ts_params->valid_devs[0];
895 	struct rte_cryptodev_info dev_info;
896 	const enum rte_crypto_cipher_algorithm ciphers[] = {
897 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
898 	};
899 
900 	rte_cryptodev_info_get(dev_id, &dev_info);
901 
902 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
903 			!(dev_info.feature_flags &
904 			RTE_CRYPTODEV_FF_SECURITY)) {
905 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
906 				"Proto testsuite not met\n");
907 		return TEST_SKIPPED;
908 	}
909 
910 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
911 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
912 				"testsuite not met\n");
913 		return TEST_SKIPPED;
914 	}
915 
916 	return 0;
917 }
918 #endif
919 
920 static int
921 aes_ccm_auth_testsuite_setup(void)
922 {
923 	struct crypto_testsuite_params *ts_params = &testsuite_params;
924 	uint8_t dev_id = ts_params->valid_devs[0];
925 	struct rte_cryptodev_info dev_info;
926 	const enum rte_crypto_aead_algorithm aeads[] = {
927 		RTE_CRYPTO_AEAD_AES_CCM
928 	};
929 
930 	rte_cryptodev_info_get(dev_id, &dev_info);
931 
932 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
933 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
934 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
935 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
936 				"testsuite not met\n");
937 		return TEST_SKIPPED;
938 	}
939 
940 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
941 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
942 				"testsuite not met\n");
943 		return TEST_SKIPPED;
944 	}
945 
946 	return 0;
947 }
948 
949 static int
950 aes_gcm_auth_testsuite_setup(void)
951 {
952 	struct crypto_testsuite_params *ts_params = &testsuite_params;
953 	uint8_t dev_id = ts_params->valid_devs[0];
954 	struct rte_cryptodev_info dev_info;
955 	const enum rte_crypto_aead_algorithm aeads[] = {
956 		RTE_CRYPTO_AEAD_AES_GCM
957 	};
958 
959 	rte_cryptodev_info_get(dev_id, &dev_info);
960 
961 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
962 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
963 				"testsuite not met\n");
964 		return TEST_SKIPPED;
965 	}
966 
967 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
968 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
969 				"testsuite not met\n");
970 		return TEST_SKIPPED;
971 	}
972 
973 	return 0;
974 }
975 
976 static int
977 aes_gmac_auth_testsuite_setup(void)
978 {
979 	struct crypto_testsuite_params *ts_params = &testsuite_params;
980 	uint8_t dev_id = ts_params->valid_devs[0];
981 	struct rte_cryptodev_info dev_info;
982 	const enum rte_crypto_auth_algorithm auths[] = {
983 		RTE_CRYPTO_AUTH_AES_GMAC
984 	};
985 
986 	rte_cryptodev_info_get(dev_id, &dev_info);
987 
988 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
989 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
990 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
991 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
992 				"testsuite not met\n");
993 		return TEST_SKIPPED;
994 	}
995 
996 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
997 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
998 				"testsuite not met\n");
999 		return TEST_SKIPPED;
1000 	}
1001 
1002 	return 0;
1003 }
1004 
1005 static int
1006 chacha20_poly1305_testsuite_setup(void)
1007 {
1008 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1009 	uint8_t dev_id = ts_params->valid_devs[0];
1010 	struct rte_cryptodev_info dev_info;
1011 	const enum rte_crypto_aead_algorithm aeads[] = {
1012 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1013 	};
1014 
1015 	rte_cryptodev_info_get(dev_id, &dev_info);
1016 
1017 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1018 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1019 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1020 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1021 				"Chacha20-Poly1305 testsuite not met\n");
1022 		return TEST_SKIPPED;
1023 	}
1024 
1025 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1026 		RTE_LOG(INFO, USER1, "Capability requirements for "
1027 				"Chacha20-Poly1305 testsuite not met\n");
1028 		return TEST_SKIPPED;
1029 	}
1030 
1031 	return 0;
1032 }
1033 
1034 static int
1035 snow3g_testsuite_setup(void)
1036 {
1037 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1038 	uint8_t dev_id = ts_params->valid_devs[0];
1039 	struct rte_cryptodev_info dev_info;
1040 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1041 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1042 
1043 	};
1044 	const enum rte_crypto_auth_algorithm auths[] = {
1045 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1046 	};
1047 
1048 	rte_cryptodev_info_get(dev_id, &dev_info);
1049 
1050 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1051 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1052 				"testsuite not met\n");
1053 		return TEST_SKIPPED;
1054 	}
1055 
1056 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1057 			&& check_auth_capabilities_supported(auths,
1058 			RTE_DIM(auths)) != 0) {
1059 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1060 				"testsuite not met\n");
1061 		return TEST_SKIPPED;
1062 	}
1063 
1064 	return 0;
1065 }
1066 
1067 static int
1068 zuc_testsuite_setup(void)
1069 {
1070 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1071 	uint8_t dev_id = ts_params->valid_devs[0];
1072 	struct rte_cryptodev_info dev_info;
1073 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1074 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1075 	};
1076 	const enum rte_crypto_auth_algorithm auths[] = {
1077 		RTE_CRYPTO_AUTH_ZUC_EIA3
1078 	};
1079 
1080 	rte_cryptodev_info_get(dev_id, &dev_info);
1081 
1082 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1083 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1084 				"testsuite not met\n");
1085 		return TEST_SKIPPED;
1086 	}
1087 
1088 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1089 			&& check_auth_capabilities_supported(auths,
1090 			RTE_DIM(auths)) != 0) {
1091 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1092 				"testsuite not met\n");
1093 		return TEST_SKIPPED;
1094 	}
1095 
1096 	return 0;
1097 }
1098 
1099 static int
1100 hmac_md5_auth_testsuite_setup(void)
1101 {
1102 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1103 	uint8_t dev_id = ts_params->valid_devs[0];
1104 	struct rte_cryptodev_info dev_info;
1105 	const enum rte_crypto_auth_algorithm auths[] = {
1106 		RTE_CRYPTO_AUTH_MD5_HMAC
1107 	};
1108 
1109 	rte_cryptodev_info_get(dev_id, &dev_info);
1110 
1111 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1112 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1113 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1114 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1115 				"Auth testsuite not met\n");
1116 		return TEST_SKIPPED;
1117 	}
1118 
1119 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1120 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1121 				"testsuite not met\n");
1122 		return TEST_SKIPPED;
1123 	}
1124 
1125 	return 0;
1126 }
1127 
1128 static int
1129 kasumi_testsuite_setup(void)
1130 {
1131 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1132 	uint8_t dev_id = ts_params->valid_devs[0];
1133 	struct rte_cryptodev_info dev_info;
1134 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1135 		RTE_CRYPTO_CIPHER_KASUMI_F8
1136 	};
1137 	const enum rte_crypto_auth_algorithm auths[] = {
1138 		RTE_CRYPTO_AUTH_KASUMI_F9
1139 	};
1140 
1141 	rte_cryptodev_info_get(dev_id, &dev_info);
1142 
1143 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1144 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1145 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1146 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1147 				"testsuite not met\n");
1148 		return TEST_SKIPPED;
1149 	}
1150 
1151 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1152 			&& check_auth_capabilities_supported(auths,
1153 			RTE_DIM(auths)) != 0) {
1154 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1155 				"testsuite not met\n");
1156 		return TEST_SKIPPED;
1157 	}
1158 
1159 	return 0;
1160 }
1161 
1162 static int
1163 negative_aes_gcm_testsuite_setup(void)
1164 {
1165 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1166 	uint8_t dev_id = ts_params->valid_devs[0];
1167 	struct rte_cryptodev_info dev_info;
1168 	const enum rte_crypto_aead_algorithm aeads[] = {
1169 		RTE_CRYPTO_AEAD_AES_GCM
1170 	};
1171 
1172 	rte_cryptodev_info_get(dev_id, &dev_info);
1173 
1174 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1175 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1176 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1177 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1178 				"AES GCM testsuite not met\n");
1179 		return TEST_SKIPPED;
1180 	}
1181 
1182 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1183 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1184 				"AES GCM testsuite not met\n");
1185 		return TEST_SKIPPED;
1186 	}
1187 
1188 	return 0;
1189 }
1190 
1191 static int
1192 negative_aes_gmac_testsuite_setup(void)
1193 {
1194 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1195 	uint8_t dev_id = ts_params->valid_devs[0];
1196 	struct rte_cryptodev_info dev_info;
1197 	const enum rte_crypto_auth_algorithm auths[] = {
1198 		RTE_CRYPTO_AUTH_AES_GMAC
1199 	};
1200 
1201 	rte_cryptodev_info_get(dev_id, &dev_info);
1202 
1203 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1204 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1205 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1206 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1207 				"AES GMAC testsuite not met\n");
1208 		return TEST_SKIPPED;
1209 	}
1210 
1211 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1212 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1213 				"AES GMAC testsuite not met\n");
1214 		return TEST_SKIPPED;
1215 	}
1216 
1217 	return 0;
1218 }
1219 
1220 static int
1221 mixed_cipher_hash_testsuite_setup(void)
1222 {
1223 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1224 	uint8_t dev_id = ts_params->valid_devs[0];
1225 	struct rte_cryptodev_info dev_info;
1226 	uint64_t feat_flags;
1227 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1228 		RTE_CRYPTO_CIPHER_NULL,
1229 		RTE_CRYPTO_CIPHER_AES_CTR,
1230 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1231 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1232 	};
1233 	const enum rte_crypto_auth_algorithm auths[] = {
1234 		RTE_CRYPTO_AUTH_NULL,
1235 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1236 		RTE_CRYPTO_AUTH_AES_CMAC,
1237 		RTE_CRYPTO_AUTH_ZUC_EIA3
1238 	};
1239 
1240 	rte_cryptodev_info_get(dev_id, &dev_info);
1241 	feat_flags = dev_info.feature_flags;
1242 
1243 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1244 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1245 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1246 				"Cipher Hash testsuite not met\n");
1247 		return TEST_SKIPPED;
1248 	}
1249 
1250 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1251 			&& check_auth_capabilities_supported(auths,
1252 			RTE_DIM(auths)) != 0) {
1253 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1254 				"Cipher Hash testsuite not met\n");
1255 		return TEST_SKIPPED;
1256 	}
1257 
1258 	return 0;
1259 }
1260 
1261 static int
1262 esn_testsuite_setup(void)
1263 {
1264 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1265 	uint8_t dev_id = ts_params->valid_devs[0];
1266 	struct rte_cryptodev_info dev_info;
1267 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1268 		RTE_CRYPTO_CIPHER_AES_CBC
1269 	};
1270 	const enum rte_crypto_auth_algorithm auths[] = {
1271 		RTE_CRYPTO_AUTH_SHA1_HMAC
1272 	};
1273 
1274 	rte_cryptodev_info_get(dev_id, &dev_info);
1275 
1276 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1277 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1278 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1279 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1280 				"testsuite not met\n");
1281 		return TEST_SKIPPED;
1282 	}
1283 
1284 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1285 			&& check_auth_capabilities_supported(auths,
1286 			RTE_DIM(auths)) != 0) {
1287 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1288 				"testsuite not met\n");
1289 		return TEST_SKIPPED;
1290 	}
1291 
1292 	return 0;
1293 }
1294 
1295 static int
1296 multi_session_testsuite_setup(void)
1297 {
1298 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1299 	uint8_t dev_id = ts_params->valid_devs[0];
1300 	struct rte_cryptodev_info dev_info;
1301 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1302 		RTE_CRYPTO_CIPHER_AES_CBC
1303 	};
1304 	const enum rte_crypto_auth_algorithm auths[] = {
1305 		RTE_CRYPTO_AUTH_SHA512_HMAC
1306 	};
1307 
1308 	rte_cryptodev_info_get(dev_id, &dev_info);
1309 
1310 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1311 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1312 				"Session testsuite not met\n");
1313 		return TEST_SKIPPED;
1314 	}
1315 
1316 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1317 			&& check_auth_capabilities_supported(auths,
1318 			RTE_DIM(auths)) != 0) {
1319 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1320 				"Session testsuite not met\n");
1321 		return TEST_SKIPPED;
1322 	}
1323 
1324 	return 0;
1325 }
1326 
1327 static int
1328 negative_hmac_sha1_testsuite_setup(void)
1329 {
1330 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1331 	uint8_t dev_id = ts_params->valid_devs[0];
1332 	struct rte_cryptodev_info dev_info;
1333 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1334 		RTE_CRYPTO_CIPHER_AES_CBC
1335 	};
1336 	const enum rte_crypto_auth_algorithm auths[] = {
1337 		RTE_CRYPTO_AUTH_SHA1_HMAC
1338 	};
1339 
1340 	rte_cryptodev_info_get(dev_id, &dev_info);
1341 
1342 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1343 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1344 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1345 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1346 				"HMAC SHA1 testsuite not met\n");
1347 		return TEST_SKIPPED;
1348 	}
1349 
1350 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1351 			&& check_auth_capabilities_supported(auths,
1352 			RTE_DIM(auths)) != 0) {
1353 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1354 				"HMAC SHA1 testsuite not met\n");
1355 		return TEST_SKIPPED;
1356 	}
1357 
1358 	return 0;
1359 }
1360 
1361 static int
1362 dev_configure_and_start(uint64_t ff_disable)
1363 {
1364 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1365 	struct crypto_unittest_params *ut_params = &unittest_params;
1366 
1367 	uint16_t qp_id;
1368 
1369 	/* Clear unit test parameters before running test */
1370 	memset(ut_params, 0, sizeof(*ut_params));
1371 
1372 	/* Reconfigure device to default parameters */
1373 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1374 	ts_params->conf.ff_disable = ff_disable;
1375 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1376 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1377 
1378 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1379 			&ts_params->conf),
1380 			"Failed to configure cryptodev %u",
1381 			ts_params->valid_devs[0]);
1382 
1383 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1384 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1385 			ts_params->valid_devs[0], qp_id,
1386 			&ts_params->qp_conf,
1387 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1388 			"Failed to setup queue pair %u on cryptodev %u",
1389 			qp_id, ts_params->valid_devs[0]);
1390 	}
1391 
1392 
1393 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1394 
1395 	/* Start the device */
1396 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1397 			"Failed to start cryptodev %u",
1398 			ts_params->valid_devs[0]);
1399 
1400 	return TEST_SUCCESS;
1401 }
1402 
1403 int
1404 ut_setup(void)
1405 {
1406 	/* Configure and start the device with security feature disabled */
1407 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1408 }
1409 
1410 static int
1411 ut_setup_security(void)
1412 {
1413 	/* Configure and start the device with no features disabled */
1414 	return dev_configure_and_start(0);
1415 }
1416 
1417 void
1418 ut_teardown(void)
1419 {
1420 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1421 	struct crypto_unittest_params *ut_params = &unittest_params;
1422 
1423 	/* free crypto session structure */
1424 #ifdef RTE_LIB_SECURITY
1425 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1426 		if (ut_params->sec_session) {
1427 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1428 						(ts_params->valid_devs[0]),
1429 						ut_params->sec_session);
1430 			ut_params->sec_session = NULL;
1431 		}
1432 	} else
1433 #endif
1434 	{
1435 		if (ut_params->sess) {
1436 			rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1437 					ut_params->sess);
1438 			ut_params->sess = NULL;
1439 		}
1440 	}
1441 
1442 	/* free crypto operation structure */
1443 	rte_crypto_op_free(ut_params->op);
1444 
1445 	/*
1446 	 * free mbuf - both obuf and ibuf are usually the same,
1447 	 * so check if they point at the same address is necessary,
1448 	 * to avoid freeing the mbuf twice.
1449 	 */
1450 	if (ut_params->obuf) {
1451 		rte_pktmbuf_free(ut_params->obuf);
1452 		if (ut_params->ibuf == ut_params->obuf)
1453 			ut_params->ibuf = 0;
1454 		ut_params->obuf = 0;
1455 	}
1456 	if (ut_params->ibuf) {
1457 		rte_pktmbuf_free(ut_params->ibuf);
1458 		ut_params->ibuf = 0;
1459 	}
1460 
1461 	if (ts_params->mbuf_pool != NULL)
1462 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1463 			rte_mempool_avail_count(ts_params->mbuf_pool));
1464 
1465 	/* Stop the device */
1466 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1467 }
1468 
1469 static int
1470 test_device_configure_invalid_dev_id(void)
1471 {
1472 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1473 	uint16_t dev_id, num_devs = 0;
1474 
1475 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1476 			"Need at least %d devices for test", 1);
1477 
1478 	/* valid dev_id values */
1479 	dev_id = ts_params->valid_devs[0];
1480 
1481 	/* Stop the device in case it's started so it can be configured */
1482 	rte_cryptodev_stop(dev_id);
1483 
1484 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1485 			"Failed test for rte_cryptodev_configure: "
1486 			"invalid dev_num %u", dev_id);
1487 
1488 	/* invalid dev_id values */
1489 	dev_id = num_devs;
1490 
1491 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1492 			"Failed test for rte_cryptodev_configure: "
1493 			"invalid dev_num %u", dev_id);
1494 
1495 	dev_id = 0xff;
1496 
1497 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1498 			"Failed test for rte_cryptodev_configure:"
1499 			"invalid dev_num %u", dev_id);
1500 
1501 	return TEST_SUCCESS;
1502 }
1503 
1504 static int
1505 test_device_configure_invalid_queue_pair_ids(void)
1506 {
1507 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1508 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1509 
1510 	/* Stop the device in case it's started so it can be configured */
1511 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1512 
1513 	/* valid - max value queue pairs */
1514 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1515 
1516 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1517 			&ts_params->conf),
1518 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1519 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1520 
1521 	/* valid - one queue pairs */
1522 	ts_params->conf.nb_queue_pairs = 1;
1523 
1524 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1525 			&ts_params->conf),
1526 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1527 			ts_params->valid_devs[0],
1528 			ts_params->conf.nb_queue_pairs);
1529 
1530 
1531 	/* invalid - zero queue pairs */
1532 	ts_params->conf.nb_queue_pairs = 0;
1533 
1534 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1535 			&ts_params->conf),
1536 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1537 			" invalid qps: %u",
1538 			ts_params->valid_devs[0],
1539 			ts_params->conf.nb_queue_pairs);
1540 
1541 
1542 	/* invalid - max value supported by field queue pairs */
1543 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1544 
1545 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1546 			&ts_params->conf),
1547 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1548 			" invalid qps: %u",
1549 			ts_params->valid_devs[0],
1550 			ts_params->conf.nb_queue_pairs);
1551 
1552 
1553 	/* invalid - max value + 1 queue pairs */
1554 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1555 
1556 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1557 			&ts_params->conf),
1558 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1559 			" invalid qps: %u",
1560 			ts_params->valid_devs[0],
1561 			ts_params->conf.nb_queue_pairs);
1562 
1563 	/* revert to original testsuite value */
1564 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1565 
1566 	return TEST_SUCCESS;
1567 }
1568 
1569 static int
1570 test_queue_pair_descriptor_setup(void)
1571 {
1572 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1573 	struct rte_cryptodev_qp_conf qp_conf = {
1574 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1575 	};
1576 	uint16_t qp_id;
1577 
1578 	/* Stop the device in case it's started so it can be configured */
1579 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1580 
1581 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1582 			&ts_params->conf),
1583 			"Failed to configure cryptodev %u",
1584 			ts_params->valid_devs[0]);
1585 
1586 	/*
1587 	 * Test various ring sizes on this device. memzones can't be
1588 	 * freed so are re-used if ring is released and re-created.
1589 	 */
1590 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1591 	qp_conf.mp_session = ts_params->session_mpool;
1592 
1593 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1594 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1595 				ts_params->valid_devs[0], qp_id, &qp_conf,
1596 				rte_cryptodev_socket_id(
1597 						ts_params->valid_devs[0])),
1598 				"Failed test for "
1599 				"rte_cryptodev_queue_pair_setup: num_inflights "
1600 				"%u on qp %u on cryptodev %u",
1601 				qp_conf.nb_descriptors, qp_id,
1602 				ts_params->valid_devs[0]);
1603 	}
1604 
1605 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1606 
1607 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1608 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1609 				ts_params->valid_devs[0], qp_id, &qp_conf,
1610 				rte_cryptodev_socket_id(
1611 						ts_params->valid_devs[0])),
1612 				"Failed test for"
1613 				" rte_cryptodev_queue_pair_setup: num_inflights"
1614 				" %u on qp %u on cryptodev %u",
1615 				qp_conf.nb_descriptors, qp_id,
1616 				ts_params->valid_devs[0]);
1617 	}
1618 
1619 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1620 
1621 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1622 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1623 				ts_params->valid_devs[0], qp_id, &qp_conf,
1624 				rte_cryptodev_socket_id(
1625 						ts_params->valid_devs[0])),
1626 				"Failed test for "
1627 				"rte_cryptodev_queue_pair_setup: num_inflights"
1628 				" %u on qp %u on cryptodev %u",
1629 				qp_conf.nb_descriptors, qp_id,
1630 				ts_params->valid_devs[0]);
1631 	}
1632 
1633 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1634 
1635 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1636 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1637 				ts_params->valid_devs[0], qp_id, &qp_conf,
1638 				rte_cryptodev_socket_id(
1639 						ts_params->valid_devs[0])),
1640 				"Failed test for"
1641 				" rte_cryptodev_queue_pair_setup:"
1642 				"num_inflights %u on qp %u on cryptodev %u",
1643 				qp_conf.nb_descriptors, qp_id,
1644 				ts_params->valid_devs[0]);
1645 	}
1646 
1647 	/* test invalid queue pair id */
1648 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1649 
1650 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1651 
1652 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1653 			ts_params->valid_devs[0],
1654 			qp_id, &qp_conf,
1655 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1656 			"Failed test for rte_cryptodev_queue_pair_setup:"
1657 			"invalid qp %u on cryptodev %u",
1658 			qp_id, ts_params->valid_devs[0]);
1659 
1660 	qp_id = 0xffff; /*invalid*/
1661 
1662 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1663 			ts_params->valid_devs[0],
1664 			qp_id, &qp_conf,
1665 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1666 			"Failed test for rte_cryptodev_queue_pair_setup:"
1667 			"invalid qp %u on cryptodev %u",
1668 			qp_id, ts_params->valid_devs[0]);
1669 
1670 	return TEST_SUCCESS;
1671 }
1672 
1673 /* ***** Plaintext data for tests ***** */
1674 
1675 const char catch_22_quote_1[] =
1676 		"There was only one catch and that was Catch-22, which "
1677 		"specified that a concern for one's safety in the face of "
1678 		"dangers that were real and immediate was the process of a "
1679 		"rational mind. Orr was crazy and could be grounded. All he "
1680 		"had to do was ask; and as soon as he did, he would no longer "
1681 		"be crazy and would have to fly more missions. Orr would be "
1682 		"crazy to fly more missions and sane if he didn't, but if he "
1683 		"was sane he had to fly them. If he flew them he was crazy "
1684 		"and didn't have to; but if he didn't want to he was sane and "
1685 		"had to. Yossarian was moved very deeply by the absolute "
1686 		"simplicity of this clause of Catch-22 and let out a "
1687 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1688 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1689 
1690 const char catch_22_quote[] =
1691 		"What a lousy earth! He wondered how many people were "
1692 		"destitute that same night even in his own prosperous country, "
1693 		"how many homes were shanties, how many husbands were drunk "
1694 		"and wives socked, and how many children were bullied, abused, "
1695 		"or abandoned. How many families hungered for food they could "
1696 		"not afford to buy? How many hearts were broken? How many "
1697 		"suicides would take place that same night, how many people "
1698 		"would go insane? How many cockroaches and landlords would "
1699 		"triumph? How many winners were losers, successes failures, "
1700 		"and rich men poor men? How many wise guys were stupid? How "
1701 		"many happy endings were unhappy endings? How many honest men "
1702 		"were liars, brave men cowards, loyal men traitors, how many "
1703 		"sainted men were corrupt, how many people in positions of "
1704 		"trust had sold their souls to bodyguards, how many had never "
1705 		"had souls? How many straight-and-narrow paths were crooked "
1706 		"paths? How many best families were worst families and how "
1707 		"many good people were bad people? When you added them all up "
1708 		"and then subtracted, you might be left with only the children, "
1709 		"and perhaps with Albert Einstein and an old violinist or "
1710 		"sculptor somewhere.";
1711 
1712 #define QUOTE_480_BYTES		(480)
1713 #define QUOTE_512_BYTES		(512)
1714 #define QUOTE_768_BYTES		(768)
1715 #define QUOTE_1024_BYTES	(1024)
1716 
1717 
1718 
1719 /* ***** SHA1 Hash Tests ***** */
1720 
1721 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1722 
1723 static uint8_t hmac_sha1_key[] = {
1724 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1725 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1726 	0xDE, 0xF4, 0xDE, 0xAD };
1727 
1728 /* ***** SHA224 Hash Tests ***** */
1729 
1730 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
1731 
1732 
1733 /* ***** AES-CBC Cipher Tests ***** */
1734 
1735 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
1736 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
1737 
1738 static uint8_t aes_cbc_key[] = {
1739 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1740 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1741 
1742 static uint8_t aes_cbc_iv[] = {
1743 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1744 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1745 
1746 
1747 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1748 
1749 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1750 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1751 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1752 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1753 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1754 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1755 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1756 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1757 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1758 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1759 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1760 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1761 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1762 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1763 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1764 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1765 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1766 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1767 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1768 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1769 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1770 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1771 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1772 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1773 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1774 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1775 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1776 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1777 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1778 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1779 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1780 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1781 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1782 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1783 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1784 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1785 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1786 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1787 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1788 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1789 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1790 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1791 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1792 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1793 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1794 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1795 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1796 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1797 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1798 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1799 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1800 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1801 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1802 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1803 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1804 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1805 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1806 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1807 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1808 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1809 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1810 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1811 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1812 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1813 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1814 };
1815 
1816 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1817 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1818 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1819 	0x18, 0x8c, 0x1d, 0x32
1820 };
1821 
1822 
1823 /* Multisession Vector context Test */
1824 /*Begin Session 0 */
1825 static uint8_t ms_aes_cbc_key0[] = {
1826 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1827 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1828 };
1829 
1830 static uint8_t ms_aes_cbc_iv0[] = {
1831 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1832 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1833 };
1834 
1835 static const uint8_t ms_aes_cbc_cipher0[] = {
1836 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1837 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1838 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1839 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1840 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1841 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1842 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1843 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1844 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1845 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1846 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1847 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1848 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1849 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1850 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1851 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1852 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1853 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1854 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1855 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1856 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1857 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1858 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1859 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1860 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1861 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1862 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1863 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1864 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1865 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1866 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1867 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1868 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1869 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1870 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1871 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1872 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1873 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1874 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1875 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1876 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1877 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1878 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1879 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1880 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1881 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1882 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1883 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1884 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1885 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1886 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1887 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1888 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1889 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1890 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1891 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1892 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1893 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1894 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1895 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1896 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1897 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1898 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1899 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1900 };
1901 
1902 
1903 static  uint8_t ms_hmac_key0[] = {
1904 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1905 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1906 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1907 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1908 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1909 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1910 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1911 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1912 };
1913 
1914 static const uint8_t ms_hmac_digest0[] = {
1915 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1916 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1917 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1918 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1919 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1920 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1921 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1922 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1923 		};
1924 
1925 /* End Session 0 */
1926 /* Begin session 1 */
1927 
1928 static  uint8_t ms_aes_cbc_key1[] = {
1929 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1930 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1931 };
1932 
1933 static  uint8_t ms_aes_cbc_iv1[] = {
1934 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1935 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1936 };
1937 
1938 static const uint8_t ms_aes_cbc_cipher1[] = {
1939 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1940 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1941 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1942 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1943 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1944 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1945 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1946 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1947 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1948 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1949 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1950 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1951 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1952 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1953 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1954 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1955 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1956 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1957 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1958 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1959 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1960 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1961 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1962 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1963 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1964 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1965 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1966 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1967 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1968 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1969 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1970 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1971 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1972 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1973 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1974 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1975 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1976 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1977 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1978 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1979 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1980 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1981 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1982 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1983 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1984 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1985 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1986 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1987 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1988 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1989 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1990 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1991 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1992 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1993 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1994 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1995 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1996 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1997 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1998 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1999 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2000 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2001 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2002 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2003 
2004 };
2005 
2006 static uint8_t ms_hmac_key1[] = {
2007 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2008 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2009 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2010 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2011 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2012 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2013 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2014 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2015 };
2016 
2017 static const uint8_t ms_hmac_digest1[] = {
2018 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2019 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2020 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2021 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2022 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2023 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2024 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2025 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2026 };
2027 /* End Session 1  */
2028 /* Begin Session 2 */
2029 static  uint8_t ms_aes_cbc_key2[] = {
2030 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2031 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2032 };
2033 
2034 static  uint8_t ms_aes_cbc_iv2[] = {
2035 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2036 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2037 };
2038 
2039 static const uint8_t ms_aes_cbc_cipher2[] = {
2040 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2041 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2042 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2043 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2044 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2045 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2046 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2047 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2048 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2049 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2050 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2051 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2052 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2053 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2054 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2055 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2056 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2057 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2058 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2059 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2060 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2061 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2062 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2063 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2064 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2065 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2066 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2067 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2068 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2069 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2070 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2071 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2072 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2073 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2074 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2075 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2076 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2077 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2078 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2079 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2080 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2081 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2082 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2083 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2084 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2085 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2086 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2087 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2088 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2089 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2090 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2091 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2092 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2093 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2094 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2095 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2096 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2097 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2098 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2099 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2100 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2101 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2102 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2103 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2104 };
2105 
2106 static  uint8_t ms_hmac_key2[] = {
2107 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2108 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2109 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2110 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2111 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2112 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2113 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2114 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2115 };
2116 
2117 static const uint8_t ms_hmac_digest2[] = {
2118 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2119 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2120 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2121 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2122 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2123 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2124 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2125 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2126 };
2127 
2128 /* End Session 2 */
2129 
2130 
2131 static int
2132 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2133 {
2134 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2135 	struct crypto_unittest_params *ut_params = &unittest_params;
2136 	/* Verify the capabilities */
2137 	struct rte_cryptodev_sym_capability_idx cap_idx;
2138 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2139 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2140 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2141 			&cap_idx) == NULL)
2142 		return TEST_SKIPPED;
2143 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2144 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2145 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2146 			&cap_idx) == NULL)
2147 		return TEST_SKIPPED;
2148 
2149 	/* Generate test mbuf data and space for digest */
2150 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2151 			catch_22_quote,	QUOTE_512_BYTES, 0);
2152 
2153 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2154 			DIGEST_BYTE_LENGTH_SHA1);
2155 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2156 
2157 	/* Setup Cipher Parameters */
2158 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2159 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2160 
2161 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2162 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2163 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2164 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2165 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2166 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2167 
2168 	/* Setup HMAC Parameters */
2169 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2170 
2171 	ut_params->auth_xform.next = NULL;
2172 
2173 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2174 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2175 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2176 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2177 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2178 
2179 	rte_errno = 0;
2180 	ut_params->sess = rte_cryptodev_sym_session_create(
2181 			ts_params->valid_devs[0], &ut_params->cipher_xform,
2182 			ts_params->session_mpool);
2183 	if (rte_errno == ENOTSUP)
2184 		return TEST_SKIPPED;
2185 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2186 
2187 	/* Generate crypto op data structure */
2188 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2189 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2190 	TEST_ASSERT_NOT_NULL(ut_params->op,
2191 			"Failed to allocate symmetric crypto operation struct");
2192 
2193 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2194 
2195 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2196 
2197 	/* set crypto operation source mbuf */
2198 	sym_op->m_src = ut_params->ibuf;
2199 
2200 	/* Set crypto operation authentication parameters */
2201 	sym_op->auth.digest.data = ut_params->digest;
2202 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2203 			ut_params->ibuf, QUOTE_512_BYTES);
2204 
2205 	sym_op->auth.data.offset = 0;
2206 	sym_op->auth.data.length = QUOTE_512_BYTES;
2207 
2208 	/* Copy IV at the end of the crypto operation */
2209 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2210 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2211 
2212 	/* Set crypto operation cipher parameters */
2213 	sym_op->cipher.data.offset = 0;
2214 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2215 
2216 	/* Process crypto operation */
2217 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2218 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2219 			ut_params->op);
2220 	else
2221 		TEST_ASSERT_NOT_NULL(
2222 			process_crypto_request(ts_params->valid_devs[0],
2223 				ut_params->op),
2224 				"failed to process sym crypto op");
2225 
2226 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2227 			"crypto op processing failed");
2228 
2229 	/* Validate obuf */
2230 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2231 			uint8_t *);
2232 
2233 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2234 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2235 			QUOTE_512_BYTES,
2236 			"ciphertext data not as expected");
2237 
2238 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2239 
2240 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2241 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2242 			gbl_driver_id == rte_cryptodev_driver_id_get(
2243 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2244 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2245 					DIGEST_BYTE_LENGTH_SHA1,
2246 			"Generated digest data not as expected");
2247 
2248 	return TEST_SUCCESS;
2249 }
2250 
2251 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2252 
2253 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2254 
2255 static uint8_t hmac_sha512_key[] = {
2256 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2257 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2258 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2259 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2260 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2261 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2262 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2263 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2264 
2265 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2266 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2267 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2268 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2269 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2270 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2271 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2272 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2273 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2274 
2275 
2276 
2277 static int
2278 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2279 		struct crypto_unittest_params *ut_params,
2280 		uint8_t *cipher_key,
2281 		uint8_t *hmac_key);
2282 
2283 static int
2284 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2285 		struct crypto_unittest_params *ut_params,
2286 		struct crypto_testsuite_params *ts_params,
2287 		const uint8_t *cipher,
2288 		const uint8_t *digest,
2289 		const uint8_t *iv);
2290 
2291 
2292 static int
2293 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2294 		struct crypto_unittest_params *ut_params,
2295 		uint8_t *cipher_key,
2296 		uint8_t *hmac_key)
2297 {
2298 
2299 	/* Setup Cipher Parameters */
2300 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2301 	ut_params->cipher_xform.next = NULL;
2302 
2303 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2304 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2305 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2306 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2307 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2308 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2309 
2310 	/* Setup HMAC Parameters */
2311 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2312 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2313 
2314 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2315 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2316 	ut_params->auth_xform.auth.key.data = hmac_key;
2317 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2318 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2319 
2320 	return TEST_SUCCESS;
2321 }
2322 
2323 
2324 static int
2325 test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2326 		struct crypto_unittest_params *ut_params,
2327 		struct crypto_testsuite_params *ts_params,
2328 		const uint8_t *cipher,
2329 		const uint8_t *digest,
2330 		const uint8_t *iv)
2331 {
2332 	/* Generate test mbuf data and digest */
2333 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2334 			(const char *)
2335 			cipher,
2336 			QUOTE_512_BYTES, 0);
2337 
2338 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2339 			DIGEST_BYTE_LENGTH_SHA512);
2340 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2341 
2342 	rte_memcpy(ut_params->digest,
2343 			digest,
2344 			DIGEST_BYTE_LENGTH_SHA512);
2345 
2346 	/* Generate Crypto op data structure */
2347 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2348 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2349 	TEST_ASSERT_NOT_NULL(ut_params->op,
2350 			"Failed to allocate symmetric crypto operation struct");
2351 
2352 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2353 
2354 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2355 
2356 	/* set crypto operation source mbuf */
2357 	sym_op->m_src = ut_params->ibuf;
2358 
2359 	sym_op->auth.digest.data = ut_params->digest;
2360 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2361 			ut_params->ibuf, QUOTE_512_BYTES);
2362 
2363 	sym_op->auth.data.offset = 0;
2364 	sym_op->auth.data.length = QUOTE_512_BYTES;
2365 
2366 	/* Copy IV at the end of the crypto operation */
2367 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2368 			iv, CIPHER_IV_LENGTH_AES_CBC);
2369 
2370 	sym_op->cipher.data.offset = 0;
2371 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2372 
2373 	/* Process crypto operation */
2374 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2375 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2376 			ut_params->op);
2377 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2378 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2379 				ut_params->op, 1, 1, 0, 0);
2380 	else
2381 		TEST_ASSERT_NOT_NULL(
2382 				process_crypto_request(ts_params->valid_devs[0],
2383 					ut_params->op),
2384 					"failed to process sym crypto op");
2385 
2386 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2387 			"crypto op processing failed");
2388 
2389 	ut_params->obuf = ut_params->op->sym->m_src;
2390 
2391 	/* Validate obuf */
2392 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2393 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2394 			catch_22_quote,
2395 			QUOTE_512_BYTES,
2396 			"Plaintext data not as expected");
2397 
2398 	/* Validate obuf */
2399 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2400 			"Digest verification failed");
2401 
2402 	return TEST_SUCCESS;
2403 }
2404 
2405 /* ***** SNOW 3G Tests ***** */
2406 static int
2407 create_wireless_algo_hash_session(uint8_t dev_id,
2408 	const uint8_t *key, const uint8_t key_len,
2409 	const uint8_t iv_len, const uint8_t auth_len,
2410 	enum rte_crypto_auth_operation op,
2411 	enum rte_crypto_auth_algorithm algo)
2412 {
2413 	uint8_t hash_key[key_len];
2414 
2415 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2416 	struct crypto_unittest_params *ut_params = &unittest_params;
2417 
2418 	memcpy(hash_key, key, key_len);
2419 
2420 	debug_hexdump(stdout, "key:", key, key_len);
2421 
2422 	/* Setup Authentication Parameters */
2423 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2424 	ut_params->auth_xform.next = NULL;
2425 
2426 	ut_params->auth_xform.auth.op = op;
2427 	ut_params->auth_xform.auth.algo = algo;
2428 	ut_params->auth_xform.auth.key.length = key_len;
2429 	ut_params->auth_xform.auth.key.data = hash_key;
2430 	ut_params->auth_xform.auth.digest_length = auth_len;
2431 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2432 	ut_params->auth_xform.auth.iv.length = iv_len;
2433 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2434 			&ut_params->auth_xform, ts_params->session_mpool);
2435 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2436 		return TEST_SKIPPED;
2437 
2438 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2439 	return 0;
2440 }
2441 
2442 static int
2443 create_wireless_algo_cipher_session(uint8_t dev_id,
2444 			enum rte_crypto_cipher_operation op,
2445 			enum rte_crypto_cipher_algorithm algo,
2446 			const uint8_t *key, const uint8_t key_len,
2447 			uint8_t iv_len)
2448 {
2449 	uint8_t cipher_key[key_len];
2450 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2451 	struct crypto_unittest_params *ut_params = &unittest_params;
2452 
2453 	memcpy(cipher_key, key, key_len);
2454 
2455 	/* Setup Cipher Parameters */
2456 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2457 	ut_params->cipher_xform.next = NULL;
2458 
2459 	ut_params->cipher_xform.cipher.algo = algo;
2460 	ut_params->cipher_xform.cipher.op = op;
2461 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2462 	ut_params->cipher_xform.cipher.key.length = key_len;
2463 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2464 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2465 
2466 	debug_hexdump(stdout, "key:", key, key_len);
2467 
2468 	/* Create Crypto session */
2469 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2470 			&ut_params->cipher_xform, ts_params->session_mpool);
2471 
2472 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2473 		return TEST_SKIPPED;
2474 
2475 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2476 	return 0;
2477 }
2478 
2479 static int
2480 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2481 			unsigned int cipher_len,
2482 			unsigned int cipher_offset)
2483 {
2484 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2485 	struct crypto_unittest_params *ut_params = &unittest_params;
2486 
2487 	/* Generate Crypto op data structure */
2488 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2489 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2490 	TEST_ASSERT_NOT_NULL(ut_params->op,
2491 				"Failed to allocate pktmbuf offload");
2492 
2493 	/* Set crypto operation data parameters */
2494 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2495 
2496 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2497 
2498 	/* set crypto operation source mbuf */
2499 	sym_op->m_src = ut_params->ibuf;
2500 
2501 	/* iv */
2502 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2503 			iv, iv_len);
2504 	sym_op->cipher.data.length = cipher_len;
2505 	sym_op->cipher.data.offset = cipher_offset;
2506 	return 0;
2507 }
2508 
2509 static int
2510 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2511 			unsigned int cipher_len,
2512 			unsigned int cipher_offset)
2513 {
2514 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2515 	struct crypto_unittest_params *ut_params = &unittest_params;
2516 
2517 	/* Generate Crypto op data structure */
2518 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2519 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2520 	TEST_ASSERT_NOT_NULL(ut_params->op,
2521 				"Failed to allocate pktmbuf offload");
2522 
2523 	/* Set crypto operation data parameters */
2524 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2525 
2526 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2527 
2528 	/* set crypto operation source mbuf */
2529 	sym_op->m_src = ut_params->ibuf;
2530 	sym_op->m_dst = ut_params->obuf;
2531 
2532 	/* iv */
2533 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2534 			iv, iv_len);
2535 	sym_op->cipher.data.length = cipher_len;
2536 	sym_op->cipher.data.offset = cipher_offset;
2537 	return 0;
2538 }
2539 
2540 static int
2541 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2542 		enum rte_crypto_cipher_operation cipher_op,
2543 		enum rte_crypto_auth_operation auth_op,
2544 		enum rte_crypto_auth_algorithm auth_algo,
2545 		enum rte_crypto_cipher_algorithm cipher_algo,
2546 		const uint8_t *key, uint8_t key_len,
2547 		uint8_t auth_iv_len, uint8_t auth_len,
2548 		uint8_t cipher_iv_len)
2549 
2550 {
2551 	uint8_t cipher_auth_key[key_len];
2552 
2553 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2554 	struct crypto_unittest_params *ut_params = &unittest_params;
2555 
2556 	memcpy(cipher_auth_key, key, key_len);
2557 
2558 	/* Setup Authentication Parameters */
2559 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2560 	ut_params->auth_xform.next = NULL;
2561 
2562 	ut_params->auth_xform.auth.op = auth_op;
2563 	ut_params->auth_xform.auth.algo = auth_algo;
2564 	ut_params->auth_xform.auth.key.length = key_len;
2565 	/* Hash key = cipher key */
2566 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2567 	ut_params->auth_xform.auth.digest_length = auth_len;
2568 	/* Auth IV will be after cipher IV */
2569 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2570 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2571 
2572 	/* Setup Cipher Parameters */
2573 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2574 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2575 
2576 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2577 	ut_params->cipher_xform.cipher.op = cipher_op;
2578 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2579 	ut_params->cipher_xform.cipher.key.length = key_len;
2580 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2581 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2582 
2583 	debug_hexdump(stdout, "key:", key, key_len);
2584 
2585 	/* Create Crypto session*/
2586 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2587 			&ut_params->cipher_xform, ts_params->session_mpool);
2588 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2589 		return TEST_SKIPPED;
2590 
2591 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2592 	return 0;
2593 }
2594 
2595 static int
2596 create_wireless_cipher_auth_session(uint8_t dev_id,
2597 		enum rte_crypto_cipher_operation cipher_op,
2598 		enum rte_crypto_auth_operation auth_op,
2599 		enum rte_crypto_auth_algorithm auth_algo,
2600 		enum rte_crypto_cipher_algorithm cipher_algo,
2601 		const struct wireless_test_data *tdata)
2602 {
2603 	const uint8_t key_len = tdata->key.len;
2604 	uint8_t cipher_auth_key[key_len];
2605 
2606 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2607 	struct crypto_unittest_params *ut_params = &unittest_params;
2608 	const uint8_t *key = tdata->key.data;
2609 	const uint8_t auth_len = tdata->digest.len;
2610 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2611 	uint8_t auth_iv_len = tdata->auth_iv.len;
2612 
2613 	memcpy(cipher_auth_key, key, key_len);
2614 
2615 	/* Setup Authentication Parameters */
2616 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2617 	ut_params->auth_xform.next = NULL;
2618 
2619 	ut_params->auth_xform.auth.op = auth_op;
2620 	ut_params->auth_xform.auth.algo = auth_algo;
2621 	ut_params->auth_xform.auth.key.length = key_len;
2622 	/* Hash key = cipher key */
2623 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2624 	ut_params->auth_xform.auth.digest_length = auth_len;
2625 	/* Auth IV will be after cipher IV */
2626 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2627 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2628 
2629 	/* Setup Cipher Parameters */
2630 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2631 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2632 
2633 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2634 	ut_params->cipher_xform.cipher.op = cipher_op;
2635 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2636 	ut_params->cipher_xform.cipher.key.length = key_len;
2637 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2638 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2639 
2640 
2641 	debug_hexdump(stdout, "key:", key, key_len);
2642 
2643 	/* Create Crypto session*/
2644 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2645 			&ut_params->cipher_xform, ts_params->session_mpool);
2646 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2647 		return TEST_SKIPPED;
2648 
2649 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2650 	return 0;
2651 }
2652 
2653 static int
2654 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2655 		const struct wireless_test_data *tdata)
2656 {
2657 	return create_wireless_cipher_auth_session(dev_id,
2658 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2659 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2660 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2661 }
2662 
2663 static int
2664 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2665 		enum rte_crypto_cipher_operation cipher_op,
2666 		enum rte_crypto_auth_operation auth_op,
2667 		enum rte_crypto_auth_algorithm auth_algo,
2668 		enum rte_crypto_cipher_algorithm cipher_algo,
2669 		const uint8_t *key, const uint8_t key_len,
2670 		uint8_t auth_iv_len, uint8_t auth_len,
2671 		uint8_t cipher_iv_len)
2672 {
2673 	uint8_t auth_cipher_key[key_len];
2674 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2675 	struct crypto_unittest_params *ut_params = &unittest_params;
2676 
2677 	memcpy(auth_cipher_key, key, key_len);
2678 
2679 	/* Setup Authentication Parameters */
2680 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2681 	ut_params->auth_xform.auth.op = auth_op;
2682 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2683 	ut_params->auth_xform.auth.algo = auth_algo;
2684 	ut_params->auth_xform.auth.key.length = key_len;
2685 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
2686 	ut_params->auth_xform.auth.digest_length = auth_len;
2687 	/* Auth IV will be after cipher IV */
2688 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2689 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2690 
2691 	/* Setup Cipher Parameters */
2692 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2693 	ut_params->cipher_xform.next = NULL;
2694 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2695 	ut_params->cipher_xform.cipher.op = cipher_op;
2696 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2697 	ut_params->cipher_xform.cipher.key.length = key_len;
2698 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2699 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2700 
2701 	debug_hexdump(stdout, "key:", key, key_len);
2702 
2703 	/* Create Crypto session*/
2704 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2705 		ut_params->auth_xform.next = NULL;
2706 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2707 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2708 			&ut_params->cipher_xform, ts_params->session_mpool);
2709 	} else
2710 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2711 			&ut_params->auth_xform, ts_params->session_mpool);
2712 
2713 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2714 		return TEST_SKIPPED;
2715 
2716 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2717 
2718 	return 0;
2719 }
2720 
2721 static int
2722 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2723 		unsigned int auth_tag_len,
2724 		const uint8_t *iv, unsigned int iv_len,
2725 		unsigned int data_pad_len,
2726 		enum rte_crypto_auth_operation op,
2727 		unsigned int auth_len, unsigned int auth_offset)
2728 {
2729 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2730 
2731 	struct crypto_unittest_params *ut_params = &unittest_params;
2732 
2733 	/* Generate Crypto op data structure */
2734 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2735 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2736 	TEST_ASSERT_NOT_NULL(ut_params->op,
2737 		"Failed to allocate pktmbuf offload");
2738 
2739 	/* Set crypto operation data parameters */
2740 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2741 
2742 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2743 
2744 	/* set crypto operation source mbuf */
2745 	sym_op->m_src = ut_params->ibuf;
2746 
2747 	/* iv */
2748 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2749 			iv, iv_len);
2750 	/* digest */
2751 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2752 					ut_params->ibuf, auth_tag_len);
2753 
2754 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2755 				"no room to append auth tag");
2756 	ut_params->digest = sym_op->auth.digest.data;
2757 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2758 			ut_params->ibuf, data_pad_len);
2759 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2760 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2761 	else
2762 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2763 
2764 	debug_hexdump(stdout, "digest:",
2765 		sym_op->auth.digest.data,
2766 		auth_tag_len);
2767 
2768 	sym_op->auth.data.length = auth_len;
2769 	sym_op->auth.data.offset = auth_offset;
2770 
2771 	return 0;
2772 }
2773 
2774 static int
2775 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2776 	enum rte_crypto_auth_operation op)
2777 {
2778 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2779 	struct crypto_unittest_params *ut_params = &unittest_params;
2780 
2781 	const uint8_t *auth_tag = tdata->digest.data;
2782 	const unsigned int auth_tag_len = tdata->digest.len;
2783 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2784 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2785 
2786 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2787 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2788 	const uint8_t *auth_iv = tdata->auth_iv.data;
2789 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2790 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2791 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2792 
2793 	/* Generate Crypto op data structure */
2794 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2795 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2796 	TEST_ASSERT_NOT_NULL(ut_params->op,
2797 			"Failed to allocate pktmbuf offload");
2798 	/* Set crypto operation data parameters */
2799 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2800 
2801 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2802 
2803 	/* set crypto operation source mbuf */
2804 	sym_op->m_src = ut_params->ibuf;
2805 
2806 	/* digest */
2807 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2808 			ut_params->ibuf, auth_tag_len);
2809 
2810 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2811 			"no room to append auth tag");
2812 	ut_params->digest = sym_op->auth.digest.data;
2813 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2814 			ut_params->ibuf, data_pad_len);
2815 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2816 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2817 	else
2818 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2819 
2820 	debug_hexdump(stdout, "digest:",
2821 		sym_op->auth.digest.data,
2822 		auth_tag_len);
2823 
2824 	/* Copy cipher and auth IVs at the end of the crypto operation */
2825 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2826 						IV_OFFSET);
2827 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2828 	iv_ptr += cipher_iv_len;
2829 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2830 
2831 	sym_op->cipher.data.length = cipher_len;
2832 	sym_op->cipher.data.offset = 0;
2833 	sym_op->auth.data.length = auth_len;
2834 	sym_op->auth.data.offset = 0;
2835 
2836 	return 0;
2837 }
2838 
2839 static int
2840 create_zuc_cipher_hash_generate_operation(
2841 		const struct wireless_test_data *tdata)
2842 {
2843 	return create_wireless_cipher_hash_operation(tdata,
2844 		RTE_CRYPTO_AUTH_OP_GENERATE);
2845 }
2846 
2847 static int
2848 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2849 		const unsigned auth_tag_len,
2850 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2851 		unsigned data_pad_len,
2852 		enum rte_crypto_auth_operation op,
2853 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2854 		const unsigned cipher_len, const unsigned cipher_offset,
2855 		const unsigned auth_len, const unsigned auth_offset)
2856 {
2857 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2858 	struct crypto_unittest_params *ut_params = &unittest_params;
2859 
2860 	enum rte_crypto_cipher_algorithm cipher_algo =
2861 			ut_params->cipher_xform.cipher.algo;
2862 	enum rte_crypto_auth_algorithm auth_algo =
2863 			ut_params->auth_xform.auth.algo;
2864 
2865 	/* Generate Crypto op data structure */
2866 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2867 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2868 	TEST_ASSERT_NOT_NULL(ut_params->op,
2869 			"Failed to allocate pktmbuf offload");
2870 	/* Set crypto operation data parameters */
2871 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2872 
2873 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2874 
2875 	/* set crypto operation source mbuf */
2876 	sym_op->m_src = ut_params->ibuf;
2877 
2878 	/* digest */
2879 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2880 			ut_params->ibuf, auth_tag_len);
2881 
2882 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2883 			"no room to append auth tag");
2884 	ut_params->digest = sym_op->auth.digest.data;
2885 
2886 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2887 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2888 				ut_params->ibuf, data_pad_len);
2889 	} else {
2890 		struct rte_mbuf *m = ut_params->ibuf;
2891 		unsigned int offset = data_pad_len;
2892 
2893 		while (offset > m->data_len && m->next != NULL) {
2894 			offset -= m->data_len;
2895 			m = m->next;
2896 		}
2897 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2898 			m, offset);
2899 	}
2900 
2901 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2902 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2903 	else
2904 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2905 
2906 	debug_hexdump(stdout, "digest:",
2907 		sym_op->auth.digest.data,
2908 		auth_tag_len);
2909 
2910 	/* Copy cipher and auth IVs at the end of the crypto operation */
2911 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2912 						IV_OFFSET);
2913 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2914 	iv_ptr += cipher_iv_len;
2915 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2916 
2917 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2918 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2919 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2920 		sym_op->cipher.data.length = cipher_len;
2921 		sym_op->cipher.data.offset = cipher_offset;
2922 	} else {
2923 		sym_op->cipher.data.length = cipher_len >> 3;
2924 		sym_op->cipher.data.offset = cipher_offset >> 3;
2925 	}
2926 
2927 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2928 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2929 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2930 		sym_op->auth.data.length = auth_len;
2931 		sym_op->auth.data.offset = auth_offset;
2932 	} else {
2933 		sym_op->auth.data.length = auth_len >> 3;
2934 		sym_op->auth.data.offset = auth_offset >> 3;
2935 	}
2936 
2937 	return 0;
2938 }
2939 
2940 static int
2941 create_wireless_algo_auth_cipher_operation(
2942 		const uint8_t *auth_tag, unsigned int auth_tag_len,
2943 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2944 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2945 		unsigned int data_pad_len,
2946 		unsigned int cipher_len, unsigned int cipher_offset,
2947 		unsigned int auth_len, unsigned int auth_offset,
2948 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2949 {
2950 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2951 	struct crypto_unittest_params *ut_params = &unittest_params;
2952 
2953 	enum rte_crypto_cipher_algorithm cipher_algo =
2954 			ut_params->cipher_xform.cipher.algo;
2955 	enum rte_crypto_auth_algorithm auth_algo =
2956 			ut_params->auth_xform.auth.algo;
2957 
2958 	/* Generate Crypto op data structure */
2959 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2960 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2961 	TEST_ASSERT_NOT_NULL(ut_params->op,
2962 			"Failed to allocate pktmbuf offload");
2963 
2964 	/* Set crypto operation data parameters */
2965 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2966 
2967 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2968 
2969 	/* set crypto operation mbufs */
2970 	sym_op->m_src = ut_params->ibuf;
2971 	if (op_mode == OUT_OF_PLACE)
2972 		sym_op->m_dst = ut_params->obuf;
2973 
2974 	/* digest */
2975 	if (!do_sgl) {
2976 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2977 			(op_mode == IN_PLACE ?
2978 				ut_params->ibuf : ut_params->obuf),
2979 			uint8_t *, data_pad_len);
2980 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2981 			(op_mode == IN_PLACE ?
2982 				ut_params->ibuf : ut_params->obuf),
2983 			data_pad_len);
2984 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2985 	} else {
2986 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2987 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2988 				sym_op->m_src : sym_op->m_dst);
2989 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2990 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2991 			sgl_buf = sgl_buf->next;
2992 		}
2993 
2994 		/* The last segment should be large enough to hold full digest */
2995 		if (sgl_buf->data_len < auth_tag_len) {
2996 			rte_pktmbuf_free(sgl_buf->next);
2997 			sgl_buf->next = NULL;
2998 			TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
2999 					auth_tag_len - sgl_buf->data_len),
3000 					"No room to append auth tag");
3001 		}
3002 
3003 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3004 				uint8_t *, remaining_off);
3005 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3006 				remaining_off);
3007 		memset(sym_op->auth.digest.data, 0, remaining_off);
3008 		while (sgl_buf->next != NULL) {
3009 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3010 				0, rte_pktmbuf_data_len(sgl_buf));
3011 			sgl_buf = sgl_buf->next;
3012 		}
3013 	}
3014 
3015 	/* Copy digest for the verification */
3016 	if (verify)
3017 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3018 
3019 	/* Copy cipher and auth IVs at the end of the crypto operation */
3020 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3021 			ut_params->op, uint8_t *, IV_OFFSET);
3022 
3023 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3024 	iv_ptr += cipher_iv_len;
3025 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3026 
3027 	/* Only copy over the offset data needed from src to dst in OOP,
3028 	 * if the auth and cipher offsets are not aligned
3029 	 */
3030 	if (op_mode == OUT_OF_PLACE) {
3031 		if (cipher_offset > auth_offset)
3032 			rte_memcpy(
3033 				rte_pktmbuf_mtod_offset(
3034 					sym_op->m_dst,
3035 					uint8_t *, auth_offset >> 3),
3036 				rte_pktmbuf_mtod_offset(
3037 					sym_op->m_src,
3038 					uint8_t *, auth_offset >> 3),
3039 				((cipher_offset >> 3) - (auth_offset >> 3)));
3040 	}
3041 
3042 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3043 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3044 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3045 		sym_op->cipher.data.length = cipher_len;
3046 		sym_op->cipher.data.offset = cipher_offset;
3047 	} else {
3048 		sym_op->cipher.data.length = cipher_len >> 3;
3049 		sym_op->cipher.data.offset = cipher_offset >> 3;
3050 	}
3051 
3052 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3053 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3054 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3055 		sym_op->auth.data.length = auth_len;
3056 		sym_op->auth.data.offset = auth_offset;
3057 	} else {
3058 		sym_op->auth.data.length = auth_len >> 3;
3059 		sym_op->auth.data.offset = auth_offset >> 3;
3060 	}
3061 
3062 	return 0;
3063 }
3064 
3065 static int
3066 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3067 {
3068 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3069 	struct crypto_unittest_params *ut_params = &unittest_params;
3070 
3071 	int retval;
3072 	unsigned plaintext_pad_len;
3073 	unsigned plaintext_len;
3074 	uint8_t *plaintext;
3075 	struct rte_cryptodev_info dev_info;
3076 
3077 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3078 	uint64_t feat_flags = dev_info.feature_flags;
3079 
3080 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3081 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3082 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3083 		return TEST_SKIPPED;
3084 	}
3085 
3086 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3087 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3088 		printf("Device doesn't support RAW data-path APIs.\n");
3089 		return TEST_SKIPPED;
3090 	}
3091 
3092 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3093 		return TEST_SKIPPED;
3094 
3095 	/* Verify the capabilities */
3096 	struct rte_cryptodev_sym_capability_idx cap_idx;
3097 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3098 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3099 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3100 			&cap_idx) == NULL)
3101 		return TEST_SKIPPED;
3102 
3103 	/* Create SNOW 3G session */
3104 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3105 			tdata->key.data, tdata->key.len,
3106 			tdata->auth_iv.len, tdata->digest.len,
3107 			RTE_CRYPTO_AUTH_OP_GENERATE,
3108 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3109 	if (retval < 0)
3110 		return retval;
3111 
3112 	/* alloc mbuf and set payload */
3113 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3114 
3115 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3116 	rte_pktmbuf_tailroom(ut_params->ibuf));
3117 
3118 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3119 	/* Append data which is padded to a multiple of */
3120 	/* the algorithms block size */
3121 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3122 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3123 				plaintext_pad_len);
3124 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3125 
3126 	/* Create SNOW 3G operation */
3127 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3128 			tdata->auth_iv.data, tdata->auth_iv.len,
3129 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3130 			tdata->validAuthLenInBits.len,
3131 			0);
3132 	if (retval < 0)
3133 		return retval;
3134 
3135 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3136 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3137 				ut_params->op, 0, 1, 1, 0);
3138 	else
3139 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3140 				ut_params->op);
3141 	ut_params->obuf = ut_params->op->sym->m_src;
3142 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3143 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3144 			+ plaintext_pad_len;
3145 
3146 	/* Validate obuf */
3147 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3148 	ut_params->digest,
3149 	tdata->digest.data,
3150 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3151 	"SNOW 3G Generated auth tag not as expected");
3152 
3153 	return 0;
3154 }
3155 
3156 static int
3157 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3158 {
3159 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3160 	struct crypto_unittest_params *ut_params = &unittest_params;
3161 
3162 	int retval;
3163 	unsigned plaintext_pad_len;
3164 	unsigned plaintext_len;
3165 	uint8_t *plaintext;
3166 	struct rte_cryptodev_info dev_info;
3167 
3168 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3169 	uint64_t feat_flags = dev_info.feature_flags;
3170 
3171 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3172 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3173 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3174 		return TEST_SKIPPED;
3175 	}
3176 
3177 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3178 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3179 		printf("Device doesn't support RAW data-path APIs.\n");
3180 		return TEST_SKIPPED;
3181 	}
3182 
3183 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3184 		return TEST_SKIPPED;
3185 
3186 	/* Verify the capabilities */
3187 	struct rte_cryptodev_sym_capability_idx cap_idx;
3188 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3189 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3190 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3191 			&cap_idx) == NULL)
3192 		return TEST_SKIPPED;
3193 
3194 	/* Create SNOW 3G session */
3195 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3196 				tdata->key.data, tdata->key.len,
3197 				tdata->auth_iv.len, tdata->digest.len,
3198 				RTE_CRYPTO_AUTH_OP_VERIFY,
3199 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3200 	if (retval < 0)
3201 		return retval;
3202 	/* alloc mbuf and set payload */
3203 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3204 
3205 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3206 	rte_pktmbuf_tailroom(ut_params->ibuf));
3207 
3208 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3209 	/* Append data which is padded to a multiple of */
3210 	/* the algorithms block size */
3211 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3212 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3213 				plaintext_pad_len);
3214 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3215 
3216 	/* Create SNOW 3G operation */
3217 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3218 			tdata->digest.len,
3219 			tdata->auth_iv.data, tdata->auth_iv.len,
3220 			plaintext_pad_len,
3221 			RTE_CRYPTO_AUTH_OP_VERIFY,
3222 			tdata->validAuthLenInBits.len,
3223 			0);
3224 	if (retval < 0)
3225 		return retval;
3226 
3227 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3228 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3229 				ut_params->op, 0, 1, 1, 0);
3230 	else
3231 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3232 				ut_params->op);
3233 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3234 	ut_params->obuf = ut_params->op->sym->m_src;
3235 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3236 				+ plaintext_pad_len;
3237 
3238 	/* Validate obuf */
3239 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3240 		return 0;
3241 	else
3242 		return -1;
3243 
3244 	return 0;
3245 }
3246 
3247 static int
3248 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3249 {
3250 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3251 	struct crypto_unittest_params *ut_params = &unittest_params;
3252 
3253 	int retval;
3254 	unsigned plaintext_pad_len;
3255 	unsigned plaintext_len;
3256 	uint8_t *plaintext;
3257 	struct rte_cryptodev_info dev_info;
3258 
3259 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3260 	uint64_t feat_flags = dev_info.feature_flags;
3261 
3262 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3263 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3264 		printf("Device doesn't support RAW data-path APIs.\n");
3265 		return TEST_SKIPPED;
3266 	}
3267 
3268 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3269 		return TEST_SKIPPED;
3270 
3271 	/* Verify the capabilities */
3272 	struct rte_cryptodev_sym_capability_idx cap_idx;
3273 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3274 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3275 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3276 			&cap_idx) == NULL)
3277 		return TEST_SKIPPED;
3278 
3279 	/* Create KASUMI session */
3280 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3281 			tdata->key.data, tdata->key.len,
3282 			0, tdata->digest.len,
3283 			RTE_CRYPTO_AUTH_OP_GENERATE,
3284 			RTE_CRYPTO_AUTH_KASUMI_F9);
3285 	if (retval < 0)
3286 		return retval;
3287 
3288 	/* alloc mbuf and set payload */
3289 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3290 
3291 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3292 	rte_pktmbuf_tailroom(ut_params->ibuf));
3293 
3294 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3295 	/* Append data which is padded to a multiple of */
3296 	/* the algorithms block size */
3297 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3298 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3299 				plaintext_pad_len);
3300 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3301 
3302 	/* Create KASUMI operation */
3303 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3304 			NULL, 0,
3305 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3306 			tdata->plaintext.len,
3307 			0);
3308 	if (retval < 0)
3309 		return retval;
3310 
3311 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3312 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3313 			ut_params->op);
3314 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3315 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3316 				ut_params->op, 0, 1, 1, 0);
3317 	else
3318 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3319 			ut_params->op);
3320 
3321 	ut_params->obuf = ut_params->op->sym->m_src;
3322 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3323 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3324 			+ plaintext_pad_len;
3325 
3326 	/* Validate obuf */
3327 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3328 	ut_params->digest,
3329 	tdata->digest.data,
3330 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3331 	"KASUMI Generated auth tag not as expected");
3332 
3333 	return 0;
3334 }
3335 
3336 static int
3337 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3338 {
3339 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3340 	struct crypto_unittest_params *ut_params = &unittest_params;
3341 
3342 	int retval;
3343 	unsigned plaintext_pad_len;
3344 	unsigned plaintext_len;
3345 	uint8_t *plaintext;
3346 	struct rte_cryptodev_info dev_info;
3347 
3348 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3349 	uint64_t feat_flags = dev_info.feature_flags;
3350 
3351 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3352 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3353 		printf("Device doesn't support RAW data-path APIs.\n");
3354 		return TEST_SKIPPED;
3355 	}
3356 
3357 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3358 		return TEST_SKIPPED;
3359 
3360 	/* Verify the capabilities */
3361 	struct rte_cryptodev_sym_capability_idx cap_idx;
3362 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3363 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3364 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3365 			&cap_idx) == NULL)
3366 		return TEST_SKIPPED;
3367 
3368 	/* Create KASUMI session */
3369 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3370 				tdata->key.data, tdata->key.len,
3371 				0, tdata->digest.len,
3372 				RTE_CRYPTO_AUTH_OP_VERIFY,
3373 				RTE_CRYPTO_AUTH_KASUMI_F9);
3374 	if (retval < 0)
3375 		return retval;
3376 	/* alloc mbuf and set payload */
3377 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3378 
3379 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3380 	rte_pktmbuf_tailroom(ut_params->ibuf));
3381 
3382 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3383 	/* Append data which is padded to a multiple */
3384 	/* of the algorithms block size */
3385 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3386 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3387 				plaintext_pad_len);
3388 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3389 
3390 	/* Create KASUMI operation */
3391 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3392 			tdata->digest.len,
3393 			NULL, 0,
3394 			plaintext_pad_len,
3395 			RTE_CRYPTO_AUTH_OP_VERIFY,
3396 			tdata->plaintext.len,
3397 			0);
3398 	if (retval < 0)
3399 		return retval;
3400 
3401 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3402 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3403 				ut_params->op, 0, 1, 1, 0);
3404 	else
3405 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3406 				ut_params->op);
3407 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3408 	ut_params->obuf = ut_params->op->sym->m_src;
3409 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3410 				+ plaintext_pad_len;
3411 
3412 	/* Validate obuf */
3413 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3414 		return 0;
3415 	else
3416 		return -1;
3417 
3418 	return 0;
3419 }
3420 
3421 static int
3422 test_snow3g_hash_generate_test_case_1(void)
3423 {
3424 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3425 }
3426 
3427 static int
3428 test_snow3g_hash_generate_test_case_2(void)
3429 {
3430 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3431 }
3432 
3433 static int
3434 test_snow3g_hash_generate_test_case_3(void)
3435 {
3436 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3437 }
3438 
3439 static int
3440 test_snow3g_hash_generate_test_case_4(void)
3441 {
3442 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3443 }
3444 
3445 static int
3446 test_snow3g_hash_generate_test_case_5(void)
3447 {
3448 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3449 }
3450 
3451 static int
3452 test_snow3g_hash_generate_test_case_6(void)
3453 {
3454 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3455 }
3456 
3457 static int
3458 test_snow3g_hash_verify_test_case_1(void)
3459 {
3460 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3461 
3462 }
3463 
3464 static int
3465 test_snow3g_hash_verify_test_case_2(void)
3466 {
3467 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3468 }
3469 
3470 static int
3471 test_snow3g_hash_verify_test_case_3(void)
3472 {
3473 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3474 }
3475 
3476 static int
3477 test_snow3g_hash_verify_test_case_4(void)
3478 {
3479 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3480 }
3481 
3482 static int
3483 test_snow3g_hash_verify_test_case_5(void)
3484 {
3485 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3486 }
3487 
3488 static int
3489 test_snow3g_hash_verify_test_case_6(void)
3490 {
3491 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3492 }
3493 
3494 static int
3495 test_kasumi_hash_generate_test_case_1(void)
3496 {
3497 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3498 }
3499 
3500 static int
3501 test_kasumi_hash_generate_test_case_2(void)
3502 {
3503 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3504 }
3505 
3506 static int
3507 test_kasumi_hash_generate_test_case_3(void)
3508 {
3509 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3510 }
3511 
3512 static int
3513 test_kasumi_hash_generate_test_case_4(void)
3514 {
3515 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3516 }
3517 
3518 static int
3519 test_kasumi_hash_generate_test_case_5(void)
3520 {
3521 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3522 }
3523 
3524 static int
3525 test_kasumi_hash_generate_test_case_6(void)
3526 {
3527 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3528 }
3529 
3530 static int
3531 test_kasumi_hash_verify_test_case_1(void)
3532 {
3533 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3534 }
3535 
3536 static int
3537 test_kasumi_hash_verify_test_case_2(void)
3538 {
3539 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3540 }
3541 
3542 static int
3543 test_kasumi_hash_verify_test_case_3(void)
3544 {
3545 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3546 }
3547 
3548 static int
3549 test_kasumi_hash_verify_test_case_4(void)
3550 {
3551 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3552 }
3553 
3554 static int
3555 test_kasumi_hash_verify_test_case_5(void)
3556 {
3557 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3558 }
3559 
3560 static int
3561 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3562 {
3563 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3564 	struct crypto_unittest_params *ut_params = &unittest_params;
3565 
3566 	int retval;
3567 	uint8_t *plaintext, *ciphertext;
3568 	unsigned plaintext_pad_len;
3569 	unsigned plaintext_len;
3570 	struct rte_cryptodev_info dev_info;
3571 
3572 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3573 	uint64_t feat_flags = dev_info.feature_flags;
3574 
3575 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3576 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3577 		printf("Device doesn't support RAW data-path APIs.\n");
3578 		return TEST_SKIPPED;
3579 	}
3580 
3581 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3582 		return TEST_SKIPPED;
3583 
3584 	/* Verify the capabilities */
3585 	struct rte_cryptodev_sym_capability_idx cap_idx;
3586 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3587 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3588 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3589 			&cap_idx) == NULL)
3590 		return TEST_SKIPPED;
3591 
3592 	/* Create KASUMI session */
3593 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3594 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3595 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3596 					tdata->key.data, tdata->key.len,
3597 					tdata->cipher_iv.len);
3598 	if (retval < 0)
3599 		return retval;
3600 
3601 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3602 
3603 	/* Clear mbuf payload */
3604 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3605 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3606 
3607 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3608 	/* Append data which is padded to a multiple */
3609 	/* of the algorithms block size */
3610 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3611 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3612 				plaintext_pad_len);
3613 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3614 
3615 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3616 
3617 	/* Create KASUMI operation */
3618 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3619 				tdata->cipher_iv.len,
3620 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3621 				tdata->validCipherOffsetInBits.len);
3622 	if (retval < 0)
3623 		return retval;
3624 
3625 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3626 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3627 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3628 	else
3629 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3630 				ut_params->op);
3631 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3632 
3633 	ut_params->obuf = ut_params->op->sym->m_dst;
3634 	if (ut_params->obuf)
3635 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3636 	else
3637 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3638 
3639 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3640 
3641 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3642 				(tdata->validCipherOffsetInBits.len >> 3);
3643 	/* Validate obuf */
3644 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3645 		ciphertext,
3646 		reference_ciphertext,
3647 		tdata->validCipherLenInBits.len,
3648 		"KASUMI Ciphertext data not as expected");
3649 	return 0;
3650 }
3651 
3652 static int
3653 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3654 {
3655 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3656 	struct crypto_unittest_params *ut_params = &unittest_params;
3657 
3658 	int retval;
3659 
3660 	unsigned int plaintext_pad_len;
3661 	unsigned int plaintext_len;
3662 
3663 	uint8_t buffer[10000];
3664 	const uint8_t *ciphertext;
3665 
3666 	struct rte_cryptodev_info dev_info;
3667 
3668 	/* Verify the capabilities */
3669 	struct rte_cryptodev_sym_capability_idx cap_idx;
3670 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3671 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3672 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3673 			&cap_idx) == NULL)
3674 		return TEST_SKIPPED;
3675 
3676 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3677 
3678 	uint64_t feat_flags = dev_info.feature_flags;
3679 
3680 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3681 		printf("Device doesn't support in-place scatter-gather. "
3682 				"Test Skipped.\n");
3683 		return TEST_SKIPPED;
3684 	}
3685 
3686 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3687 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3688 		printf("Device doesn't support RAW data-path APIs.\n");
3689 		return TEST_SKIPPED;
3690 	}
3691 
3692 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3693 		return TEST_SKIPPED;
3694 
3695 	/* Create KASUMI session */
3696 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3697 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3698 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3699 					tdata->key.data, tdata->key.len,
3700 					tdata->cipher_iv.len);
3701 	if (retval < 0)
3702 		return retval;
3703 
3704 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3705 
3706 
3707 	/* Append data which is padded to a multiple */
3708 	/* of the algorithms block size */
3709 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3710 
3711 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3712 			plaintext_pad_len, 10, 0);
3713 
3714 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3715 
3716 	/* Create KASUMI operation */
3717 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3718 				tdata->cipher_iv.len,
3719 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3720 				tdata->validCipherOffsetInBits.len);
3721 	if (retval < 0)
3722 		return retval;
3723 
3724 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3725 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3726 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3727 	else
3728 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3729 						ut_params->op);
3730 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3731 
3732 	ut_params->obuf = ut_params->op->sym->m_dst;
3733 
3734 	if (ut_params->obuf)
3735 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3736 				plaintext_len, buffer);
3737 	else
3738 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3739 				tdata->validCipherOffsetInBits.len >> 3,
3740 				plaintext_len, buffer);
3741 
3742 	/* Validate obuf */
3743 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3744 
3745 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3746 				(tdata->validCipherOffsetInBits.len >> 3);
3747 	/* Validate obuf */
3748 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3749 		ciphertext,
3750 		reference_ciphertext,
3751 		tdata->validCipherLenInBits.len,
3752 		"KASUMI Ciphertext data not as expected");
3753 	return 0;
3754 }
3755 
3756 static int
3757 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3758 {
3759 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3760 	struct crypto_unittest_params *ut_params = &unittest_params;
3761 
3762 	int retval;
3763 	uint8_t *plaintext, *ciphertext;
3764 	unsigned plaintext_pad_len;
3765 	unsigned plaintext_len;
3766 
3767 	/* Verify the capabilities */
3768 	struct rte_cryptodev_sym_capability_idx cap_idx;
3769 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3770 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3771 	/* Data-path service does not support OOP */
3772 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3773 			&cap_idx) == NULL)
3774 		return TEST_SKIPPED;
3775 
3776 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3777 		return TEST_SKIPPED;
3778 
3779 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3780 		return TEST_SKIPPED;
3781 
3782 	/* Create KASUMI session */
3783 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3784 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3785 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3786 					tdata->key.data, tdata->key.len,
3787 					tdata->cipher_iv.len);
3788 	if (retval < 0)
3789 		return retval;
3790 
3791 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3792 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3793 
3794 	/* Clear mbuf payload */
3795 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3796 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3797 
3798 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3799 	/* Append data which is padded to a multiple */
3800 	/* of the algorithms block size */
3801 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3802 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3803 				plaintext_pad_len);
3804 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3805 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3806 
3807 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3808 
3809 	/* Create KASUMI operation */
3810 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3811 				tdata->cipher_iv.len,
3812 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3813 				tdata->validCipherOffsetInBits.len);
3814 	if (retval < 0)
3815 		return retval;
3816 
3817 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3818 						ut_params->op);
3819 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3820 
3821 	ut_params->obuf = ut_params->op->sym->m_dst;
3822 	if (ut_params->obuf)
3823 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3824 	else
3825 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3826 
3827 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3828 
3829 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3830 				(tdata->validCipherOffsetInBits.len >> 3);
3831 	/* Validate obuf */
3832 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3833 		ciphertext,
3834 		reference_ciphertext,
3835 		tdata->validCipherLenInBits.len,
3836 		"KASUMI Ciphertext data not as expected");
3837 	return 0;
3838 }
3839 
3840 static int
3841 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3842 {
3843 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3844 	struct crypto_unittest_params *ut_params = &unittest_params;
3845 
3846 	int retval;
3847 	unsigned int plaintext_pad_len;
3848 	unsigned int plaintext_len;
3849 
3850 	const uint8_t *ciphertext;
3851 	uint8_t buffer[2048];
3852 
3853 	struct rte_cryptodev_info dev_info;
3854 
3855 	/* Verify the capabilities */
3856 	struct rte_cryptodev_sym_capability_idx cap_idx;
3857 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3858 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3859 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3860 			&cap_idx) == NULL)
3861 		return TEST_SKIPPED;
3862 
3863 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3864 		return TEST_SKIPPED;
3865 
3866 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3867 		return TEST_SKIPPED;
3868 
3869 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3870 
3871 	uint64_t feat_flags = dev_info.feature_flags;
3872 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3873 		printf("Device doesn't support out-of-place scatter-gather "
3874 				"in both input and output mbufs. "
3875 				"Test Skipped.\n");
3876 		return TEST_SKIPPED;
3877 	}
3878 
3879 	/* Create KASUMI session */
3880 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3881 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3882 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3883 					tdata->key.data, tdata->key.len,
3884 					tdata->cipher_iv.len);
3885 	if (retval < 0)
3886 		return retval;
3887 
3888 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3889 	/* Append data which is padded to a multiple */
3890 	/* of the algorithms block size */
3891 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3892 
3893 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3894 			plaintext_pad_len, 10, 0);
3895 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3896 			plaintext_pad_len, 3, 0);
3897 
3898 	/* Append data which is padded to a multiple */
3899 	/* of the algorithms block size */
3900 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3901 
3902 	/* Create KASUMI operation */
3903 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3904 				tdata->cipher_iv.len,
3905 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3906 				tdata->validCipherOffsetInBits.len);
3907 	if (retval < 0)
3908 		return retval;
3909 
3910 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3911 						ut_params->op);
3912 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3913 
3914 	ut_params->obuf = ut_params->op->sym->m_dst;
3915 	if (ut_params->obuf)
3916 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3917 				plaintext_pad_len, buffer);
3918 	else
3919 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3920 				tdata->validCipherOffsetInBits.len >> 3,
3921 				plaintext_pad_len, buffer);
3922 
3923 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3924 				(tdata->validCipherOffsetInBits.len >> 3);
3925 	/* Validate obuf */
3926 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3927 		ciphertext,
3928 		reference_ciphertext,
3929 		tdata->validCipherLenInBits.len,
3930 		"KASUMI Ciphertext data not as expected");
3931 	return 0;
3932 }
3933 
3934 
3935 static int
3936 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3937 {
3938 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3939 	struct crypto_unittest_params *ut_params = &unittest_params;
3940 
3941 	int retval;
3942 	uint8_t *ciphertext, *plaintext;
3943 	unsigned ciphertext_pad_len;
3944 	unsigned ciphertext_len;
3945 
3946 	/* Verify the capabilities */
3947 	struct rte_cryptodev_sym_capability_idx cap_idx;
3948 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3949 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3950 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3951 			&cap_idx) == NULL)
3952 		return TEST_SKIPPED;
3953 
3954 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3955 		return TEST_SKIPPED;
3956 
3957 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3958 		return TEST_SKIPPED;
3959 
3960 	/* Create KASUMI session */
3961 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3962 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3963 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3964 					tdata->key.data, tdata->key.len,
3965 					tdata->cipher_iv.len);
3966 	if (retval < 0)
3967 		return retval;
3968 
3969 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3970 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3971 
3972 	/* Clear mbuf payload */
3973 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3974 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3975 
3976 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3977 	/* Append data which is padded to a multiple */
3978 	/* of the algorithms block size */
3979 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3980 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3981 				ciphertext_pad_len);
3982 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3983 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3984 
3985 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3986 
3987 	/* Create KASUMI operation */
3988 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3989 				tdata->cipher_iv.len,
3990 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3991 				tdata->validCipherOffsetInBits.len);
3992 	if (retval < 0)
3993 		return retval;
3994 
3995 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3996 						ut_params->op);
3997 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3998 
3999 	ut_params->obuf = ut_params->op->sym->m_dst;
4000 	if (ut_params->obuf)
4001 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4002 	else
4003 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4004 
4005 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4006 
4007 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4008 				(tdata->validCipherOffsetInBits.len >> 3);
4009 	/* Validate obuf */
4010 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4011 		plaintext,
4012 		reference_plaintext,
4013 		tdata->validCipherLenInBits.len,
4014 		"KASUMI Plaintext data not as expected");
4015 	return 0;
4016 }
4017 
4018 static int
4019 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4020 {
4021 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4022 	struct crypto_unittest_params *ut_params = &unittest_params;
4023 
4024 	int retval;
4025 	uint8_t *ciphertext, *plaintext;
4026 	unsigned ciphertext_pad_len;
4027 	unsigned ciphertext_len;
4028 	struct rte_cryptodev_info dev_info;
4029 
4030 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4031 	uint64_t feat_flags = dev_info.feature_flags;
4032 
4033 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4034 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4035 		printf("Device doesn't support RAW data-path APIs.\n");
4036 		return TEST_SKIPPED;
4037 	}
4038 
4039 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4040 		return TEST_SKIPPED;
4041 
4042 	/* Verify the capabilities */
4043 	struct rte_cryptodev_sym_capability_idx cap_idx;
4044 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4045 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4046 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4047 			&cap_idx) == NULL)
4048 		return TEST_SKIPPED;
4049 
4050 	/* Create KASUMI session */
4051 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4052 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4053 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4054 					tdata->key.data, tdata->key.len,
4055 					tdata->cipher_iv.len);
4056 	if (retval < 0)
4057 		return retval;
4058 
4059 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4060 
4061 	/* Clear mbuf payload */
4062 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4063 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4064 
4065 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4066 	/* Append data which is padded to a multiple */
4067 	/* of the algorithms block size */
4068 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4069 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4070 				ciphertext_pad_len);
4071 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4072 
4073 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4074 
4075 	/* Create KASUMI operation */
4076 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4077 			tdata->cipher_iv.len,
4078 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4079 			tdata->validCipherOffsetInBits.len);
4080 	if (retval < 0)
4081 		return retval;
4082 
4083 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4084 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4085 				ut_params->op, 1, 0, 1, 0);
4086 	else
4087 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4088 						ut_params->op);
4089 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4090 
4091 	ut_params->obuf = ut_params->op->sym->m_dst;
4092 	if (ut_params->obuf)
4093 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4094 	else
4095 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4096 
4097 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4098 
4099 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4100 				(tdata->validCipherOffsetInBits.len >> 3);
4101 	/* Validate obuf */
4102 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4103 		plaintext,
4104 		reference_plaintext,
4105 		tdata->validCipherLenInBits.len,
4106 		"KASUMI Plaintext data not as expected");
4107 	return 0;
4108 }
4109 
4110 static int
4111 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4112 {
4113 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4114 	struct crypto_unittest_params *ut_params = &unittest_params;
4115 
4116 	int retval;
4117 	uint8_t *plaintext, *ciphertext;
4118 	unsigned plaintext_pad_len;
4119 	unsigned plaintext_len;
4120 	struct rte_cryptodev_info dev_info;
4121 
4122 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4123 	uint64_t feat_flags = dev_info.feature_flags;
4124 
4125 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4126 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4127 		printf("Device doesn't support RAW data-path APIs.\n");
4128 		return TEST_SKIPPED;
4129 	}
4130 
4131 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4132 		return TEST_SKIPPED;
4133 
4134 	/* Verify the capabilities */
4135 	struct rte_cryptodev_sym_capability_idx cap_idx;
4136 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4137 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4138 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4139 			&cap_idx) == NULL)
4140 		return TEST_SKIPPED;
4141 
4142 	/* Create SNOW 3G session */
4143 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4144 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4145 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4146 					tdata->key.data, tdata->key.len,
4147 					tdata->cipher_iv.len);
4148 	if (retval < 0)
4149 		return retval;
4150 
4151 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4152 
4153 	/* Clear mbuf payload */
4154 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4155 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4156 
4157 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4158 	/* Append data which is padded to a multiple of */
4159 	/* the algorithms block size */
4160 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4161 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4162 				plaintext_pad_len);
4163 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4164 
4165 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4166 
4167 	/* Create SNOW 3G operation */
4168 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4169 					tdata->cipher_iv.len,
4170 					tdata->validCipherLenInBits.len,
4171 					0);
4172 	if (retval < 0)
4173 		return retval;
4174 
4175 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4176 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4177 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4178 	else
4179 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4180 						ut_params->op);
4181 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4182 
4183 	ut_params->obuf = ut_params->op->sym->m_dst;
4184 	if (ut_params->obuf)
4185 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4186 	else
4187 		ciphertext = plaintext;
4188 
4189 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4190 
4191 	/* Validate obuf */
4192 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4193 		ciphertext,
4194 		tdata->ciphertext.data,
4195 		tdata->validDataLenInBits.len,
4196 		"SNOW 3G Ciphertext data not as expected");
4197 	return 0;
4198 }
4199 
4200 
4201 static int
4202 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4203 {
4204 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4205 	struct crypto_unittest_params *ut_params = &unittest_params;
4206 	uint8_t *plaintext, *ciphertext;
4207 
4208 	int retval;
4209 	unsigned plaintext_pad_len;
4210 	unsigned plaintext_len;
4211 	struct rte_cryptodev_info dev_info;
4212 
4213 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4214 	uint64_t feat_flags = dev_info.feature_flags;
4215 
4216 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4217 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4218 		printf("Device does not support RAW data-path APIs.\n");
4219 		return -ENOTSUP;
4220 	}
4221 
4222 	/* Verify the capabilities */
4223 	struct rte_cryptodev_sym_capability_idx cap_idx;
4224 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4225 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4226 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4227 			&cap_idx) == NULL)
4228 		return TEST_SKIPPED;
4229 
4230 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4231 		return TEST_SKIPPED;
4232 
4233 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4234 		return TEST_SKIPPED;
4235 
4236 	/* Create SNOW 3G session */
4237 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4238 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4239 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4240 					tdata->key.data, tdata->key.len,
4241 					tdata->cipher_iv.len);
4242 	if (retval < 0)
4243 		return retval;
4244 
4245 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4246 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4247 
4248 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4249 			"Failed to allocate input buffer in mempool");
4250 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4251 			"Failed to allocate output buffer in mempool");
4252 
4253 	/* Clear mbuf payload */
4254 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4255 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4256 
4257 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4258 	/* Append data which is padded to a multiple of */
4259 	/* the algorithms block size */
4260 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4261 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4262 				plaintext_pad_len);
4263 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4264 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4265 
4266 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4267 
4268 	/* Create SNOW 3G operation */
4269 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4270 					tdata->cipher_iv.len,
4271 					tdata->validCipherLenInBits.len,
4272 					0);
4273 	if (retval < 0)
4274 		return retval;
4275 
4276 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4277 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4278 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4279 	else
4280 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4281 						ut_params->op);
4282 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4283 
4284 	ut_params->obuf = ut_params->op->sym->m_dst;
4285 	if (ut_params->obuf)
4286 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4287 	else
4288 		ciphertext = plaintext;
4289 
4290 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4291 
4292 	/* Validate obuf */
4293 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4294 		ciphertext,
4295 		tdata->ciphertext.data,
4296 		tdata->validDataLenInBits.len,
4297 		"SNOW 3G Ciphertext data not as expected");
4298 	return 0;
4299 }
4300 
4301 static int
4302 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4303 		uint8_t sgl_in, uint8_t sgl_out)
4304 {
4305 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4306 	struct crypto_unittest_params *ut_params = &unittest_params;
4307 
4308 	int retval;
4309 	unsigned int plaintext_pad_len;
4310 	unsigned int plaintext_len;
4311 	uint8_t buffer[10000];
4312 	const uint8_t *ciphertext;
4313 
4314 	struct rte_cryptodev_info dev_info;
4315 
4316 	/* Verify the capabilities */
4317 	struct rte_cryptodev_sym_capability_idx cap_idx;
4318 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4319 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4320 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4321 			&cap_idx) == NULL)
4322 		return TEST_SKIPPED;
4323 
4324 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4325 		return TEST_SKIPPED;
4326 
4327 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4328 		return TEST_SKIPPED;
4329 
4330 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4331 
4332 	uint64_t feat_flags = dev_info.feature_flags;
4333 
4334 	if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4335 			|| ((!sgl_in && sgl_out) &&
4336 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4337 			|| ((sgl_in && !sgl_out) &&
4338 			!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4339 		printf("Device doesn't support out-of-place scatter gather type. "
4340 				"Test Skipped.\n");
4341 		return TEST_SKIPPED;
4342 	}
4343 
4344 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4345 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4346 		printf("Device does not support RAW data-path APIs.\n");
4347 		return -ENOTSUP;
4348 	}
4349 
4350 	/* Create SNOW 3G session */
4351 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4352 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4353 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4354 					tdata->key.data, tdata->key.len,
4355 					tdata->cipher_iv.len);
4356 	if (retval < 0)
4357 		return retval;
4358 
4359 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4360 	/* Append data which is padded to a multiple of */
4361 	/* the algorithms block size */
4362 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4363 
4364 	if (sgl_in)
4365 		ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4366 				plaintext_pad_len, 10, 0);
4367 	else {
4368 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4369 		rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4370 	}
4371 
4372 	if (sgl_out)
4373 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4374 				plaintext_pad_len, 3, 0);
4375 	else {
4376 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4377 		rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4378 	}
4379 
4380 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4381 			"Failed to allocate input buffer in mempool");
4382 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4383 			"Failed to allocate output buffer in mempool");
4384 
4385 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4386 
4387 	/* Create SNOW 3G operation */
4388 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4389 					tdata->cipher_iv.len,
4390 					tdata->validCipherLenInBits.len,
4391 					0);
4392 	if (retval < 0)
4393 		return retval;
4394 
4395 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4396 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4397 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4398 	else
4399 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4400 						ut_params->op);
4401 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4402 
4403 	ut_params->obuf = ut_params->op->sym->m_dst;
4404 	if (ut_params->obuf)
4405 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4406 				plaintext_len, buffer);
4407 	else
4408 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4409 				plaintext_len, buffer);
4410 
4411 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4412 
4413 	/* Validate obuf */
4414 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4415 		ciphertext,
4416 		tdata->ciphertext.data,
4417 		tdata->validDataLenInBits.len,
4418 		"SNOW 3G Ciphertext data not as expected");
4419 
4420 	return 0;
4421 }
4422 
4423 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4424 static void
4425 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4426 {
4427 	uint8_t curr_byte, prev_byte;
4428 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4429 	uint8_t lower_byte_mask = (1 << offset) - 1;
4430 	unsigned i;
4431 
4432 	prev_byte = buffer[0];
4433 	buffer[0] >>= offset;
4434 
4435 	for (i = 1; i < length_in_bytes; i++) {
4436 		curr_byte = buffer[i];
4437 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4438 				(curr_byte >> offset);
4439 		prev_byte = curr_byte;
4440 	}
4441 }
4442 
4443 static int
4444 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4445 {
4446 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4447 	struct crypto_unittest_params *ut_params = &unittest_params;
4448 	uint8_t *plaintext, *ciphertext;
4449 	int retval;
4450 	uint32_t plaintext_len;
4451 	uint32_t plaintext_pad_len;
4452 	uint8_t extra_offset = 4;
4453 	uint8_t *expected_ciphertext_shifted;
4454 	struct rte_cryptodev_info dev_info;
4455 
4456 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4457 	uint64_t feat_flags = dev_info.feature_flags;
4458 
4459 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4460 			((tdata->validDataLenInBits.len % 8) != 0)) {
4461 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4462 		return TEST_SKIPPED;
4463 	}
4464 
4465 	/* Verify the capabilities */
4466 	struct rte_cryptodev_sym_capability_idx cap_idx;
4467 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4468 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4469 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4470 			&cap_idx) == NULL)
4471 		return TEST_SKIPPED;
4472 
4473 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4474 		return TEST_SKIPPED;
4475 
4476 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4477 		return TEST_SKIPPED;
4478 
4479 	/* Create SNOW 3G session */
4480 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4481 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4482 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4483 					tdata->key.data, tdata->key.len,
4484 					tdata->cipher_iv.len);
4485 	if (retval < 0)
4486 		return retval;
4487 
4488 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4489 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4490 
4491 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4492 			"Failed to allocate input buffer in mempool");
4493 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4494 			"Failed to allocate output buffer in mempool");
4495 
4496 	/* Clear mbuf payload */
4497 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4498 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4499 
4500 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4501 	/*
4502 	 * Append data which is padded to a
4503 	 * multiple of the algorithms block size
4504 	 */
4505 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4506 
4507 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4508 						plaintext_pad_len);
4509 
4510 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4511 
4512 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4513 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4514 
4515 #ifdef RTE_APP_TEST_DEBUG
4516 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4517 #endif
4518 	/* Create SNOW 3G operation */
4519 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4520 					tdata->cipher_iv.len,
4521 					tdata->validCipherLenInBits.len,
4522 					extra_offset);
4523 	if (retval < 0)
4524 		return retval;
4525 
4526 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4527 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4528 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4529 	else
4530 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4531 						ut_params->op);
4532 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4533 
4534 	ut_params->obuf = ut_params->op->sym->m_dst;
4535 	if (ut_params->obuf)
4536 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4537 	else
4538 		ciphertext = plaintext;
4539 
4540 #ifdef RTE_APP_TEST_DEBUG
4541 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4542 #endif
4543 
4544 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4545 
4546 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4547 			"failed to reserve memory for ciphertext shifted\n");
4548 
4549 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4550 			ceil_byte_length(tdata->ciphertext.len));
4551 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4552 			extra_offset);
4553 	/* Validate obuf */
4554 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4555 		ciphertext,
4556 		expected_ciphertext_shifted,
4557 		tdata->validDataLenInBits.len,
4558 		extra_offset,
4559 		"SNOW 3G Ciphertext data not as expected");
4560 	return 0;
4561 }
4562 
4563 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4564 {
4565 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4566 	struct crypto_unittest_params *ut_params = &unittest_params;
4567 
4568 	int retval;
4569 
4570 	uint8_t *plaintext, *ciphertext;
4571 	unsigned ciphertext_pad_len;
4572 	unsigned ciphertext_len;
4573 	struct rte_cryptodev_info dev_info;
4574 
4575 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4576 	uint64_t feat_flags = dev_info.feature_flags;
4577 
4578 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4579 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4580 		printf("Device doesn't support RAW data-path APIs.\n");
4581 		return TEST_SKIPPED;
4582 	}
4583 
4584 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4585 		return TEST_SKIPPED;
4586 
4587 	/* Verify the capabilities */
4588 	struct rte_cryptodev_sym_capability_idx cap_idx;
4589 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4590 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4591 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4592 			&cap_idx) == NULL)
4593 		return TEST_SKIPPED;
4594 
4595 	/* Create SNOW 3G session */
4596 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4597 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4598 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4599 					tdata->key.data, tdata->key.len,
4600 					tdata->cipher_iv.len);
4601 	if (retval < 0)
4602 		return retval;
4603 
4604 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4605 
4606 	/* Clear mbuf payload */
4607 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4608 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4609 
4610 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4611 	/* Append data which is padded to a multiple of */
4612 	/* the algorithms block size */
4613 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4614 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4615 				ciphertext_pad_len);
4616 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4617 
4618 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4619 
4620 	/* Create SNOW 3G operation */
4621 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4622 					tdata->cipher_iv.len,
4623 					tdata->validCipherLenInBits.len,
4624 					tdata->cipher.offset_bits);
4625 	if (retval < 0)
4626 		return retval;
4627 
4628 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4629 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4630 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4631 	else
4632 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4633 						ut_params->op);
4634 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4635 	ut_params->obuf = ut_params->op->sym->m_dst;
4636 	if (ut_params->obuf)
4637 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4638 	else
4639 		plaintext = ciphertext;
4640 
4641 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4642 
4643 	/* Validate obuf */
4644 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4645 				tdata->plaintext.data,
4646 				tdata->validDataLenInBits.len,
4647 				"SNOW 3G Plaintext data not as expected");
4648 	return 0;
4649 }
4650 
4651 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4652 {
4653 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4654 	struct crypto_unittest_params *ut_params = &unittest_params;
4655 
4656 	int retval;
4657 
4658 	uint8_t *plaintext, *ciphertext;
4659 	unsigned ciphertext_pad_len;
4660 	unsigned ciphertext_len;
4661 	struct rte_cryptodev_info dev_info;
4662 
4663 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4664 	uint64_t feat_flags = dev_info.feature_flags;
4665 
4666 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4667 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4668 		printf("Device does not support RAW data-path APIs.\n");
4669 		return -ENOTSUP;
4670 	}
4671 	/* Verify the capabilities */
4672 	struct rte_cryptodev_sym_capability_idx cap_idx;
4673 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4674 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4675 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4676 			&cap_idx) == NULL)
4677 		return TEST_SKIPPED;
4678 
4679 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4680 		return TEST_SKIPPED;
4681 
4682 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4683 		return TEST_SKIPPED;
4684 
4685 	/* Create SNOW 3G session */
4686 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4687 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4688 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4689 					tdata->key.data, tdata->key.len,
4690 					tdata->cipher_iv.len);
4691 	if (retval < 0)
4692 		return retval;
4693 
4694 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4695 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4696 
4697 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4698 			"Failed to allocate input buffer");
4699 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4700 			"Failed to allocate output buffer");
4701 
4702 	/* Clear mbuf payload */
4703 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4704 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4705 
4706 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4707 		       rte_pktmbuf_tailroom(ut_params->obuf));
4708 
4709 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4710 	/* Append data which is padded to a multiple of */
4711 	/* the algorithms block size */
4712 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4713 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4714 				ciphertext_pad_len);
4715 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4716 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4717 
4718 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4719 
4720 	/* Create SNOW 3G operation */
4721 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4722 					tdata->cipher_iv.len,
4723 					tdata->validCipherLenInBits.len,
4724 					0);
4725 	if (retval < 0)
4726 		return retval;
4727 
4728 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4729 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4730 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4731 	else
4732 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4733 						ut_params->op);
4734 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4735 	ut_params->obuf = ut_params->op->sym->m_dst;
4736 	if (ut_params->obuf)
4737 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4738 	else
4739 		plaintext = ciphertext;
4740 
4741 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4742 
4743 	/* Validate obuf */
4744 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4745 				tdata->plaintext.data,
4746 				tdata->validDataLenInBits.len,
4747 				"SNOW 3G Plaintext data not as expected");
4748 	return 0;
4749 }
4750 
4751 static int
4752 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4753 {
4754 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4755 	struct crypto_unittest_params *ut_params = &unittest_params;
4756 
4757 	int retval;
4758 
4759 	uint8_t *plaintext, *ciphertext;
4760 	unsigned int plaintext_pad_len;
4761 	unsigned int plaintext_len;
4762 
4763 	struct rte_cryptodev_info dev_info;
4764 	struct rte_cryptodev_sym_capability_idx cap_idx;
4765 
4766 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4767 	uint64_t feat_flags = dev_info.feature_flags;
4768 
4769 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4770 			((tdata->validAuthLenInBits.len % 8 != 0) ||
4771 			(tdata->validDataLenInBits.len % 8 != 0))) {
4772 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4773 		return TEST_SKIPPED;
4774 	}
4775 
4776 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4777 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4778 		printf("Device doesn't support RAW data-path APIs.\n");
4779 		return TEST_SKIPPED;
4780 	}
4781 
4782 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4783 		return TEST_SKIPPED;
4784 
4785 	/* Check if device supports ZUC EEA3 */
4786 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4787 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4788 
4789 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4790 			&cap_idx) == NULL)
4791 		return TEST_SKIPPED;
4792 
4793 	/* Check if device supports ZUC EIA3 */
4794 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4795 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4796 
4797 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4798 			&cap_idx) == NULL)
4799 		return TEST_SKIPPED;
4800 
4801 	/* Create ZUC session */
4802 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4803 			ts_params->valid_devs[0],
4804 			tdata);
4805 	if (retval != 0)
4806 		return retval;
4807 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4808 
4809 	/* clear mbuf payload */
4810 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4811 			rte_pktmbuf_tailroom(ut_params->ibuf));
4812 
4813 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4814 	/* Append data which is padded to a multiple of */
4815 	/* the algorithms block size */
4816 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4817 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4818 				plaintext_pad_len);
4819 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4820 
4821 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4822 
4823 	/* Create ZUC operation */
4824 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4825 	if (retval < 0)
4826 		return retval;
4827 
4828 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4829 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4830 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4831 	else
4832 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4833 			ut_params->op);
4834 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4835 	ut_params->obuf = ut_params->op->sym->m_src;
4836 	if (ut_params->obuf)
4837 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4838 	else
4839 		ciphertext = plaintext;
4840 
4841 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4842 	/* Validate obuf */
4843 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4844 			ciphertext,
4845 			tdata->ciphertext.data,
4846 			tdata->validDataLenInBits.len,
4847 			"ZUC Ciphertext data not as expected");
4848 
4849 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4850 	    + plaintext_pad_len;
4851 
4852 	/* Validate obuf */
4853 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4854 			ut_params->digest,
4855 			tdata->digest.data,
4856 			4,
4857 			"ZUC Generated auth tag not as expected");
4858 	return 0;
4859 }
4860 
4861 static int
4862 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4863 {
4864 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4865 	struct crypto_unittest_params *ut_params = &unittest_params;
4866 
4867 	int retval;
4868 
4869 	uint8_t *plaintext, *ciphertext;
4870 	unsigned plaintext_pad_len;
4871 	unsigned plaintext_len;
4872 	struct rte_cryptodev_info dev_info;
4873 
4874 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4875 	uint64_t feat_flags = dev_info.feature_flags;
4876 
4877 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4878 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4879 		printf("Device doesn't support RAW data-path APIs.\n");
4880 		return TEST_SKIPPED;
4881 	}
4882 
4883 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4884 		return TEST_SKIPPED;
4885 
4886 	/* Verify the capabilities */
4887 	struct rte_cryptodev_sym_capability_idx cap_idx;
4888 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4889 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4890 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4891 			&cap_idx) == NULL)
4892 		return TEST_SKIPPED;
4893 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4894 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4895 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4896 			&cap_idx) == NULL)
4897 		return TEST_SKIPPED;
4898 
4899 	/* Create SNOW 3G session */
4900 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4901 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4902 			RTE_CRYPTO_AUTH_OP_GENERATE,
4903 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4904 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4905 			tdata->key.data, tdata->key.len,
4906 			tdata->auth_iv.len, tdata->digest.len,
4907 			tdata->cipher_iv.len);
4908 	if (retval != 0)
4909 		return retval;
4910 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4911 
4912 	/* clear mbuf payload */
4913 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4914 			rte_pktmbuf_tailroom(ut_params->ibuf));
4915 
4916 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4917 	/* Append data which is padded to a multiple of */
4918 	/* the algorithms block size */
4919 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4920 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4921 				plaintext_pad_len);
4922 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4923 
4924 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4925 
4926 	/* Create SNOW 3G operation */
4927 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4928 			tdata->digest.len, tdata->auth_iv.data,
4929 			tdata->auth_iv.len,
4930 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4931 			tdata->cipher_iv.data, tdata->cipher_iv.len,
4932 			tdata->validCipherLenInBits.len,
4933 			0,
4934 			tdata->validAuthLenInBits.len,
4935 			0
4936 			);
4937 	if (retval < 0)
4938 		return retval;
4939 
4940 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4941 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4942 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4943 	else
4944 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4945 			ut_params->op);
4946 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4947 	ut_params->obuf = ut_params->op->sym->m_src;
4948 	if (ut_params->obuf)
4949 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4950 	else
4951 		ciphertext = plaintext;
4952 
4953 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4954 	/* Validate obuf */
4955 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4956 			ciphertext,
4957 			tdata->ciphertext.data,
4958 			tdata->validDataLenInBits.len,
4959 			"SNOW 3G Ciphertext data not as expected");
4960 
4961 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4962 	    + plaintext_pad_len;
4963 
4964 	/* Validate obuf */
4965 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4966 			ut_params->digest,
4967 			tdata->digest.data,
4968 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4969 			"SNOW 3G Generated auth tag not as expected");
4970 	return 0;
4971 }
4972 
4973 static int
4974 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4975 	uint8_t op_mode, uint8_t verify)
4976 {
4977 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4978 	struct crypto_unittest_params *ut_params = &unittest_params;
4979 
4980 	int retval;
4981 
4982 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4983 	unsigned int plaintext_pad_len;
4984 	unsigned int plaintext_len;
4985 	unsigned int ciphertext_pad_len;
4986 	unsigned int ciphertext_len;
4987 
4988 	struct rte_cryptodev_info dev_info;
4989 
4990 	/* Verify the capabilities */
4991 	struct rte_cryptodev_sym_capability_idx cap_idx;
4992 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4993 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4994 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4995 			&cap_idx) == NULL)
4996 		return TEST_SKIPPED;
4997 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4998 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4999 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5000 			&cap_idx) == NULL)
5001 		return TEST_SKIPPED;
5002 
5003 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5004 		return TEST_SKIPPED;
5005 
5006 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5007 
5008 	uint64_t feat_flags = dev_info.feature_flags;
5009 
5010 	if (op_mode == OUT_OF_PLACE) {
5011 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5012 			printf("Device doesn't support digest encrypted.\n");
5013 			return TEST_SKIPPED;
5014 		}
5015 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5016 			return TEST_SKIPPED;
5017 	}
5018 
5019 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5020 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5021 		printf("Device doesn't support RAW data-path APIs.\n");
5022 		return TEST_SKIPPED;
5023 	}
5024 
5025 	/* Create SNOW 3G session */
5026 	retval = create_wireless_algo_auth_cipher_session(
5027 			ts_params->valid_devs[0],
5028 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5029 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5030 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5031 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5032 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5033 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5034 			tdata->key.data, tdata->key.len,
5035 			tdata->auth_iv.len, tdata->digest.len,
5036 			tdata->cipher_iv.len);
5037 	if (retval != 0)
5038 		return retval;
5039 
5040 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5041 	if (op_mode == OUT_OF_PLACE)
5042 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5043 
5044 	/* clear mbuf payload */
5045 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5046 		rte_pktmbuf_tailroom(ut_params->ibuf));
5047 	if (op_mode == OUT_OF_PLACE)
5048 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5049 			rte_pktmbuf_tailroom(ut_params->obuf));
5050 
5051 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5052 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5053 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5054 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5055 
5056 	if (verify) {
5057 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5058 					ciphertext_pad_len);
5059 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5060 		if (op_mode == OUT_OF_PLACE)
5061 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5062 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5063 			ciphertext_len);
5064 	} else {
5065 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5066 					plaintext_pad_len);
5067 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5068 		if (op_mode == OUT_OF_PLACE)
5069 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5070 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5071 	}
5072 
5073 	/* Create SNOW 3G operation */
5074 	retval = create_wireless_algo_auth_cipher_operation(
5075 		tdata->digest.data, tdata->digest.len,
5076 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5077 		tdata->auth_iv.data, tdata->auth_iv.len,
5078 		(tdata->digest.offset_bytes == 0 ?
5079 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5080 			: tdata->digest.offset_bytes),
5081 		tdata->validCipherLenInBits.len,
5082 		tdata->cipher.offset_bits,
5083 		tdata->validAuthLenInBits.len,
5084 		tdata->auth.offset_bits,
5085 		op_mode, 0, verify);
5086 
5087 	if (retval < 0)
5088 		return retval;
5089 
5090 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5091 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5092 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5093 	else
5094 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5095 			ut_params->op);
5096 
5097 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5098 
5099 	ut_params->obuf = (op_mode == IN_PLACE ?
5100 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5101 
5102 	if (verify) {
5103 		if (ut_params->obuf)
5104 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5105 							uint8_t *);
5106 		else
5107 			plaintext = ciphertext +
5108 				(tdata->cipher.offset_bits >> 3);
5109 
5110 		debug_hexdump(stdout, "plaintext:", plaintext,
5111 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5112 		debug_hexdump(stdout, "plaintext expected:",
5113 			tdata->plaintext.data,
5114 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5115 	} else {
5116 		if (ut_params->obuf)
5117 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5118 							uint8_t *);
5119 		else
5120 			ciphertext = plaintext;
5121 
5122 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5123 			ciphertext_len);
5124 		debug_hexdump(stdout, "ciphertext expected:",
5125 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5126 
5127 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5128 			+ (tdata->digest.offset_bytes == 0 ?
5129 		plaintext_pad_len : tdata->digest.offset_bytes);
5130 
5131 		debug_hexdump(stdout, "digest:", ut_params->digest,
5132 			tdata->digest.len);
5133 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5134 				tdata->digest.len);
5135 	}
5136 
5137 	/* Validate obuf */
5138 	if (verify) {
5139 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5140 			plaintext,
5141 			tdata->plaintext.data,
5142 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5143 			 (tdata->digest.len << 3)),
5144 			tdata->cipher.offset_bits,
5145 			"SNOW 3G Plaintext data not as expected");
5146 	} else {
5147 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5148 			ciphertext,
5149 			tdata->ciphertext.data,
5150 			(tdata->validDataLenInBits.len -
5151 			 tdata->cipher.offset_bits),
5152 			tdata->cipher.offset_bits,
5153 			"SNOW 3G Ciphertext data not as expected");
5154 
5155 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5156 			ut_params->digest,
5157 			tdata->digest.data,
5158 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5159 			"SNOW 3G Generated auth tag not as expected");
5160 	}
5161 	return 0;
5162 }
5163 
5164 static int
5165 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5166 	uint8_t op_mode, uint8_t verify)
5167 {
5168 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5169 	struct crypto_unittest_params *ut_params = &unittest_params;
5170 
5171 	int retval;
5172 
5173 	const uint8_t *plaintext = NULL;
5174 	const uint8_t *ciphertext = NULL;
5175 	const uint8_t *digest = NULL;
5176 	unsigned int plaintext_pad_len;
5177 	unsigned int plaintext_len;
5178 	unsigned int ciphertext_pad_len;
5179 	unsigned int ciphertext_len;
5180 	uint8_t buffer[10000];
5181 	uint8_t digest_buffer[10000];
5182 
5183 	struct rte_cryptodev_info dev_info;
5184 
5185 	/* Verify the capabilities */
5186 	struct rte_cryptodev_sym_capability_idx cap_idx;
5187 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5188 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5189 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5190 			&cap_idx) == NULL)
5191 		return TEST_SKIPPED;
5192 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5193 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5194 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5195 			&cap_idx) == NULL)
5196 		return TEST_SKIPPED;
5197 
5198 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5199 		return TEST_SKIPPED;
5200 
5201 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5202 
5203 	uint64_t feat_flags = dev_info.feature_flags;
5204 
5205 	if (op_mode == IN_PLACE) {
5206 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5207 			printf("Device doesn't support in-place scatter-gather "
5208 					"in both input and output mbufs.\n");
5209 			return TEST_SKIPPED;
5210 		}
5211 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5212 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5213 			printf("Device doesn't support RAW data-path APIs.\n");
5214 			return TEST_SKIPPED;
5215 		}
5216 	} else {
5217 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5218 			return TEST_SKIPPED;
5219 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5220 			printf("Device doesn't support out-of-place scatter-gather "
5221 					"in both input and output mbufs.\n");
5222 			return TEST_SKIPPED;
5223 		}
5224 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5225 			printf("Device doesn't support digest encrypted.\n");
5226 			return TEST_SKIPPED;
5227 		}
5228 	}
5229 
5230 	/* Create SNOW 3G session */
5231 	retval = create_wireless_algo_auth_cipher_session(
5232 			ts_params->valid_devs[0],
5233 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5234 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5235 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5236 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5237 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5238 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5239 			tdata->key.data, tdata->key.len,
5240 			tdata->auth_iv.len, tdata->digest.len,
5241 			tdata->cipher_iv.len);
5242 
5243 	if (retval != 0)
5244 		return retval;
5245 
5246 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5247 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5248 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5249 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5250 
5251 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5252 			plaintext_pad_len, 15, 0);
5253 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5254 			"Failed to allocate input buffer in mempool");
5255 
5256 	if (op_mode == OUT_OF_PLACE) {
5257 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5258 				plaintext_pad_len, 15, 0);
5259 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5260 				"Failed to allocate output buffer in mempool");
5261 	}
5262 
5263 	if (verify) {
5264 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5265 			tdata->ciphertext.data);
5266 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5267 					ciphertext_len, buffer);
5268 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5269 			ciphertext_len);
5270 	} else {
5271 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5272 			tdata->plaintext.data);
5273 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5274 					plaintext_len, buffer);
5275 		debug_hexdump(stdout, "plaintext:", plaintext,
5276 			plaintext_len);
5277 	}
5278 	memset(buffer, 0, sizeof(buffer));
5279 
5280 	/* Create SNOW 3G operation */
5281 	retval = create_wireless_algo_auth_cipher_operation(
5282 		tdata->digest.data, tdata->digest.len,
5283 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5284 		tdata->auth_iv.data, tdata->auth_iv.len,
5285 		(tdata->digest.offset_bytes == 0 ?
5286 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5287 			: tdata->digest.offset_bytes),
5288 		tdata->validCipherLenInBits.len,
5289 		tdata->cipher.offset_bits,
5290 		tdata->validAuthLenInBits.len,
5291 		tdata->auth.offset_bits,
5292 		op_mode, 1, verify);
5293 
5294 	if (retval < 0)
5295 		return retval;
5296 
5297 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5298 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5299 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5300 	else
5301 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5302 			ut_params->op);
5303 
5304 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5305 
5306 	ut_params->obuf = (op_mode == IN_PLACE ?
5307 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5308 
5309 	if (verify) {
5310 		if (ut_params->obuf)
5311 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5312 					plaintext_len, buffer);
5313 		else
5314 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5315 					plaintext_len, buffer);
5316 
5317 		debug_hexdump(stdout, "plaintext:", plaintext,
5318 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5319 		debug_hexdump(stdout, "plaintext expected:",
5320 			tdata->plaintext.data,
5321 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5322 	} else {
5323 		if (ut_params->obuf)
5324 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5325 					ciphertext_len, buffer);
5326 		else
5327 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5328 					ciphertext_len, buffer);
5329 
5330 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5331 			ciphertext_len);
5332 		debug_hexdump(stdout, "ciphertext expected:",
5333 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5334 
5335 		if (ut_params->obuf)
5336 			digest = rte_pktmbuf_read(ut_params->obuf,
5337 				(tdata->digest.offset_bytes == 0 ?
5338 				plaintext_pad_len : tdata->digest.offset_bytes),
5339 				tdata->digest.len, digest_buffer);
5340 		else
5341 			digest = rte_pktmbuf_read(ut_params->ibuf,
5342 				(tdata->digest.offset_bytes == 0 ?
5343 				plaintext_pad_len : tdata->digest.offset_bytes),
5344 				tdata->digest.len, digest_buffer);
5345 
5346 		debug_hexdump(stdout, "digest:", digest,
5347 			tdata->digest.len);
5348 		debug_hexdump(stdout, "digest expected:",
5349 			tdata->digest.data, tdata->digest.len);
5350 	}
5351 
5352 	/* Validate obuf */
5353 	if (verify) {
5354 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5355 			plaintext,
5356 			tdata->plaintext.data,
5357 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5358 			 (tdata->digest.len << 3)),
5359 			tdata->cipher.offset_bits,
5360 			"SNOW 3G Plaintext data not as expected");
5361 	} else {
5362 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5363 			ciphertext,
5364 			tdata->ciphertext.data,
5365 			(tdata->validDataLenInBits.len -
5366 			 tdata->cipher.offset_bits),
5367 			tdata->cipher.offset_bits,
5368 			"SNOW 3G Ciphertext data not as expected");
5369 
5370 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5371 			digest,
5372 			tdata->digest.data,
5373 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5374 			"SNOW 3G Generated auth tag not as expected");
5375 	}
5376 	return 0;
5377 }
5378 
5379 static int
5380 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5381 	uint8_t op_mode, uint8_t verify)
5382 {
5383 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5384 	struct crypto_unittest_params *ut_params = &unittest_params;
5385 
5386 	int retval;
5387 
5388 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5389 	unsigned int plaintext_pad_len;
5390 	unsigned int plaintext_len;
5391 	unsigned int ciphertext_pad_len;
5392 	unsigned int ciphertext_len;
5393 
5394 	struct rte_cryptodev_info dev_info;
5395 
5396 	/* Verify the capabilities */
5397 	struct rte_cryptodev_sym_capability_idx cap_idx;
5398 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5399 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5400 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5401 			&cap_idx) == NULL)
5402 		return TEST_SKIPPED;
5403 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5404 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5405 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5406 			&cap_idx) == NULL)
5407 		return TEST_SKIPPED;
5408 
5409 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5410 
5411 	uint64_t feat_flags = dev_info.feature_flags;
5412 
5413 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5414 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5415 		printf("Device doesn't support RAW data-path APIs.\n");
5416 		return TEST_SKIPPED;
5417 	}
5418 
5419 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5420 		return TEST_SKIPPED;
5421 
5422 	if (op_mode == OUT_OF_PLACE) {
5423 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5424 			return TEST_SKIPPED;
5425 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5426 			printf("Device doesn't support digest encrypted.\n");
5427 			return TEST_SKIPPED;
5428 		}
5429 	}
5430 
5431 	/* Create KASUMI session */
5432 	retval = create_wireless_algo_auth_cipher_session(
5433 			ts_params->valid_devs[0],
5434 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5435 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5436 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5437 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5438 			RTE_CRYPTO_AUTH_KASUMI_F9,
5439 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5440 			tdata->key.data, tdata->key.len,
5441 			0, tdata->digest.len,
5442 			tdata->cipher_iv.len);
5443 
5444 	if (retval != 0)
5445 		return retval;
5446 
5447 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5448 	if (op_mode == OUT_OF_PLACE)
5449 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5450 
5451 	/* clear mbuf payload */
5452 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5453 		rte_pktmbuf_tailroom(ut_params->ibuf));
5454 	if (op_mode == OUT_OF_PLACE)
5455 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5456 			rte_pktmbuf_tailroom(ut_params->obuf));
5457 
5458 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5459 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5460 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5461 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5462 
5463 	if (verify) {
5464 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5465 					ciphertext_pad_len);
5466 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5467 		if (op_mode == OUT_OF_PLACE)
5468 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5469 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5470 			ciphertext_len);
5471 	} else {
5472 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5473 					plaintext_pad_len);
5474 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5475 		if (op_mode == OUT_OF_PLACE)
5476 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5477 		debug_hexdump(stdout, "plaintext:", plaintext,
5478 			plaintext_len);
5479 	}
5480 
5481 	/* Create KASUMI operation */
5482 	retval = create_wireless_algo_auth_cipher_operation(
5483 		tdata->digest.data, tdata->digest.len,
5484 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5485 		NULL, 0,
5486 		(tdata->digest.offset_bytes == 0 ?
5487 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5488 			: tdata->digest.offset_bytes),
5489 		tdata->validCipherLenInBits.len,
5490 		tdata->validCipherOffsetInBits.len,
5491 		tdata->validAuthLenInBits.len,
5492 		0,
5493 		op_mode, 0, verify);
5494 
5495 	if (retval < 0)
5496 		return retval;
5497 
5498 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5499 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5500 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5501 	else
5502 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5503 			ut_params->op);
5504 
5505 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5506 
5507 	ut_params->obuf = (op_mode == IN_PLACE ?
5508 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5509 
5510 
5511 	if (verify) {
5512 		if (ut_params->obuf)
5513 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5514 							uint8_t *);
5515 		else
5516 			plaintext = ciphertext;
5517 
5518 		debug_hexdump(stdout, "plaintext:", plaintext,
5519 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5520 		debug_hexdump(stdout, "plaintext expected:",
5521 			tdata->plaintext.data,
5522 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5523 	} else {
5524 		if (ut_params->obuf)
5525 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5526 							uint8_t *);
5527 		else
5528 			ciphertext = plaintext;
5529 
5530 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5531 			ciphertext_len);
5532 		debug_hexdump(stdout, "ciphertext expected:",
5533 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5534 
5535 		ut_params->digest = rte_pktmbuf_mtod(
5536 			ut_params->obuf, uint8_t *) +
5537 			(tdata->digest.offset_bytes == 0 ?
5538 			plaintext_pad_len : tdata->digest.offset_bytes);
5539 
5540 		debug_hexdump(stdout, "digest:", ut_params->digest,
5541 			tdata->digest.len);
5542 		debug_hexdump(stdout, "digest expected:",
5543 			tdata->digest.data, tdata->digest.len);
5544 	}
5545 
5546 	/* Validate obuf */
5547 	if (verify) {
5548 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5549 			plaintext,
5550 			tdata->plaintext.data,
5551 			tdata->plaintext.len >> 3,
5552 			"KASUMI Plaintext data not as expected");
5553 	} else {
5554 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5555 			ciphertext,
5556 			tdata->ciphertext.data,
5557 			tdata->ciphertext.len >> 3,
5558 			"KASUMI Ciphertext data not as expected");
5559 
5560 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5561 			ut_params->digest,
5562 			tdata->digest.data,
5563 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5564 			"KASUMI Generated auth tag not as expected");
5565 	}
5566 	return 0;
5567 }
5568 
5569 static int
5570 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5571 	uint8_t op_mode, uint8_t verify)
5572 {
5573 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5574 	struct crypto_unittest_params *ut_params = &unittest_params;
5575 
5576 	int retval;
5577 
5578 	const uint8_t *plaintext = NULL;
5579 	const uint8_t *ciphertext = NULL;
5580 	const uint8_t *digest = NULL;
5581 	unsigned int plaintext_pad_len;
5582 	unsigned int plaintext_len;
5583 	unsigned int ciphertext_pad_len;
5584 	unsigned int ciphertext_len;
5585 	uint8_t buffer[10000];
5586 	uint8_t digest_buffer[10000];
5587 
5588 	struct rte_cryptodev_info dev_info;
5589 
5590 	/* Verify the capabilities */
5591 	struct rte_cryptodev_sym_capability_idx cap_idx;
5592 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5593 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5594 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5595 			&cap_idx) == NULL)
5596 		return TEST_SKIPPED;
5597 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5598 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5599 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5600 			&cap_idx) == NULL)
5601 		return TEST_SKIPPED;
5602 
5603 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5604 		return TEST_SKIPPED;
5605 
5606 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5607 
5608 	uint64_t feat_flags = dev_info.feature_flags;
5609 
5610 	if (op_mode == IN_PLACE) {
5611 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5612 			printf("Device doesn't support in-place scatter-gather "
5613 					"in both input and output mbufs.\n");
5614 			return TEST_SKIPPED;
5615 		}
5616 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5617 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5618 			printf("Device doesn't support RAW data-path APIs.\n");
5619 			return TEST_SKIPPED;
5620 		}
5621 	} else {
5622 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5623 			return TEST_SKIPPED;
5624 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5625 			printf("Device doesn't support out-of-place scatter-gather "
5626 					"in both input and output mbufs.\n");
5627 			return TEST_SKIPPED;
5628 		}
5629 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5630 			printf("Device doesn't support digest encrypted.\n");
5631 			return TEST_SKIPPED;
5632 		}
5633 	}
5634 
5635 	/* Create KASUMI session */
5636 	retval = create_wireless_algo_auth_cipher_session(
5637 			ts_params->valid_devs[0],
5638 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5639 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5640 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5641 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5642 			RTE_CRYPTO_AUTH_KASUMI_F9,
5643 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5644 			tdata->key.data, tdata->key.len,
5645 			0, tdata->digest.len,
5646 			tdata->cipher_iv.len);
5647 
5648 	if (retval != 0)
5649 		return retval;
5650 
5651 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5652 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5653 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5654 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5655 
5656 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5657 			plaintext_pad_len, 15, 0);
5658 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5659 			"Failed to allocate input buffer in mempool");
5660 
5661 	if (op_mode == OUT_OF_PLACE) {
5662 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5663 				plaintext_pad_len, 15, 0);
5664 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5665 				"Failed to allocate output buffer in mempool");
5666 	}
5667 
5668 	if (verify) {
5669 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5670 			tdata->ciphertext.data);
5671 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5672 					ciphertext_len, buffer);
5673 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5674 			ciphertext_len);
5675 	} else {
5676 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5677 			tdata->plaintext.data);
5678 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5679 					plaintext_len, buffer);
5680 		debug_hexdump(stdout, "plaintext:", plaintext,
5681 			plaintext_len);
5682 	}
5683 	memset(buffer, 0, sizeof(buffer));
5684 
5685 	/* Create KASUMI operation */
5686 	retval = create_wireless_algo_auth_cipher_operation(
5687 		tdata->digest.data, tdata->digest.len,
5688 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5689 		NULL, 0,
5690 		(tdata->digest.offset_bytes == 0 ?
5691 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5692 			: tdata->digest.offset_bytes),
5693 		tdata->validCipherLenInBits.len,
5694 		tdata->validCipherOffsetInBits.len,
5695 		tdata->validAuthLenInBits.len,
5696 		0,
5697 		op_mode, 1, verify);
5698 
5699 	if (retval < 0)
5700 		return retval;
5701 
5702 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5703 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5704 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5705 	else
5706 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5707 			ut_params->op);
5708 
5709 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5710 
5711 	ut_params->obuf = (op_mode == IN_PLACE ?
5712 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5713 
5714 	if (verify) {
5715 		if (ut_params->obuf)
5716 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5717 					plaintext_len, buffer);
5718 		else
5719 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5720 					plaintext_len, buffer);
5721 
5722 		debug_hexdump(stdout, "plaintext:", plaintext,
5723 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5724 		debug_hexdump(stdout, "plaintext expected:",
5725 			tdata->plaintext.data,
5726 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5727 	} else {
5728 		if (ut_params->obuf)
5729 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5730 					ciphertext_len, buffer);
5731 		else
5732 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5733 					ciphertext_len, buffer);
5734 
5735 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5736 			ciphertext_len);
5737 		debug_hexdump(stdout, "ciphertext expected:",
5738 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5739 
5740 		if (ut_params->obuf)
5741 			digest = rte_pktmbuf_read(ut_params->obuf,
5742 				(tdata->digest.offset_bytes == 0 ?
5743 				plaintext_pad_len : tdata->digest.offset_bytes),
5744 				tdata->digest.len, digest_buffer);
5745 		else
5746 			digest = rte_pktmbuf_read(ut_params->ibuf,
5747 				(tdata->digest.offset_bytes == 0 ?
5748 				plaintext_pad_len : tdata->digest.offset_bytes),
5749 				tdata->digest.len, digest_buffer);
5750 
5751 		debug_hexdump(stdout, "digest:", digest,
5752 			tdata->digest.len);
5753 		debug_hexdump(stdout, "digest expected:",
5754 			tdata->digest.data, tdata->digest.len);
5755 	}
5756 
5757 	/* Validate obuf */
5758 	if (verify) {
5759 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5760 			plaintext,
5761 			tdata->plaintext.data,
5762 			tdata->plaintext.len >> 3,
5763 			"KASUMI Plaintext data not as expected");
5764 	} else {
5765 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5766 			ciphertext,
5767 			tdata->ciphertext.data,
5768 			tdata->validDataLenInBits.len,
5769 			"KASUMI Ciphertext data not as expected");
5770 
5771 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5772 			digest,
5773 			tdata->digest.data,
5774 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5775 			"KASUMI Generated auth tag not as expected");
5776 	}
5777 	return 0;
5778 }
5779 
5780 static int
5781 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5782 {
5783 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5784 	struct crypto_unittest_params *ut_params = &unittest_params;
5785 
5786 	int retval;
5787 
5788 	uint8_t *plaintext, *ciphertext;
5789 	unsigned plaintext_pad_len;
5790 	unsigned plaintext_len;
5791 	struct rte_cryptodev_info dev_info;
5792 
5793 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5794 	uint64_t feat_flags = dev_info.feature_flags;
5795 
5796 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5797 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5798 		printf("Device doesn't support RAW data-path APIs.\n");
5799 		return TEST_SKIPPED;
5800 	}
5801 
5802 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5803 		return TEST_SKIPPED;
5804 
5805 	/* Verify the capabilities */
5806 	struct rte_cryptodev_sym_capability_idx cap_idx;
5807 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5808 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5809 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5810 			&cap_idx) == NULL)
5811 		return TEST_SKIPPED;
5812 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5813 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5814 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5815 			&cap_idx) == NULL)
5816 		return TEST_SKIPPED;
5817 
5818 	/* Create KASUMI session */
5819 	retval = create_wireless_algo_cipher_auth_session(
5820 			ts_params->valid_devs[0],
5821 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5822 			RTE_CRYPTO_AUTH_OP_GENERATE,
5823 			RTE_CRYPTO_AUTH_KASUMI_F9,
5824 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5825 			tdata->key.data, tdata->key.len,
5826 			0, tdata->digest.len,
5827 			tdata->cipher_iv.len);
5828 	if (retval != 0)
5829 		return retval;
5830 
5831 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5832 
5833 	/* clear mbuf payload */
5834 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5835 			rte_pktmbuf_tailroom(ut_params->ibuf));
5836 
5837 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5838 	/* Append data which is padded to a multiple of */
5839 	/* the algorithms block size */
5840 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5841 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5842 				plaintext_pad_len);
5843 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5844 
5845 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5846 
5847 	/* Create KASUMI operation */
5848 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5849 				tdata->digest.len, NULL, 0,
5850 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5851 				tdata->cipher_iv.data, tdata->cipher_iv.len,
5852 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5853 				tdata->validCipherOffsetInBits.len,
5854 				tdata->validAuthLenInBits.len,
5855 				0
5856 				);
5857 	if (retval < 0)
5858 		return retval;
5859 
5860 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5861 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5862 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5863 	else
5864 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5865 			ut_params->op);
5866 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5867 
5868 	if (ut_params->op->sym->m_dst)
5869 		ut_params->obuf = ut_params->op->sym->m_dst;
5870 	else
5871 		ut_params->obuf = ut_params->op->sym->m_src;
5872 
5873 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5874 				tdata->validCipherOffsetInBits.len >> 3);
5875 
5876 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5877 			+ plaintext_pad_len;
5878 
5879 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5880 				(tdata->validCipherOffsetInBits.len >> 3);
5881 	/* Validate obuf */
5882 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5883 		ciphertext,
5884 		reference_ciphertext,
5885 		tdata->validCipherLenInBits.len,
5886 		"KASUMI Ciphertext data not as expected");
5887 
5888 	/* Validate obuf */
5889 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5890 		ut_params->digest,
5891 		tdata->digest.data,
5892 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5893 		"KASUMI Generated auth tag not as expected");
5894 	return 0;
5895 }
5896 
5897 static int
5898 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5899 			const enum rte_crypto_cipher_algorithm cipher_algo,
5900 			const uint16_t key_size, const uint16_t iv_size)
5901 {
5902 	struct rte_cryptodev_sym_capability_idx cap_idx;
5903 	const struct rte_cryptodev_symmetric_capability *cap;
5904 
5905 	/* Check if device supports the algorithm */
5906 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5907 	cap_idx.algo.cipher = cipher_algo;
5908 
5909 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5910 			&cap_idx);
5911 
5912 	if (cap == NULL)
5913 		return -1;
5914 
5915 	/* Check if device supports key size and IV size */
5916 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5917 			iv_size) < 0) {
5918 		return -1;
5919 	}
5920 
5921 	return 0;
5922 }
5923 
5924 static int
5925 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5926 			const enum rte_crypto_auth_algorithm auth_algo,
5927 			const uint16_t key_size, const uint16_t iv_size,
5928 			const uint16_t tag_size)
5929 {
5930 	struct rte_cryptodev_sym_capability_idx cap_idx;
5931 	const struct rte_cryptodev_symmetric_capability *cap;
5932 
5933 	/* Check if device supports the algorithm */
5934 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5935 	cap_idx.algo.auth = auth_algo;
5936 
5937 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5938 			&cap_idx);
5939 
5940 	if (cap == NULL)
5941 		return -1;
5942 
5943 	/* Check if device supports key size and IV size */
5944 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5945 			tag_size, iv_size) < 0) {
5946 		return -1;
5947 	}
5948 
5949 	return 0;
5950 }
5951 
5952 static int
5953 test_zuc_encryption(const struct wireless_test_data *tdata)
5954 {
5955 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5956 	struct crypto_unittest_params *ut_params = &unittest_params;
5957 
5958 	int retval;
5959 	uint8_t *plaintext, *ciphertext;
5960 	unsigned plaintext_pad_len;
5961 	unsigned plaintext_len;
5962 	struct rte_cryptodev_info dev_info;
5963 
5964 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5965 	uint64_t feat_flags = dev_info.feature_flags;
5966 
5967 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5968 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5969 		printf("Device doesn't support RAW data-path APIs.\n");
5970 		return TEST_SKIPPED;
5971 	}
5972 
5973 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5974 		return TEST_SKIPPED;
5975 
5976 	/* Check if device supports ZUC EEA3 */
5977 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5978 			tdata->key.len, tdata->cipher_iv.len) < 0)
5979 		return TEST_SKIPPED;
5980 
5981 	/* Create ZUC session */
5982 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5983 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5984 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
5985 					tdata->key.data, tdata->key.len,
5986 					tdata->cipher_iv.len);
5987 	if (retval != 0)
5988 		return retval;
5989 
5990 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5991 
5992 	/* Clear mbuf payload */
5993 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5994 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5995 
5996 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5997 	/* Append data which is padded to a multiple */
5998 	/* of the algorithms block size */
5999 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6000 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6001 				plaintext_pad_len);
6002 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6003 
6004 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6005 
6006 	/* Create ZUC operation */
6007 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6008 					tdata->cipher_iv.len,
6009 					tdata->plaintext.len,
6010 					tdata->validCipherOffsetInBits.len);
6011 	if (retval < 0)
6012 		return retval;
6013 
6014 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6015 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6016 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6017 	else
6018 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6019 						ut_params->op);
6020 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6021 
6022 	ut_params->obuf = ut_params->op->sym->m_dst;
6023 	if (ut_params->obuf)
6024 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6025 	else
6026 		ciphertext = plaintext;
6027 
6028 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6029 
6030 	/* Validate obuf */
6031 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6032 		ciphertext,
6033 		tdata->ciphertext.data,
6034 		tdata->validCipherLenInBits.len,
6035 		"ZUC Ciphertext data not as expected");
6036 	return 0;
6037 }
6038 
6039 static int
6040 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6041 {
6042 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6043 	struct crypto_unittest_params *ut_params = &unittest_params;
6044 
6045 	int retval;
6046 
6047 	unsigned int plaintext_pad_len;
6048 	unsigned int plaintext_len;
6049 	const uint8_t *ciphertext;
6050 	uint8_t ciphertext_buffer[2048];
6051 	struct rte_cryptodev_info dev_info;
6052 
6053 	/* Check if device supports ZUC EEA3 */
6054 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6055 			tdata->key.len, tdata->cipher_iv.len) < 0)
6056 		return TEST_SKIPPED;
6057 
6058 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6059 		return TEST_SKIPPED;
6060 
6061 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6062 
6063 	uint64_t feat_flags = dev_info.feature_flags;
6064 
6065 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6066 		printf("Device doesn't support in-place scatter-gather. "
6067 				"Test Skipped.\n");
6068 		return TEST_SKIPPED;
6069 	}
6070 
6071 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6072 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6073 		printf("Device doesn't support RAW data-path APIs.\n");
6074 		return TEST_SKIPPED;
6075 	}
6076 
6077 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6078 
6079 	/* Append data which is padded to a multiple */
6080 	/* of the algorithms block size */
6081 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6082 
6083 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6084 			plaintext_pad_len, 10, 0);
6085 
6086 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6087 			tdata->plaintext.data);
6088 
6089 	/* Create ZUC session */
6090 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6091 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6092 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6093 			tdata->key.data, tdata->key.len,
6094 			tdata->cipher_iv.len);
6095 	if (retval < 0)
6096 		return retval;
6097 
6098 	/* Clear mbuf payload */
6099 
6100 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6101 
6102 	/* Create ZUC operation */
6103 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6104 			tdata->cipher_iv.len, tdata->plaintext.len,
6105 			tdata->validCipherOffsetInBits.len);
6106 	if (retval < 0)
6107 		return retval;
6108 
6109 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6110 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6111 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6112 	else
6113 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6114 						ut_params->op);
6115 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6116 
6117 	ut_params->obuf = ut_params->op->sym->m_dst;
6118 	if (ut_params->obuf)
6119 		ciphertext = rte_pktmbuf_read(ut_params->obuf,
6120 			0, plaintext_len, ciphertext_buffer);
6121 	else
6122 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6123 			0, plaintext_len, ciphertext_buffer);
6124 
6125 	/* Validate obuf */
6126 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6127 
6128 	/* Validate obuf */
6129 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6130 		ciphertext,
6131 		tdata->ciphertext.data,
6132 		tdata->validCipherLenInBits.len,
6133 		"ZUC Ciphertext data not as expected");
6134 
6135 	return 0;
6136 }
6137 
6138 static int
6139 test_zuc_authentication(const struct wireless_test_data *tdata)
6140 {
6141 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6142 	struct crypto_unittest_params *ut_params = &unittest_params;
6143 
6144 	int retval;
6145 	unsigned plaintext_pad_len;
6146 	unsigned plaintext_len;
6147 	uint8_t *plaintext;
6148 
6149 	struct rte_cryptodev_info dev_info;
6150 
6151 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6152 	uint64_t feat_flags = dev_info.feature_flags;
6153 
6154 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6155 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6156 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6157 		return TEST_SKIPPED;
6158 	}
6159 
6160 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6161 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6162 		printf("Device doesn't support RAW data-path APIs.\n");
6163 		return TEST_SKIPPED;
6164 	}
6165 
6166 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6167 		return TEST_SKIPPED;
6168 
6169 	/* Check if device supports ZUC EIA3 */
6170 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6171 			tdata->key.len, tdata->auth_iv.len,
6172 			tdata->digest.len) < 0)
6173 		return TEST_SKIPPED;
6174 
6175 	/* Create ZUC session */
6176 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6177 			tdata->key.data, tdata->key.len,
6178 			tdata->auth_iv.len, tdata->digest.len,
6179 			RTE_CRYPTO_AUTH_OP_GENERATE,
6180 			RTE_CRYPTO_AUTH_ZUC_EIA3);
6181 	if (retval != 0)
6182 		return retval;
6183 
6184 	/* alloc mbuf and set payload */
6185 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6186 
6187 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6188 	rte_pktmbuf_tailroom(ut_params->ibuf));
6189 
6190 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6191 	/* Append data which is padded to a multiple of */
6192 	/* the algorithms block size */
6193 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6194 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6195 				plaintext_pad_len);
6196 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6197 
6198 	/* Create ZUC operation */
6199 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6200 			tdata->auth_iv.data, tdata->auth_iv.len,
6201 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6202 			tdata->validAuthLenInBits.len,
6203 			0);
6204 	if (retval < 0)
6205 		return retval;
6206 
6207 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6208 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6209 				ut_params->op, 0, 1, 1, 0);
6210 	else
6211 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6212 				ut_params->op);
6213 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6214 	ut_params->obuf = ut_params->op->sym->m_src;
6215 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6216 			+ plaintext_pad_len;
6217 
6218 	/* Validate obuf */
6219 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6220 	ut_params->digest,
6221 	tdata->digest.data,
6222 	tdata->digest.len,
6223 	"ZUC Generated auth tag not as expected");
6224 
6225 	return 0;
6226 }
6227 
6228 static int
6229 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6230 	uint8_t op_mode, uint8_t verify)
6231 {
6232 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6233 	struct crypto_unittest_params *ut_params = &unittest_params;
6234 
6235 	int retval;
6236 
6237 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6238 	unsigned int plaintext_pad_len;
6239 	unsigned int plaintext_len;
6240 	unsigned int ciphertext_pad_len;
6241 	unsigned int ciphertext_len;
6242 
6243 	struct rte_cryptodev_info dev_info;
6244 
6245 	/* Check if device supports ZUC EEA3 */
6246 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6247 			tdata->key.len, tdata->cipher_iv.len) < 0)
6248 		return TEST_SKIPPED;
6249 
6250 	/* Check if device supports ZUC EIA3 */
6251 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6252 			tdata->key.len, tdata->auth_iv.len,
6253 			tdata->digest.len) < 0)
6254 		return TEST_SKIPPED;
6255 
6256 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6257 
6258 	uint64_t feat_flags = dev_info.feature_flags;
6259 
6260 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6261 		printf("Device doesn't support digest encrypted.\n");
6262 		return TEST_SKIPPED;
6263 	}
6264 	if (op_mode == IN_PLACE) {
6265 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6266 			printf("Device doesn't support in-place scatter-gather "
6267 					"in both input and output mbufs.\n");
6268 			return TEST_SKIPPED;
6269 		}
6270 
6271 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6272 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6273 			printf("Device doesn't support RAW data-path APIs.\n");
6274 			return TEST_SKIPPED;
6275 		}
6276 	} else {
6277 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6278 			return TEST_SKIPPED;
6279 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6280 			printf("Device doesn't support out-of-place scatter-gather "
6281 					"in both input and output mbufs.\n");
6282 			return TEST_SKIPPED;
6283 		}
6284 	}
6285 
6286 	/* Create ZUC session */
6287 	retval = create_wireless_algo_auth_cipher_session(
6288 			ts_params->valid_devs[0],
6289 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6290 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6291 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6292 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6293 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6294 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6295 			tdata->key.data, tdata->key.len,
6296 			tdata->auth_iv.len, tdata->digest.len,
6297 			tdata->cipher_iv.len);
6298 
6299 	if (retval != 0)
6300 		return retval;
6301 
6302 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6303 	if (op_mode == OUT_OF_PLACE)
6304 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6305 
6306 	/* clear mbuf payload */
6307 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6308 		rte_pktmbuf_tailroom(ut_params->ibuf));
6309 	if (op_mode == OUT_OF_PLACE)
6310 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6311 			rte_pktmbuf_tailroom(ut_params->obuf));
6312 
6313 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6314 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6315 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6316 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6317 
6318 	if (verify) {
6319 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6320 					ciphertext_pad_len);
6321 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6322 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6323 			ciphertext_len);
6324 	} else {
6325 		/* make sure enough space to cover partial digest verify case */
6326 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6327 					ciphertext_pad_len);
6328 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6329 		debug_hexdump(stdout, "plaintext:", plaintext,
6330 			plaintext_len);
6331 	}
6332 
6333 	if (op_mode == OUT_OF_PLACE)
6334 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6335 
6336 	/* Create ZUC operation */
6337 	retval = create_wireless_algo_auth_cipher_operation(
6338 		tdata->digest.data, tdata->digest.len,
6339 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6340 		tdata->auth_iv.data, tdata->auth_iv.len,
6341 		(tdata->digest.offset_bytes == 0 ?
6342 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6343 			: tdata->digest.offset_bytes),
6344 		tdata->validCipherLenInBits.len,
6345 		tdata->validCipherOffsetInBits.len,
6346 		tdata->validAuthLenInBits.len,
6347 		0,
6348 		op_mode, 0, verify);
6349 
6350 	if (retval < 0)
6351 		return retval;
6352 
6353 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6354 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6355 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6356 	else
6357 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6358 			ut_params->op);
6359 
6360 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6361 
6362 	ut_params->obuf = (op_mode == IN_PLACE ?
6363 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6364 
6365 
6366 	if (verify) {
6367 		if (ut_params->obuf)
6368 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6369 							uint8_t *);
6370 		else
6371 			plaintext = ciphertext;
6372 
6373 		debug_hexdump(stdout, "plaintext:", plaintext,
6374 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6375 		debug_hexdump(stdout, "plaintext expected:",
6376 			tdata->plaintext.data,
6377 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6378 	} else {
6379 		if (ut_params->obuf)
6380 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6381 							uint8_t *);
6382 		else
6383 			ciphertext = plaintext;
6384 
6385 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6386 			ciphertext_len);
6387 		debug_hexdump(stdout, "ciphertext expected:",
6388 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6389 
6390 		ut_params->digest = rte_pktmbuf_mtod(
6391 			ut_params->obuf, uint8_t *) +
6392 			(tdata->digest.offset_bytes == 0 ?
6393 			plaintext_pad_len : tdata->digest.offset_bytes);
6394 
6395 		debug_hexdump(stdout, "digest:", ut_params->digest,
6396 			tdata->digest.len);
6397 		debug_hexdump(stdout, "digest expected:",
6398 			tdata->digest.data, tdata->digest.len);
6399 	}
6400 
6401 	/* Validate obuf */
6402 	if (verify) {
6403 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6404 			plaintext,
6405 			tdata->plaintext.data,
6406 			tdata->plaintext.len >> 3,
6407 			"ZUC Plaintext data not as expected");
6408 	} else {
6409 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6410 			ciphertext,
6411 			tdata->ciphertext.data,
6412 			tdata->ciphertext.len >> 3,
6413 			"ZUC Ciphertext data not as expected");
6414 
6415 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6416 			ut_params->digest,
6417 			tdata->digest.data,
6418 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6419 			"ZUC Generated auth tag not as expected");
6420 	}
6421 	return 0;
6422 }
6423 
6424 static int
6425 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6426 	uint8_t op_mode, uint8_t verify)
6427 {
6428 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6429 	struct crypto_unittest_params *ut_params = &unittest_params;
6430 
6431 	int retval;
6432 
6433 	const uint8_t *plaintext = NULL;
6434 	const uint8_t *ciphertext = NULL;
6435 	const uint8_t *digest = NULL;
6436 	unsigned int plaintext_pad_len;
6437 	unsigned int plaintext_len;
6438 	unsigned int ciphertext_pad_len;
6439 	unsigned int ciphertext_len;
6440 	uint8_t buffer[10000];
6441 	uint8_t digest_buffer[10000];
6442 
6443 	struct rte_cryptodev_info dev_info;
6444 
6445 	/* Check if device supports ZUC EEA3 */
6446 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6447 			tdata->key.len, tdata->cipher_iv.len) < 0)
6448 		return TEST_SKIPPED;
6449 
6450 	/* Check if device supports ZUC EIA3 */
6451 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6452 			tdata->key.len, tdata->auth_iv.len,
6453 			tdata->digest.len) < 0)
6454 		return TEST_SKIPPED;
6455 
6456 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6457 
6458 	uint64_t feat_flags = dev_info.feature_flags;
6459 
6460 	if (op_mode == IN_PLACE) {
6461 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6462 			printf("Device doesn't support in-place scatter-gather "
6463 					"in both input and output mbufs.\n");
6464 			return TEST_SKIPPED;
6465 		}
6466 
6467 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6468 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6469 			printf("Device doesn't support RAW data-path APIs.\n");
6470 			return TEST_SKIPPED;
6471 		}
6472 	} else {
6473 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6474 			return TEST_SKIPPED;
6475 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6476 			printf("Device doesn't support out-of-place scatter-gather "
6477 					"in both input and output mbufs.\n");
6478 			return TEST_SKIPPED;
6479 		}
6480 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6481 			printf("Device doesn't support digest encrypted.\n");
6482 			return TEST_SKIPPED;
6483 		}
6484 	}
6485 
6486 	/* Create ZUC session */
6487 	retval = create_wireless_algo_auth_cipher_session(
6488 			ts_params->valid_devs[0],
6489 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6490 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6491 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6492 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6493 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6494 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6495 			tdata->key.data, tdata->key.len,
6496 			tdata->auth_iv.len, tdata->digest.len,
6497 			tdata->cipher_iv.len);
6498 
6499 	if (retval != 0)
6500 		return retval;
6501 
6502 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6503 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6504 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6505 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6506 
6507 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6508 			plaintext_pad_len, 15, 0);
6509 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6510 			"Failed to allocate input buffer in mempool");
6511 
6512 	if (op_mode == OUT_OF_PLACE) {
6513 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6514 				plaintext_pad_len, 15, 0);
6515 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6516 				"Failed to allocate output buffer in mempool");
6517 	}
6518 
6519 	if (verify) {
6520 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6521 			tdata->ciphertext.data);
6522 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6523 					ciphertext_len, buffer);
6524 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6525 			ciphertext_len);
6526 	} else {
6527 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6528 			tdata->plaintext.data);
6529 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6530 					plaintext_len, buffer);
6531 		debug_hexdump(stdout, "plaintext:", plaintext,
6532 			plaintext_len);
6533 	}
6534 	memset(buffer, 0, sizeof(buffer));
6535 
6536 	/* Create ZUC operation */
6537 	retval = create_wireless_algo_auth_cipher_operation(
6538 		tdata->digest.data, tdata->digest.len,
6539 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6540 		tdata->auth_iv.data, tdata->auth_iv.len,
6541 		(tdata->digest.offset_bytes == 0 ?
6542 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6543 			: tdata->digest.offset_bytes),
6544 		tdata->validCipherLenInBits.len,
6545 		tdata->validCipherOffsetInBits.len,
6546 		tdata->validAuthLenInBits.len,
6547 		0,
6548 		op_mode, 1, verify);
6549 
6550 	if (retval < 0)
6551 		return retval;
6552 
6553 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6554 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6555 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6556 	else
6557 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6558 			ut_params->op);
6559 
6560 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6561 
6562 	ut_params->obuf = (op_mode == IN_PLACE ?
6563 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6564 
6565 	if (verify) {
6566 		if (ut_params->obuf)
6567 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6568 					plaintext_len, buffer);
6569 		else
6570 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6571 					plaintext_len, buffer);
6572 
6573 		debug_hexdump(stdout, "plaintext:", plaintext,
6574 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6575 		debug_hexdump(stdout, "plaintext expected:",
6576 			tdata->plaintext.data,
6577 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6578 	} else {
6579 		if (ut_params->obuf)
6580 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6581 					ciphertext_len, buffer);
6582 		else
6583 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6584 					ciphertext_len, buffer);
6585 
6586 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6587 			ciphertext_len);
6588 		debug_hexdump(stdout, "ciphertext expected:",
6589 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6590 
6591 		if (ut_params->obuf)
6592 			digest = rte_pktmbuf_read(ut_params->obuf,
6593 				(tdata->digest.offset_bytes == 0 ?
6594 				plaintext_pad_len : tdata->digest.offset_bytes),
6595 				tdata->digest.len, digest_buffer);
6596 		else
6597 			digest = rte_pktmbuf_read(ut_params->ibuf,
6598 				(tdata->digest.offset_bytes == 0 ?
6599 				plaintext_pad_len : tdata->digest.offset_bytes),
6600 				tdata->digest.len, digest_buffer);
6601 
6602 		debug_hexdump(stdout, "digest:", digest,
6603 			tdata->digest.len);
6604 		debug_hexdump(stdout, "digest expected:",
6605 			tdata->digest.data, tdata->digest.len);
6606 	}
6607 
6608 	/* Validate obuf */
6609 	if (verify) {
6610 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6611 			plaintext,
6612 			tdata->plaintext.data,
6613 			tdata->plaintext.len >> 3,
6614 			"ZUC Plaintext data not as expected");
6615 	} else {
6616 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6617 			ciphertext,
6618 			tdata->ciphertext.data,
6619 			tdata->validDataLenInBits.len,
6620 			"ZUC Ciphertext data not as expected");
6621 
6622 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6623 			digest,
6624 			tdata->digest.data,
6625 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6626 			"ZUC Generated auth tag not as expected");
6627 	}
6628 	return 0;
6629 }
6630 
6631 static int
6632 test_kasumi_encryption_test_case_1(void)
6633 {
6634 	return test_kasumi_encryption(&kasumi_test_case_1);
6635 }
6636 
6637 static int
6638 test_kasumi_encryption_test_case_1_sgl(void)
6639 {
6640 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6641 }
6642 
6643 static int
6644 test_kasumi_encryption_test_case_1_oop(void)
6645 {
6646 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
6647 }
6648 
6649 static int
6650 test_kasumi_encryption_test_case_1_oop_sgl(void)
6651 {
6652 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6653 }
6654 
6655 static int
6656 test_kasumi_encryption_test_case_2(void)
6657 {
6658 	return test_kasumi_encryption(&kasumi_test_case_2);
6659 }
6660 
6661 static int
6662 test_kasumi_encryption_test_case_3(void)
6663 {
6664 	return test_kasumi_encryption(&kasumi_test_case_3);
6665 }
6666 
6667 static int
6668 test_kasumi_encryption_test_case_4(void)
6669 {
6670 	return test_kasumi_encryption(&kasumi_test_case_4);
6671 }
6672 
6673 static int
6674 test_kasumi_encryption_test_case_5(void)
6675 {
6676 	return test_kasumi_encryption(&kasumi_test_case_5);
6677 }
6678 
6679 static int
6680 test_kasumi_decryption_test_case_1(void)
6681 {
6682 	return test_kasumi_decryption(&kasumi_test_case_1);
6683 }
6684 
6685 static int
6686 test_kasumi_decryption_test_case_1_oop(void)
6687 {
6688 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
6689 }
6690 
6691 static int
6692 test_kasumi_decryption_test_case_2(void)
6693 {
6694 	return test_kasumi_decryption(&kasumi_test_case_2);
6695 }
6696 
6697 static int
6698 test_kasumi_decryption_test_case_3(void)
6699 {
6700 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6701 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6702 		return TEST_SKIPPED;
6703 	return test_kasumi_decryption(&kasumi_test_case_3);
6704 }
6705 
6706 static int
6707 test_kasumi_decryption_test_case_4(void)
6708 {
6709 	return test_kasumi_decryption(&kasumi_test_case_4);
6710 }
6711 
6712 static int
6713 test_kasumi_decryption_test_case_5(void)
6714 {
6715 	return test_kasumi_decryption(&kasumi_test_case_5);
6716 }
6717 static int
6718 test_snow3g_encryption_test_case_1(void)
6719 {
6720 	return test_snow3g_encryption(&snow3g_test_case_1);
6721 }
6722 
6723 static int
6724 test_snow3g_encryption_test_case_1_oop(void)
6725 {
6726 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
6727 }
6728 
6729 static int
6730 test_snow3g_encryption_test_case_1_oop_sgl(void)
6731 {
6732 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
6733 }
6734 
6735 static int
6736 test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
6737 {
6738 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
6739 }
6740 
6741 static int
6742 test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
6743 {
6744 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
6745 }
6746 
6747 static int
6748 test_snow3g_encryption_test_case_1_offset_oop(void)
6749 {
6750 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6751 }
6752 
6753 static int
6754 test_snow3g_encryption_test_case_2(void)
6755 {
6756 	return test_snow3g_encryption(&snow3g_test_case_2);
6757 }
6758 
6759 static int
6760 test_snow3g_encryption_test_case_3(void)
6761 {
6762 	return test_snow3g_encryption(&snow3g_test_case_3);
6763 }
6764 
6765 static int
6766 test_snow3g_encryption_test_case_4(void)
6767 {
6768 	return test_snow3g_encryption(&snow3g_test_case_4);
6769 }
6770 
6771 static int
6772 test_snow3g_encryption_test_case_5(void)
6773 {
6774 	return test_snow3g_encryption(&snow3g_test_case_5);
6775 }
6776 
6777 static int
6778 test_snow3g_decryption_test_case_1(void)
6779 {
6780 	return test_snow3g_decryption(&snow3g_test_case_1);
6781 }
6782 
6783 static int
6784 test_snow3g_decryption_test_case_1_oop(void)
6785 {
6786 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
6787 }
6788 
6789 static int
6790 test_snow3g_decryption_test_case_2(void)
6791 {
6792 	return test_snow3g_decryption(&snow3g_test_case_2);
6793 }
6794 
6795 static int
6796 test_snow3g_decryption_test_case_3(void)
6797 {
6798 	return test_snow3g_decryption(&snow3g_test_case_3);
6799 }
6800 
6801 static int
6802 test_snow3g_decryption_test_case_4(void)
6803 {
6804 	return test_snow3g_decryption(&snow3g_test_case_4);
6805 }
6806 
6807 static int
6808 test_snow3g_decryption_test_case_5(void)
6809 {
6810 	return test_snow3g_decryption(&snow3g_test_case_5);
6811 }
6812 
6813 /*
6814  * Function prepares snow3g_hash_test_data from snow3g_test_data.
6815  * Pattern digest from snow3g_test_data must be allocated as
6816  * 4 last bytes in plaintext.
6817  */
6818 static void
6819 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6820 		struct snow3g_hash_test_data *output)
6821 {
6822 	if ((pattern != NULL) && (output != NULL)) {
6823 		output->key.len = pattern->key.len;
6824 
6825 		memcpy(output->key.data,
6826 		pattern->key.data, pattern->key.len);
6827 
6828 		output->auth_iv.len = pattern->auth_iv.len;
6829 
6830 		memcpy(output->auth_iv.data,
6831 		pattern->auth_iv.data, pattern->auth_iv.len);
6832 
6833 		output->plaintext.len = pattern->plaintext.len;
6834 
6835 		memcpy(output->plaintext.data,
6836 		pattern->plaintext.data, pattern->plaintext.len >> 3);
6837 
6838 		output->digest.len = pattern->digest.len;
6839 
6840 		memcpy(output->digest.data,
6841 		&pattern->plaintext.data[pattern->digest.offset_bytes],
6842 		pattern->digest.len);
6843 
6844 		output->validAuthLenInBits.len =
6845 		pattern->validAuthLenInBits.len;
6846 	}
6847 }
6848 
6849 /*
6850  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6851  */
6852 static int
6853 test_snow3g_decryption_with_digest_test_case_1(void)
6854 {
6855 	struct snow3g_hash_test_data snow3g_hash_data;
6856 	struct rte_cryptodev_info dev_info;
6857 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6858 
6859 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6860 	uint64_t feat_flags = dev_info.feature_flags;
6861 
6862 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6863 		printf("Device doesn't support encrypted digest operations.\n");
6864 		return TEST_SKIPPED;
6865 	}
6866 
6867 	/*
6868 	 * Function prepare data for hash verification test case.
6869 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
6870 	 */
6871 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6872 
6873 	return test_snow3g_decryption(&snow3g_test_case_7) &
6874 			test_snow3g_authentication_verify(&snow3g_hash_data);
6875 }
6876 
6877 static int
6878 test_snow3g_cipher_auth_test_case_1(void)
6879 {
6880 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
6881 }
6882 
6883 static int
6884 test_snow3g_auth_cipher_test_case_1(void)
6885 {
6886 	return test_snow3g_auth_cipher(
6887 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6888 }
6889 
6890 static int
6891 test_snow3g_auth_cipher_test_case_2(void)
6892 {
6893 	return test_snow3g_auth_cipher(
6894 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6895 }
6896 
6897 static int
6898 test_snow3g_auth_cipher_test_case_2_oop(void)
6899 {
6900 	return test_snow3g_auth_cipher(
6901 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6902 }
6903 
6904 static int
6905 test_snow3g_auth_cipher_part_digest_enc(void)
6906 {
6907 	return test_snow3g_auth_cipher(
6908 		&snow3g_auth_cipher_partial_digest_encryption,
6909 			IN_PLACE, 0);
6910 }
6911 
6912 static int
6913 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6914 {
6915 	return test_snow3g_auth_cipher(
6916 		&snow3g_auth_cipher_partial_digest_encryption,
6917 			OUT_OF_PLACE, 0);
6918 }
6919 
6920 static int
6921 test_snow3g_auth_cipher_test_case_3_sgl(void)
6922 {
6923 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6924 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6925 		return TEST_SKIPPED;
6926 	return test_snow3g_auth_cipher_sgl(
6927 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6928 }
6929 
6930 static int
6931 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6932 {
6933 	return test_snow3g_auth_cipher_sgl(
6934 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6935 }
6936 
6937 static int
6938 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6939 {
6940 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6941 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6942 		return TEST_SKIPPED;
6943 	return test_snow3g_auth_cipher_sgl(
6944 		&snow3g_auth_cipher_partial_digest_encryption,
6945 			IN_PLACE, 0);
6946 }
6947 
6948 static int
6949 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6950 {
6951 	return test_snow3g_auth_cipher_sgl(
6952 		&snow3g_auth_cipher_partial_digest_encryption,
6953 			OUT_OF_PLACE, 0);
6954 }
6955 
6956 static int
6957 test_snow3g_auth_cipher_total_digest_enc_1(void)
6958 {
6959 	return test_snow3g_auth_cipher(
6960 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
6961 }
6962 
6963 static int
6964 test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
6965 {
6966 	return test_snow3g_auth_cipher(
6967 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
6968 }
6969 
6970 static int
6971 test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
6972 {
6973 	return test_snow3g_auth_cipher_sgl(
6974 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
6975 }
6976 
6977 static int
6978 test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
6979 {
6980 	return test_snow3g_auth_cipher_sgl(
6981 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
6982 }
6983 
6984 static int
6985 test_snow3g_auth_cipher_verify_test_case_1(void)
6986 {
6987 	return test_snow3g_auth_cipher(
6988 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6989 }
6990 
6991 static int
6992 test_snow3g_auth_cipher_verify_test_case_2(void)
6993 {
6994 	return test_snow3g_auth_cipher(
6995 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6996 }
6997 
6998 static int
6999 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7000 {
7001 	return test_snow3g_auth_cipher(
7002 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7003 }
7004 
7005 static int
7006 test_snow3g_auth_cipher_verify_part_digest_enc(void)
7007 {
7008 	return test_snow3g_auth_cipher(
7009 		&snow3g_auth_cipher_partial_digest_encryption,
7010 			IN_PLACE, 1);
7011 }
7012 
7013 static int
7014 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7015 {
7016 	return test_snow3g_auth_cipher(
7017 		&snow3g_auth_cipher_partial_digest_encryption,
7018 			OUT_OF_PLACE, 1);
7019 }
7020 
7021 static int
7022 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7023 {
7024 	return test_snow3g_auth_cipher_sgl(
7025 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7026 }
7027 
7028 static int
7029 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7030 {
7031 	return test_snow3g_auth_cipher_sgl(
7032 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7033 }
7034 
7035 static int
7036 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7037 {
7038 	return test_snow3g_auth_cipher_sgl(
7039 		&snow3g_auth_cipher_partial_digest_encryption,
7040 			IN_PLACE, 1);
7041 }
7042 
7043 static int
7044 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7045 {
7046 	return test_snow3g_auth_cipher_sgl(
7047 		&snow3g_auth_cipher_partial_digest_encryption,
7048 			OUT_OF_PLACE, 1);
7049 }
7050 
7051 static int
7052 test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7053 {
7054 	return test_snow3g_auth_cipher(
7055 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7056 }
7057 
7058 static int
7059 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7060 {
7061 	return test_snow3g_auth_cipher(
7062 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7063 }
7064 
7065 static int
7066 test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7067 {
7068 	return test_snow3g_auth_cipher_sgl(
7069 		&snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7070 }
7071 
7072 static int
7073 test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7074 {
7075 	return test_snow3g_auth_cipher_sgl(
7076 		&snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7077 }
7078 
7079 static int
7080 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7081 {
7082 	return test_snow3g_auth_cipher(
7083 		&snow3g_test_case_7, IN_PLACE, 0);
7084 }
7085 
7086 static int
7087 test_kasumi_auth_cipher_test_case_1(void)
7088 {
7089 	return test_kasumi_auth_cipher(
7090 		&kasumi_test_case_3, IN_PLACE, 0);
7091 }
7092 
7093 static int
7094 test_kasumi_auth_cipher_test_case_2(void)
7095 {
7096 	return test_kasumi_auth_cipher(
7097 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7098 }
7099 
7100 static int
7101 test_kasumi_auth_cipher_test_case_2_oop(void)
7102 {
7103 	return test_kasumi_auth_cipher(
7104 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7105 }
7106 
7107 static int
7108 test_kasumi_auth_cipher_test_case_2_sgl(void)
7109 {
7110 	return test_kasumi_auth_cipher_sgl(
7111 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7112 }
7113 
7114 static int
7115 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7116 {
7117 	return test_kasumi_auth_cipher_sgl(
7118 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7119 }
7120 
7121 static int
7122 test_kasumi_auth_cipher_verify_test_case_1(void)
7123 {
7124 	return test_kasumi_auth_cipher(
7125 		&kasumi_test_case_3, IN_PLACE, 1);
7126 }
7127 
7128 static int
7129 test_kasumi_auth_cipher_verify_test_case_2(void)
7130 {
7131 	return test_kasumi_auth_cipher(
7132 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7133 }
7134 
7135 static int
7136 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7137 {
7138 	return test_kasumi_auth_cipher(
7139 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7140 }
7141 
7142 static int
7143 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7144 {
7145 	return test_kasumi_auth_cipher_sgl(
7146 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7147 }
7148 
7149 static int
7150 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7151 {
7152 	return test_kasumi_auth_cipher_sgl(
7153 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7154 }
7155 
7156 static int
7157 test_kasumi_cipher_auth_test_case_1(void)
7158 {
7159 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7160 }
7161 
7162 static int
7163 test_zuc_encryption_test_case_1(void)
7164 {
7165 	return test_zuc_encryption(&zuc_test_case_cipher_193b);
7166 }
7167 
7168 static int
7169 test_zuc_encryption_test_case_2(void)
7170 {
7171 	return test_zuc_encryption(&zuc_test_case_cipher_800b);
7172 }
7173 
7174 static int
7175 test_zuc_encryption_test_case_3(void)
7176 {
7177 	return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7178 }
7179 
7180 static int
7181 test_zuc_encryption_test_case_4(void)
7182 {
7183 	return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7184 }
7185 
7186 static int
7187 test_zuc_encryption_test_case_5(void)
7188 {
7189 	return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7190 }
7191 
7192 static int
7193 test_zuc_encryption_test_case_6_sgl(void)
7194 {
7195 	return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7196 }
7197 
7198 static int
7199 test_zuc_hash_generate_test_case_1(void)
7200 {
7201 	return test_zuc_authentication(&zuc_test_case_auth_1b);
7202 }
7203 
7204 static int
7205 test_zuc_hash_generate_test_case_2(void)
7206 {
7207 	return test_zuc_authentication(&zuc_test_case_auth_90b);
7208 }
7209 
7210 static int
7211 test_zuc_hash_generate_test_case_3(void)
7212 {
7213 	return test_zuc_authentication(&zuc_test_case_auth_577b);
7214 }
7215 
7216 static int
7217 test_zuc_hash_generate_test_case_4(void)
7218 {
7219 	return test_zuc_authentication(&zuc_test_case_auth_2079b);
7220 }
7221 
7222 static int
7223 test_zuc_hash_generate_test_case_5(void)
7224 {
7225 	return test_zuc_authentication(&zuc_test_auth_5670b);
7226 }
7227 
7228 static int
7229 test_zuc_hash_generate_test_case_6(void)
7230 {
7231 	return test_zuc_authentication(&zuc_test_case_auth_128b);
7232 }
7233 
7234 static int
7235 test_zuc_hash_generate_test_case_7(void)
7236 {
7237 	return test_zuc_authentication(&zuc_test_case_auth_2080b);
7238 }
7239 
7240 static int
7241 test_zuc_hash_generate_test_case_8(void)
7242 {
7243 	return test_zuc_authentication(&zuc_test_case_auth_584b);
7244 }
7245 
7246 static int
7247 test_zuc_hash_generate_test_case_9(void)
7248 {
7249 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7250 }
7251 
7252 static int
7253 test_zuc_hash_generate_test_case_10(void)
7254 {
7255 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7256 }
7257 
7258 static int
7259 test_zuc_hash_generate_test_case_11(void)
7260 {
7261 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7262 }
7263 
7264 static int
7265 test_zuc_cipher_auth_test_case_1(void)
7266 {
7267 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7268 }
7269 
7270 static int
7271 test_zuc_cipher_auth_test_case_2(void)
7272 {
7273 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7274 }
7275 
7276 static int
7277 test_zuc_auth_cipher_test_case_1(void)
7278 {
7279 	return test_zuc_auth_cipher(
7280 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7281 }
7282 
7283 static int
7284 test_zuc_auth_cipher_test_case_1_oop(void)
7285 {
7286 	return test_zuc_auth_cipher(
7287 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7288 }
7289 
7290 static int
7291 test_zuc_auth_cipher_test_case_1_sgl(void)
7292 {
7293 	return test_zuc_auth_cipher_sgl(
7294 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7295 }
7296 
7297 static int
7298 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7299 {
7300 	return test_zuc_auth_cipher_sgl(
7301 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7302 }
7303 
7304 static int
7305 test_zuc_auth_cipher_test_case_2(void)
7306 {
7307 	return test_zuc_auth_cipher(
7308 		&zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7309 }
7310 
7311 static int
7312 test_zuc_auth_cipher_test_case_2_oop(void)
7313 {
7314 	return test_zuc_auth_cipher(
7315 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7316 }
7317 
7318 static int
7319 test_zuc_auth_cipher_verify_test_case_1(void)
7320 {
7321 	return test_zuc_auth_cipher(
7322 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7323 }
7324 
7325 static int
7326 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7327 {
7328 	return test_zuc_auth_cipher(
7329 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7330 }
7331 
7332 static int
7333 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7334 {
7335 	return test_zuc_auth_cipher_sgl(
7336 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7337 }
7338 
7339 static int
7340 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7341 {
7342 	return test_zuc_auth_cipher_sgl(
7343 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7344 }
7345 
7346 static int
7347 test_zuc_auth_cipher_verify_test_case_2(void)
7348 {
7349 	return test_zuc_auth_cipher(
7350 		&zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7351 }
7352 
7353 static int
7354 test_zuc_auth_cipher_verify_test_case_2_oop(void)
7355 {
7356 	return test_zuc_auth_cipher(
7357 		&zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7358 }
7359 
7360 static int
7361 test_zuc256_encryption_test_case_1(void)
7362 {
7363 	return test_zuc_encryption(&zuc256_test_case_cipher_1);
7364 }
7365 
7366 static int
7367 test_zuc256_encryption_test_case_2(void)
7368 {
7369 	return test_zuc_encryption(&zuc256_test_case_cipher_2);
7370 }
7371 
7372 static int
7373 test_zuc256_authentication_test_case_1(void)
7374 {
7375 	return test_zuc_authentication(&zuc256_test_case_auth_1);
7376 }
7377 
7378 static int
7379 test_zuc256_authentication_test_case_2(void)
7380 {
7381 	return test_zuc_authentication(&zuc256_test_case_auth_2);
7382 }
7383 
7384 static int
7385 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7386 {
7387 	uint8_t dev_id = testsuite_params.valid_devs[0];
7388 
7389 	struct rte_cryptodev_sym_capability_idx cap_idx;
7390 
7391 	/* Check if device supports particular cipher algorithm */
7392 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7393 	cap_idx.algo.cipher = tdata->cipher_algo;
7394 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7395 		return TEST_SKIPPED;
7396 
7397 	/* Check if device supports particular hash algorithm */
7398 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7399 	cap_idx.algo.auth = tdata->auth_algo;
7400 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7401 		return TEST_SKIPPED;
7402 
7403 	return 0;
7404 }
7405 
7406 static int
7407 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7408 	uint8_t op_mode, uint8_t verify)
7409 {
7410 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7411 	struct crypto_unittest_params *ut_params = &unittest_params;
7412 
7413 	int retval;
7414 
7415 	uint8_t *plaintext = NULL, *ciphertext = NULL;
7416 	unsigned int plaintext_pad_len;
7417 	unsigned int plaintext_len;
7418 	unsigned int ciphertext_pad_len;
7419 	unsigned int ciphertext_len;
7420 
7421 	struct rte_cryptodev_info dev_info;
7422 	struct rte_crypto_op *op;
7423 
7424 	/* Check if device supports particular algorithms separately */
7425 	if (test_mixed_check_if_unsupported(tdata))
7426 		return TEST_SKIPPED;
7427 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7428 		return TEST_SKIPPED;
7429 
7430 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7431 
7432 	uint64_t feat_flags = dev_info.feature_flags;
7433 
7434 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7435 		printf("Device doesn't support digest encrypted.\n");
7436 		return TEST_SKIPPED;
7437 	}
7438 
7439 	/* Create the session */
7440 	if (verify)
7441 		retval = create_wireless_algo_cipher_auth_session(
7442 				ts_params->valid_devs[0],
7443 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
7444 				RTE_CRYPTO_AUTH_OP_VERIFY,
7445 				tdata->auth_algo,
7446 				tdata->cipher_algo,
7447 				tdata->auth_key.data, tdata->auth_key.len,
7448 				tdata->auth_iv.len, tdata->digest_enc.len,
7449 				tdata->cipher_iv.len);
7450 	else
7451 		retval = create_wireless_algo_auth_cipher_session(
7452 				ts_params->valid_devs[0],
7453 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7454 				RTE_CRYPTO_AUTH_OP_GENERATE,
7455 				tdata->auth_algo,
7456 				tdata->cipher_algo,
7457 				tdata->auth_key.data, tdata->auth_key.len,
7458 				tdata->auth_iv.len, tdata->digest_enc.len,
7459 				tdata->cipher_iv.len);
7460 	if (retval != 0)
7461 		return retval;
7462 
7463 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7464 	if (op_mode == OUT_OF_PLACE)
7465 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7466 
7467 	/* clear mbuf payload */
7468 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7469 		rte_pktmbuf_tailroom(ut_params->ibuf));
7470 	if (op_mode == OUT_OF_PLACE) {
7471 
7472 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7473 				rte_pktmbuf_tailroom(ut_params->obuf));
7474 	}
7475 
7476 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7477 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7478 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7479 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7480 
7481 	if (verify) {
7482 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7483 				ciphertext_pad_len);
7484 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7485 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7486 				ciphertext_len);
7487 	} else {
7488 		/* make sure enough space to cover partial digest verify case */
7489 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7490 				ciphertext_pad_len);
7491 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7492 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7493 	}
7494 
7495 	if (op_mode == OUT_OF_PLACE)
7496 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7497 
7498 	/* Create the operation */
7499 	retval = create_wireless_algo_auth_cipher_operation(
7500 			tdata->digest_enc.data, tdata->digest_enc.len,
7501 			tdata->cipher_iv.data, tdata->cipher_iv.len,
7502 			tdata->auth_iv.data, tdata->auth_iv.len,
7503 			(tdata->digest_enc.offset == 0 ?
7504 				plaintext_pad_len
7505 				: tdata->digest_enc.offset),
7506 			tdata->validCipherLen.len_bits,
7507 			tdata->cipher.offset_bits,
7508 			tdata->validAuthLen.len_bits,
7509 			tdata->auth.offset_bits,
7510 			op_mode, 0, verify);
7511 
7512 	if (retval < 0)
7513 		return retval;
7514 
7515 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7516 
7517 	/* Check if the op failed because the device doesn't */
7518 	/* support this particular combination of algorithms */
7519 	if (op == NULL && ut_params->op->status ==
7520 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7521 		printf("Device doesn't support this mixed combination. "
7522 				"Test Skipped.\n");
7523 		return TEST_SKIPPED;
7524 	}
7525 	ut_params->op = op;
7526 
7527 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7528 
7529 	ut_params->obuf = (op_mode == IN_PLACE ?
7530 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7531 
7532 	if (verify) {
7533 		if (ut_params->obuf)
7534 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7535 							uint8_t *);
7536 		else
7537 			plaintext = ciphertext +
7538 					(tdata->cipher.offset_bits >> 3);
7539 
7540 		debug_hexdump(stdout, "plaintext:", plaintext,
7541 				tdata->plaintext.len_bits >> 3);
7542 		debug_hexdump(stdout, "plaintext expected:",
7543 				tdata->plaintext.data,
7544 				tdata->plaintext.len_bits >> 3);
7545 	} else {
7546 		if (ut_params->obuf)
7547 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7548 					uint8_t *);
7549 		else
7550 			ciphertext = plaintext;
7551 
7552 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7553 				ciphertext_len);
7554 		debug_hexdump(stdout, "ciphertext expected:",
7555 				tdata->ciphertext.data,
7556 				tdata->ciphertext.len_bits >> 3);
7557 
7558 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7559 				+ (tdata->digest_enc.offset == 0 ?
7560 		plaintext_pad_len : tdata->digest_enc.offset);
7561 
7562 		debug_hexdump(stdout, "digest:", ut_params->digest,
7563 				tdata->digest_enc.len);
7564 		debug_hexdump(stdout, "digest expected:",
7565 				tdata->digest_enc.data,
7566 				tdata->digest_enc.len);
7567 	}
7568 
7569 	if (!verify) {
7570 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7571 				ut_params->digest,
7572 				tdata->digest_enc.data,
7573 				tdata->digest_enc.len,
7574 				"Generated auth tag not as expected");
7575 	}
7576 
7577 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7578 		if (verify) {
7579 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7580 					plaintext,
7581 					tdata->plaintext.data,
7582 					tdata->plaintext.len_bits >> 3,
7583 					"Plaintext data not as expected");
7584 		} else {
7585 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7586 					ciphertext,
7587 					tdata->ciphertext.data,
7588 					tdata->validDataLen.len_bits,
7589 					"Ciphertext data not as expected");
7590 		}
7591 	}
7592 
7593 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7594 			"crypto op processing failed");
7595 
7596 	return 0;
7597 }
7598 
7599 static int
7600 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7601 	uint8_t op_mode, uint8_t verify)
7602 {
7603 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7604 	struct crypto_unittest_params *ut_params = &unittest_params;
7605 
7606 	int retval;
7607 
7608 	const uint8_t *plaintext = NULL;
7609 	const uint8_t *ciphertext = NULL;
7610 	const uint8_t *digest = NULL;
7611 	unsigned int plaintext_pad_len;
7612 	unsigned int plaintext_len;
7613 	unsigned int ciphertext_pad_len;
7614 	unsigned int ciphertext_len;
7615 	uint8_t buffer[10000];
7616 	uint8_t digest_buffer[10000];
7617 
7618 	struct rte_cryptodev_info dev_info;
7619 	struct rte_crypto_op *op;
7620 
7621 	/* Check if device supports particular algorithms */
7622 	if (test_mixed_check_if_unsupported(tdata))
7623 		return TEST_SKIPPED;
7624 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7625 		return TEST_SKIPPED;
7626 
7627 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7628 
7629 	uint64_t feat_flags = dev_info.feature_flags;
7630 
7631 	if (op_mode == IN_PLACE) {
7632 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7633 			printf("Device doesn't support in-place scatter-gather "
7634 					"in both input and output mbufs.\n");
7635 			return TEST_SKIPPED;
7636 		}
7637 	} else {
7638 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7639 			printf("Device doesn't support out-of-place scatter-gather "
7640 					"in both input and output mbufs.\n");
7641 			return TEST_SKIPPED;
7642 		}
7643 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7644 			printf("Device doesn't support digest encrypted.\n");
7645 			return TEST_SKIPPED;
7646 		}
7647 	}
7648 
7649 	/* Create the session */
7650 	if (verify)
7651 		retval = create_wireless_algo_cipher_auth_session(
7652 				ts_params->valid_devs[0],
7653 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
7654 				RTE_CRYPTO_AUTH_OP_VERIFY,
7655 				tdata->auth_algo,
7656 				tdata->cipher_algo,
7657 				tdata->auth_key.data, tdata->auth_key.len,
7658 				tdata->auth_iv.len, tdata->digest_enc.len,
7659 				tdata->cipher_iv.len);
7660 	else
7661 		retval = create_wireless_algo_auth_cipher_session(
7662 				ts_params->valid_devs[0],
7663 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7664 				RTE_CRYPTO_AUTH_OP_GENERATE,
7665 				tdata->auth_algo,
7666 				tdata->cipher_algo,
7667 				tdata->auth_key.data, tdata->auth_key.len,
7668 				tdata->auth_iv.len, tdata->digest_enc.len,
7669 				tdata->cipher_iv.len);
7670 	if (retval != 0)
7671 		return retval;
7672 
7673 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7674 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7675 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7676 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7677 
7678 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7679 			ciphertext_pad_len, 15, 0);
7680 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7681 			"Failed to allocate input buffer in mempool");
7682 
7683 	if (op_mode == OUT_OF_PLACE) {
7684 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7685 				plaintext_pad_len, 15, 0);
7686 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
7687 				"Failed to allocate output buffer in mempool");
7688 	}
7689 
7690 	if (verify) {
7691 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7692 			tdata->ciphertext.data);
7693 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7694 					ciphertext_len, buffer);
7695 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7696 			ciphertext_len);
7697 	} else {
7698 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7699 			tdata->plaintext.data);
7700 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7701 					plaintext_len, buffer);
7702 		debug_hexdump(stdout, "plaintext:", plaintext,
7703 			plaintext_len);
7704 	}
7705 	memset(buffer, 0, sizeof(buffer));
7706 
7707 	/* Create the operation */
7708 	retval = create_wireless_algo_auth_cipher_operation(
7709 			tdata->digest_enc.data, tdata->digest_enc.len,
7710 			tdata->cipher_iv.data, tdata->cipher_iv.len,
7711 			tdata->auth_iv.data, tdata->auth_iv.len,
7712 			(tdata->digest_enc.offset == 0 ?
7713 				plaintext_pad_len
7714 				: tdata->digest_enc.offset),
7715 			tdata->validCipherLen.len_bits,
7716 			tdata->cipher.offset_bits,
7717 			tdata->validAuthLen.len_bits,
7718 			tdata->auth.offset_bits,
7719 			op_mode, 1, verify);
7720 
7721 	if (retval < 0)
7722 		return retval;
7723 
7724 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7725 
7726 	/* Check if the op failed because the device doesn't */
7727 	/* support this particular combination of algorithms */
7728 	if (op == NULL && ut_params->op->status ==
7729 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7730 		printf("Device doesn't support this mixed combination. "
7731 				"Test Skipped.\n");
7732 		return TEST_SKIPPED;
7733 	}
7734 	ut_params->op = op;
7735 
7736 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7737 
7738 	ut_params->obuf = (op_mode == IN_PLACE ?
7739 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7740 
7741 	if (verify) {
7742 		if (ut_params->obuf)
7743 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7744 					plaintext_len, buffer);
7745 		else
7746 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7747 					plaintext_len, buffer);
7748 
7749 		debug_hexdump(stdout, "plaintext:", plaintext,
7750 				(tdata->plaintext.len_bits >> 3) -
7751 				tdata->digest_enc.len);
7752 		debug_hexdump(stdout, "plaintext expected:",
7753 				tdata->plaintext.data,
7754 				(tdata->plaintext.len_bits >> 3) -
7755 				tdata->digest_enc.len);
7756 	} else {
7757 		if (ut_params->obuf)
7758 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7759 					ciphertext_len, buffer);
7760 		else
7761 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7762 					ciphertext_len, buffer);
7763 
7764 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7765 			ciphertext_len);
7766 		debug_hexdump(stdout, "ciphertext expected:",
7767 			tdata->ciphertext.data,
7768 			tdata->ciphertext.len_bits >> 3);
7769 
7770 		if (ut_params->obuf)
7771 			digest = rte_pktmbuf_read(ut_params->obuf,
7772 					(tdata->digest_enc.offset == 0 ?
7773 						plaintext_pad_len :
7774 						tdata->digest_enc.offset),
7775 					tdata->digest_enc.len, digest_buffer);
7776 		else
7777 			digest = rte_pktmbuf_read(ut_params->ibuf,
7778 					(tdata->digest_enc.offset == 0 ?
7779 						plaintext_pad_len :
7780 						tdata->digest_enc.offset),
7781 					tdata->digest_enc.len, digest_buffer);
7782 
7783 		debug_hexdump(stdout, "digest:", digest,
7784 				tdata->digest_enc.len);
7785 		debug_hexdump(stdout, "digest expected:",
7786 				tdata->digest_enc.data, tdata->digest_enc.len);
7787 	}
7788 
7789 	if (!verify) {
7790 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7791 				digest,
7792 				tdata->digest_enc.data,
7793 				tdata->digest_enc.len,
7794 				"Generated auth tag not as expected");
7795 	}
7796 
7797 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7798 		if (verify) {
7799 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7800 					plaintext,
7801 					tdata->plaintext.data,
7802 					tdata->plaintext.len_bits >> 3,
7803 					"Plaintext data not as expected");
7804 		} else {
7805 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7806 					ciphertext,
7807 					tdata->ciphertext.data,
7808 					tdata->validDataLen.len_bits,
7809 					"Ciphertext data not as expected");
7810 		}
7811 	}
7812 
7813 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7814 			"crypto op processing failed");
7815 
7816 	return 0;
7817 }
7818 
7819 /** AUTH AES CMAC + CIPHER AES CTR */
7820 
7821 static int
7822 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7823 {
7824 	return test_mixed_auth_cipher(
7825 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7826 }
7827 
7828 static int
7829 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7830 {
7831 	return test_mixed_auth_cipher(
7832 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7833 }
7834 
7835 static int
7836 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7837 {
7838 	return test_mixed_auth_cipher_sgl(
7839 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7840 }
7841 
7842 static int
7843 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7844 {
7845 	return test_mixed_auth_cipher_sgl(
7846 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7847 }
7848 
7849 static int
7850 test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
7851 {
7852 	return test_mixed_auth_cipher(
7853 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
7854 }
7855 
7856 static int
7857 test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
7858 {
7859 	return test_mixed_auth_cipher(
7860 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
7861 }
7862 
7863 static int
7864 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7865 {
7866 	return test_mixed_auth_cipher(
7867 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7868 }
7869 
7870 static int
7871 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
7872 {
7873 	return test_mixed_auth_cipher(
7874 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
7875 }
7876 
7877 static int
7878 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7879 {
7880 	return test_mixed_auth_cipher(
7881 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7882 }
7883 
7884 static int
7885 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7886 {
7887 	return test_mixed_auth_cipher_sgl(
7888 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7889 }
7890 
7891 static int
7892 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7893 {
7894 	return test_mixed_auth_cipher_sgl(
7895 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7896 }
7897 
7898 static int
7899 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
7900 {
7901 	return test_mixed_auth_cipher(
7902 		&auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
7903 }
7904 
7905 /** MIXED AUTH + CIPHER */
7906 
7907 static int
7908 test_auth_zuc_cipher_snow_test_case_1(void)
7909 {
7910 	return test_mixed_auth_cipher(
7911 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7912 }
7913 
7914 static int
7915 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7916 {
7917 	return test_mixed_auth_cipher(
7918 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7919 }
7920 
7921 static int
7922 test_auth_zuc_cipher_snow_test_case_1_inplace(void)
7923 {
7924 	return test_mixed_auth_cipher(
7925 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
7926 }
7927 
7928 static int
7929 test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
7930 {
7931 	return test_mixed_auth_cipher(
7932 		&auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
7933 }
7934 
7935 
7936 static int
7937 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7938 {
7939 	return test_mixed_auth_cipher(
7940 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7941 }
7942 
7943 static int
7944 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7945 {
7946 	return test_mixed_auth_cipher(
7947 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7948 }
7949 
7950 static int
7951 test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
7952 {
7953 	return test_mixed_auth_cipher(
7954 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
7955 }
7956 
7957 static int
7958 test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
7959 {
7960 	return test_mixed_auth_cipher(
7961 		&auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
7962 }
7963 
7964 static int
7965 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7966 {
7967 	return test_mixed_auth_cipher(
7968 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7969 }
7970 
7971 static int
7972 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7973 {
7974 	return test_mixed_auth_cipher(
7975 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7976 }
7977 
7978 static int
7979 test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
7980 {
7981 	return test_mixed_auth_cipher(
7982 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7983 }
7984 
7985 static int
7986 test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
7987 {
7988 	return test_mixed_auth_cipher(
7989 		&auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7990 }
7991 
7992 static int
7993 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7994 {
7995 	return test_mixed_auth_cipher(
7996 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7997 }
7998 
7999 static int
8000 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8001 {
8002 	return test_mixed_auth_cipher(
8003 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8004 }
8005 
8006 static int
8007 test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8008 {
8009 	return test_mixed_auth_cipher_sgl(
8010 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8011 }
8012 
8013 static int
8014 test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8015 {
8016 	return test_mixed_auth_cipher(
8017 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8018 }
8019 
8020 static int
8021 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8022 {
8023 	return test_mixed_auth_cipher_sgl(
8024 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8025 }
8026 
8027 static int
8028 test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8029 {
8030 	return test_mixed_auth_cipher(
8031 		&auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8032 }
8033 
8034 static int
8035 test_auth_snow_cipher_zuc_test_case_1(void)
8036 {
8037 	return test_mixed_auth_cipher(
8038 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8039 }
8040 
8041 static int
8042 test_verify_auth_snow_cipher_zuc_test_case_1(void)
8043 {
8044 	return test_mixed_auth_cipher(
8045 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8046 }
8047 
8048 static int
8049 test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8050 {
8051 	return test_mixed_auth_cipher(
8052 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8053 }
8054 
8055 static int
8056 test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8057 {
8058 	return test_mixed_auth_cipher(
8059 		&auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8060 }
8061 
8062 static int
8063 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8064 {
8065 	return test_mixed_auth_cipher(
8066 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8067 }
8068 
8069 static int
8070 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8071 {
8072 	return test_mixed_auth_cipher(
8073 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8074 }
8075 static int
8076 test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8077 {
8078 	return test_mixed_auth_cipher(
8079 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8080 }
8081 
8082 static int
8083 test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8084 {
8085 	return test_mixed_auth_cipher(
8086 		&auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8087 }
8088 
8089 static int
8090 test_auth_null_cipher_snow_test_case_1(void)
8091 {
8092 	return test_mixed_auth_cipher(
8093 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8094 }
8095 
8096 static int
8097 test_verify_auth_null_cipher_snow_test_case_1(void)
8098 {
8099 	return test_mixed_auth_cipher(
8100 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8101 }
8102 
8103 static int
8104 test_auth_null_cipher_zuc_test_case_1(void)
8105 {
8106 	return test_mixed_auth_cipher(
8107 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8108 }
8109 
8110 static int
8111 test_verify_auth_null_cipher_zuc_test_case_1(void)
8112 {
8113 	return test_mixed_auth_cipher(
8114 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8115 }
8116 
8117 static int
8118 test_auth_snow_cipher_null_test_case_1(void)
8119 {
8120 	return test_mixed_auth_cipher(
8121 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8122 }
8123 
8124 static int
8125 test_verify_auth_snow_cipher_null_test_case_1(void)
8126 {
8127 	return test_mixed_auth_cipher(
8128 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8129 }
8130 
8131 static int
8132 test_auth_zuc_cipher_null_test_case_1(void)
8133 {
8134 	return test_mixed_auth_cipher(
8135 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8136 }
8137 
8138 static int
8139 test_verify_auth_zuc_cipher_null_test_case_1(void)
8140 {
8141 	return test_mixed_auth_cipher(
8142 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8143 }
8144 
8145 static int
8146 test_auth_null_cipher_aes_ctr_test_case_1(void)
8147 {
8148 	return test_mixed_auth_cipher(
8149 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8150 }
8151 
8152 static int
8153 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8154 {
8155 	return test_mixed_auth_cipher(
8156 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8157 }
8158 
8159 static int
8160 test_auth_aes_cmac_cipher_null_test_case_1(void)
8161 {
8162 	return test_mixed_auth_cipher(
8163 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8164 }
8165 
8166 static int
8167 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8168 {
8169 	return test_mixed_auth_cipher(
8170 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8171 }
8172 
8173 /* ***** AEAD algorithm Tests ***** */
8174 
8175 static int
8176 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8177 		enum rte_crypto_aead_operation op,
8178 		const uint8_t *key, const uint8_t key_len,
8179 		const uint16_t aad_len, const uint8_t auth_len,
8180 		uint8_t iv_len)
8181 {
8182 	uint8_t aead_key[key_len];
8183 
8184 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8185 	struct crypto_unittest_params *ut_params = &unittest_params;
8186 
8187 	memcpy(aead_key, key, key_len);
8188 
8189 	/* Setup AEAD Parameters */
8190 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8191 	ut_params->aead_xform.next = NULL;
8192 	ut_params->aead_xform.aead.algo = algo;
8193 	ut_params->aead_xform.aead.op = op;
8194 	ut_params->aead_xform.aead.key.data = aead_key;
8195 	ut_params->aead_xform.aead.key.length = key_len;
8196 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8197 	ut_params->aead_xform.aead.iv.length = iv_len;
8198 	ut_params->aead_xform.aead.digest_length = auth_len;
8199 	ut_params->aead_xform.aead.aad_length = aad_len;
8200 
8201 	debug_hexdump(stdout, "key:", key, key_len);
8202 
8203 	/* Create Crypto session*/
8204 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8205 			&ut_params->aead_xform, ts_params->session_mpool);
8206 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8207 		return TEST_SKIPPED;
8208 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8209 	return 0;
8210 }
8211 
8212 static int
8213 create_aead_xform(struct rte_crypto_op *op,
8214 		enum rte_crypto_aead_algorithm algo,
8215 		enum rte_crypto_aead_operation aead_op,
8216 		uint8_t *key, const uint8_t key_len,
8217 		const uint8_t aad_len, const uint8_t auth_len,
8218 		uint8_t iv_len)
8219 {
8220 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8221 			"failed to allocate space for crypto transform");
8222 
8223 	struct rte_crypto_sym_op *sym_op = op->sym;
8224 
8225 	/* Setup AEAD Parameters */
8226 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8227 	sym_op->xform->next = NULL;
8228 	sym_op->xform->aead.algo = algo;
8229 	sym_op->xform->aead.op = aead_op;
8230 	sym_op->xform->aead.key.data = key;
8231 	sym_op->xform->aead.key.length = key_len;
8232 	sym_op->xform->aead.iv.offset = IV_OFFSET;
8233 	sym_op->xform->aead.iv.length = iv_len;
8234 	sym_op->xform->aead.digest_length = auth_len;
8235 	sym_op->xform->aead.aad_length = aad_len;
8236 
8237 	debug_hexdump(stdout, "key:", key, key_len);
8238 
8239 	return 0;
8240 }
8241 
8242 static int
8243 create_aead_operation(enum rte_crypto_aead_operation op,
8244 		const struct aead_test_data *tdata)
8245 {
8246 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8247 	struct crypto_unittest_params *ut_params = &unittest_params;
8248 
8249 	uint8_t *plaintext, *ciphertext;
8250 	unsigned int aad_pad_len, plaintext_pad_len;
8251 
8252 	/* Generate Crypto op data structure */
8253 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8254 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8255 	TEST_ASSERT_NOT_NULL(ut_params->op,
8256 			"Failed to allocate symmetric crypto operation struct");
8257 
8258 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8259 
8260 	/* Append aad data */
8261 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8262 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8263 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8264 				aad_pad_len);
8265 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8266 				"no room to append aad");
8267 
8268 		sym_op->aead.aad.phys_addr =
8269 				rte_pktmbuf_iova(ut_params->ibuf);
8270 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
8271 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8272 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8273 			tdata->aad.len);
8274 
8275 		/* Append IV at the end of the crypto operation*/
8276 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8277 				uint8_t *, IV_OFFSET);
8278 
8279 		/* Copy IV 1 byte after the IV pointer, according to the API */
8280 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8281 		debug_hexdump(stdout, "iv:", iv_ptr + 1,
8282 			tdata->iv.len);
8283 	} else {
8284 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8285 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8286 				aad_pad_len);
8287 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8288 				"no room to append aad");
8289 
8290 		sym_op->aead.aad.phys_addr =
8291 				rte_pktmbuf_iova(ut_params->ibuf);
8292 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8293 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8294 			tdata->aad.len);
8295 
8296 		/* Append IV at the end of the crypto operation*/
8297 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8298 				uint8_t *, IV_OFFSET);
8299 
8300 		if (tdata->iv.len == 0) {
8301 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8302 			debug_hexdump(stdout, "iv:", iv_ptr,
8303 				AES_GCM_J0_LENGTH);
8304 		} else {
8305 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8306 			debug_hexdump(stdout, "iv:", iv_ptr,
8307 				tdata->iv.len);
8308 		}
8309 	}
8310 
8311 	/* Append plaintext/ciphertext */
8312 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8313 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8314 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8315 				plaintext_pad_len);
8316 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8317 
8318 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8319 		debug_hexdump(stdout, "plaintext:", plaintext,
8320 				tdata->plaintext.len);
8321 
8322 		if (ut_params->obuf) {
8323 			ciphertext = (uint8_t *)rte_pktmbuf_append(
8324 					ut_params->obuf,
8325 					plaintext_pad_len + aad_pad_len);
8326 			TEST_ASSERT_NOT_NULL(ciphertext,
8327 					"no room to append ciphertext");
8328 
8329 			memset(ciphertext + aad_pad_len, 0,
8330 					tdata->ciphertext.len);
8331 		}
8332 	} else {
8333 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8334 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8335 				plaintext_pad_len);
8336 		TEST_ASSERT_NOT_NULL(ciphertext,
8337 				"no room to append ciphertext");
8338 
8339 		memcpy(ciphertext, tdata->ciphertext.data,
8340 				tdata->ciphertext.len);
8341 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8342 				tdata->ciphertext.len);
8343 
8344 		if (ut_params->obuf) {
8345 			plaintext = (uint8_t *)rte_pktmbuf_append(
8346 					ut_params->obuf,
8347 					plaintext_pad_len + aad_pad_len);
8348 			TEST_ASSERT_NOT_NULL(plaintext,
8349 					"no room to append plaintext");
8350 
8351 			memset(plaintext + aad_pad_len, 0,
8352 					tdata->plaintext.len);
8353 		}
8354 	}
8355 
8356 	/* Append digest data */
8357 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8358 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8359 				ut_params->obuf ? ut_params->obuf :
8360 						ut_params->ibuf,
8361 						tdata->auth_tag.len);
8362 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8363 				"no room to append digest");
8364 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8365 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8366 				ut_params->obuf ? ut_params->obuf :
8367 						ut_params->ibuf,
8368 						plaintext_pad_len +
8369 						aad_pad_len);
8370 	} else {
8371 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8372 				ut_params->ibuf, tdata->auth_tag.len);
8373 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8374 				"no room to append digest");
8375 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8376 				ut_params->ibuf,
8377 				plaintext_pad_len + aad_pad_len);
8378 
8379 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8380 			tdata->auth_tag.len);
8381 		debug_hexdump(stdout, "digest:",
8382 			sym_op->aead.digest.data,
8383 			tdata->auth_tag.len);
8384 	}
8385 
8386 	sym_op->aead.data.length = tdata->plaintext.len;
8387 	sym_op->aead.data.offset = aad_pad_len;
8388 
8389 	return 0;
8390 }
8391 
8392 static int
8393 test_authenticated_encryption(const struct aead_test_data *tdata)
8394 {
8395 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8396 	struct crypto_unittest_params *ut_params = &unittest_params;
8397 
8398 	int retval;
8399 	uint8_t *ciphertext, *auth_tag;
8400 	uint16_t plaintext_pad_len;
8401 	uint32_t i;
8402 	struct rte_cryptodev_info dev_info;
8403 
8404 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8405 	uint64_t feat_flags = dev_info.feature_flags;
8406 
8407 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8408 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8409 		printf("Device doesn't support RAW data-path APIs.\n");
8410 		return TEST_SKIPPED;
8411 	}
8412 
8413 	/* Verify the capabilities */
8414 	struct rte_cryptodev_sym_capability_idx cap_idx;
8415 	const struct rte_cryptodev_symmetric_capability *capability;
8416 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8417 	cap_idx.algo.aead = tdata->algo;
8418 	capability = rte_cryptodev_sym_capability_get(
8419 			ts_params->valid_devs[0], &cap_idx);
8420 	if (capability == NULL)
8421 		return TEST_SKIPPED;
8422 	if (rte_cryptodev_sym_capability_check_aead(
8423 			capability, tdata->key.len, tdata->auth_tag.len,
8424 			tdata->aad.len, tdata->iv.len))
8425 		return TEST_SKIPPED;
8426 
8427 	/* Create AEAD session */
8428 	retval = create_aead_session(ts_params->valid_devs[0],
8429 			tdata->algo,
8430 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
8431 			tdata->key.data, tdata->key.len,
8432 			tdata->aad.len, tdata->auth_tag.len,
8433 			tdata->iv.len);
8434 	if (retval < 0)
8435 		return retval;
8436 
8437 	if (tdata->aad.len > MBUF_SIZE) {
8438 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8439 		/* Populate full size of add data */
8440 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8441 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8442 	} else
8443 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8444 
8445 	/* clear mbuf payload */
8446 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8447 			rte_pktmbuf_tailroom(ut_params->ibuf));
8448 
8449 	/* Create AEAD operation */
8450 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8451 	if (retval < 0)
8452 		return retval;
8453 
8454 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8455 
8456 	ut_params->op->sym->m_src = ut_params->ibuf;
8457 
8458 	/* Process crypto operation */
8459 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8460 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8461 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8462 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8463 				ut_params->op, 0, 0, 0, 0);
8464 	else
8465 		TEST_ASSERT_NOT_NULL(
8466 			process_crypto_request(ts_params->valid_devs[0],
8467 			ut_params->op), "failed to process sym crypto op");
8468 
8469 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8470 			"crypto op processing failed");
8471 
8472 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8473 
8474 	if (ut_params->op->sym->m_dst) {
8475 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8476 				uint8_t *);
8477 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8478 				uint8_t *, plaintext_pad_len);
8479 	} else {
8480 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8481 				uint8_t *,
8482 				ut_params->op->sym->cipher.data.offset);
8483 		auth_tag = ciphertext + plaintext_pad_len;
8484 	}
8485 
8486 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8487 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8488 
8489 	/* Validate obuf */
8490 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8491 			ciphertext,
8492 			tdata->ciphertext.data,
8493 			tdata->ciphertext.len,
8494 			"Ciphertext data not as expected");
8495 
8496 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8497 			auth_tag,
8498 			tdata->auth_tag.data,
8499 			tdata->auth_tag.len,
8500 			"Generated auth tag not as expected");
8501 
8502 	return 0;
8503 
8504 }
8505 
8506 #ifdef RTE_LIB_SECURITY
8507 static int
8508 security_proto_supported(enum rte_security_session_action_type action,
8509 	enum rte_security_session_protocol proto)
8510 {
8511 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8512 
8513 	const struct rte_security_capability *capabilities;
8514 	const struct rte_security_capability *capability;
8515 	uint16_t i = 0;
8516 
8517 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8518 				rte_cryptodev_get_sec_ctx(
8519 				ts_params->valid_devs[0]);
8520 
8521 
8522 	capabilities = rte_security_capabilities_get(ctx);
8523 
8524 	if (capabilities == NULL)
8525 		return -ENOTSUP;
8526 
8527 	while ((capability = &capabilities[i++])->action !=
8528 			RTE_SECURITY_ACTION_TYPE_NONE) {
8529 		if (capability->action == action &&
8530 				capability->protocol == proto)
8531 			return 0;
8532 	}
8533 
8534 	return -ENOTSUP;
8535 }
8536 
8537 /* Basic algorithm run function for async inplace mode.
8538  * Creates a session from input parameters and runs one operation
8539  * on input_vec. Checks the output of the crypto operation against
8540  * output_vec.
8541  */
8542 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8543 			   enum rte_crypto_auth_operation opa,
8544 			   const uint8_t *input_vec, unsigned int input_vec_len,
8545 			   const uint8_t *output_vec,
8546 			   unsigned int output_vec_len,
8547 			   enum rte_crypto_cipher_algorithm cipher_alg,
8548 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
8549 			   enum rte_crypto_auth_algorithm auth_alg,
8550 			   const uint8_t *auth_key, uint32_t auth_key_len,
8551 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
8552 			   uint8_t packet_direction, uint8_t sn_size,
8553 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8554 {
8555 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8556 	struct crypto_unittest_params *ut_params = &unittest_params;
8557 	uint8_t *plaintext;
8558 	int ret = TEST_SUCCESS;
8559 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8560 				rte_cryptodev_get_sec_ctx(
8561 				ts_params->valid_devs[0]);
8562 	struct rte_cryptodev_info dev_info;
8563 	uint64_t feat_flags;
8564 
8565 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8566 	feat_flags = dev_info.feature_flags;
8567 
8568 	/* Verify the capabilities */
8569 	struct rte_security_capability_idx sec_cap_idx;
8570 
8571 	sec_cap_idx.action = ut_params->type;
8572 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8573 	sec_cap_idx.pdcp.domain = domain;
8574 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8575 		return TEST_SKIPPED;
8576 
8577 	/* Generate test mbuf data */
8578 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8579 
8580 	/* clear mbuf payload */
8581 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8582 			rte_pktmbuf_tailroom(ut_params->ibuf));
8583 
8584 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8585 						  input_vec_len);
8586 	memcpy(plaintext, input_vec, input_vec_len);
8587 
8588 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8589 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8590 		printf("Device does not support RAW data-path APIs.\n");
8591 		return TEST_SKIPPED;
8592 	}
8593 	/* Out of place support */
8594 	if (oop) {
8595 		/*
8596 		 * For out-op-place we need to alloc another mbuf
8597 		 */
8598 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8599 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8600 	}
8601 
8602 	/* Setup Cipher Parameters */
8603 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8604 	ut_params->cipher_xform.cipher.algo = cipher_alg;
8605 	ut_params->cipher_xform.cipher.op = opc;
8606 	ut_params->cipher_xform.cipher.key.data = cipher_key;
8607 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8608 	ut_params->cipher_xform.cipher.iv.length =
8609 				packet_direction ? 4 : 0;
8610 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8611 
8612 	/* Setup HMAC Parameters if ICV header is required */
8613 	if (auth_alg != 0) {
8614 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8615 		ut_params->auth_xform.next = NULL;
8616 		ut_params->auth_xform.auth.algo = auth_alg;
8617 		ut_params->auth_xform.auth.op = opa;
8618 		ut_params->auth_xform.auth.key.data = auth_key;
8619 		ut_params->auth_xform.auth.key.length = auth_key_len;
8620 
8621 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8622 	} else {
8623 		ut_params->cipher_xform.next = NULL;
8624 	}
8625 
8626 	struct rte_security_session_conf sess_conf = {
8627 		.action_type = ut_params->type,
8628 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8629 		{.pdcp = {
8630 			.bearer = bearer,
8631 			.domain = domain,
8632 			.pkt_dir = packet_direction,
8633 			.sn_size = sn_size,
8634 			.hfn = packet_direction ? 0 : hfn,
8635 			/**
8636 			 * hfn can be set as pdcp_test_hfn[i]
8637 			 * if hfn_ovrd is not set. Here, PDCP
8638 			 * packet direction is just used to
8639 			 * run half of the cases with session
8640 			 * HFN and other half with per packet
8641 			 * HFN.
8642 			 */
8643 			.hfn_threshold = hfn_threshold,
8644 			.hfn_ovrd = packet_direction ? 1 : 0,
8645 			.sdap_enabled = sdap,
8646 		} },
8647 		.crypto_xform = &ut_params->cipher_xform
8648 	};
8649 
8650 	/* Create security session */
8651 	ut_params->sec_session = rte_security_session_create(ctx,
8652 				&sess_conf, ts_params->session_mpool);
8653 
8654 	if (!ut_params->sec_session) {
8655 		printf("TestCase %s()-%d line %d failed %s: ",
8656 			__func__, i, __LINE__, "Failed to allocate session");
8657 		ret = TEST_FAILED;
8658 		goto on_err;
8659 	}
8660 
8661 	/* Generate crypto op data structure */
8662 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8663 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8664 	if (!ut_params->op) {
8665 		printf("TestCase %s()-%d line %d failed %s: ",
8666 			__func__, i, __LINE__,
8667 			"Failed to allocate symmetric crypto operation struct");
8668 		ret = TEST_FAILED;
8669 		goto on_err;
8670 	}
8671 
8672 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8673 					uint32_t *, IV_OFFSET);
8674 	*per_pkt_hfn = packet_direction ? hfn : 0;
8675 
8676 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8677 
8678 	/* set crypto operation source mbuf */
8679 	ut_params->op->sym->m_src = ut_params->ibuf;
8680 	if (oop)
8681 		ut_params->op->sym->m_dst = ut_params->obuf;
8682 
8683 	/* Process crypto operation */
8684 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8685 		/* filling lengths */
8686 		ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
8687 		ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
8688 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8689 			ut_params->op, 1, 1, 0, 0);
8690 	} else {
8691 		ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8692 	}
8693 	if (ut_params->op == NULL) {
8694 		printf("TestCase %s()-%d line %d failed %s: ",
8695 			__func__, i, __LINE__,
8696 			"failed to process sym crypto op");
8697 		ret = TEST_FAILED;
8698 		goto on_err;
8699 	}
8700 
8701 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8702 		printf("TestCase %s()-%d line %d failed %s: ",
8703 			__func__, i, __LINE__, "crypto op processing failed");
8704 		ret = TEST_FAILED;
8705 		goto on_err;
8706 	}
8707 
8708 	/* Validate obuf */
8709 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8710 			uint8_t *);
8711 	if (oop) {
8712 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8713 				uint8_t *);
8714 	}
8715 
8716 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
8717 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8718 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8719 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8720 		ret = TEST_FAILED;
8721 		goto on_err;
8722 	}
8723 
8724 on_err:
8725 	rte_crypto_op_free(ut_params->op);
8726 	ut_params->op = NULL;
8727 
8728 	if (ut_params->sec_session)
8729 		rte_security_session_destroy(ctx, ut_params->sec_session);
8730 	ut_params->sec_session = NULL;
8731 
8732 	rte_pktmbuf_free(ut_params->ibuf);
8733 	ut_params->ibuf = NULL;
8734 	if (oop) {
8735 		rte_pktmbuf_free(ut_params->obuf);
8736 		ut_params->obuf = NULL;
8737 	}
8738 
8739 	return ret;
8740 }
8741 
8742 static int
8743 test_pdcp_proto_SGL(int i, int oop,
8744 	enum rte_crypto_cipher_operation opc,
8745 	enum rte_crypto_auth_operation opa,
8746 	uint8_t *input_vec,
8747 	unsigned int input_vec_len,
8748 	uint8_t *output_vec,
8749 	unsigned int output_vec_len,
8750 	uint32_t fragsz,
8751 	uint32_t fragsz_oop)
8752 {
8753 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8754 	struct crypto_unittest_params *ut_params = &unittest_params;
8755 	uint8_t *plaintext;
8756 	struct rte_mbuf *buf, *buf_oop = NULL;
8757 	int ret = TEST_SUCCESS;
8758 	int to_trn = 0;
8759 	int to_trn_tbl[16];
8760 	int segs = 1;
8761 	unsigned int trn_data = 0;
8762 	struct rte_cryptodev_info dev_info;
8763 	uint64_t feat_flags;
8764 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8765 				rte_cryptodev_get_sec_ctx(
8766 				ts_params->valid_devs[0]);
8767 	struct rte_mbuf *temp_mbuf;
8768 
8769 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8770 	feat_flags = dev_info.feature_flags;
8771 
8772 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8773 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8774 		printf("Device does not support RAW data-path APIs.\n");
8775 		return -ENOTSUP;
8776 	}
8777 	/* Verify the capabilities */
8778 	struct rte_security_capability_idx sec_cap_idx;
8779 
8780 	sec_cap_idx.action = ut_params->type;
8781 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8782 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8783 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8784 		return TEST_SKIPPED;
8785 
8786 	if (fragsz > input_vec_len)
8787 		fragsz = input_vec_len;
8788 
8789 	uint16_t plaintext_len = fragsz;
8790 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8791 
8792 	if (fragsz_oop > output_vec_len)
8793 		frag_size_oop = output_vec_len;
8794 
8795 	int ecx = 0;
8796 	if (input_vec_len % fragsz != 0) {
8797 		if (input_vec_len / fragsz + 1 > 16)
8798 			return 1;
8799 	} else if (input_vec_len / fragsz > 16)
8800 		return 1;
8801 
8802 	/* Out of place support */
8803 	if (oop) {
8804 		/*
8805 		 * For out-op-place we need to alloc another mbuf
8806 		 */
8807 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8808 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8809 		buf_oop = ut_params->obuf;
8810 	}
8811 
8812 	/* Generate test mbuf data */
8813 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8814 
8815 	/* clear mbuf payload */
8816 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8817 			rte_pktmbuf_tailroom(ut_params->ibuf));
8818 
8819 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8820 						  plaintext_len);
8821 	memcpy(plaintext, input_vec, plaintext_len);
8822 	trn_data += plaintext_len;
8823 
8824 	buf = ut_params->ibuf;
8825 
8826 	/*
8827 	 * Loop until no more fragments
8828 	 */
8829 
8830 	while (trn_data < input_vec_len) {
8831 		++segs;
8832 		to_trn = (input_vec_len - trn_data < fragsz) ?
8833 				(input_vec_len - trn_data) : fragsz;
8834 
8835 		to_trn_tbl[ecx++] = to_trn;
8836 
8837 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8838 		buf = buf->next;
8839 
8840 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8841 				rte_pktmbuf_tailroom(buf));
8842 
8843 		/* OOP */
8844 		if (oop && !fragsz_oop) {
8845 			buf_oop->next =
8846 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
8847 			buf_oop = buf_oop->next;
8848 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8849 					0, rte_pktmbuf_tailroom(buf_oop));
8850 			rte_pktmbuf_append(buf_oop, to_trn);
8851 		}
8852 
8853 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8854 				to_trn);
8855 
8856 		memcpy(plaintext, input_vec + trn_data, to_trn);
8857 		trn_data += to_trn;
8858 	}
8859 
8860 	ut_params->ibuf->nb_segs = segs;
8861 
8862 	segs = 1;
8863 	if (fragsz_oop && oop) {
8864 		to_trn = 0;
8865 		ecx = 0;
8866 
8867 		trn_data = frag_size_oop;
8868 		while (trn_data < output_vec_len) {
8869 			++segs;
8870 			to_trn =
8871 				(output_vec_len - trn_data <
8872 						frag_size_oop) ?
8873 				(output_vec_len - trn_data) :
8874 						frag_size_oop;
8875 
8876 			to_trn_tbl[ecx++] = to_trn;
8877 
8878 			buf_oop->next =
8879 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
8880 			buf_oop = buf_oop->next;
8881 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8882 					0, rte_pktmbuf_tailroom(buf_oop));
8883 			rte_pktmbuf_append(buf_oop, to_trn);
8884 
8885 			trn_data += to_trn;
8886 		}
8887 		ut_params->obuf->nb_segs = segs;
8888 	}
8889 
8890 	/* Setup Cipher Parameters */
8891 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8892 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8893 	ut_params->cipher_xform.cipher.op = opc;
8894 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8895 	ut_params->cipher_xform.cipher.key.length =
8896 					pdcp_test_params[i].cipher_key_len;
8897 	ut_params->cipher_xform.cipher.iv.length = 0;
8898 
8899 	/* Setup HMAC Parameters if ICV header is required */
8900 	if (pdcp_test_params[i].auth_alg != 0) {
8901 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8902 		ut_params->auth_xform.next = NULL;
8903 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8904 		ut_params->auth_xform.auth.op = opa;
8905 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8906 		ut_params->auth_xform.auth.key.length =
8907 					pdcp_test_params[i].auth_key_len;
8908 
8909 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8910 	} else {
8911 		ut_params->cipher_xform.next = NULL;
8912 	}
8913 
8914 	struct rte_security_session_conf sess_conf = {
8915 		.action_type = ut_params->type,
8916 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8917 		{.pdcp = {
8918 			.bearer = pdcp_test_bearer[i],
8919 			.domain = pdcp_test_params[i].domain,
8920 			.pkt_dir = pdcp_test_packet_direction[i],
8921 			.sn_size = pdcp_test_data_sn_size[i],
8922 			.hfn = pdcp_test_hfn[i],
8923 			.hfn_threshold = pdcp_test_hfn_threshold[i],
8924 			.hfn_ovrd = 0,
8925 		} },
8926 		.crypto_xform = &ut_params->cipher_xform
8927 	};
8928 
8929 	/* Create security session */
8930 	ut_params->sec_session = rte_security_session_create(ctx,
8931 				&sess_conf, ts_params->session_mpool);
8932 
8933 	if (!ut_params->sec_session) {
8934 		printf("TestCase %s()-%d line %d failed %s: ",
8935 			__func__, i, __LINE__, "Failed to allocate session");
8936 		ret = TEST_FAILED;
8937 		goto on_err;
8938 	}
8939 
8940 	/* Generate crypto op data structure */
8941 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8942 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8943 	if (!ut_params->op) {
8944 		printf("TestCase %s()-%d line %d failed %s: ",
8945 			__func__, i, __LINE__,
8946 			"Failed to allocate symmetric crypto operation struct");
8947 		ret = TEST_FAILED;
8948 		goto on_err;
8949 	}
8950 
8951 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8952 
8953 	/* set crypto operation source mbuf */
8954 	ut_params->op->sym->m_src = ut_params->ibuf;
8955 	if (oop)
8956 		ut_params->op->sym->m_dst = ut_params->obuf;
8957 
8958 	/* Process crypto operation */
8959 	temp_mbuf = ut_params->op->sym->m_src;
8960 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8961 		/* filling lengths */
8962 		while (temp_mbuf) {
8963 			ut_params->op->sym->cipher.data.length
8964 				+= temp_mbuf->pkt_len;
8965 			ut_params->op->sym->auth.data.length
8966 				+= temp_mbuf->pkt_len;
8967 			temp_mbuf = temp_mbuf->next;
8968 		}
8969 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8970 			ut_params->op, 1, 1, 0, 0);
8971 	} else {
8972 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8973 							ut_params->op);
8974 	}
8975 	if (ut_params->op == NULL) {
8976 		printf("TestCase %s()-%d line %d failed %s: ",
8977 			__func__, i, __LINE__,
8978 			"failed to process sym crypto op");
8979 		ret = TEST_FAILED;
8980 		goto on_err;
8981 	}
8982 
8983 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8984 		printf("TestCase %s()-%d line %d failed %s: ",
8985 			__func__, i, __LINE__, "crypto op processing failed");
8986 		ret = TEST_FAILED;
8987 		goto on_err;
8988 	}
8989 
8990 	/* Validate obuf */
8991 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8992 			uint8_t *);
8993 	if (oop) {
8994 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8995 				uint8_t *);
8996 	}
8997 	if (fragsz_oop)
8998 		fragsz = frag_size_oop;
8999 	if (memcmp(ciphertext, output_vec, fragsz)) {
9000 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9001 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9002 		rte_hexdump(stdout, "reference", output_vec, fragsz);
9003 		ret = TEST_FAILED;
9004 		goto on_err;
9005 	}
9006 
9007 	buf = ut_params->op->sym->m_src->next;
9008 	if (oop)
9009 		buf = ut_params->op->sym->m_dst->next;
9010 
9011 	unsigned int off = fragsz;
9012 
9013 	ecx = 0;
9014 	while (buf) {
9015 		ciphertext = rte_pktmbuf_mtod(buf,
9016 				uint8_t *);
9017 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9018 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9019 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9020 			rte_hexdump(stdout, "reference", output_vec + off,
9021 					to_trn_tbl[ecx]);
9022 			ret = TEST_FAILED;
9023 			goto on_err;
9024 		}
9025 		off += to_trn_tbl[ecx++];
9026 		buf = buf->next;
9027 	}
9028 on_err:
9029 	rte_crypto_op_free(ut_params->op);
9030 	ut_params->op = NULL;
9031 
9032 	if (ut_params->sec_session)
9033 		rte_security_session_destroy(ctx, ut_params->sec_session);
9034 	ut_params->sec_session = NULL;
9035 
9036 	rte_pktmbuf_free(ut_params->ibuf);
9037 	ut_params->ibuf = NULL;
9038 	if (oop) {
9039 		rte_pktmbuf_free(ut_params->obuf);
9040 		ut_params->obuf = NULL;
9041 	}
9042 
9043 	return ret;
9044 }
9045 
9046 int
9047 test_pdcp_proto_cplane_encap(int i)
9048 {
9049 	return test_pdcp_proto(
9050 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9051 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9052 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9053 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9054 		pdcp_test_params[i].cipher_key_len,
9055 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9056 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9057 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9058 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9059 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9060 }
9061 
9062 int
9063 test_pdcp_proto_uplane_encap(int i)
9064 {
9065 	return test_pdcp_proto(
9066 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9067 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9068 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9069 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9070 		pdcp_test_params[i].cipher_key_len,
9071 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9072 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9073 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9074 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9075 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9076 }
9077 
9078 int
9079 test_pdcp_proto_uplane_encap_with_int(int i)
9080 {
9081 	return test_pdcp_proto(
9082 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9083 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9084 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9085 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9086 		pdcp_test_params[i].cipher_key_len,
9087 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9088 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9089 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9090 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9091 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9092 }
9093 
9094 int
9095 test_pdcp_proto_cplane_decap(int i)
9096 {
9097 	return test_pdcp_proto(
9098 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9099 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9100 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9101 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9102 		pdcp_test_params[i].cipher_key_len,
9103 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9104 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9105 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9106 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9107 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9108 }
9109 
9110 int
9111 test_pdcp_proto_uplane_decap(int i)
9112 {
9113 	return test_pdcp_proto(
9114 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9115 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9116 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9117 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9118 		pdcp_test_params[i].cipher_key_len,
9119 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9120 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9121 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9122 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9123 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9124 }
9125 
9126 int
9127 test_pdcp_proto_uplane_decap_with_int(int i)
9128 {
9129 	return test_pdcp_proto(
9130 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9131 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9132 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9133 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9134 		pdcp_test_params[i].cipher_key_len,
9135 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9136 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9137 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9138 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9139 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9140 }
9141 
9142 static int
9143 test_PDCP_PROTO_SGL_in_place_32B(void)
9144 {
9145 	/* i can be used for running any PDCP case
9146 	 * In this case it is uplane 12-bit AES-SNOW DL encap
9147 	 */
9148 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9149 	return test_pdcp_proto_SGL(i, IN_PLACE,
9150 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9151 			RTE_CRYPTO_AUTH_OP_GENERATE,
9152 			pdcp_test_data_in[i],
9153 			pdcp_test_data_in_len[i],
9154 			pdcp_test_data_out[i],
9155 			pdcp_test_data_in_len[i]+4,
9156 			32, 0);
9157 }
9158 static int
9159 test_PDCP_PROTO_SGL_oop_32B_128B(void)
9160 {
9161 	/* i can be used for running any PDCP case
9162 	 * In this case it is uplane 18-bit NULL-NULL DL encap
9163 	 */
9164 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9165 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9166 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9167 			RTE_CRYPTO_AUTH_OP_GENERATE,
9168 			pdcp_test_data_in[i],
9169 			pdcp_test_data_in_len[i],
9170 			pdcp_test_data_out[i],
9171 			pdcp_test_data_in_len[i]+4,
9172 			32, 128);
9173 }
9174 static int
9175 test_PDCP_PROTO_SGL_oop_32B_40B(void)
9176 {
9177 	/* i can be used for running any PDCP case
9178 	 * In this case it is uplane 18-bit AES DL encap
9179 	 */
9180 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9181 			+ DOWNLINK;
9182 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9183 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9184 			RTE_CRYPTO_AUTH_OP_GENERATE,
9185 			pdcp_test_data_in[i],
9186 			pdcp_test_data_in_len[i],
9187 			pdcp_test_data_out[i],
9188 			pdcp_test_data_in_len[i],
9189 			32, 40);
9190 }
9191 static int
9192 test_PDCP_PROTO_SGL_oop_128B_32B(void)
9193 {
9194 	/* i can be used for running any PDCP case
9195 	 * In this case it is cplane 12-bit AES-ZUC DL encap
9196 	 */
9197 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9198 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9199 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9200 			RTE_CRYPTO_AUTH_OP_GENERATE,
9201 			pdcp_test_data_in[i],
9202 			pdcp_test_data_in_len[i],
9203 			pdcp_test_data_out[i],
9204 			pdcp_test_data_in_len[i]+4,
9205 			128, 32);
9206 }
9207 
9208 static int
9209 test_PDCP_SDAP_PROTO_encap_all(void)
9210 {
9211 	int i = 0, size = 0;
9212 	int err, all_err = TEST_SUCCESS;
9213 	const struct pdcp_sdap_test *cur_test;
9214 
9215 	size = RTE_DIM(list_pdcp_sdap_tests);
9216 
9217 	for (i = 0; i < size; i++) {
9218 		cur_test = &list_pdcp_sdap_tests[i];
9219 		err = test_pdcp_proto(
9220 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9221 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9222 			cur_test->in_len, cur_test->data_out,
9223 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9224 			cur_test->param.cipher_alg, cur_test->cipher_key,
9225 			cur_test->param.cipher_key_len,
9226 			cur_test->param.auth_alg,
9227 			cur_test->auth_key, cur_test->param.auth_key_len,
9228 			cur_test->bearer, cur_test->param.domain,
9229 			cur_test->packet_direction, cur_test->sn_size,
9230 			cur_test->hfn,
9231 			cur_test->hfn_threshold, SDAP_ENABLED);
9232 		if (err) {
9233 			printf("\t%d) %s: Encapsulation failed\n",
9234 					cur_test->test_idx,
9235 					cur_test->param.name);
9236 			err = TEST_FAILED;
9237 		} else {
9238 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9239 					cur_test->param.name);
9240 			err = TEST_SUCCESS;
9241 		}
9242 		all_err += err;
9243 	}
9244 
9245 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9246 
9247 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9248 }
9249 
9250 static int
9251 test_PDCP_PROTO_short_mac(void)
9252 {
9253 	int i = 0, size = 0;
9254 	int err, all_err = TEST_SUCCESS;
9255 	const struct pdcp_short_mac_test *cur_test;
9256 
9257 	size = RTE_DIM(list_pdcp_smac_tests);
9258 
9259 	for (i = 0; i < size; i++) {
9260 		cur_test = &list_pdcp_smac_tests[i];
9261 		err = test_pdcp_proto(
9262 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9263 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9264 			cur_test->in_len, cur_test->data_out,
9265 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9266 			RTE_CRYPTO_CIPHER_NULL, NULL,
9267 			0, cur_test->param.auth_alg,
9268 			cur_test->auth_key, cur_test->param.auth_key_len,
9269 			0, cur_test->param.domain, 0, 0,
9270 			0, 0, 0);
9271 		if (err) {
9272 			printf("\t%d) %s: Short MAC test failed\n",
9273 					cur_test->test_idx,
9274 					cur_test->param.name);
9275 			err = TEST_FAILED;
9276 		} else {
9277 			printf("\t%d) %s: Short MAC test PASS\n",
9278 					cur_test->test_idx,
9279 					cur_test->param.name);
9280 			rte_hexdump(stdout, "MAC I",
9281 				    cur_test->data_out + cur_test->in_len + 2,
9282 				    2);
9283 			err = TEST_SUCCESS;
9284 		}
9285 		all_err += err;
9286 	}
9287 
9288 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9289 
9290 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9291 
9292 }
9293 
9294 static int
9295 test_PDCP_SDAP_PROTO_decap_all(void)
9296 {
9297 	int i = 0, size = 0;
9298 	int err, all_err = TEST_SUCCESS;
9299 	const struct pdcp_sdap_test *cur_test;
9300 
9301 	size = RTE_DIM(list_pdcp_sdap_tests);
9302 
9303 	for (i = 0; i < size; i++) {
9304 		cur_test = &list_pdcp_sdap_tests[i];
9305 		err = test_pdcp_proto(
9306 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9307 			RTE_CRYPTO_AUTH_OP_VERIFY,
9308 			cur_test->data_out,
9309 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9310 			cur_test->data_in, cur_test->in_len,
9311 			cur_test->param.cipher_alg,
9312 			cur_test->cipher_key, cur_test->param.cipher_key_len,
9313 			cur_test->param.auth_alg, cur_test->auth_key,
9314 			cur_test->param.auth_key_len, cur_test->bearer,
9315 			cur_test->param.domain, cur_test->packet_direction,
9316 			cur_test->sn_size, cur_test->hfn,
9317 			cur_test->hfn_threshold, SDAP_ENABLED);
9318 		if (err) {
9319 			printf("\t%d) %s: Decapsulation failed\n",
9320 					cur_test->test_idx,
9321 					cur_test->param.name);
9322 			err = TEST_FAILED;
9323 		} else {
9324 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9325 					cur_test->param.name);
9326 			err = TEST_SUCCESS;
9327 		}
9328 		all_err += err;
9329 	}
9330 
9331 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9332 
9333 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9334 }
9335 
9336 static int
9337 test_ipsec_proto_process(const struct ipsec_test_data td[],
9338 			 struct ipsec_test_data res_d[],
9339 			 int nb_td,
9340 			 bool silent,
9341 			 const struct ipsec_test_flags *flags)
9342 {
9343 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
9344 				0x0000, 0x001a};
9345 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
9346 				0xe82c, 0x4887};
9347 	const struct rte_ipv4_hdr *ipv4 =
9348 			(const struct rte_ipv4_hdr *)td[0].output_text.data;
9349 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9350 	struct crypto_unittest_params *ut_params = &unittest_params;
9351 	struct rte_security_capability_idx sec_cap_idx;
9352 	const struct rte_security_capability *sec_cap;
9353 	struct rte_security_ipsec_xform ipsec_xform;
9354 	uint8_t dev_id = ts_params->valid_devs[0];
9355 	enum rte_security_ipsec_sa_direction dir;
9356 	struct ipsec_test_data *res_d_tmp = NULL;
9357 	int salt_len, i, ret = TEST_SUCCESS;
9358 	struct rte_security_ctx *ctx;
9359 	uint8_t *input_text;
9360 	uint32_t src, dst;
9361 	uint32_t verify;
9362 
9363 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9364 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9365 
9366 	/* Use first test data to create session */
9367 
9368 	/* Copy IPsec xform */
9369 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9370 
9371 	dir = ipsec_xform.direction;
9372 	verify = flags->tunnel_hdr_verify;
9373 
9374 	memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
9375 	memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
9376 
9377 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9378 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9379 			src += 1;
9380 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9381 			dst += 1;
9382 	}
9383 
9384 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
9385 		if (td->ipsec_xform.tunnel.type ==
9386 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
9387 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
9388 			       sizeof(src));
9389 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
9390 			       sizeof(dst));
9391 
9392 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
9393 				ipsec_xform.tunnel.ipv4.df = 0;
9394 
9395 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
9396 				ipsec_xform.tunnel.ipv4.df = 1;
9397 
9398 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9399 				ipsec_xform.tunnel.ipv4.dscp = 0;
9400 
9401 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9402 				ipsec_xform.tunnel.ipv4.dscp =
9403 						TEST_IPSEC_DSCP_VAL;
9404 
9405 		} else {
9406 			if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9407 				ipsec_xform.tunnel.ipv6.dscp = 0;
9408 
9409 			if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9410 				ipsec_xform.tunnel.ipv6.dscp =
9411 						TEST_IPSEC_DSCP_VAL;
9412 
9413 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
9414 			       sizeof(v6_src));
9415 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
9416 			       sizeof(v6_dst));
9417 		}
9418 	}
9419 
9420 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
9421 
9422 	sec_cap_idx.action = ut_params->type;
9423 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9424 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9425 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9426 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9427 
9428 	if (flags->udp_encap)
9429 		ipsec_xform.options.udp_encap = 1;
9430 
9431 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9432 	if (sec_cap == NULL)
9433 		return TEST_SKIPPED;
9434 
9435 	/* Copy cipher session parameters */
9436 	if (td[0].aead) {
9437 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9438 		       sizeof(ut_params->aead_xform));
9439 		ut_params->aead_xform.aead.key.data = td[0].key.data;
9440 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9441 
9442 		/* Verify crypto capabilities */
9443 		if (test_ipsec_crypto_caps_aead_verify(
9444 				sec_cap,
9445 				&ut_params->aead_xform) != 0) {
9446 			if (!silent)
9447 				RTE_LOG(INFO, USER1,
9448 					"Crypto capabilities not supported\n");
9449 			return TEST_SKIPPED;
9450 		}
9451 	} else if (td[0].auth_only) {
9452 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9453 		       sizeof(ut_params->auth_xform));
9454 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9455 
9456 		if (test_ipsec_crypto_caps_auth_verify(
9457 				sec_cap,
9458 				&ut_params->auth_xform) != 0) {
9459 			if (!silent)
9460 				RTE_LOG(INFO, USER1,
9461 					"Auth crypto capabilities not supported\n");
9462 			return TEST_SKIPPED;
9463 		}
9464 	} else {
9465 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
9466 		       sizeof(ut_params->cipher_xform));
9467 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9468 		       sizeof(ut_params->auth_xform));
9469 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
9470 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9471 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9472 
9473 		/* Verify crypto capabilities */
9474 
9475 		if (test_ipsec_crypto_caps_cipher_verify(
9476 				sec_cap,
9477 				&ut_params->cipher_xform) != 0) {
9478 			if (!silent)
9479 				RTE_LOG(INFO, USER1,
9480 					"Cipher crypto capabilities not supported\n");
9481 			return TEST_SKIPPED;
9482 		}
9483 
9484 		if (test_ipsec_crypto_caps_auth_verify(
9485 				sec_cap,
9486 				&ut_params->auth_xform) != 0) {
9487 			if (!silent)
9488 				RTE_LOG(INFO, USER1,
9489 					"Auth crypto capabilities not supported\n");
9490 			return TEST_SKIPPED;
9491 		}
9492 	}
9493 
9494 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9495 		return TEST_SKIPPED;
9496 
9497 	struct rte_security_session_conf sess_conf = {
9498 		.action_type = ut_params->type,
9499 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9500 	};
9501 
9502 	if (td[0].aead || td[0].aes_gmac) {
9503 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9504 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9505 	}
9506 
9507 	if (td[0].aead) {
9508 		sess_conf.ipsec = ipsec_xform;
9509 		sess_conf.crypto_xform = &ut_params->aead_xform;
9510 	} else if (td[0].auth_only) {
9511 		sess_conf.ipsec = ipsec_xform;
9512 		sess_conf.crypto_xform = &ut_params->auth_xform;
9513 	} else {
9514 		sess_conf.ipsec = ipsec_xform;
9515 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
9516 			sess_conf.crypto_xform = &ut_params->cipher_xform;
9517 			ut_params->cipher_xform.next = &ut_params->auth_xform;
9518 		} else {
9519 			sess_conf.crypto_xform = &ut_params->auth_xform;
9520 			ut_params->auth_xform.next = &ut_params->cipher_xform;
9521 		}
9522 	}
9523 
9524 	/* Create security session */
9525 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9526 					ts_params->session_mpool);
9527 
9528 	if (ut_params->sec_session == NULL)
9529 		return TEST_SKIPPED;
9530 
9531 	for (i = 0; i < nb_td; i++) {
9532 		if (flags->antireplay &&
9533 		    (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
9534 			sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
9535 			ret = rte_security_session_update(ctx,
9536 				ut_params->sec_session, &sess_conf);
9537 			if (ret) {
9538 				printf("Could not update sequence number in "
9539 				       "session\n");
9540 				return TEST_SKIPPED;
9541 			}
9542 		}
9543 
9544 		/* Setup source mbuf payload */
9545 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9546 		memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9547 				rte_pktmbuf_tailroom(ut_params->ibuf));
9548 
9549 		input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9550 				td[i].input_text.len);
9551 
9552 		memcpy(input_text, td[i].input_text.data,
9553 		       td[i].input_text.len);
9554 
9555 		if (test_ipsec_pkt_update(input_text, flags))
9556 			return TEST_FAILED;
9557 
9558 		/* Generate crypto op data structure */
9559 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9560 					RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9561 		if (!ut_params->op) {
9562 			printf("TestCase %s line %d: %s\n",
9563 				__func__, __LINE__,
9564 				"failed to allocate crypto op");
9565 			ret = TEST_FAILED;
9566 			goto crypto_op_free;
9567 		}
9568 
9569 		/* Attach session to operation */
9570 		rte_security_attach_session(ut_params->op,
9571 					    ut_params->sec_session);
9572 
9573 		/* Set crypto operation mbufs */
9574 		ut_params->op->sym->m_src = ut_params->ibuf;
9575 		ut_params->op->sym->m_dst = NULL;
9576 
9577 		/* Copy IV in crypto operation when IV generation is disabled */
9578 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9579 		    ipsec_xform.options.iv_gen_disable == 1) {
9580 			uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9581 								uint8_t *,
9582 								IV_OFFSET);
9583 			int len;
9584 
9585 			if (td[i].aead)
9586 				len = td[i].xform.aead.aead.iv.length;
9587 			else if (td[i].aes_gmac)
9588 				len = td[i].xform.chain.auth.auth.iv.length;
9589 			else
9590 				len = td[i].xform.chain.cipher.cipher.iv.length;
9591 
9592 			memcpy(iv, td[i].iv.data, len);
9593 		}
9594 
9595 		/* Process crypto operation */
9596 		process_crypto_request(dev_id, ut_params->op);
9597 
9598 		ret = test_ipsec_status_check(&td[i], ut_params->op, flags, dir,
9599 					      i + 1);
9600 		if (ret != TEST_SUCCESS)
9601 			goto crypto_op_free;
9602 
9603 		if (res_d != NULL)
9604 			res_d_tmp = &res_d[i];
9605 
9606 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9607 					      res_d_tmp, silent, flags);
9608 		if (ret != TEST_SUCCESS)
9609 			goto crypto_op_free;
9610 
9611 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
9612 					      flags, dir);
9613 		if (ret != TEST_SUCCESS)
9614 			goto crypto_op_free;
9615 
9616 		rte_crypto_op_free(ut_params->op);
9617 		ut_params->op = NULL;
9618 
9619 		rte_pktmbuf_free(ut_params->ibuf);
9620 		ut_params->ibuf = NULL;
9621 	}
9622 
9623 crypto_op_free:
9624 	rte_crypto_op_free(ut_params->op);
9625 	ut_params->op = NULL;
9626 
9627 	rte_pktmbuf_free(ut_params->ibuf);
9628 	ut_params->ibuf = NULL;
9629 
9630 	if (ut_params->sec_session)
9631 		rte_security_session_destroy(ctx, ut_params->sec_session);
9632 	ut_params->sec_session = NULL;
9633 
9634 	return ret;
9635 }
9636 
9637 static int
9638 test_ipsec_proto_known_vec(const void *test_data)
9639 {
9640 	struct ipsec_test_data td_outb;
9641 	struct ipsec_test_flags flags;
9642 
9643 	memset(&flags, 0, sizeof(flags));
9644 
9645 	memcpy(&td_outb, test_data, sizeof(td_outb));
9646 
9647 	if (td_outb.aes_gmac || td_outb.aead ||
9648 	    ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
9649 	     (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
9650 		/* Disable IV gen to be able to test with known vectors */
9651 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
9652 	}
9653 
9654 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9655 }
9656 
9657 static int
9658 test_ipsec_proto_known_vec_inb(const void *test_data)
9659 {
9660 	const struct ipsec_test_data *td = test_data;
9661 	struct ipsec_test_flags flags;
9662 	struct ipsec_test_data td_inb;
9663 
9664 	memset(&flags, 0, sizeof(flags));
9665 
9666 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
9667 		test_ipsec_td_in_from_out(td, &td_inb);
9668 	else
9669 		memcpy(&td_inb, td, sizeof(td_inb));
9670 
9671 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9672 }
9673 
9674 static int
9675 test_ipsec_proto_known_vec_fragmented(const void *test_data)
9676 {
9677 	struct ipsec_test_data td_outb;
9678 	struct ipsec_test_flags flags;
9679 
9680 	memset(&flags, 0, sizeof(flags));
9681 	flags.fragment = true;
9682 
9683 	memcpy(&td_outb, test_data, sizeof(td_outb));
9684 
9685 	/* Disable IV gen to be able to test with known vectors */
9686 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
9687 
9688 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9689 }
9690 
9691 static int
9692 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9693 {
9694 	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9695 	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9696 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
9697 	int ret;
9698 
9699 	if (flags->iv_gen ||
9700 	    flags->sa_expiry_pkts_soft ||
9701 	    flags->sa_expiry_pkts_hard)
9702 		nb_pkts = IPSEC_TEST_PACKETS_MAX;
9703 
9704 	for (i = 0; i < RTE_DIM(alg_list); i++) {
9705 		test_ipsec_td_prepare(alg_list[i].param1,
9706 				      alg_list[i].param2,
9707 				      flags,
9708 				      td_outb,
9709 				      nb_pkts);
9710 
9711 		if (!td_outb->aead) {
9712 			enum rte_crypto_cipher_algorithm cipher_alg;
9713 			enum rte_crypto_auth_algorithm auth_alg;
9714 
9715 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
9716 			auth_alg = td_outb->xform.chain.auth.auth.algo;
9717 
9718 			if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
9719 				continue;
9720 
9721 			/* ICV is not applicable for NULL auth */
9722 			if (flags->icv_corrupt &&
9723 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
9724 				continue;
9725 
9726 			/* IV is not applicable for NULL cipher */
9727 			if (flags->iv_gen &&
9728 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
9729 				continue;
9730 		}
9731 
9732 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9733 					       flags);
9734 		if (ret == TEST_SKIPPED)
9735 			continue;
9736 
9737 		if (ret == TEST_FAILED)
9738 			return TEST_FAILED;
9739 
9740 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9741 
9742 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9743 					       flags);
9744 		if (ret == TEST_SKIPPED)
9745 			continue;
9746 
9747 		if (ret == TEST_FAILED)
9748 			return TEST_FAILED;
9749 
9750 		if (flags->display_alg)
9751 			test_ipsec_display_alg(alg_list[i].param1,
9752 					       alg_list[i].param2);
9753 
9754 		pass_cnt++;
9755 	}
9756 
9757 	if (pass_cnt > 0)
9758 		return TEST_SUCCESS;
9759 	else
9760 		return TEST_SKIPPED;
9761 }
9762 
9763 static int
9764 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
9765 {
9766 	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9767 	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9768 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
9769 	int ret;
9770 
9771 	for (i = 0; i < RTE_DIM(ah_alg_list); i++) {
9772 		test_ipsec_td_prepare(ah_alg_list[i].param1,
9773 				      ah_alg_list[i].param2,
9774 				      flags,
9775 				      td_outb,
9776 				      nb_pkts);
9777 
9778 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9779 					       flags);
9780 		if (ret == TEST_SKIPPED)
9781 			continue;
9782 
9783 		if (ret == TEST_FAILED)
9784 			return TEST_FAILED;
9785 
9786 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9787 
9788 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9789 					       flags);
9790 		if (ret == TEST_SKIPPED)
9791 			continue;
9792 
9793 		if (ret == TEST_FAILED)
9794 			return TEST_FAILED;
9795 
9796 		if (flags->display_alg)
9797 			test_ipsec_display_alg(ah_alg_list[i].param1,
9798 					       ah_alg_list[i].param2);
9799 
9800 		pass_cnt++;
9801 	}
9802 
9803 	if (pass_cnt > 0)
9804 		return TEST_SUCCESS;
9805 	else
9806 		return TEST_SKIPPED;
9807 }
9808 
9809 static int
9810 test_ipsec_proto_display_list(const void *data __rte_unused)
9811 {
9812 	struct ipsec_test_flags flags;
9813 
9814 	memset(&flags, 0, sizeof(flags));
9815 
9816 	flags.display_alg = true;
9817 
9818 	return test_ipsec_proto_all(&flags);
9819 }
9820 
9821 static int
9822 test_ipsec_proto_ah_tunnel_ipv4(const void *data __rte_unused)
9823 {
9824 	struct ipsec_test_flags flags;
9825 
9826 	memset(&flags, 0, sizeof(flags));
9827 
9828 	flags.ah = true;
9829 	flags.display_alg = true;
9830 
9831 	return test_ipsec_ah_proto_all(&flags);
9832 }
9833 
9834 static int
9835 test_ipsec_proto_ah_transport_ipv4(const void *data __rte_unused)
9836 {
9837 	struct ipsec_test_flags flags;
9838 
9839 	memset(&flags, 0, sizeof(flags));
9840 
9841 	flags.ah = true;
9842 	flags.transport = true;
9843 
9844 	return test_ipsec_ah_proto_all(&flags);
9845 }
9846 
9847 static int
9848 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9849 {
9850 	struct ipsec_test_flags flags;
9851 
9852 	memset(&flags, 0, sizeof(flags));
9853 
9854 	flags.iv_gen = true;
9855 
9856 	return test_ipsec_proto_all(&flags);
9857 }
9858 
9859 static int
9860 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9861 {
9862 	struct ipsec_test_flags flags;
9863 
9864 	memset(&flags, 0, sizeof(flags));
9865 
9866 	flags.sa_expiry_pkts_soft = true;
9867 
9868 	return test_ipsec_proto_all(&flags);
9869 }
9870 
9871 static int
9872 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9873 {
9874 	struct ipsec_test_flags flags;
9875 
9876 	memset(&flags, 0, sizeof(flags));
9877 
9878 	flags.sa_expiry_pkts_hard = true;
9879 
9880 	return test_ipsec_proto_all(&flags);
9881 }
9882 
9883 static int
9884 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9885 {
9886 	struct ipsec_test_flags flags;
9887 
9888 	memset(&flags, 0, sizeof(flags));
9889 
9890 	flags.icv_corrupt = true;
9891 
9892 	return test_ipsec_proto_all(&flags);
9893 }
9894 
9895 static int
9896 test_ipsec_proto_udp_encap_custom_ports(const void *data __rte_unused)
9897 {
9898 	struct ipsec_test_flags flags;
9899 
9900 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
9901 			RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
9902 		return TEST_SKIPPED;
9903 
9904 	memset(&flags, 0, sizeof(flags));
9905 
9906 	flags.udp_encap = true;
9907 	flags.udp_encap_custom_ports = true;
9908 
9909 	return test_ipsec_proto_all(&flags);
9910 }
9911 
9912 static int
9913 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9914 {
9915 	struct ipsec_test_flags flags;
9916 
9917 	memset(&flags, 0, sizeof(flags));
9918 
9919 	flags.udp_encap = true;
9920 
9921 	return test_ipsec_proto_all(&flags);
9922 }
9923 
9924 static int
9925 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9926 {
9927 	struct ipsec_test_flags flags;
9928 
9929 	memset(&flags, 0, sizeof(flags));
9930 
9931 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9932 
9933 	return test_ipsec_proto_all(&flags);
9934 }
9935 
9936 static int
9937 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9938 {
9939 	struct ipsec_test_flags flags;
9940 
9941 	memset(&flags, 0, sizeof(flags));
9942 
9943 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9944 
9945 	return test_ipsec_proto_all(&flags);
9946 }
9947 
9948 static int
9949 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9950 {
9951 	struct ipsec_test_flags flags;
9952 
9953 	memset(&flags, 0, sizeof(flags));
9954 
9955 	flags.udp_encap = true;
9956 	flags.udp_ports_verify = true;
9957 
9958 	return test_ipsec_proto_all(&flags);
9959 }
9960 
9961 static int
9962 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9963 {
9964 	struct ipsec_test_flags flags;
9965 
9966 	memset(&flags, 0, sizeof(flags));
9967 
9968 	flags.ip_csum = true;
9969 
9970 	return test_ipsec_proto_all(&flags);
9971 }
9972 
9973 static int
9974 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9975 {
9976 	struct ipsec_test_flags flags;
9977 
9978 	memset(&flags, 0, sizeof(flags));
9979 
9980 	flags.l4_csum = true;
9981 
9982 	return test_ipsec_proto_all(&flags);
9983 }
9984 
9985 static int
9986 test_ipsec_proto_tunnel_v4_in_v4(const void *data __rte_unused)
9987 {
9988 	struct ipsec_test_flags flags;
9989 
9990 	memset(&flags, 0, sizeof(flags));
9991 
9992 	flags.ipv6 = false;
9993 	flags.tunnel_ipv6 = false;
9994 
9995 	return test_ipsec_proto_all(&flags);
9996 }
9997 
9998 static int
9999 test_ipsec_proto_tunnel_v6_in_v6(const void *data __rte_unused)
10000 {
10001 	struct ipsec_test_flags flags;
10002 
10003 	memset(&flags, 0, sizeof(flags));
10004 
10005 	flags.ipv6 = true;
10006 	flags.tunnel_ipv6 = true;
10007 
10008 	return test_ipsec_proto_all(&flags);
10009 }
10010 
10011 static int
10012 test_ipsec_proto_tunnel_v4_in_v6(const void *data __rte_unused)
10013 {
10014 	struct ipsec_test_flags flags;
10015 
10016 	memset(&flags, 0, sizeof(flags));
10017 
10018 	flags.ipv6 = false;
10019 	flags.tunnel_ipv6 = true;
10020 
10021 	return test_ipsec_proto_all(&flags);
10022 }
10023 
10024 static int
10025 test_ipsec_proto_tunnel_v6_in_v4(const void *data __rte_unused)
10026 {
10027 	struct ipsec_test_flags flags;
10028 
10029 	memset(&flags, 0, sizeof(flags));
10030 
10031 	flags.ipv6 = true;
10032 	flags.tunnel_ipv6 = false;
10033 
10034 	return test_ipsec_proto_all(&flags);
10035 }
10036 
10037 static int
10038 test_ipsec_proto_transport_v4(const void *data __rte_unused)
10039 {
10040 	struct ipsec_test_flags flags;
10041 
10042 	memset(&flags, 0, sizeof(flags));
10043 
10044 	flags.ipv6 = false;
10045 	flags.transport = true;
10046 
10047 	return test_ipsec_proto_all(&flags);
10048 }
10049 
10050 static int
10051 test_ipsec_proto_transport_l4_csum(const void *data __rte_unused)
10052 {
10053 	struct ipsec_test_flags flags = {
10054 		.l4_csum = true,
10055 		.transport = true,
10056 	};
10057 
10058 	return test_ipsec_proto_all(&flags);
10059 }
10060 
10061 static int
10062 test_ipsec_proto_stats(const void *data __rte_unused)
10063 {
10064 	struct ipsec_test_flags flags;
10065 
10066 	memset(&flags, 0, sizeof(flags));
10067 
10068 	flags.stats_success = true;
10069 
10070 	return test_ipsec_proto_all(&flags);
10071 }
10072 
10073 static int
10074 test_ipsec_proto_pkt_fragment(const void *data __rte_unused)
10075 {
10076 	struct ipsec_test_flags flags;
10077 
10078 	memset(&flags, 0, sizeof(flags));
10079 
10080 	flags.fragment = true;
10081 
10082 	return test_ipsec_proto_all(&flags);
10083 
10084 }
10085 
10086 static int
10087 test_ipsec_proto_copy_df_inner_0(const void *data __rte_unused)
10088 {
10089 	struct ipsec_test_flags flags;
10090 
10091 	memset(&flags, 0, sizeof(flags));
10092 
10093 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10094 
10095 	return test_ipsec_proto_all(&flags);
10096 }
10097 
10098 static int
10099 test_ipsec_proto_copy_df_inner_1(const void *data __rte_unused)
10100 {
10101 	struct ipsec_test_flags flags;
10102 
10103 	memset(&flags, 0, sizeof(flags));
10104 
10105 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10106 
10107 	return test_ipsec_proto_all(&flags);
10108 }
10109 
10110 static int
10111 test_ipsec_proto_set_df_0_inner_1(const void *data __rte_unused)
10112 {
10113 	struct ipsec_test_flags flags;
10114 
10115 	memset(&flags, 0, sizeof(flags));
10116 
10117 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10118 
10119 	return test_ipsec_proto_all(&flags);
10120 }
10121 
10122 static int
10123 test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
10124 {
10125 	struct ipsec_test_flags flags;
10126 
10127 	memset(&flags, 0, sizeof(flags));
10128 
10129 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10130 
10131 	return test_ipsec_proto_all(&flags);
10132 }
10133 
10134 static int
10135 test_ipsec_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused)
10136 {
10137 	struct ipsec_test_flags flags;
10138 
10139 	memset(&flags, 0, sizeof(flags));
10140 
10141 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10142 
10143 	return test_ipsec_proto_all(&flags);
10144 }
10145 
10146 static int
10147 test_ipsec_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused)
10148 {
10149 	struct ipsec_test_flags flags;
10150 
10151 	memset(&flags, 0, sizeof(flags));
10152 
10153 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10154 
10155 	return test_ipsec_proto_all(&flags);
10156 }
10157 
10158 static int
10159 test_ipsec_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused)
10160 {
10161 	struct ipsec_test_flags flags;
10162 
10163 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10164 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10165 		return TEST_SKIPPED;
10166 
10167 	memset(&flags, 0, sizeof(flags));
10168 
10169 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10170 
10171 	return test_ipsec_proto_all(&flags);
10172 }
10173 
10174 static int
10175 test_ipsec_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused)
10176 {
10177 	struct ipsec_test_flags flags;
10178 
10179 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10180 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10181 		return TEST_SKIPPED;
10182 
10183 	memset(&flags, 0, sizeof(flags));
10184 
10185 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
10186 
10187 	return test_ipsec_proto_all(&flags);
10188 }
10189 
10190 static int
10191 test_ipsec_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused)
10192 {
10193 	struct ipsec_test_flags flags;
10194 
10195 	memset(&flags, 0, sizeof(flags));
10196 
10197 	flags.ipv6 = true;
10198 	flags.tunnel_ipv6 = true;
10199 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10200 
10201 	return test_ipsec_proto_all(&flags);
10202 }
10203 
10204 static int
10205 test_ipsec_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused)
10206 {
10207 	struct ipsec_test_flags flags;
10208 
10209 	memset(&flags, 0, sizeof(flags));
10210 
10211 	flags.ipv6 = true;
10212 	flags.tunnel_ipv6 = true;
10213 	flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10214 
10215 	return test_ipsec_proto_all(&flags);
10216 }
10217 
10218 static int
10219 test_ipsec_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused)
10220 {
10221 	struct ipsec_test_flags flags;
10222 
10223 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10224 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10225 		return TEST_SKIPPED;
10226 
10227 	memset(&flags, 0, sizeof(flags));
10228 
10229 	flags.ipv6 = true;
10230 	flags.tunnel_ipv6 = true;
10231 	flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10232 
10233 	return test_ipsec_proto_all(&flags);
10234 }
10235 
10236 static int
10237 test_ipsec_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused)
10238 {
10239 	struct ipsec_test_flags flags;
10240 
10241 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
10242 			RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10243 		return TEST_SKIPPED;
10244 
10245 	memset(&flags, 0, sizeof(flags));
10246 
10247 	flags.ipv6 = true;
10248 	flags.tunnel_ipv6 = true;
10249 	flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
10250 
10251 	return test_ipsec_proto_all(&flags);
10252 }
10253 
10254 static int
10255 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
10256 		      bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
10257 		      uint64_t winsz)
10258 {
10259 	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10260 	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10261 	struct ipsec_test_flags flags;
10262 	uint32_t i = 0, ret = 0;
10263 
10264 	if (nb_pkts == 0)
10265 		return TEST_FAILED;
10266 
10267 	memset(&flags, 0, sizeof(flags));
10268 	flags.antireplay = true;
10269 
10270 	for (i = 0; i < nb_pkts; i++) {
10271 		memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
10272 		td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
10273 		td_outb[i].ipsec_xform.replay_win_sz = winsz;
10274 		td_outb[i].ipsec_xform.options.esn = esn_en;
10275 	}
10276 
10277 	for (i = 0; i < nb_pkts; i++)
10278 		td_outb[i].ipsec_xform.esn.value = esn[i];
10279 
10280 	ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10281 				       &flags);
10282 	if (ret != TEST_SUCCESS)
10283 		return ret;
10284 
10285 	test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
10286 
10287 	for (i = 0; i < nb_pkts; i++) {
10288 		td_inb[i].ipsec_xform.options.esn = esn_en;
10289 		/* Set antireplay flag for packets to be dropped */
10290 		td_inb[i].ar_packet = replayed_pkt[i];
10291 	}
10292 
10293 	ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10294 				       &flags);
10295 
10296 	return ret;
10297 }
10298 
10299 static int
10300 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
10301 {
10302 
10303 	uint32_t nb_pkts = 5;
10304 	bool replayed_pkt[5];
10305 	uint64_t esn[5];
10306 
10307 	/* 1. Advance the TOP of the window to WS * 2 */
10308 	esn[0] = winsz * 2;
10309 	/* 2. Test sequence number within the new window(WS + 1) */
10310 	esn[1] = winsz + 1;
10311 	/* 3. Test sequence number less than the window BOTTOM */
10312 	esn[2] = winsz;
10313 	/* 4. Test sequence number in the middle of the window */
10314 	esn[3] = winsz + (winsz / 2);
10315 	/* 5. Test replay of the packet in the middle of the window */
10316 	esn[4] = winsz + (winsz / 2);
10317 
10318 	replayed_pkt[0] = false;
10319 	replayed_pkt[1] = false;
10320 	replayed_pkt[2] = true;
10321 	replayed_pkt[3] = false;
10322 	replayed_pkt[4] = true;
10323 
10324 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
10325 				     false, winsz);
10326 }
10327 
10328 static int
10329 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
10330 {
10331 	return test_ipsec_proto_pkt_antireplay(test_data, 1024);
10332 }
10333 
10334 static int
10335 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
10336 {
10337 	return test_ipsec_proto_pkt_antireplay(test_data, 2048);
10338 }
10339 
10340 static int
10341 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
10342 {
10343 	return test_ipsec_proto_pkt_antireplay(test_data, 4096);
10344 }
10345 
10346 static int
10347 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
10348 {
10349 
10350 	uint32_t nb_pkts = 7;
10351 	bool replayed_pkt[7];
10352 	uint64_t esn[7];
10353 
10354 	/* Set the initial sequence number */
10355 	esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
10356 	/* 1. Advance the TOP of the window to (1<<32 + WS/2) */
10357 	esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
10358 	/* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
10359 	esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
10360 	/* 3. Test with sequence number within window (1<<32 - 1) */
10361 	esn[3] = (uint64_t)((1ULL << 32) - 1);
10362 	/* 4. Test with sequence number within window (1<<32 - 1) */
10363 	esn[4] = (uint64_t)(1ULL << 32);
10364 	/* 5. Test with duplicate sequence number within
10365 	 * new window (1<<32 - 1)
10366 	 */
10367 	esn[5] = (uint64_t)((1ULL << 32) - 1);
10368 	/* 6. Test with duplicate sequence number within new window (1<<32) */
10369 	esn[6] = (uint64_t)(1ULL << 32);
10370 
10371 	replayed_pkt[0] = false;
10372 	replayed_pkt[1] = false;
10373 	replayed_pkt[2] = false;
10374 	replayed_pkt[3] = false;
10375 	replayed_pkt[4] = false;
10376 	replayed_pkt[5] = true;
10377 	replayed_pkt[6] = true;
10378 
10379 	return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
10380 				     true, winsz);
10381 }
10382 
10383 static int
10384 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
10385 {
10386 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
10387 }
10388 
10389 static int
10390 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
10391 {
10392 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
10393 }
10394 
10395 static int
10396 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
10397 {
10398 	return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
10399 }
10400 
10401 static int
10402 test_PDCP_PROTO_all(void)
10403 {
10404 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10405 	struct crypto_unittest_params *ut_params = &unittest_params;
10406 	struct rte_cryptodev_info dev_info;
10407 	int status;
10408 
10409 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10410 	uint64_t feat_flags = dev_info.feature_flags;
10411 
10412 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
10413 		return TEST_SKIPPED;
10414 
10415 	/* Set action type */
10416 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10417 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10418 		gbl_action_type;
10419 
10420 	if (security_proto_supported(ut_params->type,
10421 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
10422 		return TEST_SKIPPED;
10423 
10424 	status = test_PDCP_PROTO_cplane_encap_all();
10425 	status += test_PDCP_PROTO_cplane_decap_all();
10426 	status += test_PDCP_PROTO_uplane_encap_all();
10427 	status += test_PDCP_PROTO_uplane_decap_all();
10428 	status += test_PDCP_PROTO_SGL_in_place_32B();
10429 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
10430 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
10431 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
10432 	status += test_PDCP_SDAP_PROTO_encap_all();
10433 	status += test_PDCP_SDAP_PROTO_decap_all();
10434 	status += test_PDCP_PROTO_short_mac();
10435 
10436 	if (status)
10437 		return TEST_FAILED;
10438 	else
10439 		return TEST_SUCCESS;
10440 }
10441 
10442 static int
10443 test_ipsec_proto_ipv4_ttl_decrement(const void *data __rte_unused)
10444 {
10445 	struct ipsec_test_flags flags = {
10446 		.dec_ttl_or_hop_limit = true
10447 	};
10448 
10449 	return test_ipsec_proto_all(&flags);
10450 }
10451 
10452 static int
10453 test_ipsec_proto_ipv6_hop_limit_decrement(const void *data __rte_unused)
10454 {
10455 	struct ipsec_test_flags flags = {
10456 		.ipv6 = true,
10457 		.dec_ttl_or_hop_limit = true
10458 	};
10459 
10460 	return test_ipsec_proto_all(&flags);
10461 }
10462 
10463 static int
10464 test_docsis_proto_uplink(const void *data)
10465 {
10466 	const struct docsis_test_data *d_td = data;
10467 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10468 	struct crypto_unittest_params *ut_params = &unittest_params;
10469 	uint8_t *plaintext = NULL;
10470 	uint8_t *ciphertext = NULL;
10471 	uint8_t *iv_ptr;
10472 	int32_t cipher_len, crc_len;
10473 	uint32_t crc_data_len;
10474 	int ret = TEST_SUCCESS;
10475 
10476 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10477 					rte_cryptodev_get_sec_ctx(
10478 						ts_params->valid_devs[0]);
10479 
10480 	/* Verify the capabilities */
10481 	struct rte_security_capability_idx sec_cap_idx;
10482 	const struct rte_security_capability *sec_cap;
10483 	const struct rte_cryptodev_capabilities *crypto_cap;
10484 	const struct rte_cryptodev_symmetric_capability *sym_cap;
10485 	int j = 0;
10486 
10487 	/* Set action type */
10488 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10489 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10490 		gbl_action_type;
10491 
10492 	if (security_proto_supported(ut_params->type,
10493 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10494 		return TEST_SKIPPED;
10495 
10496 	sec_cap_idx.action = ut_params->type;
10497 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10498 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
10499 
10500 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10501 	if (sec_cap == NULL)
10502 		return TEST_SKIPPED;
10503 
10504 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10505 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10506 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10507 				crypto_cap->sym.xform_type ==
10508 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
10509 				crypto_cap->sym.cipher.algo ==
10510 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10511 			sym_cap = &crypto_cap->sym;
10512 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10513 						d_td->key.len,
10514 						d_td->iv.len) == 0)
10515 				break;
10516 		}
10517 	}
10518 
10519 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10520 		return TEST_SKIPPED;
10521 
10522 	/* Setup source mbuf payload */
10523 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10524 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10525 			rte_pktmbuf_tailroom(ut_params->ibuf));
10526 
10527 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10528 			d_td->ciphertext.len);
10529 
10530 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
10531 
10532 	/* Setup cipher session parameters */
10533 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10534 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10535 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10536 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10537 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10538 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10539 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10540 	ut_params->cipher_xform.next = NULL;
10541 
10542 	/* Setup DOCSIS session parameters */
10543 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
10544 
10545 	struct rte_security_session_conf sess_conf = {
10546 		.action_type = ut_params->type,
10547 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10548 		.docsis = ut_params->docsis_xform,
10549 		.crypto_xform = &ut_params->cipher_xform,
10550 	};
10551 
10552 	/* Create security session */
10553 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10554 					ts_params->session_mpool);
10555 
10556 	if (!ut_params->sec_session) {
10557 		printf("Test function %s line %u: failed to allocate session\n",
10558 			__func__, __LINE__);
10559 		ret = TEST_FAILED;
10560 		goto on_err;
10561 	}
10562 
10563 	/* Generate crypto op data structure */
10564 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10565 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10566 	if (!ut_params->op) {
10567 		printf("Test function %s line %u: failed to allocate symmetric "
10568 			"crypto operation\n", __func__, __LINE__);
10569 		ret = TEST_FAILED;
10570 		goto on_err;
10571 	}
10572 
10573 	/* Setup CRC operation parameters */
10574 	crc_len = d_td->ciphertext.no_crc == false ?
10575 			(d_td->ciphertext.len -
10576 				d_td->ciphertext.crc_offset -
10577 				RTE_ETHER_CRC_LEN) :
10578 			0;
10579 	crc_len = crc_len > 0 ? crc_len : 0;
10580 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
10581 	ut_params->op->sym->auth.data.length = crc_len;
10582 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
10583 
10584 	/* Setup cipher operation parameters */
10585 	cipher_len = d_td->ciphertext.no_cipher == false ?
10586 			(d_td->ciphertext.len -
10587 				d_td->ciphertext.cipher_offset) :
10588 			0;
10589 	cipher_len = cipher_len > 0 ? cipher_len : 0;
10590 	ut_params->op->sym->cipher.data.length = cipher_len;
10591 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
10592 
10593 	/* Setup cipher IV */
10594 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10595 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10596 
10597 	/* Attach session to operation */
10598 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10599 
10600 	/* Set crypto operation mbufs */
10601 	ut_params->op->sym->m_src = ut_params->ibuf;
10602 	ut_params->op->sym->m_dst = NULL;
10603 
10604 	/* Process crypto operation */
10605 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10606 			NULL) {
10607 		printf("Test function %s line %u: failed to process security "
10608 			"crypto op\n", __func__, __LINE__);
10609 		ret = TEST_FAILED;
10610 		goto on_err;
10611 	}
10612 
10613 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10614 		printf("Test function %s line %u: failed to process crypto op\n",
10615 			__func__, __LINE__);
10616 		ret = TEST_FAILED;
10617 		goto on_err;
10618 	}
10619 
10620 	/* Validate plaintext */
10621 	plaintext = ciphertext;
10622 
10623 	if (memcmp(plaintext, d_td->plaintext.data,
10624 			d_td->plaintext.len - crc_data_len)) {
10625 		printf("Test function %s line %u: plaintext not as expected\n",
10626 			__func__, __LINE__);
10627 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
10628 				d_td->plaintext.len);
10629 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
10630 		ret = TEST_FAILED;
10631 		goto on_err;
10632 	}
10633 
10634 on_err:
10635 	rte_crypto_op_free(ut_params->op);
10636 	ut_params->op = NULL;
10637 
10638 	if (ut_params->sec_session)
10639 		rte_security_session_destroy(ctx, ut_params->sec_session);
10640 	ut_params->sec_session = NULL;
10641 
10642 	rte_pktmbuf_free(ut_params->ibuf);
10643 	ut_params->ibuf = NULL;
10644 
10645 	return ret;
10646 }
10647 
10648 static int
10649 test_docsis_proto_downlink(const void *data)
10650 {
10651 	const struct docsis_test_data *d_td = data;
10652 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10653 	struct crypto_unittest_params *ut_params = &unittest_params;
10654 	uint8_t *plaintext = NULL;
10655 	uint8_t *ciphertext = NULL;
10656 	uint8_t *iv_ptr;
10657 	int32_t cipher_len, crc_len;
10658 	int ret = TEST_SUCCESS;
10659 
10660 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10661 					rte_cryptodev_get_sec_ctx(
10662 						ts_params->valid_devs[0]);
10663 
10664 	/* Verify the capabilities */
10665 	struct rte_security_capability_idx sec_cap_idx;
10666 	const struct rte_security_capability *sec_cap;
10667 	const struct rte_cryptodev_capabilities *crypto_cap;
10668 	const struct rte_cryptodev_symmetric_capability *sym_cap;
10669 	int j = 0;
10670 
10671 	/* Set action type */
10672 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10673 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10674 		gbl_action_type;
10675 
10676 	if (security_proto_supported(ut_params->type,
10677 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10678 		return TEST_SKIPPED;
10679 
10680 	sec_cap_idx.action = ut_params->type;
10681 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10682 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10683 
10684 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10685 	if (sec_cap == NULL)
10686 		return TEST_SKIPPED;
10687 
10688 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10689 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10690 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10691 				crypto_cap->sym.xform_type ==
10692 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
10693 				crypto_cap->sym.cipher.algo ==
10694 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10695 			sym_cap = &crypto_cap->sym;
10696 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10697 						d_td->key.len,
10698 						d_td->iv.len) == 0)
10699 				break;
10700 		}
10701 	}
10702 
10703 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10704 		return TEST_SKIPPED;
10705 
10706 	/* Setup source mbuf payload */
10707 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10708 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10709 			rte_pktmbuf_tailroom(ut_params->ibuf));
10710 
10711 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10712 			d_td->plaintext.len);
10713 
10714 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
10715 
10716 	/* Setup cipher session parameters */
10717 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10718 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10719 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10720 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10721 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10722 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10723 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10724 	ut_params->cipher_xform.next = NULL;
10725 
10726 	/* Setup DOCSIS session parameters */
10727 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10728 
10729 	struct rte_security_session_conf sess_conf = {
10730 		.action_type = ut_params->type,
10731 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10732 		.docsis = ut_params->docsis_xform,
10733 		.crypto_xform = &ut_params->cipher_xform,
10734 	};
10735 
10736 	/* Create security session */
10737 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10738 					ts_params->session_mpool);
10739 
10740 	if (!ut_params->sec_session) {
10741 		printf("Test function %s line %u: failed to allocate session\n",
10742 			__func__, __LINE__);
10743 		ret = TEST_FAILED;
10744 		goto on_err;
10745 	}
10746 
10747 	/* Generate crypto op data structure */
10748 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10749 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10750 	if (!ut_params->op) {
10751 		printf("Test function %s line %u: failed to allocate symmetric "
10752 			"crypto operation\n", __func__, __LINE__);
10753 		ret = TEST_FAILED;
10754 		goto on_err;
10755 	}
10756 
10757 	/* Setup CRC operation parameters */
10758 	crc_len = d_td->plaintext.no_crc == false ?
10759 			(d_td->plaintext.len -
10760 				d_td->plaintext.crc_offset -
10761 				RTE_ETHER_CRC_LEN) :
10762 			0;
10763 	crc_len = crc_len > 0 ? crc_len : 0;
10764 	ut_params->op->sym->auth.data.length = crc_len;
10765 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
10766 
10767 	/* Setup cipher operation parameters */
10768 	cipher_len = d_td->plaintext.no_cipher == false ?
10769 			(d_td->plaintext.len -
10770 				d_td->plaintext.cipher_offset) :
10771 			0;
10772 	cipher_len = cipher_len > 0 ? cipher_len : 0;
10773 	ut_params->op->sym->cipher.data.length = cipher_len;
10774 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
10775 
10776 	/* Setup cipher IV */
10777 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10778 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10779 
10780 	/* Attach session to operation */
10781 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10782 
10783 	/* Set crypto operation mbufs */
10784 	ut_params->op->sym->m_src = ut_params->ibuf;
10785 	ut_params->op->sym->m_dst = NULL;
10786 
10787 	/* Process crypto operation */
10788 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10789 			NULL) {
10790 		printf("Test function %s line %u: failed to process crypto op\n",
10791 			__func__, __LINE__);
10792 		ret = TEST_FAILED;
10793 		goto on_err;
10794 	}
10795 
10796 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10797 		printf("Test function %s line %u: crypto op processing failed\n",
10798 			__func__, __LINE__);
10799 		ret = TEST_FAILED;
10800 		goto on_err;
10801 	}
10802 
10803 	/* Validate ciphertext */
10804 	ciphertext = plaintext;
10805 
10806 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
10807 		printf("Test function %s line %u: plaintext not as expected\n",
10808 			__func__, __LINE__);
10809 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
10810 				d_td->ciphertext.len);
10811 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
10812 		ret = TEST_FAILED;
10813 		goto on_err;
10814 	}
10815 
10816 on_err:
10817 	rte_crypto_op_free(ut_params->op);
10818 	ut_params->op = NULL;
10819 
10820 	if (ut_params->sec_session)
10821 		rte_security_session_destroy(ctx, ut_params->sec_session);
10822 	ut_params->sec_session = NULL;
10823 
10824 	rte_pktmbuf_free(ut_params->ibuf);
10825 	ut_params->ibuf = NULL;
10826 
10827 	return ret;
10828 }
10829 #endif
10830 
10831 static int
10832 test_AES_GCM_authenticated_encryption_test_case_1(void)
10833 {
10834 	return test_authenticated_encryption(&gcm_test_case_1);
10835 }
10836 
10837 static int
10838 test_AES_GCM_authenticated_encryption_test_case_2(void)
10839 {
10840 	return test_authenticated_encryption(&gcm_test_case_2);
10841 }
10842 
10843 static int
10844 test_AES_GCM_authenticated_encryption_test_case_3(void)
10845 {
10846 	return test_authenticated_encryption(&gcm_test_case_3);
10847 }
10848 
10849 static int
10850 test_AES_GCM_authenticated_encryption_test_case_4(void)
10851 {
10852 	return test_authenticated_encryption(&gcm_test_case_4);
10853 }
10854 
10855 static int
10856 test_AES_GCM_authenticated_encryption_test_case_5(void)
10857 {
10858 	return test_authenticated_encryption(&gcm_test_case_5);
10859 }
10860 
10861 static int
10862 test_AES_GCM_authenticated_encryption_test_case_6(void)
10863 {
10864 	return test_authenticated_encryption(&gcm_test_case_6);
10865 }
10866 
10867 static int
10868 test_AES_GCM_authenticated_encryption_test_case_7(void)
10869 {
10870 	return test_authenticated_encryption(&gcm_test_case_7);
10871 }
10872 
10873 static int
10874 test_AES_GCM_authenticated_encryption_test_case_8(void)
10875 {
10876 	return test_authenticated_encryption(&gcm_test_case_8);
10877 }
10878 
10879 static int
10880 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10881 {
10882 	return test_authenticated_encryption(&gcm_J0_test_case_1);
10883 }
10884 
10885 static int
10886 test_AES_GCM_auth_encryption_test_case_192_1(void)
10887 {
10888 	return test_authenticated_encryption(&gcm_test_case_192_1);
10889 }
10890 
10891 static int
10892 test_AES_GCM_auth_encryption_test_case_192_2(void)
10893 {
10894 	return test_authenticated_encryption(&gcm_test_case_192_2);
10895 }
10896 
10897 static int
10898 test_AES_GCM_auth_encryption_test_case_192_3(void)
10899 {
10900 	return test_authenticated_encryption(&gcm_test_case_192_3);
10901 }
10902 
10903 static int
10904 test_AES_GCM_auth_encryption_test_case_192_4(void)
10905 {
10906 	return test_authenticated_encryption(&gcm_test_case_192_4);
10907 }
10908 
10909 static int
10910 test_AES_GCM_auth_encryption_test_case_192_5(void)
10911 {
10912 	return test_authenticated_encryption(&gcm_test_case_192_5);
10913 }
10914 
10915 static int
10916 test_AES_GCM_auth_encryption_test_case_192_6(void)
10917 {
10918 	return test_authenticated_encryption(&gcm_test_case_192_6);
10919 }
10920 
10921 static int
10922 test_AES_GCM_auth_encryption_test_case_192_7(void)
10923 {
10924 	return test_authenticated_encryption(&gcm_test_case_192_7);
10925 }
10926 
10927 static int
10928 test_AES_GCM_auth_encryption_test_case_256_1(void)
10929 {
10930 	return test_authenticated_encryption(&gcm_test_case_256_1);
10931 }
10932 
10933 static int
10934 test_AES_GCM_auth_encryption_test_case_256_2(void)
10935 {
10936 	return test_authenticated_encryption(&gcm_test_case_256_2);
10937 }
10938 
10939 static int
10940 test_AES_GCM_auth_encryption_test_case_256_3(void)
10941 {
10942 	return test_authenticated_encryption(&gcm_test_case_256_3);
10943 }
10944 
10945 static int
10946 test_AES_GCM_auth_encryption_test_case_256_4(void)
10947 {
10948 	return test_authenticated_encryption(&gcm_test_case_256_4);
10949 }
10950 
10951 static int
10952 test_AES_GCM_auth_encryption_test_case_256_5(void)
10953 {
10954 	return test_authenticated_encryption(&gcm_test_case_256_5);
10955 }
10956 
10957 static int
10958 test_AES_GCM_auth_encryption_test_case_256_6(void)
10959 {
10960 	return test_authenticated_encryption(&gcm_test_case_256_6);
10961 }
10962 
10963 static int
10964 test_AES_GCM_auth_encryption_test_case_256_7(void)
10965 {
10966 	return test_authenticated_encryption(&gcm_test_case_256_7);
10967 }
10968 
10969 static int
10970 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10971 {
10972 	return test_authenticated_encryption(&gcm_test_case_aad_1);
10973 }
10974 
10975 static int
10976 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10977 {
10978 	return test_authenticated_encryption(&gcm_test_case_aad_2);
10979 }
10980 
10981 static int
10982 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10983 {
10984 	struct aead_test_data tdata;
10985 	int res;
10986 
10987 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10988 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10989 	tdata.iv.data[0] += 1;
10990 	res = test_authenticated_encryption(&tdata);
10991 	if (res == TEST_SKIPPED)
10992 		return res;
10993 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10994 	return TEST_SUCCESS;
10995 }
10996 
10997 static int
10998 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10999 {
11000 	struct aead_test_data tdata;
11001 	int res;
11002 
11003 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11004 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11005 	tdata.plaintext.data[0] += 1;
11006 	res = test_authenticated_encryption(&tdata);
11007 	if (res == TEST_SKIPPED)
11008 		return res;
11009 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11010 	return TEST_SUCCESS;
11011 }
11012 
11013 static int
11014 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
11015 {
11016 	struct aead_test_data tdata;
11017 	int res;
11018 
11019 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11020 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11021 	tdata.ciphertext.data[0] += 1;
11022 	res = test_authenticated_encryption(&tdata);
11023 	if (res == TEST_SKIPPED)
11024 		return res;
11025 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11026 	return TEST_SUCCESS;
11027 }
11028 
11029 static int
11030 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
11031 {
11032 	struct aead_test_data tdata;
11033 	int res;
11034 
11035 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11036 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11037 	tdata.aad.len += 1;
11038 	res = test_authenticated_encryption(&tdata);
11039 	if (res == TEST_SKIPPED)
11040 		return res;
11041 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11042 	return TEST_SUCCESS;
11043 }
11044 
11045 static int
11046 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
11047 {
11048 	struct aead_test_data tdata;
11049 	uint8_t aad[gcm_test_case_7.aad.len];
11050 	int res;
11051 
11052 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11053 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11054 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
11055 	aad[0] += 1;
11056 	tdata.aad.data = aad;
11057 	res = test_authenticated_encryption(&tdata);
11058 	if (res == TEST_SKIPPED)
11059 		return res;
11060 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11061 	return TEST_SUCCESS;
11062 }
11063 
11064 static int
11065 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
11066 {
11067 	struct aead_test_data tdata;
11068 	int res;
11069 
11070 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11071 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11072 	tdata.auth_tag.data[0] += 1;
11073 	res = test_authenticated_encryption(&tdata);
11074 	if (res == TEST_SKIPPED)
11075 		return res;
11076 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
11077 	return TEST_SUCCESS;
11078 }
11079 
11080 static int
11081 test_authenticated_decryption(const struct aead_test_data *tdata)
11082 {
11083 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11084 	struct crypto_unittest_params *ut_params = &unittest_params;
11085 
11086 	int retval;
11087 	uint8_t *plaintext;
11088 	uint32_t i;
11089 	struct rte_cryptodev_info dev_info;
11090 
11091 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11092 	uint64_t feat_flags = dev_info.feature_flags;
11093 
11094 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11095 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11096 		printf("Device doesn't support RAW data-path APIs.\n");
11097 		return TEST_SKIPPED;
11098 	}
11099 
11100 	/* Verify the capabilities */
11101 	struct rte_cryptodev_sym_capability_idx cap_idx;
11102 	const struct rte_cryptodev_symmetric_capability *capability;
11103 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11104 	cap_idx.algo.aead = tdata->algo;
11105 	capability = rte_cryptodev_sym_capability_get(
11106 			ts_params->valid_devs[0], &cap_idx);
11107 	if (capability == NULL)
11108 		return TEST_SKIPPED;
11109 	if (rte_cryptodev_sym_capability_check_aead(
11110 			capability, tdata->key.len, tdata->auth_tag.len,
11111 			tdata->aad.len, tdata->iv.len))
11112 		return TEST_SKIPPED;
11113 
11114 	/* Create AEAD session */
11115 	retval = create_aead_session(ts_params->valid_devs[0],
11116 			tdata->algo,
11117 			RTE_CRYPTO_AEAD_OP_DECRYPT,
11118 			tdata->key.data, tdata->key.len,
11119 			tdata->aad.len, tdata->auth_tag.len,
11120 			tdata->iv.len);
11121 	if (retval < 0)
11122 		return retval;
11123 
11124 	/* alloc mbuf and set payload */
11125 	if (tdata->aad.len > MBUF_SIZE) {
11126 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11127 		/* Populate full size of add data */
11128 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
11129 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
11130 	} else
11131 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11132 
11133 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11134 			rte_pktmbuf_tailroom(ut_params->ibuf));
11135 
11136 	/* Create AEAD operation */
11137 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11138 	if (retval < 0)
11139 		return retval;
11140 
11141 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11142 
11143 	ut_params->op->sym->m_src = ut_params->ibuf;
11144 
11145 	/* Process crypto operation */
11146 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11147 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11148 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11149 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11150 				ut_params->op, 0, 0, 0, 0);
11151 	else
11152 		TEST_ASSERT_NOT_NULL(
11153 			process_crypto_request(ts_params->valid_devs[0],
11154 			ut_params->op), "failed to process sym crypto op");
11155 
11156 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11157 			"crypto op processing failed");
11158 
11159 	if (ut_params->op->sym->m_dst)
11160 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
11161 				uint8_t *);
11162 	else
11163 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11164 				uint8_t *,
11165 				ut_params->op->sym->cipher.data.offset);
11166 
11167 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11168 
11169 	/* Validate obuf */
11170 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11171 			plaintext,
11172 			tdata->plaintext.data,
11173 			tdata->plaintext.len,
11174 			"Plaintext data not as expected");
11175 
11176 	TEST_ASSERT_EQUAL(ut_params->op->status,
11177 			RTE_CRYPTO_OP_STATUS_SUCCESS,
11178 			"Authentication failed");
11179 
11180 	return 0;
11181 }
11182 
11183 static int
11184 test_AES_GCM_authenticated_decryption_test_case_1(void)
11185 {
11186 	return test_authenticated_decryption(&gcm_test_case_1);
11187 }
11188 
11189 static int
11190 test_AES_GCM_authenticated_decryption_test_case_2(void)
11191 {
11192 	return test_authenticated_decryption(&gcm_test_case_2);
11193 }
11194 
11195 static int
11196 test_AES_GCM_authenticated_decryption_test_case_3(void)
11197 {
11198 	return test_authenticated_decryption(&gcm_test_case_3);
11199 }
11200 
11201 static int
11202 test_AES_GCM_authenticated_decryption_test_case_4(void)
11203 {
11204 	return test_authenticated_decryption(&gcm_test_case_4);
11205 }
11206 
11207 static int
11208 test_AES_GCM_authenticated_decryption_test_case_5(void)
11209 {
11210 	return test_authenticated_decryption(&gcm_test_case_5);
11211 }
11212 
11213 static int
11214 test_AES_GCM_authenticated_decryption_test_case_6(void)
11215 {
11216 	return test_authenticated_decryption(&gcm_test_case_6);
11217 }
11218 
11219 static int
11220 test_AES_GCM_authenticated_decryption_test_case_7(void)
11221 {
11222 	return test_authenticated_decryption(&gcm_test_case_7);
11223 }
11224 
11225 static int
11226 test_AES_GCM_authenticated_decryption_test_case_8(void)
11227 {
11228 	return test_authenticated_decryption(&gcm_test_case_8);
11229 }
11230 
11231 static int
11232 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
11233 {
11234 	return test_authenticated_decryption(&gcm_J0_test_case_1);
11235 }
11236 
11237 static int
11238 test_AES_GCM_auth_decryption_test_case_192_1(void)
11239 {
11240 	return test_authenticated_decryption(&gcm_test_case_192_1);
11241 }
11242 
11243 static int
11244 test_AES_GCM_auth_decryption_test_case_192_2(void)
11245 {
11246 	return test_authenticated_decryption(&gcm_test_case_192_2);
11247 }
11248 
11249 static int
11250 test_AES_GCM_auth_decryption_test_case_192_3(void)
11251 {
11252 	return test_authenticated_decryption(&gcm_test_case_192_3);
11253 }
11254 
11255 static int
11256 test_AES_GCM_auth_decryption_test_case_192_4(void)
11257 {
11258 	return test_authenticated_decryption(&gcm_test_case_192_4);
11259 }
11260 
11261 static int
11262 test_AES_GCM_auth_decryption_test_case_192_5(void)
11263 {
11264 	return test_authenticated_decryption(&gcm_test_case_192_5);
11265 }
11266 
11267 static int
11268 test_AES_GCM_auth_decryption_test_case_192_6(void)
11269 {
11270 	return test_authenticated_decryption(&gcm_test_case_192_6);
11271 }
11272 
11273 static int
11274 test_AES_GCM_auth_decryption_test_case_192_7(void)
11275 {
11276 	return test_authenticated_decryption(&gcm_test_case_192_7);
11277 }
11278 
11279 static int
11280 test_AES_GCM_auth_decryption_test_case_256_1(void)
11281 {
11282 	return test_authenticated_decryption(&gcm_test_case_256_1);
11283 }
11284 
11285 static int
11286 test_AES_GCM_auth_decryption_test_case_256_2(void)
11287 {
11288 	return test_authenticated_decryption(&gcm_test_case_256_2);
11289 }
11290 
11291 static int
11292 test_AES_GCM_auth_decryption_test_case_256_3(void)
11293 {
11294 	return test_authenticated_decryption(&gcm_test_case_256_3);
11295 }
11296 
11297 static int
11298 test_AES_GCM_auth_decryption_test_case_256_4(void)
11299 {
11300 	return test_authenticated_decryption(&gcm_test_case_256_4);
11301 }
11302 
11303 static int
11304 test_AES_GCM_auth_decryption_test_case_256_5(void)
11305 {
11306 	return test_authenticated_decryption(&gcm_test_case_256_5);
11307 }
11308 
11309 static int
11310 test_AES_GCM_auth_decryption_test_case_256_6(void)
11311 {
11312 	return test_authenticated_decryption(&gcm_test_case_256_6);
11313 }
11314 
11315 static int
11316 test_AES_GCM_auth_decryption_test_case_256_7(void)
11317 {
11318 	return test_authenticated_decryption(&gcm_test_case_256_7);
11319 }
11320 
11321 static int
11322 test_AES_GCM_auth_decryption_test_case_aad_1(void)
11323 {
11324 	return test_authenticated_decryption(&gcm_test_case_aad_1);
11325 }
11326 
11327 static int
11328 test_AES_GCM_auth_decryption_test_case_aad_2(void)
11329 {
11330 	return test_authenticated_decryption(&gcm_test_case_aad_2);
11331 }
11332 
11333 static int
11334 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
11335 {
11336 	struct aead_test_data tdata;
11337 	int res;
11338 
11339 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11340 	tdata.iv.data[0] += 1;
11341 	res = test_authenticated_decryption(&tdata);
11342 	if (res == TEST_SKIPPED)
11343 		return res;
11344 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11345 	return TEST_SUCCESS;
11346 }
11347 
11348 static int
11349 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
11350 {
11351 	struct aead_test_data tdata;
11352 	int res;
11353 
11354 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11355 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11356 	tdata.plaintext.data[0] += 1;
11357 	res = test_authenticated_decryption(&tdata);
11358 	if (res == TEST_SKIPPED)
11359 		return res;
11360 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11361 	return TEST_SUCCESS;
11362 }
11363 
11364 static int
11365 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
11366 {
11367 	struct aead_test_data tdata;
11368 	int res;
11369 
11370 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11371 	tdata.ciphertext.data[0] += 1;
11372 	res = test_authenticated_decryption(&tdata);
11373 	if (res == TEST_SKIPPED)
11374 		return res;
11375 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11376 	return TEST_SUCCESS;
11377 }
11378 
11379 static int
11380 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
11381 {
11382 	struct aead_test_data tdata;
11383 	int res;
11384 
11385 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11386 	tdata.aad.len += 1;
11387 	res = test_authenticated_decryption(&tdata);
11388 	if (res == TEST_SKIPPED)
11389 		return res;
11390 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11391 	return TEST_SUCCESS;
11392 }
11393 
11394 static int
11395 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
11396 {
11397 	struct aead_test_data tdata;
11398 	uint8_t aad[gcm_test_case_7.aad.len];
11399 	int res;
11400 
11401 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11402 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
11403 	aad[0] += 1;
11404 	tdata.aad.data = aad;
11405 	res = test_authenticated_decryption(&tdata);
11406 	if (res == TEST_SKIPPED)
11407 		return res;
11408 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11409 	return TEST_SUCCESS;
11410 }
11411 
11412 static int
11413 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
11414 {
11415 	struct aead_test_data tdata;
11416 	int res;
11417 
11418 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11419 	tdata.auth_tag.data[0] += 1;
11420 	res = test_authenticated_decryption(&tdata);
11421 	if (res == TEST_SKIPPED)
11422 		return res;
11423 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
11424 	return TEST_SUCCESS;
11425 }
11426 
11427 static int
11428 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
11429 {
11430 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11431 	struct crypto_unittest_params *ut_params = &unittest_params;
11432 
11433 	int retval;
11434 	uint8_t *ciphertext, *auth_tag;
11435 	uint16_t plaintext_pad_len;
11436 	struct rte_cryptodev_info dev_info;
11437 
11438 	/* Verify the capabilities */
11439 	struct rte_cryptodev_sym_capability_idx cap_idx;
11440 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11441 	cap_idx.algo.aead = tdata->algo;
11442 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11443 			&cap_idx) == NULL)
11444 		return TEST_SKIPPED;
11445 
11446 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11447 	uint64_t feat_flags = dev_info.feature_flags;
11448 
11449 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11450 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
11451 		return TEST_SKIPPED;
11452 
11453 	/* not supported with CPU crypto */
11454 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11455 		return TEST_SKIPPED;
11456 
11457 	/* Create AEAD session */
11458 	retval = create_aead_session(ts_params->valid_devs[0],
11459 			tdata->algo,
11460 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
11461 			tdata->key.data, tdata->key.len,
11462 			tdata->aad.len, tdata->auth_tag.len,
11463 			tdata->iv.len);
11464 	if (retval < 0)
11465 		return retval;
11466 
11467 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11468 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11469 
11470 	/* clear mbuf payload */
11471 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11472 			rte_pktmbuf_tailroom(ut_params->ibuf));
11473 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
11474 			rte_pktmbuf_tailroom(ut_params->obuf));
11475 
11476 	/* Create AEAD operation */
11477 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11478 	if (retval < 0)
11479 		return retval;
11480 
11481 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11482 
11483 	ut_params->op->sym->m_src = ut_params->ibuf;
11484 	ut_params->op->sym->m_dst = ut_params->obuf;
11485 
11486 	/* Process crypto operation */
11487 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11488 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11489 			ut_params->op, 0, 0, 0, 0);
11490 	else
11491 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11492 			ut_params->op), "failed to process sym crypto op");
11493 
11494 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11495 			"crypto op processing failed");
11496 
11497 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11498 
11499 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
11500 			ut_params->op->sym->cipher.data.offset);
11501 	auth_tag = ciphertext + plaintext_pad_len;
11502 
11503 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11504 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11505 
11506 	/* Validate obuf */
11507 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11508 			ciphertext,
11509 			tdata->ciphertext.data,
11510 			tdata->ciphertext.len,
11511 			"Ciphertext data not as expected");
11512 
11513 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11514 			auth_tag,
11515 			tdata->auth_tag.data,
11516 			tdata->auth_tag.len,
11517 			"Generated auth tag not as expected");
11518 
11519 	return 0;
11520 
11521 }
11522 
11523 static int
11524 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
11525 {
11526 	return test_authenticated_encryption_oop(&gcm_test_case_5);
11527 }
11528 
11529 static int
11530 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
11531 {
11532 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11533 	struct crypto_unittest_params *ut_params = &unittest_params;
11534 
11535 	int retval;
11536 	uint8_t *plaintext;
11537 	struct rte_cryptodev_info dev_info;
11538 
11539 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11540 	uint64_t feat_flags = dev_info.feature_flags;
11541 
11542 	/* Verify the capabilities */
11543 	struct rte_cryptodev_sym_capability_idx cap_idx;
11544 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11545 	cap_idx.algo.aead = tdata->algo;
11546 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11547 			&cap_idx) == NULL)
11548 		return TEST_SKIPPED;
11549 
11550 	/* not supported with CPU crypto and raw data-path APIs*/
11551 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
11552 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
11553 		return TEST_SKIPPED;
11554 
11555 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11556 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11557 		printf("Device does not support RAW data-path APIs.\n");
11558 		return TEST_SKIPPED;
11559 	}
11560 
11561 	/* Create AEAD session */
11562 	retval = create_aead_session(ts_params->valid_devs[0],
11563 			tdata->algo,
11564 			RTE_CRYPTO_AEAD_OP_DECRYPT,
11565 			tdata->key.data, tdata->key.len,
11566 			tdata->aad.len, tdata->auth_tag.len,
11567 			tdata->iv.len);
11568 	if (retval < 0)
11569 		return retval;
11570 
11571 	/* alloc mbuf and set payload */
11572 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11573 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11574 
11575 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11576 			rte_pktmbuf_tailroom(ut_params->ibuf));
11577 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
11578 			rte_pktmbuf_tailroom(ut_params->obuf));
11579 
11580 	/* Create AEAD operation */
11581 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11582 	if (retval < 0)
11583 		return retval;
11584 
11585 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11586 
11587 	ut_params->op->sym->m_src = ut_params->ibuf;
11588 	ut_params->op->sym->m_dst = ut_params->obuf;
11589 
11590 	/* Process crypto operation */
11591 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11592 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11593 				ut_params->op, 0, 0, 0, 0);
11594 	else
11595 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11596 			ut_params->op), "failed to process sym crypto op");
11597 
11598 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11599 			"crypto op processing failed");
11600 
11601 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
11602 			ut_params->op->sym->cipher.data.offset);
11603 
11604 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11605 
11606 	/* Validate obuf */
11607 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11608 			plaintext,
11609 			tdata->plaintext.data,
11610 			tdata->plaintext.len,
11611 			"Plaintext data not as expected");
11612 
11613 	TEST_ASSERT_EQUAL(ut_params->op->status,
11614 			RTE_CRYPTO_OP_STATUS_SUCCESS,
11615 			"Authentication failed");
11616 	return 0;
11617 }
11618 
11619 static int
11620 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
11621 {
11622 	return test_authenticated_decryption_oop(&gcm_test_case_5);
11623 }
11624 
11625 static int
11626 test_authenticated_encryption_sessionless(
11627 		const struct aead_test_data *tdata)
11628 {
11629 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11630 	struct crypto_unittest_params *ut_params = &unittest_params;
11631 
11632 	int retval;
11633 	uint8_t *ciphertext, *auth_tag;
11634 	uint16_t plaintext_pad_len;
11635 	uint8_t key[tdata->key.len + 1];
11636 	struct rte_cryptodev_info dev_info;
11637 
11638 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11639 	uint64_t feat_flags = dev_info.feature_flags;
11640 
11641 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11642 		printf("Device doesn't support Sessionless ops.\n");
11643 		return TEST_SKIPPED;
11644 	}
11645 
11646 	/* not supported with CPU crypto */
11647 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11648 		return TEST_SKIPPED;
11649 
11650 	/* Verify the capabilities */
11651 	struct rte_cryptodev_sym_capability_idx cap_idx;
11652 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11653 	cap_idx.algo.aead = tdata->algo;
11654 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11655 			&cap_idx) == NULL)
11656 		return TEST_SKIPPED;
11657 
11658 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11659 
11660 	/* clear mbuf payload */
11661 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11662 			rte_pktmbuf_tailroom(ut_params->ibuf));
11663 
11664 	/* Create AEAD operation */
11665 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11666 	if (retval < 0)
11667 		return retval;
11668 
11669 	/* Create GCM xform */
11670 	memcpy(key, tdata->key.data, tdata->key.len);
11671 	retval = create_aead_xform(ut_params->op,
11672 			tdata->algo,
11673 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
11674 			key, tdata->key.len,
11675 			tdata->aad.len, tdata->auth_tag.len,
11676 			tdata->iv.len);
11677 	if (retval < 0)
11678 		return retval;
11679 
11680 	ut_params->op->sym->m_src = ut_params->ibuf;
11681 
11682 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11683 			RTE_CRYPTO_OP_SESSIONLESS,
11684 			"crypto op session type not sessionless");
11685 
11686 	/* Process crypto operation */
11687 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11688 			ut_params->op), "failed to process sym crypto op");
11689 
11690 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11691 
11692 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11693 			"crypto op status not success");
11694 
11695 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11696 
11697 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11698 			ut_params->op->sym->cipher.data.offset);
11699 	auth_tag = ciphertext + plaintext_pad_len;
11700 
11701 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11702 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11703 
11704 	/* Validate obuf */
11705 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11706 			ciphertext,
11707 			tdata->ciphertext.data,
11708 			tdata->ciphertext.len,
11709 			"Ciphertext data not as expected");
11710 
11711 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11712 			auth_tag,
11713 			tdata->auth_tag.data,
11714 			tdata->auth_tag.len,
11715 			"Generated auth tag not as expected");
11716 
11717 	return 0;
11718 
11719 }
11720 
11721 static int
11722 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
11723 {
11724 	return test_authenticated_encryption_sessionless(
11725 			&gcm_test_case_5);
11726 }
11727 
11728 static int
11729 test_authenticated_decryption_sessionless(
11730 		const struct aead_test_data *tdata)
11731 {
11732 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11733 	struct crypto_unittest_params *ut_params = &unittest_params;
11734 
11735 	int retval;
11736 	uint8_t *plaintext;
11737 	uint8_t key[tdata->key.len + 1];
11738 	struct rte_cryptodev_info dev_info;
11739 
11740 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11741 	uint64_t feat_flags = dev_info.feature_flags;
11742 
11743 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11744 		printf("Device doesn't support Sessionless ops.\n");
11745 		return TEST_SKIPPED;
11746 	}
11747 
11748 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11749 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11750 		printf("Device doesn't support RAW data-path APIs.\n");
11751 		return TEST_SKIPPED;
11752 	}
11753 
11754 	/* not supported with CPU crypto */
11755 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11756 		return TEST_SKIPPED;
11757 
11758 	/* Verify the capabilities */
11759 	struct rte_cryptodev_sym_capability_idx cap_idx;
11760 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11761 	cap_idx.algo.aead = tdata->algo;
11762 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11763 			&cap_idx) == NULL)
11764 		return TEST_SKIPPED;
11765 
11766 	/* alloc mbuf and set payload */
11767 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11768 
11769 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11770 			rte_pktmbuf_tailroom(ut_params->ibuf));
11771 
11772 	/* Create AEAD operation */
11773 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11774 	if (retval < 0)
11775 		return retval;
11776 
11777 	/* Create AEAD xform */
11778 	memcpy(key, tdata->key.data, tdata->key.len);
11779 	retval = create_aead_xform(ut_params->op,
11780 			tdata->algo,
11781 			RTE_CRYPTO_AEAD_OP_DECRYPT,
11782 			key, tdata->key.len,
11783 			tdata->aad.len, tdata->auth_tag.len,
11784 			tdata->iv.len);
11785 	if (retval < 0)
11786 		return retval;
11787 
11788 	ut_params->op->sym->m_src = ut_params->ibuf;
11789 
11790 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11791 			RTE_CRYPTO_OP_SESSIONLESS,
11792 			"crypto op session type not sessionless");
11793 
11794 	/* Process crypto operation */
11795 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11796 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11797 				ut_params->op, 0, 0, 0, 0);
11798 	else
11799 		TEST_ASSERT_NOT_NULL(process_crypto_request(
11800 			ts_params->valid_devs[0], ut_params->op),
11801 				"failed to process sym crypto op");
11802 
11803 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11804 
11805 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11806 			"crypto op status not success");
11807 
11808 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11809 			ut_params->op->sym->cipher.data.offset);
11810 
11811 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11812 
11813 	/* Validate obuf */
11814 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11815 			plaintext,
11816 			tdata->plaintext.data,
11817 			tdata->plaintext.len,
11818 			"Plaintext data not as expected");
11819 
11820 	TEST_ASSERT_EQUAL(ut_params->op->status,
11821 			RTE_CRYPTO_OP_STATUS_SUCCESS,
11822 			"Authentication failed");
11823 	return 0;
11824 }
11825 
11826 static int
11827 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
11828 {
11829 	return test_authenticated_decryption_sessionless(
11830 			&gcm_test_case_5);
11831 }
11832 
11833 static int
11834 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
11835 {
11836 	return test_authenticated_encryption(&ccm_test_case_128_1);
11837 }
11838 
11839 static int
11840 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
11841 {
11842 	return test_authenticated_encryption(&ccm_test_case_128_2);
11843 }
11844 
11845 static int
11846 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
11847 {
11848 	return test_authenticated_encryption(&ccm_test_case_128_3);
11849 }
11850 
11851 static int
11852 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
11853 {
11854 	return test_authenticated_decryption(&ccm_test_case_128_1);
11855 }
11856 
11857 static int
11858 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11859 {
11860 	return test_authenticated_decryption(&ccm_test_case_128_2);
11861 }
11862 
11863 static int
11864 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11865 {
11866 	return test_authenticated_decryption(&ccm_test_case_128_3);
11867 }
11868 
11869 static int
11870 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11871 {
11872 	return test_authenticated_encryption(&ccm_test_case_192_1);
11873 }
11874 
11875 static int
11876 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11877 {
11878 	return test_authenticated_encryption(&ccm_test_case_192_2);
11879 }
11880 
11881 static int
11882 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11883 {
11884 	return test_authenticated_encryption(&ccm_test_case_192_3);
11885 }
11886 
11887 static int
11888 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11889 {
11890 	return test_authenticated_decryption(&ccm_test_case_192_1);
11891 }
11892 
11893 static int
11894 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11895 {
11896 	return test_authenticated_decryption(&ccm_test_case_192_2);
11897 }
11898 
11899 static int
11900 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11901 {
11902 	return test_authenticated_decryption(&ccm_test_case_192_3);
11903 }
11904 
11905 static int
11906 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11907 {
11908 	return test_authenticated_encryption(&ccm_test_case_256_1);
11909 }
11910 
11911 static int
11912 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11913 {
11914 	return test_authenticated_encryption(&ccm_test_case_256_2);
11915 }
11916 
11917 static int
11918 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11919 {
11920 	return test_authenticated_encryption(&ccm_test_case_256_3);
11921 }
11922 
11923 static int
11924 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11925 {
11926 	return test_authenticated_decryption(&ccm_test_case_256_1);
11927 }
11928 
11929 static int
11930 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11931 {
11932 	return test_authenticated_decryption(&ccm_test_case_256_2);
11933 }
11934 
11935 static int
11936 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11937 {
11938 	return test_authenticated_decryption(&ccm_test_case_256_3);
11939 }
11940 
11941 static int
11942 test_stats(void)
11943 {
11944 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11945 	struct rte_cryptodev_stats stats;
11946 
11947 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11948 		return TEST_SKIPPED;
11949 
11950 	/* Verify the capabilities */
11951 	struct rte_cryptodev_sym_capability_idx cap_idx;
11952 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11953 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11954 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11955 			&cap_idx) == NULL)
11956 		return TEST_SKIPPED;
11957 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11958 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11959 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11960 			&cap_idx) == NULL)
11961 		return TEST_SKIPPED;
11962 
11963 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11964 			== -ENOTSUP)
11965 		return TEST_SKIPPED;
11966 
11967 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11968 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11969 			&stats) == -ENODEV),
11970 		"rte_cryptodev_stats_get invalid dev failed");
11971 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11972 		"rte_cryptodev_stats_get invalid Param failed");
11973 
11974 	/* Test expected values */
11975 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
11976 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11977 			&stats),
11978 		"rte_cryptodev_stats_get failed");
11979 	TEST_ASSERT((stats.enqueued_count == 1),
11980 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11981 	TEST_ASSERT((stats.dequeued_count == 1),
11982 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11983 	TEST_ASSERT((stats.enqueue_err_count == 0),
11984 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11985 	TEST_ASSERT((stats.dequeue_err_count == 0),
11986 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11987 
11988 	/* invalid device but should ignore and not reset device stats*/
11989 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11990 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11991 			&stats),
11992 		"rte_cryptodev_stats_get failed");
11993 	TEST_ASSERT((stats.enqueued_count == 1),
11994 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11995 
11996 	/* check that a valid reset clears stats */
11997 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11998 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11999 			&stats),
12000 					  "rte_cryptodev_stats_get failed");
12001 	TEST_ASSERT((stats.enqueued_count == 0),
12002 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
12003 	TEST_ASSERT((stats.dequeued_count == 0),
12004 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
12005 
12006 	return TEST_SUCCESS;
12007 }
12008 
12009 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
12010 				   struct crypto_unittest_params *ut_params,
12011 				   enum rte_crypto_auth_operation op,
12012 				   const struct HMAC_MD5_vector *test_case)
12013 {
12014 	uint8_t key[64];
12015 
12016 	memcpy(key, test_case->key.data, test_case->key.len);
12017 
12018 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12019 	ut_params->auth_xform.next = NULL;
12020 	ut_params->auth_xform.auth.op = op;
12021 
12022 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
12023 
12024 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
12025 	ut_params->auth_xform.auth.key.length = test_case->key.len;
12026 	ut_params->auth_xform.auth.key.data = key;
12027 
12028 	ut_params->sess = rte_cryptodev_sym_session_create(
12029 		ts_params->valid_devs[0], &ut_params->auth_xform,
12030 			ts_params->session_mpool);
12031 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
12032 		return TEST_SKIPPED;
12033 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12034 
12035 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12036 
12037 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12038 			rte_pktmbuf_tailroom(ut_params->ibuf));
12039 
12040 	return 0;
12041 }
12042 
12043 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
12044 			      const struct HMAC_MD5_vector *test_case,
12045 			      uint8_t **plaintext)
12046 {
12047 	uint16_t plaintext_pad_len;
12048 
12049 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12050 
12051 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
12052 				16);
12053 
12054 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12055 			plaintext_pad_len);
12056 	memcpy(*plaintext, test_case->plaintext.data,
12057 			test_case->plaintext.len);
12058 
12059 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12060 			ut_params->ibuf, MD5_DIGEST_LEN);
12061 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12062 			"no room to append digest");
12063 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12064 			ut_params->ibuf, plaintext_pad_len);
12065 
12066 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12067 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
12068 			   test_case->auth_tag.len);
12069 	}
12070 
12071 	sym_op->auth.data.offset = 0;
12072 	sym_op->auth.data.length = test_case->plaintext.len;
12073 
12074 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12075 	ut_params->op->sym->m_src = ut_params->ibuf;
12076 
12077 	return 0;
12078 }
12079 
12080 static int
12081 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
12082 {
12083 	uint16_t plaintext_pad_len;
12084 	uint8_t *plaintext, *auth_tag;
12085 
12086 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12087 	struct crypto_unittest_params *ut_params = &unittest_params;
12088 	struct rte_cryptodev_info dev_info;
12089 
12090 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12091 	uint64_t feat_flags = dev_info.feature_flags;
12092 
12093 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12094 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12095 		printf("Device doesn't support RAW data-path APIs.\n");
12096 		return TEST_SKIPPED;
12097 	}
12098 
12099 	/* Verify the capabilities */
12100 	struct rte_cryptodev_sym_capability_idx cap_idx;
12101 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12102 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
12103 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12104 			&cap_idx) == NULL)
12105 		return TEST_SKIPPED;
12106 
12107 	if (MD5_HMAC_create_session(ts_params, ut_params,
12108 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
12109 		return TEST_FAILED;
12110 
12111 	/* Generate Crypto op data structure */
12112 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12113 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12114 	TEST_ASSERT_NOT_NULL(ut_params->op,
12115 			"Failed to allocate symmetric crypto operation struct");
12116 
12117 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
12118 				16);
12119 
12120 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
12121 		return TEST_FAILED;
12122 
12123 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12124 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12125 			ut_params->op);
12126 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12127 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12128 				ut_params->op, 0, 1, 0, 0);
12129 	else
12130 		TEST_ASSERT_NOT_NULL(
12131 			process_crypto_request(ts_params->valid_devs[0],
12132 				ut_params->op),
12133 				"failed to process sym crypto op");
12134 
12135 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12136 			"crypto op processing failed");
12137 
12138 	if (ut_params->op->sym->m_dst) {
12139 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12140 				uint8_t *, plaintext_pad_len);
12141 	} else {
12142 		auth_tag = plaintext + plaintext_pad_len;
12143 	}
12144 
12145 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12146 			auth_tag,
12147 			test_case->auth_tag.data,
12148 			test_case->auth_tag.len,
12149 			"HMAC_MD5 generated tag not as expected");
12150 
12151 	return TEST_SUCCESS;
12152 }
12153 
12154 static int
12155 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
12156 {
12157 	uint8_t *plaintext;
12158 
12159 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12160 	struct crypto_unittest_params *ut_params = &unittest_params;
12161 	struct rte_cryptodev_info dev_info;
12162 
12163 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12164 	uint64_t feat_flags = dev_info.feature_flags;
12165 
12166 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12167 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12168 		printf("Device doesn't support RAW data-path APIs.\n");
12169 		return TEST_SKIPPED;
12170 	}
12171 
12172 	/* Verify the capabilities */
12173 	struct rte_cryptodev_sym_capability_idx cap_idx;
12174 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12175 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
12176 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12177 			&cap_idx) == NULL)
12178 		return TEST_SKIPPED;
12179 
12180 	if (MD5_HMAC_create_session(ts_params, ut_params,
12181 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
12182 		return TEST_FAILED;
12183 	}
12184 
12185 	/* Generate Crypto op data structure */
12186 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12187 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12188 	TEST_ASSERT_NOT_NULL(ut_params->op,
12189 			"Failed to allocate symmetric crypto operation struct");
12190 
12191 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
12192 		return TEST_FAILED;
12193 
12194 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12195 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12196 			ut_params->op);
12197 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12198 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12199 				ut_params->op, 0, 1, 0, 0);
12200 	else
12201 		TEST_ASSERT_NOT_NULL(
12202 			process_crypto_request(ts_params->valid_devs[0],
12203 				ut_params->op),
12204 				"failed to process sym crypto op");
12205 
12206 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12207 			"HMAC_MD5 crypto op processing failed");
12208 
12209 	return TEST_SUCCESS;
12210 }
12211 
12212 static int
12213 test_MD5_HMAC_generate_case_1(void)
12214 {
12215 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
12216 }
12217 
12218 static int
12219 test_MD5_HMAC_verify_case_1(void)
12220 {
12221 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
12222 }
12223 
12224 static int
12225 test_MD5_HMAC_generate_case_2(void)
12226 {
12227 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
12228 }
12229 
12230 static int
12231 test_MD5_HMAC_verify_case_2(void)
12232 {
12233 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
12234 }
12235 
12236 static int
12237 test_multi_session(void)
12238 {
12239 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12240 	struct crypto_unittest_params *ut_params = &unittest_params;
12241 	struct rte_cryptodev_info dev_info;
12242 	void **sessions;
12243 	uint16_t i;
12244 
12245 	/* Verify the capabilities */
12246 	struct rte_cryptodev_sym_capability_idx cap_idx;
12247 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12248 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
12249 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12250 			&cap_idx) == NULL)
12251 		return TEST_SKIPPED;
12252 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12253 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12254 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12255 			&cap_idx) == NULL)
12256 		return TEST_SKIPPED;
12257 
12258 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
12259 			aes_cbc_key, hmac_sha512_key);
12260 
12261 
12262 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12263 
12264 	sessions = rte_malloc(NULL,
12265 			sizeof(void *) *
12266 			(MAX_NB_SESSIONS + 1), 0);
12267 
12268 	/* Create multiple crypto sessions*/
12269 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
12270 		sessions[i] = rte_cryptodev_sym_session_create(
12271 			ts_params->valid_devs[0], &ut_params->auth_xform,
12272 				ts_params->session_mpool);
12273 		if (sessions[i] == NULL && rte_errno == ENOTSUP)
12274 			return TEST_SKIPPED;
12275 
12276 		TEST_ASSERT_NOT_NULL(sessions[i],
12277 				"Session creation failed at session number %u",
12278 				i);
12279 		/* Attempt to send a request on each session */
12280 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
12281 			sessions[i],
12282 			ut_params,
12283 			ts_params,
12284 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
12285 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
12286 			aes_cbc_iv),
12287 			"Failed to perform decrypt on request number %u.", i);
12288 		/* free crypto operation structure */
12289 		rte_crypto_op_free(ut_params->op);
12290 
12291 		/*
12292 		 * free mbuf - both obuf and ibuf are usually the same,
12293 		 * so check if they point at the same address is necessary,
12294 		 * to avoid freeing the mbuf twice.
12295 		 */
12296 		if (ut_params->obuf) {
12297 			rte_pktmbuf_free(ut_params->obuf);
12298 			if (ut_params->ibuf == ut_params->obuf)
12299 				ut_params->ibuf = 0;
12300 			ut_params->obuf = 0;
12301 		}
12302 		if (ut_params->ibuf) {
12303 			rte_pktmbuf_free(ut_params->ibuf);
12304 			ut_params->ibuf = 0;
12305 		}
12306 	}
12307 
12308 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
12309 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
12310 				sessions[i]);
12311 	}
12312 
12313 	rte_free(sessions);
12314 
12315 	return TEST_SUCCESS;
12316 }
12317 
12318 struct multi_session_params {
12319 	struct crypto_unittest_params ut_params;
12320 	uint8_t *cipher_key;
12321 	uint8_t *hmac_key;
12322 	const uint8_t *cipher;
12323 	const uint8_t *digest;
12324 	uint8_t *iv;
12325 };
12326 
12327 #define MB_SESSION_NUMBER 3
12328 
12329 static int
12330 test_multi_session_random_usage(void)
12331 {
12332 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12333 	struct rte_cryptodev_info dev_info;
12334 	void **sessions;
12335 	uint32_t i, j;
12336 	struct multi_session_params ut_paramz[] = {
12337 
12338 		{
12339 			.cipher_key = ms_aes_cbc_key0,
12340 			.hmac_key = ms_hmac_key0,
12341 			.cipher = ms_aes_cbc_cipher0,
12342 			.digest = ms_hmac_digest0,
12343 			.iv = ms_aes_cbc_iv0
12344 		},
12345 		{
12346 			.cipher_key = ms_aes_cbc_key1,
12347 			.hmac_key = ms_hmac_key1,
12348 			.cipher = ms_aes_cbc_cipher1,
12349 			.digest = ms_hmac_digest1,
12350 			.iv = ms_aes_cbc_iv1
12351 		},
12352 		{
12353 			.cipher_key = ms_aes_cbc_key2,
12354 			.hmac_key = ms_hmac_key2,
12355 			.cipher = ms_aes_cbc_cipher2,
12356 			.digest = ms_hmac_digest2,
12357 			.iv = ms_aes_cbc_iv2
12358 		},
12359 
12360 	};
12361 
12362 	/* Verify the capabilities */
12363 	struct rte_cryptodev_sym_capability_idx cap_idx;
12364 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12365 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
12366 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12367 			&cap_idx) == NULL)
12368 		return TEST_SKIPPED;
12369 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12370 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12371 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12372 			&cap_idx) == NULL)
12373 		return TEST_SKIPPED;
12374 
12375 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12376 
12377 	sessions = rte_malloc(NULL, (sizeof(void *)
12378 					* MAX_NB_SESSIONS) + 1, 0);
12379 
12380 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
12381 
12382 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
12383 				sizeof(struct crypto_unittest_params));
12384 
12385 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
12386 				&ut_paramz[i].ut_params,
12387 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
12388 
12389 		/* Create multiple crypto sessions*/
12390 		sessions[i] = rte_cryptodev_sym_session_create(
12391 				ts_params->valid_devs[0],
12392 				&ut_paramz[i].ut_params.auth_xform,
12393 				ts_params->session_mpool);
12394 		if (sessions[i] == NULL && rte_errno == ENOTSUP)
12395 			return TEST_SKIPPED;
12396 
12397 		TEST_ASSERT_NOT_NULL(sessions[i],
12398 				"Session creation failed at session number %u",
12399 				i);
12400 	}
12401 
12402 	srand(time(NULL));
12403 	for (i = 0; i < 40000; i++) {
12404 
12405 		j = rand() % MB_SESSION_NUMBER;
12406 
12407 		TEST_ASSERT_SUCCESS(
12408 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
12409 					sessions[j],
12410 					&ut_paramz[j].ut_params,
12411 					ts_params, ut_paramz[j].cipher,
12412 					ut_paramz[j].digest,
12413 					ut_paramz[j].iv),
12414 			"Failed to perform decrypt on request number %u.", i);
12415 
12416 		rte_crypto_op_free(ut_paramz[j].ut_params.op);
12417 
12418 		/*
12419 		 * free mbuf - both obuf and ibuf are usually the same,
12420 		 * so check if they point at the same address is necessary,
12421 		 * to avoid freeing the mbuf twice.
12422 		 */
12423 		if (ut_paramz[j].ut_params.obuf) {
12424 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
12425 			if (ut_paramz[j].ut_params.ibuf
12426 					== ut_paramz[j].ut_params.obuf)
12427 				ut_paramz[j].ut_params.ibuf = 0;
12428 			ut_paramz[j].ut_params.obuf = 0;
12429 		}
12430 		if (ut_paramz[j].ut_params.ibuf) {
12431 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
12432 			ut_paramz[j].ut_params.ibuf = 0;
12433 		}
12434 	}
12435 
12436 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
12437 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
12438 				sessions[i]);
12439 	}
12440 
12441 	rte_free(sessions);
12442 
12443 	return TEST_SUCCESS;
12444 }
12445 
12446 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
12447 			0xab, 0xab, 0xab, 0xab,
12448 			0xab, 0xab, 0xab, 0xab,
12449 			0xab, 0xab, 0xab, 0xab};
12450 
12451 static int
12452 test_null_invalid_operation(void)
12453 {
12454 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12455 	struct crypto_unittest_params *ut_params = &unittest_params;
12456 
12457 	/* This test is for NULL PMD only */
12458 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
12459 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
12460 		return TEST_SKIPPED;
12461 
12462 	/* Setup Cipher Parameters */
12463 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12464 	ut_params->cipher_xform.next = NULL;
12465 
12466 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
12467 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12468 
12469 	/* Create Crypto session*/
12470 	ut_params->sess = rte_cryptodev_sym_session_create(
12471 			ts_params->valid_devs[0], &ut_params->cipher_xform,
12472 			ts_params->session_mpool);
12473 	TEST_ASSERT(ut_params->sess == NULL,
12474 			"Session creation succeeded unexpectedly");
12475 
12476 	/* Setup HMAC Parameters */
12477 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12478 	ut_params->auth_xform.next = NULL;
12479 
12480 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
12481 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12482 
12483 	/* Create Crypto session*/
12484 	ut_params->sess = rte_cryptodev_sym_session_create(
12485 			ts_params->valid_devs[0], &ut_params->auth_xform,
12486 			ts_params->session_mpool);
12487 	TEST_ASSERT(ut_params->sess == NULL,
12488 			"Session creation succeeded unexpectedly");
12489 
12490 	return TEST_SUCCESS;
12491 }
12492 
12493 
12494 #define NULL_BURST_LENGTH (32)
12495 
12496 static int
12497 test_null_burst_operation(void)
12498 {
12499 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12500 	struct crypto_unittest_params *ut_params = &unittest_params;
12501 
12502 	unsigned i, burst_len = NULL_BURST_LENGTH;
12503 
12504 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
12505 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
12506 
12507 	/* This test is for NULL PMD only */
12508 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
12509 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
12510 		return TEST_SKIPPED;
12511 
12512 	/* Setup Cipher Parameters */
12513 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12514 	ut_params->cipher_xform.next = &ut_params->auth_xform;
12515 
12516 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
12517 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12518 
12519 	/* Setup HMAC Parameters */
12520 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12521 	ut_params->auth_xform.next = NULL;
12522 
12523 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
12524 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12525 
12526 	/* Create Crypto session*/
12527 	ut_params->sess = rte_cryptodev_sym_session_create(
12528 				ts_params->valid_devs[0],
12529 				&ut_params->auth_xform,
12530 				ts_params->session_mpool);
12531 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
12532 		return TEST_SKIPPED;
12533 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12534 
12535 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
12536 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
12537 			burst_len, "failed to generate burst of crypto ops");
12538 
12539 	/* Generate an operation for each mbuf in burst */
12540 	for (i = 0; i < burst_len; i++) {
12541 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12542 
12543 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
12544 
12545 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
12546 				sizeof(unsigned));
12547 		*data = i;
12548 
12549 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
12550 
12551 		burst[i]->sym->m_src = m;
12552 	}
12553 
12554 	/* Process crypto operation */
12555 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
12556 			0, burst, burst_len),
12557 			burst_len,
12558 			"Error enqueuing burst");
12559 
12560 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
12561 			0, burst_dequeued, burst_len),
12562 			burst_len,
12563 			"Error dequeuing burst");
12564 
12565 
12566 	for (i = 0; i < burst_len; i++) {
12567 		TEST_ASSERT_EQUAL(
12568 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
12569 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
12570 					uint32_t *),
12571 			"data not as expected");
12572 
12573 		rte_pktmbuf_free(burst[i]->sym->m_src);
12574 		rte_crypto_op_free(burst[i]);
12575 	}
12576 
12577 	return TEST_SUCCESS;
12578 }
12579 
12580 static uint16_t
12581 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12582 		  uint16_t nb_ops, void *user_param)
12583 {
12584 	RTE_SET_USED(dev_id);
12585 	RTE_SET_USED(qp_id);
12586 	RTE_SET_USED(ops);
12587 	RTE_SET_USED(user_param);
12588 
12589 	printf("crypto enqueue callback called\n");
12590 	return nb_ops;
12591 }
12592 
12593 static uint16_t
12594 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12595 		  uint16_t nb_ops, void *user_param)
12596 {
12597 	RTE_SET_USED(dev_id);
12598 	RTE_SET_USED(qp_id);
12599 	RTE_SET_USED(ops);
12600 	RTE_SET_USED(user_param);
12601 
12602 	printf("crypto dequeue callback called\n");
12603 	return nb_ops;
12604 }
12605 
12606 /*
12607  * Thread using enqueue/dequeue callback with RCU.
12608  */
12609 static int
12610 test_enqdeq_callback_thread(void *arg)
12611 {
12612 	RTE_SET_USED(arg);
12613 	/* DP thread calls rte_cryptodev_enqueue_burst()/
12614 	 * rte_cryptodev_dequeue_burst() and invokes callback.
12615 	 */
12616 	test_null_burst_operation();
12617 	return 0;
12618 }
12619 
12620 static int
12621 test_enq_callback_setup(void)
12622 {
12623 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12624 	struct rte_cryptodev_info dev_info;
12625 	struct rte_cryptodev_qp_conf qp_conf = {
12626 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
12627 	};
12628 
12629 	struct rte_cryptodev_cb *cb;
12630 	uint16_t qp_id = 0;
12631 
12632 	/* Stop the device in case it's started so it can be configured */
12633 	rte_cryptodev_stop(ts_params->valid_devs[0]);
12634 
12635 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12636 
12637 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12638 			&ts_params->conf),
12639 			"Failed to configure cryptodev %u",
12640 			ts_params->valid_devs[0]);
12641 
12642 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12643 	qp_conf.mp_session = ts_params->session_mpool;
12644 
12645 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12646 			ts_params->valid_devs[0], qp_id, &qp_conf,
12647 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12648 			"Failed test for "
12649 			"rte_cryptodev_queue_pair_setup: num_inflights "
12650 			"%u on qp %u on cryptodev %u",
12651 			qp_conf.nb_descriptors, qp_id,
12652 			ts_params->valid_devs[0]);
12653 
12654 	/* Test with invalid crypto device */
12655 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
12656 			qp_id, test_enq_callback, NULL);
12657 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12658 			"cryptodev %u did not fail",
12659 			qp_id, RTE_CRYPTO_MAX_DEVS);
12660 
12661 	/* Test with invalid queue pair */
12662 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12663 			dev_info.max_nb_queue_pairs + 1,
12664 			test_enq_callback, NULL);
12665 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12666 			"cryptodev %u did not fail",
12667 			dev_info.max_nb_queue_pairs + 1,
12668 			ts_params->valid_devs[0]);
12669 
12670 	/* Test with NULL callback */
12671 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12672 			qp_id, NULL, NULL);
12673 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12674 			"cryptodev %u did not fail",
12675 			qp_id, ts_params->valid_devs[0]);
12676 
12677 	/* Test with valid configuration */
12678 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12679 			qp_id, test_enq_callback, NULL);
12680 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12681 			"qp %u on cryptodev %u",
12682 			qp_id, ts_params->valid_devs[0]);
12683 
12684 	rte_cryptodev_start(ts_params->valid_devs[0]);
12685 
12686 	/* Launch a thread */
12687 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12688 				rte_get_next_lcore(-1, 1, 0));
12689 
12690 	/* Wait until reader exited. */
12691 	rte_eal_mp_wait_lcore();
12692 
12693 	/* Test with invalid crypto device */
12694 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12695 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12696 			"Expected call to fail as crypto device is invalid");
12697 
12698 	/* Test with invalid queue pair */
12699 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12700 			ts_params->valid_devs[0],
12701 			dev_info.max_nb_queue_pairs + 1, cb),
12702 			"Expected call to fail as queue pair is invalid");
12703 
12704 	/* Test with NULL callback */
12705 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12706 			ts_params->valid_devs[0], qp_id, NULL),
12707 			"Expected call to fail as callback is NULL");
12708 
12709 	/* Test with valid configuration */
12710 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
12711 			ts_params->valid_devs[0], qp_id, cb),
12712 			"Failed test to remove callback on "
12713 			"qp %u on cryptodev %u",
12714 			qp_id, ts_params->valid_devs[0]);
12715 
12716 	return TEST_SUCCESS;
12717 }
12718 
12719 static int
12720 test_deq_callback_setup(void)
12721 {
12722 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12723 	struct rte_cryptodev_info dev_info;
12724 	struct rte_cryptodev_qp_conf qp_conf = {
12725 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
12726 	};
12727 
12728 	struct rte_cryptodev_cb *cb;
12729 	uint16_t qp_id = 0;
12730 
12731 	/* Stop the device in case it's started so it can be configured */
12732 	rte_cryptodev_stop(ts_params->valid_devs[0]);
12733 
12734 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12735 
12736 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12737 			&ts_params->conf),
12738 			"Failed to configure cryptodev %u",
12739 			ts_params->valid_devs[0]);
12740 
12741 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12742 	qp_conf.mp_session = ts_params->session_mpool;
12743 
12744 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12745 			ts_params->valid_devs[0], qp_id, &qp_conf,
12746 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12747 			"Failed test for "
12748 			"rte_cryptodev_queue_pair_setup: num_inflights "
12749 			"%u on qp %u on cryptodev %u",
12750 			qp_conf.nb_descriptors, qp_id,
12751 			ts_params->valid_devs[0]);
12752 
12753 	/* Test with invalid crypto device */
12754 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
12755 			qp_id, test_deq_callback, NULL);
12756 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12757 			"cryptodev %u did not fail",
12758 			qp_id, RTE_CRYPTO_MAX_DEVS);
12759 
12760 	/* Test with invalid queue pair */
12761 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12762 			dev_info.max_nb_queue_pairs + 1,
12763 			test_deq_callback, NULL);
12764 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12765 			"cryptodev %u did not fail",
12766 			dev_info.max_nb_queue_pairs + 1,
12767 			ts_params->valid_devs[0]);
12768 
12769 	/* Test with NULL callback */
12770 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12771 			qp_id, NULL, NULL);
12772 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12773 			"cryptodev %u did not fail",
12774 			qp_id, ts_params->valid_devs[0]);
12775 
12776 	/* Test with valid configuration */
12777 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12778 			qp_id, test_deq_callback, NULL);
12779 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12780 			"qp %u on cryptodev %u",
12781 			qp_id, ts_params->valid_devs[0]);
12782 
12783 	rte_cryptodev_start(ts_params->valid_devs[0]);
12784 
12785 	/* Launch a thread */
12786 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12787 				rte_get_next_lcore(-1, 1, 0));
12788 
12789 	/* Wait until reader exited. */
12790 	rte_eal_mp_wait_lcore();
12791 
12792 	/* Test with invalid crypto device */
12793 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12794 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12795 			"Expected call to fail as crypto device is invalid");
12796 
12797 	/* Test with invalid queue pair */
12798 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12799 			ts_params->valid_devs[0],
12800 			dev_info.max_nb_queue_pairs + 1, cb),
12801 			"Expected call to fail as queue pair is invalid");
12802 
12803 	/* Test with NULL callback */
12804 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12805 			ts_params->valid_devs[0], qp_id, NULL),
12806 			"Expected call to fail as callback is NULL");
12807 
12808 	/* Test with valid configuration */
12809 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
12810 			ts_params->valid_devs[0], qp_id, cb),
12811 			"Failed test to remove callback on "
12812 			"qp %u on cryptodev %u",
12813 			qp_id, ts_params->valid_devs[0]);
12814 
12815 	return TEST_SUCCESS;
12816 }
12817 
12818 static void
12819 generate_gmac_large_plaintext(uint8_t *data)
12820 {
12821 	uint16_t i;
12822 
12823 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12824 		memcpy(&data[i], &data[0], 32);
12825 }
12826 
12827 static int
12828 create_gmac_operation(enum rte_crypto_auth_operation op,
12829 		const struct gmac_test_data *tdata)
12830 {
12831 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12832 	struct crypto_unittest_params *ut_params = &unittest_params;
12833 	struct rte_crypto_sym_op *sym_op;
12834 
12835 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12836 
12837 	/* Generate Crypto op data structure */
12838 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12839 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12840 	TEST_ASSERT_NOT_NULL(ut_params->op,
12841 			"Failed to allocate symmetric crypto operation struct");
12842 
12843 	sym_op = ut_params->op->sym;
12844 
12845 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12846 			ut_params->ibuf, tdata->gmac_tag.len);
12847 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12848 			"no room to append digest");
12849 
12850 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12851 			ut_params->ibuf, plaintext_pad_len);
12852 
12853 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12854 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12855 				tdata->gmac_tag.len);
12856 		debug_hexdump(stdout, "digest:",
12857 				sym_op->auth.digest.data,
12858 				tdata->gmac_tag.len);
12859 	}
12860 
12861 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12862 			uint8_t *, IV_OFFSET);
12863 
12864 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12865 
12866 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12867 
12868 	sym_op->cipher.data.length = 0;
12869 	sym_op->cipher.data.offset = 0;
12870 
12871 	sym_op->auth.data.offset = 0;
12872 	sym_op->auth.data.length = tdata->plaintext.len;
12873 
12874 	return 0;
12875 }
12876 
12877 static int
12878 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12879 		const struct gmac_test_data *tdata,
12880 		void *digest_mem, uint64_t digest_phys)
12881 {
12882 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12883 	struct crypto_unittest_params *ut_params = &unittest_params;
12884 	struct rte_crypto_sym_op *sym_op;
12885 
12886 	/* Generate Crypto op data structure */
12887 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12888 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12889 	TEST_ASSERT_NOT_NULL(ut_params->op,
12890 			"Failed to allocate symmetric crypto operation struct");
12891 
12892 	sym_op = ut_params->op->sym;
12893 
12894 	sym_op->auth.digest.data = digest_mem;
12895 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12896 			"no room to append digest");
12897 
12898 	sym_op->auth.digest.phys_addr = digest_phys;
12899 
12900 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12901 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12902 				tdata->gmac_tag.len);
12903 		debug_hexdump(stdout, "digest:",
12904 				sym_op->auth.digest.data,
12905 				tdata->gmac_tag.len);
12906 	}
12907 
12908 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12909 			uint8_t *, IV_OFFSET);
12910 
12911 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12912 
12913 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12914 
12915 	sym_op->cipher.data.length = 0;
12916 	sym_op->cipher.data.offset = 0;
12917 
12918 	sym_op->auth.data.offset = 0;
12919 	sym_op->auth.data.length = tdata->plaintext.len;
12920 
12921 	return 0;
12922 }
12923 
12924 static int create_gmac_session(uint8_t dev_id,
12925 		const struct gmac_test_data *tdata,
12926 		enum rte_crypto_auth_operation auth_op)
12927 {
12928 	uint8_t auth_key[tdata->key.len];
12929 
12930 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12931 	struct crypto_unittest_params *ut_params = &unittest_params;
12932 
12933 	memcpy(auth_key, tdata->key.data, tdata->key.len);
12934 
12935 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12936 	ut_params->auth_xform.next = NULL;
12937 
12938 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12939 	ut_params->auth_xform.auth.op = auth_op;
12940 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12941 	ut_params->auth_xform.auth.key.length = tdata->key.len;
12942 	ut_params->auth_xform.auth.key.data = auth_key;
12943 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12944 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12945 
12946 
12947 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
12948 			&ut_params->auth_xform, ts_params->session_mpool);
12949 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
12950 		return TEST_SKIPPED;
12951 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12952 
12953 	return 0;
12954 }
12955 
12956 static int
12957 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12958 {
12959 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12960 	struct crypto_unittest_params *ut_params = &unittest_params;
12961 	struct rte_cryptodev_info dev_info;
12962 
12963 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12964 	uint64_t feat_flags = dev_info.feature_flags;
12965 
12966 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12967 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12968 		printf("Device doesn't support RAW data-path APIs.\n");
12969 		return TEST_SKIPPED;
12970 	}
12971 
12972 	int retval;
12973 
12974 	uint8_t *auth_tag, *plaintext;
12975 	uint16_t plaintext_pad_len;
12976 
12977 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12978 			      "No GMAC length in the source data");
12979 
12980 	/* Verify the capabilities */
12981 	struct rte_cryptodev_sym_capability_idx cap_idx;
12982 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12983 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12984 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12985 			&cap_idx) == NULL)
12986 		return TEST_SKIPPED;
12987 
12988 	retval = create_gmac_session(ts_params->valid_devs[0],
12989 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12990 
12991 	if (retval == -ENOTSUP)
12992 		return TEST_SKIPPED;
12993 	if (retval < 0)
12994 		return retval;
12995 
12996 	if (tdata->plaintext.len > MBUF_SIZE)
12997 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12998 	else
12999 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13000 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13001 			"Failed to allocate input buffer in mempool");
13002 
13003 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13004 			rte_pktmbuf_tailroom(ut_params->ibuf));
13005 
13006 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13007 	/*
13008 	 * Runtime generate the large plain text instead of use hard code
13009 	 * plain text vector. It is done to avoid create huge source file
13010 	 * with the test vector.
13011 	 */
13012 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
13013 		generate_gmac_large_plaintext(tdata->plaintext.data);
13014 
13015 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13016 				plaintext_pad_len);
13017 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13018 
13019 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
13020 	debug_hexdump(stdout, "plaintext:", plaintext,
13021 			tdata->plaintext.len);
13022 
13023 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
13024 			tdata);
13025 
13026 	if (retval < 0)
13027 		return retval;
13028 
13029 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13030 
13031 	ut_params->op->sym->m_src = ut_params->ibuf;
13032 
13033 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13034 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13035 			ut_params->op);
13036 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13037 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13038 				ut_params->op, 0, 1, 0, 0);
13039 	else
13040 		TEST_ASSERT_NOT_NULL(
13041 			process_crypto_request(ts_params->valid_devs[0],
13042 			ut_params->op), "failed to process sym crypto op");
13043 
13044 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13045 			"crypto op processing failed");
13046 
13047 	if (ut_params->op->sym->m_dst) {
13048 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13049 				uint8_t *, plaintext_pad_len);
13050 	} else {
13051 		auth_tag = plaintext + plaintext_pad_len;
13052 	}
13053 
13054 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
13055 
13056 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13057 			auth_tag,
13058 			tdata->gmac_tag.data,
13059 			tdata->gmac_tag.len,
13060 			"GMAC Generated auth tag not as expected");
13061 
13062 	return 0;
13063 }
13064 
13065 static int
13066 test_AES_GMAC_authentication_test_case_1(void)
13067 {
13068 	return test_AES_GMAC_authentication(&gmac_test_case_1);
13069 }
13070 
13071 static int
13072 test_AES_GMAC_authentication_test_case_2(void)
13073 {
13074 	return test_AES_GMAC_authentication(&gmac_test_case_2);
13075 }
13076 
13077 static int
13078 test_AES_GMAC_authentication_test_case_3(void)
13079 {
13080 	return test_AES_GMAC_authentication(&gmac_test_case_3);
13081 }
13082 
13083 static int
13084 test_AES_GMAC_authentication_test_case_4(void)
13085 {
13086 	return test_AES_GMAC_authentication(&gmac_test_case_4);
13087 }
13088 
13089 static int
13090 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
13091 {
13092 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13093 	struct crypto_unittest_params *ut_params = &unittest_params;
13094 	int retval;
13095 	uint32_t plaintext_pad_len;
13096 	uint8_t *plaintext;
13097 	struct rte_cryptodev_info dev_info;
13098 
13099 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13100 	uint64_t feat_flags = dev_info.feature_flags;
13101 
13102 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13103 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13104 		printf("Device doesn't support RAW data-path APIs.\n");
13105 		return TEST_SKIPPED;
13106 	}
13107 
13108 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
13109 			      "No GMAC length in the source data");
13110 
13111 	/* Verify the capabilities */
13112 	struct rte_cryptodev_sym_capability_idx cap_idx;
13113 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13114 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
13115 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13116 			&cap_idx) == NULL)
13117 		return TEST_SKIPPED;
13118 
13119 	retval = create_gmac_session(ts_params->valid_devs[0],
13120 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
13121 
13122 	if (retval == -ENOTSUP)
13123 		return TEST_SKIPPED;
13124 	if (retval < 0)
13125 		return retval;
13126 
13127 	if (tdata->plaintext.len > MBUF_SIZE)
13128 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
13129 	else
13130 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13131 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13132 			"Failed to allocate input buffer in mempool");
13133 
13134 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13135 			rte_pktmbuf_tailroom(ut_params->ibuf));
13136 
13137 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13138 
13139 	/*
13140 	 * Runtime generate the large plain text instead of use hard code
13141 	 * plain text vector. It is done to avoid create huge source file
13142 	 * with the test vector.
13143 	 */
13144 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
13145 		generate_gmac_large_plaintext(tdata->plaintext.data);
13146 
13147 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13148 				plaintext_pad_len);
13149 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13150 
13151 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
13152 	debug_hexdump(stdout, "plaintext:", plaintext,
13153 			tdata->plaintext.len);
13154 
13155 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
13156 			tdata);
13157 
13158 	if (retval < 0)
13159 		return retval;
13160 
13161 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13162 
13163 	ut_params->op->sym->m_src = ut_params->ibuf;
13164 
13165 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13166 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13167 			ut_params->op);
13168 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13169 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13170 				ut_params->op, 0, 1, 0, 0);
13171 	else
13172 		TEST_ASSERT_NOT_NULL(
13173 			process_crypto_request(ts_params->valid_devs[0],
13174 			ut_params->op), "failed to process sym crypto op");
13175 
13176 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13177 			"crypto op processing failed");
13178 
13179 	return 0;
13180 
13181 }
13182 
13183 static int
13184 test_AES_GMAC_authentication_verify_test_case_1(void)
13185 {
13186 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
13187 }
13188 
13189 static int
13190 test_AES_GMAC_authentication_verify_test_case_2(void)
13191 {
13192 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
13193 }
13194 
13195 static int
13196 test_AES_GMAC_authentication_verify_test_case_3(void)
13197 {
13198 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
13199 }
13200 
13201 static int
13202 test_AES_GMAC_authentication_verify_test_case_4(void)
13203 {
13204 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
13205 }
13206 
13207 static int
13208 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
13209 				uint32_t fragsz)
13210 {
13211 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13212 	struct crypto_unittest_params *ut_params = &unittest_params;
13213 	struct rte_cryptodev_info dev_info;
13214 	uint64_t feature_flags;
13215 	unsigned int trn_data = 0;
13216 	void *digest_mem = NULL;
13217 	uint32_t segs = 1;
13218 	unsigned int to_trn = 0;
13219 	struct rte_mbuf *buf = NULL;
13220 	uint8_t *auth_tag, *plaintext;
13221 	int retval;
13222 
13223 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
13224 			      "No GMAC length in the source data");
13225 
13226 	/* Verify the capabilities */
13227 	struct rte_cryptodev_sym_capability_idx cap_idx;
13228 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13229 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
13230 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13231 			&cap_idx) == NULL)
13232 		return TEST_SKIPPED;
13233 
13234 	/* Check for any input SGL support */
13235 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13236 	feature_flags = dev_info.feature_flags;
13237 
13238 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
13239 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
13240 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
13241 		return TEST_SKIPPED;
13242 
13243 	if (fragsz > tdata->plaintext.len)
13244 		fragsz = tdata->plaintext.len;
13245 
13246 	uint16_t plaintext_len = fragsz;
13247 
13248 	retval = create_gmac_session(ts_params->valid_devs[0],
13249 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
13250 
13251 	if (retval == -ENOTSUP)
13252 		return TEST_SKIPPED;
13253 	if (retval < 0)
13254 		return retval;
13255 
13256 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13257 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13258 			"Failed to allocate input buffer in mempool");
13259 
13260 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13261 			rte_pktmbuf_tailroom(ut_params->ibuf));
13262 
13263 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13264 				plaintext_len);
13265 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13266 
13267 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13268 
13269 	trn_data += plaintext_len;
13270 
13271 	buf = ut_params->ibuf;
13272 
13273 	/*
13274 	 * Loop until no more fragments
13275 	 */
13276 
13277 	while (trn_data < tdata->plaintext.len) {
13278 		++segs;
13279 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13280 				(tdata->plaintext.len - trn_data) : fragsz;
13281 
13282 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13283 		buf = buf->next;
13284 
13285 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13286 				rte_pktmbuf_tailroom(buf));
13287 
13288 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13289 				to_trn);
13290 
13291 		memcpy(plaintext, tdata->plaintext.data + trn_data,
13292 				to_trn);
13293 		trn_data += to_trn;
13294 		if (trn_data  == tdata->plaintext.len)
13295 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13296 					tdata->gmac_tag.len);
13297 	}
13298 	ut_params->ibuf->nb_segs = segs;
13299 
13300 	/*
13301 	 * Place digest at the end of the last buffer
13302 	 */
13303 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13304 
13305 	if (!digest_mem) {
13306 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13307 				+ tdata->gmac_tag.len);
13308 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13309 				tdata->plaintext.len);
13310 	}
13311 
13312 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
13313 			tdata, digest_mem, digest_phys);
13314 
13315 	if (retval < 0)
13316 		return retval;
13317 
13318 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13319 
13320 	ut_params->op->sym->m_src = ut_params->ibuf;
13321 
13322 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13323 		return TEST_SKIPPED;
13324 
13325 	TEST_ASSERT_NOT_NULL(
13326 		process_crypto_request(ts_params->valid_devs[0],
13327 		ut_params->op), "failed to process sym crypto op");
13328 
13329 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13330 			"crypto op processing failed");
13331 
13332 	auth_tag = digest_mem;
13333 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
13334 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13335 			auth_tag,
13336 			tdata->gmac_tag.data,
13337 			tdata->gmac_tag.len,
13338 			"GMAC Generated auth tag not as expected");
13339 
13340 	return 0;
13341 }
13342 
13343 /* Segment size not multiple of block size (16B) */
13344 static int
13345 test_AES_GMAC_authentication_SGL_40B(void)
13346 {
13347 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
13348 }
13349 
13350 static int
13351 test_AES_GMAC_authentication_SGL_80B(void)
13352 {
13353 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
13354 }
13355 
13356 static int
13357 test_AES_GMAC_authentication_SGL_2048B(void)
13358 {
13359 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
13360 }
13361 
13362 /* Segment size not multiple of block size (16B) */
13363 static int
13364 test_AES_GMAC_authentication_SGL_2047B(void)
13365 {
13366 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
13367 }
13368 
13369 struct test_crypto_vector {
13370 	enum rte_crypto_cipher_algorithm crypto_algo;
13371 	unsigned int cipher_offset;
13372 	unsigned int cipher_len;
13373 
13374 	struct {
13375 		uint8_t data[64];
13376 		unsigned int len;
13377 	} cipher_key;
13378 
13379 	struct {
13380 		uint8_t data[64];
13381 		unsigned int len;
13382 	} iv;
13383 
13384 	struct {
13385 		const uint8_t *data;
13386 		unsigned int len;
13387 	} plaintext;
13388 
13389 	struct {
13390 		const uint8_t *data;
13391 		unsigned int len;
13392 	} ciphertext;
13393 
13394 	enum rte_crypto_auth_algorithm auth_algo;
13395 	unsigned int auth_offset;
13396 
13397 	struct {
13398 		uint8_t data[128];
13399 		unsigned int len;
13400 	} auth_key;
13401 
13402 	struct {
13403 		const uint8_t *data;
13404 		unsigned int len;
13405 	} aad;
13406 
13407 	struct {
13408 		uint8_t data[128];
13409 		unsigned int len;
13410 	} digest;
13411 };
13412 
13413 static const struct test_crypto_vector
13414 hmac_sha1_test_crypto_vector = {
13415 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13416 	.plaintext = {
13417 		.data = plaintext_hash,
13418 		.len = 512
13419 	},
13420 	.auth_key = {
13421 		.data = {
13422 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13423 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13424 			0xDE, 0xF4, 0xDE, 0xAD
13425 		},
13426 		.len = 20
13427 	},
13428 	.digest = {
13429 		.data = {
13430 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
13431 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
13432 			0x3F, 0x91, 0x64, 0x59
13433 		},
13434 		.len = 20
13435 	}
13436 };
13437 
13438 static const struct test_crypto_vector
13439 aes128_gmac_test_vector = {
13440 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
13441 	.plaintext = {
13442 		.data = plaintext_hash,
13443 		.len = 512
13444 	},
13445 	.iv = {
13446 		.data = {
13447 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13448 			0x08, 0x09, 0x0A, 0x0B
13449 		},
13450 		.len = 12
13451 	},
13452 	.auth_key = {
13453 		.data = {
13454 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
13455 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
13456 		},
13457 		.len = 16
13458 	},
13459 	.digest = {
13460 		.data = {
13461 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
13462 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
13463 		},
13464 		.len = 16
13465 	}
13466 };
13467 
13468 static const struct test_crypto_vector
13469 aes128cbc_hmac_sha1_test_vector = {
13470 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13471 	.cipher_offset = 0,
13472 	.cipher_len = 512,
13473 	.cipher_key = {
13474 		.data = {
13475 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13476 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13477 		},
13478 		.len = 16
13479 	},
13480 	.iv = {
13481 		.data = {
13482 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13483 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13484 		},
13485 		.len = 16
13486 	},
13487 	.plaintext = {
13488 		.data = plaintext_hash,
13489 		.len = 512
13490 	},
13491 	.ciphertext = {
13492 		.data = ciphertext512_aes128cbc,
13493 		.len = 512
13494 	},
13495 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13496 	.auth_offset = 0,
13497 	.auth_key = {
13498 		.data = {
13499 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13500 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13501 			0xDE, 0xF4, 0xDE, 0xAD
13502 		},
13503 		.len = 20
13504 	},
13505 	.digest = {
13506 		.data = {
13507 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
13508 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
13509 			0x18, 0x8C, 0x1D, 0x32
13510 		},
13511 		.len = 20
13512 	}
13513 };
13514 
13515 static const struct test_crypto_vector
13516 aes128cbc_hmac_sha1_aad_test_vector = {
13517 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13518 	.cipher_offset = 8,
13519 	.cipher_len = 496,
13520 	.cipher_key = {
13521 		.data = {
13522 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13523 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13524 		},
13525 		.len = 16
13526 	},
13527 	.iv = {
13528 		.data = {
13529 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13530 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13531 		},
13532 		.len = 16
13533 	},
13534 	.plaintext = {
13535 		.data = plaintext_hash,
13536 		.len = 512
13537 	},
13538 	.ciphertext = {
13539 		.data = ciphertext512_aes128cbc_aad,
13540 		.len = 512
13541 	},
13542 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13543 	.auth_offset = 0,
13544 	.auth_key = {
13545 		.data = {
13546 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13547 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13548 			0xDE, 0xF4, 0xDE, 0xAD
13549 		},
13550 		.len = 20
13551 	},
13552 	.digest = {
13553 		.data = {
13554 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
13555 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
13556 			0x62, 0x0F, 0xFB, 0x10
13557 		},
13558 		.len = 20
13559 	}
13560 };
13561 
13562 static void
13563 data_corruption(uint8_t *data)
13564 {
13565 	data[0] += 1;
13566 }
13567 
13568 static void
13569 tag_corruption(uint8_t *data, unsigned int tag_offset)
13570 {
13571 	data[tag_offset] += 1;
13572 }
13573 
13574 static int
13575 create_auth_session(struct crypto_unittest_params *ut_params,
13576 		uint8_t dev_id,
13577 		const struct test_crypto_vector *reference,
13578 		enum rte_crypto_auth_operation auth_op)
13579 {
13580 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13581 	uint8_t auth_key[reference->auth_key.len + 1];
13582 
13583 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13584 
13585 	/* Setup Authentication Parameters */
13586 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13587 	ut_params->auth_xform.auth.op = auth_op;
13588 	ut_params->auth_xform.next = NULL;
13589 	ut_params->auth_xform.auth.algo = reference->auth_algo;
13590 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13591 	ut_params->auth_xform.auth.key.data = auth_key;
13592 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
13593 
13594 	/* Create Crypto session*/
13595 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
13596 				&ut_params->auth_xform,
13597 				ts_params->session_mpool);
13598 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13599 		return TEST_SKIPPED;
13600 
13601 	return 0;
13602 }
13603 
13604 static int
13605 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
13606 		uint8_t dev_id,
13607 		const struct test_crypto_vector *reference,
13608 		enum rte_crypto_auth_operation auth_op,
13609 		enum rte_crypto_cipher_operation cipher_op)
13610 {
13611 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13612 	uint8_t cipher_key[reference->cipher_key.len + 1];
13613 	uint8_t auth_key[reference->auth_key.len + 1];
13614 
13615 	memcpy(cipher_key, reference->cipher_key.data,
13616 			reference->cipher_key.len);
13617 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13618 
13619 	/* Setup Authentication Parameters */
13620 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13621 	ut_params->auth_xform.auth.op = auth_op;
13622 	ut_params->auth_xform.auth.algo = reference->auth_algo;
13623 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13624 	ut_params->auth_xform.auth.key.data = auth_key;
13625 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
13626 
13627 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
13628 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13629 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
13630 	} else {
13631 		ut_params->auth_xform.next = &ut_params->cipher_xform;
13632 
13633 		/* Setup Cipher Parameters */
13634 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13635 		ut_params->cipher_xform.next = NULL;
13636 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13637 		ut_params->cipher_xform.cipher.op = cipher_op;
13638 		ut_params->cipher_xform.cipher.key.data = cipher_key;
13639 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13640 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13641 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13642 	}
13643 
13644 	/* Create Crypto session*/
13645 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
13646 				&ut_params->auth_xform,
13647 				ts_params->session_mpool);
13648 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13649 		return TEST_SKIPPED;
13650 
13651 	return 0;
13652 }
13653 
13654 static int
13655 create_auth_operation(struct crypto_testsuite_params *ts_params,
13656 		struct crypto_unittest_params *ut_params,
13657 		const struct test_crypto_vector *reference,
13658 		unsigned int auth_generate)
13659 {
13660 	/* Generate Crypto op data structure */
13661 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13662 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13663 	TEST_ASSERT_NOT_NULL(ut_params->op,
13664 			"Failed to allocate pktmbuf offload");
13665 
13666 	/* Set crypto operation data parameters */
13667 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13668 
13669 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13670 
13671 	/* set crypto operation source mbuf */
13672 	sym_op->m_src = ut_params->ibuf;
13673 
13674 	/* digest */
13675 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13676 			ut_params->ibuf, reference->digest.len);
13677 
13678 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13679 			"no room to append auth tag");
13680 
13681 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13682 			ut_params->ibuf, reference->plaintext.len);
13683 
13684 	if (auth_generate)
13685 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
13686 	else
13687 		memcpy(sym_op->auth.digest.data,
13688 				reference->digest.data,
13689 				reference->digest.len);
13690 
13691 	debug_hexdump(stdout, "digest:",
13692 			sym_op->auth.digest.data,
13693 			reference->digest.len);
13694 
13695 	sym_op->auth.data.length = reference->plaintext.len;
13696 	sym_op->auth.data.offset = 0;
13697 
13698 	return 0;
13699 }
13700 
13701 static int
13702 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
13703 		struct crypto_unittest_params *ut_params,
13704 		const struct test_crypto_vector *reference,
13705 		unsigned int auth_generate)
13706 {
13707 	/* Generate Crypto op data structure */
13708 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13709 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13710 	TEST_ASSERT_NOT_NULL(ut_params->op,
13711 			"Failed to allocate pktmbuf offload");
13712 
13713 	/* Set crypto operation data parameters */
13714 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13715 
13716 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13717 
13718 	/* set crypto operation source mbuf */
13719 	sym_op->m_src = ut_params->ibuf;
13720 
13721 	/* digest */
13722 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13723 			ut_params->ibuf, reference->digest.len);
13724 
13725 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13726 			"no room to append auth tag");
13727 
13728 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13729 			ut_params->ibuf, reference->ciphertext.len);
13730 
13731 	if (auth_generate)
13732 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
13733 	else
13734 		memcpy(sym_op->auth.digest.data,
13735 				reference->digest.data,
13736 				reference->digest.len);
13737 
13738 	debug_hexdump(stdout, "digest:",
13739 			sym_op->auth.digest.data,
13740 			reference->digest.len);
13741 
13742 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13743 			reference->iv.data, reference->iv.len);
13744 
13745 	sym_op->cipher.data.length = 0;
13746 	sym_op->cipher.data.offset = 0;
13747 
13748 	sym_op->auth.data.length = reference->plaintext.len;
13749 	sym_op->auth.data.offset = 0;
13750 
13751 	return 0;
13752 }
13753 
13754 static int
13755 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
13756 		struct crypto_unittest_params *ut_params,
13757 		const struct test_crypto_vector *reference,
13758 		unsigned int auth_generate)
13759 {
13760 	/* Generate Crypto op data structure */
13761 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13762 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13763 	TEST_ASSERT_NOT_NULL(ut_params->op,
13764 			"Failed to allocate pktmbuf offload");
13765 
13766 	/* Set crypto operation data parameters */
13767 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13768 
13769 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13770 
13771 	/* set crypto operation source mbuf */
13772 	sym_op->m_src = ut_params->ibuf;
13773 
13774 	/* digest */
13775 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13776 			ut_params->ibuf, reference->digest.len);
13777 
13778 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13779 			"no room to append auth tag");
13780 
13781 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13782 			ut_params->ibuf, reference->ciphertext.len);
13783 
13784 	if (auth_generate)
13785 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
13786 	else
13787 		memcpy(sym_op->auth.digest.data,
13788 				reference->digest.data,
13789 				reference->digest.len);
13790 
13791 	debug_hexdump(stdout, "digest:",
13792 			sym_op->auth.digest.data,
13793 			reference->digest.len);
13794 
13795 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13796 			reference->iv.data, reference->iv.len);
13797 
13798 	sym_op->cipher.data.length = reference->cipher_len;
13799 	sym_op->cipher.data.offset = reference->cipher_offset;
13800 
13801 	sym_op->auth.data.length = reference->plaintext.len;
13802 	sym_op->auth.data.offset = reference->auth_offset;
13803 
13804 	return 0;
13805 }
13806 
13807 static int
13808 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13809 		struct crypto_unittest_params *ut_params,
13810 		const struct test_crypto_vector *reference)
13811 {
13812 	return create_auth_operation(ts_params, ut_params, reference, 0);
13813 }
13814 
13815 static int
13816 create_auth_verify_GMAC_operation(
13817 		struct crypto_testsuite_params *ts_params,
13818 		struct crypto_unittest_params *ut_params,
13819 		const struct test_crypto_vector *reference)
13820 {
13821 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13822 }
13823 
13824 static int
13825 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13826 		struct crypto_unittest_params *ut_params,
13827 		const struct test_crypto_vector *reference)
13828 {
13829 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13830 }
13831 
13832 static int
13833 test_authentication_verify_fail_when_data_corruption(
13834 		struct crypto_testsuite_params *ts_params,
13835 		struct crypto_unittest_params *ut_params,
13836 		const struct test_crypto_vector *reference,
13837 		unsigned int data_corrupted)
13838 {
13839 	int retval;
13840 
13841 	uint8_t *plaintext;
13842 	struct rte_cryptodev_info dev_info;
13843 
13844 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13845 	uint64_t feat_flags = dev_info.feature_flags;
13846 
13847 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13848 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13849 		printf("Device doesn't support RAW data-path APIs.\n");
13850 		return TEST_SKIPPED;
13851 	}
13852 
13853 	/* Verify the capabilities */
13854 	struct rte_cryptodev_sym_capability_idx cap_idx;
13855 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13856 	cap_idx.algo.auth = reference->auth_algo;
13857 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13858 			&cap_idx) == NULL)
13859 		return TEST_SKIPPED;
13860 
13861 
13862 	/* Create session */
13863 	retval = create_auth_session(ut_params,
13864 			ts_params->valid_devs[0],
13865 			reference,
13866 			RTE_CRYPTO_AUTH_OP_VERIFY);
13867 
13868 	if (retval == -ENOTSUP)
13869 		return TEST_SKIPPED;
13870 	if (retval < 0)
13871 		return retval;
13872 
13873 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13874 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13875 			"Failed to allocate input buffer in mempool");
13876 
13877 	/* clear mbuf payload */
13878 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13879 			rte_pktmbuf_tailroom(ut_params->ibuf));
13880 
13881 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13882 			reference->plaintext.len);
13883 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13884 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13885 
13886 	debug_hexdump(stdout, "plaintext:", plaintext,
13887 		reference->plaintext.len);
13888 
13889 	/* Create operation */
13890 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
13891 
13892 	if (retval < 0)
13893 		return retval;
13894 
13895 	if (data_corrupted)
13896 		data_corruption(plaintext);
13897 	else
13898 		tag_corruption(plaintext, reference->plaintext.len);
13899 
13900 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13901 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13902 			ut_params->op);
13903 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13904 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13905 			"authentication not failed");
13906 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13907 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13908 				ut_params->op, 0, 1, 0, 0);
13909 	else {
13910 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13911 			ut_params->op);
13912 	}
13913 	if (ut_params->op == NULL)
13914 		return 0;
13915 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13916 		return 0;
13917 
13918 	return -1;
13919 }
13920 
13921 static int
13922 test_authentication_verify_GMAC_fail_when_corruption(
13923 		struct crypto_testsuite_params *ts_params,
13924 		struct crypto_unittest_params *ut_params,
13925 		const struct test_crypto_vector *reference,
13926 		unsigned int data_corrupted)
13927 {
13928 	int retval;
13929 	uint8_t *plaintext;
13930 	struct rte_cryptodev_info dev_info;
13931 
13932 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13933 	uint64_t feat_flags = dev_info.feature_flags;
13934 
13935 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13936 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13937 		printf("Device doesn't support RAW data-path APIs.\n");
13938 		return TEST_SKIPPED;
13939 	}
13940 
13941 	/* Verify the capabilities */
13942 	struct rte_cryptodev_sym_capability_idx cap_idx;
13943 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13944 	cap_idx.algo.auth = reference->auth_algo;
13945 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13946 			&cap_idx) == NULL)
13947 		return TEST_SKIPPED;
13948 
13949 	/* Create session */
13950 	retval = create_auth_cipher_session(ut_params,
13951 			ts_params->valid_devs[0],
13952 			reference,
13953 			RTE_CRYPTO_AUTH_OP_VERIFY,
13954 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
13955 	if (retval < 0)
13956 		return retval;
13957 
13958 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13959 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13960 			"Failed to allocate input buffer in mempool");
13961 
13962 	/* clear mbuf payload */
13963 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13964 			rte_pktmbuf_tailroom(ut_params->ibuf));
13965 
13966 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13967 			reference->plaintext.len);
13968 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13969 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13970 
13971 	debug_hexdump(stdout, "plaintext:", plaintext,
13972 		reference->plaintext.len);
13973 
13974 	/* Create operation */
13975 	retval = create_auth_verify_GMAC_operation(ts_params,
13976 			ut_params,
13977 			reference);
13978 
13979 	if (retval < 0)
13980 		return retval;
13981 
13982 	if (data_corrupted)
13983 		data_corruption(plaintext);
13984 	else
13985 		tag_corruption(plaintext, reference->aad.len);
13986 
13987 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13988 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13989 			ut_params->op);
13990 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13991 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13992 			"authentication not failed");
13993 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13994 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13995 				ut_params->op, 0, 1, 0, 0);
13996 	else {
13997 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13998 			ut_params->op);
13999 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
14000 	}
14001 
14002 	return 0;
14003 }
14004 
14005 static int
14006 test_authenticated_decryption_fail_when_corruption(
14007 		struct crypto_testsuite_params *ts_params,
14008 		struct crypto_unittest_params *ut_params,
14009 		const struct test_crypto_vector *reference,
14010 		unsigned int data_corrupted)
14011 {
14012 	int retval;
14013 
14014 	uint8_t *ciphertext;
14015 	struct rte_cryptodev_info dev_info;
14016 
14017 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14018 	uint64_t feat_flags = dev_info.feature_flags;
14019 
14020 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14021 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14022 		printf("Device doesn't support RAW data-path APIs.\n");
14023 		return TEST_SKIPPED;
14024 	}
14025 
14026 	/* Verify the capabilities */
14027 	struct rte_cryptodev_sym_capability_idx cap_idx;
14028 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14029 	cap_idx.algo.auth = reference->auth_algo;
14030 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14031 			&cap_idx) == NULL)
14032 		return TEST_SKIPPED;
14033 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14034 	cap_idx.algo.cipher = reference->crypto_algo;
14035 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14036 			&cap_idx) == NULL)
14037 		return TEST_SKIPPED;
14038 
14039 	/* Create session */
14040 	retval = create_auth_cipher_session(ut_params,
14041 			ts_params->valid_devs[0],
14042 			reference,
14043 			RTE_CRYPTO_AUTH_OP_VERIFY,
14044 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
14045 
14046 	if (retval == -ENOTSUP)
14047 		return TEST_SKIPPED;
14048 	if (retval < 0)
14049 		return retval;
14050 
14051 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14052 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14053 			"Failed to allocate input buffer in mempool");
14054 
14055 	/* clear mbuf payload */
14056 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14057 			rte_pktmbuf_tailroom(ut_params->ibuf));
14058 
14059 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14060 			reference->ciphertext.len);
14061 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
14062 	memcpy(ciphertext, reference->ciphertext.data,
14063 			reference->ciphertext.len);
14064 
14065 	/* Create operation */
14066 	retval = create_cipher_auth_verify_operation(ts_params,
14067 			ut_params,
14068 			reference);
14069 
14070 	if (retval < 0)
14071 		return retval;
14072 
14073 	if (data_corrupted)
14074 		data_corruption(ciphertext);
14075 	else
14076 		tag_corruption(ciphertext, reference->ciphertext.len);
14077 
14078 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
14079 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14080 			ut_params->op);
14081 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
14082 			RTE_CRYPTO_OP_STATUS_SUCCESS,
14083 			"authentication not failed");
14084 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14085 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14086 				ut_params->op, 1, 1, 0, 0);
14087 	else {
14088 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14089 			ut_params->op);
14090 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
14091 	}
14092 
14093 	return 0;
14094 }
14095 
14096 static int
14097 test_authenticated_encrypt_with_esn(
14098 		struct crypto_testsuite_params *ts_params,
14099 		struct crypto_unittest_params *ut_params,
14100 		const struct test_crypto_vector *reference)
14101 {
14102 	int retval;
14103 
14104 	uint8_t *authciphertext, *plaintext, *auth_tag;
14105 	uint16_t plaintext_pad_len;
14106 	uint8_t cipher_key[reference->cipher_key.len + 1];
14107 	uint8_t auth_key[reference->auth_key.len + 1];
14108 	struct rte_cryptodev_info dev_info;
14109 
14110 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14111 	uint64_t feat_flags = dev_info.feature_flags;
14112 
14113 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14114 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14115 		printf("Device doesn't support RAW data-path APIs.\n");
14116 		return TEST_SKIPPED;
14117 	}
14118 
14119 	/* Verify the capabilities */
14120 	struct rte_cryptodev_sym_capability_idx cap_idx;
14121 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14122 	cap_idx.algo.auth = reference->auth_algo;
14123 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14124 			&cap_idx) == NULL)
14125 		return TEST_SKIPPED;
14126 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14127 	cap_idx.algo.cipher = reference->crypto_algo;
14128 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14129 			&cap_idx) == NULL)
14130 		return TEST_SKIPPED;
14131 
14132 	/* Create session */
14133 	memcpy(cipher_key, reference->cipher_key.data,
14134 			reference->cipher_key.len);
14135 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14136 
14137 	/* Setup Cipher Parameters */
14138 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14139 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14140 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14141 	ut_params->cipher_xform.cipher.key.data = cipher_key;
14142 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14143 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14144 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14145 
14146 	ut_params->cipher_xform.next = &ut_params->auth_xform;
14147 
14148 	/* Setup Authentication Parameters */
14149 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14150 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14151 	ut_params->auth_xform.auth.algo = reference->auth_algo;
14152 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14153 	ut_params->auth_xform.auth.key.data = auth_key;
14154 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
14155 	ut_params->auth_xform.next = NULL;
14156 
14157 	/* Create Crypto session*/
14158 	ut_params->sess = rte_cryptodev_sym_session_create(
14159 			ts_params->valid_devs[0], &ut_params->cipher_xform,
14160 			ts_params->session_mpool);
14161 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14162 		return TEST_SKIPPED;
14163 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14164 
14165 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14166 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14167 			"Failed to allocate input buffer in mempool");
14168 
14169 	/* clear mbuf payload */
14170 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14171 			rte_pktmbuf_tailroom(ut_params->ibuf));
14172 
14173 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14174 			reference->plaintext.len);
14175 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14176 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14177 
14178 	/* Create operation */
14179 	retval = create_cipher_auth_operation(ts_params,
14180 			ut_params,
14181 			reference, 0);
14182 
14183 	if (retval < 0)
14184 		return retval;
14185 
14186 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14187 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14188 			ut_params->op);
14189 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14190 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14191 				ut_params->op, 1, 1, 0, 0);
14192 	else
14193 		ut_params->op = process_crypto_request(
14194 			ts_params->valid_devs[0], ut_params->op);
14195 
14196 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
14197 
14198 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14199 			"crypto op processing failed");
14200 
14201 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
14202 
14203 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14204 			ut_params->op->sym->auth.data.offset);
14205 	auth_tag = authciphertext + plaintext_pad_len;
14206 	debug_hexdump(stdout, "ciphertext:", authciphertext,
14207 			reference->ciphertext.len);
14208 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
14209 
14210 	/* Validate obuf */
14211 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14212 			authciphertext,
14213 			reference->ciphertext.data,
14214 			reference->ciphertext.len,
14215 			"Ciphertext data not as expected");
14216 
14217 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14218 			auth_tag,
14219 			reference->digest.data,
14220 			reference->digest.len,
14221 			"Generated digest not as expected");
14222 
14223 	return TEST_SUCCESS;
14224 
14225 }
14226 
14227 static int
14228 test_authenticated_decrypt_with_esn(
14229 		struct crypto_testsuite_params *ts_params,
14230 		struct crypto_unittest_params *ut_params,
14231 		const struct test_crypto_vector *reference)
14232 {
14233 	int retval;
14234 
14235 	uint8_t *ciphertext;
14236 	uint8_t cipher_key[reference->cipher_key.len + 1];
14237 	uint8_t auth_key[reference->auth_key.len + 1];
14238 	struct rte_cryptodev_info dev_info;
14239 
14240 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14241 	uint64_t feat_flags = dev_info.feature_flags;
14242 
14243 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14244 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14245 		printf("Device doesn't support RAW data-path APIs.\n");
14246 		return TEST_SKIPPED;
14247 	}
14248 
14249 	/* Verify the capabilities */
14250 	struct rte_cryptodev_sym_capability_idx cap_idx;
14251 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14252 	cap_idx.algo.auth = reference->auth_algo;
14253 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14254 			&cap_idx) == NULL)
14255 		return TEST_SKIPPED;
14256 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14257 	cap_idx.algo.cipher = reference->crypto_algo;
14258 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14259 			&cap_idx) == NULL)
14260 		return TEST_SKIPPED;
14261 
14262 	/* Create session */
14263 	memcpy(cipher_key, reference->cipher_key.data,
14264 			reference->cipher_key.len);
14265 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14266 
14267 	/* Setup Authentication Parameters */
14268 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14269 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
14270 	ut_params->auth_xform.auth.algo = reference->auth_algo;
14271 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14272 	ut_params->auth_xform.auth.key.data = auth_key;
14273 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
14274 	ut_params->auth_xform.next = &ut_params->cipher_xform;
14275 
14276 	/* Setup Cipher Parameters */
14277 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14278 	ut_params->cipher_xform.next = NULL;
14279 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14280 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
14281 	ut_params->cipher_xform.cipher.key.data = cipher_key;
14282 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14283 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14284 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14285 
14286 	/* Create Crypto session*/
14287 	ut_params->sess = rte_cryptodev_sym_session_create(
14288 			ts_params->valid_devs[0], &ut_params->auth_xform,
14289 			ts_params->session_mpool);
14290 	if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14291 		return TEST_SKIPPED;
14292 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14293 
14294 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14295 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14296 			"Failed to allocate input buffer in mempool");
14297 
14298 	/* clear mbuf payload */
14299 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14300 			rte_pktmbuf_tailroom(ut_params->ibuf));
14301 
14302 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14303 			reference->ciphertext.len);
14304 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
14305 	memcpy(ciphertext, reference->ciphertext.data,
14306 			reference->ciphertext.len);
14307 
14308 	/* Create operation */
14309 	retval = create_cipher_auth_verify_operation(ts_params,
14310 			ut_params,
14311 			reference);
14312 
14313 	if (retval < 0)
14314 		return retval;
14315 
14316 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14317 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14318 			ut_params->op);
14319 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14320 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14321 				ut_params->op, 1, 1, 0, 0);
14322 	else
14323 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14324 			ut_params->op);
14325 
14326 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14327 	TEST_ASSERT_EQUAL(ut_params->op->status,
14328 			RTE_CRYPTO_OP_STATUS_SUCCESS,
14329 			"crypto op processing passed");
14330 
14331 	ut_params->obuf = ut_params->op->sym->m_src;
14332 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
14333 
14334 	return 0;
14335 }
14336 
14337 static int
14338 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
14339 		const struct aead_test_data *tdata,
14340 		void *digest_mem, uint64_t digest_phys)
14341 {
14342 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14343 	struct crypto_unittest_params *ut_params = &unittest_params;
14344 
14345 	const unsigned int auth_tag_len = tdata->auth_tag.len;
14346 	const unsigned int iv_len = tdata->iv.len;
14347 	unsigned int aad_len = tdata->aad.len;
14348 	unsigned int aad_len_pad = 0;
14349 
14350 	/* Generate Crypto op data structure */
14351 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14352 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14353 	TEST_ASSERT_NOT_NULL(ut_params->op,
14354 		"Failed to allocate symmetric crypto operation struct");
14355 
14356 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14357 
14358 	sym_op->aead.digest.data = digest_mem;
14359 
14360 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
14361 			"no room to append digest");
14362 
14363 	sym_op->aead.digest.phys_addr = digest_phys;
14364 
14365 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
14366 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
14367 				auth_tag_len);
14368 		debug_hexdump(stdout, "digest:",
14369 				sym_op->aead.digest.data,
14370 				auth_tag_len);
14371 	}
14372 
14373 	/* Append aad data */
14374 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
14375 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14376 				uint8_t *, IV_OFFSET);
14377 
14378 		/* Copy IV 1 byte after the IV pointer, according to the API */
14379 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
14380 
14381 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
14382 
14383 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
14384 				ut_params->ibuf, aad_len);
14385 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
14386 				"no room to prepend aad");
14387 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
14388 				ut_params->ibuf);
14389 
14390 		memset(sym_op->aead.aad.data, 0, aad_len);
14391 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
14392 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
14393 
14394 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
14395 		debug_hexdump(stdout, "aad:",
14396 				sym_op->aead.aad.data, aad_len);
14397 	} else {
14398 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14399 				uint8_t *, IV_OFFSET);
14400 
14401 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
14402 
14403 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
14404 
14405 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
14406 				ut_params->ibuf, aad_len_pad);
14407 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
14408 				"no room to prepend aad");
14409 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
14410 				ut_params->ibuf);
14411 
14412 		memset(sym_op->aead.aad.data, 0, aad_len);
14413 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
14414 
14415 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
14416 		debug_hexdump(stdout, "aad:",
14417 				sym_op->aead.aad.data, aad_len);
14418 	}
14419 
14420 	sym_op->aead.data.length = tdata->plaintext.len;
14421 	sym_op->aead.data.offset = aad_len_pad;
14422 
14423 	return 0;
14424 }
14425 
14426 #define SGL_MAX_NO	16
14427 
14428 static int
14429 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
14430 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
14431 {
14432 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14433 	struct crypto_unittest_params *ut_params = &unittest_params;
14434 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
14435 	int retval;
14436 	int to_trn = 0;
14437 	int to_trn_tbl[SGL_MAX_NO];
14438 	int segs = 1;
14439 	unsigned int trn_data = 0;
14440 	uint8_t *plaintext, *ciphertext, *auth_tag;
14441 	struct rte_cryptodev_info dev_info;
14442 
14443 	/* Verify the capabilities */
14444 	struct rte_cryptodev_sym_capability_idx cap_idx;
14445 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14446 	cap_idx.algo.aead = tdata->algo;
14447 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14448 			&cap_idx) == NULL)
14449 		return TEST_SKIPPED;
14450 
14451 	/* OOP not supported with CPU crypto */
14452 	if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14453 		return TEST_SKIPPED;
14454 
14455 	/* Detailed check for the particular SGL support flag */
14456 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14457 	if (!oop) {
14458 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
14459 		if (sgl_in && (!(dev_info.feature_flags &
14460 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
14461 			return TEST_SKIPPED;
14462 
14463 		uint64_t feat_flags = dev_info.feature_flags;
14464 
14465 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14466 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14467 			printf("Device doesn't support RAW data-path APIs.\n");
14468 			return TEST_SKIPPED;
14469 		}
14470 	} else {
14471 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
14472 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
14473 				tdata->plaintext.len;
14474 		/* Raw data path API does not support OOP */
14475 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14476 			return TEST_SKIPPED;
14477 		if (sgl_in && !sgl_out) {
14478 			if (!(dev_info.feature_flags &
14479 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
14480 				return TEST_SKIPPED;
14481 		} else if (!sgl_in && sgl_out) {
14482 			if (!(dev_info.feature_flags &
14483 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
14484 				return TEST_SKIPPED;
14485 		} else if (sgl_in && sgl_out) {
14486 			if (!(dev_info.feature_flags &
14487 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
14488 				return TEST_SKIPPED;
14489 		}
14490 	}
14491 
14492 	if (fragsz > tdata->plaintext.len)
14493 		fragsz = tdata->plaintext.len;
14494 
14495 	uint16_t plaintext_len = fragsz;
14496 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
14497 
14498 	if (fragsz_oop > tdata->plaintext.len)
14499 		frag_size_oop = tdata->plaintext.len;
14500 
14501 	int ecx = 0;
14502 	void *digest_mem = NULL;
14503 
14504 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
14505 
14506 	if (tdata->plaintext.len % fragsz != 0) {
14507 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
14508 			return 1;
14509 	}	else {
14510 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
14511 			return 1;
14512 	}
14513 
14514 	/*
14515 	 * For out-op-place we need to alloc another mbuf
14516 	 */
14517 	if (oop) {
14518 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14519 		rte_pktmbuf_append(ut_params->obuf,
14520 				frag_size_oop + prepend_len);
14521 		buf_oop = ut_params->obuf;
14522 	}
14523 
14524 	/* Create AEAD session */
14525 	retval = create_aead_session(ts_params->valid_devs[0],
14526 			tdata->algo,
14527 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
14528 			tdata->key.data, tdata->key.len,
14529 			tdata->aad.len, tdata->auth_tag.len,
14530 			tdata->iv.len);
14531 	if (retval < 0)
14532 		return retval;
14533 
14534 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14535 
14536 	/* clear mbuf payload */
14537 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14538 			rte_pktmbuf_tailroom(ut_params->ibuf));
14539 
14540 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14541 			plaintext_len);
14542 
14543 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14544 
14545 	trn_data += plaintext_len;
14546 
14547 	buf = ut_params->ibuf;
14548 
14549 	/*
14550 	 * Loop until no more fragments
14551 	 */
14552 
14553 	while (trn_data < tdata->plaintext.len) {
14554 		++segs;
14555 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14556 				(tdata->plaintext.len - trn_data) : fragsz;
14557 
14558 		to_trn_tbl[ecx++] = to_trn;
14559 
14560 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14561 		buf = buf->next;
14562 
14563 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14564 				rte_pktmbuf_tailroom(buf));
14565 
14566 		/* OOP */
14567 		if (oop && !fragsz_oop) {
14568 			buf_last_oop = buf_oop->next =
14569 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
14570 			buf_oop = buf_oop->next;
14571 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14572 					0, rte_pktmbuf_tailroom(buf_oop));
14573 			rte_pktmbuf_append(buf_oop, to_trn);
14574 		}
14575 
14576 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14577 				to_trn);
14578 
14579 		memcpy(plaintext, tdata->plaintext.data + trn_data,
14580 				to_trn);
14581 		trn_data += to_trn;
14582 		if (trn_data  == tdata->plaintext.len) {
14583 			if (oop) {
14584 				if (!fragsz_oop)
14585 					digest_mem = rte_pktmbuf_append(buf_oop,
14586 						tdata->auth_tag.len);
14587 			} else
14588 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14589 					tdata->auth_tag.len);
14590 		}
14591 	}
14592 
14593 	uint64_t digest_phys = 0;
14594 
14595 	ut_params->ibuf->nb_segs = segs;
14596 
14597 	segs = 1;
14598 	if (fragsz_oop && oop) {
14599 		to_trn = 0;
14600 		ecx = 0;
14601 
14602 		if (frag_size_oop == tdata->plaintext.len) {
14603 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
14604 				tdata->auth_tag.len);
14605 
14606 			digest_phys = rte_pktmbuf_iova_offset(
14607 					ut_params->obuf,
14608 					tdata->plaintext.len + prepend_len);
14609 		}
14610 
14611 		trn_data = frag_size_oop;
14612 		while (trn_data < tdata->plaintext.len) {
14613 			++segs;
14614 			to_trn =
14615 				(tdata->plaintext.len - trn_data <
14616 						frag_size_oop) ?
14617 				(tdata->plaintext.len - trn_data) :
14618 						frag_size_oop;
14619 
14620 			to_trn_tbl[ecx++] = to_trn;
14621 
14622 			buf_last_oop = buf_oop->next =
14623 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
14624 			buf_oop = buf_oop->next;
14625 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14626 					0, rte_pktmbuf_tailroom(buf_oop));
14627 			rte_pktmbuf_append(buf_oop, to_trn);
14628 
14629 			trn_data += to_trn;
14630 
14631 			if (trn_data  == tdata->plaintext.len) {
14632 				digest_mem = rte_pktmbuf_append(buf_oop,
14633 					tdata->auth_tag.len);
14634 			}
14635 		}
14636 
14637 		ut_params->obuf->nb_segs = segs;
14638 	}
14639 
14640 	/*
14641 	 * Place digest at the end of the last buffer
14642 	 */
14643 	if (!digest_phys)
14644 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14645 	if (oop && buf_last_oop)
14646 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
14647 
14648 	if (!digest_mem && !oop) {
14649 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14650 				+ tdata->auth_tag.len);
14651 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14652 				tdata->plaintext.len);
14653 	}
14654 
14655 	/* Create AEAD operation */
14656 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
14657 			tdata, digest_mem, digest_phys);
14658 
14659 	if (retval < 0)
14660 		return retval;
14661 
14662 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14663 
14664 	ut_params->op->sym->m_src = ut_params->ibuf;
14665 	if (oop)
14666 		ut_params->op->sym->m_dst = ut_params->obuf;
14667 
14668 	/* Process crypto operation */
14669 	if (oop == IN_PLACE &&
14670 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14671 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
14672 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14673 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14674 				ut_params->op, 0, 0, 0, 0);
14675 	else
14676 		TEST_ASSERT_NOT_NULL(
14677 			process_crypto_request(ts_params->valid_devs[0],
14678 			ut_params->op), "failed to process sym crypto op");
14679 
14680 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14681 			"crypto op processing failed");
14682 
14683 
14684 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
14685 			uint8_t *, prepend_len);
14686 	if (oop) {
14687 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14688 				uint8_t *, prepend_len);
14689 	}
14690 
14691 	if (fragsz_oop)
14692 		fragsz = fragsz_oop;
14693 
14694 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14695 			ciphertext,
14696 			tdata->ciphertext.data,
14697 			fragsz,
14698 			"Ciphertext data not as expected");
14699 
14700 	buf = ut_params->op->sym->m_src->next;
14701 	if (oop)
14702 		buf = ut_params->op->sym->m_dst->next;
14703 
14704 	unsigned int off = fragsz;
14705 
14706 	ecx = 0;
14707 	while (buf) {
14708 		ciphertext = rte_pktmbuf_mtod(buf,
14709 				uint8_t *);
14710 
14711 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
14712 				ciphertext,
14713 				tdata->ciphertext.data + off,
14714 				to_trn_tbl[ecx],
14715 				"Ciphertext data not as expected");
14716 
14717 		off += to_trn_tbl[ecx++];
14718 		buf = buf->next;
14719 	}
14720 
14721 	auth_tag = digest_mem;
14722 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14723 			auth_tag,
14724 			tdata->auth_tag.data,
14725 			tdata->auth_tag.len,
14726 			"Generated auth tag not as expected");
14727 
14728 	return 0;
14729 }
14730 
14731 static int
14732 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
14733 {
14734 	return test_authenticated_encryption_SGL(
14735 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
14736 }
14737 
14738 static int
14739 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
14740 {
14741 	return test_authenticated_encryption_SGL(
14742 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
14743 }
14744 
14745 static int
14746 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
14747 {
14748 	return test_authenticated_encryption_SGL(
14749 			&gcm_test_case_8, OUT_OF_PLACE, 400,
14750 			gcm_test_case_8.plaintext.len);
14751 }
14752 
14753 static int
14754 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
14755 {
14756 	/* This test is not for OPENSSL PMD */
14757 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
14758 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
14759 		return TEST_SKIPPED;
14760 
14761 	return test_authenticated_encryption_SGL(
14762 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
14763 }
14764 
14765 static int
14766 test_authentication_verify_fail_when_data_corrupted(
14767 		struct crypto_testsuite_params *ts_params,
14768 		struct crypto_unittest_params *ut_params,
14769 		const struct test_crypto_vector *reference)
14770 {
14771 	return test_authentication_verify_fail_when_data_corruption(
14772 			ts_params, ut_params, reference, 1);
14773 }
14774 
14775 static int
14776 test_authentication_verify_fail_when_tag_corrupted(
14777 		struct crypto_testsuite_params *ts_params,
14778 		struct crypto_unittest_params *ut_params,
14779 		const struct test_crypto_vector *reference)
14780 {
14781 	return test_authentication_verify_fail_when_data_corruption(
14782 			ts_params, ut_params, reference, 0);
14783 }
14784 
14785 static int
14786 test_authentication_verify_GMAC_fail_when_data_corrupted(
14787 		struct crypto_testsuite_params *ts_params,
14788 		struct crypto_unittest_params *ut_params,
14789 		const struct test_crypto_vector *reference)
14790 {
14791 	return test_authentication_verify_GMAC_fail_when_corruption(
14792 			ts_params, ut_params, reference, 1);
14793 }
14794 
14795 static int
14796 test_authentication_verify_GMAC_fail_when_tag_corrupted(
14797 		struct crypto_testsuite_params *ts_params,
14798 		struct crypto_unittest_params *ut_params,
14799 		const struct test_crypto_vector *reference)
14800 {
14801 	return test_authentication_verify_GMAC_fail_when_corruption(
14802 			ts_params, ut_params, reference, 0);
14803 }
14804 
14805 static int
14806 test_authenticated_decryption_fail_when_data_corrupted(
14807 		struct crypto_testsuite_params *ts_params,
14808 		struct crypto_unittest_params *ut_params,
14809 		const struct test_crypto_vector *reference)
14810 {
14811 	return test_authenticated_decryption_fail_when_corruption(
14812 			ts_params, ut_params, reference, 1);
14813 }
14814 
14815 static int
14816 test_authenticated_decryption_fail_when_tag_corrupted(
14817 		struct crypto_testsuite_params *ts_params,
14818 		struct crypto_unittest_params *ut_params,
14819 		const struct test_crypto_vector *reference)
14820 {
14821 	return test_authenticated_decryption_fail_when_corruption(
14822 			ts_params, ut_params, reference, 0);
14823 }
14824 
14825 static int
14826 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14827 {
14828 	return test_authentication_verify_fail_when_data_corrupted(
14829 			&testsuite_params, &unittest_params,
14830 			&hmac_sha1_test_crypto_vector);
14831 }
14832 
14833 static int
14834 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14835 {
14836 	return test_authentication_verify_fail_when_tag_corrupted(
14837 			&testsuite_params, &unittest_params,
14838 			&hmac_sha1_test_crypto_vector);
14839 }
14840 
14841 static int
14842 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14843 {
14844 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
14845 			&testsuite_params, &unittest_params,
14846 			&aes128_gmac_test_vector);
14847 }
14848 
14849 static int
14850 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14851 {
14852 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14853 			&testsuite_params, &unittest_params,
14854 			&aes128_gmac_test_vector);
14855 }
14856 
14857 static int
14858 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14859 {
14860 	return test_authenticated_decryption_fail_when_data_corrupted(
14861 			&testsuite_params,
14862 			&unittest_params,
14863 			&aes128cbc_hmac_sha1_test_vector);
14864 }
14865 
14866 static int
14867 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14868 {
14869 	return test_authenticated_decryption_fail_when_tag_corrupted(
14870 			&testsuite_params,
14871 			&unittest_params,
14872 			&aes128cbc_hmac_sha1_test_vector);
14873 }
14874 
14875 static int
14876 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14877 {
14878 	return test_authenticated_encrypt_with_esn(
14879 			&testsuite_params,
14880 			&unittest_params,
14881 			&aes128cbc_hmac_sha1_aad_test_vector);
14882 }
14883 
14884 static int
14885 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14886 {
14887 	return test_authenticated_decrypt_with_esn(
14888 			&testsuite_params,
14889 			&unittest_params,
14890 			&aes128cbc_hmac_sha1_aad_test_vector);
14891 }
14892 
14893 static int
14894 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14895 {
14896 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14897 }
14898 
14899 static int
14900 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14901 {
14902 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14903 }
14904 
14905 static int
14906 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14907 {
14908 	return test_authenticated_encryption_SGL(
14909 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14910 		chacha20_poly1305_case_2.plaintext.len);
14911 }
14912 
14913 #ifdef RTE_CRYPTO_SCHEDULER
14914 
14915 /* global AESNI worker IDs for the scheduler test */
14916 uint8_t aesni_ids[2];
14917 
14918 static int
14919 scheduler_testsuite_setup(void)
14920 {
14921 	uint32_t i = 0;
14922 	int32_t nb_devs, ret;
14923 	char vdev_args[VDEV_ARGS_SIZE] = {""};
14924 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14925 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
14926 	uint16_t worker_core_count = 0;
14927 	uint16_t socket_id = 0;
14928 
14929 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
14930 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14931 
14932 		/* Identify the Worker Cores
14933 		 * Use 2 worker cores for the device args
14934 		 */
14935 		RTE_LCORE_FOREACH_WORKER(i) {
14936 			if (worker_core_count > 1)
14937 				break;
14938 			snprintf(vdev_args, sizeof(vdev_args),
14939 					"%s%d", temp_str, i);
14940 			strcpy(temp_str, vdev_args);
14941 			strlcat(temp_str, ";", sizeof(temp_str));
14942 			worker_core_count++;
14943 			socket_id = rte_lcore_to_socket_id(i);
14944 		}
14945 		if (worker_core_count != 2) {
14946 			RTE_LOG(ERR, USER1,
14947 				"Cryptodev scheduler test require at least "
14948 				"two worker cores to run. "
14949 				"Please use the correct coremask.\n");
14950 			return TEST_FAILED;
14951 		}
14952 		strcpy(temp_str, vdev_args);
14953 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14954 				temp_str, socket_id);
14955 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14956 		nb_devs = rte_cryptodev_device_count_by_driver(
14957 				rte_cryptodev_driver_id_get(
14958 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14959 		if (nb_devs < 1) {
14960 			ret = rte_vdev_init(
14961 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14962 					vdev_args);
14963 			TEST_ASSERT(ret == 0,
14964 				"Failed to create instance %u of pmd : %s",
14965 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14966 		}
14967 	}
14968 	return testsuite_setup();
14969 }
14970 
14971 static int
14972 test_scheduler_attach_worker_op(void)
14973 {
14974 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14975 	uint8_t sched_id = ts_params->valid_devs[0];
14976 	uint32_t i, nb_devs_attached = 0;
14977 	int ret;
14978 	char vdev_name[32];
14979 	unsigned int count = rte_cryptodev_count();
14980 
14981 	/* create 2 AESNI_MB vdevs on top of existing devices */
14982 	for (i = count; i < count + 2; i++) {
14983 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14984 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14985 				i);
14986 		ret = rte_vdev_init(vdev_name, NULL);
14987 
14988 		TEST_ASSERT(ret == 0,
14989 			"Failed to create instance %u of"
14990 			" pmd : %s",
14991 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14992 
14993 		if (ret < 0) {
14994 			RTE_LOG(ERR, USER1,
14995 				"Failed to create 2 AESNI MB PMDs.\n");
14996 			return TEST_SKIPPED;
14997 		}
14998 	}
14999 
15000 	/* attach 2 AESNI_MB cdevs */
15001 	for (i = count; i < count + 2; i++) {
15002 		struct rte_cryptodev_info info;
15003 		unsigned int session_size;
15004 
15005 		rte_cryptodev_info_get(i, &info);
15006 		if (info.driver_id != rte_cryptodev_driver_id_get(
15007 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
15008 			continue;
15009 
15010 		session_size = rte_cryptodev_sym_get_private_session_size(i);
15011 		/*
15012 		 * Create the session mempool again, since now there are new devices
15013 		 * to use the mempool.
15014 		 */
15015 		if (ts_params->session_mpool) {
15016 			rte_mempool_free(ts_params->session_mpool);
15017 			ts_params->session_mpool = NULL;
15018 		}
15019 
15020 		if (info.sym.max_nb_sessions != 0 &&
15021 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
15022 			RTE_LOG(ERR, USER1,
15023 					"Device does not support "
15024 					"at least %u sessions\n",
15025 					MAX_NB_SESSIONS);
15026 			return TEST_FAILED;
15027 		}
15028 		/*
15029 		 * Create mempool with maximum number of sessions,
15030 		 * to include the session headers
15031 		 */
15032 		if (ts_params->session_mpool == NULL) {
15033 			ts_params->session_mpool =
15034 				rte_cryptodev_sym_session_pool_create(
15035 						"test_sess_mp",
15036 						MAX_NB_SESSIONS, session_size,
15037 						0, 0, SOCKET_ID_ANY);
15038 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
15039 					"session mempool allocation failed");
15040 		}
15041 
15042 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
15043 
15044 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
15045 				(uint8_t)i);
15046 
15047 		TEST_ASSERT(ret == 0,
15048 			"Failed to attach device %u of pmd : %s", i,
15049 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15050 
15051 		aesni_ids[nb_devs_attached] = (uint8_t)i;
15052 
15053 		nb_devs_attached++;
15054 	}
15055 
15056 	return 0;
15057 }
15058 
15059 static int
15060 test_scheduler_detach_worker_op(void)
15061 {
15062 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15063 	uint8_t sched_id = ts_params->valid_devs[0];
15064 	uint32_t i;
15065 	int ret;
15066 
15067 	for (i = 0; i < 2; i++) {
15068 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
15069 				aesni_ids[i]);
15070 		TEST_ASSERT(ret == 0,
15071 			"Failed to detach device %u", aesni_ids[i]);
15072 	}
15073 
15074 	return 0;
15075 }
15076 
15077 static int
15078 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
15079 {
15080 	struct crypto_testsuite_params *ts_params = &testsuite_params;
15081 	uint8_t sched_id = ts_params->valid_devs[0];
15082 	/* set mode */
15083 	return rte_cryptodev_scheduler_mode_set(sched_id,
15084 		scheduler_mode);
15085 }
15086 
15087 static int
15088 test_scheduler_mode_roundrobin_op(void)
15089 {
15090 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
15091 			0, "Failed to set roundrobin mode");
15092 	return 0;
15093 
15094 }
15095 
15096 static int
15097 test_scheduler_mode_multicore_op(void)
15098 {
15099 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
15100 			0, "Failed to set multicore mode");
15101 
15102 	return 0;
15103 }
15104 
15105 static int
15106 test_scheduler_mode_failover_op(void)
15107 {
15108 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
15109 			0, "Failed to set failover mode");
15110 
15111 	return 0;
15112 }
15113 
15114 static int
15115 test_scheduler_mode_pkt_size_distr_op(void)
15116 {
15117 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
15118 			0, "Failed to set pktsize mode");
15119 
15120 	return 0;
15121 }
15122 
15123 static int
15124 scheduler_multicore_testsuite_setup(void)
15125 {
15126 	if (test_scheduler_attach_worker_op() < 0)
15127 		return TEST_SKIPPED;
15128 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
15129 		return TEST_SKIPPED;
15130 	return 0;
15131 }
15132 
15133 static int
15134 scheduler_roundrobin_testsuite_setup(void)
15135 {
15136 	if (test_scheduler_attach_worker_op() < 0)
15137 		return TEST_SKIPPED;
15138 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
15139 		return TEST_SKIPPED;
15140 	return 0;
15141 }
15142 
15143 static int
15144 scheduler_failover_testsuite_setup(void)
15145 {
15146 	if (test_scheduler_attach_worker_op() < 0)
15147 		return TEST_SKIPPED;
15148 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
15149 		return TEST_SKIPPED;
15150 	return 0;
15151 }
15152 
15153 static int
15154 scheduler_pkt_size_distr_testsuite_setup(void)
15155 {
15156 	if (test_scheduler_attach_worker_op() < 0)
15157 		return TEST_SKIPPED;
15158 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
15159 		return TEST_SKIPPED;
15160 	return 0;
15161 }
15162 
15163 static void
15164 scheduler_mode_testsuite_teardown(void)
15165 {
15166 	test_scheduler_detach_worker_op();
15167 }
15168 
15169 #endif /* RTE_CRYPTO_SCHEDULER */
15170 
15171 static struct unit_test_suite end_testsuite = {
15172 	.suite_name = NULL,
15173 	.setup = NULL,
15174 	.teardown = NULL,
15175 	.unit_test_suites = NULL
15176 };
15177 
15178 #ifdef RTE_LIB_SECURITY
15179 static struct unit_test_suite ipsec_proto_testsuite  = {
15180 	.suite_name = "IPsec Proto Unit Test Suite",
15181 	.setup = ipsec_proto_testsuite_setup,
15182 	.unit_test_cases = {
15183 		TEST_CASE_NAMED_WITH_DATA(
15184 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
15185 			ut_setup_security, ut_teardown,
15186 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
15187 		TEST_CASE_NAMED_WITH_DATA(
15188 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
15189 			ut_setup_security, ut_teardown,
15190 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
15191 		TEST_CASE_NAMED_WITH_DATA(
15192 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
15193 			ut_setup_security, ut_teardown,
15194 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
15195 		TEST_CASE_NAMED_WITH_DATA(
15196 			"Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
15197 			ut_setup_security, ut_teardown,
15198 			test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
15199 		TEST_CASE_NAMED_WITH_DATA(
15200 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
15201 			ut_setup_security, ut_teardown,
15202 			test_ipsec_proto_known_vec,
15203 			&pkt_aes_128_cbc_md5),
15204 		TEST_CASE_NAMED_WITH_DATA(
15205 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15206 			ut_setup_security, ut_teardown,
15207 			test_ipsec_proto_known_vec,
15208 			&pkt_aes_128_cbc_hmac_sha256),
15209 		TEST_CASE_NAMED_WITH_DATA(
15210 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
15211 			ut_setup_security, ut_teardown,
15212 			test_ipsec_proto_known_vec,
15213 			&pkt_aes_128_cbc_hmac_sha384),
15214 		TEST_CASE_NAMED_WITH_DATA(
15215 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
15216 			ut_setup_security, ut_teardown,
15217 			test_ipsec_proto_known_vec,
15218 			&pkt_aes_128_cbc_hmac_sha512),
15219 		TEST_CASE_NAMED_WITH_DATA(
15220 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
15221 			ut_setup_security, ut_teardown,
15222 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
15223 		TEST_CASE_NAMED_WITH_DATA(
15224 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15225 			ut_setup_security, ut_teardown,
15226 			test_ipsec_proto_known_vec,
15227 			&pkt_aes_128_cbc_hmac_sha256_v6),
15228 		TEST_CASE_NAMED_WITH_DATA(
15229 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
15230 			ut_setup_security, ut_teardown,
15231 			test_ipsec_proto_known_vec,
15232 			&pkt_null_aes_xcbc),
15233 		TEST_CASE_NAMED_WITH_DATA(
15234 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
15235 			ut_setup_security, ut_teardown,
15236 			test_ipsec_proto_known_vec,
15237 			&pkt_des_cbc_hmac_sha256),
15238 		TEST_CASE_NAMED_WITH_DATA(
15239 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
15240 			ut_setup_security, ut_teardown,
15241 			test_ipsec_proto_known_vec,
15242 			&pkt_des_cbc_hmac_sha384),
15243 		TEST_CASE_NAMED_WITH_DATA(
15244 			"Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
15245 			ut_setup_security, ut_teardown,
15246 			test_ipsec_proto_known_vec,
15247 			&pkt_des_cbc_hmac_sha512),
15248 		TEST_CASE_NAMED_WITH_DATA(
15249 			"Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
15250 			ut_setup_security, ut_teardown,
15251 			test_ipsec_proto_known_vec,
15252 			&pkt_des_cbc_hmac_sha256_v6),
15253 		TEST_CASE_NAMED_WITH_DATA(
15254 			"Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
15255 			ut_setup_security, ut_teardown,
15256 			test_ipsec_proto_known_vec,
15257 			&pkt_ah_tunnel_sha256),
15258 		TEST_CASE_NAMED_WITH_DATA(
15259 			"Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
15260 			ut_setup_security, ut_teardown,
15261 			test_ipsec_proto_known_vec,
15262 			&pkt_ah_transport_sha256),
15263 		TEST_CASE_NAMED_WITH_DATA(
15264 			"Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
15265 			ut_setup_security, ut_teardown,
15266 			test_ipsec_proto_known_vec,
15267 			&pkt_ah_ipv4_aes_gmac_128),
15268 		TEST_CASE_NAMED_WITH_DATA(
15269 			"Outbound fragmented packet",
15270 			ut_setup_security, ut_teardown,
15271 			test_ipsec_proto_known_vec_fragmented,
15272 			&pkt_aes_128_gcm_frag),
15273 		TEST_CASE_NAMED_WITH_DATA(
15274 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
15275 			ut_setup_security, ut_teardown,
15276 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
15277 		TEST_CASE_NAMED_WITH_DATA(
15278 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
15279 			ut_setup_security, ut_teardown,
15280 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
15281 		TEST_CASE_NAMED_WITH_DATA(
15282 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
15283 			ut_setup_security, ut_teardown,
15284 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
15285 		TEST_CASE_NAMED_WITH_DATA(
15286 			"Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
15287 			ut_setup_security, ut_teardown,
15288 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
15289 		TEST_CASE_NAMED_WITH_DATA(
15290 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
15291 			ut_setup_security, ut_teardown,
15292 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
15293 		TEST_CASE_NAMED_WITH_DATA(
15294 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
15295 			ut_setup_security, ut_teardown,
15296 			test_ipsec_proto_known_vec_inb,
15297 			&pkt_aes_128_cbc_md5),
15298 		TEST_CASE_NAMED_WITH_DATA(
15299 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15300 			ut_setup_security, ut_teardown,
15301 			test_ipsec_proto_known_vec_inb,
15302 			&pkt_aes_128_cbc_hmac_sha256),
15303 		TEST_CASE_NAMED_WITH_DATA(
15304 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
15305 			ut_setup_security, ut_teardown,
15306 			test_ipsec_proto_known_vec_inb,
15307 			&pkt_aes_128_cbc_hmac_sha384),
15308 		TEST_CASE_NAMED_WITH_DATA(
15309 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
15310 			ut_setup_security, ut_teardown,
15311 			test_ipsec_proto_known_vec_inb,
15312 			&pkt_aes_128_cbc_hmac_sha512),
15313 		TEST_CASE_NAMED_WITH_DATA(
15314 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
15315 			ut_setup_security, ut_teardown,
15316 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
15317 		TEST_CASE_NAMED_WITH_DATA(
15318 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15319 			ut_setup_security, ut_teardown,
15320 			test_ipsec_proto_known_vec_inb,
15321 			&pkt_aes_128_cbc_hmac_sha256_v6),
15322 		TEST_CASE_NAMED_WITH_DATA(
15323 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
15324 			ut_setup_security, ut_teardown,
15325 			test_ipsec_proto_known_vec_inb,
15326 			&pkt_null_aes_xcbc),
15327 		TEST_CASE_NAMED_WITH_DATA(
15328 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
15329 			ut_setup_security, ut_teardown,
15330 			test_ipsec_proto_known_vec_inb,
15331 			&pkt_des_cbc_hmac_sha256),
15332 		TEST_CASE_NAMED_WITH_DATA(
15333 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
15334 			ut_setup_security, ut_teardown,
15335 			test_ipsec_proto_known_vec_inb,
15336 			&pkt_des_cbc_hmac_sha384),
15337 		TEST_CASE_NAMED_WITH_DATA(
15338 			"Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
15339 			ut_setup_security, ut_teardown,
15340 			test_ipsec_proto_known_vec_inb,
15341 			&pkt_des_cbc_hmac_sha512),
15342 		TEST_CASE_NAMED_WITH_DATA(
15343 			"Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
15344 			ut_setup_security, ut_teardown,
15345 			test_ipsec_proto_known_vec_inb,
15346 			&pkt_des_cbc_hmac_sha256_v6),
15347 		TEST_CASE_NAMED_WITH_DATA(
15348 			"Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
15349 			ut_setup_security, ut_teardown,
15350 			test_ipsec_proto_known_vec_inb,
15351 			&pkt_ah_tunnel_sha256),
15352 		TEST_CASE_NAMED_WITH_DATA(
15353 			"Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
15354 			ut_setup_security, ut_teardown,
15355 			test_ipsec_proto_known_vec_inb,
15356 			&pkt_ah_transport_sha256),
15357 		TEST_CASE_NAMED_WITH_DATA(
15358 			"Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
15359 			ut_setup_security, ut_teardown,
15360 			test_ipsec_proto_known_vec_inb,
15361 			&pkt_ah_ipv4_aes_gmac_128),
15362 		TEST_CASE_NAMED_ST(
15363 			"Combined test alg list",
15364 			ut_setup_security, ut_teardown,
15365 			test_ipsec_proto_display_list),
15366 		TEST_CASE_NAMED_ST(
15367 			"Combined test alg list (AH)",
15368 			ut_setup_security, ut_teardown,
15369 			test_ipsec_proto_ah_tunnel_ipv4),
15370 		TEST_CASE_NAMED_ST(
15371 			"IV generation",
15372 			ut_setup_security, ut_teardown,
15373 			test_ipsec_proto_iv_gen),
15374 		TEST_CASE_NAMED_ST(
15375 			"UDP encapsulation",
15376 			ut_setup_security, ut_teardown,
15377 			test_ipsec_proto_udp_encap),
15378 		TEST_CASE_NAMED_ST(
15379 			"UDP encapsulation with custom ports",
15380 			ut_setup_security, ut_teardown,
15381 			test_ipsec_proto_udp_encap_custom_ports),
15382 		TEST_CASE_NAMED_ST(
15383 			"UDP encapsulation ports verification test",
15384 			ut_setup_security, ut_teardown,
15385 			test_ipsec_proto_udp_ports_verify),
15386 		TEST_CASE_NAMED_ST(
15387 			"SA expiry packets soft",
15388 			ut_setup_security, ut_teardown,
15389 			test_ipsec_proto_sa_exp_pkts_soft),
15390 		TEST_CASE_NAMED_ST(
15391 			"SA expiry packets hard",
15392 			ut_setup_security, ut_teardown,
15393 			test_ipsec_proto_sa_exp_pkts_hard),
15394 		TEST_CASE_NAMED_ST(
15395 			"Negative test: ICV corruption",
15396 			ut_setup_security, ut_teardown,
15397 			test_ipsec_proto_err_icv_corrupt),
15398 		TEST_CASE_NAMED_ST(
15399 			"Tunnel dst addr verification",
15400 			ut_setup_security, ut_teardown,
15401 			test_ipsec_proto_tunnel_dst_addr_verify),
15402 		TEST_CASE_NAMED_ST(
15403 			"Tunnel src and dst addr verification",
15404 			ut_setup_security, ut_teardown,
15405 			test_ipsec_proto_tunnel_src_dst_addr_verify),
15406 		TEST_CASE_NAMED_ST(
15407 			"Inner IP checksum",
15408 			ut_setup_security, ut_teardown,
15409 			test_ipsec_proto_inner_ip_csum),
15410 		TEST_CASE_NAMED_ST(
15411 			"Inner L4 checksum",
15412 			ut_setup_security, ut_teardown,
15413 			test_ipsec_proto_inner_l4_csum),
15414 		TEST_CASE_NAMED_ST(
15415 			"Tunnel IPv4 in IPv4",
15416 			ut_setup_security, ut_teardown,
15417 			test_ipsec_proto_tunnel_v4_in_v4),
15418 		TEST_CASE_NAMED_ST(
15419 			"Tunnel IPv6 in IPv6",
15420 			ut_setup_security, ut_teardown,
15421 			test_ipsec_proto_tunnel_v6_in_v6),
15422 		TEST_CASE_NAMED_ST(
15423 			"Tunnel IPv4 in IPv6",
15424 			ut_setup_security, ut_teardown,
15425 			test_ipsec_proto_tunnel_v4_in_v6),
15426 		TEST_CASE_NAMED_ST(
15427 			"Tunnel IPv6 in IPv4",
15428 			ut_setup_security, ut_teardown,
15429 			test_ipsec_proto_tunnel_v6_in_v4),
15430 		TEST_CASE_NAMED_ST(
15431 			"Transport IPv4",
15432 			ut_setup_security, ut_teardown,
15433 			test_ipsec_proto_transport_v4),
15434 		TEST_CASE_NAMED_ST(
15435 			"AH transport IPv4",
15436 			ut_setup_security, ut_teardown,
15437 			test_ipsec_proto_ah_transport_ipv4),
15438 		TEST_CASE_NAMED_ST(
15439 			"Transport l4 checksum",
15440 			ut_setup_security, ut_teardown,
15441 			test_ipsec_proto_transport_l4_csum),
15442 		TEST_CASE_NAMED_ST(
15443 			"Statistics: success",
15444 			ut_setup_security, ut_teardown,
15445 			test_ipsec_proto_stats),
15446 		TEST_CASE_NAMED_ST(
15447 			"Fragmented packet",
15448 			ut_setup_security, ut_teardown,
15449 			test_ipsec_proto_pkt_fragment),
15450 		TEST_CASE_NAMED_ST(
15451 			"Tunnel header copy DF (inner 0)",
15452 			ut_setup_security, ut_teardown,
15453 			test_ipsec_proto_copy_df_inner_0),
15454 		TEST_CASE_NAMED_ST(
15455 			"Tunnel header copy DF (inner 1)",
15456 			ut_setup_security, ut_teardown,
15457 			test_ipsec_proto_copy_df_inner_1),
15458 		TEST_CASE_NAMED_ST(
15459 			"Tunnel header set DF 0 (inner 1)",
15460 			ut_setup_security, ut_teardown,
15461 			test_ipsec_proto_set_df_0_inner_1),
15462 		TEST_CASE_NAMED_ST(
15463 			"Tunnel header set DF 1 (inner 0)",
15464 			ut_setup_security, ut_teardown,
15465 			test_ipsec_proto_set_df_1_inner_0),
15466 		TEST_CASE_NAMED_ST(
15467 			"Tunnel header IPv4 copy DSCP (inner 0)",
15468 			ut_setup_security, ut_teardown,
15469 			test_ipsec_proto_ipv4_copy_dscp_inner_0),
15470 		TEST_CASE_NAMED_ST(
15471 			"Tunnel header IPv4 copy DSCP (inner 1)",
15472 			ut_setup_security, ut_teardown,
15473 			test_ipsec_proto_ipv4_copy_dscp_inner_1),
15474 		TEST_CASE_NAMED_ST(
15475 			"Tunnel header IPv4 set DSCP 0 (inner 1)",
15476 			ut_setup_security, ut_teardown,
15477 			test_ipsec_proto_ipv4_set_dscp_0_inner_1),
15478 		TEST_CASE_NAMED_ST(
15479 			"Tunnel header IPv4 set DSCP 1 (inner 0)",
15480 			ut_setup_security, ut_teardown,
15481 			test_ipsec_proto_ipv4_set_dscp_1_inner_0),
15482 		TEST_CASE_NAMED_ST(
15483 			"Tunnel header IPv6 copy DSCP (inner 0)",
15484 			ut_setup_security, ut_teardown,
15485 			test_ipsec_proto_ipv6_copy_dscp_inner_0),
15486 		TEST_CASE_NAMED_ST(
15487 			"Tunnel header IPv6 copy DSCP (inner 1)",
15488 			ut_setup_security, ut_teardown,
15489 			test_ipsec_proto_ipv6_copy_dscp_inner_1),
15490 		TEST_CASE_NAMED_ST(
15491 			"Tunnel header IPv6 set DSCP 0 (inner 1)",
15492 			ut_setup_security, ut_teardown,
15493 			test_ipsec_proto_ipv6_set_dscp_0_inner_1),
15494 		TEST_CASE_NAMED_ST(
15495 			"Tunnel header IPv6 set DSCP 1 (inner 0)",
15496 			ut_setup_security, ut_teardown,
15497 			test_ipsec_proto_ipv6_set_dscp_1_inner_0),
15498 		TEST_CASE_NAMED_WITH_DATA(
15499 			"Antireplay with window size 1024",
15500 			ut_setup_security, ut_teardown,
15501 			test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
15502 		TEST_CASE_NAMED_WITH_DATA(
15503 			"Antireplay with window size 2048",
15504 			ut_setup_security, ut_teardown,
15505 			test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
15506 		TEST_CASE_NAMED_WITH_DATA(
15507 			"Antireplay with window size 4096",
15508 			ut_setup_security, ut_teardown,
15509 			test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
15510 		TEST_CASE_NAMED_WITH_DATA(
15511 			"ESN and Antireplay with window size 1024",
15512 			ut_setup_security, ut_teardown,
15513 			test_ipsec_proto_pkt_esn_antireplay1024,
15514 			&pkt_aes_128_gcm),
15515 		TEST_CASE_NAMED_WITH_DATA(
15516 			"ESN and Antireplay with window size 2048",
15517 			ut_setup_security, ut_teardown,
15518 			test_ipsec_proto_pkt_esn_antireplay2048,
15519 			&pkt_aes_128_gcm),
15520 		TEST_CASE_NAMED_WITH_DATA(
15521 			"ESN and Antireplay with window size 4096",
15522 			ut_setup_security, ut_teardown,
15523 			test_ipsec_proto_pkt_esn_antireplay4096,
15524 			&pkt_aes_128_gcm),
15525 		TEST_CASE_NAMED_ST(
15526 			"Tunnel header IPv4 decrement inner TTL",
15527 			ut_setup_security, ut_teardown,
15528 			test_ipsec_proto_ipv4_ttl_decrement),
15529 		TEST_CASE_NAMED_ST(
15530 			"Tunnel header IPv6 decrement inner hop limit",
15531 			ut_setup_security, ut_teardown,
15532 			test_ipsec_proto_ipv6_hop_limit_decrement),
15533 		TEST_CASES_END() /**< NULL terminate unit test array */
15534 	}
15535 };
15536 
15537 static struct unit_test_suite pdcp_proto_testsuite  = {
15538 	.suite_name = "PDCP Proto Unit Test Suite",
15539 	.setup = pdcp_proto_testsuite_setup,
15540 	.unit_test_cases = {
15541 		TEST_CASE_ST(ut_setup_security, ut_teardown,
15542 			test_PDCP_PROTO_all),
15543 		TEST_CASES_END() /**< NULL terminate unit test array */
15544 	}
15545 };
15546 
15547 #define ADD_UPLINK_TESTCASE(data)						\
15548 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
15549 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
15550 
15551 #define ADD_DOWNLINK_TESTCASE(data)						\
15552 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
15553 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
15554 
15555 static struct unit_test_suite docsis_proto_testsuite  = {
15556 	.suite_name = "DOCSIS Proto Unit Test Suite",
15557 	.setup = docsis_proto_testsuite_setup,
15558 	.unit_test_cases = {
15559 		/* Uplink */
15560 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
15561 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
15562 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
15563 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
15564 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
15565 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
15566 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
15567 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
15568 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
15569 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
15570 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
15571 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
15572 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
15573 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
15574 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
15575 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
15576 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
15577 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
15578 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
15579 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
15580 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
15581 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
15582 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
15583 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
15584 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
15585 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
15586 		/* Downlink */
15587 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
15588 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
15589 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
15590 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
15591 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
15592 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
15593 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
15594 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
15595 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
15596 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
15597 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
15598 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
15599 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
15600 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
15601 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
15602 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
15603 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
15604 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
15605 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
15606 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
15607 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
15608 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
15609 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
15610 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
15611 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
15612 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
15613 		TEST_CASES_END() /**< NULL terminate unit test array */
15614 	}
15615 };
15616 #endif
15617 
15618 static struct unit_test_suite cryptodev_gen_testsuite  = {
15619 	.suite_name = "Crypto General Unit Test Suite",
15620 	.setup = crypto_gen_testsuite_setup,
15621 	.unit_test_cases = {
15622 		TEST_CASE_ST(ut_setup, ut_teardown,
15623 				test_device_configure_invalid_dev_id),
15624 		TEST_CASE_ST(ut_setup, ut_teardown,
15625 				test_queue_pair_descriptor_setup),
15626 		TEST_CASE_ST(ut_setup, ut_teardown,
15627 				test_device_configure_invalid_queue_pair_ids),
15628 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
15629 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
15630 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
15631 		TEST_CASES_END() /**< NULL terminate unit test array */
15632 	}
15633 };
15634 
15635 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
15636 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
15637 	.setup = negative_hmac_sha1_testsuite_setup,
15638 	.unit_test_cases = {
15639 		/** Negative tests */
15640 		TEST_CASE_ST(ut_setup, ut_teardown,
15641 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
15642 		TEST_CASE_ST(ut_setup, ut_teardown,
15643 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
15644 		TEST_CASE_ST(ut_setup, ut_teardown,
15645 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
15646 		TEST_CASE_ST(ut_setup, ut_teardown,
15647 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
15648 
15649 		TEST_CASES_END() /**< NULL terminate unit test array */
15650 	}
15651 };
15652 
15653 static struct unit_test_suite cryptodev_multi_session_testsuite = {
15654 	.suite_name = "Multi Session Unit Test Suite",
15655 	.setup = multi_session_testsuite_setup,
15656 	.unit_test_cases = {
15657 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
15658 		TEST_CASE_ST(ut_setup, ut_teardown,
15659 				test_multi_session_random_usage),
15660 
15661 		TEST_CASES_END() /**< NULL terminate unit test array */
15662 	}
15663 };
15664 
15665 static struct unit_test_suite cryptodev_null_testsuite  = {
15666 	.suite_name = "NULL Test Suite",
15667 	.setup = null_testsuite_setup,
15668 	.unit_test_cases = {
15669 		TEST_CASE_ST(ut_setup, ut_teardown,
15670 			test_null_invalid_operation),
15671 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
15672 		TEST_CASES_END()
15673 	}
15674 };
15675 
15676 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
15677 	.suite_name = "AES CCM Authenticated Test Suite",
15678 	.setup = aes_ccm_auth_testsuite_setup,
15679 	.unit_test_cases = {
15680 		/** AES CCM Authenticated Encryption 128 bits key*/
15681 		TEST_CASE_ST(ut_setup, ut_teardown,
15682 			test_AES_CCM_authenticated_encryption_test_case_128_1),
15683 		TEST_CASE_ST(ut_setup, ut_teardown,
15684 			test_AES_CCM_authenticated_encryption_test_case_128_2),
15685 		TEST_CASE_ST(ut_setup, ut_teardown,
15686 			test_AES_CCM_authenticated_encryption_test_case_128_3),
15687 
15688 		/** AES CCM Authenticated Decryption 128 bits key*/
15689 		TEST_CASE_ST(ut_setup, ut_teardown,
15690 			test_AES_CCM_authenticated_decryption_test_case_128_1),
15691 		TEST_CASE_ST(ut_setup, ut_teardown,
15692 			test_AES_CCM_authenticated_decryption_test_case_128_2),
15693 		TEST_CASE_ST(ut_setup, ut_teardown,
15694 			test_AES_CCM_authenticated_decryption_test_case_128_3),
15695 
15696 		/** AES CCM Authenticated Encryption 192 bits key */
15697 		TEST_CASE_ST(ut_setup, ut_teardown,
15698 			test_AES_CCM_authenticated_encryption_test_case_192_1),
15699 		TEST_CASE_ST(ut_setup, ut_teardown,
15700 			test_AES_CCM_authenticated_encryption_test_case_192_2),
15701 		TEST_CASE_ST(ut_setup, ut_teardown,
15702 			test_AES_CCM_authenticated_encryption_test_case_192_3),
15703 
15704 		/** AES CCM Authenticated Decryption 192 bits key*/
15705 		TEST_CASE_ST(ut_setup, ut_teardown,
15706 			test_AES_CCM_authenticated_decryption_test_case_192_1),
15707 		TEST_CASE_ST(ut_setup, ut_teardown,
15708 			test_AES_CCM_authenticated_decryption_test_case_192_2),
15709 		TEST_CASE_ST(ut_setup, ut_teardown,
15710 			test_AES_CCM_authenticated_decryption_test_case_192_3),
15711 
15712 		/** AES CCM Authenticated Encryption 256 bits key */
15713 		TEST_CASE_ST(ut_setup, ut_teardown,
15714 			test_AES_CCM_authenticated_encryption_test_case_256_1),
15715 		TEST_CASE_ST(ut_setup, ut_teardown,
15716 			test_AES_CCM_authenticated_encryption_test_case_256_2),
15717 		TEST_CASE_ST(ut_setup, ut_teardown,
15718 			test_AES_CCM_authenticated_encryption_test_case_256_3),
15719 
15720 		/** AES CCM Authenticated Decryption 256 bits key*/
15721 		TEST_CASE_ST(ut_setup, ut_teardown,
15722 			test_AES_CCM_authenticated_decryption_test_case_256_1),
15723 		TEST_CASE_ST(ut_setup, ut_teardown,
15724 			test_AES_CCM_authenticated_decryption_test_case_256_2),
15725 		TEST_CASE_ST(ut_setup, ut_teardown,
15726 			test_AES_CCM_authenticated_decryption_test_case_256_3),
15727 		TEST_CASES_END()
15728 	}
15729 };
15730 
15731 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
15732 	.suite_name = "AES GCM Authenticated Test Suite",
15733 	.setup = aes_gcm_auth_testsuite_setup,
15734 	.unit_test_cases = {
15735 		/** AES GCM Authenticated Encryption */
15736 		TEST_CASE_ST(ut_setup, ut_teardown,
15737 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
15738 		TEST_CASE_ST(ut_setup, ut_teardown,
15739 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
15740 		TEST_CASE_ST(ut_setup, ut_teardown,
15741 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
15742 		TEST_CASE_ST(ut_setup, ut_teardown,
15743 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
15744 		TEST_CASE_ST(ut_setup, ut_teardown,
15745 			test_AES_GCM_authenticated_encryption_test_case_1),
15746 		TEST_CASE_ST(ut_setup, ut_teardown,
15747 			test_AES_GCM_authenticated_encryption_test_case_2),
15748 		TEST_CASE_ST(ut_setup, ut_teardown,
15749 			test_AES_GCM_authenticated_encryption_test_case_3),
15750 		TEST_CASE_ST(ut_setup, ut_teardown,
15751 			test_AES_GCM_authenticated_encryption_test_case_4),
15752 		TEST_CASE_ST(ut_setup, ut_teardown,
15753 			test_AES_GCM_authenticated_encryption_test_case_5),
15754 		TEST_CASE_ST(ut_setup, ut_teardown,
15755 			test_AES_GCM_authenticated_encryption_test_case_6),
15756 		TEST_CASE_ST(ut_setup, ut_teardown,
15757 			test_AES_GCM_authenticated_encryption_test_case_7),
15758 		TEST_CASE_ST(ut_setup, ut_teardown,
15759 			test_AES_GCM_authenticated_encryption_test_case_8),
15760 		TEST_CASE_ST(ut_setup, ut_teardown,
15761 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
15762 
15763 		/** AES GCM Authenticated Decryption */
15764 		TEST_CASE_ST(ut_setup, ut_teardown,
15765 			test_AES_GCM_authenticated_decryption_test_case_1),
15766 		TEST_CASE_ST(ut_setup, ut_teardown,
15767 			test_AES_GCM_authenticated_decryption_test_case_2),
15768 		TEST_CASE_ST(ut_setup, ut_teardown,
15769 			test_AES_GCM_authenticated_decryption_test_case_3),
15770 		TEST_CASE_ST(ut_setup, ut_teardown,
15771 			test_AES_GCM_authenticated_decryption_test_case_4),
15772 		TEST_CASE_ST(ut_setup, ut_teardown,
15773 			test_AES_GCM_authenticated_decryption_test_case_5),
15774 		TEST_CASE_ST(ut_setup, ut_teardown,
15775 			test_AES_GCM_authenticated_decryption_test_case_6),
15776 		TEST_CASE_ST(ut_setup, ut_teardown,
15777 			test_AES_GCM_authenticated_decryption_test_case_7),
15778 		TEST_CASE_ST(ut_setup, ut_teardown,
15779 			test_AES_GCM_authenticated_decryption_test_case_8),
15780 		TEST_CASE_ST(ut_setup, ut_teardown,
15781 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
15782 
15783 		/** AES GCM Authenticated Encryption 192 bits key */
15784 		TEST_CASE_ST(ut_setup, ut_teardown,
15785 			test_AES_GCM_auth_encryption_test_case_192_1),
15786 		TEST_CASE_ST(ut_setup, ut_teardown,
15787 			test_AES_GCM_auth_encryption_test_case_192_2),
15788 		TEST_CASE_ST(ut_setup, ut_teardown,
15789 			test_AES_GCM_auth_encryption_test_case_192_3),
15790 		TEST_CASE_ST(ut_setup, ut_teardown,
15791 			test_AES_GCM_auth_encryption_test_case_192_4),
15792 		TEST_CASE_ST(ut_setup, ut_teardown,
15793 			test_AES_GCM_auth_encryption_test_case_192_5),
15794 		TEST_CASE_ST(ut_setup, ut_teardown,
15795 			test_AES_GCM_auth_encryption_test_case_192_6),
15796 		TEST_CASE_ST(ut_setup, ut_teardown,
15797 			test_AES_GCM_auth_encryption_test_case_192_7),
15798 
15799 		/** AES GCM Authenticated Decryption 192 bits key */
15800 		TEST_CASE_ST(ut_setup, ut_teardown,
15801 			test_AES_GCM_auth_decryption_test_case_192_1),
15802 		TEST_CASE_ST(ut_setup, ut_teardown,
15803 			test_AES_GCM_auth_decryption_test_case_192_2),
15804 		TEST_CASE_ST(ut_setup, ut_teardown,
15805 			test_AES_GCM_auth_decryption_test_case_192_3),
15806 		TEST_CASE_ST(ut_setup, ut_teardown,
15807 			test_AES_GCM_auth_decryption_test_case_192_4),
15808 		TEST_CASE_ST(ut_setup, ut_teardown,
15809 			test_AES_GCM_auth_decryption_test_case_192_5),
15810 		TEST_CASE_ST(ut_setup, ut_teardown,
15811 			test_AES_GCM_auth_decryption_test_case_192_6),
15812 		TEST_CASE_ST(ut_setup, ut_teardown,
15813 			test_AES_GCM_auth_decryption_test_case_192_7),
15814 
15815 		/** AES GCM Authenticated Encryption 256 bits key */
15816 		TEST_CASE_ST(ut_setup, ut_teardown,
15817 			test_AES_GCM_auth_encryption_test_case_256_1),
15818 		TEST_CASE_ST(ut_setup, ut_teardown,
15819 			test_AES_GCM_auth_encryption_test_case_256_2),
15820 		TEST_CASE_ST(ut_setup, ut_teardown,
15821 			test_AES_GCM_auth_encryption_test_case_256_3),
15822 		TEST_CASE_ST(ut_setup, ut_teardown,
15823 			test_AES_GCM_auth_encryption_test_case_256_4),
15824 		TEST_CASE_ST(ut_setup, ut_teardown,
15825 			test_AES_GCM_auth_encryption_test_case_256_5),
15826 		TEST_CASE_ST(ut_setup, ut_teardown,
15827 			test_AES_GCM_auth_encryption_test_case_256_6),
15828 		TEST_CASE_ST(ut_setup, ut_teardown,
15829 			test_AES_GCM_auth_encryption_test_case_256_7),
15830 
15831 		/** AES GCM Authenticated Decryption 256 bits key */
15832 		TEST_CASE_ST(ut_setup, ut_teardown,
15833 			test_AES_GCM_auth_decryption_test_case_256_1),
15834 		TEST_CASE_ST(ut_setup, ut_teardown,
15835 			test_AES_GCM_auth_decryption_test_case_256_2),
15836 		TEST_CASE_ST(ut_setup, ut_teardown,
15837 			test_AES_GCM_auth_decryption_test_case_256_3),
15838 		TEST_CASE_ST(ut_setup, ut_teardown,
15839 			test_AES_GCM_auth_decryption_test_case_256_4),
15840 		TEST_CASE_ST(ut_setup, ut_teardown,
15841 			test_AES_GCM_auth_decryption_test_case_256_5),
15842 		TEST_CASE_ST(ut_setup, ut_teardown,
15843 			test_AES_GCM_auth_decryption_test_case_256_6),
15844 		TEST_CASE_ST(ut_setup, ut_teardown,
15845 			test_AES_GCM_auth_decryption_test_case_256_7),
15846 
15847 		/** AES GCM Authenticated Encryption big aad size */
15848 		TEST_CASE_ST(ut_setup, ut_teardown,
15849 			test_AES_GCM_auth_encryption_test_case_aad_1),
15850 		TEST_CASE_ST(ut_setup, ut_teardown,
15851 			test_AES_GCM_auth_encryption_test_case_aad_2),
15852 
15853 		/** AES GCM Authenticated Decryption big aad size */
15854 		TEST_CASE_ST(ut_setup, ut_teardown,
15855 			test_AES_GCM_auth_decryption_test_case_aad_1),
15856 		TEST_CASE_ST(ut_setup, ut_teardown,
15857 			test_AES_GCM_auth_decryption_test_case_aad_2),
15858 
15859 		/** Out of place tests */
15860 		TEST_CASE_ST(ut_setup, ut_teardown,
15861 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
15862 		TEST_CASE_ST(ut_setup, ut_teardown,
15863 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
15864 
15865 		/** Session-less tests */
15866 		TEST_CASE_ST(ut_setup, ut_teardown,
15867 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
15868 		TEST_CASE_ST(ut_setup, ut_teardown,
15869 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
15870 
15871 		TEST_CASES_END()
15872 	}
15873 };
15874 
15875 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
15876 	.suite_name = "AES GMAC Authentication Test Suite",
15877 	.setup = aes_gmac_auth_testsuite_setup,
15878 	.unit_test_cases = {
15879 		TEST_CASE_ST(ut_setup, ut_teardown,
15880 			test_AES_GMAC_authentication_test_case_1),
15881 		TEST_CASE_ST(ut_setup, ut_teardown,
15882 			test_AES_GMAC_authentication_verify_test_case_1),
15883 		TEST_CASE_ST(ut_setup, ut_teardown,
15884 			test_AES_GMAC_authentication_test_case_2),
15885 		TEST_CASE_ST(ut_setup, ut_teardown,
15886 			test_AES_GMAC_authentication_verify_test_case_2),
15887 		TEST_CASE_ST(ut_setup, ut_teardown,
15888 			test_AES_GMAC_authentication_test_case_3),
15889 		TEST_CASE_ST(ut_setup, ut_teardown,
15890 			test_AES_GMAC_authentication_verify_test_case_3),
15891 		TEST_CASE_ST(ut_setup, ut_teardown,
15892 			test_AES_GMAC_authentication_test_case_4),
15893 		TEST_CASE_ST(ut_setup, ut_teardown,
15894 			test_AES_GMAC_authentication_verify_test_case_4),
15895 		TEST_CASE_ST(ut_setup, ut_teardown,
15896 			test_AES_GMAC_authentication_SGL_40B),
15897 		TEST_CASE_ST(ut_setup, ut_teardown,
15898 			test_AES_GMAC_authentication_SGL_80B),
15899 		TEST_CASE_ST(ut_setup, ut_teardown,
15900 			test_AES_GMAC_authentication_SGL_2048B),
15901 		TEST_CASE_ST(ut_setup, ut_teardown,
15902 			test_AES_GMAC_authentication_SGL_2047B),
15903 
15904 		TEST_CASES_END()
15905 	}
15906 };
15907 
15908 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
15909 	.suite_name = "Chacha20-Poly1305 Test Suite",
15910 	.setup = chacha20_poly1305_testsuite_setup,
15911 	.unit_test_cases = {
15912 		TEST_CASE_ST(ut_setup, ut_teardown,
15913 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
15914 		TEST_CASE_ST(ut_setup, ut_teardown,
15915 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
15916 		TEST_CASE_ST(ut_setup, ut_teardown,
15917 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
15918 		TEST_CASES_END()
15919 	}
15920 };
15921 
15922 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
15923 	.suite_name = "SNOW 3G Test Suite",
15924 	.setup = snow3g_testsuite_setup,
15925 	.unit_test_cases = {
15926 		/** SNOW 3G encrypt only (UEA2) */
15927 		TEST_CASE_ST(ut_setup, ut_teardown,
15928 			test_snow3g_encryption_test_case_1),
15929 		TEST_CASE_ST(ut_setup, ut_teardown,
15930 			test_snow3g_encryption_test_case_2),
15931 		TEST_CASE_ST(ut_setup, ut_teardown,
15932 			test_snow3g_encryption_test_case_3),
15933 		TEST_CASE_ST(ut_setup, ut_teardown,
15934 			test_snow3g_encryption_test_case_4),
15935 		TEST_CASE_ST(ut_setup, ut_teardown,
15936 			test_snow3g_encryption_test_case_5),
15937 
15938 		TEST_CASE_ST(ut_setup, ut_teardown,
15939 			test_snow3g_encryption_test_case_1_oop),
15940 		TEST_CASE_ST(ut_setup, ut_teardown,
15941 			test_snow3g_encryption_test_case_1_oop_sgl),
15942 		TEST_CASE_ST(ut_setup, ut_teardown,
15943 			test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
15944 		TEST_CASE_ST(ut_setup, ut_teardown,
15945 			test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
15946 		TEST_CASE_ST(ut_setup, ut_teardown,
15947 			test_snow3g_encryption_test_case_1_offset_oop),
15948 		TEST_CASE_ST(ut_setup, ut_teardown,
15949 			test_snow3g_decryption_test_case_1_oop),
15950 
15951 		/** SNOW 3G generate auth, then encrypt (UEA2) */
15952 		TEST_CASE_ST(ut_setup, ut_teardown,
15953 			test_snow3g_auth_cipher_test_case_1),
15954 		TEST_CASE_ST(ut_setup, ut_teardown,
15955 			test_snow3g_auth_cipher_test_case_2),
15956 		TEST_CASE_ST(ut_setup, ut_teardown,
15957 			test_snow3g_auth_cipher_test_case_2_oop),
15958 		TEST_CASE_ST(ut_setup, ut_teardown,
15959 			test_snow3g_auth_cipher_part_digest_enc),
15960 		TEST_CASE_ST(ut_setup, ut_teardown,
15961 			test_snow3g_auth_cipher_part_digest_enc_oop),
15962 		TEST_CASE_ST(ut_setup, ut_teardown,
15963 			test_snow3g_auth_cipher_test_case_3_sgl),
15964 		TEST_CASE_ST(ut_setup, ut_teardown,
15965 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
15966 		TEST_CASE_ST(ut_setup, ut_teardown,
15967 			test_snow3g_auth_cipher_part_digest_enc_sgl),
15968 		TEST_CASE_ST(ut_setup, ut_teardown,
15969 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
15970 		TEST_CASE_ST(ut_setup, ut_teardown,
15971 			test_snow3g_auth_cipher_total_digest_enc_1),
15972 		TEST_CASE_ST(ut_setup, ut_teardown,
15973 			test_snow3g_auth_cipher_total_digest_enc_1_oop),
15974 		TEST_CASE_ST(ut_setup, ut_teardown,
15975 			test_snow3g_auth_cipher_total_digest_enc_1_sgl),
15976 		TEST_CASE_ST(ut_setup, ut_teardown,
15977 			test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
15978 
15979 		/** SNOW 3G decrypt (UEA2), then verify auth */
15980 		TEST_CASE_ST(ut_setup, ut_teardown,
15981 			test_snow3g_auth_cipher_verify_test_case_1),
15982 		TEST_CASE_ST(ut_setup, ut_teardown,
15983 			test_snow3g_auth_cipher_verify_test_case_2),
15984 		TEST_CASE_ST(ut_setup, ut_teardown,
15985 			test_snow3g_auth_cipher_verify_test_case_2_oop),
15986 		TEST_CASE_ST(ut_setup, ut_teardown,
15987 			test_snow3g_auth_cipher_verify_part_digest_enc),
15988 		TEST_CASE_ST(ut_setup, ut_teardown,
15989 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
15990 		TEST_CASE_ST(ut_setup, ut_teardown,
15991 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
15992 		TEST_CASE_ST(ut_setup, ut_teardown,
15993 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
15994 		TEST_CASE_ST(ut_setup, ut_teardown,
15995 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
15996 		TEST_CASE_ST(ut_setup, ut_teardown,
15997 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
15998 		TEST_CASE_ST(ut_setup, ut_teardown,
15999 			test_snow3g_auth_cipher_verify_total_digest_enc_1),
16000 		TEST_CASE_ST(ut_setup, ut_teardown,
16001 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
16002 		TEST_CASE_ST(ut_setup, ut_teardown,
16003 			test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
16004 		TEST_CASE_ST(ut_setup, ut_teardown,
16005 			test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
16006 
16007 		/** SNOW 3G decrypt only (UEA2) */
16008 		TEST_CASE_ST(ut_setup, ut_teardown,
16009 			test_snow3g_decryption_test_case_1),
16010 		TEST_CASE_ST(ut_setup, ut_teardown,
16011 			test_snow3g_decryption_test_case_2),
16012 		TEST_CASE_ST(ut_setup, ut_teardown,
16013 			test_snow3g_decryption_test_case_3),
16014 		TEST_CASE_ST(ut_setup, ut_teardown,
16015 			test_snow3g_decryption_test_case_4),
16016 		TEST_CASE_ST(ut_setup, ut_teardown,
16017 			test_snow3g_decryption_test_case_5),
16018 		TEST_CASE_ST(ut_setup, ut_teardown,
16019 			test_snow3g_decryption_with_digest_test_case_1),
16020 		TEST_CASE_ST(ut_setup, ut_teardown,
16021 			test_snow3g_hash_generate_test_case_1),
16022 		TEST_CASE_ST(ut_setup, ut_teardown,
16023 			test_snow3g_hash_generate_test_case_2),
16024 		TEST_CASE_ST(ut_setup, ut_teardown,
16025 			test_snow3g_hash_generate_test_case_3),
16026 
16027 		/* Tests with buffers which length is not byte-aligned */
16028 		TEST_CASE_ST(ut_setup, ut_teardown,
16029 			test_snow3g_hash_generate_test_case_4),
16030 		TEST_CASE_ST(ut_setup, ut_teardown,
16031 			test_snow3g_hash_generate_test_case_5),
16032 		TEST_CASE_ST(ut_setup, ut_teardown,
16033 			test_snow3g_hash_generate_test_case_6),
16034 		TEST_CASE_ST(ut_setup, ut_teardown,
16035 			test_snow3g_hash_verify_test_case_1),
16036 		TEST_CASE_ST(ut_setup, ut_teardown,
16037 			test_snow3g_hash_verify_test_case_2),
16038 		TEST_CASE_ST(ut_setup, ut_teardown,
16039 			test_snow3g_hash_verify_test_case_3),
16040 
16041 		/* Tests with buffers which length is not byte-aligned */
16042 		TEST_CASE_ST(ut_setup, ut_teardown,
16043 			test_snow3g_hash_verify_test_case_4),
16044 		TEST_CASE_ST(ut_setup, ut_teardown,
16045 			test_snow3g_hash_verify_test_case_5),
16046 		TEST_CASE_ST(ut_setup, ut_teardown,
16047 			test_snow3g_hash_verify_test_case_6),
16048 		TEST_CASE_ST(ut_setup, ut_teardown,
16049 			test_snow3g_cipher_auth_test_case_1),
16050 		TEST_CASE_ST(ut_setup, ut_teardown,
16051 			test_snow3g_auth_cipher_with_digest_test_case_1),
16052 		TEST_CASES_END()
16053 	}
16054 };
16055 
16056 static struct unit_test_suite cryptodev_zuc_testsuite  = {
16057 	.suite_name = "ZUC Test Suite",
16058 	.setup = zuc_testsuite_setup,
16059 	.unit_test_cases = {
16060 		/** ZUC encrypt only (EEA3) */
16061 		TEST_CASE_ST(ut_setup, ut_teardown,
16062 			test_zuc_encryption_test_case_1),
16063 		TEST_CASE_ST(ut_setup, ut_teardown,
16064 			test_zuc_encryption_test_case_2),
16065 		TEST_CASE_ST(ut_setup, ut_teardown,
16066 			test_zuc_encryption_test_case_3),
16067 		TEST_CASE_ST(ut_setup, ut_teardown,
16068 			test_zuc_encryption_test_case_4),
16069 		TEST_CASE_ST(ut_setup, ut_teardown,
16070 			test_zuc_encryption_test_case_5),
16071 		TEST_CASE_ST(ut_setup, ut_teardown,
16072 			test_zuc_encryption_test_case_6_sgl),
16073 
16074 		/** ZUC authenticate (EIA3) */
16075 		TEST_CASE_ST(ut_setup, ut_teardown,
16076 			test_zuc_hash_generate_test_case_1),
16077 		TEST_CASE_ST(ut_setup, ut_teardown,
16078 			test_zuc_hash_generate_test_case_2),
16079 		TEST_CASE_ST(ut_setup, ut_teardown,
16080 			test_zuc_hash_generate_test_case_3),
16081 		TEST_CASE_ST(ut_setup, ut_teardown,
16082 			test_zuc_hash_generate_test_case_4),
16083 		TEST_CASE_ST(ut_setup, ut_teardown,
16084 			test_zuc_hash_generate_test_case_5),
16085 		TEST_CASE_ST(ut_setup, ut_teardown,
16086 			test_zuc_hash_generate_test_case_6),
16087 		TEST_CASE_ST(ut_setup, ut_teardown,
16088 			test_zuc_hash_generate_test_case_7),
16089 		TEST_CASE_ST(ut_setup, ut_teardown,
16090 			test_zuc_hash_generate_test_case_8),
16091 		TEST_CASE_ST(ut_setup, ut_teardown,
16092 			test_zuc_hash_generate_test_case_9),
16093 		TEST_CASE_ST(ut_setup, ut_teardown,
16094 			test_zuc_hash_generate_test_case_10),
16095 		TEST_CASE_ST(ut_setup, ut_teardown,
16096 			test_zuc_hash_generate_test_case_11),
16097 
16098 
16099 		/** ZUC alg-chain (EEA3/EIA3) */
16100 		TEST_CASE_ST(ut_setup, ut_teardown,
16101 			test_zuc_cipher_auth_test_case_1),
16102 		TEST_CASE_ST(ut_setup, ut_teardown,
16103 			test_zuc_cipher_auth_test_case_2),
16104 
16105 		/** ZUC generate auth, then encrypt (EEA3) */
16106 		TEST_CASE_ST(ut_setup, ut_teardown,
16107 			test_zuc_auth_cipher_test_case_1),
16108 		TEST_CASE_ST(ut_setup, ut_teardown,
16109 			test_zuc_auth_cipher_test_case_1_oop),
16110 		TEST_CASE_ST(ut_setup, ut_teardown,
16111 			test_zuc_auth_cipher_test_case_1_sgl),
16112 		TEST_CASE_ST(ut_setup, ut_teardown,
16113 			test_zuc_auth_cipher_test_case_1_oop_sgl),
16114 		TEST_CASE_ST(ut_setup, ut_teardown,
16115 			test_zuc_auth_cipher_test_case_2),
16116 		TEST_CASE_ST(ut_setup, ut_teardown,
16117 			test_zuc_auth_cipher_test_case_2_oop),
16118 
16119 		/** ZUC decrypt (EEA3), then verify auth */
16120 		TEST_CASE_ST(ut_setup, ut_teardown,
16121 			test_zuc_auth_cipher_verify_test_case_1),
16122 		TEST_CASE_ST(ut_setup, ut_teardown,
16123 			test_zuc_auth_cipher_verify_test_case_1_oop),
16124 		TEST_CASE_ST(ut_setup, ut_teardown,
16125 			test_zuc_auth_cipher_verify_test_case_1_sgl),
16126 		TEST_CASE_ST(ut_setup, ut_teardown,
16127 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
16128 		TEST_CASE_ST(ut_setup, ut_teardown,
16129 			test_zuc_auth_cipher_verify_test_case_2),
16130 		TEST_CASE_ST(ut_setup, ut_teardown,
16131 			test_zuc_auth_cipher_verify_test_case_2_oop),
16132 
16133 		/** ZUC-256 encrypt only **/
16134 		TEST_CASE_ST(ut_setup, ut_teardown,
16135 			test_zuc256_encryption_test_case_1),
16136 		TEST_CASE_ST(ut_setup, ut_teardown,
16137 			test_zuc256_encryption_test_case_2),
16138 
16139 		/** ZUC-256 authentication only **/
16140 		TEST_CASE_ST(ut_setup, ut_teardown,
16141 			test_zuc256_authentication_test_case_1),
16142 		TEST_CASE_ST(ut_setup, ut_teardown,
16143 			test_zuc256_authentication_test_case_2),
16144 
16145 		TEST_CASES_END()
16146 	}
16147 };
16148 
16149 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
16150 	.suite_name = "HMAC_MD5 Authentication Test Suite",
16151 	.setup = hmac_md5_auth_testsuite_setup,
16152 	.unit_test_cases = {
16153 		TEST_CASE_ST(ut_setup, ut_teardown,
16154 			test_MD5_HMAC_generate_case_1),
16155 		TEST_CASE_ST(ut_setup, ut_teardown,
16156 			test_MD5_HMAC_verify_case_1),
16157 		TEST_CASE_ST(ut_setup, ut_teardown,
16158 			test_MD5_HMAC_generate_case_2),
16159 		TEST_CASE_ST(ut_setup, ut_teardown,
16160 			test_MD5_HMAC_verify_case_2),
16161 		TEST_CASES_END()
16162 	}
16163 };
16164 
16165 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
16166 	.suite_name = "Kasumi Test Suite",
16167 	.setup = kasumi_testsuite_setup,
16168 	.unit_test_cases = {
16169 		/** KASUMI hash only (UIA1) */
16170 		TEST_CASE_ST(ut_setup, ut_teardown,
16171 			test_kasumi_hash_generate_test_case_1),
16172 		TEST_CASE_ST(ut_setup, ut_teardown,
16173 			test_kasumi_hash_generate_test_case_2),
16174 		TEST_CASE_ST(ut_setup, ut_teardown,
16175 			test_kasumi_hash_generate_test_case_3),
16176 		TEST_CASE_ST(ut_setup, ut_teardown,
16177 			test_kasumi_hash_generate_test_case_4),
16178 		TEST_CASE_ST(ut_setup, ut_teardown,
16179 			test_kasumi_hash_generate_test_case_5),
16180 		TEST_CASE_ST(ut_setup, ut_teardown,
16181 			test_kasumi_hash_generate_test_case_6),
16182 
16183 		TEST_CASE_ST(ut_setup, ut_teardown,
16184 			test_kasumi_hash_verify_test_case_1),
16185 		TEST_CASE_ST(ut_setup, ut_teardown,
16186 			test_kasumi_hash_verify_test_case_2),
16187 		TEST_CASE_ST(ut_setup, ut_teardown,
16188 			test_kasumi_hash_verify_test_case_3),
16189 		TEST_CASE_ST(ut_setup, ut_teardown,
16190 			test_kasumi_hash_verify_test_case_4),
16191 		TEST_CASE_ST(ut_setup, ut_teardown,
16192 			test_kasumi_hash_verify_test_case_5),
16193 
16194 		/** KASUMI encrypt only (UEA1) */
16195 		TEST_CASE_ST(ut_setup, ut_teardown,
16196 			test_kasumi_encryption_test_case_1),
16197 		TEST_CASE_ST(ut_setup, ut_teardown,
16198 			test_kasumi_encryption_test_case_1_sgl),
16199 		TEST_CASE_ST(ut_setup, ut_teardown,
16200 			test_kasumi_encryption_test_case_1_oop),
16201 		TEST_CASE_ST(ut_setup, ut_teardown,
16202 			test_kasumi_encryption_test_case_1_oop_sgl),
16203 		TEST_CASE_ST(ut_setup, ut_teardown,
16204 			test_kasumi_encryption_test_case_2),
16205 		TEST_CASE_ST(ut_setup, ut_teardown,
16206 			test_kasumi_encryption_test_case_3),
16207 		TEST_CASE_ST(ut_setup, ut_teardown,
16208 			test_kasumi_encryption_test_case_4),
16209 		TEST_CASE_ST(ut_setup, ut_teardown,
16210 			test_kasumi_encryption_test_case_5),
16211 
16212 		/** KASUMI decrypt only (UEA1) */
16213 		TEST_CASE_ST(ut_setup, ut_teardown,
16214 			test_kasumi_decryption_test_case_1),
16215 		TEST_CASE_ST(ut_setup, ut_teardown,
16216 			test_kasumi_decryption_test_case_2),
16217 		TEST_CASE_ST(ut_setup, ut_teardown,
16218 			test_kasumi_decryption_test_case_3),
16219 		TEST_CASE_ST(ut_setup, ut_teardown,
16220 			test_kasumi_decryption_test_case_4),
16221 		TEST_CASE_ST(ut_setup, ut_teardown,
16222 			test_kasumi_decryption_test_case_5),
16223 		TEST_CASE_ST(ut_setup, ut_teardown,
16224 			test_kasumi_decryption_test_case_1_oop),
16225 		TEST_CASE_ST(ut_setup, ut_teardown,
16226 			test_kasumi_cipher_auth_test_case_1),
16227 
16228 		/** KASUMI generate auth, then encrypt (F8) */
16229 		TEST_CASE_ST(ut_setup, ut_teardown,
16230 			test_kasumi_auth_cipher_test_case_1),
16231 		TEST_CASE_ST(ut_setup, ut_teardown,
16232 			test_kasumi_auth_cipher_test_case_2),
16233 		TEST_CASE_ST(ut_setup, ut_teardown,
16234 			test_kasumi_auth_cipher_test_case_2_oop),
16235 		TEST_CASE_ST(ut_setup, ut_teardown,
16236 			test_kasumi_auth_cipher_test_case_2_sgl),
16237 		TEST_CASE_ST(ut_setup, ut_teardown,
16238 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
16239 
16240 		/** KASUMI decrypt (F8), then verify auth */
16241 		TEST_CASE_ST(ut_setup, ut_teardown,
16242 			test_kasumi_auth_cipher_verify_test_case_1),
16243 		TEST_CASE_ST(ut_setup, ut_teardown,
16244 			test_kasumi_auth_cipher_verify_test_case_2),
16245 		TEST_CASE_ST(ut_setup, ut_teardown,
16246 			test_kasumi_auth_cipher_verify_test_case_2_oop),
16247 		TEST_CASE_ST(ut_setup, ut_teardown,
16248 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
16249 		TEST_CASE_ST(ut_setup, ut_teardown,
16250 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
16251 
16252 		TEST_CASES_END()
16253 	}
16254 };
16255 
16256 static struct unit_test_suite cryptodev_esn_testsuite  = {
16257 	.suite_name = "ESN Test Suite",
16258 	.setup = esn_testsuite_setup,
16259 	.unit_test_cases = {
16260 		TEST_CASE_ST(ut_setup, ut_teardown,
16261 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
16262 		TEST_CASE_ST(ut_setup, ut_teardown,
16263 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
16264 		TEST_CASES_END()
16265 	}
16266 };
16267 
16268 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
16269 	.suite_name = "Negative AES GCM Test Suite",
16270 	.setup = negative_aes_gcm_testsuite_setup,
16271 	.unit_test_cases = {
16272 		TEST_CASE_ST(ut_setup, ut_teardown,
16273 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
16274 		TEST_CASE_ST(ut_setup, ut_teardown,
16275 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
16276 		TEST_CASE_ST(ut_setup, ut_teardown,
16277 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
16278 		TEST_CASE_ST(ut_setup, ut_teardown,
16279 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
16280 		TEST_CASE_ST(ut_setup, ut_teardown,
16281 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
16282 		TEST_CASE_ST(ut_setup, ut_teardown,
16283 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
16284 		TEST_CASE_ST(ut_setup, ut_teardown,
16285 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
16286 		TEST_CASE_ST(ut_setup, ut_teardown,
16287 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
16288 		TEST_CASE_ST(ut_setup, ut_teardown,
16289 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
16290 		TEST_CASE_ST(ut_setup, ut_teardown,
16291 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
16292 		TEST_CASE_ST(ut_setup, ut_teardown,
16293 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
16294 		TEST_CASE_ST(ut_setup, ut_teardown,
16295 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
16296 
16297 		TEST_CASES_END()
16298 	}
16299 };
16300 
16301 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
16302 	.suite_name = "Negative AES GMAC Test Suite",
16303 	.setup = negative_aes_gmac_testsuite_setup,
16304 	.unit_test_cases = {
16305 		TEST_CASE_ST(ut_setup, ut_teardown,
16306 			authentication_verify_AES128_GMAC_fail_data_corrupt),
16307 		TEST_CASE_ST(ut_setup, ut_teardown,
16308 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
16309 
16310 		TEST_CASES_END()
16311 	}
16312 };
16313 
16314 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
16315 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
16316 	.setup = mixed_cipher_hash_testsuite_setup,
16317 	.unit_test_cases = {
16318 		/** AUTH AES CMAC + CIPHER AES CTR */
16319 		TEST_CASE_ST(ut_setup, ut_teardown,
16320 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
16321 		TEST_CASE_ST(ut_setup, ut_teardown,
16322 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
16323 		TEST_CASE_ST(ut_setup, ut_teardown,
16324 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
16325 		TEST_CASE_ST(ut_setup, ut_teardown,
16326 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
16327 		TEST_CASE_ST(ut_setup, ut_teardown,
16328 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
16329 		TEST_CASE_ST(ut_setup, ut_teardown,
16330 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
16331 		TEST_CASE_ST(ut_setup, ut_teardown,
16332 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
16333 		TEST_CASE_ST(ut_setup, ut_teardown,
16334 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
16335 		TEST_CASE_ST(ut_setup, ut_teardown,
16336 			test_aes_cmac_aes_ctr_digest_enc_test_case_2),
16337 		TEST_CASE_ST(ut_setup, ut_teardown,
16338 			test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
16339 		TEST_CASE_ST(ut_setup, ut_teardown,
16340 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
16341 		TEST_CASE_ST(ut_setup, ut_teardown,
16342 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
16343 
16344 		/** AUTH ZUC + CIPHER SNOW3G */
16345 		TEST_CASE_ST(ut_setup, ut_teardown,
16346 			test_auth_zuc_cipher_snow_test_case_1),
16347 		TEST_CASE_ST(ut_setup, ut_teardown,
16348 			test_verify_auth_zuc_cipher_snow_test_case_1),
16349 		TEST_CASE_ST(ut_setup, ut_teardown,
16350 			test_auth_zuc_cipher_snow_test_case_1_inplace),
16351 		TEST_CASE_ST(ut_setup, ut_teardown,
16352 			test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
16353 		/** AUTH AES CMAC + CIPHER SNOW3G */
16354 		TEST_CASE_ST(ut_setup, ut_teardown,
16355 			test_auth_aes_cmac_cipher_snow_test_case_1),
16356 		TEST_CASE_ST(ut_setup, ut_teardown,
16357 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
16358 		TEST_CASE_ST(ut_setup, ut_teardown,
16359 			test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
16360 		TEST_CASE_ST(ut_setup, ut_teardown,
16361 			test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
16362 		/** AUTH ZUC + CIPHER AES CTR */
16363 		TEST_CASE_ST(ut_setup, ut_teardown,
16364 			test_auth_zuc_cipher_aes_ctr_test_case_1),
16365 		TEST_CASE_ST(ut_setup, ut_teardown,
16366 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
16367 		TEST_CASE_ST(ut_setup, ut_teardown,
16368 			test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
16369 		TEST_CASE_ST(ut_setup, ut_teardown,
16370 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
16371 		/** AUTH SNOW3G + CIPHER AES CTR */
16372 		TEST_CASE_ST(ut_setup, ut_teardown,
16373 			test_auth_snow_cipher_aes_ctr_test_case_1),
16374 		TEST_CASE_ST(ut_setup, ut_teardown,
16375 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
16376 		TEST_CASE_ST(ut_setup, ut_teardown,
16377 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
16378 		TEST_CASE_ST(ut_setup, ut_teardown,
16379 			test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
16380 		TEST_CASE_ST(ut_setup, ut_teardown,
16381 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
16382 		TEST_CASE_ST(ut_setup, ut_teardown,
16383 			test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
16384 		/** AUTH SNOW3G + CIPHER ZUC */
16385 		TEST_CASE_ST(ut_setup, ut_teardown,
16386 			test_auth_snow_cipher_zuc_test_case_1),
16387 		TEST_CASE_ST(ut_setup, ut_teardown,
16388 			test_verify_auth_snow_cipher_zuc_test_case_1),
16389 		TEST_CASE_ST(ut_setup, ut_teardown,
16390 			test_auth_snow_cipher_zuc_test_case_1_inplace),
16391 		TEST_CASE_ST(ut_setup, ut_teardown,
16392 			test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
16393 		/** AUTH AES CMAC + CIPHER ZUC */
16394 		TEST_CASE_ST(ut_setup, ut_teardown,
16395 			test_auth_aes_cmac_cipher_zuc_test_case_1),
16396 		TEST_CASE_ST(ut_setup, ut_teardown,
16397 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
16398 		TEST_CASE_ST(ut_setup, ut_teardown,
16399 			test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
16400 		TEST_CASE_ST(ut_setup, ut_teardown,
16401 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
16402 
16403 		/** AUTH NULL + CIPHER SNOW3G */
16404 		TEST_CASE_ST(ut_setup, ut_teardown,
16405 			test_auth_null_cipher_snow_test_case_1),
16406 		TEST_CASE_ST(ut_setup, ut_teardown,
16407 			test_verify_auth_null_cipher_snow_test_case_1),
16408 		/** AUTH NULL + CIPHER ZUC */
16409 		TEST_CASE_ST(ut_setup, ut_teardown,
16410 			test_auth_null_cipher_zuc_test_case_1),
16411 		TEST_CASE_ST(ut_setup, ut_teardown,
16412 			test_verify_auth_null_cipher_zuc_test_case_1),
16413 		/** AUTH SNOW3G + CIPHER NULL */
16414 		TEST_CASE_ST(ut_setup, ut_teardown,
16415 			test_auth_snow_cipher_null_test_case_1),
16416 		TEST_CASE_ST(ut_setup, ut_teardown,
16417 			test_verify_auth_snow_cipher_null_test_case_1),
16418 		/** AUTH ZUC + CIPHER NULL */
16419 		TEST_CASE_ST(ut_setup, ut_teardown,
16420 			test_auth_zuc_cipher_null_test_case_1),
16421 		TEST_CASE_ST(ut_setup, ut_teardown,
16422 			test_verify_auth_zuc_cipher_null_test_case_1),
16423 		/** AUTH NULL + CIPHER AES CTR */
16424 		TEST_CASE_ST(ut_setup, ut_teardown,
16425 			test_auth_null_cipher_aes_ctr_test_case_1),
16426 		TEST_CASE_ST(ut_setup, ut_teardown,
16427 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
16428 		/** AUTH AES CMAC + CIPHER NULL */
16429 		TEST_CASE_ST(ut_setup, ut_teardown,
16430 			test_auth_aes_cmac_cipher_null_test_case_1),
16431 		TEST_CASE_ST(ut_setup, ut_teardown,
16432 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
16433 		TEST_CASES_END()
16434 	}
16435 };
16436 
16437 static int
16438 run_cryptodev_testsuite(const char *pmd_name)
16439 {
16440 	uint8_t ret, j, i = 0, blk_start_idx = 0;
16441 	const enum blockcipher_test_type blk_suites[] = {
16442 		BLKCIPHER_AES_CHAIN_TYPE,
16443 		BLKCIPHER_AES_CIPHERONLY_TYPE,
16444 		BLKCIPHER_AES_DOCSIS_TYPE,
16445 		BLKCIPHER_3DES_CHAIN_TYPE,
16446 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
16447 		BLKCIPHER_DES_CIPHERONLY_TYPE,
16448 		BLKCIPHER_DES_DOCSIS_TYPE,
16449 		BLKCIPHER_AUTHONLY_TYPE};
16450 	struct unit_test_suite *static_suites[] = {
16451 		&cryptodev_multi_session_testsuite,
16452 		&cryptodev_null_testsuite,
16453 		&cryptodev_aes_ccm_auth_testsuite,
16454 		&cryptodev_aes_gcm_auth_testsuite,
16455 		&cryptodev_aes_gmac_auth_testsuite,
16456 		&cryptodev_snow3g_testsuite,
16457 		&cryptodev_chacha20_poly1305_testsuite,
16458 		&cryptodev_zuc_testsuite,
16459 		&cryptodev_hmac_md5_auth_testsuite,
16460 		&cryptodev_kasumi_testsuite,
16461 		&cryptodev_esn_testsuite,
16462 		&cryptodev_negative_aes_gcm_testsuite,
16463 		&cryptodev_negative_aes_gmac_testsuite,
16464 		&cryptodev_mixed_cipher_hash_testsuite,
16465 		&cryptodev_negative_hmac_sha1_testsuite,
16466 		&cryptodev_gen_testsuite,
16467 #ifdef RTE_LIB_SECURITY
16468 		&ipsec_proto_testsuite,
16469 		&pdcp_proto_testsuite,
16470 		&docsis_proto_testsuite,
16471 #endif
16472 		&end_testsuite
16473 	};
16474 	static struct unit_test_suite ts = {
16475 		.suite_name = "Cryptodev Unit Test Suite",
16476 		.setup = testsuite_setup,
16477 		.teardown = testsuite_teardown,
16478 		.unit_test_cases = {TEST_CASES_END()}
16479 	};
16480 
16481 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
16482 
16483 	if (gbl_driver_id == -1) {
16484 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
16485 		return TEST_SKIPPED;
16486 	}
16487 
16488 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
16489 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
16490 
16491 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
16492 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
16493 	ret = unit_test_suite_runner(&ts);
16494 
16495 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
16496 	free(ts.unit_test_suites);
16497 	return ret;
16498 }
16499 
16500 static int
16501 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
16502 {
16503 	struct rte_cryptodev_info dev_info;
16504 	uint8_t i, nb_devs;
16505 	int driver_id;
16506 
16507 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
16508 	if (driver_id == -1) {
16509 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
16510 		return TEST_SKIPPED;
16511 	}
16512 
16513 	nb_devs = rte_cryptodev_count();
16514 	if (nb_devs < 1) {
16515 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
16516 		return TEST_SKIPPED;
16517 	}
16518 
16519 	for (i = 0; i < nb_devs; i++) {
16520 		rte_cryptodev_info_get(i, &dev_info);
16521 		if (dev_info.driver_id == driver_id) {
16522 			if (!(dev_info.feature_flags & flag)) {
16523 				RTE_LOG(INFO, USER1, "%s not supported\n",
16524 						flag_name);
16525 				return TEST_SKIPPED;
16526 			}
16527 			return 0; /* found */
16528 		}
16529 	}
16530 
16531 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
16532 	return TEST_SKIPPED;
16533 }
16534 
16535 static int
16536 test_cryptodev_qat(void)
16537 {
16538 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
16539 }
16540 
16541 static int
16542 test_cryptodev_uadk(void)
16543 {
16544 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
16545 }
16546 
16547 static int
16548 test_cryptodev_virtio(void)
16549 {
16550 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
16551 }
16552 
16553 static int
16554 test_cryptodev_aesni_mb(void)
16555 {
16556 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16557 }
16558 
16559 static int
16560 test_cryptodev_cpu_aesni_mb(void)
16561 {
16562 	int32_t rc;
16563 	enum rte_security_session_action_type at = gbl_action_type;
16564 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
16565 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16566 	gbl_action_type = at;
16567 	return rc;
16568 }
16569 
16570 static int
16571 test_cryptodev_chacha_poly_mb(void)
16572 {
16573 	int32_t rc;
16574 	enum rte_security_session_action_type at = gbl_action_type;
16575 	rc = run_cryptodev_testsuite(
16576 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
16577 	gbl_action_type = at;
16578 	return rc;
16579 }
16580 
16581 static int
16582 test_cryptodev_openssl(void)
16583 {
16584 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
16585 }
16586 
16587 static int
16588 test_cryptodev_aesni_gcm(void)
16589 {
16590 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
16591 }
16592 
16593 static int
16594 test_cryptodev_cpu_aesni_gcm(void)
16595 {
16596 	int32_t rc;
16597 	enum rte_security_session_action_type at = gbl_action_type;
16598 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
16599 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
16600 	gbl_action_type = at;
16601 	return rc;
16602 }
16603 
16604 static int
16605 test_cryptodev_mlx5(void)
16606 {
16607 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
16608 }
16609 
16610 static int
16611 test_cryptodev_null(void)
16612 {
16613 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
16614 }
16615 
16616 static int
16617 test_cryptodev_sw_snow3g(void)
16618 {
16619 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
16620 }
16621 
16622 static int
16623 test_cryptodev_sw_kasumi(void)
16624 {
16625 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
16626 }
16627 
16628 static int
16629 test_cryptodev_sw_zuc(void)
16630 {
16631 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
16632 }
16633 
16634 static int
16635 test_cryptodev_armv8(void)
16636 {
16637 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
16638 }
16639 
16640 static int
16641 test_cryptodev_mrvl(void)
16642 {
16643 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
16644 }
16645 
16646 #ifdef RTE_CRYPTO_SCHEDULER
16647 
16648 static int
16649 test_cryptodev_scheduler(void)
16650 {
16651 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
16652 	const enum blockcipher_test_type blk_suites[] = {
16653 		BLKCIPHER_AES_CHAIN_TYPE,
16654 		BLKCIPHER_AES_CIPHERONLY_TYPE,
16655 		BLKCIPHER_AUTHONLY_TYPE
16656 	};
16657 	static struct unit_test_suite scheduler_multicore = {
16658 		.suite_name = "Scheduler Multicore Unit Test Suite",
16659 		.setup = scheduler_multicore_testsuite_setup,
16660 		.teardown = scheduler_mode_testsuite_teardown,
16661 		.unit_test_cases = {TEST_CASES_END()}
16662 	};
16663 	static struct unit_test_suite scheduler_round_robin = {
16664 		.suite_name = "Scheduler Round Robin Unit Test Suite",
16665 		.setup = scheduler_roundrobin_testsuite_setup,
16666 		.teardown = scheduler_mode_testsuite_teardown,
16667 		.unit_test_cases = {TEST_CASES_END()}
16668 	};
16669 	static struct unit_test_suite scheduler_failover = {
16670 		.suite_name = "Scheduler Failover Unit Test Suite",
16671 		.setup = scheduler_failover_testsuite_setup,
16672 		.teardown = scheduler_mode_testsuite_teardown,
16673 		.unit_test_cases = {TEST_CASES_END()}
16674 	};
16675 	static struct unit_test_suite scheduler_pkt_size_distr = {
16676 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
16677 		.setup = scheduler_pkt_size_distr_testsuite_setup,
16678 		.teardown = scheduler_mode_testsuite_teardown,
16679 		.unit_test_cases = {TEST_CASES_END()}
16680 	};
16681 	struct unit_test_suite *sched_mode_suites[] = {
16682 		&scheduler_multicore,
16683 		&scheduler_round_robin,
16684 		&scheduler_failover,
16685 		&scheduler_pkt_size_distr
16686 	};
16687 	static struct unit_test_suite scheduler_config = {
16688 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
16689 		.unit_test_cases = {
16690 			TEST_CASE(test_scheduler_attach_worker_op),
16691 			TEST_CASE(test_scheduler_mode_multicore_op),
16692 			TEST_CASE(test_scheduler_mode_roundrobin_op),
16693 			TEST_CASE(test_scheduler_mode_failover_op),
16694 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
16695 			TEST_CASE(test_scheduler_detach_worker_op),
16696 
16697 			TEST_CASES_END() /**< NULL terminate array */
16698 		}
16699 	};
16700 	struct unit_test_suite *static_suites[] = {
16701 		&scheduler_config,
16702 		&end_testsuite
16703 	};
16704 	static struct unit_test_suite ts = {
16705 		.suite_name = "Scheduler Unit Test Suite",
16706 		.setup = scheduler_testsuite_setup,
16707 		.teardown = testsuite_teardown,
16708 		.unit_test_cases = {TEST_CASES_END()}
16709 	};
16710 
16711 	gbl_driver_id =	rte_cryptodev_driver_id_get(
16712 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16713 
16714 	if (gbl_driver_id == -1) {
16715 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
16716 		return TEST_SKIPPED;
16717 	}
16718 
16719 	if (rte_cryptodev_driver_id_get(
16720 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
16721 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
16722 		return TEST_SKIPPED;
16723 	}
16724 
16725 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16726 		uint8_t blk_i = 0;
16727 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
16728 				(struct unit_test_suite *) *
16729 				(RTE_DIM(blk_suites) + 1));
16730 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
16731 				blk_suites, RTE_DIM(blk_suites));
16732 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
16733 	}
16734 
16735 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
16736 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
16737 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
16738 			RTE_DIM(sched_mode_suites));
16739 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
16740 	ret = unit_test_suite_runner(&ts);
16741 
16742 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16743 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
16744 				(*sched_mode_suites[sched_i]),
16745 				RTE_DIM(blk_suites));
16746 		free(sched_mode_suites[sched_i]->unit_test_suites);
16747 	}
16748 	free(ts.unit_test_suites);
16749 	return ret;
16750 }
16751 
16752 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
16753 
16754 #endif
16755 
16756 static int
16757 test_cryptodev_dpaa2_sec(void)
16758 {
16759 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
16760 }
16761 
16762 static int
16763 test_cryptodev_dpaa_sec(void)
16764 {
16765 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
16766 }
16767 
16768 static int
16769 test_cryptodev_ccp(void)
16770 {
16771 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
16772 }
16773 
16774 static int
16775 test_cryptodev_octeontx(void)
16776 {
16777 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
16778 }
16779 
16780 static int
16781 test_cryptodev_caam_jr(void)
16782 {
16783 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
16784 }
16785 
16786 static int
16787 test_cryptodev_nitrox(void)
16788 {
16789 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
16790 }
16791 
16792 static int
16793 test_cryptodev_bcmfs(void)
16794 {
16795 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
16796 }
16797 
16798 static int
16799 test_cryptodev_qat_raw_api(void)
16800 {
16801 	static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
16802 	int ret;
16803 
16804 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16805 			"RAW API");
16806 	if (ret)
16807 		return ret;
16808 
16809 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
16810 	ret = run_cryptodev_testsuite(pmd_name);
16811 	global_api_test_type = CRYPTODEV_API_TEST;
16812 
16813 	return ret;
16814 }
16815 
16816 static int
16817 test_cryptodev_cn9k(void)
16818 {
16819 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
16820 }
16821 
16822 static int
16823 test_cryptodev_cn10k(void)
16824 {
16825 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
16826 }
16827 
16828 static int
16829 test_cryptodev_dpaa2_sec_raw_api(void)
16830 {
16831 	static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16832 	int ret;
16833 
16834 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16835 			"RAW API");
16836 	if (ret)
16837 		return ret;
16838 
16839 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
16840 	ret = run_cryptodev_testsuite(pmd_name);
16841 	global_api_test_type = CRYPTODEV_API_TEST;
16842 
16843 	return ret;
16844 }
16845 
16846 static int
16847 test_cryptodev_dpaa_sec_raw_api(void)
16848 {
16849 	static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD);
16850 	int ret;
16851 
16852 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16853 			"RAW API");
16854 	if (ret)
16855 		return ret;
16856 
16857 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
16858 	ret = run_cryptodev_testsuite(pmd_name);
16859 	global_api_test_type = CRYPTODEV_API_TEST;
16860 
16861 	return ret;
16862 }
16863 
16864 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
16865 		test_cryptodev_dpaa2_sec_raw_api);
16866 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
16867 		test_cryptodev_dpaa_sec_raw_api);
16868 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
16869 		test_cryptodev_qat_raw_api);
16870 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
16871 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
16872 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
16873 	test_cryptodev_cpu_aesni_mb);
16874 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
16875 	test_cryptodev_chacha_poly_mb);
16876 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
16877 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
16878 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
16879 	test_cryptodev_cpu_aesni_gcm);
16880 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
16881 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
16882 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
16883 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
16884 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
16885 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
16886 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
16887 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
16888 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
16889 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
16890 REGISTER_TEST_COMMAND(cryptodev_uadk_autotest, test_cryptodev_uadk);
16891 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
16892 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
16893 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
16894 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
16895 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
16896 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
16897 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
16898