xref: /dpdk/app/test/test_cryptodev.c (revision ccdeca8e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Intel Corporation
3  * Copyright 2020 NXP
4  */
5 
6 #ifndef RTE_EXEC_ENV_WINDOWS
7 
8 #include <time.h>
9 
10 #include <rte_common.h>
11 #include <rte_hexdump.h>
12 #include <rte_mbuf.h>
13 #include <rte_malloc.h>
14 #include <rte_memcpy.h>
15 #include <rte_pause.h>
16 #include <rte_bus_vdev.h>
17 #include <rte_ether.h>
18 
19 #include <rte_crypto.h>
20 #include <rte_cryptodev.h>
21 #include <rte_ip.h>
22 #include <rte_string_fns.h>
23 #include <rte_tcp.h>
24 #include <rte_udp.h>
25 
26 #ifdef RTE_CRYPTO_SCHEDULER
27 #include <rte_cryptodev_scheduler.h>
28 #include <rte_cryptodev_scheduler_operations.h>
29 #endif
30 
31 #include <rte_lcore.h>
32 
33 #include "test.h"
34 #include "test_cryptodev.h"
35 
36 #include "test_cryptodev_blockcipher.h"
37 #include "test_cryptodev_aes_test_vectors.h"
38 #include "test_cryptodev_des_test_vectors.h"
39 #include "test_cryptodev_hash_test_vectors.h"
40 #include "test_cryptodev_kasumi_test_vectors.h"
41 #include "test_cryptodev_kasumi_hash_test_vectors.h"
42 #include "test_cryptodev_snow3g_test_vectors.h"
43 #include "test_cryptodev_snow3g_hash_test_vectors.h"
44 #include "test_cryptodev_zuc_test_vectors.h"
45 #include "test_cryptodev_aead_test_vectors.h"
46 #include "test_cryptodev_hmac_test_vectors.h"
47 #include "test_cryptodev_mixed_test_vectors.h"
48 #ifdef RTE_LIB_SECURITY
49 #include "test_cryptodev_security_ipsec.h"
50 #include "test_cryptodev_security_ipsec_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_vectors.h"
52 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
53 #include "test_cryptodev_security_pdcp_test_func.h"
54 #include "test_cryptodev_security_docsis_test_vectors.h"
55 
56 #define SDAP_DISABLED	0
57 #define SDAP_ENABLED	1
58 #endif
59 
60 #define VDEV_ARGS_SIZE 100
61 #define MAX_NB_SESSIONS 4
62 
63 #define MAX_DRV_SERVICE_CTX_SIZE 256
64 
65 #define MAX_RAW_DEQUEUE_COUNT	65535
66 
67 #define IN_PLACE 0
68 #define OUT_OF_PLACE 1
69 
70 static int gbl_driver_id;
71 
72 static enum rte_security_session_action_type gbl_action_type =
73 	RTE_SECURITY_ACTION_TYPE_NONE;
74 
75 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
76 
77 struct crypto_unittest_params {
78 	struct rte_crypto_sym_xform cipher_xform;
79 	struct rte_crypto_sym_xform auth_xform;
80 	struct rte_crypto_sym_xform aead_xform;
81 #ifdef RTE_LIB_SECURITY
82 	struct rte_security_docsis_xform docsis_xform;
83 #endif
84 
85 	union {
86 		struct rte_cryptodev_sym_session *sess;
87 #ifdef RTE_LIB_SECURITY
88 		struct rte_security_session *sec_session;
89 #endif
90 	};
91 #ifdef RTE_LIB_SECURITY
92 	enum rte_security_session_action_type type;
93 #endif
94 	struct rte_crypto_op *op;
95 
96 	struct rte_mbuf *obuf, *ibuf;
97 
98 	uint8_t *digest;
99 };
100 
101 #define ALIGN_POW2_ROUNDUP(num, align) \
102 	(((num) + (align) - 1) & ~((align) - 1))
103 
104 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
105 	for (j = 0; j < num_child_ts; index++, j++)			\
106 		parent_ts.unit_test_suites[index] = child_ts[j]
107 
108 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
109 	for (j = 0; j < num_blk_types; index++, j++)				\
110 		parent_ts.unit_test_suites[index] =				\
111 				build_blockcipher_test_suite(blk_types[j])
112 
113 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
114 	for (j = index; j < index + num_blk_types; j++)				\
115 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 
117 /*
118  * Forward declarations.
119  */
120 static int
121 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
122 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
123 		uint8_t *hmac_key);
124 
125 static int
126 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
127 		struct crypto_unittest_params *ut_params,
128 		struct crypto_testsuite_params *ts_param,
129 		const uint8_t *cipher,
130 		const uint8_t *digest,
131 		const uint8_t *iv);
132 
133 static int
134 security_proto_supported(enum rte_security_session_action_type action,
135 	enum rte_security_session_protocol proto);
136 
137 static int
138 dev_configure_and_start(uint64_t ff_disable);
139 
140 static struct rte_mbuf *
141 setup_test_string(struct rte_mempool *mpool,
142 		const char *string, size_t len, uint8_t blocksize)
143 {
144 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
145 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
146 
147 	if (m) {
148 		char *dst;
149 
150 		memset(m->buf_addr, 0, m->buf_len);
151 		dst = rte_pktmbuf_append(m, t_len);
152 		if (!dst) {
153 			rte_pktmbuf_free(m);
154 			return NULL;
155 		}
156 		if (string != NULL)
157 			rte_memcpy(dst, string, t_len);
158 		else
159 			memset(dst, 0, t_len);
160 	}
161 
162 	return m;
163 }
164 
165 /* Get number of bytes in X bits (rounding up) */
166 static uint32_t
167 ceil_byte_length(uint32_t num_bits)
168 {
169 	if (num_bits % 8)
170 		return ((num_bits >> 3) + 1);
171 	else
172 		return (num_bits >> 3);
173 }
174 
175 static void
176 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
177 		uint8_t is_op_success)
178 {
179 	struct rte_crypto_op *op = user_data;
180 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
181 			RTE_CRYPTO_OP_STATUS_ERROR;
182 }
183 
184 static struct crypto_testsuite_params testsuite_params = { NULL };
185 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
186 static struct crypto_unittest_params unittest_params;
187 
188 void
189 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
190 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
191 		uint8_t len_in_bits, uint8_t cipher_iv_len)
192 {
193 	struct rte_crypto_sym_op *sop = op->sym;
194 	struct rte_crypto_op *ret_op = NULL;
195 	struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
196 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
197 	union rte_crypto_sym_ofs ofs;
198 	struct rte_crypto_sym_vec vec;
199 	struct rte_crypto_sgl sgl, dest_sgl;
200 	uint32_t max_len;
201 	union rte_cryptodev_session_ctx sess;
202 	uint64_t auth_end_iova;
203 	uint32_t count = 0;
204 	struct rte_crypto_raw_dp_ctx *ctx;
205 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
206 			auth_len = 0;
207 	int32_t n;
208 	uint32_t n_success;
209 	int ctx_service_size;
210 	int32_t status = 0;
211 	int enqueue_status, dequeue_status;
212 	struct crypto_unittest_params *ut_params = &unittest_params;
213 	int is_sgl = sop->m_src->nb_segs > 1;
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 (is_cipher && is_auth) {
253 		cipher_offset = sop->cipher.data.offset;
254 		cipher_len = sop->cipher.data.length;
255 		auth_offset = sop->auth.data.offset;
256 		auth_len = sop->auth.data.length;
257 		max_len = RTE_MAX(cipher_offset + cipher_len,
258 				auth_offset + auth_len);
259 		if (len_in_bits) {
260 			max_len = max_len >> 3;
261 			cipher_offset = cipher_offset >> 3;
262 			auth_offset = auth_offset >> 3;
263 			cipher_len = cipher_len >> 3;
264 			auth_len = auth_len >> 3;
265 		}
266 		ofs.ofs.cipher.head = cipher_offset;
267 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
268 		ofs.ofs.auth.head = auth_offset;
269 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
270 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
271 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
272 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
273 				op, void *, IV_OFFSET + cipher_iv_len);
274 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
275 				cipher_iv_len);
276 		digest.va = (void *)sop->auth.digest.data;
277 		digest.iova = sop->auth.digest.phys_addr;
278 
279 		if (is_sgl) {
280 			uint32_t remaining_off = auth_offset + auth_len;
281 			struct rte_mbuf *sgl_buf = sop->m_src;
282 
283 			while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
284 					&& sgl_buf->next != NULL) {
285 				remaining_off -= rte_pktmbuf_data_len(sgl_buf);
286 				sgl_buf = sgl_buf->next;
287 			}
288 
289 			auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
290 				sgl_buf, remaining_off);
291 		} else {
292 			auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
293 							 auth_offset + auth_len;
294 		}
295 		/* Then check if digest-encrypted conditions are met */
296 		if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
297 				(digest.iova == auth_end_iova) && is_sgl)
298 			max_len = RTE_MAX(max_len, auth_offset + auth_len +
299 				ut_params->auth_xform.auth.digest_length);
300 
301 	} else if (is_cipher) {
302 		cipher_offset = sop->cipher.data.offset;
303 		cipher_len = sop->cipher.data.length;
304 		max_len = cipher_len + cipher_offset;
305 		if (len_in_bits) {
306 			max_len = max_len >> 3;
307 			cipher_offset = cipher_offset >> 3;
308 			cipher_len = cipher_len >> 3;
309 		}
310 		ofs.ofs.cipher.head = cipher_offset;
311 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
312 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
313 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
314 
315 	} else if (is_auth) {
316 		auth_offset = sop->auth.data.offset;
317 		auth_len = sop->auth.data.length;
318 		max_len = auth_len + auth_offset;
319 		if (len_in_bits) {
320 			max_len = max_len >> 3;
321 			auth_offset = auth_offset >> 3;
322 			auth_len = auth_len >> 3;
323 		}
324 		ofs.ofs.auth.head = auth_offset;
325 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
326 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
327 				op, void *, IV_OFFSET + cipher_iv_len);
328 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
329 				cipher_iv_len);
330 		digest.va = (void *)sop->auth.digest.data;
331 		digest.iova = sop->auth.digest.phys_addr;
332 
333 	} else { /* aead */
334 		cipher_offset = sop->aead.data.offset;
335 		cipher_len = sop->aead.data.length;
336 		max_len = cipher_len + cipher_offset;
337 		if (len_in_bits) {
338 			max_len = max_len >> 3;
339 			cipher_offset = cipher_offset >> 3;
340 			cipher_len = cipher_len >> 3;
341 		}
342 		ofs.ofs.cipher.head = cipher_offset;
343 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
344 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
345 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
346 		aad_auth_iv.va = (void *)sop->aead.aad.data;
347 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
348 		digest.va = (void *)sop->aead.digest.data;
349 		digest.iova = sop->aead.digest.phys_addr;
350 	}
351 
352 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
353 			data_vec, RTE_DIM(data_vec));
354 	if (n < 0 || n > sop->m_src->nb_segs) {
355 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
356 		goto exit;
357 	}
358 
359 	sgl.num = n;
360 	/* Out of place */
361 	if (sop->m_dst != NULL) {
362 		dest_sgl.vec = dest_data_vec;
363 		vec.dest_sgl = &dest_sgl;
364 		n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
365 				dest_data_vec, RTE_DIM(dest_data_vec));
366 		if (n < 0 || n > sop->m_dst->nb_segs) {
367 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
368 			goto exit;
369 		}
370 		dest_sgl.num = n;
371 	} else
372 		vec.dest_sgl = NULL;
373 
374 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
375 			&enqueue_status) < 1) {
376 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
377 		goto exit;
378 	}
379 
380 	if (enqueue_status == 0) {
381 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
382 		if (status < 0) {
383 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
384 			goto exit;
385 		}
386 	} else if (enqueue_status < 0) {
387 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
388 		goto exit;
389 	}
390 
391 	n = n_success = 0;
392 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
393 		n = rte_cryptodev_raw_dequeue_burst(ctx,
394 			NULL, 1, post_process_raw_dp_op,
395 				(void **)&ret_op, 0, &n_success,
396 				&dequeue_status);
397 		if (dequeue_status < 0) {
398 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
399 			goto exit;
400 		}
401 		if (n == 0)
402 			rte_pause();
403 	}
404 
405 	if (n == 1 && dequeue_status == 0) {
406 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
407 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
408 			goto exit;
409 		}
410 	}
411 
412 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
413 			ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
414 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
415 					RTE_CRYPTO_OP_STATUS_SUCCESS;
416 
417 exit:
418 	free(ctx);
419 }
420 
421 static void
422 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
423 {
424 	int32_t n, st;
425 	struct rte_crypto_sym_op *sop;
426 	union rte_crypto_sym_ofs ofs;
427 	struct rte_crypto_sgl sgl;
428 	struct rte_crypto_sym_vec symvec;
429 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
430 	struct rte_crypto_vec vec[UINT8_MAX];
431 
432 	sop = op->sym;
433 
434 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
435 		sop->aead.data.length, vec, RTE_DIM(vec));
436 
437 	if (n < 0 || n != sop->m_src->nb_segs) {
438 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
439 		return;
440 	}
441 
442 	sgl.vec = vec;
443 	sgl.num = n;
444 	symvec.src_sgl = &sgl;
445 	symvec.iv = &iv_ptr;
446 	symvec.digest = &digest_ptr;
447 	symvec.aad = &aad_ptr;
448 	symvec.status = &st;
449 	symvec.num = 1;
450 
451 	/* for CPU crypto the IOVA address is not required */
452 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
453 	digest_ptr.va = (void *)sop->aead.digest.data;
454 	aad_ptr.va = (void *)sop->aead.aad.data;
455 
456 	ofs.raw = 0;
457 
458 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
459 		&symvec);
460 
461 	if (n != 1)
462 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
463 	else
464 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
465 }
466 
467 static void
468 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
469 {
470 	int32_t n, st;
471 	struct rte_crypto_sym_op *sop;
472 	union rte_crypto_sym_ofs ofs;
473 	struct rte_crypto_sgl sgl;
474 	struct rte_crypto_sym_vec symvec;
475 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
476 	struct rte_crypto_vec vec[UINT8_MAX];
477 
478 	sop = op->sym;
479 
480 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
481 		sop->auth.data.length, vec, RTE_DIM(vec));
482 
483 	if (n < 0 || n != sop->m_src->nb_segs) {
484 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
485 		return;
486 	}
487 
488 	sgl.vec = vec;
489 	sgl.num = n;
490 	symvec.src_sgl = &sgl;
491 	symvec.iv = &iv_ptr;
492 	symvec.digest = &digest_ptr;
493 	symvec.status = &st;
494 	symvec.num = 1;
495 
496 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
497 	digest_ptr.va = (void *)sop->auth.digest.data;
498 
499 	ofs.raw = 0;
500 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
501 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
502 		(sop->cipher.data.offset + sop->cipher.data.length);
503 
504 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
505 		&symvec);
506 
507 	if (n != 1)
508 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
509 	else
510 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
511 }
512 
513 static struct rte_crypto_op *
514 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
515 {
516 
517 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
518 
519 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
520 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
521 		return NULL;
522 	}
523 
524 	op = NULL;
525 
526 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
527 		rte_pause();
528 
529 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
530 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
531 		return NULL;
532 	}
533 
534 	return op;
535 }
536 
537 static int
538 testsuite_setup(void)
539 {
540 	struct crypto_testsuite_params *ts_params = &testsuite_params;
541 	struct rte_cryptodev_info info;
542 	uint32_t i = 0, nb_devs, dev_id;
543 	uint16_t qp_id;
544 
545 	memset(ts_params, 0, sizeof(*ts_params));
546 
547 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
548 	if (ts_params->mbuf_pool == NULL) {
549 		/* Not already created so create */
550 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
551 				"CRYPTO_MBUFPOOL",
552 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
553 				rte_socket_id());
554 		if (ts_params->mbuf_pool == NULL) {
555 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
556 			return TEST_FAILED;
557 		}
558 	}
559 
560 	ts_params->large_mbuf_pool = rte_mempool_lookup(
561 			"CRYPTO_LARGE_MBUFPOOL");
562 	if (ts_params->large_mbuf_pool == NULL) {
563 		/* Not already created so create */
564 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
565 				"CRYPTO_LARGE_MBUFPOOL",
566 				1, 0, 0, UINT16_MAX,
567 				rte_socket_id());
568 		if (ts_params->large_mbuf_pool == NULL) {
569 			RTE_LOG(ERR, USER1,
570 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
571 			return TEST_FAILED;
572 		}
573 	}
574 
575 	ts_params->op_mpool = rte_crypto_op_pool_create(
576 			"MBUF_CRYPTO_SYM_OP_POOL",
577 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
578 			NUM_MBUFS, MBUF_CACHE_SIZE,
579 			DEFAULT_NUM_XFORMS *
580 			sizeof(struct rte_crypto_sym_xform) +
581 			MAXIMUM_IV_LENGTH,
582 			rte_socket_id());
583 	if (ts_params->op_mpool == NULL) {
584 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
585 		return TEST_FAILED;
586 	}
587 
588 	nb_devs = rte_cryptodev_count();
589 	if (nb_devs < 1) {
590 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
591 		return TEST_SKIPPED;
592 	}
593 
594 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
595 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
596 				rte_cryptodev_driver_name_get(gbl_driver_id));
597 		return TEST_SKIPPED;
598 	}
599 
600 	/* Create list of valid crypto devs */
601 	for (i = 0; i < nb_devs; i++) {
602 		rte_cryptodev_info_get(i, &info);
603 		if (info.driver_id == gbl_driver_id)
604 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
605 	}
606 
607 	if (ts_params->valid_dev_count < 1)
608 		return TEST_FAILED;
609 
610 	/* Set up all the qps on the first of the valid devices found */
611 
612 	dev_id = ts_params->valid_devs[0];
613 
614 	rte_cryptodev_info_get(dev_id, &info);
615 
616 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
617 	ts_params->conf.socket_id = SOCKET_ID_ANY;
618 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
619 
620 	unsigned int session_size =
621 		rte_cryptodev_sym_get_private_session_size(dev_id);
622 
623 #ifdef RTE_LIB_SECURITY
624 	unsigned int security_session_size = rte_security_session_get_size(
625 			rte_cryptodev_get_sec_ctx(dev_id));
626 
627 	if (session_size < security_session_size)
628 		session_size = security_session_size;
629 #endif
630 	/*
631 	 * Create mempool with maximum number of sessions.
632 	 */
633 	if (info.sym.max_nb_sessions != 0 &&
634 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
635 		RTE_LOG(ERR, USER1, "Device does not support "
636 				"at least %u sessions\n",
637 				MAX_NB_SESSIONS);
638 		return TEST_FAILED;
639 	}
640 
641 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
642 			"test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
643 			SOCKET_ID_ANY);
644 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
645 			"session mempool allocation failed");
646 
647 	ts_params->session_priv_mpool = rte_mempool_create(
648 			"test_sess_mp_priv",
649 			MAX_NB_SESSIONS,
650 			session_size,
651 			0, 0, NULL, NULL, NULL,
652 			NULL, SOCKET_ID_ANY,
653 			0);
654 	TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
655 			"session mempool allocation failed");
656 
657 
658 
659 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
660 			&ts_params->conf),
661 			"Failed to configure cryptodev %u with %u qps",
662 			dev_id, ts_params->conf.nb_queue_pairs);
663 
664 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
665 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
666 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
667 
668 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
669 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
670 			dev_id, qp_id, &ts_params->qp_conf,
671 			rte_cryptodev_socket_id(dev_id)),
672 			"Failed to setup queue pair %u on cryptodev %u",
673 			qp_id, dev_id);
674 	}
675 
676 	return TEST_SUCCESS;
677 }
678 
679 static void
680 testsuite_teardown(void)
681 {
682 	struct crypto_testsuite_params *ts_params = &testsuite_params;
683 	int res;
684 
685 	if (ts_params->mbuf_pool != NULL) {
686 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
687 		rte_mempool_avail_count(ts_params->mbuf_pool));
688 	}
689 
690 	if (ts_params->op_mpool != NULL) {
691 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
692 		rte_mempool_avail_count(ts_params->op_mpool));
693 	}
694 
695 	/* Free session mempools */
696 	if (ts_params->session_priv_mpool != NULL) {
697 		rte_mempool_free(ts_params->session_priv_mpool);
698 		ts_params->session_priv_mpool = NULL;
699 	}
700 
701 	if (ts_params->session_mpool != NULL) {
702 		rte_mempool_free(ts_params->session_mpool);
703 		ts_params->session_mpool = NULL;
704 	}
705 
706 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
707 	if (res)
708 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
709 }
710 
711 static int
712 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
713 		const int *algs, uint16_t num_algs)
714 {
715 	uint8_t dev_id = testsuite_params.valid_devs[0];
716 	bool some_alg_supported = FALSE;
717 	uint16_t i;
718 
719 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
720 		struct rte_cryptodev_sym_capability_idx alg = {
721 			type, {algs[i]}
722 		};
723 		if (rte_cryptodev_sym_capability_get(dev_id,
724 				&alg) != NULL)
725 			some_alg_supported = TRUE;
726 	}
727 	if (!some_alg_supported)
728 		return TEST_SKIPPED;
729 
730 	return 0;
731 }
732 
733 int
734 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
735 		uint16_t num_ciphers)
736 {
737 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
738 			(const int *) ciphers, num_ciphers);
739 }
740 
741 int
742 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
743 		uint16_t num_auths)
744 {
745 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
746 			(const int *) auths, num_auths);
747 }
748 
749 int
750 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
751 		uint16_t num_aeads)
752 {
753 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
754 			(const int *) aeads, num_aeads);
755 }
756 
757 static int
758 null_testsuite_setup(void)
759 {
760 	struct crypto_testsuite_params *ts_params = &testsuite_params;
761 	uint8_t dev_id = ts_params->valid_devs[0];
762 	struct rte_cryptodev_info dev_info;
763 	const enum rte_crypto_cipher_algorithm ciphers[] = {
764 		RTE_CRYPTO_CIPHER_NULL
765 	};
766 	const enum rte_crypto_auth_algorithm auths[] = {
767 		RTE_CRYPTO_AUTH_NULL
768 	};
769 
770 	rte_cryptodev_info_get(dev_id, &dev_info);
771 
772 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
773 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
774 				"testsuite not met\n");
775 		return TEST_SKIPPED;
776 	}
777 
778 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
779 			&& check_auth_capabilities_supported(auths,
780 			RTE_DIM(auths)) != 0) {
781 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
782 				"testsuite not met\n");
783 		return TEST_SKIPPED;
784 	}
785 
786 	return 0;
787 }
788 
789 static int
790 crypto_gen_testsuite_setup(void)
791 {
792 	struct crypto_testsuite_params *ts_params = &testsuite_params;
793 	uint8_t dev_id = ts_params->valid_devs[0];
794 	struct rte_cryptodev_info dev_info;
795 
796 	rte_cryptodev_info_get(dev_id, &dev_info);
797 
798 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
799 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
800 				"testsuite not met\n");
801 		return TEST_SKIPPED;
802 	}
803 
804 	return 0;
805 }
806 
807 #ifdef RTE_LIB_SECURITY
808 static int
809 ipsec_proto_testsuite_setup(void)
810 {
811 	struct crypto_testsuite_params *ts_params = &testsuite_params;
812 	struct crypto_unittest_params *ut_params = &unittest_params;
813 	struct rte_cryptodev_info dev_info;
814 	int ret = 0;
815 
816 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
817 
818 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
819 		RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
820 				"testsuite not met\n");
821 		return TEST_SKIPPED;
822 	}
823 
824 	/* Reconfigure to enable security */
825 	ret = dev_configure_and_start(0);
826 	if (ret != TEST_SUCCESS)
827 		return ret;
828 
829 	/* Set action type */
830 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
831 
832 	if (security_proto_supported(
833 			RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
834 			RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
835 		RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
836 				"test not met\n");
837 		ret = TEST_SKIPPED;
838 	}
839 
840 	test_ipsec_alg_list_populate();
841 
842 	/*
843 	 * Stop the device. Device would be started again by individual test
844 	 * case setup routine.
845 	 */
846 	rte_cryptodev_stop(ts_params->valid_devs[0]);
847 
848 	return ret;
849 }
850 
851 static int
852 pdcp_proto_testsuite_setup(void)
853 {
854 	struct crypto_testsuite_params *ts_params = &testsuite_params;
855 	uint8_t dev_id = ts_params->valid_devs[0];
856 	struct rte_cryptodev_info dev_info;
857 	const enum rte_crypto_cipher_algorithm ciphers[] = {
858 		RTE_CRYPTO_CIPHER_NULL,
859 		RTE_CRYPTO_CIPHER_AES_CTR,
860 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
861 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
862 	};
863 	const enum rte_crypto_auth_algorithm auths[] = {
864 		RTE_CRYPTO_AUTH_NULL,
865 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
866 		RTE_CRYPTO_AUTH_AES_CMAC,
867 		RTE_CRYPTO_AUTH_ZUC_EIA3
868 	};
869 
870 	rte_cryptodev_info_get(dev_id, &dev_info);
871 
872 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
873 			!(dev_info.feature_flags &
874 			RTE_CRYPTODEV_FF_SECURITY)) {
875 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
876 				"testsuite not met\n");
877 		return TEST_SKIPPED;
878 	}
879 
880 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
881 			&& check_auth_capabilities_supported(auths,
882 			RTE_DIM(auths)) != 0) {
883 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
884 				"testsuite not met\n");
885 		return TEST_SKIPPED;
886 	}
887 
888 	return 0;
889 }
890 
891 static int
892 docsis_proto_testsuite_setup(void)
893 {
894 	struct crypto_testsuite_params *ts_params = &testsuite_params;
895 	uint8_t dev_id = ts_params->valid_devs[0];
896 	struct rte_cryptodev_info dev_info;
897 	const enum rte_crypto_cipher_algorithm ciphers[] = {
898 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
899 	};
900 
901 	rte_cryptodev_info_get(dev_id, &dev_info);
902 
903 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
904 			!(dev_info.feature_flags &
905 			RTE_CRYPTODEV_FF_SECURITY)) {
906 		RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
907 				"Proto testsuite not met\n");
908 		return TEST_SKIPPED;
909 	}
910 
911 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
912 		RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
913 				"testsuite not met\n");
914 		return TEST_SKIPPED;
915 	}
916 
917 	return 0;
918 }
919 #endif
920 
921 static int
922 aes_ccm_auth_testsuite_setup(void)
923 {
924 	struct crypto_testsuite_params *ts_params = &testsuite_params;
925 	uint8_t dev_id = ts_params->valid_devs[0];
926 	struct rte_cryptodev_info dev_info;
927 	const enum rte_crypto_aead_algorithm aeads[] = {
928 		RTE_CRYPTO_AEAD_AES_CCM
929 	};
930 
931 	rte_cryptodev_info_get(dev_id, &dev_info);
932 
933 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
934 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
935 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
936 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
937 				"testsuite not met\n");
938 		return TEST_SKIPPED;
939 	}
940 
941 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
942 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
943 				"testsuite not met\n");
944 		return TEST_SKIPPED;
945 	}
946 
947 	return 0;
948 }
949 
950 static int
951 aes_gcm_auth_testsuite_setup(void)
952 {
953 	struct crypto_testsuite_params *ts_params = &testsuite_params;
954 	uint8_t dev_id = ts_params->valid_devs[0];
955 	struct rte_cryptodev_info dev_info;
956 	const enum rte_crypto_aead_algorithm aeads[] = {
957 		RTE_CRYPTO_AEAD_AES_GCM
958 	};
959 
960 	rte_cryptodev_info_get(dev_id, &dev_info);
961 
962 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
963 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
964 				"testsuite not met\n");
965 		return TEST_SKIPPED;
966 	}
967 
968 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
969 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
970 				"testsuite not met\n");
971 		return TEST_SKIPPED;
972 	}
973 
974 	return 0;
975 }
976 
977 static int
978 aes_gmac_auth_testsuite_setup(void)
979 {
980 	struct crypto_testsuite_params *ts_params = &testsuite_params;
981 	uint8_t dev_id = ts_params->valid_devs[0];
982 	struct rte_cryptodev_info dev_info;
983 	const enum rte_crypto_auth_algorithm auths[] = {
984 		RTE_CRYPTO_AUTH_AES_GMAC
985 	};
986 
987 	rte_cryptodev_info_get(dev_id, &dev_info);
988 
989 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
990 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
991 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
992 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
993 				"testsuite not met\n");
994 		return TEST_SKIPPED;
995 	}
996 
997 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
998 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
999 				"testsuite not met\n");
1000 		return TEST_SKIPPED;
1001 	}
1002 
1003 	return 0;
1004 }
1005 
1006 static int
1007 chacha20_poly1305_testsuite_setup(void)
1008 {
1009 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1010 	uint8_t dev_id = ts_params->valid_devs[0];
1011 	struct rte_cryptodev_info dev_info;
1012 	const enum rte_crypto_aead_algorithm aeads[] = {
1013 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1014 	};
1015 
1016 	rte_cryptodev_info_get(dev_id, &dev_info);
1017 
1018 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1019 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1020 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1021 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
1022 				"Chacha20-Poly1305 testsuite not met\n");
1023 		return TEST_SKIPPED;
1024 	}
1025 
1026 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1027 		RTE_LOG(INFO, USER1, "Capability requirements for "
1028 				"Chacha20-Poly1305 testsuite not met\n");
1029 		return TEST_SKIPPED;
1030 	}
1031 
1032 	return 0;
1033 }
1034 
1035 static int
1036 snow3g_testsuite_setup(void)
1037 {
1038 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1039 	uint8_t dev_id = ts_params->valid_devs[0];
1040 	struct rte_cryptodev_info dev_info;
1041 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1042 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1043 
1044 	};
1045 	const enum rte_crypto_auth_algorithm auths[] = {
1046 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
1047 	};
1048 
1049 	rte_cryptodev_info_get(dev_id, &dev_info);
1050 
1051 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1052 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1053 				"testsuite not met\n");
1054 		return TEST_SKIPPED;
1055 	}
1056 
1057 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1058 			&& check_auth_capabilities_supported(auths,
1059 			RTE_DIM(auths)) != 0) {
1060 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1061 				"testsuite not met\n");
1062 		return TEST_SKIPPED;
1063 	}
1064 
1065 	return 0;
1066 }
1067 
1068 static int
1069 zuc_testsuite_setup(void)
1070 {
1071 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1072 	uint8_t dev_id = ts_params->valid_devs[0];
1073 	struct rte_cryptodev_info dev_info;
1074 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1075 		RTE_CRYPTO_CIPHER_ZUC_EEA3
1076 	};
1077 	const enum rte_crypto_auth_algorithm auths[] = {
1078 		RTE_CRYPTO_AUTH_ZUC_EIA3
1079 	};
1080 
1081 	rte_cryptodev_info_get(dev_id, &dev_info);
1082 
1083 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1084 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1085 				"testsuite not met\n");
1086 		return TEST_SKIPPED;
1087 	}
1088 
1089 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1090 			&& check_auth_capabilities_supported(auths,
1091 			RTE_DIM(auths)) != 0) {
1092 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1093 				"testsuite not met\n");
1094 		return TEST_SKIPPED;
1095 	}
1096 
1097 	return 0;
1098 }
1099 
1100 static int
1101 hmac_md5_auth_testsuite_setup(void)
1102 {
1103 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1104 	uint8_t dev_id = ts_params->valid_devs[0];
1105 	struct rte_cryptodev_info dev_info;
1106 	const enum rte_crypto_auth_algorithm auths[] = {
1107 		RTE_CRYPTO_AUTH_MD5_HMAC
1108 	};
1109 
1110 	rte_cryptodev_info_get(dev_id, &dev_info);
1111 
1112 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1113 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1114 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1115 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1116 				"Auth testsuite not met\n");
1117 		return TEST_SKIPPED;
1118 	}
1119 
1120 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1121 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1122 				"testsuite not met\n");
1123 		return TEST_SKIPPED;
1124 	}
1125 
1126 	return 0;
1127 }
1128 
1129 static int
1130 kasumi_testsuite_setup(void)
1131 {
1132 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1133 	uint8_t dev_id = ts_params->valid_devs[0];
1134 	struct rte_cryptodev_info dev_info;
1135 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1136 		RTE_CRYPTO_CIPHER_KASUMI_F8
1137 	};
1138 	const enum rte_crypto_auth_algorithm auths[] = {
1139 		RTE_CRYPTO_AUTH_KASUMI_F9
1140 	};
1141 
1142 	rte_cryptodev_info_get(dev_id, &dev_info);
1143 
1144 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1145 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1146 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1147 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1148 				"testsuite not met\n");
1149 		return TEST_SKIPPED;
1150 	}
1151 
1152 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1153 			&& check_auth_capabilities_supported(auths,
1154 			RTE_DIM(auths)) != 0) {
1155 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1156 				"testsuite not met\n");
1157 		return TEST_SKIPPED;
1158 	}
1159 
1160 	return 0;
1161 }
1162 
1163 static int
1164 negative_aes_gcm_testsuite_setup(void)
1165 {
1166 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1167 	uint8_t dev_id = ts_params->valid_devs[0];
1168 	struct rte_cryptodev_info dev_info;
1169 	const enum rte_crypto_aead_algorithm aeads[] = {
1170 		RTE_CRYPTO_AEAD_AES_GCM
1171 	};
1172 
1173 	rte_cryptodev_info_get(dev_id, &dev_info);
1174 
1175 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1176 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1177 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1178 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1179 				"AES GCM testsuite not met\n");
1180 		return TEST_SKIPPED;
1181 	}
1182 
1183 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1184 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1185 				"AES GCM testsuite not met\n");
1186 		return TEST_SKIPPED;
1187 	}
1188 
1189 	return 0;
1190 }
1191 
1192 static int
1193 negative_aes_gmac_testsuite_setup(void)
1194 {
1195 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1196 	uint8_t dev_id = ts_params->valid_devs[0];
1197 	struct rte_cryptodev_info dev_info;
1198 	const enum rte_crypto_auth_algorithm auths[] = {
1199 		RTE_CRYPTO_AUTH_AES_GMAC
1200 	};
1201 
1202 	rte_cryptodev_info_get(dev_id, &dev_info);
1203 
1204 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1205 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1206 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1207 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1208 				"AES GMAC testsuite not met\n");
1209 		return TEST_SKIPPED;
1210 	}
1211 
1212 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1213 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1214 				"AES GMAC testsuite not met\n");
1215 		return TEST_SKIPPED;
1216 	}
1217 
1218 	return 0;
1219 }
1220 
1221 static int
1222 mixed_cipher_hash_testsuite_setup(void)
1223 {
1224 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1225 	uint8_t dev_id = ts_params->valid_devs[0];
1226 	struct rte_cryptodev_info dev_info;
1227 	uint64_t feat_flags;
1228 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1229 		RTE_CRYPTO_CIPHER_NULL,
1230 		RTE_CRYPTO_CIPHER_AES_CTR,
1231 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1232 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1233 	};
1234 	const enum rte_crypto_auth_algorithm auths[] = {
1235 		RTE_CRYPTO_AUTH_NULL,
1236 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1237 		RTE_CRYPTO_AUTH_AES_CMAC,
1238 		RTE_CRYPTO_AUTH_ZUC_EIA3
1239 	};
1240 
1241 	rte_cryptodev_info_get(dev_id, &dev_info);
1242 	feat_flags = dev_info.feature_flags;
1243 
1244 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1245 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1246 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1247 				"Cipher Hash testsuite not met\n");
1248 		return TEST_SKIPPED;
1249 	}
1250 
1251 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1252 			&& check_auth_capabilities_supported(auths,
1253 			RTE_DIM(auths)) != 0) {
1254 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1255 				"Cipher Hash testsuite not met\n");
1256 		return TEST_SKIPPED;
1257 	}
1258 
1259 	return 0;
1260 }
1261 
1262 static int
1263 esn_testsuite_setup(void)
1264 {
1265 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1266 	uint8_t dev_id = ts_params->valid_devs[0];
1267 	struct rte_cryptodev_info dev_info;
1268 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1269 		RTE_CRYPTO_CIPHER_AES_CBC
1270 	};
1271 	const enum rte_crypto_auth_algorithm auths[] = {
1272 		RTE_CRYPTO_AUTH_SHA1_HMAC
1273 	};
1274 
1275 	rte_cryptodev_info_get(dev_id, &dev_info);
1276 
1277 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1278 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1279 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1280 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1281 				"testsuite not met\n");
1282 		return TEST_SKIPPED;
1283 	}
1284 
1285 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1286 			&& check_auth_capabilities_supported(auths,
1287 			RTE_DIM(auths)) != 0) {
1288 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1289 				"testsuite not met\n");
1290 		return TEST_SKIPPED;
1291 	}
1292 
1293 	return 0;
1294 }
1295 
1296 static int
1297 multi_session_testsuite_setup(void)
1298 {
1299 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1300 	uint8_t dev_id = ts_params->valid_devs[0];
1301 	struct rte_cryptodev_info dev_info;
1302 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1303 		RTE_CRYPTO_CIPHER_AES_CBC
1304 	};
1305 	const enum rte_crypto_auth_algorithm auths[] = {
1306 		RTE_CRYPTO_AUTH_SHA512_HMAC
1307 	};
1308 
1309 	rte_cryptodev_info_get(dev_id, &dev_info);
1310 
1311 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1312 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1313 				"Session testsuite not met\n");
1314 		return TEST_SKIPPED;
1315 	}
1316 
1317 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1318 			&& check_auth_capabilities_supported(auths,
1319 			RTE_DIM(auths)) != 0) {
1320 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1321 				"Session testsuite not met\n");
1322 		return TEST_SKIPPED;
1323 	}
1324 
1325 	return 0;
1326 }
1327 
1328 static int
1329 negative_hmac_sha1_testsuite_setup(void)
1330 {
1331 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1332 	uint8_t dev_id = ts_params->valid_devs[0];
1333 	struct rte_cryptodev_info dev_info;
1334 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1335 		RTE_CRYPTO_CIPHER_AES_CBC
1336 	};
1337 	const enum rte_crypto_auth_algorithm auths[] = {
1338 		RTE_CRYPTO_AUTH_SHA1_HMAC
1339 	};
1340 
1341 	rte_cryptodev_info_get(dev_id, &dev_info);
1342 
1343 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1344 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1345 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1346 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1347 				"HMAC SHA1 testsuite not met\n");
1348 		return TEST_SKIPPED;
1349 	}
1350 
1351 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1352 			&& check_auth_capabilities_supported(auths,
1353 			RTE_DIM(auths)) != 0) {
1354 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1355 				"HMAC SHA1 testsuite not met\n");
1356 		return TEST_SKIPPED;
1357 	}
1358 
1359 	return 0;
1360 }
1361 
1362 static int
1363 dev_configure_and_start(uint64_t ff_disable)
1364 {
1365 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1366 	struct crypto_unittest_params *ut_params = &unittest_params;
1367 
1368 	uint16_t qp_id;
1369 
1370 	/* Clear unit test parameters before running test */
1371 	memset(ut_params, 0, sizeof(*ut_params));
1372 
1373 	/* Reconfigure device to default parameters */
1374 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1375 	ts_params->conf.ff_disable = ff_disable;
1376 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1377 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1378 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1379 
1380 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1381 			&ts_params->conf),
1382 			"Failed to configure cryptodev %u",
1383 			ts_params->valid_devs[0]);
1384 
1385 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1386 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1387 			ts_params->valid_devs[0], qp_id,
1388 			&ts_params->qp_conf,
1389 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1390 			"Failed to setup queue pair %u on cryptodev %u",
1391 			qp_id, ts_params->valid_devs[0]);
1392 	}
1393 
1394 
1395 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1396 
1397 	/* Start the device */
1398 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1399 			"Failed to start cryptodev %u",
1400 			ts_params->valid_devs[0]);
1401 
1402 	return TEST_SUCCESS;
1403 }
1404 
1405 int
1406 ut_setup(void)
1407 {
1408 	/* Configure and start the device with security feature disabled */
1409 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1410 }
1411 
1412 static int
1413 ut_setup_security(void)
1414 {
1415 	/* Configure and start the device with no features disabled */
1416 	return dev_configure_and_start(0);
1417 }
1418 
1419 void
1420 ut_teardown(void)
1421 {
1422 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1423 	struct crypto_unittest_params *ut_params = &unittest_params;
1424 
1425 	/* free crypto session structure */
1426 #ifdef RTE_LIB_SECURITY
1427 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1428 		if (ut_params->sec_session) {
1429 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1430 						(ts_params->valid_devs[0]),
1431 						ut_params->sec_session);
1432 			ut_params->sec_session = NULL;
1433 		}
1434 	} else
1435 #endif
1436 	{
1437 		if (ut_params->sess) {
1438 			rte_cryptodev_sym_session_clear(
1439 					ts_params->valid_devs[0],
1440 					ut_params->sess);
1441 			rte_cryptodev_sym_session_free(ut_params->sess);
1442 			ut_params->sess = NULL;
1443 		}
1444 	}
1445 
1446 	/* free crypto operation structure */
1447 	if (ut_params->op)
1448 		rte_crypto_op_free(ut_params->op);
1449 
1450 	/*
1451 	 * free mbuf - both obuf and ibuf are usually the same,
1452 	 * so check if they point at the same address is necessary,
1453 	 * to avoid freeing the mbuf twice.
1454 	 */
1455 	if (ut_params->obuf) {
1456 		rte_pktmbuf_free(ut_params->obuf);
1457 		if (ut_params->ibuf == ut_params->obuf)
1458 			ut_params->ibuf = 0;
1459 		ut_params->obuf = 0;
1460 	}
1461 	if (ut_params->ibuf) {
1462 		rte_pktmbuf_free(ut_params->ibuf);
1463 		ut_params->ibuf = 0;
1464 	}
1465 
1466 	if (ts_params->mbuf_pool != NULL)
1467 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1468 			rte_mempool_avail_count(ts_params->mbuf_pool));
1469 
1470 	/* Stop the device */
1471 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1472 }
1473 
1474 static int
1475 test_device_configure_invalid_dev_id(void)
1476 {
1477 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1478 	uint16_t dev_id, num_devs = 0;
1479 
1480 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1481 			"Need at least %d devices for test", 1);
1482 
1483 	/* valid dev_id values */
1484 	dev_id = ts_params->valid_devs[0];
1485 
1486 	/* Stop the device in case it's started so it can be configured */
1487 	rte_cryptodev_stop(dev_id);
1488 
1489 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1490 			"Failed test for rte_cryptodev_configure: "
1491 			"invalid dev_num %u", dev_id);
1492 
1493 	/* invalid dev_id values */
1494 	dev_id = num_devs;
1495 
1496 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1497 			"Failed test for rte_cryptodev_configure: "
1498 			"invalid dev_num %u", dev_id);
1499 
1500 	dev_id = 0xff;
1501 
1502 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1503 			"Failed test for rte_cryptodev_configure:"
1504 			"invalid dev_num %u", dev_id);
1505 
1506 	return TEST_SUCCESS;
1507 }
1508 
1509 static int
1510 test_device_configure_invalid_queue_pair_ids(void)
1511 {
1512 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1513 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1514 
1515 	/* Stop the device in case it's started so it can be configured */
1516 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1517 
1518 	/* valid - max value queue pairs */
1519 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1520 
1521 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1522 			&ts_params->conf),
1523 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1524 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1525 
1526 	/* valid - one queue pairs */
1527 	ts_params->conf.nb_queue_pairs = 1;
1528 
1529 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1530 			&ts_params->conf),
1531 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1532 			ts_params->valid_devs[0],
1533 			ts_params->conf.nb_queue_pairs);
1534 
1535 
1536 	/* invalid - zero queue pairs */
1537 	ts_params->conf.nb_queue_pairs = 0;
1538 
1539 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1540 			&ts_params->conf),
1541 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1542 			" invalid qps: %u",
1543 			ts_params->valid_devs[0],
1544 			ts_params->conf.nb_queue_pairs);
1545 
1546 
1547 	/* invalid - max value supported by field queue pairs */
1548 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1549 
1550 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1551 			&ts_params->conf),
1552 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1553 			" invalid qps: %u",
1554 			ts_params->valid_devs[0],
1555 			ts_params->conf.nb_queue_pairs);
1556 
1557 
1558 	/* invalid - max value + 1 queue pairs */
1559 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1560 
1561 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1562 			&ts_params->conf),
1563 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1564 			" invalid qps: %u",
1565 			ts_params->valid_devs[0],
1566 			ts_params->conf.nb_queue_pairs);
1567 
1568 	/* revert to original testsuite value */
1569 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1570 
1571 	return TEST_SUCCESS;
1572 }
1573 
1574 static int
1575 test_queue_pair_descriptor_setup(void)
1576 {
1577 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1578 	struct rte_cryptodev_qp_conf qp_conf = {
1579 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1580 	};
1581 	uint16_t qp_id;
1582 
1583 	/* Stop the device in case it's started so it can be configured */
1584 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1585 
1586 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1587 			&ts_params->conf),
1588 			"Failed to configure cryptodev %u",
1589 			ts_params->valid_devs[0]);
1590 
1591 	/*
1592 	 * Test various ring sizes on this device. memzones can't be
1593 	 * freed so are re-used if ring is released and re-created.
1594 	 */
1595 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1596 	qp_conf.mp_session = ts_params->session_mpool;
1597 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
1598 
1599 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1600 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1601 				ts_params->valid_devs[0], qp_id, &qp_conf,
1602 				rte_cryptodev_socket_id(
1603 						ts_params->valid_devs[0])),
1604 				"Failed test for "
1605 				"rte_cryptodev_queue_pair_setup: num_inflights "
1606 				"%u on qp %u on cryptodev %u",
1607 				qp_conf.nb_descriptors, qp_id,
1608 				ts_params->valid_devs[0]);
1609 	}
1610 
1611 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1612 
1613 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1614 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1615 				ts_params->valid_devs[0], qp_id, &qp_conf,
1616 				rte_cryptodev_socket_id(
1617 						ts_params->valid_devs[0])),
1618 				"Failed test for"
1619 				" rte_cryptodev_queue_pair_setup: num_inflights"
1620 				" %u on qp %u on cryptodev %u",
1621 				qp_conf.nb_descriptors, qp_id,
1622 				ts_params->valid_devs[0]);
1623 	}
1624 
1625 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1626 
1627 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1628 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1629 				ts_params->valid_devs[0], qp_id, &qp_conf,
1630 				rte_cryptodev_socket_id(
1631 						ts_params->valid_devs[0])),
1632 				"Failed test for "
1633 				"rte_cryptodev_queue_pair_setup: num_inflights"
1634 				" %u on qp %u on cryptodev %u",
1635 				qp_conf.nb_descriptors, qp_id,
1636 				ts_params->valid_devs[0]);
1637 	}
1638 
1639 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1640 
1641 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1642 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1643 				ts_params->valid_devs[0], qp_id, &qp_conf,
1644 				rte_cryptodev_socket_id(
1645 						ts_params->valid_devs[0])),
1646 				"Failed test for"
1647 				" rte_cryptodev_queue_pair_setup:"
1648 				"num_inflights %u on qp %u on cryptodev %u",
1649 				qp_conf.nb_descriptors, qp_id,
1650 				ts_params->valid_devs[0]);
1651 	}
1652 
1653 	/* test invalid queue pair id */
1654 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1655 
1656 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1657 
1658 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1659 			ts_params->valid_devs[0],
1660 			qp_id, &qp_conf,
1661 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1662 			"Failed test for rte_cryptodev_queue_pair_setup:"
1663 			"invalid qp %u on cryptodev %u",
1664 			qp_id, ts_params->valid_devs[0]);
1665 
1666 	qp_id = 0xffff; /*invalid*/
1667 
1668 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1669 			ts_params->valid_devs[0],
1670 			qp_id, &qp_conf,
1671 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1672 			"Failed test for rte_cryptodev_queue_pair_setup:"
1673 			"invalid qp %u on cryptodev %u",
1674 			qp_id, ts_params->valid_devs[0]);
1675 
1676 	return TEST_SUCCESS;
1677 }
1678 
1679 /* ***** Plaintext data for tests ***** */
1680 
1681 const char catch_22_quote_1[] =
1682 		"There was only one catch and that was Catch-22, which "
1683 		"specified that a concern for one's safety in the face of "
1684 		"dangers that were real and immediate was the process of a "
1685 		"rational mind. Orr was crazy and could be grounded. All he "
1686 		"had to do was ask; and as soon as he did, he would no longer "
1687 		"be crazy and would have to fly more missions. Orr would be "
1688 		"crazy to fly more missions and sane if he didn't, but if he "
1689 		"was sane he had to fly them. If he flew them he was crazy "
1690 		"and didn't have to; but if he didn't want to he was sane and "
1691 		"had to. Yossarian was moved very deeply by the absolute "
1692 		"simplicity of this clause of Catch-22 and let out a "
1693 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1694 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1695 
1696 const char catch_22_quote[] =
1697 		"What a lousy earth! He wondered how many people were "
1698 		"destitute that same night even in his own prosperous country, "
1699 		"how many homes were shanties, how many husbands were drunk "
1700 		"and wives socked, and how many children were bullied, abused, "
1701 		"or abandoned. How many families hungered for food they could "
1702 		"not afford to buy? How many hearts were broken? How many "
1703 		"suicides would take place that same night, how many people "
1704 		"would go insane? How many cockroaches and landlords would "
1705 		"triumph? How many winners were losers, successes failures, "
1706 		"and rich men poor men? How many wise guys were stupid? How "
1707 		"many happy endings were unhappy endings? How many honest men "
1708 		"were liars, brave men cowards, loyal men traitors, how many "
1709 		"sainted men were corrupt, how many people in positions of "
1710 		"trust had sold their souls to bodyguards, how many had never "
1711 		"had souls? How many straight-and-narrow paths were crooked "
1712 		"paths? How many best families were worst families and how "
1713 		"many good people were bad people? When you added them all up "
1714 		"and then subtracted, you might be left with only the children, "
1715 		"and perhaps with Albert Einstein and an old violinist or "
1716 		"sculptor somewhere.";
1717 
1718 #define QUOTE_480_BYTES		(480)
1719 #define QUOTE_512_BYTES		(512)
1720 #define QUOTE_768_BYTES		(768)
1721 #define QUOTE_1024_BYTES	(1024)
1722 
1723 
1724 
1725 /* ***** SHA1 Hash Tests ***** */
1726 
1727 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1728 
1729 static uint8_t hmac_sha1_key[] = {
1730 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1731 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1732 	0xDE, 0xF4, 0xDE, 0xAD };
1733 
1734 /* ***** SHA224 Hash Tests ***** */
1735 
1736 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
1737 
1738 
1739 /* ***** AES-CBC Cipher Tests ***** */
1740 
1741 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
1742 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
1743 
1744 static uint8_t aes_cbc_key[] = {
1745 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1746 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1747 
1748 static uint8_t aes_cbc_iv[] = {
1749 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1750 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1751 
1752 
1753 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1754 
1755 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1756 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1757 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1758 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1759 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1760 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1761 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1762 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1763 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1764 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1765 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1766 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1767 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1768 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1769 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1770 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1771 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1772 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1773 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1774 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1775 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1776 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1777 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1778 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1779 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1780 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1781 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1782 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1783 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1784 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1785 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1786 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1787 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1788 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1789 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1790 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1791 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1792 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1793 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1794 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1795 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1796 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1797 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1798 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1799 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1800 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1801 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1802 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1803 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1804 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1805 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1806 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1807 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1808 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1809 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1810 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1811 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1812 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1813 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1814 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1815 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1816 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1817 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1818 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1819 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1820 };
1821 
1822 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1823 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1824 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1825 	0x18, 0x8c, 0x1d, 0x32
1826 };
1827 
1828 
1829 /* Multisession Vector context Test */
1830 /*Begin Session 0 */
1831 static uint8_t ms_aes_cbc_key0[] = {
1832 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1833 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1834 };
1835 
1836 static uint8_t ms_aes_cbc_iv0[] = {
1837 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1838 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1839 };
1840 
1841 static const uint8_t ms_aes_cbc_cipher0[] = {
1842 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1843 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1844 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1845 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1846 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1847 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1848 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1849 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1850 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1851 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1852 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1853 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1854 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1855 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1856 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1857 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1858 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1859 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1860 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1861 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1862 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1863 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1864 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1865 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1866 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1867 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1868 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1869 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1870 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1871 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1872 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1873 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1874 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1875 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1876 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1877 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1878 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1879 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1880 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1881 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1882 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1883 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1884 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1885 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1886 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1887 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1888 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1889 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1890 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1891 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1892 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1893 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1894 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1895 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1896 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1897 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1898 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1899 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1900 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1901 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1902 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1903 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1904 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1905 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1906 };
1907 
1908 
1909 static  uint8_t ms_hmac_key0[] = {
1910 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1911 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1912 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1913 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1914 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1915 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1916 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1917 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1918 };
1919 
1920 static const uint8_t ms_hmac_digest0[] = {
1921 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1922 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1923 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1924 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1925 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1926 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1927 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1928 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1929 		};
1930 
1931 /* End Session 0 */
1932 /* Begin session 1 */
1933 
1934 static  uint8_t ms_aes_cbc_key1[] = {
1935 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1936 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1937 };
1938 
1939 static  uint8_t ms_aes_cbc_iv1[] = {
1940 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1941 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1942 };
1943 
1944 static const uint8_t ms_aes_cbc_cipher1[] = {
1945 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1946 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1947 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1948 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1949 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1950 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1951 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1952 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1953 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1954 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1955 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1956 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1957 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1958 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1959 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1960 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1961 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1962 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1963 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1964 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1965 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1966 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1967 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1968 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1969 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1970 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1971 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1972 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1973 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1974 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1975 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1976 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1977 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1978 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1979 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1980 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1981 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1982 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1983 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1984 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1985 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1986 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1987 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1988 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1989 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1990 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1991 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1992 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1993 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1994 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1995 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1996 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1997 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1998 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1999 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2000 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2001 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2002 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2003 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2004 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2005 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2006 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2007 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2008 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2009 
2010 };
2011 
2012 static uint8_t ms_hmac_key1[] = {
2013 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2014 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2015 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2016 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2017 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2018 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2019 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2020 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2021 };
2022 
2023 static const uint8_t ms_hmac_digest1[] = {
2024 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2025 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2026 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2027 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2028 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2029 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2030 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2031 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2032 };
2033 /* End Session 1  */
2034 /* Begin Session 2 */
2035 static  uint8_t ms_aes_cbc_key2[] = {
2036 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2037 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2038 };
2039 
2040 static  uint8_t ms_aes_cbc_iv2[] = {
2041 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2042 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2043 };
2044 
2045 static const uint8_t ms_aes_cbc_cipher2[] = {
2046 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2047 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2048 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2049 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2050 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2051 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2052 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2053 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2054 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2055 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2056 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2057 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2058 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2059 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2060 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2061 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2062 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2063 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2064 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2065 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2066 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2067 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2068 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2069 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2070 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2071 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2072 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2073 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2074 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2075 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2076 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2077 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2078 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2079 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2080 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2081 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2082 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2083 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2084 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2085 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2086 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2087 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2088 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2089 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2090 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2091 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2092 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2093 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2094 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2095 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2096 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2097 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2098 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2099 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2100 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2101 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2102 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2103 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2104 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2105 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2106 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2107 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2108 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2109 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2110 };
2111 
2112 static  uint8_t ms_hmac_key2[] = {
2113 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2114 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2115 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2116 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2117 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2118 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2119 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2120 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2121 };
2122 
2123 static const uint8_t ms_hmac_digest2[] = {
2124 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2125 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2126 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2127 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2128 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2129 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2130 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2131 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2132 };
2133 
2134 /* End Session 2 */
2135 
2136 
2137 static int
2138 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2139 {
2140 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2141 	struct crypto_unittest_params *ut_params = &unittest_params;
2142 	int status;
2143 
2144 	/* Verify the capabilities */
2145 	struct rte_cryptodev_sym_capability_idx cap_idx;
2146 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2147 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2148 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2149 			&cap_idx) == NULL)
2150 		return TEST_SKIPPED;
2151 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2152 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2153 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2154 			&cap_idx) == NULL)
2155 		return TEST_SKIPPED;
2156 
2157 	/* Generate test mbuf data and space for digest */
2158 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2159 			catch_22_quote,	QUOTE_512_BYTES, 0);
2160 
2161 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2162 			DIGEST_BYTE_LENGTH_SHA1);
2163 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2164 
2165 	/* Setup Cipher Parameters */
2166 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2167 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2168 
2169 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2170 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2171 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2172 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2173 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2174 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2175 
2176 	/* Setup HMAC Parameters */
2177 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2178 
2179 	ut_params->auth_xform.next = NULL;
2180 
2181 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2182 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2183 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2184 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2185 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2186 
2187 	ut_params->sess = rte_cryptodev_sym_session_create(
2188 			ts_params->session_mpool);
2189 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2190 
2191 	/* Create crypto session*/
2192 	status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2193 			ut_params->sess, &ut_params->cipher_xform,
2194 			ts_params->session_priv_mpool);
2195 
2196 	if (status == -ENOTSUP)
2197 		return TEST_SKIPPED;
2198 
2199 	TEST_ASSERT_EQUAL(status, 0, "Session init failed");
2200 
2201 	/* Generate crypto op data structure */
2202 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2203 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2204 	TEST_ASSERT_NOT_NULL(ut_params->op,
2205 			"Failed to allocate symmetric crypto operation struct");
2206 
2207 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2208 
2209 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2210 
2211 	/* set crypto operation source mbuf */
2212 	sym_op->m_src = ut_params->ibuf;
2213 
2214 	/* Set crypto operation authentication parameters */
2215 	sym_op->auth.digest.data = ut_params->digest;
2216 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2217 			ut_params->ibuf, QUOTE_512_BYTES);
2218 
2219 	sym_op->auth.data.offset = 0;
2220 	sym_op->auth.data.length = QUOTE_512_BYTES;
2221 
2222 	/* Copy IV at the end of the crypto operation */
2223 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2224 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2225 
2226 	/* Set crypto operation cipher parameters */
2227 	sym_op->cipher.data.offset = 0;
2228 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2229 
2230 	/* Process crypto operation */
2231 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2232 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2233 			ut_params->op);
2234 	else
2235 		TEST_ASSERT_NOT_NULL(
2236 			process_crypto_request(ts_params->valid_devs[0],
2237 				ut_params->op),
2238 				"failed to process sym crypto op");
2239 
2240 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2241 			"crypto op processing failed");
2242 
2243 	/* Validate obuf */
2244 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2245 			uint8_t *);
2246 
2247 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2248 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2249 			QUOTE_512_BYTES,
2250 			"ciphertext data not as expected");
2251 
2252 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2253 
2254 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2255 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2256 			gbl_driver_id == rte_cryptodev_driver_id_get(
2257 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2258 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2259 					DIGEST_BYTE_LENGTH_SHA1,
2260 			"Generated digest data not as expected");
2261 
2262 	return TEST_SUCCESS;
2263 }
2264 
2265 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2266 
2267 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2268 
2269 static uint8_t hmac_sha512_key[] = {
2270 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2271 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2272 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2273 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2274 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2275 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2276 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2277 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2278 
2279 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2280 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2281 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2282 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2283 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2284 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2285 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2286 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2287 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2288 
2289 
2290 
2291 static int
2292 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2293 		struct crypto_unittest_params *ut_params,
2294 		uint8_t *cipher_key,
2295 		uint8_t *hmac_key);
2296 
2297 static int
2298 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2299 		struct crypto_unittest_params *ut_params,
2300 		struct crypto_testsuite_params *ts_params,
2301 		const uint8_t *cipher,
2302 		const uint8_t *digest,
2303 		const uint8_t *iv);
2304 
2305 
2306 static int
2307 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2308 		struct crypto_unittest_params *ut_params,
2309 		uint8_t *cipher_key,
2310 		uint8_t *hmac_key)
2311 {
2312 
2313 	/* Setup Cipher Parameters */
2314 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2315 	ut_params->cipher_xform.next = NULL;
2316 
2317 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2318 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2319 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2320 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2321 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2322 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2323 
2324 	/* Setup HMAC Parameters */
2325 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2326 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2327 
2328 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2329 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2330 	ut_params->auth_xform.auth.key.data = hmac_key;
2331 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2332 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2333 
2334 	return TEST_SUCCESS;
2335 }
2336 
2337 
2338 static int
2339 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2340 		struct crypto_unittest_params *ut_params,
2341 		struct crypto_testsuite_params *ts_params,
2342 		const uint8_t *cipher,
2343 		const uint8_t *digest,
2344 		const uint8_t *iv)
2345 {
2346 	/* Generate test mbuf data and digest */
2347 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2348 			(const char *)
2349 			cipher,
2350 			QUOTE_512_BYTES, 0);
2351 
2352 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2353 			DIGEST_BYTE_LENGTH_SHA512);
2354 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2355 
2356 	rte_memcpy(ut_params->digest,
2357 			digest,
2358 			DIGEST_BYTE_LENGTH_SHA512);
2359 
2360 	/* Generate Crypto op data structure */
2361 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2362 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2363 	TEST_ASSERT_NOT_NULL(ut_params->op,
2364 			"Failed to allocate symmetric crypto operation struct");
2365 
2366 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2367 
2368 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2369 
2370 	/* set crypto operation source mbuf */
2371 	sym_op->m_src = ut_params->ibuf;
2372 
2373 	sym_op->auth.digest.data = ut_params->digest;
2374 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2375 			ut_params->ibuf, QUOTE_512_BYTES);
2376 
2377 	sym_op->auth.data.offset = 0;
2378 	sym_op->auth.data.length = QUOTE_512_BYTES;
2379 
2380 	/* Copy IV at the end of the crypto operation */
2381 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2382 			iv, CIPHER_IV_LENGTH_AES_CBC);
2383 
2384 	sym_op->cipher.data.offset = 0;
2385 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2386 
2387 	/* Process crypto operation */
2388 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2389 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2390 			ut_params->op);
2391 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2392 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2393 				ut_params->op, 1, 1, 0, 0);
2394 	else
2395 		TEST_ASSERT_NOT_NULL(
2396 				process_crypto_request(ts_params->valid_devs[0],
2397 					ut_params->op),
2398 					"failed to process sym crypto op");
2399 
2400 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2401 			"crypto op processing failed");
2402 
2403 	ut_params->obuf = ut_params->op->sym->m_src;
2404 
2405 	/* Validate obuf */
2406 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2407 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2408 			catch_22_quote,
2409 			QUOTE_512_BYTES,
2410 			"Plaintext data not as expected");
2411 
2412 	/* Validate obuf */
2413 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2414 			"Digest verification failed");
2415 
2416 	return TEST_SUCCESS;
2417 }
2418 
2419 /* ***** SNOW 3G Tests ***** */
2420 static int
2421 create_wireless_algo_hash_session(uint8_t dev_id,
2422 	const uint8_t *key, const uint8_t key_len,
2423 	const uint8_t iv_len, const uint8_t auth_len,
2424 	enum rte_crypto_auth_operation op,
2425 	enum rte_crypto_auth_algorithm algo)
2426 {
2427 	uint8_t hash_key[key_len];
2428 	int status;
2429 
2430 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2431 	struct crypto_unittest_params *ut_params = &unittest_params;
2432 
2433 	memcpy(hash_key, key, key_len);
2434 
2435 	debug_hexdump(stdout, "key:", key, key_len);
2436 
2437 	/* Setup Authentication Parameters */
2438 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2439 	ut_params->auth_xform.next = NULL;
2440 
2441 	ut_params->auth_xform.auth.op = op;
2442 	ut_params->auth_xform.auth.algo = algo;
2443 	ut_params->auth_xform.auth.key.length = key_len;
2444 	ut_params->auth_xform.auth.key.data = hash_key;
2445 	ut_params->auth_xform.auth.digest_length = auth_len;
2446 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2447 	ut_params->auth_xform.auth.iv.length = iv_len;
2448 	ut_params->sess = rte_cryptodev_sym_session_create(
2449 			ts_params->session_mpool);
2450 
2451 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2452 			&ut_params->auth_xform,
2453 			ts_params->session_priv_mpool);
2454 	if (status == -ENOTSUP)
2455 		return TEST_SKIPPED;
2456 
2457 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2458 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2459 	return 0;
2460 }
2461 
2462 static int
2463 create_wireless_algo_cipher_session(uint8_t dev_id,
2464 			enum rte_crypto_cipher_operation op,
2465 			enum rte_crypto_cipher_algorithm algo,
2466 			const uint8_t *key, const uint8_t key_len,
2467 			uint8_t iv_len)
2468 {
2469 	uint8_t cipher_key[key_len];
2470 	int status;
2471 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2472 	struct crypto_unittest_params *ut_params = &unittest_params;
2473 
2474 	memcpy(cipher_key, key, key_len);
2475 
2476 	/* Setup Cipher Parameters */
2477 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2478 	ut_params->cipher_xform.next = NULL;
2479 
2480 	ut_params->cipher_xform.cipher.algo = algo;
2481 	ut_params->cipher_xform.cipher.op = op;
2482 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2483 	ut_params->cipher_xform.cipher.key.length = key_len;
2484 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2485 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2486 
2487 	debug_hexdump(stdout, "key:", key, key_len);
2488 
2489 	/* Create Crypto session */
2490 	ut_params->sess = rte_cryptodev_sym_session_create(
2491 			ts_params->session_mpool);
2492 
2493 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2494 			&ut_params->cipher_xform,
2495 			ts_params->session_priv_mpool);
2496 	if (status == -ENOTSUP)
2497 		return TEST_SKIPPED;
2498 
2499 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2500 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2501 	return 0;
2502 }
2503 
2504 static int
2505 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2506 			unsigned int cipher_len,
2507 			unsigned int cipher_offset)
2508 {
2509 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2510 	struct crypto_unittest_params *ut_params = &unittest_params;
2511 
2512 	/* Generate Crypto op data structure */
2513 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2514 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2515 	TEST_ASSERT_NOT_NULL(ut_params->op,
2516 				"Failed to allocate pktmbuf offload");
2517 
2518 	/* Set crypto operation data parameters */
2519 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2520 
2521 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2522 
2523 	/* set crypto operation source mbuf */
2524 	sym_op->m_src = ut_params->ibuf;
2525 
2526 	/* iv */
2527 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2528 			iv, iv_len);
2529 	sym_op->cipher.data.length = cipher_len;
2530 	sym_op->cipher.data.offset = cipher_offset;
2531 	return 0;
2532 }
2533 
2534 static int
2535 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2536 			unsigned int cipher_len,
2537 			unsigned int cipher_offset)
2538 {
2539 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2540 	struct crypto_unittest_params *ut_params = &unittest_params;
2541 
2542 	/* Generate Crypto op data structure */
2543 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2544 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2545 	TEST_ASSERT_NOT_NULL(ut_params->op,
2546 				"Failed to allocate pktmbuf offload");
2547 
2548 	/* Set crypto operation data parameters */
2549 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2550 
2551 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2552 
2553 	/* set crypto operation source mbuf */
2554 	sym_op->m_src = ut_params->ibuf;
2555 	sym_op->m_dst = ut_params->obuf;
2556 
2557 	/* iv */
2558 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2559 			iv, iv_len);
2560 	sym_op->cipher.data.length = cipher_len;
2561 	sym_op->cipher.data.offset = cipher_offset;
2562 	return 0;
2563 }
2564 
2565 static int
2566 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2567 		enum rte_crypto_cipher_operation cipher_op,
2568 		enum rte_crypto_auth_operation auth_op,
2569 		enum rte_crypto_auth_algorithm auth_algo,
2570 		enum rte_crypto_cipher_algorithm cipher_algo,
2571 		const uint8_t *key, uint8_t key_len,
2572 		uint8_t auth_iv_len, uint8_t auth_len,
2573 		uint8_t cipher_iv_len)
2574 
2575 {
2576 	uint8_t cipher_auth_key[key_len];
2577 	int status;
2578 
2579 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2580 	struct crypto_unittest_params *ut_params = &unittest_params;
2581 
2582 	memcpy(cipher_auth_key, key, key_len);
2583 
2584 	/* Setup Authentication Parameters */
2585 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2586 	ut_params->auth_xform.next = NULL;
2587 
2588 	ut_params->auth_xform.auth.op = auth_op;
2589 	ut_params->auth_xform.auth.algo = auth_algo;
2590 	ut_params->auth_xform.auth.key.length = key_len;
2591 	/* Hash key = cipher key */
2592 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2593 	ut_params->auth_xform.auth.digest_length = auth_len;
2594 	/* Auth IV will be after cipher IV */
2595 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2596 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2597 
2598 	/* Setup Cipher Parameters */
2599 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2600 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2601 
2602 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2603 	ut_params->cipher_xform.cipher.op = cipher_op;
2604 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2605 	ut_params->cipher_xform.cipher.key.length = key_len;
2606 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2607 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2608 
2609 	debug_hexdump(stdout, "key:", key, key_len);
2610 
2611 	/* Create Crypto session*/
2612 	ut_params->sess = rte_cryptodev_sym_session_create(
2613 			ts_params->session_mpool);
2614 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2615 
2616 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2617 			&ut_params->cipher_xform,
2618 			ts_params->session_priv_mpool);
2619 	if (status == -ENOTSUP)
2620 		return TEST_SKIPPED;
2621 
2622 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2623 	return 0;
2624 }
2625 
2626 static int
2627 create_wireless_cipher_auth_session(uint8_t dev_id,
2628 		enum rte_crypto_cipher_operation cipher_op,
2629 		enum rte_crypto_auth_operation auth_op,
2630 		enum rte_crypto_auth_algorithm auth_algo,
2631 		enum rte_crypto_cipher_algorithm cipher_algo,
2632 		const struct wireless_test_data *tdata)
2633 {
2634 	const uint8_t key_len = tdata->key.len;
2635 	uint8_t cipher_auth_key[key_len];
2636 	int status;
2637 
2638 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2639 	struct crypto_unittest_params *ut_params = &unittest_params;
2640 	const uint8_t *key = tdata->key.data;
2641 	const uint8_t auth_len = tdata->digest.len;
2642 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2643 	uint8_t auth_iv_len = tdata->auth_iv.len;
2644 
2645 	memcpy(cipher_auth_key, key, key_len);
2646 
2647 	/* Setup Authentication Parameters */
2648 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2649 	ut_params->auth_xform.next = NULL;
2650 
2651 	ut_params->auth_xform.auth.op = auth_op;
2652 	ut_params->auth_xform.auth.algo = auth_algo;
2653 	ut_params->auth_xform.auth.key.length = key_len;
2654 	/* Hash key = cipher key */
2655 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2656 	ut_params->auth_xform.auth.digest_length = auth_len;
2657 	/* Auth IV will be after cipher IV */
2658 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2659 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2660 
2661 	/* Setup Cipher Parameters */
2662 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2663 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2664 
2665 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2666 	ut_params->cipher_xform.cipher.op = cipher_op;
2667 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2668 	ut_params->cipher_xform.cipher.key.length = key_len;
2669 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2670 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2671 
2672 
2673 	debug_hexdump(stdout, "key:", key, key_len);
2674 
2675 	/* Create Crypto session*/
2676 	ut_params->sess = rte_cryptodev_sym_session_create(
2677 			ts_params->session_mpool);
2678 
2679 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2680 			&ut_params->cipher_xform,
2681 			ts_params->session_priv_mpool);
2682 	if (status == -ENOTSUP)
2683 		return TEST_SKIPPED;
2684 
2685 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2686 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2687 	return 0;
2688 }
2689 
2690 static int
2691 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2692 		const struct wireless_test_data *tdata)
2693 {
2694 	return create_wireless_cipher_auth_session(dev_id,
2695 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2696 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2697 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2698 }
2699 
2700 static int
2701 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2702 		enum rte_crypto_cipher_operation cipher_op,
2703 		enum rte_crypto_auth_operation auth_op,
2704 		enum rte_crypto_auth_algorithm auth_algo,
2705 		enum rte_crypto_cipher_algorithm cipher_algo,
2706 		const uint8_t *key, const uint8_t key_len,
2707 		uint8_t auth_iv_len, uint8_t auth_len,
2708 		uint8_t cipher_iv_len)
2709 {
2710 	uint8_t auth_cipher_key[key_len];
2711 	int status;
2712 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2713 	struct crypto_unittest_params *ut_params = &unittest_params;
2714 
2715 	memcpy(auth_cipher_key, key, key_len);
2716 
2717 	/* Setup Authentication Parameters */
2718 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2719 	ut_params->auth_xform.auth.op = auth_op;
2720 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2721 	ut_params->auth_xform.auth.algo = auth_algo;
2722 	ut_params->auth_xform.auth.key.length = key_len;
2723 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
2724 	ut_params->auth_xform.auth.digest_length = auth_len;
2725 	/* Auth IV will be after cipher IV */
2726 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2727 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2728 
2729 	/* Setup Cipher Parameters */
2730 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2731 	ut_params->cipher_xform.next = NULL;
2732 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2733 	ut_params->cipher_xform.cipher.op = cipher_op;
2734 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2735 	ut_params->cipher_xform.cipher.key.length = key_len;
2736 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2737 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2738 
2739 	debug_hexdump(stdout, "key:", key, key_len);
2740 
2741 	/* Create Crypto session*/
2742 	ut_params->sess = rte_cryptodev_sym_session_create(
2743 			ts_params->session_mpool);
2744 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2745 
2746 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2747 		ut_params->auth_xform.next = NULL;
2748 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2749 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2750 				&ut_params->cipher_xform,
2751 				ts_params->session_priv_mpool);
2752 
2753 	} else
2754 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2755 				&ut_params->auth_xform,
2756 				ts_params->session_priv_mpool);
2757 
2758 	if (status == -ENOTSUP)
2759 		return TEST_SKIPPED;
2760 
2761 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2762 
2763 	return 0;
2764 }
2765 
2766 static int
2767 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2768 		unsigned int auth_tag_len,
2769 		const uint8_t *iv, unsigned int iv_len,
2770 		unsigned int data_pad_len,
2771 		enum rte_crypto_auth_operation op,
2772 		unsigned int auth_len, unsigned int auth_offset)
2773 {
2774 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2775 
2776 	struct crypto_unittest_params *ut_params = &unittest_params;
2777 
2778 	/* Generate Crypto op data structure */
2779 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2780 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2781 	TEST_ASSERT_NOT_NULL(ut_params->op,
2782 		"Failed to allocate pktmbuf offload");
2783 
2784 	/* Set crypto operation data parameters */
2785 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2786 
2787 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2788 
2789 	/* set crypto operation source mbuf */
2790 	sym_op->m_src = ut_params->ibuf;
2791 
2792 	/* iv */
2793 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2794 			iv, iv_len);
2795 	/* digest */
2796 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2797 					ut_params->ibuf, auth_tag_len);
2798 
2799 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2800 				"no room to append auth tag");
2801 	ut_params->digest = sym_op->auth.digest.data;
2802 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2803 			ut_params->ibuf, data_pad_len);
2804 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2805 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2806 	else
2807 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2808 
2809 	debug_hexdump(stdout, "digest:",
2810 		sym_op->auth.digest.data,
2811 		auth_tag_len);
2812 
2813 	sym_op->auth.data.length = auth_len;
2814 	sym_op->auth.data.offset = auth_offset;
2815 
2816 	return 0;
2817 }
2818 
2819 static int
2820 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2821 	enum rte_crypto_auth_operation op)
2822 {
2823 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2824 	struct crypto_unittest_params *ut_params = &unittest_params;
2825 
2826 	const uint8_t *auth_tag = tdata->digest.data;
2827 	const unsigned int auth_tag_len = tdata->digest.len;
2828 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2829 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2830 
2831 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2832 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2833 	const uint8_t *auth_iv = tdata->auth_iv.data;
2834 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2835 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2836 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2837 
2838 	/* Generate Crypto op data structure */
2839 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2840 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2841 	TEST_ASSERT_NOT_NULL(ut_params->op,
2842 			"Failed to allocate pktmbuf offload");
2843 	/* Set crypto operation data parameters */
2844 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2845 
2846 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2847 
2848 	/* set crypto operation source mbuf */
2849 	sym_op->m_src = ut_params->ibuf;
2850 
2851 	/* digest */
2852 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2853 			ut_params->ibuf, auth_tag_len);
2854 
2855 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2856 			"no room to append auth tag");
2857 	ut_params->digest = sym_op->auth.digest.data;
2858 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2859 			ut_params->ibuf, data_pad_len);
2860 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2861 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2862 	else
2863 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2864 
2865 	debug_hexdump(stdout, "digest:",
2866 		sym_op->auth.digest.data,
2867 		auth_tag_len);
2868 
2869 	/* Copy cipher and auth IVs at the end of the crypto operation */
2870 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2871 						IV_OFFSET);
2872 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2873 	iv_ptr += cipher_iv_len;
2874 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2875 
2876 	sym_op->cipher.data.length = cipher_len;
2877 	sym_op->cipher.data.offset = 0;
2878 	sym_op->auth.data.length = auth_len;
2879 	sym_op->auth.data.offset = 0;
2880 
2881 	return 0;
2882 }
2883 
2884 static int
2885 create_zuc_cipher_hash_generate_operation(
2886 		const struct wireless_test_data *tdata)
2887 {
2888 	return create_wireless_cipher_hash_operation(tdata,
2889 		RTE_CRYPTO_AUTH_OP_GENERATE);
2890 }
2891 
2892 static int
2893 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2894 		const unsigned auth_tag_len,
2895 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2896 		unsigned data_pad_len,
2897 		enum rte_crypto_auth_operation op,
2898 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2899 		const unsigned cipher_len, const unsigned cipher_offset,
2900 		const unsigned auth_len, const unsigned auth_offset)
2901 {
2902 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2903 	struct crypto_unittest_params *ut_params = &unittest_params;
2904 
2905 	enum rte_crypto_cipher_algorithm cipher_algo =
2906 			ut_params->cipher_xform.cipher.algo;
2907 	enum rte_crypto_auth_algorithm auth_algo =
2908 			ut_params->auth_xform.auth.algo;
2909 
2910 	/* Generate Crypto op data structure */
2911 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2912 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2913 	TEST_ASSERT_NOT_NULL(ut_params->op,
2914 			"Failed to allocate pktmbuf offload");
2915 	/* Set crypto operation data parameters */
2916 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2917 
2918 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2919 
2920 	/* set crypto operation source mbuf */
2921 	sym_op->m_src = ut_params->ibuf;
2922 
2923 	/* digest */
2924 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2925 			ut_params->ibuf, auth_tag_len);
2926 
2927 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2928 			"no room to append auth tag");
2929 	ut_params->digest = sym_op->auth.digest.data;
2930 
2931 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2932 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2933 				ut_params->ibuf, data_pad_len);
2934 	} else {
2935 		struct rte_mbuf *m = ut_params->ibuf;
2936 		unsigned int offset = data_pad_len;
2937 
2938 		while (offset > m->data_len && m->next != NULL) {
2939 			offset -= m->data_len;
2940 			m = m->next;
2941 		}
2942 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2943 			m, offset);
2944 	}
2945 
2946 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2947 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2948 	else
2949 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2950 
2951 	debug_hexdump(stdout, "digest:",
2952 		sym_op->auth.digest.data,
2953 		auth_tag_len);
2954 
2955 	/* Copy cipher and auth IVs at the end of the crypto operation */
2956 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2957 						IV_OFFSET);
2958 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2959 	iv_ptr += cipher_iv_len;
2960 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2961 
2962 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2963 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2964 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2965 		sym_op->cipher.data.length = cipher_len;
2966 		sym_op->cipher.data.offset = cipher_offset;
2967 	} else {
2968 		sym_op->cipher.data.length = cipher_len >> 3;
2969 		sym_op->cipher.data.offset = cipher_offset >> 3;
2970 	}
2971 
2972 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2973 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2974 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2975 		sym_op->auth.data.length = auth_len;
2976 		sym_op->auth.data.offset = auth_offset;
2977 	} else {
2978 		sym_op->auth.data.length = auth_len >> 3;
2979 		sym_op->auth.data.offset = auth_offset >> 3;
2980 	}
2981 
2982 	return 0;
2983 }
2984 
2985 static int
2986 create_wireless_algo_auth_cipher_operation(
2987 		const uint8_t *auth_tag, unsigned int auth_tag_len,
2988 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2989 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2990 		unsigned int data_pad_len,
2991 		unsigned int cipher_len, unsigned int cipher_offset,
2992 		unsigned int auth_len, unsigned int auth_offset,
2993 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2994 {
2995 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2996 	struct crypto_unittest_params *ut_params = &unittest_params;
2997 
2998 	enum rte_crypto_cipher_algorithm cipher_algo =
2999 			ut_params->cipher_xform.cipher.algo;
3000 	enum rte_crypto_auth_algorithm auth_algo =
3001 			ut_params->auth_xform.auth.algo;
3002 
3003 	/* Generate Crypto op data structure */
3004 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3005 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3006 	TEST_ASSERT_NOT_NULL(ut_params->op,
3007 			"Failed to allocate pktmbuf offload");
3008 
3009 	/* Set crypto operation data parameters */
3010 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3011 
3012 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3013 
3014 	/* set crypto operation mbufs */
3015 	sym_op->m_src = ut_params->ibuf;
3016 	if (op_mode == OUT_OF_PLACE)
3017 		sym_op->m_dst = ut_params->obuf;
3018 
3019 	/* digest */
3020 	if (!do_sgl) {
3021 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3022 			(op_mode == IN_PLACE ?
3023 				ut_params->ibuf : ut_params->obuf),
3024 			uint8_t *, data_pad_len);
3025 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3026 			(op_mode == IN_PLACE ?
3027 				ut_params->ibuf : ut_params->obuf),
3028 			data_pad_len);
3029 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3030 	} else {
3031 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3032 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3033 				sym_op->m_src : sym_op->m_dst);
3034 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3035 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3036 			sgl_buf = sgl_buf->next;
3037 		}
3038 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3039 				uint8_t *, remaining_off);
3040 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3041 				remaining_off);
3042 		memset(sym_op->auth.digest.data, 0, remaining_off);
3043 		while (sgl_buf->next != NULL) {
3044 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3045 				0, rte_pktmbuf_data_len(sgl_buf));
3046 			sgl_buf = sgl_buf->next;
3047 		}
3048 	}
3049 
3050 	/* Copy digest for the verification */
3051 	if (verify)
3052 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3053 
3054 	/* Copy cipher and auth IVs at the end of the crypto operation */
3055 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3056 			ut_params->op, uint8_t *, IV_OFFSET);
3057 
3058 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3059 	iv_ptr += cipher_iv_len;
3060 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3061 
3062 	/* Only copy over the offset data needed from src to dst in OOP,
3063 	 * if the auth and cipher offsets are not aligned
3064 	 */
3065 	if (op_mode == OUT_OF_PLACE) {
3066 		if (cipher_offset > auth_offset)
3067 			rte_memcpy(
3068 				rte_pktmbuf_mtod_offset(
3069 					sym_op->m_dst,
3070 					uint8_t *, auth_offset >> 3),
3071 				rte_pktmbuf_mtod_offset(
3072 					sym_op->m_src,
3073 					uint8_t *, auth_offset >> 3),
3074 				((cipher_offset >> 3) - (auth_offset >> 3)));
3075 	}
3076 
3077 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3078 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3079 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3080 		sym_op->cipher.data.length = cipher_len;
3081 		sym_op->cipher.data.offset = cipher_offset;
3082 	} else {
3083 		sym_op->cipher.data.length = cipher_len >> 3;
3084 		sym_op->cipher.data.offset = cipher_offset >> 3;
3085 	}
3086 
3087 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3088 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3089 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3090 		sym_op->auth.data.length = auth_len;
3091 		sym_op->auth.data.offset = auth_offset;
3092 	} else {
3093 		sym_op->auth.data.length = auth_len >> 3;
3094 		sym_op->auth.data.offset = auth_offset >> 3;
3095 	}
3096 
3097 	return 0;
3098 }
3099 
3100 static int
3101 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3102 {
3103 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3104 	struct crypto_unittest_params *ut_params = &unittest_params;
3105 
3106 	int retval;
3107 	unsigned plaintext_pad_len;
3108 	unsigned plaintext_len;
3109 	uint8_t *plaintext;
3110 	struct rte_cryptodev_info dev_info;
3111 
3112 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3113 	uint64_t feat_flags = dev_info.feature_flags;
3114 
3115 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3116 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3117 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3118 		return TEST_SKIPPED;
3119 	}
3120 
3121 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3122 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3123 		printf("Device doesn't support RAW data-path APIs.\n");
3124 		return TEST_SKIPPED;
3125 	}
3126 
3127 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3128 		return TEST_SKIPPED;
3129 
3130 	/* Verify the capabilities */
3131 	struct rte_cryptodev_sym_capability_idx cap_idx;
3132 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3133 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3134 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3135 			&cap_idx) == NULL)
3136 		return TEST_SKIPPED;
3137 
3138 	/* Create SNOW 3G session */
3139 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3140 			tdata->key.data, tdata->key.len,
3141 			tdata->auth_iv.len, tdata->digest.len,
3142 			RTE_CRYPTO_AUTH_OP_GENERATE,
3143 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3144 	if (retval < 0)
3145 		return retval;
3146 
3147 	/* alloc mbuf and set payload */
3148 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3149 
3150 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3151 	rte_pktmbuf_tailroom(ut_params->ibuf));
3152 
3153 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3154 	/* Append data which is padded to a multiple of */
3155 	/* the algorithms block size */
3156 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3157 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3158 				plaintext_pad_len);
3159 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3160 
3161 	/* Create SNOW 3G operation */
3162 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3163 			tdata->auth_iv.data, tdata->auth_iv.len,
3164 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3165 			tdata->validAuthLenInBits.len,
3166 			0);
3167 	if (retval < 0)
3168 		return retval;
3169 
3170 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3171 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3172 				ut_params->op, 0, 1, 1, 0);
3173 	else
3174 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3175 				ut_params->op);
3176 	ut_params->obuf = ut_params->op->sym->m_src;
3177 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3178 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3179 			+ plaintext_pad_len;
3180 
3181 	/* Validate obuf */
3182 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3183 	ut_params->digest,
3184 	tdata->digest.data,
3185 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3186 	"SNOW 3G Generated auth tag not as expected");
3187 
3188 	return 0;
3189 }
3190 
3191 static int
3192 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3193 {
3194 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3195 	struct crypto_unittest_params *ut_params = &unittest_params;
3196 
3197 	int retval;
3198 	unsigned plaintext_pad_len;
3199 	unsigned plaintext_len;
3200 	uint8_t *plaintext;
3201 	struct rte_cryptodev_info dev_info;
3202 
3203 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3204 	uint64_t feat_flags = dev_info.feature_flags;
3205 
3206 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3207 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3208 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3209 		return TEST_SKIPPED;
3210 	}
3211 
3212 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3213 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3214 		printf("Device doesn't support RAW data-path APIs.\n");
3215 		return TEST_SKIPPED;
3216 	}
3217 
3218 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3219 		return TEST_SKIPPED;
3220 
3221 	/* Verify the capabilities */
3222 	struct rte_cryptodev_sym_capability_idx cap_idx;
3223 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3224 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3225 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3226 			&cap_idx) == NULL)
3227 		return TEST_SKIPPED;
3228 
3229 	/* Create SNOW 3G session */
3230 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3231 				tdata->key.data, tdata->key.len,
3232 				tdata->auth_iv.len, tdata->digest.len,
3233 				RTE_CRYPTO_AUTH_OP_VERIFY,
3234 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3235 	if (retval < 0)
3236 		return retval;
3237 	/* alloc mbuf and set payload */
3238 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3239 
3240 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3241 	rte_pktmbuf_tailroom(ut_params->ibuf));
3242 
3243 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3244 	/* Append data which is padded to a multiple of */
3245 	/* the algorithms block size */
3246 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3247 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3248 				plaintext_pad_len);
3249 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3250 
3251 	/* Create SNOW 3G operation */
3252 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3253 			tdata->digest.len,
3254 			tdata->auth_iv.data, tdata->auth_iv.len,
3255 			plaintext_pad_len,
3256 			RTE_CRYPTO_AUTH_OP_VERIFY,
3257 			tdata->validAuthLenInBits.len,
3258 			0);
3259 	if (retval < 0)
3260 		return retval;
3261 
3262 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3263 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3264 				ut_params->op, 0, 1, 1, 0);
3265 	else
3266 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3267 				ut_params->op);
3268 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3269 	ut_params->obuf = ut_params->op->sym->m_src;
3270 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3271 				+ plaintext_pad_len;
3272 
3273 	/* Validate obuf */
3274 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3275 		return 0;
3276 	else
3277 		return -1;
3278 
3279 	return 0;
3280 }
3281 
3282 static int
3283 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3284 {
3285 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3286 	struct crypto_unittest_params *ut_params = &unittest_params;
3287 
3288 	int retval;
3289 	unsigned plaintext_pad_len;
3290 	unsigned plaintext_len;
3291 	uint8_t *plaintext;
3292 	struct rte_cryptodev_info dev_info;
3293 
3294 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3295 	uint64_t feat_flags = dev_info.feature_flags;
3296 
3297 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3298 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3299 		printf("Device doesn't support RAW data-path APIs.\n");
3300 		return TEST_SKIPPED;
3301 	}
3302 
3303 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3304 		return TEST_SKIPPED;
3305 
3306 	/* Verify the capabilities */
3307 	struct rte_cryptodev_sym_capability_idx cap_idx;
3308 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3309 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3310 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3311 			&cap_idx) == NULL)
3312 		return TEST_SKIPPED;
3313 
3314 	/* Create KASUMI session */
3315 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3316 			tdata->key.data, tdata->key.len,
3317 			0, tdata->digest.len,
3318 			RTE_CRYPTO_AUTH_OP_GENERATE,
3319 			RTE_CRYPTO_AUTH_KASUMI_F9);
3320 	if (retval < 0)
3321 		return retval;
3322 
3323 	/* alloc mbuf and set payload */
3324 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3325 
3326 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3327 	rte_pktmbuf_tailroom(ut_params->ibuf));
3328 
3329 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3330 	/* Append data which is padded to a multiple of */
3331 	/* the algorithms block size */
3332 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3333 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3334 				plaintext_pad_len);
3335 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3336 
3337 	/* Create KASUMI operation */
3338 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3339 			NULL, 0,
3340 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3341 			tdata->plaintext.len,
3342 			0);
3343 	if (retval < 0)
3344 		return retval;
3345 
3346 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3347 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3348 			ut_params->op);
3349 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3350 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3351 				ut_params->op, 0, 1, 1, 0);
3352 	else
3353 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3354 			ut_params->op);
3355 
3356 	ut_params->obuf = ut_params->op->sym->m_src;
3357 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3358 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3359 			+ plaintext_pad_len;
3360 
3361 	/* Validate obuf */
3362 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3363 	ut_params->digest,
3364 	tdata->digest.data,
3365 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3366 	"KASUMI Generated auth tag not as expected");
3367 
3368 	return 0;
3369 }
3370 
3371 static int
3372 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3373 {
3374 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3375 	struct crypto_unittest_params *ut_params = &unittest_params;
3376 
3377 	int retval;
3378 	unsigned plaintext_pad_len;
3379 	unsigned plaintext_len;
3380 	uint8_t *plaintext;
3381 	struct rte_cryptodev_info dev_info;
3382 
3383 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3384 	uint64_t feat_flags = dev_info.feature_flags;
3385 
3386 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3387 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3388 		printf("Device doesn't support RAW data-path APIs.\n");
3389 		return TEST_SKIPPED;
3390 	}
3391 
3392 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3393 		return TEST_SKIPPED;
3394 
3395 	/* Verify the capabilities */
3396 	struct rte_cryptodev_sym_capability_idx cap_idx;
3397 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3398 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3399 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3400 			&cap_idx) == NULL)
3401 		return TEST_SKIPPED;
3402 
3403 	/* Create KASUMI session */
3404 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3405 				tdata->key.data, tdata->key.len,
3406 				0, tdata->digest.len,
3407 				RTE_CRYPTO_AUTH_OP_VERIFY,
3408 				RTE_CRYPTO_AUTH_KASUMI_F9);
3409 	if (retval < 0)
3410 		return retval;
3411 	/* alloc mbuf and set payload */
3412 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3413 
3414 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3415 	rte_pktmbuf_tailroom(ut_params->ibuf));
3416 
3417 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3418 	/* Append data which is padded to a multiple */
3419 	/* of the algorithms block size */
3420 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3421 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3422 				plaintext_pad_len);
3423 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3424 
3425 	/* Create KASUMI operation */
3426 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3427 			tdata->digest.len,
3428 			NULL, 0,
3429 			plaintext_pad_len,
3430 			RTE_CRYPTO_AUTH_OP_VERIFY,
3431 			tdata->plaintext.len,
3432 			0);
3433 	if (retval < 0)
3434 		return retval;
3435 
3436 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3437 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3438 				ut_params->op, 0, 1, 1, 0);
3439 	else
3440 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3441 				ut_params->op);
3442 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3443 	ut_params->obuf = ut_params->op->sym->m_src;
3444 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3445 				+ plaintext_pad_len;
3446 
3447 	/* Validate obuf */
3448 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3449 		return 0;
3450 	else
3451 		return -1;
3452 
3453 	return 0;
3454 }
3455 
3456 static int
3457 test_snow3g_hash_generate_test_case_1(void)
3458 {
3459 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3460 }
3461 
3462 static int
3463 test_snow3g_hash_generate_test_case_2(void)
3464 {
3465 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3466 }
3467 
3468 static int
3469 test_snow3g_hash_generate_test_case_3(void)
3470 {
3471 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3472 }
3473 
3474 static int
3475 test_snow3g_hash_generate_test_case_4(void)
3476 {
3477 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3478 }
3479 
3480 static int
3481 test_snow3g_hash_generate_test_case_5(void)
3482 {
3483 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3484 }
3485 
3486 static int
3487 test_snow3g_hash_generate_test_case_6(void)
3488 {
3489 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3490 }
3491 
3492 static int
3493 test_snow3g_hash_verify_test_case_1(void)
3494 {
3495 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3496 
3497 }
3498 
3499 static int
3500 test_snow3g_hash_verify_test_case_2(void)
3501 {
3502 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3503 }
3504 
3505 static int
3506 test_snow3g_hash_verify_test_case_3(void)
3507 {
3508 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3509 }
3510 
3511 static int
3512 test_snow3g_hash_verify_test_case_4(void)
3513 {
3514 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3515 }
3516 
3517 static int
3518 test_snow3g_hash_verify_test_case_5(void)
3519 {
3520 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3521 }
3522 
3523 static int
3524 test_snow3g_hash_verify_test_case_6(void)
3525 {
3526 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3527 }
3528 
3529 static int
3530 test_kasumi_hash_generate_test_case_1(void)
3531 {
3532 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3533 }
3534 
3535 static int
3536 test_kasumi_hash_generate_test_case_2(void)
3537 {
3538 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3539 }
3540 
3541 static int
3542 test_kasumi_hash_generate_test_case_3(void)
3543 {
3544 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3545 }
3546 
3547 static int
3548 test_kasumi_hash_generate_test_case_4(void)
3549 {
3550 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3551 }
3552 
3553 static int
3554 test_kasumi_hash_generate_test_case_5(void)
3555 {
3556 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3557 }
3558 
3559 static int
3560 test_kasumi_hash_generate_test_case_6(void)
3561 {
3562 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3563 }
3564 
3565 static int
3566 test_kasumi_hash_verify_test_case_1(void)
3567 {
3568 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3569 }
3570 
3571 static int
3572 test_kasumi_hash_verify_test_case_2(void)
3573 {
3574 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3575 }
3576 
3577 static int
3578 test_kasumi_hash_verify_test_case_3(void)
3579 {
3580 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3581 }
3582 
3583 static int
3584 test_kasumi_hash_verify_test_case_4(void)
3585 {
3586 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3587 }
3588 
3589 static int
3590 test_kasumi_hash_verify_test_case_5(void)
3591 {
3592 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3593 }
3594 
3595 static int
3596 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3597 {
3598 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3599 	struct crypto_unittest_params *ut_params = &unittest_params;
3600 
3601 	int retval;
3602 	uint8_t *plaintext, *ciphertext;
3603 	unsigned plaintext_pad_len;
3604 	unsigned plaintext_len;
3605 	struct rte_cryptodev_info dev_info;
3606 
3607 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3608 	uint64_t feat_flags = dev_info.feature_flags;
3609 
3610 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3611 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3612 		printf("Device doesn't support RAW data-path APIs.\n");
3613 		return TEST_SKIPPED;
3614 	}
3615 
3616 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3617 		return TEST_SKIPPED;
3618 
3619 	/* Verify the capabilities */
3620 	struct rte_cryptodev_sym_capability_idx cap_idx;
3621 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3622 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3623 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3624 			&cap_idx) == NULL)
3625 		return TEST_SKIPPED;
3626 
3627 	/* Create KASUMI session */
3628 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3629 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3630 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3631 					tdata->key.data, tdata->key.len,
3632 					tdata->cipher_iv.len);
3633 	if (retval < 0)
3634 		return retval;
3635 
3636 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 
3638 	/* Clear mbuf payload */
3639 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3640 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3641 
3642 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3643 	/* Append data which is padded to a multiple */
3644 	/* of the algorithms block size */
3645 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3646 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3647 				plaintext_pad_len);
3648 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3649 
3650 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3651 
3652 	/* Create KASUMI operation */
3653 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3654 				tdata->cipher_iv.len,
3655 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3656 				tdata->validCipherOffsetInBits.len);
3657 	if (retval < 0)
3658 		return retval;
3659 
3660 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3661 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3662 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3663 	else
3664 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3665 				ut_params->op);
3666 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3667 
3668 	ut_params->obuf = ut_params->op->sym->m_dst;
3669 	if (ut_params->obuf)
3670 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3671 	else
3672 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3673 
3674 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3675 
3676 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3677 				(tdata->validCipherOffsetInBits.len >> 3);
3678 	/* Validate obuf */
3679 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3680 		ciphertext,
3681 		reference_ciphertext,
3682 		tdata->validCipherLenInBits.len,
3683 		"KASUMI Ciphertext data not as expected");
3684 	return 0;
3685 }
3686 
3687 static int
3688 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3689 {
3690 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3691 	struct crypto_unittest_params *ut_params = &unittest_params;
3692 
3693 	int retval;
3694 
3695 	unsigned int plaintext_pad_len;
3696 	unsigned int plaintext_len;
3697 
3698 	uint8_t buffer[10000];
3699 	const uint8_t *ciphertext;
3700 
3701 	struct rte_cryptodev_info dev_info;
3702 
3703 	/* Verify the capabilities */
3704 	struct rte_cryptodev_sym_capability_idx cap_idx;
3705 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3706 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3707 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3708 			&cap_idx) == NULL)
3709 		return TEST_SKIPPED;
3710 
3711 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3712 
3713 	uint64_t feat_flags = dev_info.feature_flags;
3714 
3715 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3716 		printf("Device doesn't support in-place scatter-gather. "
3717 				"Test Skipped.\n");
3718 		return TEST_SKIPPED;
3719 	}
3720 
3721 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3722 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3723 		printf("Device doesn't support RAW data-path APIs.\n");
3724 		return TEST_SKIPPED;
3725 	}
3726 
3727 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3728 		return TEST_SKIPPED;
3729 
3730 	/* Create KASUMI session */
3731 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3732 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3733 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3734 					tdata->key.data, tdata->key.len,
3735 					tdata->cipher_iv.len);
3736 	if (retval < 0)
3737 		return retval;
3738 
3739 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3740 
3741 
3742 	/* Append data which is padded to a multiple */
3743 	/* of the algorithms block size */
3744 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3745 
3746 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3747 			plaintext_pad_len, 10, 0);
3748 
3749 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3750 
3751 	/* Create KASUMI operation */
3752 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3753 				tdata->cipher_iv.len,
3754 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3755 				tdata->validCipherOffsetInBits.len);
3756 	if (retval < 0)
3757 		return retval;
3758 
3759 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3760 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3761 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3762 	else
3763 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3764 						ut_params->op);
3765 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3766 
3767 	ut_params->obuf = ut_params->op->sym->m_dst;
3768 
3769 	if (ut_params->obuf)
3770 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3771 				plaintext_len, buffer);
3772 	else
3773 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3774 				tdata->validCipherOffsetInBits.len >> 3,
3775 				plaintext_len, buffer);
3776 
3777 	/* Validate obuf */
3778 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3779 
3780 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3781 				(tdata->validCipherOffsetInBits.len >> 3);
3782 	/* Validate obuf */
3783 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3784 		ciphertext,
3785 		reference_ciphertext,
3786 		tdata->validCipherLenInBits.len,
3787 		"KASUMI Ciphertext data not as expected");
3788 	return 0;
3789 }
3790 
3791 static int
3792 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3793 {
3794 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3795 	struct crypto_unittest_params *ut_params = &unittest_params;
3796 
3797 	int retval;
3798 	uint8_t *plaintext, *ciphertext;
3799 	unsigned plaintext_pad_len;
3800 	unsigned plaintext_len;
3801 
3802 	/* Verify the capabilities */
3803 	struct rte_cryptodev_sym_capability_idx cap_idx;
3804 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3805 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3806 	/* Data-path service does not support OOP */
3807 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3808 			&cap_idx) == NULL)
3809 		return TEST_SKIPPED;
3810 
3811 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3812 		return TEST_SKIPPED;
3813 
3814 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3815 		return TEST_SKIPPED;
3816 
3817 	/* Create KASUMI session */
3818 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3819 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3820 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3821 					tdata->key.data, tdata->key.len,
3822 					tdata->cipher_iv.len);
3823 	if (retval < 0)
3824 		return retval;
3825 
3826 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3827 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3828 
3829 	/* Clear mbuf payload */
3830 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3831 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3832 
3833 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3834 	/* Append data which is padded to a multiple */
3835 	/* of the algorithms block size */
3836 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3837 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3838 				plaintext_pad_len);
3839 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3840 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3841 
3842 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3843 
3844 	/* Create KASUMI operation */
3845 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3846 				tdata->cipher_iv.len,
3847 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3848 				tdata->validCipherOffsetInBits.len);
3849 	if (retval < 0)
3850 		return retval;
3851 
3852 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3853 						ut_params->op);
3854 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3855 
3856 	ut_params->obuf = ut_params->op->sym->m_dst;
3857 	if (ut_params->obuf)
3858 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3859 	else
3860 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3861 
3862 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3863 
3864 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3865 				(tdata->validCipherOffsetInBits.len >> 3);
3866 	/* Validate obuf */
3867 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3868 		ciphertext,
3869 		reference_ciphertext,
3870 		tdata->validCipherLenInBits.len,
3871 		"KASUMI Ciphertext data not as expected");
3872 	return 0;
3873 }
3874 
3875 static int
3876 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3877 {
3878 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3879 	struct crypto_unittest_params *ut_params = &unittest_params;
3880 
3881 	int retval;
3882 	unsigned int plaintext_pad_len;
3883 	unsigned int plaintext_len;
3884 
3885 	const uint8_t *ciphertext;
3886 	uint8_t buffer[2048];
3887 
3888 	struct rte_cryptodev_info dev_info;
3889 
3890 	/* Verify the capabilities */
3891 	struct rte_cryptodev_sym_capability_idx cap_idx;
3892 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3893 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3894 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3895 			&cap_idx) == NULL)
3896 		return TEST_SKIPPED;
3897 
3898 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3899 		return TEST_SKIPPED;
3900 
3901 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3902 		return TEST_SKIPPED;
3903 
3904 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3905 
3906 	uint64_t feat_flags = dev_info.feature_flags;
3907 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3908 		printf("Device doesn't support out-of-place scatter-gather "
3909 				"in both input and output mbufs. "
3910 				"Test Skipped.\n");
3911 		return TEST_SKIPPED;
3912 	}
3913 
3914 	/* Create KASUMI session */
3915 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3916 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3917 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3918 					tdata->key.data, tdata->key.len,
3919 					tdata->cipher_iv.len);
3920 	if (retval < 0)
3921 		return retval;
3922 
3923 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3924 	/* Append data which is padded to a multiple */
3925 	/* of the algorithms block size */
3926 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3927 
3928 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3929 			plaintext_pad_len, 10, 0);
3930 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3931 			plaintext_pad_len, 3, 0);
3932 
3933 	/* Append data which is padded to a multiple */
3934 	/* of the algorithms block size */
3935 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3936 
3937 	/* Create KASUMI operation */
3938 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3939 				tdata->cipher_iv.len,
3940 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3941 				tdata->validCipherOffsetInBits.len);
3942 	if (retval < 0)
3943 		return retval;
3944 
3945 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3946 						ut_params->op);
3947 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3948 
3949 	ut_params->obuf = ut_params->op->sym->m_dst;
3950 	if (ut_params->obuf)
3951 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3952 				plaintext_pad_len, buffer);
3953 	else
3954 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3955 				tdata->validCipherOffsetInBits.len >> 3,
3956 				plaintext_pad_len, buffer);
3957 
3958 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3959 				(tdata->validCipherOffsetInBits.len >> 3);
3960 	/* Validate obuf */
3961 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3962 		ciphertext,
3963 		reference_ciphertext,
3964 		tdata->validCipherLenInBits.len,
3965 		"KASUMI Ciphertext data not as expected");
3966 	return 0;
3967 }
3968 
3969 
3970 static int
3971 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3972 {
3973 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3974 	struct crypto_unittest_params *ut_params = &unittest_params;
3975 
3976 	int retval;
3977 	uint8_t *ciphertext, *plaintext;
3978 	unsigned ciphertext_pad_len;
3979 	unsigned ciphertext_len;
3980 
3981 	/* Verify the capabilities */
3982 	struct rte_cryptodev_sym_capability_idx cap_idx;
3983 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3984 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3985 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3986 			&cap_idx) == NULL)
3987 		return TEST_SKIPPED;
3988 
3989 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3990 		return TEST_SKIPPED;
3991 
3992 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3993 		return TEST_SKIPPED;
3994 
3995 	/* Create KASUMI session */
3996 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3997 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3998 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3999 					tdata->key.data, tdata->key.len,
4000 					tdata->cipher_iv.len);
4001 	if (retval < 0)
4002 		return retval;
4003 
4004 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4005 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4006 
4007 	/* Clear mbuf payload */
4008 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4009 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4010 
4011 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4012 	/* Append data which is padded to a multiple */
4013 	/* of the algorithms block size */
4014 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4015 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4016 				ciphertext_pad_len);
4017 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4018 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4019 
4020 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4021 
4022 	/* Create KASUMI operation */
4023 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4024 				tdata->cipher_iv.len,
4025 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4026 				tdata->validCipherOffsetInBits.len);
4027 	if (retval < 0)
4028 		return retval;
4029 
4030 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4031 						ut_params->op);
4032 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4033 
4034 	ut_params->obuf = ut_params->op->sym->m_dst;
4035 	if (ut_params->obuf)
4036 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4037 	else
4038 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4039 
4040 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4041 
4042 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4043 				(tdata->validCipherOffsetInBits.len >> 3);
4044 	/* Validate obuf */
4045 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4046 		plaintext,
4047 		reference_plaintext,
4048 		tdata->validCipherLenInBits.len,
4049 		"KASUMI Plaintext data not as expected");
4050 	return 0;
4051 }
4052 
4053 static int
4054 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4055 {
4056 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4057 	struct crypto_unittest_params *ut_params = &unittest_params;
4058 
4059 	int retval;
4060 	uint8_t *ciphertext, *plaintext;
4061 	unsigned ciphertext_pad_len;
4062 	unsigned ciphertext_len;
4063 	struct rte_cryptodev_info dev_info;
4064 
4065 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4066 	uint64_t feat_flags = dev_info.feature_flags;
4067 
4068 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4069 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4070 		printf("Device doesn't support RAW data-path APIs.\n");
4071 		return TEST_SKIPPED;
4072 	}
4073 
4074 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4075 		return TEST_SKIPPED;
4076 
4077 	/* Verify the capabilities */
4078 	struct rte_cryptodev_sym_capability_idx cap_idx;
4079 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4080 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4081 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4082 			&cap_idx) == NULL)
4083 		return TEST_SKIPPED;
4084 
4085 	/* Create KASUMI session */
4086 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4087 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4088 					RTE_CRYPTO_CIPHER_KASUMI_F8,
4089 					tdata->key.data, tdata->key.len,
4090 					tdata->cipher_iv.len);
4091 	if (retval < 0)
4092 		return retval;
4093 
4094 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4095 
4096 	/* Clear mbuf payload */
4097 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4098 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4099 
4100 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4101 	/* Append data which is padded to a multiple */
4102 	/* of the algorithms block size */
4103 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4104 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4105 				ciphertext_pad_len);
4106 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4107 
4108 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4109 
4110 	/* Create KASUMI operation */
4111 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4112 			tdata->cipher_iv.len,
4113 			RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4114 			tdata->validCipherOffsetInBits.len);
4115 	if (retval < 0)
4116 		return retval;
4117 
4118 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4119 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4120 				ut_params->op, 1, 0, 1, 0);
4121 	else
4122 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4123 						ut_params->op);
4124 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4125 
4126 	ut_params->obuf = ut_params->op->sym->m_dst;
4127 	if (ut_params->obuf)
4128 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4129 	else
4130 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4131 
4132 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4133 
4134 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4135 				(tdata->validCipherOffsetInBits.len >> 3);
4136 	/* Validate obuf */
4137 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4138 		plaintext,
4139 		reference_plaintext,
4140 		tdata->validCipherLenInBits.len,
4141 		"KASUMI Plaintext data not as expected");
4142 	return 0;
4143 }
4144 
4145 static int
4146 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4147 {
4148 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4149 	struct crypto_unittest_params *ut_params = &unittest_params;
4150 
4151 	int retval;
4152 	uint8_t *plaintext, *ciphertext;
4153 	unsigned plaintext_pad_len;
4154 	unsigned plaintext_len;
4155 	struct rte_cryptodev_info dev_info;
4156 
4157 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4158 	uint64_t feat_flags = dev_info.feature_flags;
4159 
4160 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4161 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4162 		printf("Device doesn't support RAW data-path APIs.\n");
4163 		return TEST_SKIPPED;
4164 	}
4165 
4166 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4167 		return TEST_SKIPPED;
4168 
4169 	/* Verify the capabilities */
4170 	struct rte_cryptodev_sym_capability_idx cap_idx;
4171 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4172 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4173 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4174 			&cap_idx) == NULL)
4175 		return TEST_SKIPPED;
4176 
4177 	/* Create SNOW 3G session */
4178 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4179 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4180 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4181 					tdata->key.data, tdata->key.len,
4182 					tdata->cipher_iv.len);
4183 	if (retval < 0)
4184 		return retval;
4185 
4186 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4187 
4188 	/* Clear mbuf payload */
4189 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4190 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4191 
4192 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4193 	/* Append data which is padded to a multiple of */
4194 	/* the algorithms block size */
4195 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4196 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4197 				plaintext_pad_len);
4198 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4199 
4200 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4201 
4202 	/* Create SNOW 3G operation */
4203 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4204 					tdata->cipher_iv.len,
4205 					tdata->validCipherLenInBits.len,
4206 					0);
4207 	if (retval < 0)
4208 		return retval;
4209 
4210 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4211 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4212 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4213 	else
4214 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4215 						ut_params->op);
4216 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4217 
4218 	ut_params->obuf = ut_params->op->sym->m_dst;
4219 	if (ut_params->obuf)
4220 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4221 	else
4222 		ciphertext = plaintext;
4223 
4224 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4225 
4226 	/* Validate obuf */
4227 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4228 		ciphertext,
4229 		tdata->ciphertext.data,
4230 		tdata->validDataLenInBits.len,
4231 		"SNOW 3G Ciphertext data not as expected");
4232 	return 0;
4233 }
4234 
4235 
4236 static int
4237 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4238 {
4239 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4240 	struct crypto_unittest_params *ut_params = &unittest_params;
4241 	uint8_t *plaintext, *ciphertext;
4242 
4243 	int retval;
4244 	unsigned plaintext_pad_len;
4245 	unsigned plaintext_len;
4246 	struct rte_cryptodev_info dev_info;
4247 
4248 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4249 	uint64_t feat_flags = dev_info.feature_flags;
4250 
4251 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4252 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4253 		printf("Device does not support RAW data-path APIs.\n");
4254 		return -ENOTSUP;
4255 	}
4256 
4257 	/* Verify the capabilities */
4258 	struct rte_cryptodev_sym_capability_idx cap_idx;
4259 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4260 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4261 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4262 			&cap_idx) == NULL)
4263 		return TEST_SKIPPED;
4264 
4265 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4266 		return TEST_SKIPPED;
4267 
4268 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4269 		return TEST_SKIPPED;
4270 
4271 	/* Create SNOW 3G session */
4272 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4273 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4274 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4275 					tdata->key.data, tdata->key.len,
4276 					tdata->cipher_iv.len);
4277 	if (retval < 0)
4278 		return retval;
4279 
4280 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4281 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4282 
4283 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4284 			"Failed to allocate input buffer in mempool");
4285 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4286 			"Failed to allocate output buffer in mempool");
4287 
4288 	/* Clear mbuf payload */
4289 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4290 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4291 
4292 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4293 	/* Append data which is padded to a multiple of */
4294 	/* the algorithms block size */
4295 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4296 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4297 				plaintext_pad_len);
4298 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4299 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4300 
4301 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4302 
4303 	/* Create SNOW 3G operation */
4304 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4305 					tdata->cipher_iv.len,
4306 					tdata->validCipherLenInBits.len,
4307 					0);
4308 	if (retval < 0)
4309 		return retval;
4310 
4311 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4312 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4313 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4314 	else
4315 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4316 						ut_params->op);
4317 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4318 
4319 	ut_params->obuf = ut_params->op->sym->m_dst;
4320 	if (ut_params->obuf)
4321 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4322 	else
4323 		ciphertext = plaintext;
4324 
4325 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4326 
4327 	/* Validate obuf */
4328 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4329 		ciphertext,
4330 		tdata->ciphertext.data,
4331 		tdata->validDataLenInBits.len,
4332 		"SNOW 3G Ciphertext data not as expected");
4333 	return 0;
4334 }
4335 
4336 static int
4337 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4338 {
4339 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4340 	struct crypto_unittest_params *ut_params = &unittest_params;
4341 
4342 	int retval;
4343 	unsigned int plaintext_pad_len;
4344 	unsigned int plaintext_len;
4345 	uint8_t buffer[10000];
4346 	const uint8_t *ciphertext;
4347 
4348 	struct rte_cryptodev_info dev_info;
4349 
4350 	/* Verify the capabilities */
4351 	struct rte_cryptodev_sym_capability_idx cap_idx;
4352 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4353 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4354 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4355 			&cap_idx) == NULL)
4356 		return TEST_SKIPPED;
4357 
4358 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4359 		return TEST_SKIPPED;
4360 
4361 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4362 		return TEST_SKIPPED;
4363 
4364 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4365 
4366 	uint64_t feat_flags = dev_info.feature_flags;
4367 
4368 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4369 		printf("Device doesn't support out-of-place scatter-gather "
4370 				"in both input and output mbufs. "
4371 				"Test Skipped.\n");
4372 		return TEST_SKIPPED;
4373 	}
4374 
4375 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4376 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4377 		printf("Device does not support RAW data-path APIs.\n");
4378 		return -ENOTSUP;
4379 	}
4380 
4381 	/* Create SNOW 3G session */
4382 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4383 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4384 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4385 					tdata->key.data, tdata->key.len,
4386 					tdata->cipher_iv.len);
4387 	if (retval < 0)
4388 		return retval;
4389 
4390 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4391 	/* Append data which is padded to a multiple of */
4392 	/* the algorithms block size */
4393 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4394 
4395 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4396 			plaintext_pad_len, 10, 0);
4397 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4398 			plaintext_pad_len, 3, 0);
4399 
4400 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4401 			"Failed to allocate input buffer in mempool");
4402 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4403 			"Failed to allocate output buffer in mempool");
4404 
4405 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4406 
4407 	/* Create SNOW 3G operation */
4408 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4409 					tdata->cipher_iv.len,
4410 					tdata->validCipherLenInBits.len,
4411 					0);
4412 	if (retval < 0)
4413 		return retval;
4414 
4415 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4416 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4417 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4418 	else
4419 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4420 						ut_params->op);
4421 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4422 
4423 	ut_params->obuf = ut_params->op->sym->m_dst;
4424 	if (ut_params->obuf)
4425 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4426 				plaintext_len, buffer);
4427 	else
4428 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4429 				plaintext_len, buffer);
4430 
4431 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4432 
4433 	/* Validate obuf */
4434 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4435 		ciphertext,
4436 		tdata->ciphertext.data,
4437 		tdata->validDataLenInBits.len,
4438 		"SNOW 3G Ciphertext data not as expected");
4439 
4440 	return 0;
4441 }
4442 
4443 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4444 static void
4445 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4446 {
4447 	uint8_t curr_byte, prev_byte;
4448 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4449 	uint8_t lower_byte_mask = (1 << offset) - 1;
4450 	unsigned i;
4451 
4452 	prev_byte = buffer[0];
4453 	buffer[0] >>= offset;
4454 
4455 	for (i = 1; i < length_in_bytes; i++) {
4456 		curr_byte = buffer[i];
4457 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4458 				(curr_byte >> offset);
4459 		prev_byte = curr_byte;
4460 	}
4461 }
4462 
4463 static int
4464 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4465 {
4466 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4467 	struct crypto_unittest_params *ut_params = &unittest_params;
4468 	uint8_t *plaintext, *ciphertext;
4469 	int retval;
4470 	uint32_t plaintext_len;
4471 	uint32_t plaintext_pad_len;
4472 	uint8_t extra_offset = 4;
4473 	uint8_t *expected_ciphertext_shifted;
4474 	struct rte_cryptodev_info dev_info;
4475 
4476 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4477 	uint64_t feat_flags = dev_info.feature_flags;
4478 
4479 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4480 			((tdata->validDataLenInBits.len % 8) != 0)) {
4481 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4482 		return TEST_SKIPPED;
4483 	}
4484 
4485 	/* Verify the capabilities */
4486 	struct rte_cryptodev_sym_capability_idx cap_idx;
4487 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4488 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4489 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4490 			&cap_idx) == NULL)
4491 		return TEST_SKIPPED;
4492 
4493 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4494 		return TEST_SKIPPED;
4495 
4496 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4497 		return TEST_SKIPPED;
4498 
4499 	/* Create SNOW 3G session */
4500 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4501 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4502 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4503 					tdata->key.data, tdata->key.len,
4504 					tdata->cipher_iv.len);
4505 	if (retval < 0)
4506 		return retval;
4507 
4508 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4509 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4510 
4511 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4512 			"Failed to allocate input buffer in mempool");
4513 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4514 			"Failed to allocate output buffer in mempool");
4515 
4516 	/* Clear mbuf payload */
4517 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4518 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4519 
4520 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4521 	/*
4522 	 * Append data which is padded to a
4523 	 * multiple of the algorithms block size
4524 	 */
4525 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4526 
4527 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4528 						plaintext_pad_len);
4529 
4530 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4531 
4532 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4533 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4534 
4535 #ifdef RTE_APP_TEST_DEBUG
4536 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4537 #endif
4538 	/* Create SNOW 3G operation */
4539 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4540 					tdata->cipher_iv.len,
4541 					tdata->validCipherLenInBits.len,
4542 					extra_offset);
4543 	if (retval < 0)
4544 		return retval;
4545 
4546 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4547 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4548 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4549 	else
4550 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4551 						ut_params->op);
4552 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4553 
4554 	ut_params->obuf = ut_params->op->sym->m_dst;
4555 	if (ut_params->obuf)
4556 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4557 	else
4558 		ciphertext = plaintext;
4559 
4560 #ifdef RTE_APP_TEST_DEBUG
4561 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4562 #endif
4563 
4564 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4565 
4566 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4567 			"failed to reserve memory for ciphertext shifted\n");
4568 
4569 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4570 			ceil_byte_length(tdata->ciphertext.len));
4571 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4572 			extra_offset);
4573 	/* Validate obuf */
4574 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4575 		ciphertext,
4576 		expected_ciphertext_shifted,
4577 		tdata->validDataLenInBits.len,
4578 		extra_offset,
4579 		"SNOW 3G Ciphertext data not as expected");
4580 	return 0;
4581 }
4582 
4583 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4584 {
4585 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4586 	struct crypto_unittest_params *ut_params = &unittest_params;
4587 
4588 	int retval;
4589 
4590 	uint8_t *plaintext, *ciphertext;
4591 	unsigned ciphertext_pad_len;
4592 	unsigned ciphertext_len;
4593 	struct rte_cryptodev_info dev_info;
4594 
4595 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4596 	uint64_t feat_flags = dev_info.feature_flags;
4597 
4598 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4599 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4600 		printf("Device doesn't support RAW data-path APIs.\n");
4601 		return TEST_SKIPPED;
4602 	}
4603 
4604 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4605 		return TEST_SKIPPED;
4606 
4607 	/* Verify the capabilities */
4608 	struct rte_cryptodev_sym_capability_idx cap_idx;
4609 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4610 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4611 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4612 			&cap_idx) == NULL)
4613 		return TEST_SKIPPED;
4614 
4615 	/* Create SNOW 3G session */
4616 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4617 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4618 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4619 					tdata->key.data, tdata->key.len,
4620 					tdata->cipher_iv.len);
4621 	if (retval < 0)
4622 		return retval;
4623 
4624 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4625 
4626 	/* Clear mbuf payload */
4627 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4628 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4629 
4630 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4631 	/* Append data which is padded to a multiple of */
4632 	/* the algorithms block size */
4633 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4634 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4635 				ciphertext_pad_len);
4636 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4637 
4638 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4639 
4640 	/* Create SNOW 3G operation */
4641 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4642 					tdata->cipher_iv.len,
4643 					tdata->validCipherLenInBits.len,
4644 					tdata->cipher.offset_bits);
4645 	if (retval < 0)
4646 		return retval;
4647 
4648 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4649 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4650 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4651 	else
4652 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4653 						ut_params->op);
4654 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4655 	ut_params->obuf = ut_params->op->sym->m_dst;
4656 	if (ut_params->obuf)
4657 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4658 	else
4659 		plaintext = ciphertext;
4660 
4661 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4662 
4663 	/* Validate obuf */
4664 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4665 				tdata->plaintext.data,
4666 				tdata->validDataLenInBits.len,
4667 				"SNOW 3G Plaintext data not as expected");
4668 	return 0;
4669 }
4670 
4671 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4672 {
4673 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4674 	struct crypto_unittest_params *ut_params = &unittest_params;
4675 
4676 	int retval;
4677 
4678 	uint8_t *plaintext, *ciphertext;
4679 	unsigned ciphertext_pad_len;
4680 	unsigned ciphertext_len;
4681 	struct rte_cryptodev_info dev_info;
4682 
4683 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4684 	uint64_t feat_flags = dev_info.feature_flags;
4685 
4686 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4687 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4688 		printf("Device does not support RAW data-path APIs.\n");
4689 		return -ENOTSUP;
4690 	}
4691 	/* Verify the capabilities */
4692 	struct rte_cryptodev_sym_capability_idx cap_idx;
4693 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4694 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4695 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4696 			&cap_idx) == NULL)
4697 		return TEST_SKIPPED;
4698 
4699 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4700 		return TEST_SKIPPED;
4701 
4702 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4703 		return TEST_SKIPPED;
4704 
4705 	/* Create SNOW 3G session */
4706 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4707 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4708 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4709 					tdata->key.data, tdata->key.len,
4710 					tdata->cipher_iv.len);
4711 	if (retval < 0)
4712 		return retval;
4713 
4714 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4715 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4716 
4717 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4718 			"Failed to allocate input buffer");
4719 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4720 			"Failed to allocate output buffer");
4721 
4722 	/* Clear mbuf payload */
4723 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4724 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4725 
4726 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4727 		       rte_pktmbuf_tailroom(ut_params->obuf));
4728 
4729 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4730 	/* Append data which is padded to a multiple of */
4731 	/* the algorithms block size */
4732 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4733 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4734 				ciphertext_pad_len);
4735 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4736 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4737 
4738 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4739 
4740 	/* Create SNOW 3G operation */
4741 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4742 					tdata->cipher_iv.len,
4743 					tdata->validCipherLenInBits.len,
4744 					0);
4745 	if (retval < 0)
4746 		return retval;
4747 
4748 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4749 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4750 			ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4751 	else
4752 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4753 						ut_params->op);
4754 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4755 	ut_params->obuf = ut_params->op->sym->m_dst;
4756 	if (ut_params->obuf)
4757 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4758 	else
4759 		plaintext = ciphertext;
4760 
4761 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4762 
4763 	/* Validate obuf */
4764 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4765 				tdata->plaintext.data,
4766 				tdata->validDataLenInBits.len,
4767 				"SNOW 3G Plaintext data not as expected");
4768 	return 0;
4769 }
4770 
4771 static int
4772 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4773 {
4774 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4775 	struct crypto_unittest_params *ut_params = &unittest_params;
4776 
4777 	int retval;
4778 
4779 	uint8_t *plaintext, *ciphertext;
4780 	unsigned int plaintext_pad_len;
4781 	unsigned int plaintext_len;
4782 
4783 	struct rte_cryptodev_info dev_info;
4784 	struct rte_cryptodev_sym_capability_idx cap_idx;
4785 
4786 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4787 	uint64_t feat_flags = dev_info.feature_flags;
4788 
4789 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4790 			((tdata->validAuthLenInBits.len % 8 != 0) ||
4791 			(tdata->validDataLenInBits.len % 8 != 0))) {
4792 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4793 		return TEST_SKIPPED;
4794 	}
4795 
4796 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4797 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4798 		printf("Device doesn't support RAW data-path APIs.\n");
4799 		return TEST_SKIPPED;
4800 	}
4801 
4802 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4803 		return TEST_SKIPPED;
4804 
4805 	/* Check if device supports ZUC EEA3 */
4806 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4807 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4808 
4809 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4810 			&cap_idx) == NULL)
4811 		return TEST_SKIPPED;
4812 
4813 	/* Check if device supports ZUC EIA3 */
4814 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4815 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4816 
4817 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4818 			&cap_idx) == NULL)
4819 		return TEST_SKIPPED;
4820 
4821 	/* Create ZUC session */
4822 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4823 			ts_params->valid_devs[0],
4824 			tdata);
4825 	if (retval != 0)
4826 		return retval;
4827 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4828 
4829 	/* clear mbuf payload */
4830 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4831 			rte_pktmbuf_tailroom(ut_params->ibuf));
4832 
4833 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4834 	/* Append data which is padded to a multiple of */
4835 	/* the algorithms block size */
4836 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4837 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4838 				plaintext_pad_len);
4839 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4840 
4841 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4842 
4843 	/* Create ZUC operation */
4844 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4845 	if (retval < 0)
4846 		return retval;
4847 
4848 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4849 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4850 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4851 	else
4852 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4853 			ut_params->op);
4854 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4855 	ut_params->obuf = ut_params->op->sym->m_src;
4856 	if (ut_params->obuf)
4857 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4858 	else
4859 		ciphertext = plaintext;
4860 
4861 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4862 	/* Validate obuf */
4863 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4864 			ciphertext,
4865 			tdata->ciphertext.data,
4866 			tdata->validDataLenInBits.len,
4867 			"ZUC Ciphertext data not as expected");
4868 
4869 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4870 	    + plaintext_pad_len;
4871 
4872 	/* Validate obuf */
4873 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4874 			ut_params->digest,
4875 			tdata->digest.data,
4876 			4,
4877 			"ZUC Generated auth tag not as expected");
4878 	return 0;
4879 }
4880 
4881 static int
4882 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4883 {
4884 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4885 	struct crypto_unittest_params *ut_params = &unittest_params;
4886 
4887 	int retval;
4888 
4889 	uint8_t *plaintext, *ciphertext;
4890 	unsigned plaintext_pad_len;
4891 	unsigned plaintext_len;
4892 	struct rte_cryptodev_info dev_info;
4893 
4894 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4895 	uint64_t feat_flags = dev_info.feature_flags;
4896 
4897 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4898 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4899 		printf("Device doesn't support RAW data-path APIs.\n");
4900 		return TEST_SKIPPED;
4901 	}
4902 
4903 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4904 		return TEST_SKIPPED;
4905 
4906 	/* Verify the capabilities */
4907 	struct rte_cryptodev_sym_capability_idx cap_idx;
4908 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4909 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4910 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4911 			&cap_idx) == NULL)
4912 		return TEST_SKIPPED;
4913 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4914 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4915 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4916 			&cap_idx) == NULL)
4917 		return TEST_SKIPPED;
4918 
4919 	/* Create SNOW 3G session */
4920 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4921 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4922 			RTE_CRYPTO_AUTH_OP_GENERATE,
4923 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4924 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4925 			tdata->key.data, tdata->key.len,
4926 			tdata->auth_iv.len, tdata->digest.len,
4927 			tdata->cipher_iv.len);
4928 	if (retval != 0)
4929 		return retval;
4930 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4931 
4932 	/* clear mbuf payload */
4933 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4934 			rte_pktmbuf_tailroom(ut_params->ibuf));
4935 
4936 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4937 	/* Append data which is padded to a multiple of */
4938 	/* the algorithms block size */
4939 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4940 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4941 				plaintext_pad_len);
4942 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4943 
4944 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4945 
4946 	/* Create SNOW 3G operation */
4947 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4948 			tdata->digest.len, tdata->auth_iv.data,
4949 			tdata->auth_iv.len,
4950 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4951 			tdata->cipher_iv.data, tdata->cipher_iv.len,
4952 			tdata->validCipherLenInBits.len,
4953 			0,
4954 			tdata->validAuthLenInBits.len,
4955 			0
4956 			);
4957 	if (retval < 0)
4958 		return retval;
4959 
4960 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4961 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4962 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4963 	else
4964 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4965 			ut_params->op);
4966 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4967 	ut_params->obuf = ut_params->op->sym->m_src;
4968 	if (ut_params->obuf)
4969 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4970 	else
4971 		ciphertext = plaintext;
4972 
4973 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4974 	/* Validate obuf */
4975 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4976 			ciphertext,
4977 			tdata->ciphertext.data,
4978 			tdata->validDataLenInBits.len,
4979 			"SNOW 3G Ciphertext data not as expected");
4980 
4981 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4982 	    + plaintext_pad_len;
4983 
4984 	/* Validate obuf */
4985 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4986 			ut_params->digest,
4987 			tdata->digest.data,
4988 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4989 			"SNOW 3G Generated auth tag not as expected");
4990 	return 0;
4991 }
4992 
4993 static int
4994 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4995 	uint8_t op_mode, uint8_t verify)
4996 {
4997 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4998 	struct crypto_unittest_params *ut_params = &unittest_params;
4999 
5000 	int retval;
5001 
5002 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5003 	unsigned int plaintext_pad_len;
5004 	unsigned int plaintext_len;
5005 	unsigned int ciphertext_pad_len;
5006 	unsigned int ciphertext_len;
5007 
5008 	struct rte_cryptodev_info dev_info;
5009 
5010 	/* Verify the capabilities */
5011 	struct rte_cryptodev_sym_capability_idx cap_idx;
5012 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5013 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5014 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5015 			&cap_idx) == NULL)
5016 		return TEST_SKIPPED;
5017 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5018 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5019 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5020 			&cap_idx) == NULL)
5021 		return TEST_SKIPPED;
5022 
5023 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5024 		return TEST_SKIPPED;
5025 
5026 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5027 
5028 	uint64_t feat_flags = dev_info.feature_flags;
5029 
5030 	if (op_mode == OUT_OF_PLACE) {
5031 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5032 			printf("Device doesn't support digest encrypted.\n");
5033 			return TEST_SKIPPED;
5034 		}
5035 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5036 			return TEST_SKIPPED;
5037 	}
5038 
5039 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5040 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5041 		printf("Device doesn't support RAW data-path APIs.\n");
5042 		return TEST_SKIPPED;
5043 	}
5044 
5045 	/* Create SNOW 3G session */
5046 	retval = create_wireless_algo_auth_cipher_session(
5047 			ts_params->valid_devs[0],
5048 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5049 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5050 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5051 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5052 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5053 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5054 			tdata->key.data, tdata->key.len,
5055 			tdata->auth_iv.len, tdata->digest.len,
5056 			tdata->cipher_iv.len);
5057 	if (retval != 0)
5058 		return retval;
5059 
5060 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5061 	if (op_mode == OUT_OF_PLACE)
5062 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5063 
5064 	/* clear mbuf payload */
5065 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5066 		rte_pktmbuf_tailroom(ut_params->ibuf));
5067 	if (op_mode == OUT_OF_PLACE)
5068 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5069 			rte_pktmbuf_tailroom(ut_params->obuf));
5070 
5071 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5072 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5073 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5074 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5075 
5076 	if (verify) {
5077 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5078 					ciphertext_pad_len);
5079 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5080 		if (op_mode == OUT_OF_PLACE)
5081 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5082 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5083 			ciphertext_len);
5084 	} else {
5085 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5086 					plaintext_pad_len);
5087 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5088 		if (op_mode == OUT_OF_PLACE)
5089 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5090 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5091 	}
5092 
5093 	/* Create SNOW 3G operation */
5094 	retval = create_wireless_algo_auth_cipher_operation(
5095 		tdata->digest.data, tdata->digest.len,
5096 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5097 		tdata->auth_iv.data, tdata->auth_iv.len,
5098 		(tdata->digest.offset_bytes == 0 ?
5099 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5100 			: tdata->digest.offset_bytes),
5101 		tdata->validCipherLenInBits.len,
5102 		tdata->cipher.offset_bits,
5103 		tdata->validAuthLenInBits.len,
5104 		tdata->auth.offset_bits,
5105 		op_mode, 0, verify);
5106 
5107 	if (retval < 0)
5108 		return retval;
5109 
5110 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5111 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5112 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5113 	else
5114 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5115 			ut_params->op);
5116 
5117 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5118 
5119 	ut_params->obuf = (op_mode == IN_PLACE ?
5120 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5121 
5122 	if (verify) {
5123 		if (ut_params->obuf)
5124 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5125 							uint8_t *);
5126 		else
5127 			plaintext = ciphertext +
5128 				(tdata->cipher.offset_bits >> 3);
5129 
5130 		debug_hexdump(stdout, "plaintext:", plaintext,
5131 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5132 		debug_hexdump(stdout, "plaintext expected:",
5133 			tdata->plaintext.data,
5134 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5135 	} else {
5136 		if (ut_params->obuf)
5137 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5138 							uint8_t *);
5139 		else
5140 			ciphertext = plaintext;
5141 
5142 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5143 			ciphertext_len);
5144 		debug_hexdump(stdout, "ciphertext expected:",
5145 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5146 
5147 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5148 			+ (tdata->digest.offset_bytes == 0 ?
5149 		plaintext_pad_len : tdata->digest.offset_bytes);
5150 
5151 		debug_hexdump(stdout, "digest:", ut_params->digest,
5152 			tdata->digest.len);
5153 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5154 				tdata->digest.len);
5155 	}
5156 
5157 	/* Validate obuf */
5158 	if (verify) {
5159 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5160 			plaintext,
5161 			tdata->plaintext.data,
5162 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5163 			 (tdata->digest.len << 3)),
5164 			tdata->cipher.offset_bits,
5165 			"SNOW 3G Plaintext data not as expected");
5166 	} else {
5167 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5168 			ciphertext,
5169 			tdata->ciphertext.data,
5170 			(tdata->validDataLenInBits.len -
5171 			 tdata->cipher.offset_bits),
5172 			tdata->cipher.offset_bits,
5173 			"SNOW 3G Ciphertext data not as expected");
5174 
5175 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5176 			ut_params->digest,
5177 			tdata->digest.data,
5178 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5179 			"SNOW 3G Generated auth tag not as expected");
5180 	}
5181 	return 0;
5182 }
5183 
5184 static int
5185 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5186 	uint8_t op_mode, uint8_t verify)
5187 {
5188 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5189 	struct crypto_unittest_params *ut_params = &unittest_params;
5190 
5191 	int retval;
5192 
5193 	const uint8_t *plaintext = NULL;
5194 	const uint8_t *ciphertext = NULL;
5195 	const uint8_t *digest = NULL;
5196 	unsigned int plaintext_pad_len;
5197 	unsigned int plaintext_len;
5198 	unsigned int ciphertext_pad_len;
5199 	unsigned int ciphertext_len;
5200 	uint8_t buffer[10000];
5201 	uint8_t digest_buffer[10000];
5202 
5203 	struct rte_cryptodev_info dev_info;
5204 
5205 	/* Verify the capabilities */
5206 	struct rte_cryptodev_sym_capability_idx cap_idx;
5207 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5208 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5209 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5210 			&cap_idx) == NULL)
5211 		return TEST_SKIPPED;
5212 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5213 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5214 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5215 			&cap_idx) == NULL)
5216 		return TEST_SKIPPED;
5217 
5218 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5219 		return TEST_SKIPPED;
5220 
5221 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5222 
5223 	uint64_t feat_flags = dev_info.feature_flags;
5224 
5225 	if (op_mode == IN_PLACE) {
5226 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5227 			printf("Device doesn't support in-place scatter-gather "
5228 					"in both input and output mbufs.\n");
5229 			return TEST_SKIPPED;
5230 		}
5231 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5232 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5233 			printf("Device doesn't support RAW data-path APIs.\n");
5234 			return TEST_SKIPPED;
5235 		}
5236 	} else {
5237 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5238 			return TEST_SKIPPED;
5239 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5240 			printf("Device doesn't support out-of-place scatter-gather "
5241 					"in both input and output mbufs.\n");
5242 			return TEST_SKIPPED;
5243 		}
5244 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5245 			printf("Device doesn't support digest encrypted.\n");
5246 			return TEST_SKIPPED;
5247 		}
5248 	}
5249 
5250 	/* Create SNOW 3G session */
5251 	retval = create_wireless_algo_auth_cipher_session(
5252 			ts_params->valid_devs[0],
5253 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5254 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5255 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5256 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5257 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5258 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5259 			tdata->key.data, tdata->key.len,
5260 			tdata->auth_iv.len, tdata->digest.len,
5261 			tdata->cipher_iv.len);
5262 
5263 	if (retval != 0)
5264 		return retval;
5265 
5266 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5267 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5268 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5269 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5270 
5271 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5272 			plaintext_pad_len, 15, 0);
5273 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5274 			"Failed to allocate input buffer in mempool");
5275 
5276 	if (op_mode == OUT_OF_PLACE) {
5277 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5278 				plaintext_pad_len, 15, 0);
5279 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5280 				"Failed to allocate output buffer in mempool");
5281 	}
5282 
5283 	if (verify) {
5284 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5285 			tdata->ciphertext.data);
5286 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5287 					ciphertext_len, buffer);
5288 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5289 			ciphertext_len);
5290 	} else {
5291 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5292 			tdata->plaintext.data);
5293 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5294 					plaintext_len, buffer);
5295 		debug_hexdump(stdout, "plaintext:", plaintext,
5296 			plaintext_len);
5297 	}
5298 	memset(buffer, 0, sizeof(buffer));
5299 
5300 	/* Create SNOW 3G operation */
5301 	retval = create_wireless_algo_auth_cipher_operation(
5302 		tdata->digest.data, tdata->digest.len,
5303 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5304 		tdata->auth_iv.data, tdata->auth_iv.len,
5305 		(tdata->digest.offset_bytes == 0 ?
5306 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5307 			: tdata->digest.offset_bytes),
5308 		tdata->validCipherLenInBits.len,
5309 		tdata->cipher.offset_bits,
5310 		tdata->validAuthLenInBits.len,
5311 		tdata->auth.offset_bits,
5312 		op_mode, 1, verify);
5313 
5314 	if (retval < 0)
5315 		return retval;
5316 
5317 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5318 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5319 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5320 	else
5321 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5322 			ut_params->op);
5323 
5324 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5325 
5326 	ut_params->obuf = (op_mode == IN_PLACE ?
5327 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5328 
5329 	if (verify) {
5330 		if (ut_params->obuf)
5331 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5332 					plaintext_len, buffer);
5333 		else
5334 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5335 					plaintext_len, buffer);
5336 
5337 		debug_hexdump(stdout, "plaintext:", plaintext,
5338 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5339 		debug_hexdump(stdout, "plaintext expected:",
5340 			tdata->plaintext.data,
5341 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5342 	} else {
5343 		if (ut_params->obuf)
5344 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5345 					ciphertext_len, buffer);
5346 		else
5347 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5348 					ciphertext_len, buffer);
5349 
5350 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5351 			ciphertext_len);
5352 		debug_hexdump(stdout, "ciphertext expected:",
5353 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5354 
5355 		if (ut_params->obuf)
5356 			digest = rte_pktmbuf_read(ut_params->obuf,
5357 				(tdata->digest.offset_bytes == 0 ?
5358 				plaintext_pad_len : tdata->digest.offset_bytes),
5359 				tdata->digest.len, digest_buffer);
5360 		else
5361 			digest = rte_pktmbuf_read(ut_params->ibuf,
5362 				(tdata->digest.offset_bytes == 0 ?
5363 				plaintext_pad_len : tdata->digest.offset_bytes),
5364 				tdata->digest.len, digest_buffer);
5365 
5366 		debug_hexdump(stdout, "digest:", digest,
5367 			tdata->digest.len);
5368 		debug_hexdump(stdout, "digest expected:",
5369 			tdata->digest.data, tdata->digest.len);
5370 	}
5371 
5372 	/* Validate obuf */
5373 	if (verify) {
5374 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5375 			plaintext,
5376 			tdata->plaintext.data,
5377 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5378 			 (tdata->digest.len << 3)),
5379 			tdata->cipher.offset_bits,
5380 			"SNOW 3G Plaintext data not as expected");
5381 	} else {
5382 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5383 			ciphertext,
5384 			tdata->ciphertext.data,
5385 			(tdata->validDataLenInBits.len -
5386 			 tdata->cipher.offset_bits),
5387 			tdata->cipher.offset_bits,
5388 			"SNOW 3G Ciphertext data not as expected");
5389 
5390 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5391 			digest,
5392 			tdata->digest.data,
5393 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5394 			"SNOW 3G Generated auth tag not as expected");
5395 	}
5396 	return 0;
5397 }
5398 
5399 static int
5400 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5401 	uint8_t op_mode, uint8_t verify)
5402 {
5403 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5404 	struct crypto_unittest_params *ut_params = &unittest_params;
5405 
5406 	int retval;
5407 
5408 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5409 	unsigned int plaintext_pad_len;
5410 	unsigned int plaintext_len;
5411 	unsigned int ciphertext_pad_len;
5412 	unsigned int ciphertext_len;
5413 
5414 	struct rte_cryptodev_info dev_info;
5415 
5416 	/* Verify the capabilities */
5417 	struct rte_cryptodev_sym_capability_idx cap_idx;
5418 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5419 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5420 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5421 			&cap_idx) == NULL)
5422 		return TEST_SKIPPED;
5423 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5424 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5425 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5426 			&cap_idx) == NULL)
5427 		return TEST_SKIPPED;
5428 
5429 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5430 
5431 	uint64_t feat_flags = dev_info.feature_flags;
5432 
5433 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5434 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5435 		printf("Device doesn't support RAW data-path APIs.\n");
5436 		return TEST_SKIPPED;
5437 	}
5438 
5439 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5440 		return TEST_SKIPPED;
5441 
5442 	if (op_mode == OUT_OF_PLACE) {
5443 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5444 			return TEST_SKIPPED;
5445 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5446 			printf("Device doesn't support digest encrypted.\n");
5447 			return TEST_SKIPPED;
5448 		}
5449 	}
5450 
5451 	/* Create KASUMI session */
5452 	retval = create_wireless_algo_auth_cipher_session(
5453 			ts_params->valid_devs[0],
5454 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5455 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5456 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5457 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5458 			RTE_CRYPTO_AUTH_KASUMI_F9,
5459 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5460 			tdata->key.data, tdata->key.len,
5461 			0, tdata->digest.len,
5462 			tdata->cipher_iv.len);
5463 
5464 	if (retval != 0)
5465 		return retval;
5466 
5467 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5468 	if (op_mode == OUT_OF_PLACE)
5469 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5470 
5471 	/* clear mbuf payload */
5472 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5473 		rte_pktmbuf_tailroom(ut_params->ibuf));
5474 	if (op_mode == OUT_OF_PLACE)
5475 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5476 			rte_pktmbuf_tailroom(ut_params->obuf));
5477 
5478 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5479 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5480 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5481 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5482 
5483 	if (verify) {
5484 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5485 					ciphertext_pad_len);
5486 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5487 		if (op_mode == OUT_OF_PLACE)
5488 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5489 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5490 			ciphertext_len);
5491 	} else {
5492 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5493 					plaintext_pad_len);
5494 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5495 		if (op_mode == OUT_OF_PLACE)
5496 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5497 		debug_hexdump(stdout, "plaintext:", plaintext,
5498 			plaintext_len);
5499 	}
5500 
5501 	/* Create KASUMI operation */
5502 	retval = create_wireless_algo_auth_cipher_operation(
5503 		tdata->digest.data, tdata->digest.len,
5504 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5505 		NULL, 0,
5506 		(tdata->digest.offset_bytes == 0 ?
5507 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5508 			: tdata->digest.offset_bytes),
5509 		tdata->validCipherLenInBits.len,
5510 		tdata->validCipherOffsetInBits.len,
5511 		tdata->validAuthLenInBits.len,
5512 		0,
5513 		op_mode, 0, verify);
5514 
5515 	if (retval < 0)
5516 		return retval;
5517 
5518 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5519 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5520 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5521 	else
5522 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5523 			ut_params->op);
5524 
5525 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5526 
5527 	ut_params->obuf = (op_mode == IN_PLACE ?
5528 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5529 
5530 
5531 	if (verify) {
5532 		if (ut_params->obuf)
5533 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5534 							uint8_t *);
5535 		else
5536 			plaintext = ciphertext;
5537 
5538 		debug_hexdump(stdout, "plaintext:", plaintext,
5539 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5540 		debug_hexdump(stdout, "plaintext expected:",
5541 			tdata->plaintext.data,
5542 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5543 	} else {
5544 		if (ut_params->obuf)
5545 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5546 							uint8_t *);
5547 		else
5548 			ciphertext = plaintext;
5549 
5550 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5551 			ciphertext_len);
5552 		debug_hexdump(stdout, "ciphertext expected:",
5553 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5554 
5555 		ut_params->digest = rte_pktmbuf_mtod(
5556 			ut_params->obuf, uint8_t *) +
5557 			(tdata->digest.offset_bytes == 0 ?
5558 			plaintext_pad_len : tdata->digest.offset_bytes);
5559 
5560 		debug_hexdump(stdout, "digest:", ut_params->digest,
5561 			tdata->digest.len);
5562 		debug_hexdump(stdout, "digest expected:",
5563 			tdata->digest.data, tdata->digest.len);
5564 	}
5565 
5566 	/* Validate obuf */
5567 	if (verify) {
5568 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5569 			plaintext,
5570 			tdata->plaintext.data,
5571 			tdata->plaintext.len >> 3,
5572 			"KASUMI Plaintext data not as expected");
5573 	} else {
5574 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5575 			ciphertext,
5576 			tdata->ciphertext.data,
5577 			tdata->ciphertext.len >> 3,
5578 			"KASUMI Ciphertext data not as expected");
5579 
5580 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5581 			ut_params->digest,
5582 			tdata->digest.data,
5583 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5584 			"KASUMI Generated auth tag not as expected");
5585 	}
5586 	return 0;
5587 }
5588 
5589 static int
5590 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5591 	uint8_t op_mode, uint8_t verify)
5592 {
5593 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5594 	struct crypto_unittest_params *ut_params = &unittest_params;
5595 
5596 	int retval;
5597 
5598 	const uint8_t *plaintext = NULL;
5599 	const uint8_t *ciphertext = NULL;
5600 	const uint8_t *digest = NULL;
5601 	unsigned int plaintext_pad_len;
5602 	unsigned int plaintext_len;
5603 	unsigned int ciphertext_pad_len;
5604 	unsigned int ciphertext_len;
5605 	uint8_t buffer[10000];
5606 	uint8_t digest_buffer[10000];
5607 
5608 	struct rte_cryptodev_info dev_info;
5609 
5610 	/* Verify the capabilities */
5611 	struct rte_cryptodev_sym_capability_idx cap_idx;
5612 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5613 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5614 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5615 			&cap_idx) == NULL)
5616 		return TEST_SKIPPED;
5617 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5618 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5619 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5620 			&cap_idx) == NULL)
5621 		return TEST_SKIPPED;
5622 
5623 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5624 		return TEST_SKIPPED;
5625 
5626 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5627 
5628 	uint64_t feat_flags = dev_info.feature_flags;
5629 
5630 	if (op_mode == IN_PLACE) {
5631 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5632 			printf("Device doesn't support in-place scatter-gather "
5633 					"in both input and output mbufs.\n");
5634 			return TEST_SKIPPED;
5635 		}
5636 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5637 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5638 			printf("Device doesn't support RAW data-path APIs.\n");
5639 			return TEST_SKIPPED;
5640 		}
5641 	} else {
5642 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5643 			return TEST_SKIPPED;
5644 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5645 			printf("Device doesn't support out-of-place scatter-gather "
5646 					"in both input and output mbufs.\n");
5647 			return TEST_SKIPPED;
5648 		}
5649 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5650 			printf("Device doesn't support digest encrypted.\n");
5651 			return TEST_SKIPPED;
5652 		}
5653 	}
5654 
5655 	/* Create KASUMI session */
5656 	retval = create_wireless_algo_auth_cipher_session(
5657 			ts_params->valid_devs[0],
5658 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5659 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5660 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5661 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5662 			RTE_CRYPTO_AUTH_KASUMI_F9,
5663 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5664 			tdata->key.data, tdata->key.len,
5665 			0, tdata->digest.len,
5666 			tdata->cipher_iv.len);
5667 
5668 	if (retval != 0)
5669 		return retval;
5670 
5671 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5672 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5673 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5674 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5675 
5676 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5677 			plaintext_pad_len, 15, 0);
5678 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5679 			"Failed to allocate input buffer in mempool");
5680 
5681 	if (op_mode == OUT_OF_PLACE) {
5682 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5683 				plaintext_pad_len, 15, 0);
5684 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5685 				"Failed to allocate output buffer in mempool");
5686 	}
5687 
5688 	if (verify) {
5689 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5690 			tdata->ciphertext.data);
5691 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5692 					ciphertext_len, buffer);
5693 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5694 			ciphertext_len);
5695 	} else {
5696 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5697 			tdata->plaintext.data);
5698 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5699 					plaintext_len, buffer);
5700 		debug_hexdump(stdout, "plaintext:", plaintext,
5701 			plaintext_len);
5702 	}
5703 	memset(buffer, 0, sizeof(buffer));
5704 
5705 	/* Create KASUMI operation */
5706 	retval = create_wireless_algo_auth_cipher_operation(
5707 		tdata->digest.data, tdata->digest.len,
5708 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5709 		NULL, 0,
5710 		(tdata->digest.offset_bytes == 0 ?
5711 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5712 			: tdata->digest.offset_bytes),
5713 		tdata->validCipherLenInBits.len,
5714 		tdata->validCipherOffsetInBits.len,
5715 		tdata->validAuthLenInBits.len,
5716 		0,
5717 		op_mode, 1, verify);
5718 
5719 	if (retval < 0)
5720 		return retval;
5721 
5722 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5723 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5724 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5725 	else
5726 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5727 			ut_params->op);
5728 
5729 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5730 
5731 	ut_params->obuf = (op_mode == IN_PLACE ?
5732 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5733 
5734 	if (verify) {
5735 		if (ut_params->obuf)
5736 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5737 					plaintext_len, buffer);
5738 		else
5739 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5740 					plaintext_len, buffer);
5741 
5742 		debug_hexdump(stdout, "plaintext:", plaintext,
5743 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5744 		debug_hexdump(stdout, "plaintext expected:",
5745 			tdata->plaintext.data,
5746 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5747 	} else {
5748 		if (ut_params->obuf)
5749 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5750 					ciphertext_len, buffer);
5751 		else
5752 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5753 					ciphertext_len, buffer);
5754 
5755 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5756 			ciphertext_len);
5757 		debug_hexdump(stdout, "ciphertext expected:",
5758 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5759 
5760 		if (ut_params->obuf)
5761 			digest = rte_pktmbuf_read(ut_params->obuf,
5762 				(tdata->digest.offset_bytes == 0 ?
5763 				plaintext_pad_len : tdata->digest.offset_bytes),
5764 				tdata->digest.len, digest_buffer);
5765 		else
5766 			digest = rte_pktmbuf_read(ut_params->ibuf,
5767 				(tdata->digest.offset_bytes == 0 ?
5768 				plaintext_pad_len : tdata->digest.offset_bytes),
5769 				tdata->digest.len, digest_buffer);
5770 
5771 		debug_hexdump(stdout, "digest:", digest,
5772 			tdata->digest.len);
5773 		debug_hexdump(stdout, "digest expected:",
5774 			tdata->digest.data, tdata->digest.len);
5775 	}
5776 
5777 	/* Validate obuf */
5778 	if (verify) {
5779 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5780 			plaintext,
5781 			tdata->plaintext.data,
5782 			tdata->plaintext.len >> 3,
5783 			"KASUMI Plaintext data not as expected");
5784 	} else {
5785 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5786 			ciphertext,
5787 			tdata->ciphertext.data,
5788 			tdata->validDataLenInBits.len,
5789 			"KASUMI Ciphertext data not as expected");
5790 
5791 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5792 			digest,
5793 			tdata->digest.data,
5794 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5795 			"KASUMI Generated auth tag not as expected");
5796 	}
5797 	return 0;
5798 }
5799 
5800 static int
5801 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5802 {
5803 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5804 	struct crypto_unittest_params *ut_params = &unittest_params;
5805 
5806 	int retval;
5807 
5808 	uint8_t *plaintext, *ciphertext;
5809 	unsigned plaintext_pad_len;
5810 	unsigned plaintext_len;
5811 	struct rte_cryptodev_info dev_info;
5812 
5813 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5814 	uint64_t feat_flags = dev_info.feature_flags;
5815 
5816 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5817 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5818 		printf("Device doesn't support RAW data-path APIs.\n");
5819 		return TEST_SKIPPED;
5820 	}
5821 
5822 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5823 		return TEST_SKIPPED;
5824 
5825 	/* Verify the capabilities */
5826 	struct rte_cryptodev_sym_capability_idx cap_idx;
5827 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5828 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5829 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5830 			&cap_idx) == NULL)
5831 		return TEST_SKIPPED;
5832 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5833 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5834 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5835 			&cap_idx) == NULL)
5836 		return TEST_SKIPPED;
5837 
5838 	/* Create KASUMI session */
5839 	retval = create_wireless_algo_cipher_auth_session(
5840 			ts_params->valid_devs[0],
5841 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5842 			RTE_CRYPTO_AUTH_OP_GENERATE,
5843 			RTE_CRYPTO_AUTH_KASUMI_F9,
5844 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5845 			tdata->key.data, tdata->key.len,
5846 			0, tdata->digest.len,
5847 			tdata->cipher_iv.len);
5848 	if (retval != 0)
5849 		return retval;
5850 
5851 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5852 
5853 	/* clear mbuf payload */
5854 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5855 			rte_pktmbuf_tailroom(ut_params->ibuf));
5856 
5857 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5858 	/* Append data which is padded to a multiple of */
5859 	/* the algorithms block size */
5860 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5861 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5862 				plaintext_pad_len);
5863 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5864 
5865 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5866 
5867 	/* Create KASUMI operation */
5868 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5869 				tdata->digest.len, NULL, 0,
5870 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5871 				tdata->cipher_iv.data, tdata->cipher_iv.len,
5872 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5873 				tdata->validCipherOffsetInBits.len,
5874 				tdata->validAuthLenInBits.len,
5875 				0
5876 				);
5877 	if (retval < 0)
5878 		return retval;
5879 
5880 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5881 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5882 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5883 	else
5884 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5885 			ut_params->op);
5886 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5887 
5888 	if (ut_params->op->sym->m_dst)
5889 		ut_params->obuf = ut_params->op->sym->m_dst;
5890 	else
5891 		ut_params->obuf = ut_params->op->sym->m_src;
5892 
5893 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5894 				tdata->validCipherOffsetInBits.len >> 3);
5895 
5896 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5897 			+ plaintext_pad_len;
5898 
5899 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5900 				(tdata->validCipherOffsetInBits.len >> 3);
5901 	/* Validate obuf */
5902 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5903 		ciphertext,
5904 		reference_ciphertext,
5905 		tdata->validCipherLenInBits.len,
5906 		"KASUMI Ciphertext data not as expected");
5907 
5908 	/* Validate obuf */
5909 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5910 		ut_params->digest,
5911 		tdata->digest.data,
5912 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5913 		"KASUMI Generated auth tag not as expected");
5914 	return 0;
5915 }
5916 
5917 static int
5918 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5919 			const enum rte_crypto_cipher_algorithm cipher_algo,
5920 			const uint16_t key_size, const uint16_t iv_size)
5921 {
5922 	struct rte_cryptodev_sym_capability_idx cap_idx;
5923 	const struct rte_cryptodev_symmetric_capability *cap;
5924 
5925 	/* Check if device supports the algorithm */
5926 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5927 	cap_idx.algo.cipher = cipher_algo;
5928 
5929 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5930 			&cap_idx);
5931 
5932 	if (cap == NULL)
5933 		return -1;
5934 
5935 	/* Check if device supports key size and IV size */
5936 	if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5937 			iv_size) < 0) {
5938 		return -1;
5939 	}
5940 
5941 	return 0;
5942 }
5943 
5944 static int
5945 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5946 			const enum rte_crypto_auth_algorithm auth_algo,
5947 			const uint16_t key_size, const uint16_t iv_size,
5948 			const uint16_t tag_size)
5949 {
5950 	struct rte_cryptodev_sym_capability_idx cap_idx;
5951 	const struct rte_cryptodev_symmetric_capability *cap;
5952 
5953 	/* Check if device supports the algorithm */
5954 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5955 	cap_idx.algo.auth = auth_algo;
5956 
5957 	cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5958 			&cap_idx);
5959 
5960 	if (cap == NULL)
5961 		return -1;
5962 
5963 	/* Check if device supports key size and IV size */
5964 	if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5965 			tag_size, iv_size) < 0) {
5966 		return -1;
5967 	}
5968 
5969 	return 0;
5970 }
5971 
5972 static int
5973 test_zuc_encryption(const struct wireless_test_data *tdata)
5974 {
5975 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5976 	struct crypto_unittest_params *ut_params = &unittest_params;
5977 
5978 	int retval;
5979 	uint8_t *plaintext, *ciphertext;
5980 	unsigned plaintext_pad_len;
5981 	unsigned plaintext_len;
5982 	struct rte_cryptodev_info dev_info;
5983 
5984 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5985 	uint64_t feat_flags = dev_info.feature_flags;
5986 
5987 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5988 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5989 		printf("Device doesn't support RAW data-path APIs.\n");
5990 		return TEST_SKIPPED;
5991 	}
5992 
5993 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5994 		return TEST_SKIPPED;
5995 
5996 	/* Check if device supports ZUC EEA3 */
5997 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5998 			tdata->key.len, tdata->cipher_iv.len) < 0)
5999 		return TEST_SKIPPED;
6000 
6001 	/* Create ZUC session */
6002 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6003 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6004 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
6005 					tdata->key.data, tdata->key.len,
6006 					tdata->cipher_iv.len);
6007 	if (retval != 0)
6008 		return retval;
6009 
6010 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6011 
6012 	/* Clear mbuf payload */
6013 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6014 	       rte_pktmbuf_tailroom(ut_params->ibuf));
6015 
6016 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6017 	/* Append data which is padded to a multiple */
6018 	/* of the algorithms block size */
6019 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6020 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6021 				plaintext_pad_len);
6022 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6023 
6024 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6025 
6026 	/* Create ZUC operation */
6027 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6028 					tdata->cipher_iv.len,
6029 					tdata->plaintext.len,
6030 					0);
6031 	if (retval < 0)
6032 		return retval;
6033 
6034 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6035 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6036 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6037 	else
6038 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6039 						ut_params->op);
6040 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6041 
6042 	ut_params->obuf = ut_params->op->sym->m_dst;
6043 	if (ut_params->obuf)
6044 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6045 	else
6046 		ciphertext = plaintext;
6047 
6048 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6049 
6050 	/* Validate obuf */
6051 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6052 		ciphertext,
6053 		tdata->ciphertext.data,
6054 		tdata->validCipherLenInBits.len,
6055 		"ZUC Ciphertext data not as expected");
6056 	return 0;
6057 }
6058 
6059 static int
6060 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6061 {
6062 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6063 	struct crypto_unittest_params *ut_params = &unittest_params;
6064 
6065 	int retval;
6066 
6067 	unsigned int plaintext_pad_len;
6068 	unsigned int plaintext_len;
6069 	const uint8_t *ciphertext;
6070 	uint8_t ciphertext_buffer[2048];
6071 	struct rte_cryptodev_info dev_info;
6072 
6073 	/* Check if device supports ZUC EEA3 */
6074 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6075 			tdata->key.len, tdata->cipher_iv.len) < 0)
6076 		return TEST_SKIPPED;
6077 
6078 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6079 		return TEST_SKIPPED;
6080 
6081 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6082 
6083 	uint64_t feat_flags = dev_info.feature_flags;
6084 
6085 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6086 		printf("Device doesn't support in-place scatter-gather. "
6087 				"Test Skipped.\n");
6088 		return TEST_SKIPPED;
6089 	}
6090 
6091 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6092 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6093 		printf("Device doesn't support RAW data-path APIs.\n");
6094 		return TEST_SKIPPED;
6095 	}
6096 
6097 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6098 
6099 	/* Append data which is padded to a multiple */
6100 	/* of the algorithms block size */
6101 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6102 
6103 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6104 			plaintext_pad_len, 10, 0);
6105 
6106 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6107 			tdata->plaintext.data);
6108 
6109 	/* Create ZUC session */
6110 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6111 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6112 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6113 			tdata->key.data, tdata->key.len,
6114 			tdata->cipher_iv.len);
6115 	if (retval < 0)
6116 		return retval;
6117 
6118 	/* Clear mbuf payload */
6119 
6120 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6121 
6122 	/* Create ZUC operation */
6123 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6124 			tdata->cipher_iv.len, tdata->plaintext.len,
6125 			0);
6126 	if (retval < 0)
6127 		return retval;
6128 
6129 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6130 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6131 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6132 	else
6133 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6134 						ut_params->op);
6135 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6136 
6137 	ut_params->obuf = ut_params->op->sym->m_dst;
6138 	if (ut_params->obuf)
6139 		ciphertext = rte_pktmbuf_read(ut_params->obuf,
6140 			0, plaintext_len, ciphertext_buffer);
6141 	else
6142 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6143 			0, plaintext_len, ciphertext_buffer);
6144 
6145 	/* Validate obuf */
6146 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6147 
6148 	/* Validate obuf */
6149 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6150 		ciphertext,
6151 		tdata->ciphertext.data,
6152 		tdata->validCipherLenInBits.len,
6153 		"ZUC Ciphertext data not as expected");
6154 
6155 	return 0;
6156 }
6157 
6158 static int
6159 test_zuc_authentication(const struct wireless_test_data *tdata)
6160 {
6161 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6162 	struct crypto_unittest_params *ut_params = &unittest_params;
6163 
6164 	int retval;
6165 	unsigned plaintext_pad_len;
6166 	unsigned plaintext_len;
6167 	uint8_t *plaintext;
6168 
6169 	struct rte_cryptodev_info dev_info;
6170 
6171 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6172 	uint64_t feat_flags = dev_info.feature_flags;
6173 
6174 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6175 			(tdata->validAuthLenInBits.len % 8 != 0)) {
6176 		printf("Device doesn't support NON-Byte Aligned Data.\n");
6177 		return TEST_SKIPPED;
6178 	}
6179 
6180 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6181 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6182 		printf("Device doesn't support RAW data-path APIs.\n");
6183 		return TEST_SKIPPED;
6184 	}
6185 
6186 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6187 		return TEST_SKIPPED;
6188 
6189 	/* Check if device supports ZUC EIA3 */
6190 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6191 			tdata->key.len, tdata->auth_iv.len,
6192 			tdata->digest.len) < 0)
6193 		return TEST_SKIPPED;
6194 
6195 	/* Create ZUC session */
6196 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6197 			tdata->key.data, tdata->key.len,
6198 			tdata->auth_iv.len, tdata->digest.len,
6199 			RTE_CRYPTO_AUTH_OP_GENERATE,
6200 			RTE_CRYPTO_AUTH_ZUC_EIA3);
6201 	if (retval != 0)
6202 		return retval;
6203 
6204 	/* alloc mbuf and set payload */
6205 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6206 
6207 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6208 	rte_pktmbuf_tailroom(ut_params->ibuf));
6209 
6210 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6211 	/* Append data which is padded to a multiple of */
6212 	/* the algorithms block size */
6213 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6214 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6215 				plaintext_pad_len);
6216 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6217 
6218 	/* Create ZUC operation */
6219 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6220 			tdata->auth_iv.data, tdata->auth_iv.len,
6221 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6222 			tdata->validAuthLenInBits.len,
6223 			0);
6224 	if (retval < 0)
6225 		return retval;
6226 
6227 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6228 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6229 				ut_params->op, 0, 1, 1, 0);
6230 	else
6231 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6232 				ut_params->op);
6233 	ut_params->obuf = ut_params->op->sym->m_src;
6234 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6235 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6236 			+ plaintext_pad_len;
6237 
6238 	/* Validate obuf */
6239 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6240 	ut_params->digest,
6241 	tdata->digest.data,
6242 	tdata->digest.len,
6243 	"ZUC Generated auth tag not as expected");
6244 
6245 	return 0;
6246 }
6247 
6248 static int
6249 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6250 	uint8_t op_mode, uint8_t verify)
6251 {
6252 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6253 	struct crypto_unittest_params *ut_params = &unittest_params;
6254 
6255 	int retval;
6256 
6257 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6258 	unsigned int plaintext_pad_len;
6259 	unsigned int plaintext_len;
6260 	unsigned int ciphertext_pad_len;
6261 	unsigned int ciphertext_len;
6262 
6263 	struct rte_cryptodev_info dev_info;
6264 
6265 	/* Check if device supports ZUC EEA3 */
6266 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6267 			tdata->key.len, tdata->cipher_iv.len) < 0)
6268 		return TEST_SKIPPED;
6269 
6270 	/* Check if device supports ZUC EIA3 */
6271 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6272 			tdata->key.len, tdata->auth_iv.len,
6273 			tdata->digest.len) < 0)
6274 		return TEST_SKIPPED;
6275 
6276 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6277 
6278 	uint64_t feat_flags = dev_info.feature_flags;
6279 
6280 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6281 		printf("Device doesn't support digest encrypted.\n");
6282 		return TEST_SKIPPED;
6283 	}
6284 	if (op_mode == IN_PLACE) {
6285 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6286 			printf("Device doesn't support in-place scatter-gather "
6287 					"in both input and output mbufs.\n");
6288 			return TEST_SKIPPED;
6289 		}
6290 
6291 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6292 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6293 			printf("Device doesn't support RAW data-path APIs.\n");
6294 			return TEST_SKIPPED;
6295 		}
6296 	} else {
6297 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6298 			return TEST_SKIPPED;
6299 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6300 			printf("Device doesn't support out-of-place scatter-gather "
6301 					"in both input and output mbufs.\n");
6302 			return TEST_SKIPPED;
6303 		}
6304 	}
6305 
6306 	/* Create ZUC session */
6307 	retval = create_wireless_algo_auth_cipher_session(
6308 			ts_params->valid_devs[0],
6309 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6310 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6311 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6312 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6313 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6314 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6315 			tdata->key.data, tdata->key.len,
6316 			tdata->auth_iv.len, tdata->digest.len,
6317 			tdata->cipher_iv.len);
6318 
6319 	if (retval != 0)
6320 		return retval;
6321 
6322 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6323 	if (op_mode == OUT_OF_PLACE)
6324 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6325 
6326 	/* clear mbuf payload */
6327 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6328 		rte_pktmbuf_tailroom(ut_params->ibuf));
6329 	if (op_mode == OUT_OF_PLACE)
6330 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6331 			rte_pktmbuf_tailroom(ut_params->obuf));
6332 
6333 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6334 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6335 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6336 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6337 
6338 	if (verify) {
6339 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6340 					ciphertext_pad_len);
6341 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6342 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6343 			ciphertext_len);
6344 	} else {
6345 		/* make sure enough space to cover partial digest verify case */
6346 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6347 					ciphertext_pad_len);
6348 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6349 		debug_hexdump(stdout, "plaintext:", plaintext,
6350 			plaintext_len);
6351 	}
6352 
6353 	if (op_mode == OUT_OF_PLACE)
6354 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6355 
6356 	/* Create ZUC operation */
6357 	retval = create_wireless_algo_auth_cipher_operation(
6358 		tdata->digest.data, tdata->digest.len,
6359 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6360 		tdata->auth_iv.data, tdata->auth_iv.len,
6361 		(tdata->digest.offset_bytes == 0 ?
6362 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6363 			: tdata->digest.offset_bytes),
6364 		tdata->validCipherLenInBits.len,
6365 		tdata->validCipherOffsetInBits.len,
6366 		tdata->validAuthLenInBits.len,
6367 		0,
6368 		op_mode, 0, verify);
6369 
6370 	if (retval < 0)
6371 		return retval;
6372 
6373 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6374 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6375 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6376 	else
6377 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6378 			ut_params->op);
6379 
6380 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6381 
6382 	ut_params->obuf = (op_mode == IN_PLACE ?
6383 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6384 
6385 
6386 	if (verify) {
6387 		if (ut_params->obuf)
6388 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6389 							uint8_t *);
6390 		else
6391 			plaintext = ciphertext;
6392 
6393 		debug_hexdump(stdout, "plaintext:", plaintext,
6394 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6395 		debug_hexdump(stdout, "plaintext expected:",
6396 			tdata->plaintext.data,
6397 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6398 	} else {
6399 		if (ut_params->obuf)
6400 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6401 							uint8_t *);
6402 		else
6403 			ciphertext = plaintext;
6404 
6405 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6406 			ciphertext_len);
6407 		debug_hexdump(stdout, "ciphertext expected:",
6408 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6409 
6410 		ut_params->digest = rte_pktmbuf_mtod(
6411 			ut_params->obuf, uint8_t *) +
6412 			(tdata->digest.offset_bytes == 0 ?
6413 			plaintext_pad_len : tdata->digest.offset_bytes);
6414 
6415 		debug_hexdump(stdout, "digest:", ut_params->digest,
6416 			tdata->digest.len);
6417 		debug_hexdump(stdout, "digest expected:",
6418 			tdata->digest.data, tdata->digest.len);
6419 	}
6420 
6421 	/* Validate obuf */
6422 	if (verify) {
6423 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6424 			plaintext,
6425 			tdata->plaintext.data,
6426 			tdata->plaintext.len >> 3,
6427 			"ZUC Plaintext data not as expected");
6428 	} else {
6429 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6430 			ciphertext,
6431 			tdata->ciphertext.data,
6432 			tdata->ciphertext.len >> 3,
6433 			"ZUC Ciphertext data not as expected");
6434 
6435 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6436 			ut_params->digest,
6437 			tdata->digest.data,
6438 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6439 			"ZUC Generated auth tag not as expected");
6440 	}
6441 	return 0;
6442 }
6443 
6444 static int
6445 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6446 	uint8_t op_mode, uint8_t verify)
6447 {
6448 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6449 	struct crypto_unittest_params *ut_params = &unittest_params;
6450 
6451 	int retval;
6452 
6453 	const uint8_t *plaintext = NULL;
6454 	const uint8_t *ciphertext = NULL;
6455 	const uint8_t *digest = NULL;
6456 	unsigned int plaintext_pad_len;
6457 	unsigned int plaintext_len;
6458 	unsigned int ciphertext_pad_len;
6459 	unsigned int ciphertext_len;
6460 	uint8_t buffer[10000];
6461 	uint8_t digest_buffer[10000];
6462 
6463 	struct rte_cryptodev_info dev_info;
6464 
6465 	/* Check if device supports ZUC EEA3 */
6466 	if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6467 			tdata->key.len, tdata->cipher_iv.len) < 0)
6468 		return TEST_SKIPPED;
6469 
6470 	/* Check if device supports ZUC EIA3 */
6471 	if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6472 			tdata->key.len, tdata->auth_iv.len,
6473 			tdata->digest.len) < 0)
6474 		return TEST_SKIPPED;
6475 
6476 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6477 
6478 	uint64_t feat_flags = dev_info.feature_flags;
6479 
6480 	if (op_mode == IN_PLACE) {
6481 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6482 			printf("Device doesn't support in-place scatter-gather "
6483 					"in both input and output mbufs.\n");
6484 			return TEST_SKIPPED;
6485 		}
6486 
6487 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6488 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6489 			printf("Device doesn't support RAW data-path APIs.\n");
6490 			return TEST_SKIPPED;
6491 		}
6492 	} else {
6493 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6494 			return TEST_SKIPPED;
6495 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6496 			printf("Device doesn't support out-of-place scatter-gather "
6497 					"in both input and output mbufs.\n");
6498 			return TEST_SKIPPED;
6499 		}
6500 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6501 			printf("Device doesn't support digest encrypted.\n");
6502 			return TEST_SKIPPED;
6503 		}
6504 	}
6505 
6506 	/* Create ZUC session */
6507 	retval = create_wireless_algo_auth_cipher_session(
6508 			ts_params->valid_devs[0],
6509 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6510 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6511 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6512 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6513 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6514 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6515 			tdata->key.data, tdata->key.len,
6516 			tdata->auth_iv.len, tdata->digest.len,
6517 			tdata->cipher_iv.len);
6518 
6519 	if (retval != 0)
6520 		return retval;
6521 
6522 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6523 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6524 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6525 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6526 
6527 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6528 			plaintext_pad_len, 15, 0);
6529 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6530 			"Failed to allocate input buffer in mempool");
6531 
6532 	if (op_mode == OUT_OF_PLACE) {
6533 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6534 				plaintext_pad_len, 15, 0);
6535 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6536 				"Failed to allocate output buffer in mempool");
6537 	}
6538 
6539 	if (verify) {
6540 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6541 			tdata->ciphertext.data);
6542 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6543 					ciphertext_len, buffer);
6544 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6545 			ciphertext_len);
6546 	} else {
6547 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6548 			tdata->plaintext.data);
6549 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6550 					plaintext_len, buffer);
6551 		debug_hexdump(stdout, "plaintext:", plaintext,
6552 			plaintext_len);
6553 	}
6554 	memset(buffer, 0, sizeof(buffer));
6555 
6556 	/* Create ZUC operation */
6557 	retval = create_wireless_algo_auth_cipher_operation(
6558 		tdata->digest.data, tdata->digest.len,
6559 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6560 		NULL, 0,
6561 		(tdata->digest.offset_bytes == 0 ?
6562 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6563 			: tdata->digest.offset_bytes),
6564 		tdata->validCipherLenInBits.len,
6565 		tdata->validCipherOffsetInBits.len,
6566 		tdata->validAuthLenInBits.len,
6567 		0,
6568 		op_mode, 1, verify);
6569 
6570 	if (retval < 0)
6571 		return retval;
6572 
6573 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6574 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6575 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6576 	else
6577 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6578 			ut_params->op);
6579 
6580 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6581 
6582 	ut_params->obuf = (op_mode == IN_PLACE ?
6583 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6584 
6585 	if (verify) {
6586 		if (ut_params->obuf)
6587 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6588 					plaintext_len, buffer);
6589 		else
6590 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6591 					plaintext_len, buffer);
6592 
6593 		debug_hexdump(stdout, "plaintext:", plaintext,
6594 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6595 		debug_hexdump(stdout, "plaintext expected:",
6596 			tdata->plaintext.data,
6597 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6598 	} else {
6599 		if (ut_params->obuf)
6600 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6601 					ciphertext_len, buffer);
6602 		else
6603 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6604 					ciphertext_len, buffer);
6605 
6606 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6607 			ciphertext_len);
6608 		debug_hexdump(stdout, "ciphertext expected:",
6609 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6610 
6611 		if (ut_params->obuf)
6612 			digest = rte_pktmbuf_read(ut_params->obuf,
6613 				(tdata->digest.offset_bytes == 0 ?
6614 				plaintext_pad_len : tdata->digest.offset_bytes),
6615 				tdata->digest.len, digest_buffer);
6616 		else
6617 			digest = rte_pktmbuf_read(ut_params->ibuf,
6618 				(tdata->digest.offset_bytes == 0 ?
6619 				plaintext_pad_len : tdata->digest.offset_bytes),
6620 				tdata->digest.len, digest_buffer);
6621 
6622 		debug_hexdump(stdout, "digest:", digest,
6623 			tdata->digest.len);
6624 		debug_hexdump(stdout, "digest expected:",
6625 			tdata->digest.data, tdata->digest.len);
6626 	}
6627 
6628 	/* Validate obuf */
6629 	if (verify) {
6630 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6631 			plaintext,
6632 			tdata->plaintext.data,
6633 			tdata->plaintext.len >> 3,
6634 			"ZUC Plaintext data not as expected");
6635 	} else {
6636 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6637 			ciphertext,
6638 			tdata->ciphertext.data,
6639 			tdata->validDataLenInBits.len,
6640 			"ZUC Ciphertext data not as expected");
6641 
6642 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6643 			digest,
6644 			tdata->digest.data,
6645 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6646 			"ZUC Generated auth tag not as expected");
6647 	}
6648 	return 0;
6649 }
6650 
6651 static int
6652 test_kasumi_encryption_test_case_1(void)
6653 {
6654 	return test_kasumi_encryption(&kasumi_test_case_1);
6655 }
6656 
6657 static int
6658 test_kasumi_encryption_test_case_1_sgl(void)
6659 {
6660 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6661 }
6662 
6663 static int
6664 test_kasumi_encryption_test_case_1_oop(void)
6665 {
6666 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
6667 }
6668 
6669 static int
6670 test_kasumi_encryption_test_case_1_oop_sgl(void)
6671 {
6672 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6673 }
6674 
6675 static int
6676 test_kasumi_encryption_test_case_2(void)
6677 {
6678 	return test_kasumi_encryption(&kasumi_test_case_2);
6679 }
6680 
6681 static int
6682 test_kasumi_encryption_test_case_3(void)
6683 {
6684 	return test_kasumi_encryption(&kasumi_test_case_3);
6685 }
6686 
6687 static int
6688 test_kasumi_encryption_test_case_4(void)
6689 {
6690 	return test_kasumi_encryption(&kasumi_test_case_4);
6691 }
6692 
6693 static int
6694 test_kasumi_encryption_test_case_5(void)
6695 {
6696 	return test_kasumi_encryption(&kasumi_test_case_5);
6697 }
6698 
6699 static int
6700 test_kasumi_decryption_test_case_1(void)
6701 {
6702 	return test_kasumi_decryption(&kasumi_test_case_1);
6703 }
6704 
6705 static int
6706 test_kasumi_decryption_test_case_1_oop(void)
6707 {
6708 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
6709 }
6710 
6711 static int
6712 test_kasumi_decryption_test_case_2(void)
6713 {
6714 	return test_kasumi_decryption(&kasumi_test_case_2);
6715 }
6716 
6717 static int
6718 test_kasumi_decryption_test_case_3(void)
6719 {
6720 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6721 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6722 		return TEST_SKIPPED;
6723 	return test_kasumi_decryption(&kasumi_test_case_3);
6724 }
6725 
6726 static int
6727 test_kasumi_decryption_test_case_4(void)
6728 {
6729 	return test_kasumi_decryption(&kasumi_test_case_4);
6730 }
6731 
6732 static int
6733 test_kasumi_decryption_test_case_5(void)
6734 {
6735 	return test_kasumi_decryption(&kasumi_test_case_5);
6736 }
6737 static int
6738 test_snow3g_encryption_test_case_1(void)
6739 {
6740 	return test_snow3g_encryption(&snow3g_test_case_1);
6741 }
6742 
6743 static int
6744 test_snow3g_encryption_test_case_1_oop(void)
6745 {
6746 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
6747 }
6748 
6749 static int
6750 test_snow3g_encryption_test_case_1_oop_sgl(void)
6751 {
6752 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6753 }
6754 
6755 
6756 static int
6757 test_snow3g_encryption_test_case_1_offset_oop(void)
6758 {
6759 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6760 }
6761 
6762 static int
6763 test_snow3g_encryption_test_case_2(void)
6764 {
6765 	return test_snow3g_encryption(&snow3g_test_case_2);
6766 }
6767 
6768 static int
6769 test_snow3g_encryption_test_case_3(void)
6770 {
6771 	return test_snow3g_encryption(&snow3g_test_case_3);
6772 }
6773 
6774 static int
6775 test_snow3g_encryption_test_case_4(void)
6776 {
6777 	return test_snow3g_encryption(&snow3g_test_case_4);
6778 }
6779 
6780 static int
6781 test_snow3g_encryption_test_case_5(void)
6782 {
6783 	return test_snow3g_encryption(&snow3g_test_case_5);
6784 }
6785 
6786 static int
6787 test_snow3g_decryption_test_case_1(void)
6788 {
6789 	return test_snow3g_decryption(&snow3g_test_case_1);
6790 }
6791 
6792 static int
6793 test_snow3g_decryption_test_case_1_oop(void)
6794 {
6795 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
6796 }
6797 
6798 static int
6799 test_snow3g_decryption_test_case_2(void)
6800 {
6801 	return test_snow3g_decryption(&snow3g_test_case_2);
6802 }
6803 
6804 static int
6805 test_snow3g_decryption_test_case_3(void)
6806 {
6807 	return test_snow3g_decryption(&snow3g_test_case_3);
6808 }
6809 
6810 static int
6811 test_snow3g_decryption_test_case_4(void)
6812 {
6813 	return test_snow3g_decryption(&snow3g_test_case_4);
6814 }
6815 
6816 static int
6817 test_snow3g_decryption_test_case_5(void)
6818 {
6819 	return test_snow3g_decryption(&snow3g_test_case_5);
6820 }
6821 
6822 /*
6823  * Function prepares snow3g_hash_test_data from snow3g_test_data.
6824  * Pattern digest from snow3g_test_data must be allocated as
6825  * 4 last bytes in plaintext.
6826  */
6827 static void
6828 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6829 		struct snow3g_hash_test_data *output)
6830 {
6831 	if ((pattern != NULL) && (output != NULL)) {
6832 		output->key.len = pattern->key.len;
6833 
6834 		memcpy(output->key.data,
6835 		pattern->key.data, pattern->key.len);
6836 
6837 		output->auth_iv.len = pattern->auth_iv.len;
6838 
6839 		memcpy(output->auth_iv.data,
6840 		pattern->auth_iv.data, pattern->auth_iv.len);
6841 
6842 		output->plaintext.len = pattern->plaintext.len;
6843 
6844 		memcpy(output->plaintext.data,
6845 		pattern->plaintext.data, pattern->plaintext.len >> 3);
6846 
6847 		output->digest.len = pattern->digest.len;
6848 
6849 		memcpy(output->digest.data,
6850 		&pattern->plaintext.data[pattern->digest.offset_bytes],
6851 		pattern->digest.len);
6852 
6853 		output->validAuthLenInBits.len =
6854 		pattern->validAuthLenInBits.len;
6855 	}
6856 }
6857 
6858 /*
6859  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6860  */
6861 static int
6862 test_snow3g_decryption_with_digest_test_case_1(void)
6863 {
6864 	struct snow3g_hash_test_data snow3g_hash_data;
6865 	struct rte_cryptodev_info dev_info;
6866 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6867 
6868 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6869 	uint64_t feat_flags = dev_info.feature_flags;
6870 
6871 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6872 		printf("Device doesn't support encrypted digest operations.\n");
6873 		return TEST_SKIPPED;
6874 	}
6875 
6876 	/*
6877 	 * Function prepare data for hash verification test case.
6878 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
6879 	 */
6880 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6881 
6882 	return test_snow3g_decryption(&snow3g_test_case_7) &
6883 			test_snow3g_authentication_verify(&snow3g_hash_data);
6884 }
6885 
6886 static int
6887 test_snow3g_cipher_auth_test_case_1(void)
6888 {
6889 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
6890 }
6891 
6892 static int
6893 test_snow3g_auth_cipher_test_case_1(void)
6894 {
6895 	return test_snow3g_auth_cipher(
6896 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6897 }
6898 
6899 static int
6900 test_snow3g_auth_cipher_test_case_2(void)
6901 {
6902 	return test_snow3g_auth_cipher(
6903 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6904 }
6905 
6906 static int
6907 test_snow3g_auth_cipher_test_case_2_oop(void)
6908 {
6909 	return test_snow3g_auth_cipher(
6910 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6911 }
6912 
6913 static int
6914 test_snow3g_auth_cipher_part_digest_enc(void)
6915 {
6916 	return test_snow3g_auth_cipher(
6917 		&snow3g_auth_cipher_partial_digest_encryption,
6918 			IN_PLACE, 0);
6919 }
6920 
6921 static int
6922 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6923 {
6924 	return test_snow3g_auth_cipher(
6925 		&snow3g_auth_cipher_partial_digest_encryption,
6926 			OUT_OF_PLACE, 0);
6927 }
6928 
6929 static int
6930 test_snow3g_auth_cipher_test_case_3_sgl(void)
6931 {
6932 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6933 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6934 		return TEST_SKIPPED;
6935 	return test_snow3g_auth_cipher_sgl(
6936 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6937 }
6938 
6939 static int
6940 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6941 {
6942 	return test_snow3g_auth_cipher_sgl(
6943 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6944 }
6945 
6946 static int
6947 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6948 {
6949 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6950 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6951 		return TEST_SKIPPED;
6952 	return test_snow3g_auth_cipher_sgl(
6953 		&snow3g_auth_cipher_partial_digest_encryption,
6954 			IN_PLACE, 0);
6955 }
6956 
6957 static int
6958 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6959 {
6960 	return test_snow3g_auth_cipher_sgl(
6961 		&snow3g_auth_cipher_partial_digest_encryption,
6962 			OUT_OF_PLACE, 0);
6963 }
6964 
6965 static int
6966 test_snow3g_auth_cipher_verify_test_case_1(void)
6967 {
6968 	return test_snow3g_auth_cipher(
6969 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6970 }
6971 
6972 static int
6973 test_snow3g_auth_cipher_verify_test_case_2(void)
6974 {
6975 	return test_snow3g_auth_cipher(
6976 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6977 }
6978 
6979 static int
6980 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6981 {
6982 	return test_snow3g_auth_cipher(
6983 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6984 }
6985 
6986 static int
6987 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6988 {
6989 	return test_snow3g_auth_cipher(
6990 		&snow3g_auth_cipher_partial_digest_encryption,
6991 			IN_PLACE, 1);
6992 }
6993 
6994 static int
6995 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6996 {
6997 	return test_snow3g_auth_cipher(
6998 		&snow3g_auth_cipher_partial_digest_encryption,
6999 			OUT_OF_PLACE, 1);
7000 }
7001 
7002 static int
7003 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7004 {
7005 	return test_snow3g_auth_cipher_sgl(
7006 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7007 }
7008 
7009 static int
7010 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7011 {
7012 	return test_snow3g_auth_cipher_sgl(
7013 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7014 }
7015 
7016 static int
7017 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7018 {
7019 	return test_snow3g_auth_cipher_sgl(
7020 		&snow3g_auth_cipher_partial_digest_encryption,
7021 			IN_PLACE, 1);
7022 }
7023 
7024 static int
7025 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7026 {
7027 	return test_snow3g_auth_cipher_sgl(
7028 		&snow3g_auth_cipher_partial_digest_encryption,
7029 			OUT_OF_PLACE, 1);
7030 }
7031 
7032 static int
7033 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7034 {
7035 	return test_snow3g_auth_cipher(
7036 		&snow3g_test_case_7, IN_PLACE, 0);
7037 }
7038 
7039 static int
7040 test_kasumi_auth_cipher_test_case_1(void)
7041 {
7042 	return test_kasumi_auth_cipher(
7043 		&kasumi_test_case_3, IN_PLACE, 0);
7044 }
7045 
7046 static int
7047 test_kasumi_auth_cipher_test_case_2(void)
7048 {
7049 	return test_kasumi_auth_cipher(
7050 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7051 }
7052 
7053 static int
7054 test_kasumi_auth_cipher_test_case_2_oop(void)
7055 {
7056 	return test_kasumi_auth_cipher(
7057 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7058 }
7059 
7060 static int
7061 test_kasumi_auth_cipher_test_case_2_sgl(void)
7062 {
7063 	return test_kasumi_auth_cipher_sgl(
7064 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7065 }
7066 
7067 static int
7068 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7069 {
7070 	return test_kasumi_auth_cipher_sgl(
7071 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7072 }
7073 
7074 static int
7075 test_kasumi_auth_cipher_verify_test_case_1(void)
7076 {
7077 	return test_kasumi_auth_cipher(
7078 		&kasumi_test_case_3, IN_PLACE, 1);
7079 }
7080 
7081 static int
7082 test_kasumi_auth_cipher_verify_test_case_2(void)
7083 {
7084 	return test_kasumi_auth_cipher(
7085 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7086 }
7087 
7088 static int
7089 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7090 {
7091 	return test_kasumi_auth_cipher(
7092 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7093 }
7094 
7095 static int
7096 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7097 {
7098 	return test_kasumi_auth_cipher_sgl(
7099 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7100 }
7101 
7102 static int
7103 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7104 {
7105 	return test_kasumi_auth_cipher_sgl(
7106 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7107 }
7108 
7109 static int
7110 test_kasumi_cipher_auth_test_case_1(void)
7111 {
7112 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
7113 }
7114 
7115 static int
7116 test_zuc_encryption_test_case_1(void)
7117 {
7118 	return test_zuc_encryption(&zuc_test_case_cipher_193b);
7119 }
7120 
7121 static int
7122 test_zuc_encryption_test_case_2(void)
7123 {
7124 	return test_zuc_encryption(&zuc_test_case_cipher_800b);
7125 }
7126 
7127 static int
7128 test_zuc_encryption_test_case_3(void)
7129 {
7130 	return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7131 }
7132 
7133 static int
7134 test_zuc_encryption_test_case_4(void)
7135 {
7136 	return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7137 }
7138 
7139 static int
7140 test_zuc_encryption_test_case_5(void)
7141 {
7142 	return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7143 }
7144 
7145 static int
7146 test_zuc_encryption_test_case_6_sgl(void)
7147 {
7148 	return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7149 }
7150 
7151 static int
7152 test_zuc_hash_generate_test_case_1(void)
7153 {
7154 	return test_zuc_authentication(&zuc_test_case_auth_1b);
7155 }
7156 
7157 static int
7158 test_zuc_hash_generate_test_case_2(void)
7159 {
7160 	return test_zuc_authentication(&zuc_test_case_auth_90b);
7161 }
7162 
7163 static int
7164 test_zuc_hash_generate_test_case_3(void)
7165 {
7166 	return test_zuc_authentication(&zuc_test_case_auth_577b);
7167 }
7168 
7169 static int
7170 test_zuc_hash_generate_test_case_4(void)
7171 {
7172 	return test_zuc_authentication(&zuc_test_case_auth_2079b);
7173 }
7174 
7175 static int
7176 test_zuc_hash_generate_test_case_5(void)
7177 {
7178 	return test_zuc_authentication(&zuc_test_auth_5670b);
7179 }
7180 
7181 static int
7182 test_zuc_hash_generate_test_case_6(void)
7183 {
7184 	return test_zuc_authentication(&zuc_test_case_auth_128b);
7185 }
7186 
7187 static int
7188 test_zuc_hash_generate_test_case_7(void)
7189 {
7190 	return test_zuc_authentication(&zuc_test_case_auth_2080b);
7191 }
7192 
7193 static int
7194 test_zuc_hash_generate_test_case_8(void)
7195 {
7196 	return test_zuc_authentication(&zuc_test_case_auth_584b);
7197 }
7198 
7199 static int
7200 test_zuc_hash_generate_test_case_9(void)
7201 {
7202 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7203 }
7204 
7205 static int
7206 test_zuc_hash_generate_test_case_10(void)
7207 {
7208 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7209 }
7210 
7211 static int
7212 test_zuc_hash_generate_test_case_11(void)
7213 {
7214 	return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7215 }
7216 
7217 static int
7218 test_zuc_cipher_auth_test_case_1(void)
7219 {
7220 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7221 }
7222 
7223 static int
7224 test_zuc_cipher_auth_test_case_2(void)
7225 {
7226 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7227 }
7228 
7229 static int
7230 test_zuc_auth_cipher_test_case_1(void)
7231 {
7232 	return test_zuc_auth_cipher(
7233 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7234 }
7235 
7236 static int
7237 test_zuc_auth_cipher_test_case_1_oop(void)
7238 {
7239 	return test_zuc_auth_cipher(
7240 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7241 }
7242 
7243 static int
7244 test_zuc_auth_cipher_test_case_1_sgl(void)
7245 {
7246 	return test_zuc_auth_cipher_sgl(
7247 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7248 }
7249 
7250 static int
7251 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7252 {
7253 	return test_zuc_auth_cipher_sgl(
7254 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7255 }
7256 
7257 static int
7258 test_zuc_auth_cipher_verify_test_case_1(void)
7259 {
7260 	return test_zuc_auth_cipher(
7261 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7262 }
7263 
7264 static int
7265 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7266 {
7267 	return test_zuc_auth_cipher(
7268 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7269 }
7270 
7271 static int
7272 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7273 {
7274 	return test_zuc_auth_cipher_sgl(
7275 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7276 }
7277 
7278 static int
7279 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7280 {
7281 	return test_zuc_auth_cipher_sgl(
7282 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7283 }
7284 
7285 static int
7286 test_zuc256_encryption_test_case_1(void)
7287 {
7288 	return test_zuc_encryption(&zuc256_test_case_cipher_1);
7289 }
7290 
7291 static int
7292 test_zuc256_encryption_test_case_2(void)
7293 {
7294 	return test_zuc_encryption(&zuc256_test_case_cipher_2);
7295 }
7296 
7297 static int
7298 test_zuc256_authentication_test_case_1(void)
7299 {
7300 	return test_zuc_authentication(&zuc256_test_case_auth_1);
7301 }
7302 
7303 static int
7304 test_zuc256_authentication_test_case_2(void)
7305 {
7306 	return test_zuc_authentication(&zuc256_test_case_auth_2);
7307 }
7308 
7309 static int
7310 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7311 {
7312 	uint8_t dev_id = testsuite_params.valid_devs[0];
7313 
7314 	struct rte_cryptodev_sym_capability_idx cap_idx;
7315 
7316 	/* Check if device supports particular cipher algorithm */
7317 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7318 	cap_idx.algo.cipher = tdata->cipher_algo;
7319 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7320 		return TEST_SKIPPED;
7321 
7322 	/* Check if device supports particular hash algorithm */
7323 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7324 	cap_idx.algo.auth = tdata->auth_algo;
7325 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7326 		return TEST_SKIPPED;
7327 
7328 	return 0;
7329 }
7330 
7331 static int
7332 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7333 	uint8_t op_mode, uint8_t verify)
7334 {
7335 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7336 	struct crypto_unittest_params *ut_params = &unittest_params;
7337 
7338 	int retval;
7339 
7340 	uint8_t *plaintext = NULL, *ciphertext = NULL;
7341 	unsigned int plaintext_pad_len;
7342 	unsigned int plaintext_len;
7343 	unsigned int ciphertext_pad_len;
7344 	unsigned int ciphertext_len;
7345 
7346 	struct rte_cryptodev_info dev_info;
7347 	struct rte_crypto_op *op;
7348 
7349 	/* Check if device supports particular algorithms separately */
7350 	if (test_mixed_check_if_unsupported(tdata))
7351 		return TEST_SKIPPED;
7352 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7353 		return TEST_SKIPPED;
7354 
7355 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7356 
7357 	uint64_t feat_flags = dev_info.feature_flags;
7358 
7359 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7360 		printf("Device doesn't support digest encrypted.\n");
7361 		return TEST_SKIPPED;
7362 	}
7363 
7364 	/* Create the session */
7365 	if (verify)
7366 		retval = create_wireless_algo_cipher_auth_session(
7367 				ts_params->valid_devs[0],
7368 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
7369 				RTE_CRYPTO_AUTH_OP_VERIFY,
7370 				tdata->auth_algo,
7371 				tdata->cipher_algo,
7372 				tdata->auth_key.data, tdata->auth_key.len,
7373 				tdata->auth_iv.len, tdata->digest_enc.len,
7374 				tdata->cipher_iv.len);
7375 	else
7376 		retval = create_wireless_algo_auth_cipher_session(
7377 				ts_params->valid_devs[0],
7378 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7379 				RTE_CRYPTO_AUTH_OP_GENERATE,
7380 				tdata->auth_algo,
7381 				tdata->cipher_algo,
7382 				tdata->auth_key.data, tdata->auth_key.len,
7383 				tdata->auth_iv.len, tdata->digest_enc.len,
7384 				tdata->cipher_iv.len);
7385 	if (retval != 0)
7386 		return retval;
7387 
7388 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7389 	if (op_mode == OUT_OF_PLACE)
7390 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7391 
7392 	/* clear mbuf payload */
7393 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7394 		rte_pktmbuf_tailroom(ut_params->ibuf));
7395 	if (op_mode == OUT_OF_PLACE) {
7396 
7397 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7398 				rte_pktmbuf_tailroom(ut_params->obuf));
7399 	}
7400 
7401 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7402 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7403 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7404 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7405 
7406 	if (verify) {
7407 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7408 				ciphertext_pad_len);
7409 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7410 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7411 				ciphertext_len);
7412 	} else {
7413 		/* make sure enough space to cover partial digest verify case */
7414 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7415 				ciphertext_pad_len);
7416 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7417 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7418 	}
7419 
7420 	if (op_mode == OUT_OF_PLACE)
7421 		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7422 
7423 	/* Create the operation */
7424 	retval = create_wireless_algo_auth_cipher_operation(
7425 			tdata->digest_enc.data, tdata->digest_enc.len,
7426 			tdata->cipher_iv.data, tdata->cipher_iv.len,
7427 			tdata->auth_iv.data, tdata->auth_iv.len,
7428 			(tdata->digest_enc.offset == 0 ?
7429 				plaintext_pad_len
7430 				: tdata->digest_enc.offset),
7431 			tdata->validCipherLen.len_bits,
7432 			tdata->cipher.offset_bits,
7433 			tdata->validAuthLen.len_bits,
7434 			tdata->auth.offset_bits,
7435 			op_mode, 0, verify);
7436 
7437 	if (retval < 0)
7438 		return retval;
7439 
7440 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7441 
7442 	/* Check if the op failed because the device doesn't */
7443 	/* support this particular combination of algorithms */
7444 	if (op == NULL && ut_params->op->status ==
7445 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7446 		printf("Device doesn't support this mixed combination. "
7447 				"Test Skipped.\n");
7448 		return TEST_SKIPPED;
7449 	}
7450 	ut_params->op = op;
7451 
7452 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7453 
7454 	ut_params->obuf = (op_mode == IN_PLACE ?
7455 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7456 
7457 	if (verify) {
7458 		if (ut_params->obuf)
7459 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7460 							uint8_t *);
7461 		else
7462 			plaintext = ciphertext +
7463 					(tdata->cipher.offset_bits >> 3);
7464 
7465 		debug_hexdump(stdout, "plaintext:", plaintext,
7466 				tdata->plaintext.len_bits >> 3);
7467 		debug_hexdump(stdout, "plaintext expected:",
7468 				tdata->plaintext.data,
7469 				tdata->plaintext.len_bits >> 3);
7470 	} else {
7471 		if (ut_params->obuf)
7472 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7473 					uint8_t *);
7474 		else
7475 			ciphertext = plaintext;
7476 
7477 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7478 				ciphertext_len);
7479 		debug_hexdump(stdout, "ciphertext expected:",
7480 				tdata->ciphertext.data,
7481 				tdata->ciphertext.len_bits >> 3);
7482 
7483 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7484 				+ (tdata->digest_enc.offset == 0 ?
7485 		plaintext_pad_len : tdata->digest_enc.offset);
7486 
7487 		debug_hexdump(stdout, "digest:", ut_params->digest,
7488 				tdata->digest_enc.len);
7489 		debug_hexdump(stdout, "digest expected:",
7490 				tdata->digest_enc.data,
7491 				tdata->digest_enc.len);
7492 	}
7493 
7494 	if (!verify) {
7495 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7496 				ut_params->digest,
7497 				tdata->digest_enc.data,
7498 				tdata->digest_enc.len,
7499 				"Generated auth tag not as expected");
7500 	}
7501 
7502 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7503 		if (verify) {
7504 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7505 					plaintext,
7506 					tdata->plaintext.data,
7507 					tdata->plaintext.len_bits >> 3,
7508 					"Plaintext data not as expected");
7509 		} else {
7510 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7511 					ciphertext,
7512 					tdata->ciphertext.data,
7513 					tdata->validDataLen.len_bits,
7514 					"Ciphertext data not as expected");
7515 		}
7516 	}
7517 
7518 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7519 			"crypto op processing failed");
7520 
7521 	return 0;
7522 }
7523 
7524 static int
7525 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7526 	uint8_t op_mode, uint8_t verify)
7527 {
7528 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7529 	struct crypto_unittest_params *ut_params = &unittest_params;
7530 
7531 	int retval;
7532 
7533 	const uint8_t *plaintext = NULL;
7534 	const uint8_t *ciphertext = NULL;
7535 	const uint8_t *digest = NULL;
7536 	unsigned int plaintext_pad_len;
7537 	unsigned int plaintext_len;
7538 	unsigned int ciphertext_pad_len;
7539 	unsigned int ciphertext_len;
7540 	uint8_t buffer[10000];
7541 	uint8_t digest_buffer[10000];
7542 
7543 	struct rte_cryptodev_info dev_info;
7544 	struct rte_crypto_op *op;
7545 
7546 	/* Check if device supports particular algorithms */
7547 	if (test_mixed_check_if_unsupported(tdata))
7548 		return TEST_SKIPPED;
7549 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7550 		return TEST_SKIPPED;
7551 
7552 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7553 
7554 	uint64_t feat_flags = dev_info.feature_flags;
7555 
7556 	if (op_mode == IN_PLACE) {
7557 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7558 			printf("Device doesn't support in-place scatter-gather "
7559 					"in both input and output mbufs.\n");
7560 			return TEST_SKIPPED;
7561 		}
7562 	} else {
7563 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7564 			printf("Device doesn't support out-of-place scatter-gather "
7565 					"in both input and output mbufs.\n");
7566 			return TEST_SKIPPED;
7567 		}
7568 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7569 			printf("Device doesn't support digest encrypted.\n");
7570 			return TEST_SKIPPED;
7571 		}
7572 	}
7573 
7574 	/* Create the session */
7575 	if (verify)
7576 		retval = create_wireless_algo_cipher_auth_session(
7577 				ts_params->valid_devs[0],
7578 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
7579 				RTE_CRYPTO_AUTH_OP_VERIFY,
7580 				tdata->auth_algo,
7581 				tdata->cipher_algo,
7582 				tdata->auth_key.data, tdata->auth_key.len,
7583 				tdata->auth_iv.len, tdata->digest_enc.len,
7584 				tdata->cipher_iv.len);
7585 	else
7586 		retval = create_wireless_algo_auth_cipher_session(
7587 				ts_params->valid_devs[0],
7588 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7589 				RTE_CRYPTO_AUTH_OP_GENERATE,
7590 				tdata->auth_algo,
7591 				tdata->cipher_algo,
7592 				tdata->auth_key.data, tdata->auth_key.len,
7593 				tdata->auth_iv.len, tdata->digest_enc.len,
7594 				tdata->cipher_iv.len);
7595 	if (retval != 0)
7596 		return retval;
7597 
7598 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7599 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7600 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7601 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7602 
7603 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7604 			ciphertext_pad_len, 15, 0);
7605 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7606 			"Failed to allocate input buffer in mempool");
7607 
7608 	if (op_mode == OUT_OF_PLACE) {
7609 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7610 				plaintext_pad_len, 15, 0);
7611 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
7612 				"Failed to allocate output buffer in mempool");
7613 	}
7614 
7615 	if (verify) {
7616 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7617 			tdata->ciphertext.data);
7618 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7619 					ciphertext_len, buffer);
7620 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7621 			ciphertext_len);
7622 	} else {
7623 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7624 			tdata->plaintext.data);
7625 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7626 					plaintext_len, buffer);
7627 		debug_hexdump(stdout, "plaintext:", plaintext,
7628 			plaintext_len);
7629 	}
7630 	memset(buffer, 0, sizeof(buffer));
7631 
7632 	/* Create the operation */
7633 	retval = create_wireless_algo_auth_cipher_operation(
7634 			tdata->digest_enc.data, tdata->digest_enc.len,
7635 			tdata->cipher_iv.data, tdata->cipher_iv.len,
7636 			tdata->auth_iv.data, tdata->auth_iv.len,
7637 			(tdata->digest_enc.offset == 0 ?
7638 				plaintext_pad_len
7639 				: tdata->digest_enc.offset),
7640 			tdata->validCipherLen.len_bits,
7641 			tdata->cipher.offset_bits,
7642 			tdata->validAuthLen.len_bits,
7643 			tdata->auth.offset_bits,
7644 			op_mode, 1, verify);
7645 
7646 	if (retval < 0)
7647 		return retval;
7648 
7649 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7650 
7651 	/* Check if the op failed because the device doesn't */
7652 	/* support this particular combination of algorithms */
7653 	if (op == NULL && ut_params->op->status ==
7654 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7655 		printf("Device doesn't support this mixed combination. "
7656 				"Test Skipped.\n");
7657 		return TEST_SKIPPED;
7658 	}
7659 	ut_params->op = op;
7660 
7661 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7662 
7663 	ut_params->obuf = (op_mode == IN_PLACE ?
7664 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7665 
7666 	if (verify) {
7667 		if (ut_params->obuf)
7668 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7669 					plaintext_len, buffer);
7670 		else
7671 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7672 					plaintext_len, buffer);
7673 
7674 		debug_hexdump(stdout, "plaintext:", plaintext,
7675 				(tdata->plaintext.len_bits >> 3) -
7676 				tdata->digest_enc.len);
7677 		debug_hexdump(stdout, "plaintext expected:",
7678 				tdata->plaintext.data,
7679 				(tdata->plaintext.len_bits >> 3) -
7680 				tdata->digest_enc.len);
7681 	} else {
7682 		if (ut_params->obuf)
7683 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7684 					ciphertext_len, buffer);
7685 		else
7686 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7687 					ciphertext_len, buffer);
7688 
7689 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7690 			ciphertext_len);
7691 		debug_hexdump(stdout, "ciphertext expected:",
7692 			tdata->ciphertext.data,
7693 			tdata->ciphertext.len_bits >> 3);
7694 
7695 		if (ut_params->obuf)
7696 			digest = rte_pktmbuf_read(ut_params->obuf,
7697 					(tdata->digest_enc.offset == 0 ?
7698 						plaintext_pad_len :
7699 						tdata->digest_enc.offset),
7700 					tdata->digest_enc.len, digest_buffer);
7701 		else
7702 			digest = rte_pktmbuf_read(ut_params->ibuf,
7703 					(tdata->digest_enc.offset == 0 ?
7704 						plaintext_pad_len :
7705 						tdata->digest_enc.offset),
7706 					tdata->digest_enc.len, digest_buffer);
7707 
7708 		debug_hexdump(stdout, "digest:", digest,
7709 				tdata->digest_enc.len);
7710 		debug_hexdump(stdout, "digest expected:",
7711 				tdata->digest_enc.data, tdata->digest_enc.len);
7712 	}
7713 
7714 	if (!verify) {
7715 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7716 				digest,
7717 				tdata->digest_enc.data,
7718 				tdata->digest_enc.len,
7719 				"Generated auth tag not as expected");
7720 	}
7721 
7722 	if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7723 		if (verify) {
7724 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7725 					plaintext,
7726 					tdata->plaintext.data,
7727 					tdata->plaintext.len_bits >> 3,
7728 					"Plaintext data not as expected");
7729 		} else {
7730 			TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7731 					ciphertext,
7732 					tdata->ciphertext.data,
7733 					tdata->validDataLen.len_bits,
7734 					"Ciphertext data not as expected");
7735 		}
7736 	}
7737 
7738 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7739 			"crypto op processing failed");
7740 
7741 	return 0;
7742 }
7743 
7744 /** AUTH AES CMAC + CIPHER AES CTR */
7745 
7746 static int
7747 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7748 {
7749 	return test_mixed_auth_cipher(
7750 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7751 }
7752 
7753 static int
7754 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7755 {
7756 	return test_mixed_auth_cipher(
7757 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7758 }
7759 
7760 static int
7761 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7762 {
7763 	return test_mixed_auth_cipher_sgl(
7764 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7765 }
7766 
7767 static int
7768 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7769 {
7770 	return test_mixed_auth_cipher_sgl(
7771 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7772 }
7773 
7774 static int
7775 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7776 {
7777 	return test_mixed_auth_cipher(
7778 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7779 }
7780 
7781 static int
7782 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7783 {
7784 	return test_mixed_auth_cipher(
7785 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7786 }
7787 
7788 static int
7789 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7790 {
7791 	return test_mixed_auth_cipher_sgl(
7792 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7793 }
7794 
7795 static int
7796 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7797 {
7798 	return test_mixed_auth_cipher_sgl(
7799 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7800 }
7801 
7802 /** MIXED AUTH + CIPHER */
7803 
7804 static int
7805 test_auth_zuc_cipher_snow_test_case_1(void)
7806 {
7807 	return test_mixed_auth_cipher(
7808 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7809 }
7810 
7811 static int
7812 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7813 {
7814 	return test_mixed_auth_cipher(
7815 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7816 }
7817 
7818 static int
7819 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7820 {
7821 	return test_mixed_auth_cipher(
7822 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7823 }
7824 
7825 static int
7826 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7827 {
7828 	return test_mixed_auth_cipher(
7829 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7830 }
7831 
7832 static int
7833 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7834 {
7835 	return test_mixed_auth_cipher(
7836 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7837 }
7838 
7839 static int
7840 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7841 {
7842 	return test_mixed_auth_cipher(
7843 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7844 }
7845 
7846 static int
7847 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7848 {
7849 	return test_mixed_auth_cipher(
7850 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7851 }
7852 
7853 static int
7854 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7855 {
7856 	return test_mixed_auth_cipher(
7857 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7858 }
7859 
7860 static int
7861 test_auth_snow_cipher_zuc_test_case_1(void)
7862 {
7863 	return test_mixed_auth_cipher(
7864 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7865 }
7866 
7867 static int
7868 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7869 {
7870 	return test_mixed_auth_cipher(
7871 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7872 }
7873 
7874 static int
7875 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7876 {
7877 	return test_mixed_auth_cipher(
7878 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7879 }
7880 
7881 static int
7882 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7883 {
7884 	return test_mixed_auth_cipher(
7885 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7886 }
7887 
7888 static int
7889 test_auth_null_cipher_snow_test_case_1(void)
7890 {
7891 	return test_mixed_auth_cipher(
7892 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7893 }
7894 
7895 static int
7896 test_verify_auth_null_cipher_snow_test_case_1(void)
7897 {
7898 	return test_mixed_auth_cipher(
7899 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7900 }
7901 
7902 static int
7903 test_auth_null_cipher_zuc_test_case_1(void)
7904 {
7905 	return test_mixed_auth_cipher(
7906 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7907 }
7908 
7909 static int
7910 test_verify_auth_null_cipher_zuc_test_case_1(void)
7911 {
7912 	return test_mixed_auth_cipher(
7913 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7914 }
7915 
7916 static int
7917 test_auth_snow_cipher_null_test_case_1(void)
7918 {
7919 	return test_mixed_auth_cipher(
7920 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7921 }
7922 
7923 static int
7924 test_verify_auth_snow_cipher_null_test_case_1(void)
7925 {
7926 	return test_mixed_auth_cipher(
7927 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7928 }
7929 
7930 static int
7931 test_auth_zuc_cipher_null_test_case_1(void)
7932 {
7933 	return test_mixed_auth_cipher(
7934 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7935 }
7936 
7937 static int
7938 test_verify_auth_zuc_cipher_null_test_case_1(void)
7939 {
7940 	return test_mixed_auth_cipher(
7941 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7942 }
7943 
7944 static int
7945 test_auth_null_cipher_aes_ctr_test_case_1(void)
7946 {
7947 	return test_mixed_auth_cipher(
7948 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7949 }
7950 
7951 static int
7952 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7953 {
7954 	return test_mixed_auth_cipher(
7955 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7956 }
7957 
7958 static int
7959 test_auth_aes_cmac_cipher_null_test_case_1(void)
7960 {
7961 	return test_mixed_auth_cipher(
7962 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7963 }
7964 
7965 static int
7966 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7967 {
7968 	return test_mixed_auth_cipher(
7969 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7970 }
7971 
7972 /* ***** AEAD algorithm Tests ***** */
7973 
7974 static int
7975 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7976 		enum rte_crypto_aead_operation op,
7977 		const uint8_t *key, const uint8_t key_len,
7978 		const uint16_t aad_len, const uint8_t auth_len,
7979 		uint8_t iv_len)
7980 {
7981 	uint8_t aead_key[key_len];
7982 	int status;
7983 
7984 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7985 	struct crypto_unittest_params *ut_params = &unittest_params;
7986 
7987 	memcpy(aead_key, key, key_len);
7988 
7989 	/* Setup AEAD Parameters */
7990 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7991 	ut_params->aead_xform.next = NULL;
7992 	ut_params->aead_xform.aead.algo = algo;
7993 	ut_params->aead_xform.aead.op = op;
7994 	ut_params->aead_xform.aead.key.data = aead_key;
7995 	ut_params->aead_xform.aead.key.length = key_len;
7996 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7997 	ut_params->aead_xform.aead.iv.length = iv_len;
7998 	ut_params->aead_xform.aead.digest_length = auth_len;
7999 	ut_params->aead_xform.aead.aad_length = aad_len;
8000 
8001 	debug_hexdump(stdout, "key:", key, key_len);
8002 
8003 	/* Create Crypto session*/
8004 	ut_params->sess = rte_cryptodev_sym_session_create(
8005 			ts_params->session_mpool);
8006 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8007 
8008 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8009 			&ut_params->aead_xform,
8010 			ts_params->session_priv_mpool);
8011 
8012 	return status;
8013 }
8014 
8015 static int
8016 create_aead_xform(struct rte_crypto_op *op,
8017 		enum rte_crypto_aead_algorithm algo,
8018 		enum rte_crypto_aead_operation aead_op,
8019 		uint8_t *key, const uint8_t key_len,
8020 		const uint8_t aad_len, const uint8_t auth_len,
8021 		uint8_t iv_len)
8022 {
8023 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8024 			"failed to allocate space for crypto transform");
8025 
8026 	struct rte_crypto_sym_op *sym_op = op->sym;
8027 
8028 	/* Setup AEAD Parameters */
8029 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8030 	sym_op->xform->next = NULL;
8031 	sym_op->xform->aead.algo = algo;
8032 	sym_op->xform->aead.op = aead_op;
8033 	sym_op->xform->aead.key.data = key;
8034 	sym_op->xform->aead.key.length = key_len;
8035 	sym_op->xform->aead.iv.offset = IV_OFFSET;
8036 	sym_op->xform->aead.iv.length = iv_len;
8037 	sym_op->xform->aead.digest_length = auth_len;
8038 	sym_op->xform->aead.aad_length = aad_len;
8039 
8040 	debug_hexdump(stdout, "key:", key, key_len);
8041 
8042 	return 0;
8043 }
8044 
8045 static int
8046 create_aead_operation(enum rte_crypto_aead_operation op,
8047 		const struct aead_test_data *tdata)
8048 {
8049 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8050 	struct crypto_unittest_params *ut_params = &unittest_params;
8051 
8052 	uint8_t *plaintext, *ciphertext;
8053 	unsigned int aad_pad_len, plaintext_pad_len;
8054 
8055 	/* Generate Crypto op data structure */
8056 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8057 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8058 	TEST_ASSERT_NOT_NULL(ut_params->op,
8059 			"Failed to allocate symmetric crypto operation struct");
8060 
8061 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8062 
8063 	/* Append aad data */
8064 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8065 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8066 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8067 				aad_pad_len);
8068 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8069 				"no room to append aad");
8070 
8071 		sym_op->aead.aad.phys_addr =
8072 				rte_pktmbuf_iova(ut_params->ibuf);
8073 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
8074 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8075 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8076 			tdata->aad.len);
8077 
8078 		/* Append IV at the end of the crypto operation*/
8079 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8080 				uint8_t *, IV_OFFSET);
8081 
8082 		/* Copy IV 1 byte after the IV pointer, according to the API */
8083 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8084 		debug_hexdump(stdout, "iv:", iv_ptr,
8085 			tdata->iv.len);
8086 	} else {
8087 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8088 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8089 				aad_pad_len);
8090 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8091 				"no room to append aad");
8092 
8093 		sym_op->aead.aad.phys_addr =
8094 				rte_pktmbuf_iova(ut_params->ibuf);
8095 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8096 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8097 			tdata->aad.len);
8098 
8099 		/* Append IV at the end of the crypto operation*/
8100 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8101 				uint8_t *, IV_OFFSET);
8102 
8103 		if (tdata->iv.len == 0) {
8104 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8105 			debug_hexdump(stdout, "iv:", iv_ptr,
8106 				AES_GCM_J0_LENGTH);
8107 		} else {
8108 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8109 			debug_hexdump(stdout, "iv:", iv_ptr,
8110 				tdata->iv.len);
8111 		}
8112 	}
8113 
8114 	/* Append plaintext/ciphertext */
8115 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8116 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8117 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8118 				plaintext_pad_len);
8119 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8120 
8121 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8122 		debug_hexdump(stdout, "plaintext:", plaintext,
8123 				tdata->plaintext.len);
8124 
8125 		if (ut_params->obuf) {
8126 			ciphertext = (uint8_t *)rte_pktmbuf_append(
8127 					ut_params->obuf,
8128 					plaintext_pad_len + aad_pad_len);
8129 			TEST_ASSERT_NOT_NULL(ciphertext,
8130 					"no room to append ciphertext");
8131 
8132 			memset(ciphertext + aad_pad_len, 0,
8133 					tdata->ciphertext.len);
8134 		}
8135 	} else {
8136 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8137 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8138 				plaintext_pad_len);
8139 		TEST_ASSERT_NOT_NULL(ciphertext,
8140 				"no room to append ciphertext");
8141 
8142 		memcpy(ciphertext, tdata->ciphertext.data,
8143 				tdata->ciphertext.len);
8144 		debug_hexdump(stdout, "ciphertext:", ciphertext,
8145 				tdata->ciphertext.len);
8146 
8147 		if (ut_params->obuf) {
8148 			plaintext = (uint8_t *)rte_pktmbuf_append(
8149 					ut_params->obuf,
8150 					plaintext_pad_len + aad_pad_len);
8151 			TEST_ASSERT_NOT_NULL(plaintext,
8152 					"no room to append plaintext");
8153 
8154 			memset(plaintext + aad_pad_len, 0,
8155 					tdata->plaintext.len);
8156 		}
8157 	}
8158 
8159 	/* Append digest data */
8160 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8161 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8162 				ut_params->obuf ? ut_params->obuf :
8163 						ut_params->ibuf,
8164 						tdata->auth_tag.len);
8165 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8166 				"no room to append digest");
8167 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8168 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8169 				ut_params->obuf ? ut_params->obuf :
8170 						ut_params->ibuf,
8171 						plaintext_pad_len +
8172 						aad_pad_len);
8173 	} else {
8174 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8175 				ut_params->ibuf, tdata->auth_tag.len);
8176 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8177 				"no room to append digest");
8178 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8179 				ut_params->ibuf,
8180 				plaintext_pad_len + aad_pad_len);
8181 
8182 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8183 			tdata->auth_tag.len);
8184 		debug_hexdump(stdout, "digest:",
8185 			sym_op->aead.digest.data,
8186 			tdata->auth_tag.len);
8187 	}
8188 
8189 	sym_op->aead.data.length = tdata->plaintext.len;
8190 	sym_op->aead.data.offset = aad_pad_len;
8191 
8192 	return 0;
8193 }
8194 
8195 static int
8196 test_authenticated_encryption(const struct aead_test_data *tdata)
8197 {
8198 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8199 	struct crypto_unittest_params *ut_params = &unittest_params;
8200 
8201 	int retval;
8202 	uint8_t *ciphertext, *auth_tag;
8203 	uint16_t plaintext_pad_len;
8204 	uint32_t i;
8205 	struct rte_cryptodev_info dev_info;
8206 
8207 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8208 	uint64_t feat_flags = dev_info.feature_flags;
8209 
8210 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8211 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8212 		printf("Device doesn't support RAW data-path APIs.\n");
8213 		return TEST_SKIPPED;
8214 	}
8215 
8216 	/* Verify the capabilities */
8217 	struct rte_cryptodev_sym_capability_idx cap_idx;
8218 	const struct rte_cryptodev_symmetric_capability *capability;
8219 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8220 	cap_idx.algo.aead = tdata->algo;
8221 	capability = rte_cryptodev_sym_capability_get(
8222 			ts_params->valid_devs[0], &cap_idx);
8223 	if (capability == NULL)
8224 		return TEST_SKIPPED;
8225 	if (rte_cryptodev_sym_capability_check_aead(
8226 			capability, tdata->key.len, tdata->auth_tag.len,
8227 			tdata->aad.len, tdata->iv.len))
8228 		return TEST_SKIPPED;
8229 
8230 	/* Create AEAD session */
8231 	retval = create_aead_session(ts_params->valid_devs[0],
8232 			tdata->algo,
8233 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
8234 			tdata->key.data, tdata->key.len,
8235 			tdata->aad.len, tdata->auth_tag.len,
8236 			tdata->iv.len);
8237 	if (retval < 0)
8238 		return retval;
8239 
8240 	if (tdata->aad.len > MBUF_SIZE) {
8241 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8242 		/* Populate full size of add data */
8243 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8244 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8245 	} else
8246 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8247 
8248 	/* clear mbuf payload */
8249 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8250 			rte_pktmbuf_tailroom(ut_params->ibuf));
8251 
8252 	/* Create AEAD operation */
8253 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8254 	if (retval < 0)
8255 		return retval;
8256 
8257 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8258 
8259 	ut_params->op->sym->m_src = ut_params->ibuf;
8260 
8261 	/* Process crypto operation */
8262 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8263 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8264 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8265 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8266 				ut_params->op, 0, 0, 0, 0);
8267 	else
8268 		TEST_ASSERT_NOT_NULL(
8269 			process_crypto_request(ts_params->valid_devs[0],
8270 			ut_params->op), "failed to process sym crypto op");
8271 
8272 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8273 			"crypto op processing failed");
8274 
8275 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8276 
8277 	if (ut_params->op->sym->m_dst) {
8278 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8279 				uint8_t *);
8280 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8281 				uint8_t *, plaintext_pad_len);
8282 	} else {
8283 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8284 				uint8_t *,
8285 				ut_params->op->sym->cipher.data.offset);
8286 		auth_tag = ciphertext + plaintext_pad_len;
8287 	}
8288 
8289 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8290 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8291 
8292 	/* Validate obuf */
8293 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8294 			ciphertext,
8295 			tdata->ciphertext.data,
8296 			tdata->ciphertext.len,
8297 			"Ciphertext data not as expected");
8298 
8299 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8300 			auth_tag,
8301 			tdata->auth_tag.data,
8302 			tdata->auth_tag.len,
8303 			"Generated auth tag not as expected");
8304 
8305 	return 0;
8306 
8307 }
8308 
8309 #ifdef RTE_LIB_SECURITY
8310 static int
8311 security_proto_supported(enum rte_security_session_action_type action,
8312 	enum rte_security_session_protocol proto)
8313 {
8314 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8315 
8316 	const struct rte_security_capability *capabilities;
8317 	const struct rte_security_capability *capability;
8318 	uint16_t i = 0;
8319 
8320 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8321 				rte_cryptodev_get_sec_ctx(
8322 				ts_params->valid_devs[0]);
8323 
8324 
8325 	capabilities = rte_security_capabilities_get(ctx);
8326 
8327 	if (capabilities == NULL)
8328 		return -ENOTSUP;
8329 
8330 	while ((capability = &capabilities[i++])->action !=
8331 			RTE_SECURITY_ACTION_TYPE_NONE) {
8332 		if (capability->action == action &&
8333 				capability->protocol == proto)
8334 			return 0;
8335 	}
8336 
8337 	return -ENOTSUP;
8338 }
8339 
8340 /* Basic algorithm run function for async inplace mode.
8341  * Creates a session from input parameters and runs one operation
8342  * on input_vec. Checks the output of the crypto operation against
8343  * output_vec.
8344  */
8345 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8346 			   enum rte_crypto_auth_operation opa,
8347 			   const uint8_t *input_vec, unsigned int input_vec_len,
8348 			   const uint8_t *output_vec,
8349 			   unsigned int output_vec_len,
8350 			   enum rte_crypto_cipher_algorithm cipher_alg,
8351 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
8352 			   enum rte_crypto_auth_algorithm auth_alg,
8353 			   const uint8_t *auth_key, uint32_t auth_key_len,
8354 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
8355 			   uint8_t packet_direction, uint8_t sn_size,
8356 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8357 {
8358 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8359 	struct crypto_unittest_params *ut_params = &unittest_params;
8360 	uint8_t *plaintext;
8361 	int ret = TEST_SUCCESS;
8362 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8363 				rte_cryptodev_get_sec_ctx(
8364 				ts_params->valid_devs[0]);
8365 
8366 	/* Verify the capabilities */
8367 	struct rte_security_capability_idx sec_cap_idx;
8368 
8369 	sec_cap_idx.action = ut_params->type;
8370 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8371 	sec_cap_idx.pdcp.domain = domain;
8372 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8373 		return TEST_SKIPPED;
8374 
8375 	/* Generate test mbuf data */
8376 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8377 
8378 	/* clear mbuf payload */
8379 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8380 			rte_pktmbuf_tailroom(ut_params->ibuf));
8381 
8382 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8383 						  input_vec_len);
8384 	memcpy(plaintext, input_vec, input_vec_len);
8385 
8386 	/* Out of place support */
8387 	if (oop) {
8388 		/*
8389 		 * For out-op-place we need to alloc another mbuf
8390 		 */
8391 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8392 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8393 	}
8394 
8395 	/* Setup Cipher Parameters */
8396 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8397 	ut_params->cipher_xform.cipher.algo = cipher_alg;
8398 	ut_params->cipher_xform.cipher.op = opc;
8399 	ut_params->cipher_xform.cipher.key.data = cipher_key;
8400 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8401 	ut_params->cipher_xform.cipher.iv.length =
8402 				packet_direction ? 4 : 0;
8403 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8404 
8405 	/* Setup HMAC Parameters if ICV header is required */
8406 	if (auth_alg != 0) {
8407 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8408 		ut_params->auth_xform.next = NULL;
8409 		ut_params->auth_xform.auth.algo = auth_alg;
8410 		ut_params->auth_xform.auth.op = opa;
8411 		ut_params->auth_xform.auth.key.data = auth_key;
8412 		ut_params->auth_xform.auth.key.length = auth_key_len;
8413 
8414 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8415 	} else {
8416 		ut_params->cipher_xform.next = NULL;
8417 	}
8418 
8419 	struct rte_security_session_conf sess_conf = {
8420 		.action_type = ut_params->type,
8421 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8422 		{.pdcp = {
8423 			.bearer = bearer,
8424 			.domain = domain,
8425 			.pkt_dir = packet_direction,
8426 			.sn_size = sn_size,
8427 			.hfn = packet_direction ? 0 : hfn,
8428 			/**
8429 			 * hfn can be set as pdcp_test_hfn[i]
8430 			 * if hfn_ovrd is not set. Here, PDCP
8431 			 * packet direction is just used to
8432 			 * run half of the cases with session
8433 			 * HFN and other half with per packet
8434 			 * HFN.
8435 			 */
8436 			.hfn_threshold = hfn_threshold,
8437 			.hfn_ovrd = packet_direction ? 1 : 0,
8438 			.sdap_enabled = sdap,
8439 		} },
8440 		.crypto_xform = &ut_params->cipher_xform
8441 	};
8442 
8443 	/* Create security session */
8444 	ut_params->sec_session = rte_security_session_create(ctx,
8445 				&sess_conf, ts_params->session_mpool,
8446 				ts_params->session_priv_mpool);
8447 
8448 	if (!ut_params->sec_session) {
8449 		printf("TestCase %s()-%d line %d failed %s: ",
8450 			__func__, i, __LINE__, "Failed to allocate session");
8451 		ret = TEST_FAILED;
8452 		goto on_err;
8453 	}
8454 
8455 	/* Generate crypto op data structure */
8456 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8457 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8458 	if (!ut_params->op) {
8459 		printf("TestCase %s()-%d line %d failed %s: ",
8460 			__func__, i, __LINE__,
8461 			"Failed to allocate symmetric crypto operation struct");
8462 		ret = TEST_FAILED;
8463 		goto on_err;
8464 	}
8465 
8466 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8467 					uint32_t *, IV_OFFSET);
8468 	*per_pkt_hfn = packet_direction ? hfn : 0;
8469 
8470 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8471 
8472 	/* set crypto operation source mbuf */
8473 	ut_params->op->sym->m_src = ut_params->ibuf;
8474 	if (oop)
8475 		ut_params->op->sym->m_dst = ut_params->obuf;
8476 
8477 	/* Process crypto operation */
8478 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8479 		== NULL) {
8480 		printf("TestCase %s()-%d line %d failed %s: ",
8481 			__func__, i, __LINE__,
8482 			"failed to process sym crypto op");
8483 		ret = TEST_FAILED;
8484 		goto on_err;
8485 	}
8486 
8487 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8488 		printf("TestCase %s()-%d line %d failed %s: ",
8489 			__func__, i, __LINE__, "crypto op processing failed");
8490 		ret = TEST_FAILED;
8491 		goto on_err;
8492 	}
8493 
8494 	/* Validate obuf */
8495 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8496 			uint8_t *);
8497 	if (oop) {
8498 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8499 				uint8_t *);
8500 	}
8501 
8502 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
8503 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8504 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8505 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8506 		ret = TEST_FAILED;
8507 		goto on_err;
8508 	}
8509 
8510 on_err:
8511 	rte_crypto_op_free(ut_params->op);
8512 	ut_params->op = NULL;
8513 
8514 	if (ut_params->sec_session)
8515 		rte_security_session_destroy(ctx, ut_params->sec_session);
8516 	ut_params->sec_session = NULL;
8517 
8518 	rte_pktmbuf_free(ut_params->ibuf);
8519 	ut_params->ibuf = NULL;
8520 	if (oop) {
8521 		rte_pktmbuf_free(ut_params->obuf);
8522 		ut_params->obuf = NULL;
8523 	}
8524 
8525 	return ret;
8526 }
8527 
8528 static int
8529 test_pdcp_proto_SGL(int i, int oop,
8530 	enum rte_crypto_cipher_operation opc,
8531 	enum rte_crypto_auth_operation opa,
8532 	uint8_t *input_vec,
8533 	unsigned int input_vec_len,
8534 	uint8_t *output_vec,
8535 	unsigned int output_vec_len,
8536 	uint32_t fragsz,
8537 	uint32_t fragsz_oop)
8538 {
8539 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8540 	struct crypto_unittest_params *ut_params = &unittest_params;
8541 	uint8_t *plaintext;
8542 	struct rte_mbuf *buf, *buf_oop = NULL;
8543 	int ret = TEST_SUCCESS;
8544 	int to_trn = 0;
8545 	int to_trn_tbl[16];
8546 	int segs = 1;
8547 	unsigned int trn_data = 0;
8548 	struct rte_cryptodev_info dev_info;
8549 	uint64_t feat_flags;
8550 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8551 				rte_cryptodev_get_sec_ctx(
8552 				ts_params->valid_devs[0]);
8553 	struct rte_mbuf *temp_mbuf;
8554 
8555 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8556 	feat_flags = dev_info.feature_flags;
8557 
8558 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8559 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8560 		printf("Device does not support RAW data-path APIs.\n");
8561 		return -ENOTSUP;
8562 	}
8563 	/* Verify the capabilities */
8564 	struct rte_security_capability_idx sec_cap_idx;
8565 
8566 	sec_cap_idx.action = ut_params->type;
8567 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8568 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8569 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8570 		return TEST_SKIPPED;
8571 
8572 	if (fragsz > input_vec_len)
8573 		fragsz = input_vec_len;
8574 
8575 	uint16_t plaintext_len = fragsz;
8576 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8577 
8578 	if (fragsz_oop > output_vec_len)
8579 		frag_size_oop = output_vec_len;
8580 
8581 	int ecx = 0;
8582 	if (input_vec_len % fragsz != 0) {
8583 		if (input_vec_len / fragsz + 1 > 16)
8584 			return 1;
8585 	} else if (input_vec_len / fragsz > 16)
8586 		return 1;
8587 
8588 	/* Out of place support */
8589 	if (oop) {
8590 		/*
8591 		 * For out-op-place we need to alloc another mbuf
8592 		 */
8593 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8594 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8595 		buf_oop = ut_params->obuf;
8596 	}
8597 
8598 	/* Generate test mbuf data */
8599 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8600 
8601 	/* clear mbuf payload */
8602 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8603 			rte_pktmbuf_tailroom(ut_params->ibuf));
8604 
8605 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8606 						  plaintext_len);
8607 	memcpy(plaintext, input_vec, plaintext_len);
8608 	trn_data += plaintext_len;
8609 
8610 	buf = ut_params->ibuf;
8611 
8612 	/*
8613 	 * Loop until no more fragments
8614 	 */
8615 
8616 	while (trn_data < input_vec_len) {
8617 		++segs;
8618 		to_trn = (input_vec_len - trn_data < fragsz) ?
8619 				(input_vec_len - trn_data) : fragsz;
8620 
8621 		to_trn_tbl[ecx++] = to_trn;
8622 
8623 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8624 		buf = buf->next;
8625 
8626 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8627 				rte_pktmbuf_tailroom(buf));
8628 
8629 		/* OOP */
8630 		if (oop && !fragsz_oop) {
8631 			buf_oop->next =
8632 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
8633 			buf_oop = buf_oop->next;
8634 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8635 					0, rte_pktmbuf_tailroom(buf_oop));
8636 			rte_pktmbuf_append(buf_oop, to_trn);
8637 		}
8638 
8639 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8640 				to_trn);
8641 
8642 		memcpy(plaintext, input_vec + trn_data, to_trn);
8643 		trn_data += to_trn;
8644 	}
8645 
8646 	ut_params->ibuf->nb_segs = segs;
8647 
8648 	segs = 1;
8649 	if (fragsz_oop && oop) {
8650 		to_trn = 0;
8651 		ecx = 0;
8652 
8653 		trn_data = frag_size_oop;
8654 		while (trn_data < output_vec_len) {
8655 			++segs;
8656 			to_trn =
8657 				(output_vec_len - trn_data <
8658 						frag_size_oop) ?
8659 				(output_vec_len - trn_data) :
8660 						frag_size_oop;
8661 
8662 			to_trn_tbl[ecx++] = to_trn;
8663 
8664 			buf_oop->next =
8665 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
8666 			buf_oop = buf_oop->next;
8667 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8668 					0, rte_pktmbuf_tailroom(buf_oop));
8669 			rte_pktmbuf_append(buf_oop, to_trn);
8670 
8671 			trn_data += to_trn;
8672 		}
8673 		ut_params->obuf->nb_segs = segs;
8674 	}
8675 
8676 	/* Setup Cipher Parameters */
8677 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8678 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8679 	ut_params->cipher_xform.cipher.op = opc;
8680 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8681 	ut_params->cipher_xform.cipher.key.length =
8682 					pdcp_test_params[i].cipher_key_len;
8683 	ut_params->cipher_xform.cipher.iv.length = 0;
8684 
8685 	/* Setup HMAC Parameters if ICV header is required */
8686 	if (pdcp_test_params[i].auth_alg != 0) {
8687 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8688 		ut_params->auth_xform.next = NULL;
8689 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8690 		ut_params->auth_xform.auth.op = opa;
8691 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8692 		ut_params->auth_xform.auth.key.length =
8693 					pdcp_test_params[i].auth_key_len;
8694 
8695 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8696 	} else {
8697 		ut_params->cipher_xform.next = NULL;
8698 	}
8699 
8700 	struct rte_security_session_conf sess_conf = {
8701 		.action_type = ut_params->type,
8702 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8703 		{.pdcp = {
8704 			.bearer = pdcp_test_bearer[i],
8705 			.domain = pdcp_test_params[i].domain,
8706 			.pkt_dir = pdcp_test_packet_direction[i],
8707 			.sn_size = pdcp_test_data_sn_size[i],
8708 			.hfn = pdcp_test_hfn[i],
8709 			.hfn_threshold = pdcp_test_hfn_threshold[i],
8710 			.hfn_ovrd = 0,
8711 		} },
8712 		.crypto_xform = &ut_params->cipher_xform
8713 	};
8714 
8715 	/* Create security session */
8716 	ut_params->sec_session = rte_security_session_create(ctx,
8717 				&sess_conf, ts_params->session_mpool,
8718 				ts_params->session_priv_mpool);
8719 
8720 	if (!ut_params->sec_session) {
8721 		printf("TestCase %s()-%d line %d failed %s: ",
8722 			__func__, i, __LINE__, "Failed to allocate session");
8723 		ret = TEST_FAILED;
8724 		goto on_err;
8725 	}
8726 
8727 	/* Generate crypto op data structure */
8728 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8729 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8730 	if (!ut_params->op) {
8731 		printf("TestCase %s()-%d line %d failed %s: ",
8732 			__func__, i, __LINE__,
8733 			"Failed to allocate symmetric crypto operation struct");
8734 		ret = TEST_FAILED;
8735 		goto on_err;
8736 	}
8737 
8738 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8739 
8740 	/* set crypto operation source mbuf */
8741 	ut_params->op->sym->m_src = ut_params->ibuf;
8742 	if (oop)
8743 		ut_params->op->sym->m_dst = ut_params->obuf;
8744 
8745 	/* Process crypto operation */
8746 	temp_mbuf = ut_params->op->sym->m_src;
8747 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8748 		/* filling lengths */
8749 		while (temp_mbuf) {
8750 			ut_params->op->sym->cipher.data.length
8751 				+= temp_mbuf->pkt_len;
8752 			ut_params->op->sym->auth.data.length
8753 				+= temp_mbuf->pkt_len;
8754 			temp_mbuf = temp_mbuf->next;
8755 		}
8756 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8757 			ut_params->op, 1, 1, 0, 0);
8758 	} else {
8759 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8760 							ut_params->op);
8761 	}
8762 	if (ut_params->op == NULL) {
8763 		printf("TestCase %s()-%d line %d failed %s: ",
8764 			__func__, i, __LINE__,
8765 			"failed to process sym crypto op");
8766 		ret = TEST_FAILED;
8767 		goto on_err;
8768 	}
8769 
8770 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8771 		printf("TestCase %s()-%d line %d failed %s: ",
8772 			__func__, i, __LINE__, "crypto op processing failed");
8773 		ret = TEST_FAILED;
8774 		goto on_err;
8775 	}
8776 
8777 	/* Validate obuf */
8778 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8779 			uint8_t *);
8780 	if (oop) {
8781 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8782 				uint8_t *);
8783 	}
8784 	if (fragsz_oop)
8785 		fragsz = frag_size_oop;
8786 	if (memcmp(ciphertext, output_vec, fragsz)) {
8787 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8788 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8789 		rte_hexdump(stdout, "reference", output_vec, fragsz);
8790 		ret = TEST_FAILED;
8791 		goto on_err;
8792 	}
8793 
8794 	buf = ut_params->op->sym->m_src->next;
8795 	if (oop)
8796 		buf = ut_params->op->sym->m_dst->next;
8797 
8798 	unsigned int off = fragsz;
8799 
8800 	ecx = 0;
8801 	while (buf) {
8802 		ciphertext = rte_pktmbuf_mtod(buf,
8803 				uint8_t *);
8804 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8805 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8806 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8807 			rte_hexdump(stdout, "reference", output_vec + off,
8808 					to_trn_tbl[ecx]);
8809 			ret = TEST_FAILED;
8810 			goto on_err;
8811 		}
8812 		off += to_trn_tbl[ecx++];
8813 		buf = buf->next;
8814 	}
8815 on_err:
8816 	rte_crypto_op_free(ut_params->op);
8817 	ut_params->op = NULL;
8818 
8819 	if (ut_params->sec_session)
8820 		rte_security_session_destroy(ctx, ut_params->sec_session);
8821 	ut_params->sec_session = NULL;
8822 
8823 	rte_pktmbuf_free(ut_params->ibuf);
8824 	ut_params->ibuf = NULL;
8825 	if (oop) {
8826 		rte_pktmbuf_free(ut_params->obuf);
8827 		ut_params->obuf = NULL;
8828 	}
8829 
8830 	return ret;
8831 }
8832 
8833 int
8834 test_pdcp_proto_cplane_encap(int i)
8835 {
8836 	return test_pdcp_proto(
8837 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8838 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8839 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8840 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8841 		pdcp_test_params[i].cipher_key_len,
8842 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8843 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8844 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8845 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8846 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8847 }
8848 
8849 int
8850 test_pdcp_proto_uplane_encap(int i)
8851 {
8852 	return test_pdcp_proto(
8853 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8854 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8855 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8856 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8857 		pdcp_test_params[i].cipher_key_len,
8858 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8859 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8860 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8861 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8862 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8863 }
8864 
8865 int
8866 test_pdcp_proto_uplane_encap_with_int(int i)
8867 {
8868 	return test_pdcp_proto(
8869 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8870 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8871 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8872 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8873 		pdcp_test_params[i].cipher_key_len,
8874 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8875 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8876 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8877 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8878 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8879 }
8880 
8881 int
8882 test_pdcp_proto_cplane_decap(int i)
8883 {
8884 	return test_pdcp_proto(
8885 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8886 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8887 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8888 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8889 		pdcp_test_params[i].cipher_key_len,
8890 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8891 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8892 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8893 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8894 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8895 }
8896 
8897 int
8898 test_pdcp_proto_uplane_decap(int i)
8899 {
8900 	return test_pdcp_proto(
8901 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8902 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8903 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8904 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8905 		pdcp_test_params[i].cipher_key_len,
8906 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8907 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8908 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8909 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8910 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8911 }
8912 
8913 int
8914 test_pdcp_proto_uplane_decap_with_int(int i)
8915 {
8916 	return test_pdcp_proto(
8917 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8918 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8919 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8920 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8921 		pdcp_test_params[i].cipher_key_len,
8922 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8923 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8924 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8925 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8926 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8927 }
8928 
8929 static int
8930 test_PDCP_PROTO_SGL_in_place_32B(void)
8931 {
8932 	/* i can be used for running any PDCP case
8933 	 * In this case it is uplane 12-bit AES-SNOW DL encap
8934 	 */
8935 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8936 	return test_pdcp_proto_SGL(i, IN_PLACE,
8937 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8938 			RTE_CRYPTO_AUTH_OP_GENERATE,
8939 			pdcp_test_data_in[i],
8940 			pdcp_test_data_in_len[i],
8941 			pdcp_test_data_out[i],
8942 			pdcp_test_data_in_len[i]+4,
8943 			32, 0);
8944 }
8945 static int
8946 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8947 {
8948 	/* i can be used for running any PDCP case
8949 	 * In this case it is uplane 18-bit NULL-NULL DL encap
8950 	 */
8951 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8952 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8953 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8954 			RTE_CRYPTO_AUTH_OP_GENERATE,
8955 			pdcp_test_data_in[i],
8956 			pdcp_test_data_in_len[i],
8957 			pdcp_test_data_out[i],
8958 			pdcp_test_data_in_len[i]+4,
8959 			32, 128);
8960 }
8961 static int
8962 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8963 {
8964 	/* i can be used for running any PDCP case
8965 	 * In this case it is uplane 18-bit AES DL encap
8966 	 */
8967 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8968 			+ DOWNLINK;
8969 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8970 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8971 			RTE_CRYPTO_AUTH_OP_GENERATE,
8972 			pdcp_test_data_in[i],
8973 			pdcp_test_data_in_len[i],
8974 			pdcp_test_data_out[i],
8975 			pdcp_test_data_in_len[i],
8976 			32, 40);
8977 }
8978 static int
8979 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8980 {
8981 	/* i can be used for running any PDCP case
8982 	 * In this case it is cplane 12-bit AES-ZUC DL encap
8983 	 */
8984 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8985 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8986 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8987 			RTE_CRYPTO_AUTH_OP_GENERATE,
8988 			pdcp_test_data_in[i],
8989 			pdcp_test_data_in_len[i],
8990 			pdcp_test_data_out[i],
8991 			pdcp_test_data_in_len[i]+4,
8992 			128, 32);
8993 }
8994 
8995 static int
8996 test_PDCP_SDAP_PROTO_encap_all(void)
8997 {
8998 	int i = 0, size = 0;
8999 	int err, all_err = TEST_SUCCESS;
9000 	const struct pdcp_sdap_test *cur_test;
9001 
9002 	size = RTE_DIM(list_pdcp_sdap_tests);
9003 
9004 	for (i = 0; i < size; i++) {
9005 		cur_test = &list_pdcp_sdap_tests[i];
9006 		err = test_pdcp_proto(
9007 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9008 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9009 			cur_test->in_len, cur_test->data_out,
9010 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9011 			cur_test->param.cipher_alg, cur_test->cipher_key,
9012 			cur_test->param.cipher_key_len,
9013 			cur_test->param.auth_alg,
9014 			cur_test->auth_key, cur_test->param.auth_key_len,
9015 			cur_test->bearer, cur_test->param.domain,
9016 			cur_test->packet_direction, cur_test->sn_size,
9017 			cur_test->hfn,
9018 			cur_test->hfn_threshold, SDAP_ENABLED);
9019 		if (err) {
9020 			printf("\t%d) %s: Encapsulation failed\n",
9021 					cur_test->test_idx,
9022 					cur_test->param.name);
9023 			err = TEST_FAILED;
9024 		} else {
9025 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9026 					cur_test->param.name);
9027 			err = TEST_SUCCESS;
9028 		}
9029 		all_err += err;
9030 	}
9031 
9032 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9033 
9034 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9035 }
9036 
9037 static int
9038 test_PDCP_PROTO_short_mac(void)
9039 {
9040 	int i = 0, size = 0;
9041 	int err, all_err = TEST_SUCCESS;
9042 	const struct pdcp_short_mac_test *cur_test;
9043 
9044 	size = RTE_DIM(list_pdcp_smac_tests);
9045 
9046 	for (i = 0; i < size; i++) {
9047 		cur_test = &list_pdcp_smac_tests[i];
9048 		err = test_pdcp_proto(
9049 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9050 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9051 			cur_test->in_len, cur_test->data_out,
9052 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9053 			RTE_CRYPTO_CIPHER_NULL, NULL,
9054 			0, cur_test->param.auth_alg,
9055 			cur_test->auth_key, cur_test->param.auth_key_len,
9056 			0, cur_test->param.domain, 0, 0,
9057 			0, 0, 0);
9058 		if (err) {
9059 			printf("\t%d) %s: Short MAC test failed\n",
9060 					cur_test->test_idx,
9061 					cur_test->param.name);
9062 			err = TEST_FAILED;
9063 		} else {
9064 			printf("\t%d) %s: Short MAC test PASS\n",
9065 					cur_test->test_idx,
9066 					cur_test->param.name);
9067 			rte_hexdump(stdout, "MAC I",
9068 				    cur_test->data_out + cur_test->in_len + 2,
9069 				    2);
9070 			err = TEST_SUCCESS;
9071 		}
9072 		all_err += err;
9073 	}
9074 
9075 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9076 
9077 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9078 
9079 }
9080 
9081 static int
9082 test_PDCP_SDAP_PROTO_decap_all(void)
9083 {
9084 	int i = 0, size = 0;
9085 	int err, all_err = TEST_SUCCESS;
9086 	const struct pdcp_sdap_test *cur_test;
9087 
9088 	size = RTE_DIM(list_pdcp_sdap_tests);
9089 
9090 	for (i = 0; i < size; i++) {
9091 		cur_test = &list_pdcp_sdap_tests[i];
9092 		err = test_pdcp_proto(
9093 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9094 			RTE_CRYPTO_AUTH_OP_VERIFY,
9095 			cur_test->data_out,
9096 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9097 			cur_test->data_in, cur_test->in_len,
9098 			cur_test->param.cipher_alg,
9099 			cur_test->cipher_key, cur_test->param.cipher_key_len,
9100 			cur_test->param.auth_alg, cur_test->auth_key,
9101 			cur_test->param.auth_key_len, cur_test->bearer,
9102 			cur_test->param.domain, cur_test->packet_direction,
9103 			cur_test->sn_size, cur_test->hfn,
9104 			cur_test->hfn_threshold, SDAP_ENABLED);
9105 		if (err) {
9106 			printf("\t%d) %s: Decapsulation failed\n",
9107 					cur_test->test_idx,
9108 					cur_test->param.name);
9109 			err = TEST_FAILED;
9110 		} else {
9111 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9112 					cur_test->param.name);
9113 			err = TEST_SUCCESS;
9114 		}
9115 		all_err += err;
9116 	}
9117 
9118 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9119 
9120 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9121 }
9122 
9123 static int
9124 test_ipsec_proto_process(const struct ipsec_test_data td[],
9125 			 struct ipsec_test_data res_d[],
9126 			 int nb_td,
9127 			 bool silent,
9128 			 const struct ipsec_test_flags *flags)
9129 {
9130 	uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
9131 				0x0000, 0x001a};
9132 	uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
9133 				0xe82c, 0x4887};
9134 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9135 	struct crypto_unittest_params *ut_params = &unittest_params;
9136 	struct rte_security_capability_idx sec_cap_idx;
9137 	const struct rte_security_capability *sec_cap;
9138 	struct rte_security_ipsec_xform ipsec_xform;
9139 	uint8_t dev_id = ts_params->valid_devs[0];
9140 	enum rte_security_ipsec_sa_direction dir;
9141 	struct ipsec_test_data *res_d_tmp = NULL;
9142 	uint32_t src = RTE_IPV4(192, 168, 1, 0);
9143 	uint32_t dst = RTE_IPV4(192, 168, 1, 1);
9144 	int salt_len, i, ret = TEST_SUCCESS;
9145 	struct rte_security_ctx *ctx;
9146 	uint8_t *input_text;
9147 	uint32_t verify;
9148 
9149 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9150 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9151 
9152 	/* Use first test data to create session */
9153 
9154 	/* Copy IPsec xform */
9155 	memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9156 
9157 	dir = ipsec_xform.direction;
9158 	verify = flags->tunnel_hdr_verify;
9159 
9160 	if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9161 		if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9162 			src += 1;
9163 		else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9164 			dst += 1;
9165 	}
9166 
9167 	if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
9168 		if (td->ipsec_xform.tunnel.type ==
9169 				RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
9170 			memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
9171 			       sizeof(src));
9172 			memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
9173 			       sizeof(dst));
9174 
9175 			if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
9176 				ipsec_xform.tunnel.ipv4.df = 0;
9177 
9178 			if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
9179 				ipsec_xform.tunnel.ipv4.df = 1;
9180 
9181 		} else {
9182 			memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
9183 			       sizeof(v6_src));
9184 			memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
9185 			       sizeof(v6_dst));
9186 		}
9187 	}
9188 
9189 	ctx = rte_cryptodev_get_sec_ctx(dev_id);
9190 
9191 	sec_cap_idx.action = ut_params->type;
9192 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9193 	sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9194 	sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9195 	sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9196 
9197 	if (flags->udp_encap)
9198 		ipsec_xform.options.udp_encap = 1;
9199 
9200 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9201 	if (sec_cap == NULL)
9202 		return TEST_SKIPPED;
9203 
9204 	/* Copy cipher session parameters */
9205 	if (td[0].aead) {
9206 		memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9207 		       sizeof(ut_params->aead_xform));
9208 		ut_params->aead_xform.aead.key.data = td[0].key.data;
9209 		ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9210 
9211 		/* Verify crypto capabilities */
9212 		if (test_ipsec_crypto_caps_aead_verify(
9213 				sec_cap,
9214 				&ut_params->aead_xform) != 0) {
9215 			if (!silent)
9216 				RTE_LOG(INFO, USER1,
9217 					"Crypto capabilities not supported\n");
9218 			return TEST_SKIPPED;
9219 		}
9220 	} else {
9221 		memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
9222 		       sizeof(ut_params->cipher_xform));
9223 		memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9224 		       sizeof(ut_params->auth_xform));
9225 		ut_params->cipher_xform.cipher.key.data = td[0].key.data;
9226 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9227 		ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9228 
9229 		/* Verify crypto capabilities */
9230 
9231 		if (test_ipsec_crypto_caps_cipher_verify(
9232 				sec_cap,
9233 				&ut_params->cipher_xform) != 0) {
9234 			if (!silent)
9235 				RTE_LOG(INFO, USER1,
9236 					"Cipher crypto capabilities not supported\n");
9237 			return TEST_SKIPPED;
9238 		}
9239 
9240 		if (test_ipsec_crypto_caps_auth_verify(
9241 				sec_cap,
9242 				&ut_params->auth_xform) != 0) {
9243 			if (!silent)
9244 				RTE_LOG(INFO, USER1,
9245 					"Auth crypto capabilities not supported\n");
9246 			return TEST_SKIPPED;
9247 		}
9248 	}
9249 
9250 	if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9251 		return TEST_SKIPPED;
9252 
9253 	struct rte_security_session_conf sess_conf = {
9254 		.action_type = ut_params->type,
9255 		.protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9256 	};
9257 
9258 	if (td[0].aead) {
9259 		salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9260 		memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9261 		sess_conf.ipsec = ipsec_xform;
9262 		sess_conf.crypto_xform = &ut_params->aead_xform;
9263 	} else {
9264 		sess_conf.ipsec = ipsec_xform;
9265 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
9266 			sess_conf.crypto_xform = &ut_params->cipher_xform;
9267 			ut_params->cipher_xform.next = &ut_params->auth_xform;
9268 		} else {
9269 			sess_conf.crypto_xform = &ut_params->auth_xform;
9270 			ut_params->auth_xform.next = &ut_params->cipher_xform;
9271 		}
9272 	}
9273 
9274 	/* Create security session */
9275 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9276 					ts_params->session_mpool,
9277 					ts_params->session_priv_mpool);
9278 
9279 	if (ut_params->sec_session == NULL)
9280 		return TEST_SKIPPED;
9281 
9282 	for (i = 0; i < nb_td; i++) {
9283 		/* Setup source mbuf payload */
9284 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9285 		memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9286 				rte_pktmbuf_tailroom(ut_params->ibuf));
9287 
9288 		input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9289 				td[i].input_text.len);
9290 
9291 		memcpy(input_text, td[i].input_text.data,
9292 		       td[i].input_text.len);
9293 
9294 		if (test_ipsec_pkt_update(input_text, flags))
9295 			return TEST_FAILED;
9296 
9297 		/* Generate crypto op data structure */
9298 		ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9299 					RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9300 		if (!ut_params->op) {
9301 			printf("TestCase %s line %d: %s\n",
9302 				__func__, __LINE__,
9303 				"failed to allocate crypto op");
9304 			ret = TEST_FAILED;
9305 			goto crypto_op_free;
9306 		}
9307 
9308 		/* Attach session to operation */
9309 		rte_security_attach_session(ut_params->op,
9310 					    ut_params->sec_session);
9311 
9312 		/* Set crypto operation mbufs */
9313 		ut_params->op->sym->m_src = ut_params->ibuf;
9314 		ut_params->op->sym->m_dst = NULL;
9315 
9316 		/* Copy IV in crypto operation when IV generation is disabled */
9317 		if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9318 		    ipsec_xform.options.iv_gen_disable == 1) {
9319 			uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9320 								uint8_t *,
9321 								IV_OFFSET);
9322 			int len;
9323 
9324 			if (td[i].aead)
9325 				len = td[i].xform.aead.aead.iv.length;
9326 			else
9327 				len = td[i].xform.chain.cipher.cipher.iv.length;
9328 
9329 			memcpy(iv, td[i].iv.data, len);
9330 		}
9331 
9332 		/* Process crypto operation */
9333 		process_crypto_request(dev_id, ut_params->op);
9334 
9335 		ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9336 		if (ret != TEST_SUCCESS)
9337 			goto crypto_op_free;
9338 
9339 		if (res_d != NULL)
9340 			res_d_tmp = &res_d[i];
9341 
9342 		ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9343 					      res_d_tmp, silent, flags);
9344 		if (ret != TEST_SUCCESS)
9345 			goto crypto_op_free;
9346 
9347 		ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
9348 					      flags, dir);
9349 		if (ret != TEST_SUCCESS)
9350 			goto crypto_op_free;
9351 
9352 		rte_crypto_op_free(ut_params->op);
9353 		ut_params->op = NULL;
9354 
9355 		rte_pktmbuf_free(ut_params->ibuf);
9356 		ut_params->ibuf = NULL;
9357 	}
9358 
9359 crypto_op_free:
9360 	rte_crypto_op_free(ut_params->op);
9361 	ut_params->op = NULL;
9362 
9363 	rte_pktmbuf_free(ut_params->ibuf);
9364 	ut_params->ibuf = NULL;
9365 
9366 	if (ut_params->sec_session)
9367 		rte_security_session_destroy(ctx, ut_params->sec_session);
9368 	ut_params->sec_session = NULL;
9369 
9370 	return ret;
9371 }
9372 
9373 static int
9374 test_ipsec_proto_known_vec(const void *test_data)
9375 {
9376 	struct ipsec_test_data td_outb;
9377 	struct ipsec_test_flags flags;
9378 
9379 	memset(&flags, 0, sizeof(flags));
9380 
9381 	memcpy(&td_outb, test_data, sizeof(td_outb));
9382 
9383 	if (td_outb.aead ||
9384 	    td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL) {
9385 		/* Disable IV gen to be able to test with known vectors */
9386 		td_outb.ipsec_xform.options.iv_gen_disable = 1;
9387 	}
9388 
9389 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9390 }
9391 
9392 static int
9393 test_ipsec_proto_known_vec_inb(const void *test_data)
9394 {
9395 	const struct ipsec_test_data *td = test_data;
9396 	struct ipsec_test_flags flags;
9397 	struct ipsec_test_data td_inb;
9398 
9399 	memset(&flags, 0, sizeof(flags));
9400 
9401 	if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
9402 		test_ipsec_td_in_from_out(td, &td_inb);
9403 	else
9404 		memcpy(&td_inb, td, sizeof(td_inb));
9405 
9406 	return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9407 }
9408 
9409 static int
9410 test_ipsec_proto_known_vec_fragmented(const void *test_data)
9411 {
9412 	struct ipsec_test_data td_outb;
9413 	struct ipsec_test_flags flags;
9414 
9415 	memset(&flags, 0, sizeof(flags));
9416 	flags.fragment = true;
9417 
9418 	memcpy(&td_outb, test_data, sizeof(td_outb));
9419 
9420 	/* Disable IV gen to be able to test with known vectors */
9421 	td_outb.ipsec_xform.options.iv_gen_disable = 1;
9422 
9423 	return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9424 }
9425 
9426 static int
9427 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9428 {
9429 	struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9430 	struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9431 	unsigned int i, nb_pkts = 1, pass_cnt = 0;
9432 	int ret;
9433 
9434 	if (flags->iv_gen ||
9435 	    flags->sa_expiry_pkts_soft ||
9436 	    flags->sa_expiry_pkts_hard)
9437 		nb_pkts = IPSEC_TEST_PACKETS_MAX;
9438 
9439 	for (i = 0; i < RTE_DIM(alg_list); i++) {
9440 		test_ipsec_td_prepare(alg_list[i].param1,
9441 				      alg_list[i].param2,
9442 				      flags,
9443 				      td_outb,
9444 				      nb_pkts);
9445 
9446 		if (!td_outb->aead) {
9447 			enum rte_crypto_cipher_algorithm cipher_alg;
9448 			enum rte_crypto_auth_algorithm auth_alg;
9449 
9450 			cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
9451 			auth_alg = td_outb->xform.chain.auth.auth.algo;
9452 
9453 			/* ICV is not applicable for NULL auth */
9454 			if (flags->icv_corrupt &&
9455 			    auth_alg == RTE_CRYPTO_AUTH_NULL)
9456 				continue;
9457 
9458 			/* IV is not applicable for NULL cipher */
9459 			if (flags->iv_gen &&
9460 			    cipher_alg == RTE_CRYPTO_CIPHER_NULL)
9461 				continue;
9462 		}
9463 
9464 		ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9465 					       flags);
9466 		if (ret == TEST_SKIPPED)
9467 			continue;
9468 
9469 		if (ret == TEST_FAILED)
9470 			return TEST_FAILED;
9471 
9472 		test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9473 
9474 		ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9475 					       flags);
9476 		if (ret == TEST_SKIPPED)
9477 			continue;
9478 
9479 		if (ret == TEST_FAILED)
9480 			return TEST_FAILED;
9481 
9482 		if (flags->display_alg)
9483 			test_ipsec_display_alg(alg_list[i].param1,
9484 					       alg_list[i].param2);
9485 
9486 		pass_cnt++;
9487 	}
9488 
9489 	if (pass_cnt > 0)
9490 		return TEST_SUCCESS;
9491 	else
9492 		return TEST_SKIPPED;
9493 }
9494 
9495 static int
9496 test_ipsec_proto_display_list(const void *data __rte_unused)
9497 {
9498 	struct ipsec_test_flags flags;
9499 
9500 	memset(&flags, 0, sizeof(flags));
9501 
9502 	flags.display_alg = true;
9503 
9504 	return test_ipsec_proto_all(&flags);
9505 }
9506 
9507 static int
9508 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9509 {
9510 	struct ipsec_test_flags flags;
9511 
9512 	memset(&flags, 0, sizeof(flags));
9513 
9514 	flags.iv_gen = true;
9515 
9516 	return test_ipsec_proto_all(&flags);
9517 }
9518 
9519 static int
9520 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9521 {
9522 	struct ipsec_test_flags flags;
9523 
9524 	memset(&flags, 0, sizeof(flags));
9525 
9526 	flags.sa_expiry_pkts_soft = true;
9527 
9528 	return test_ipsec_proto_all(&flags);
9529 }
9530 
9531 static int
9532 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9533 {
9534 	struct ipsec_test_flags flags;
9535 
9536 	memset(&flags, 0, sizeof(flags));
9537 
9538 	flags.sa_expiry_pkts_hard = true;
9539 
9540 	return test_ipsec_proto_all(&flags);
9541 }
9542 
9543 static int
9544 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9545 {
9546 	struct ipsec_test_flags flags;
9547 
9548 	memset(&flags, 0, sizeof(flags));
9549 
9550 	flags.icv_corrupt = true;
9551 
9552 	return test_ipsec_proto_all(&flags);
9553 }
9554 
9555 static int
9556 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9557 {
9558 	struct ipsec_test_flags flags;
9559 
9560 	memset(&flags, 0, sizeof(flags));
9561 
9562 	flags.udp_encap = true;
9563 
9564 	return test_ipsec_proto_all(&flags);
9565 }
9566 
9567 static int
9568 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9569 {
9570 	struct ipsec_test_flags flags;
9571 
9572 	memset(&flags, 0, sizeof(flags));
9573 
9574 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9575 
9576 	return test_ipsec_proto_all(&flags);
9577 }
9578 
9579 static int
9580 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9581 {
9582 	struct ipsec_test_flags flags;
9583 
9584 	memset(&flags, 0, sizeof(flags));
9585 
9586 	flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9587 
9588 	return test_ipsec_proto_all(&flags);
9589 }
9590 
9591 static int
9592 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9593 {
9594 	struct ipsec_test_flags flags;
9595 
9596 	memset(&flags, 0, sizeof(flags));
9597 
9598 	flags.udp_encap = true;
9599 	flags.udp_ports_verify = true;
9600 
9601 	return test_ipsec_proto_all(&flags);
9602 }
9603 
9604 static int
9605 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9606 {
9607 	struct ipsec_test_flags flags;
9608 
9609 	memset(&flags, 0, sizeof(flags));
9610 
9611 	flags.ip_csum = true;
9612 
9613 	return test_ipsec_proto_all(&flags);
9614 }
9615 
9616 static int
9617 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9618 {
9619 	struct ipsec_test_flags flags;
9620 
9621 	memset(&flags, 0, sizeof(flags));
9622 
9623 	flags.l4_csum = true;
9624 
9625 	return test_ipsec_proto_all(&flags);
9626 }
9627 
9628 static int
9629 test_ipsec_proto_tunnel_v4_in_v4(const void *data __rte_unused)
9630 {
9631 	struct ipsec_test_flags flags;
9632 
9633 	memset(&flags, 0, sizeof(flags));
9634 
9635 	flags.ipv6 = false;
9636 	flags.tunnel_ipv6 = false;
9637 
9638 	return test_ipsec_proto_all(&flags);
9639 }
9640 
9641 static int
9642 test_ipsec_proto_tunnel_v6_in_v6(const void *data __rte_unused)
9643 {
9644 	struct ipsec_test_flags flags;
9645 
9646 	memset(&flags, 0, sizeof(flags));
9647 
9648 	flags.ipv6 = true;
9649 	flags.tunnel_ipv6 = true;
9650 
9651 	return test_ipsec_proto_all(&flags);
9652 }
9653 
9654 static int
9655 test_ipsec_proto_tunnel_v4_in_v6(const void *data __rte_unused)
9656 {
9657 	struct ipsec_test_flags flags;
9658 
9659 	memset(&flags, 0, sizeof(flags));
9660 
9661 	flags.ipv6 = false;
9662 	flags.tunnel_ipv6 = true;
9663 
9664 	return test_ipsec_proto_all(&flags);
9665 }
9666 
9667 static int
9668 test_ipsec_proto_tunnel_v6_in_v4(const void *data __rte_unused)
9669 {
9670 	struct ipsec_test_flags flags;
9671 
9672 	memset(&flags, 0, sizeof(flags));
9673 
9674 	flags.ipv6 = true;
9675 	flags.tunnel_ipv6 = false;
9676 
9677 	return test_ipsec_proto_all(&flags);
9678 }
9679 
9680 static int
9681 test_ipsec_proto_transport_v4(const void *data __rte_unused)
9682 {
9683 	struct ipsec_test_flags flags;
9684 
9685 	memset(&flags, 0, sizeof(flags));
9686 
9687 	flags.ipv6 = false;
9688 	flags.transport = true;
9689 
9690 	return test_ipsec_proto_all(&flags);
9691 }
9692 
9693 static int
9694 test_ipsec_proto_stats(const void *data __rte_unused)
9695 {
9696 	struct ipsec_test_flags flags;
9697 
9698 	memset(&flags, 0, sizeof(flags));
9699 
9700 	flags.stats_success = true;
9701 
9702 	return test_ipsec_proto_all(&flags);
9703 }
9704 
9705 static int
9706 test_ipsec_proto_pkt_fragment(const void *data __rte_unused)
9707 {
9708 	struct ipsec_test_flags flags;
9709 
9710 	memset(&flags, 0, sizeof(flags));
9711 
9712 	flags.fragment = true;
9713 
9714 	return test_ipsec_proto_all(&flags);
9715 
9716 }
9717 
9718 static int
9719 test_ipsec_proto_copy_df_inner_0(const void *data __rte_unused)
9720 {
9721 	struct ipsec_test_flags flags;
9722 
9723 	memset(&flags, 0, sizeof(flags));
9724 
9725 	flags.df = TEST_IPSEC_COPY_DF_INNER_0;
9726 
9727 	return test_ipsec_proto_all(&flags);
9728 }
9729 
9730 static int
9731 test_ipsec_proto_copy_df_inner_1(const void *data __rte_unused)
9732 {
9733 	struct ipsec_test_flags flags;
9734 
9735 	memset(&flags, 0, sizeof(flags));
9736 
9737 	flags.df = TEST_IPSEC_COPY_DF_INNER_1;
9738 
9739 	return test_ipsec_proto_all(&flags);
9740 }
9741 
9742 static int
9743 test_ipsec_proto_set_df_0_inner_1(const void *data __rte_unused)
9744 {
9745 	struct ipsec_test_flags flags;
9746 
9747 	memset(&flags, 0, sizeof(flags));
9748 
9749 	flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
9750 
9751 	return test_ipsec_proto_all(&flags);
9752 }
9753 
9754 static int
9755 test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
9756 {
9757 	struct ipsec_test_flags flags;
9758 
9759 	memset(&flags, 0, sizeof(flags));
9760 
9761 	flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
9762 
9763 	return test_ipsec_proto_all(&flags);
9764 }
9765 
9766 static int
9767 test_PDCP_PROTO_all(void)
9768 {
9769 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9770 	struct crypto_unittest_params *ut_params = &unittest_params;
9771 	struct rte_cryptodev_info dev_info;
9772 	int status;
9773 
9774 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9775 	uint64_t feat_flags = dev_info.feature_flags;
9776 
9777 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9778 		return TEST_SKIPPED;
9779 
9780 	/* Set action type */
9781 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9782 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9783 		gbl_action_type;
9784 
9785 	if (security_proto_supported(ut_params->type,
9786 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
9787 		return TEST_SKIPPED;
9788 
9789 	status = test_PDCP_PROTO_cplane_encap_all();
9790 	status += test_PDCP_PROTO_cplane_decap_all();
9791 	status += test_PDCP_PROTO_uplane_encap_all();
9792 	status += test_PDCP_PROTO_uplane_decap_all();
9793 	status += test_PDCP_PROTO_SGL_in_place_32B();
9794 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
9795 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
9796 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
9797 	status += test_PDCP_SDAP_PROTO_encap_all();
9798 	status += test_PDCP_SDAP_PROTO_decap_all();
9799 	status += test_PDCP_PROTO_short_mac();
9800 
9801 	if (status)
9802 		return TEST_FAILED;
9803 	else
9804 		return TEST_SUCCESS;
9805 }
9806 
9807 static int
9808 test_docsis_proto_uplink(const void *data)
9809 {
9810 	const struct docsis_test_data *d_td = data;
9811 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9812 	struct crypto_unittest_params *ut_params = &unittest_params;
9813 	uint8_t *plaintext = NULL;
9814 	uint8_t *ciphertext = NULL;
9815 	uint8_t *iv_ptr;
9816 	int32_t cipher_len, crc_len;
9817 	uint32_t crc_data_len;
9818 	int ret = TEST_SUCCESS;
9819 
9820 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9821 					rte_cryptodev_get_sec_ctx(
9822 						ts_params->valid_devs[0]);
9823 
9824 	/* Verify the capabilities */
9825 	struct rte_security_capability_idx sec_cap_idx;
9826 	const struct rte_security_capability *sec_cap;
9827 	const struct rte_cryptodev_capabilities *crypto_cap;
9828 	const struct rte_cryptodev_symmetric_capability *sym_cap;
9829 	int j = 0;
9830 
9831 	/* Set action type */
9832 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9833 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9834 		gbl_action_type;
9835 
9836 	if (security_proto_supported(ut_params->type,
9837 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9838 		return TEST_SKIPPED;
9839 
9840 	sec_cap_idx.action = ut_params->type;
9841 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9842 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9843 
9844 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9845 	if (sec_cap == NULL)
9846 		return TEST_SKIPPED;
9847 
9848 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9849 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9850 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9851 				crypto_cap->sym.xform_type ==
9852 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
9853 				crypto_cap->sym.cipher.algo ==
9854 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9855 			sym_cap = &crypto_cap->sym;
9856 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9857 						d_td->key.len,
9858 						d_td->iv.len) == 0)
9859 				break;
9860 		}
9861 	}
9862 
9863 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9864 		return TEST_SKIPPED;
9865 
9866 	/* Setup source mbuf payload */
9867 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9868 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9869 			rte_pktmbuf_tailroom(ut_params->ibuf));
9870 
9871 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9872 			d_td->ciphertext.len);
9873 
9874 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9875 
9876 	/* Setup cipher session parameters */
9877 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9878 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9879 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9880 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9881 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9882 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9883 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9884 	ut_params->cipher_xform.next = NULL;
9885 
9886 	/* Setup DOCSIS session parameters */
9887 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9888 
9889 	struct rte_security_session_conf sess_conf = {
9890 		.action_type = ut_params->type,
9891 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9892 		.docsis = ut_params->docsis_xform,
9893 		.crypto_xform = &ut_params->cipher_xform,
9894 	};
9895 
9896 	/* Create security session */
9897 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9898 					ts_params->session_mpool,
9899 					ts_params->session_priv_mpool);
9900 
9901 	if (!ut_params->sec_session) {
9902 		printf("Test function %s line %u: failed to allocate session\n",
9903 			__func__, __LINE__);
9904 		ret = TEST_FAILED;
9905 		goto on_err;
9906 	}
9907 
9908 	/* Generate crypto op data structure */
9909 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9910 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9911 	if (!ut_params->op) {
9912 		printf("Test function %s line %u: failed to allocate symmetric "
9913 			"crypto operation\n", __func__, __LINE__);
9914 		ret = TEST_FAILED;
9915 		goto on_err;
9916 	}
9917 
9918 	/* Setup CRC operation parameters */
9919 	crc_len = d_td->ciphertext.no_crc == false ?
9920 			(d_td->ciphertext.len -
9921 				d_td->ciphertext.crc_offset -
9922 				RTE_ETHER_CRC_LEN) :
9923 			0;
9924 	crc_len = crc_len > 0 ? crc_len : 0;
9925 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9926 	ut_params->op->sym->auth.data.length = crc_len;
9927 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9928 
9929 	/* Setup cipher operation parameters */
9930 	cipher_len = d_td->ciphertext.no_cipher == false ?
9931 			(d_td->ciphertext.len -
9932 				d_td->ciphertext.cipher_offset) :
9933 			0;
9934 	cipher_len = cipher_len > 0 ? cipher_len : 0;
9935 	ut_params->op->sym->cipher.data.length = cipher_len;
9936 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9937 
9938 	/* Setup cipher IV */
9939 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9940 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9941 
9942 	/* Attach session to operation */
9943 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9944 
9945 	/* Set crypto operation mbufs */
9946 	ut_params->op->sym->m_src = ut_params->ibuf;
9947 	ut_params->op->sym->m_dst = NULL;
9948 
9949 	/* Process crypto operation */
9950 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9951 			NULL) {
9952 		printf("Test function %s line %u: failed to process security "
9953 			"crypto op\n", __func__, __LINE__);
9954 		ret = TEST_FAILED;
9955 		goto on_err;
9956 	}
9957 
9958 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9959 		printf("Test function %s line %u: failed to process crypto op\n",
9960 			__func__, __LINE__);
9961 		ret = TEST_FAILED;
9962 		goto on_err;
9963 	}
9964 
9965 	/* Validate plaintext */
9966 	plaintext = ciphertext;
9967 
9968 	if (memcmp(plaintext, d_td->plaintext.data,
9969 			d_td->plaintext.len - crc_data_len)) {
9970 		printf("Test function %s line %u: plaintext not as expected\n",
9971 			__func__, __LINE__);
9972 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
9973 				d_td->plaintext.len);
9974 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9975 		ret = TEST_FAILED;
9976 		goto on_err;
9977 	}
9978 
9979 on_err:
9980 	rte_crypto_op_free(ut_params->op);
9981 	ut_params->op = NULL;
9982 
9983 	if (ut_params->sec_session)
9984 		rte_security_session_destroy(ctx, ut_params->sec_session);
9985 	ut_params->sec_session = NULL;
9986 
9987 	rte_pktmbuf_free(ut_params->ibuf);
9988 	ut_params->ibuf = NULL;
9989 
9990 	return ret;
9991 }
9992 
9993 static int
9994 test_docsis_proto_downlink(const void *data)
9995 {
9996 	const struct docsis_test_data *d_td = data;
9997 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9998 	struct crypto_unittest_params *ut_params = &unittest_params;
9999 	uint8_t *plaintext = NULL;
10000 	uint8_t *ciphertext = NULL;
10001 	uint8_t *iv_ptr;
10002 	int32_t cipher_len, crc_len;
10003 	int ret = TEST_SUCCESS;
10004 
10005 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10006 					rte_cryptodev_get_sec_ctx(
10007 						ts_params->valid_devs[0]);
10008 
10009 	/* Verify the capabilities */
10010 	struct rte_security_capability_idx sec_cap_idx;
10011 	const struct rte_security_capability *sec_cap;
10012 	const struct rte_cryptodev_capabilities *crypto_cap;
10013 	const struct rte_cryptodev_symmetric_capability *sym_cap;
10014 	int j = 0;
10015 
10016 	/* Set action type */
10017 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10018 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10019 		gbl_action_type;
10020 
10021 	if (security_proto_supported(ut_params->type,
10022 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10023 		return TEST_SKIPPED;
10024 
10025 	sec_cap_idx.action = ut_params->type;
10026 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10027 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10028 
10029 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10030 	if (sec_cap == NULL)
10031 		return TEST_SKIPPED;
10032 
10033 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10034 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10035 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10036 				crypto_cap->sym.xform_type ==
10037 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
10038 				crypto_cap->sym.cipher.algo ==
10039 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10040 			sym_cap = &crypto_cap->sym;
10041 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10042 						d_td->key.len,
10043 						d_td->iv.len) == 0)
10044 				break;
10045 		}
10046 	}
10047 
10048 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10049 		return TEST_SKIPPED;
10050 
10051 	/* Setup source mbuf payload */
10052 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10053 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10054 			rte_pktmbuf_tailroom(ut_params->ibuf));
10055 
10056 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10057 			d_td->plaintext.len);
10058 
10059 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
10060 
10061 	/* Setup cipher session parameters */
10062 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10063 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10064 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10065 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10066 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10067 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10068 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10069 	ut_params->cipher_xform.next = NULL;
10070 
10071 	/* Setup DOCSIS session parameters */
10072 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10073 
10074 	struct rte_security_session_conf sess_conf = {
10075 		.action_type = ut_params->type,
10076 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10077 		.docsis = ut_params->docsis_xform,
10078 		.crypto_xform = &ut_params->cipher_xform,
10079 	};
10080 
10081 	/* Create security session */
10082 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10083 					ts_params->session_mpool,
10084 					ts_params->session_priv_mpool);
10085 
10086 	if (!ut_params->sec_session) {
10087 		printf("Test function %s line %u: failed to allocate session\n",
10088 			__func__, __LINE__);
10089 		ret = TEST_FAILED;
10090 		goto on_err;
10091 	}
10092 
10093 	/* Generate crypto op data structure */
10094 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10095 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10096 	if (!ut_params->op) {
10097 		printf("Test function %s line %u: failed to allocate symmetric "
10098 			"crypto operation\n", __func__, __LINE__);
10099 		ret = TEST_FAILED;
10100 		goto on_err;
10101 	}
10102 
10103 	/* Setup CRC operation parameters */
10104 	crc_len = d_td->plaintext.no_crc == false ?
10105 			(d_td->plaintext.len -
10106 				d_td->plaintext.crc_offset -
10107 				RTE_ETHER_CRC_LEN) :
10108 			0;
10109 	crc_len = crc_len > 0 ? crc_len : 0;
10110 	ut_params->op->sym->auth.data.length = crc_len;
10111 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
10112 
10113 	/* Setup cipher operation parameters */
10114 	cipher_len = d_td->plaintext.no_cipher == false ?
10115 			(d_td->plaintext.len -
10116 				d_td->plaintext.cipher_offset) :
10117 			0;
10118 	cipher_len = cipher_len > 0 ? cipher_len : 0;
10119 	ut_params->op->sym->cipher.data.length = cipher_len;
10120 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
10121 
10122 	/* Setup cipher IV */
10123 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10124 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10125 
10126 	/* Attach session to operation */
10127 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
10128 
10129 	/* Set crypto operation mbufs */
10130 	ut_params->op->sym->m_src = ut_params->ibuf;
10131 	ut_params->op->sym->m_dst = NULL;
10132 
10133 	/* Process crypto operation */
10134 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10135 			NULL) {
10136 		printf("Test function %s line %u: failed to process crypto op\n",
10137 			__func__, __LINE__);
10138 		ret = TEST_FAILED;
10139 		goto on_err;
10140 	}
10141 
10142 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10143 		printf("Test function %s line %u: crypto op processing failed\n",
10144 			__func__, __LINE__);
10145 		ret = TEST_FAILED;
10146 		goto on_err;
10147 	}
10148 
10149 	/* Validate ciphertext */
10150 	ciphertext = plaintext;
10151 
10152 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
10153 		printf("Test function %s line %u: plaintext not as expected\n",
10154 			__func__, __LINE__);
10155 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
10156 				d_td->ciphertext.len);
10157 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
10158 		ret = TEST_FAILED;
10159 		goto on_err;
10160 	}
10161 
10162 on_err:
10163 	rte_crypto_op_free(ut_params->op);
10164 	ut_params->op = NULL;
10165 
10166 	if (ut_params->sec_session)
10167 		rte_security_session_destroy(ctx, ut_params->sec_session);
10168 	ut_params->sec_session = NULL;
10169 
10170 	rte_pktmbuf_free(ut_params->ibuf);
10171 	ut_params->ibuf = NULL;
10172 
10173 	return ret;
10174 }
10175 #endif
10176 
10177 static int
10178 test_AES_GCM_authenticated_encryption_test_case_1(void)
10179 {
10180 	return test_authenticated_encryption(&gcm_test_case_1);
10181 }
10182 
10183 static int
10184 test_AES_GCM_authenticated_encryption_test_case_2(void)
10185 {
10186 	return test_authenticated_encryption(&gcm_test_case_2);
10187 }
10188 
10189 static int
10190 test_AES_GCM_authenticated_encryption_test_case_3(void)
10191 {
10192 	return test_authenticated_encryption(&gcm_test_case_3);
10193 }
10194 
10195 static int
10196 test_AES_GCM_authenticated_encryption_test_case_4(void)
10197 {
10198 	return test_authenticated_encryption(&gcm_test_case_4);
10199 }
10200 
10201 static int
10202 test_AES_GCM_authenticated_encryption_test_case_5(void)
10203 {
10204 	return test_authenticated_encryption(&gcm_test_case_5);
10205 }
10206 
10207 static int
10208 test_AES_GCM_authenticated_encryption_test_case_6(void)
10209 {
10210 	return test_authenticated_encryption(&gcm_test_case_6);
10211 }
10212 
10213 static int
10214 test_AES_GCM_authenticated_encryption_test_case_7(void)
10215 {
10216 	return test_authenticated_encryption(&gcm_test_case_7);
10217 }
10218 
10219 static int
10220 test_AES_GCM_authenticated_encryption_test_case_8(void)
10221 {
10222 	return test_authenticated_encryption(&gcm_test_case_8);
10223 }
10224 
10225 static int
10226 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10227 {
10228 	return test_authenticated_encryption(&gcm_J0_test_case_1);
10229 }
10230 
10231 static int
10232 test_AES_GCM_auth_encryption_test_case_192_1(void)
10233 {
10234 	return test_authenticated_encryption(&gcm_test_case_192_1);
10235 }
10236 
10237 static int
10238 test_AES_GCM_auth_encryption_test_case_192_2(void)
10239 {
10240 	return test_authenticated_encryption(&gcm_test_case_192_2);
10241 }
10242 
10243 static int
10244 test_AES_GCM_auth_encryption_test_case_192_3(void)
10245 {
10246 	return test_authenticated_encryption(&gcm_test_case_192_3);
10247 }
10248 
10249 static int
10250 test_AES_GCM_auth_encryption_test_case_192_4(void)
10251 {
10252 	return test_authenticated_encryption(&gcm_test_case_192_4);
10253 }
10254 
10255 static int
10256 test_AES_GCM_auth_encryption_test_case_192_5(void)
10257 {
10258 	return test_authenticated_encryption(&gcm_test_case_192_5);
10259 }
10260 
10261 static int
10262 test_AES_GCM_auth_encryption_test_case_192_6(void)
10263 {
10264 	return test_authenticated_encryption(&gcm_test_case_192_6);
10265 }
10266 
10267 static int
10268 test_AES_GCM_auth_encryption_test_case_192_7(void)
10269 {
10270 	return test_authenticated_encryption(&gcm_test_case_192_7);
10271 }
10272 
10273 static int
10274 test_AES_GCM_auth_encryption_test_case_256_1(void)
10275 {
10276 	return test_authenticated_encryption(&gcm_test_case_256_1);
10277 }
10278 
10279 static int
10280 test_AES_GCM_auth_encryption_test_case_256_2(void)
10281 {
10282 	return test_authenticated_encryption(&gcm_test_case_256_2);
10283 }
10284 
10285 static int
10286 test_AES_GCM_auth_encryption_test_case_256_3(void)
10287 {
10288 	return test_authenticated_encryption(&gcm_test_case_256_3);
10289 }
10290 
10291 static int
10292 test_AES_GCM_auth_encryption_test_case_256_4(void)
10293 {
10294 	return test_authenticated_encryption(&gcm_test_case_256_4);
10295 }
10296 
10297 static int
10298 test_AES_GCM_auth_encryption_test_case_256_5(void)
10299 {
10300 	return test_authenticated_encryption(&gcm_test_case_256_5);
10301 }
10302 
10303 static int
10304 test_AES_GCM_auth_encryption_test_case_256_6(void)
10305 {
10306 	return test_authenticated_encryption(&gcm_test_case_256_6);
10307 }
10308 
10309 static int
10310 test_AES_GCM_auth_encryption_test_case_256_7(void)
10311 {
10312 	return test_authenticated_encryption(&gcm_test_case_256_7);
10313 }
10314 
10315 static int
10316 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10317 {
10318 	return test_authenticated_encryption(&gcm_test_case_aad_1);
10319 }
10320 
10321 static int
10322 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10323 {
10324 	return test_authenticated_encryption(&gcm_test_case_aad_2);
10325 }
10326 
10327 static int
10328 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10329 {
10330 	struct aead_test_data tdata;
10331 	int res;
10332 
10333 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10334 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10335 	tdata.iv.data[0] += 1;
10336 	res = test_authenticated_encryption(&tdata);
10337 	if (res == TEST_SKIPPED)
10338 		return res;
10339 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10340 	return TEST_SUCCESS;
10341 }
10342 
10343 static int
10344 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10345 {
10346 	struct aead_test_data tdata;
10347 	int res;
10348 
10349 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10350 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10351 	tdata.plaintext.data[0] += 1;
10352 	res = test_authenticated_encryption(&tdata);
10353 	if (res == TEST_SKIPPED)
10354 		return res;
10355 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10356 	return TEST_SUCCESS;
10357 }
10358 
10359 static int
10360 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10361 {
10362 	struct aead_test_data tdata;
10363 	int res;
10364 
10365 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10366 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10367 	tdata.ciphertext.data[0] += 1;
10368 	res = test_authenticated_encryption(&tdata);
10369 	if (res == TEST_SKIPPED)
10370 		return res;
10371 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10372 	return TEST_SUCCESS;
10373 }
10374 
10375 static int
10376 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10377 {
10378 	struct aead_test_data tdata;
10379 	int res;
10380 
10381 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10382 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10383 	tdata.aad.len += 1;
10384 	res = test_authenticated_encryption(&tdata);
10385 	if (res == TEST_SKIPPED)
10386 		return res;
10387 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10388 	return TEST_SUCCESS;
10389 }
10390 
10391 static int
10392 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10393 {
10394 	struct aead_test_data tdata;
10395 	uint8_t aad[gcm_test_case_7.aad.len];
10396 	int res;
10397 
10398 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10399 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10400 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10401 	aad[0] += 1;
10402 	tdata.aad.data = aad;
10403 	res = test_authenticated_encryption(&tdata);
10404 	if (res == TEST_SKIPPED)
10405 		return res;
10406 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10407 	return TEST_SUCCESS;
10408 }
10409 
10410 static int
10411 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10412 {
10413 	struct aead_test_data tdata;
10414 	int res;
10415 
10416 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10417 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10418 	tdata.auth_tag.data[0] += 1;
10419 	res = test_authenticated_encryption(&tdata);
10420 	if (res == TEST_SKIPPED)
10421 		return res;
10422 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10423 	return TEST_SUCCESS;
10424 }
10425 
10426 static int
10427 test_authenticated_decryption(const struct aead_test_data *tdata)
10428 {
10429 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10430 	struct crypto_unittest_params *ut_params = &unittest_params;
10431 
10432 	int retval;
10433 	uint8_t *plaintext;
10434 	uint32_t i;
10435 	struct rte_cryptodev_info dev_info;
10436 
10437 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10438 	uint64_t feat_flags = dev_info.feature_flags;
10439 
10440 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10441 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10442 		printf("Device doesn't support RAW data-path APIs.\n");
10443 		return TEST_SKIPPED;
10444 	}
10445 
10446 	/* Verify the capabilities */
10447 	struct rte_cryptodev_sym_capability_idx cap_idx;
10448 	const struct rte_cryptodev_symmetric_capability *capability;
10449 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10450 	cap_idx.algo.aead = tdata->algo;
10451 	capability = rte_cryptodev_sym_capability_get(
10452 			ts_params->valid_devs[0], &cap_idx);
10453 	if (capability == NULL)
10454 		return TEST_SKIPPED;
10455 	if (rte_cryptodev_sym_capability_check_aead(
10456 			capability, tdata->key.len, tdata->auth_tag.len,
10457 			tdata->aad.len, tdata->iv.len))
10458 		return TEST_SKIPPED;
10459 
10460 	/* Create AEAD session */
10461 	retval = create_aead_session(ts_params->valid_devs[0],
10462 			tdata->algo,
10463 			RTE_CRYPTO_AEAD_OP_DECRYPT,
10464 			tdata->key.data, tdata->key.len,
10465 			tdata->aad.len, tdata->auth_tag.len,
10466 			tdata->iv.len);
10467 	if (retval < 0)
10468 		return retval;
10469 
10470 	/* alloc mbuf and set payload */
10471 	if (tdata->aad.len > MBUF_SIZE) {
10472 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10473 		/* Populate full size of add data */
10474 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10475 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10476 	} else
10477 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10478 
10479 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10480 			rte_pktmbuf_tailroom(ut_params->ibuf));
10481 
10482 	/* Create AEAD operation */
10483 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10484 	if (retval < 0)
10485 		return retval;
10486 
10487 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10488 
10489 	ut_params->op->sym->m_src = ut_params->ibuf;
10490 
10491 	/* Process crypto operation */
10492 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10493 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10494 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10495 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10496 				ut_params->op, 0, 0, 0, 0);
10497 	else
10498 		TEST_ASSERT_NOT_NULL(
10499 			process_crypto_request(ts_params->valid_devs[0],
10500 			ut_params->op), "failed to process sym crypto op");
10501 
10502 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10503 			"crypto op processing failed");
10504 
10505 	if (ut_params->op->sym->m_dst)
10506 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10507 				uint8_t *);
10508 	else
10509 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10510 				uint8_t *,
10511 				ut_params->op->sym->cipher.data.offset);
10512 
10513 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10514 
10515 	/* Validate obuf */
10516 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10517 			plaintext,
10518 			tdata->plaintext.data,
10519 			tdata->plaintext.len,
10520 			"Plaintext data not as expected");
10521 
10522 	TEST_ASSERT_EQUAL(ut_params->op->status,
10523 			RTE_CRYPTO_OP_STATUS_SUCCESS,
10524 			"Authentication failed");
10525 
10526 	return 0;
10527 }
10528 
10529 static int
10530 test_AES_GCM_authenticated_decryption_test_case_1(void)
10531 {
10532 	return test_authenticated_decryption(&gcm_test_case_1);
10533 }
10534 
10535 static int
10536 test_AES_GCM_authenticated_decryption_test_case_2(void)
10537 {
10538 	return test_authenticated_decryption(&gcm_test_case_2);
10539 }
10540 
10541 static int
10542 test_AES_GCM_authenticated_decryption_test_case_3(void)
10543 {
10544 	return test_authenticated_decryption(&gcm_test_case_3);
10545 }
10546 
10547 static int
10548 test_AES_GCM_authenticated_decryption_test_case_4(void)
10549 {
10550 	return test_authenticated_decryption(&gcm_test_case_4);
10551 }
10552 
10553 static int
10554 test_AES_GCM_authenticated_decryption_test_case_5(void)
10555 {
10556 	return test_authenticated_decryption(&gcm_test_case_5);
10557 }
10558 
10559 static int
10560 test_AES_GCM_authenticated_decryption_test_case_6(void)
10561 {
10562 	return test_authenticated_decryption(&gcm_test_case_6);
10563 }
10564 
10565 static int
10566 test_AES_GCM_authenticated_decryption_test_case_7(void)
10567 {
10568 	return test_authenticated_decryption(&gcm_test_case_7);
10569 }
10570 
10571 static int
10572 test_AES_GCM_authenticated_decryption_test_case_8(void)
10573 {
10574 	return test_authenticated_decryption(&gcm_test_case_8);
10575 }
10576 
10577 static int
10578 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10579 {
10580 	return test_authenticated_decryption(&gcm_J0_test_case_1);
10581 }
10582 
10583 static int
10584 test_AES_GCM_auth_decryption_test_case_192_1(void)
10585 {
10586 	return test_authenticated_decryption(&gcm_test_case_192_1);
10587 }
10588 
10589 static int
10590 test_AES_GCM_auth_decryption_test_case_192_2(void)
10591 {
10592 	return test_authenticated_decryption(&gcm_test_case_192_2);
10593 }
10594 
10595 static int
10596 test_AES_GCM_auth_decryption_test_case_192_3(void)
10597 {
10598 	return test_authenticated_decryption(&gcm_test_case_192_3);
10599 }
10600 
10601 static int
10602 test_AES_GCM_auth_decryption_test_case_192_4(void)
10603 {
10604 	return test_authenticated_decryption(&gcm_test_case_192_4);
10605 }
10606 
10607 static int
10608 test_AES_GCM_auth_decryption_test_case_192_5(void)
10609 {
10610 	return test_authenticated_decryption(&gcm_test_case_192_5);
10611 }
10612 
10613 static int
10614 test_AES_GCM_auth_decryption_test_case_192_6(void)
10615 {
10616 	return test_authenticated_decryption(&gcm_test_case_192_6);
10617 }
10618 
10619 static int
10620 test_AES_GCM_auth_decryption_test_case_192_7(void)
10621 {
10622 	return test_authenticated_decryption(&gcm_test_case_192_7);
10623 }
10624 
10625 static int
10626 test_AES_GCM_auth_decryption_test_case_256_1(void)
10627 {
10628 	return test_authenticated_decryption(&gcm_test_case_256_1);
10629 }
10630 
10631 static int
10632 test_AES_GCM_auth_decryption_test_case_256_2(void)
10633 {
10634 	return test_authenticated_decryption(&gcm_test_case_256_2);
10635 }
10636 
10637 static int
10638 test_AES_GCM_auth_decryption_test_case_256_3(void)
10639 {
10640 	return test_authenticated_decryption(&gcm_test_case_256_3);
10641 }
10642 
10643 static int
10644 test_AES_GCM_auth_decryption_test_case_256_4(void)
10645 {
10646 	return test_authenticated_decryption(&gcm_test_case_256_4);
10647 }
10648 
10649 static int
10650 test_AES_GCM_auth_decryption_test_case_256_5(void)
10651 {
10652 	return test_authenticated_decryption(&gcm_test_case_256_5);
10653 }
10654 
10655 static int
10656 test_AES_GCM_auth_decryption_test_case_256_6(void)
10657 {
10658 	return test_authenticated_decryption(&gcm_test_case_256_6);
10659 }
10660 
10661 static int
10662 test_AES_GCM_auth_decryption_test_case_256_7(void)
10663 {
10664 	return test_authenticated_decryption(&gcm_test_case_256_7);
10665 }
10666 
10667 static int
10668 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10669 {
10670 	return test_authenticated_decryption(&gcm_test_case_aad_1);
10671 }
10672 
10673 static int
10674 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10675 {
10676 	return test_authenticated_decryption(&gcm_test_case_aad_2);
10677 }
10678 
10679 static int
10680 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10681 {
10682 	struct aead_test_data tdata;
10683 	int res;
10684 
10685 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10686 	tdata.iv.data[0] += 1;
10687 	res = test_authenticated_decryption(&tdata);
10688 	if (res == TEST_SKIPPED)
10689 		return res;
10690 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10691 	return TEST_SUCCESS;
10692 }
10693 
10694 static int
10695 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10696 {
10697 	struct aead_test_data tdata;
10698 	int res;
10699 
10700 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10701 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10702 	tdata.plaintext.data[0] += 1;
10703 	res = test_authenticated_decryption(&tdata);
10704 	if (res == TEST_SKIPPED)
10705 		return res;
10706 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10707 	return TEST_SUCCESS;
10708 }
10709 
10710 static int
10711 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10712 {
10713 	struct aead_test_data tdata;
10714 	int res;
10715 
10716 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10717 	tdata.ciphertext.data[0] += 1;
10718 	res = test_authenticated_decryption(&tdata);
10719 	if (res == TEST_SKIPPED)
10720 		return res;
10721 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10722 	return TEST_SUCCESS;
10723 }
10724 
10725 static int
10726 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10727 {
10728 	struct aead_test_data tdata;
10729 	int res;
10730 
10731 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10732 	tdata.aad.len += 1;
10733 	res = test_authenticated_decryption(&tdata);
10734 	if (res == TEST_SKIPPED)
10735 		return res;
10736 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10737 	return TEST_SUCCESS;
10738 }
10739 
10740 static int
10741 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10742 {
10743 	struct aead_test_data tdata;
10744 	uint8_t aad[gcm_test_case_7.aad.len];
10745 	int res;
10746 
10747 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10748 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10749 	aad[0] += 1;
10750 	tdata.aad.data = aad;
10751 	res = test_authenticated_decryption(&tdata);
10752 	if (res == TEST_SKIPPED)
10753 		return res;
10754 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10755 	return TEST_SUCCESS;
10756 }
10757 
10758 static int
10759 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10760 {
10761 	struct aead_test_data tdata;
10762 	int res;
10763 
10764 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10765 	tdata.auth_tag.data[0] += 1;
10766 	res = test_authenticated_decryption(&tdata);
10767 	if (res == TEST_SKIPPED)
10768 		return res;
10769 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10770 	return TEST_SUCCESS;
10771 }
10772 
10773 static int
10774 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10775 {
10776 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10777 	struct crypto_unittest_params *ut_params = &unittest_params;
10778 
10779 	int retval;
10780 	uint8_t *ciphertext, *auth_tag;
10781 	uint16_t plaintext_pad_len;
10782 	struct rte_cryptodev_info dev_info;
10783 
10784 	/* Verify the capabilities */
10785 	struct rte_cryptodev_sym_capability_idx cap_idx;
10786 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10787 	cap_idx.algo.aead = tdata->algo;
10788 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10789 			&cap_idx) == NULL)
10790 		return TEST_SKIPPED;
10791 
10792 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10793 	uint64_t feat_flags = dev_info.feature_flags;
10794 
10795 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10796 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10797 		return TEST_SKIPPED;
10798 
10799 	/* not supported with CPU crypto */
10800 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10801 		return TEST_SKIPPED;
10802 
10803 	/* Create AEAD session */
10804 	retval = create_aead_session(ts_params->valid_devs[0],
10805 			tdata->algo,
10806 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
10807 			tdata->key.data, tdata->key.len,
10808 			tdata->aad.len, tdata->auth_tag.len,
10809 			tdata->iv.len);
10810 	if (retval < 0)
10811 		return retval;
10812 
10813 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10814 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10815 
10816 	/* clear mbuf payload */
10817 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10818 			rte_pktmbuf_tailroom(ut_params->ibuf));
10819 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10820 			rte_pktmbuf_tailroom(ut_params->obuf));
10821 
10822 	/* Create AEAD operation */
10823 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10824 	if (retval < 0)
10825 		return retval;
10826 
10827 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10828 
10829 	ut_params->op->sym->m_src = ut_params->ibuf;
10830 	ut_params->op->sym->m_dst = ut_params->obuf;
10831 
10832 	/* Process crypto operation */
10833 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10834 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10835 			ut_params->op, 0, 0, 0, 0);
10836 	else
10837 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10838 			ut_params->op), "failed to process sym crypto op");
10839 
10840 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10841 			"crypto op processing failed");
10842 
10843 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10844 
10845 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10846 			ut_params->op->sym->cipher.data.offset);
10847 	auth_tag = ciphertext + plaintext_pad_len;
10848 
10849 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10850 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10851 
10852 	/* Validate obuf */
10853 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10854 			ciphertext,
10855 			tdata->ciphertext.data,
10856 			tdata->ciphertext.len,
10857 			"Ciphertext data not as expected");
10858 
10859 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10860 			auth_tag,
10861 			tdata->auth_tag.data,
10862 			tdata->auth_tag.len,
10863 			"Generated auth tag not as expected");
10864 
10865 	return 0;
10866 
10867 }
10868 
10869 static int
10870 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10871 {
10872 	return test_authenticated_encryption_oop(&gcm_test_case_5);
10873 }
10874 
10875 static int
10876 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10877 {
10878 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10879 	struct crypto_unittest_params *ut_params = &unittest_params;
10880 
10881 	int retval;
10882 	uint8_t *plaintext;
10883 	struct rte_cryptodev_info dev_info;
10884 
10885 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10886 	uint64_t feat_flags = dev_info.feature_flags;
10887 
10888 	/* Verify the capabilities */
10889 	struct rte_cryptodev_sym_capability_idx cap_idx;
10890 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10891 	cap_idx.algo.aead = tdata->algo;
10892 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10893 			&cap_idx) == NULL)
10894 		return TEST_SKIPPED;
10895 
10896 	/* not supported with CPU crypto and raw data-path APIs*/
10897 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10898 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
10899 		return TEST_SKIPPED;
10900 
10901 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10902 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10903 		printf("Device does not support RAW data-path APIs.\n");
10904 		return TEST_SKIPPED;
10905 	}
10906 
10907 	/* Create AEAD session */
10908 	retval = create_aead_session(ts_params->valid_devs[0],
10909 			tdata->algo,
10910 			RTE_CRYPTO_AEAD_OP_DECRYPT,
10911 			tdata->key.data, tdata->key.len,
10912 			tdata->aad.len, tdata->auth_tag.len,
10913 			tdata->iv.len);
10914 	if (retval < 0)
10915 		return retval;
10916 
10917 	/* alloc mbuf and set payload */
10918 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10919 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10920 
10921 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10922 			rte_pktmbuf_tailroom(ut_params->ibuf));
10923 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10924 			rte_pktmbuf_tailroom(ut_params->obuf));
10925 
10926 	/* Create AEAD operation */
10927 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10928 	if (retval < 0)
10929 		return retval;
10930 
10931 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10932 
10933 	ut_params->op->sym->m_src = ut_params->ibuf;
10934 	ut_params->op->sym->m_dst = ut_params->obuf;
10935 
10936 	/* Process crypto operation */
10937 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10938 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10939 				ut_params->op, 0, 0, 0, 0);
10940 	else
10941 		TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10942 			ut_params->op), "failed to process sym crypto op");
10943 
10944 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10945 			"crypto op processing failed");
10946 
10947 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10948 			ut_params->op->sym->cipher.data.offset);
10949 
10950 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10951 
10952 	/* Validate obuf */
10953 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10954 			plaintext,
10955 			tdata->plaintext.data,
10956 			tdata->plaintext.len,
10957 			"Plaintext data not as expected");
10958 
10959 	TEST_ASSERT_EQUAL(ut_params->op->status,
10960 			RTE_CRYPTO_OP_STATUS_SUCCESS,
10961 			"Authentication failed");
10962 	return 0;
10963 }
10964 
10965 static int
10966 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10967 {
10968 	return test_authenticated_decryption_oop(&gcm_test_case_5);
10969 }
10970 
10971 static int
10972 test_authenticated_encryption_sessionless(
10973 		const struct aead_test_data *tdata)
10974 {
10975 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10976 	struct crypto_unittest_params *ut_params = &unittest_params;
10977 
10978 	int retval;
10979 	uint8_t *ciphertext, *auth_tag;
10980 	uint16_t plaintext_pad_len;
10981 	uint8_t key[tdata->key.len + 1];
10982 	struct rte_cryptodev_info dev_info;
10983 
10984 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10985 	uint64_t feat_flags = dev_info.feature_flags;
10986 
10987 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10988 		printf("Device doesn't support Sessionless ops.\n");
10989 		return TEST_SKIPPED;
10990 	}
10991 
10992 	/* not supported with CPU crypto */
10993 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10994 		return TEST_SKIPPED;
10995 
10996 	/* Verify the capabilities */
10997 	struct rte_cryptodev_sym_capability_idx cap_idx;
10998 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10999 	cap_idx.algo.aead = tdata->algo;
11000 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11001 			&cap_idx) == NULL)
11002 		return TEST_SKIPPED;
11003 
11004 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11005 
11006 	/* clear mbuf payload */
11007 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11008 			rte_pktmbuf_tailroom(ut_params->ibuf));
11009 
11010 	/* Create AEAD operation */
11011 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11012 	if (retval < 0)
11013 		return retval;
11014 
11015 	/* Create GCM xform */
11016 	memcpy(key, tdata->key.data, tdata->key.len);
11017 	retval = create_aead_xform(ut_params->op,
11018 			tdata->algo,
11019 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
11020 			key, tdata->key.len,
11021 			tdata->aad.len, tdata->auth_tag.len,
11022 			tdata->iv.len);
11023 	if (retval < 0)
11024 		return retval;
11025 
11026 	ut_params->op->sym->m_src = ut_params->ibuf;
11027 
11028 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11029 			RTE_CRYPTO_OP_SESSIONLESS,
11030 			"crypto op session type not sessionless");
11031 
11032 	/* Process crypto operation */
11033 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11034 			ut_params->op), "failed to process sym crypto op");
11035 
11036 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11037 
11038 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11039 			"crypto op status not success");
11040 
11041 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11042 
11043 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11044 			ut_params->op->sym->cipher.data.offset);
11045 	auth_tag = ciphertext + plaintext_pad_len;
11046 
11047 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11048 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11049 
11050 	/* Validate obuf */
11051 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11052 			ciphertext,
11053 			tdata->ciphertext.data,
11054 			tdata->ciphertext.len,
11055 			"Ciphertext data not as expected");
11056 
11057 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11058 			auth_tag,
11059 			tdata->auth_tag.data,
11060 			tdata->auth_tag.len,
11061 			"Generated auth tag not as expected");
11062 
11063 	return 0;
11064 
11065 }
11066 
11067 static int
11068 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
11069 {
11070 	return test_authenticated_encryption_sessionless(
11071 			&gcm_test_case_5);
11072 }
11073 
11074 static int
11075 test_authenticated_decryption_sessionless(
11076 		const struct aead_test_data *tdata)
11077 {
11078 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11079 	struct crypto_unittest_params *ut_params = &unittest_params;
11080 
11081 	int retval;
11082 	uint8_t *plaintext;
11083 	uint8_t key[tdata->key.len + 1];
11084 	struct rte_cryptodev_info dev_info;
11085 
11086 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11087 	uint64_t feat_flags = dev_info.feature_flags;
11088 
11089 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11090 		printf("Device doesn't support Sessionless ops.\n");
11091 		return TEST_SKIPPED;
11092 	}
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 	/* not supported with CPU crypto */
11101 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11102 		return TEST_SKIPPED;
11103 
11104 	/* Verify the capabilities */
11105 	struct rte_cryptodev_sym_capability_idx cap_idx;
11106 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11107 	cap_idx.algo.aead = tdata->algo;
11108 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11109 			&cap_idx) == NULL)
11110 		return TEST_SKIPPED;
11111 
11112 	/* alloc mbuf and set payload */
11113 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11114 
11115 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11116 			rte_pktmbuf_tailroom(ut_params->ibuf));
11117 
11118 	/* Create AEAD operation */
11119 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11120 	if (retval < 0)
11121 		return retval;
11122 
11123 	/* Create AEAD xform */
11124 	memcpy(key, tdata->key.data, tdata->key.len);
11125 	retval = create_aead_xform(ut_params->op,
11126 			tdata->algo,
11127 			RTE_CRYPTO_AEAD_OP_DECRYPT,
11128 			key, tdata->key.len,
11129 			tdata->aad.len, tdata->auth_tag.len,
11130 			tdata->iv.len);
11131 	if (retval < 0)
11132 		return retval;
11133 
11134 	ut_params->op->sym->m_src = ut_params->ibuf;
11135 
11136 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11137 			RTE_CRYPTO_OP_SESSIONLESS,
11138 			"crypto op session type not sessionless");
11139 
11140 	/* Process crypto operation */
11141 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11142 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11143 				ut_params->op, 0, 0, 0, 0);
11144 	else
11145 		TEST_ASSERT_NOT_NULL(process_crypto_request(
11146 			ts_params->valid_devs[0], ut_params->op),
11147 				"failed to process sym crypto op");
11148 
11149 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11150 
11151 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11152 			"crypto op status not success");
11153 
11154 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11155 			ut_params->op->sym->cipher.data.offset);
11156 
11157 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11158 
11159 	/* Validate obuf */
11160 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11161 			plaintext,
11162 			tdata->plaintext.data,
11163 			tdata->plaintext.len,
11164 			"Plaintext data not as expected");
11165 
11166 	TEST_ASSERT_EQUAL(ut_params->op->status,
11167 			RTE_CRYPTO_OP_STATUS_SUCCESS,
11168 			"Authentication failed");
11169 	return 0;
11170 }
11171 
11172 static int
11173 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
11174 {
11175 	return test_authenticated_decryption_sessionless(
11176 			&gcm_test_case_5);
11177 }
11178 
11179 static int
11180 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
11181 {
11182 	return test_authenticated_encryption(&ccm_test_case_128_1);
11183 }
11184 
11185 static int
11186 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
11187 {
11188 	return test_authenticated_encryption(&ccm_test_case_128_2);
11189 }
11190 
11191 static int
11192 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
11193 {
11194 	return test_authenticated_encryption(&ccm_test_case_128_3);
11195 }
11196 
11197 static int
11198 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
11199 {
11200 	return test_authenticated_decryption(&ccm_test_case_128_1);
11201 }
11202 
11203 static int
11204 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11205 {
11206 	return test_authenticated_decryption(&ccm_test_case_128_2);
11207 }
11208 
11209 static int
11210 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11211 {
11212 	return test_authenticated_decryption(&ccm_test_case_128_3);
11213 }
11214 
11215 static int
11216 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11217 {
11218 	return test_authenticated_encryption(&ccm_test_case_192_1);
11219 }
11220 
11221 static int
11222 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11223 {
11224 	return test_authenticated_encryption(&ccm_test_case_192_2);
11225 }
11226 
11227 static int
11228 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11229 {
11230 	return test_authenticated_encryption(&ccm_test_case_192_3);
11231 }
11232 
11233 static int
11234 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11235 {
11236 	return test_authenticated_decryption(&ccm_test_case_192_1);
11237 }
11238 
11239 static int
11240 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11241 {
11242 	return test_authenticated_decryption(&ccm_test_case_192_2);
11243 }
11244 
11245 static int
11246 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11247 {
11248 	return test_authenticated_decryption(&ccm_test_case_192_3);
11249 }
11250 
11251 static int
11252 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11253 {
11254 	return test_authenticated_encryption(&ccm_test_case_256_1);
11255 }
11256 
11257 static int
11258 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11259 {
11260 	return test_authenticated_encryption(&ccm_test_case_256_2);
11261 }
11262 
11263 static int
11264 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11265 {
11266 	return test_authenticated_encryption(&ccm_test_case_256_3);
11267 }
11268 
11269 static int
11270 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11271 {
11272 	return test_authenticated_decryption(&ccm_test_case_256_1);
11273 }
11274 
11275 static int
11276 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11277 {
11278 	return test_authenticated_decryption(&ccm_test_case_256_2);
11279 }
11280 
11281 static int
11282 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11283 {
11284 	return test_authenticated_decryption(&ccm_test_case_256_3);
11285 }
11286 
11287 static int
11288 test_stats(void)
11289 {
11290 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11291 	struct rte_cryptodev_stats stats;
11292 
11293 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11294 		return TEST_SKIPPED;
11295 
11296 	/* Verify the capabilities */
11297 	struct rte_cryptodev_sym_capability_idx cap_idx;
11298 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11299 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11300 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11301 			&cap_idx) == NULL)
11302 		return TEST_SKIPPED;
11303 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11304 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11305 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11306 			&cap_idx) == NULL)
11307 		return TEST_SKIPPED;
11308 
11309 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11310 			== -ENOTSUP)
11311 		return TEST_SKIPPED;
11312 
11313 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11314 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11315 			&stats) == -ENODEV),
11316 		"rte_cryptodev_stats_get invalid dev failed");
11317 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11318 		"rte_cryptodev_stats_get invalid Param failed");
11319 
11320 	/* Test expected values */
11321 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
11322 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11323 			&stats),
11324 		"rte_cryptodev_stats_get failed");
11325 	TEST_ASSERT((stats.enqueued_count == 1),
11326 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11327 	TEST_ASSERT((stats.dequeued_count == 1),
11328 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11329 	TEST_ASSERT((stats.enqueue_err_count == 0),
11330 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11331 	TEST_ASSERT((stats.dequeue_err_count == 0),
11332 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11333 
11334 	/* invalid device but should ignore and not reset device stats*/
11335 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11336 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11337 			&stats),
11338 		"rte_cryptodev_stats_get failed");
11339 	TEST_ASSERT((stats.enqueued_count == 1),
11340 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11341 
11342 	/* check that a valid reset clears stats */
11343 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11344 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11345 			&stats),
11346 					  "rte_cryptodev_stats_get failed");
11347 	TEST_ASSERT((stats.enqueued_count == 0),
11348 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11349 	TEST_ASSERT((stats.dequeued_count == 0),
11350 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
11351 
11352 	return TEST_SUCCESS;
11353 }
11354 
11355 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11356 				   struct crypto_unittest_params *ut_params,
11357 				   enum rte_crypto_auth_operation op,
11358 				   const struct HMAC_MD5_vector *test_case)
11359 {
11360 	uint8_t key[64];
11361 	int status;
11362 
11363 	memcpy(key, test_case->key.data, test_case->key.len);
11364 
11365 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11366 	ut_params->auth_xform.next = NULL;
11367 	ut_params->auth_xform.auth.op = op;
11368 
11369 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11370 
11371 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11372 	ut_params->auth_xform.auth.key.length = test_case->key.len;
11373 	ut_params->auth_xform.auth.key.data = key;
11374 
11375 	ut_params->sess = rte_cryptodev_sym_session_create(
11376 			ts_params->session_mpool);
11377 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11378 	if (ut_params->sess == NULL)
11379 		return TEST_FAILED;
11380 
11381 	status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11382 			ut_params->sess, &ut_params->auth_xform,
11383 			ts_params->session_priv_mpool);
11384 	if (status == -ENOTSUP)
11385 		return TEST_SKIPPED;
11386 
11387 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11388 
11389 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11390 			rte_pktmbuf_tailroom(ut_params->ibuf));
11391 
11392 	return 0;
11393 }
11394 
11395 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11396 			      const struct HMAC_MD5_vector *test_case,
11397 			      uint8_t **plaintext)
11398 {
11399 	uint16_t plaintext_pad_len;
11400 
11401 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11402 
11403 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11404 				16);
11405 
11406 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11407 			plaintext_pad_len);
11408 	memcpy(*plaintext, test_case->plaintext.data,
11409 			test_case->plaintext.len);
11410 
11411 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11412 			ut_params->ibuf, MD5_DIGEST_LEN);
11413 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11414 			"no room to append digest");
11415 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11416 			ut_params->ibuf, plaintext_pad_len);
11417 
11418 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11419 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11420 			   test_case->auth_tag.len);
11421 	}
11422 
11423 	sym_op->auth.data.offset = 0;
11424 	sym_op->auth.data.length = test_case->plaintext.len;
11425 
11426 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11427 	ut_params->op->sym->m_src = ut_params->ibuf;
11428 
11429 	return 0;
11430 }
11431 
11432 static int
11433 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11434 {
11435 	uint16_t plaintext_pad_len;
11436 	uint8_t *plaintext, *auth_tag;
11437 
11438 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11439 	struct crypto_unittest_params *ut_params = &unittest_params;
11440 	struct rte_cryptodev_info dev_info;
11441 
11442 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11443 	uint64_t feat_flags = dev_info.feature_flags;
11444 
11445 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11446 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11447 		printf("Device doesn't support RAW data-path APIs.\n");
11448 		return TEST_SKIPPED;
11449 	}
11450 
11451 	/* Verify the capabilities */
11452 	struct rte_cryptodev_sym_capability_idx cap_idx;
11453 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11454 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11455 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11456 			&cap_idx) == NULL)
11457 		return TEST_SKIPPED;
11458 
11459 	if (MD5_HMAC_create_session(ts_params, ut_params,
11460 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11461 		return TEST_FAILED;
11462 
11463 	/* Generate Crypto op data structure */
11464 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11465 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11466 	TEST_ASSERT_NOT_NULL(ut_params->op,
11467 			"Failed to allocate symmetric crypto operation struct");
11468 
11469 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11470 				16);
11471 
11472 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11473 		return TEST_FAILED;
11474 
11475 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11476 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11477 			ut_params->op);
11478 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11479 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11480 				ut_params->op, 0, 1, 0, 0);
11481 	else
11482 		TEST_ASSERT_NOT_NULL(
11483 			process_crypto_request(ts_params->valid_devs[0],
11484 				ut_params->op),
11485 				"failed to process sym crypto op");
11486 
11487 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11488 			"crypto op processing failed");
11489 
11490 	if (ut_params->op->sym->m_dst) {
11491 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11492 				uint8_t *, plaintext_pad_len);
11493 	} else {
11494 		auth_tag = plaintext + plaintext_pad_len;
11495 	}
11496 
11497 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11498 			auth_tag,
11499 			test_case->auth_tag.data,
11500 			test_case->auth_tag.len,
11501 			"HMAC_MD5 generated tag not as expected");
11502 
11503 	return TEST_SUCCESS;
11504 }
11505 
11506 static int
11507 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11508 {
11509 	uint8_t *plaintext;
11510 
11511 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11512 	struct crypto_unittest_params *ut_params = &unittest_params;
11513 	struct rte_cryptodev_info dev_info;
11514 
11515 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11516 	uint64_t feat_flags = dev_info.feature_flags;
11517 
11518 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11519 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11520 		printf("Device doesn't support RAW data-path APIs.\n");
11521 		return TEST_SKIPPED;
11522 	}
11523 
11524 	/* Verify the capabilities */
11525 	struct rte_cryptodev_sym_capability_idx cap_idx;
11526 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11527 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11528 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11529 			&cap_idx) == NULL)
11530 		return TEST_SKIPPED;
11531 
11532 	if (MD5_HMAC_create_session(ts_params, ut_params,
11533 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11534 		return TEST_FAILED;
11535 	}
11536 
11537 	/* Generate Crypto op data structure */
11538 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11539 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11540 	TEST_ASSERT_NOT_NULL(ut_params->op,
11541 			"Failed to allocate symmetric crypto operation struct");
11542 
11543 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11544 		return TEST_FAILED;
11545 
11546 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11547 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11548 			ut_params->op);
11549 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11550 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11551 				ut_params->op, 0, 1, 0, 0);
11552 	else
11553 		TEST_ASSERT_NOT_NULL(
11554 			process_crypto_request(ts_params->valid_devs[0],
11555 				ut_params->op),
11556 				"failed to process sym crypto op");
11557 
11558 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11559 			"HMAC_MD5 crypto op processing failed");
11560 
11561 	return TEST_SUCCESS;
11562 }
11563 
11564 static int
11565 test_MD5_HMAC_generate_case_1(void)
11566 {
11567 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11568 }
11569 
11570 static int
11571 test_MD5_HMAC_verify_case_1(void)
11572 {
11573 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11574 }
11575 
11576 static int
11577 test_MD5_HMAC_generate_case_2(void)
11578 {
11579 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11580 }
11581 
11582 static int
11583 test_MD5_HMAC_verify_case_2(void)
11584 {
11585 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11586 }
11587 
11588 static int
11589 test_multi_session(void)
11590 {
11591 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11592 	struct crypto_unittest_params *ut_params = &unittest_params;
11593 
11594 	struct rte_cryptodev_info dev_info;
11595 	struct rte_cryptodev_sym_session **sessions;
11596 
11597 	uint16_t i;
11598 	int status;
11599 
11600 	/* Verify the capabilities */
11601 	struct rte_cryptodev_sym_capability_idx cap_idx;
11602 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11603 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11604 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11605 			&cap_idx) == NULL)
11606 		return TEST_SKIPPED;
11607 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11608 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11609 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11610 			&cap_idx) == NULL)
11611 		return TEST_SKIPPED;
11612 
11613 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11614 			aes_cbc_key, hmac_sha512_key);
11615 
11616 
11617 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11618 
11619 	sessions = rte_malloc(NULL,
11620 			sizeof(struct rte_cryptodev_sym_session *) *
11621 			(MAX_NB_SESSIONS + 1), 0);
11622 
11623 	/* Create multiple crypto sessions*/
11624 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
11625 
11626 		sessions[i] = rte_cryptodev_sym_session_create(
11627 				ts_params->session_mpool);
11628 		TEST_ASSERT_NOT_NULL(sessions[i],
11629 				"Session creation failed at session number %u",
11630 				i);
11631 
11632 		status = rte_cryptodev_sym_session_init(
11633 				ts_params->valid_devs[0],
11634 				sessions[i], &ut_params->auth_xform,
11635 				ts_params->session_priv_mpool);
11636 		if (status == -ENOTSUP)
11637 			return TEST_SKIPPED;
11638 
11639 		/* Attempt to send a request on each session */
11640 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11641 			sessions[i],
11642 			ut_params,
11643 			ts_params,
11644 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11645 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11646 			aes_cbc_iv),
11647 			"Failed to perform decrypt on request number %u.", i);
11648 		/* free crypto operation structure */
11649 		if (ut_params->op)
11650 			rte_crypto_op_free(ut_params->op);
11651 
11652 		/*
11653 		 * free mbuf - both obuf and ibuf are usually the same,
11654 		 * so check if they point at the same address is necessary,
11655 		 * to avoid freeing the mbuf twice.
11656 		 */
11657 		if (ut_params->obuf) {
11658 			rte_pktmbuf_free(ut_params->obuf);
11659 			if (ut_params->ibuf == ut_params->obuf)
11660 				ut_params->ibuf = 0;
11661 			ut_params->obuf = 0;
11662 		}
11663 		if (ut_params->ibuf) {
11664 			rte_pktmbuf_free(ut_params->ibuf);
11665 			ut_params->ibuf = 0;
11666 		}
11667 	}
11668 
11669 	sessions[i] = NULL;
11670 	/* Next session create should fail */
11671 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11672 			sessions[i], &ut_params->auth_xform,
11673 			ts_params->session_priv_mpool);
11674 	TEST_ASSERT_NULL(sessions[i],
11675 			"Session creation succeeded unexpectedly!");
11676 
11677 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
11678 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11679 				sessions[i]);
11680 		rte_cryptodev_sym_session_free(sessions[i]);
11681 	}
11682 
11683 	rte_free(sessions);
11684 
11685 	return TEST_SUCCESS;
11686 }
11687 
11688 struct multi_session_params {
11689 	struct crypto_unittest_params ut_params;
11690 	uint8_t *cipher_key;
11691 	uint8_t *hmac_key;
11692 	const uint8_t *cipher;
11693 	const uint8_t *digest;
11694 	uint8_t *iv;
11695 };
11696 
11697 #define MB_SESSION_NUMBER 3
11698 
11699 static int
11700 test_multi_session_random_usage(void)
11701 {
11702 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11703 	struct rte_cryptodev_info dev_info;
11704 	struct rte_cryptodev_sym_session **sessions;
11705 	uint32_t i, j;
11706 	struct multi_session_params ut_paramz[] = {
11707 
11708 		{
11709 			.cipher_key = ms_aes_cbc_key0,
11710 			.hmac_key = ms_hmac_key0,
11711 			.cipher = ms_aes_cbc_cipher0,
11712 			.digest = ms_hmac_digest0,
11713 			.iv = ms_aes_cbc_iv0
11714 		},
11715 		{
11716 			.cipher_key = ms_aes_cbc_key1,
11717 			.hmac_key = ms_hmac_key1,
11718 			.cipher = ms_aes_cbc_cipher1,
11719 			.digest = ms_hmac_digest1,
11720 			.iv = ms_aes_cbc_iv1
11721 		},
11722 		{
11723 			.cipher_key = ms_aes_cbc_key2,
11724 			.hmac_key = ms_hmac_key2,
11725 			.cipher = ms_aes_cbc_cipher2,
11726 			.digest = ms_hmac_digest2,
11727 			.iv = ms_aes_cbc_iv2
11728 		},
11729 
11730 	};
11731 	int status;
11732 
11733 	/* Verify the capabilities */
11734 	struct rte_cryptodev_sym_capability_idx cap_idx;
11735 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11736 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11737 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11738 			&cap_idx) == NULL)
11739 		return TEST_SKIPPED;
11740 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11741 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11742 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11743 			&cap_idx) == NULL)
11744 		return TEST_SKIPPED;
11745 
11746 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11747 
11748 	sessions = rte_malloc(NULL,
11749 			(sizeof(struct rte_cryptodev_sym_session *)
11750 					* MAX_NB_SESSIONS) + 1, 0);
11751 
11752 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
11753 		sessions[i] = rte_cryptodev_sym_session_create(
11754 				ts_params->session_mpool);
11755 		TEST_ASSERT_NOT_NULL(sessions[i],
11756 				"Session creation failed at session number %u",
11757 				i);
11758 
11759 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11760 				sizeof(struct crypto_unittest_params));
11761 
11762 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11763 				&ut_paramz[i].ut_params,
11764 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11765 
11766 		/* Create multiple crypto sessions*/
11767 		status = rte_cryptodev_sym_session_init(
11768 				ts_params->valid_devs[0],
11769 				sessions[i],
11770 				&ut_paramz[i].ut_params.auth_xform,
11771 				ts_params->session_priv_mpool);
11772 
11773 		if (status == -ENOTSUP)
11774 			return TEST_SKIPPED;
11775 
11776 		TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11777 	}
11778 
11779 	srand(time(NULL));
11780 	for (i = 0; i < 40000; i++) {
11781 
11782 		j = rand() % MB_SESSION_NUMBER;
11783 
11784 		TEST_ASSERT_SUCCESS(
11785 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
11786 					sessions[j],
11787 					&ut_paramz[j].ut_params,
11788 					ts_params, ut_paramz[j].cipher,
11789 					ut_paramz[j].digest,
11790 					ut_paramz[j].iv),
11791 			"Failed to perform decrypt on request number %u.", i);
11792 
11793 		if (ut_paramz[j].ut_params.op)
11794 			rte_crypto_op_free(ut_paramz[j].ut_params.op);
11795 
11796 		/*
11797 		 * free mbuf - both obuf and ibuf are usually the same,
11798 		 * so check if they point at the same address is necessary,
11799 		 * to avoid freeing the mbuf twice.
11800 		 */
11801 		if (ut_paramz[j].ut_params.obuf) {
11802 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11803 			if (ut_paramz[j].ut_params.ibuf
11804 					== ut_paramz[j].ut_params.obuf)
11805 				ut_paramz[j].ut_params.ibuf = 0;
11806 			ut_paramz[j].ut_params.obuf = 0;
11807 		}
11808 		if (ut_paramz[j].ut_params.ibuf) {
11809 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11810 			ut_paramz[j].ut_params.ibuf = 0;
11811 		}
11812 	}
11813 
11814 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
11815 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11816 				sessions[i]);
11817 		rte_cryptodev_sym_session_free(sessions[i]);
11818 	}
11819 
11820 	rte_free(sessions);
11821 
11822 	return TEST_SUCCESS;
11823 }
11824 
11825 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11826 			0xab, 0xab, 0xab, 0xab,
11827 			0xab, 0xab, 0xab, 0xab,
11828 			0xab, 0xab, 0xab, 0xab};
11829 
11830 static int
11831 test_null_invalid_operation(void)
11832 {
11833 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11834 	struct crypto_unittest_params *ut_params = &unittest_params;
11835 	int ret;
11836 
11837 	/* This test is for NULL PMD only */
11838 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
11839 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11840 		return TEST_SKIPPED;
11841 
11842 	/* Setup Cipher Parameters */
11843 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11844 	ut_params->cipher_xform.next = NULL;
11845 
11846 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11847 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11848 
11849 	ut_params->sess = rte_cryptodev_sym_session_create(
11850 			ts_params->session_mpool);
11851 
11852 	/* Create Crypto session*/
11853 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11854 			ut_params->sess, &ut_params->cipher_xform,
11855 			ts_params->session_priv_mpool);
11856 	TEST_ASSERT(ret < 0,
11857 			"Session creation succeeded unexpectedly");
11858 
11859 
11860 	/* Setup HMAC Parameters */
11861 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11862 	ut_params->auth_xform.next = NULL;
11863 
11864 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11865 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11866 
11867 	ut_params->sess = rte_cryptodev_sym_session_create(
11868 			ts_params->session_mpool);
11869 
11870 	/* Create Crypto session*/
11871 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11872 			ut_params->sess, &ut_params->auth_xform,
11873 			ts_params->session_priv_mpool);
11874 	TEST_ASSERT(ret < 0,
11875 			"Session creation succeeded unexpectedly");
11876 
11877 	return TEST_SUCCESS;
11878 }
11879 
11880 
11881 #define NULL_BURST_LENGTH (32)
11882 
11883 static int
11884 test_null_burst_operation(void)
11885 {
11886 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11887 	struct crypto_unittest_params *ut_params = &unittest_params;
11888 	int status;
11889 
11890 	unsigned i, burst_len = NULL_BURST_LENGTH;
11891 
11892 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11893 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11894 
11895 	/* This test is for NULL PMD only */
11896 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
11897 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11898 		return TEST_SKIPPED;
11899 
11900 	/* Setup Cipher Parameters */
11901 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11902 	ut_params->cipher_xform.next = &ut_params->auth_xform;
11903 
11904 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11905 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11906 
11907 	/* Setup HMAC Parameters */
11908 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11909 	ut_params->auth_xform.next = NULL;
11910 
11911 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11912 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11913 
11914 	ut_params->sess = rte_cryptodev_sym_session_create(
11915 			ts_params->session_mpool);
11916 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11917 
11918 	/* Create Crypto session*/
11919 	status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11920 			ut_params->sess, &ut_params->cipher_xform,
11921 			ts_params->session_priv_mpool);
11922 
11923 	if (status == -ENOTSUP)
11924 		return TEST_SKIPPED;
11925 
11926 	TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11927 
11928 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11929 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11930 			burst_len, "failed to generate burst of crypto ops");
11931 
11932 	/* Generate an operation for each mbuf in burst */
11933 	for (i = 0; i < burst_len; i++) {
11934 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11935 
11936 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11937 
11938 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11939 				sizeof(unsigned));
11940 		*data = i;
11941 
11942 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11943 
11944 		burst[i]->sym->m_src = m;
11945 	}
11946 
11947 	/* Process crypto operation */
11948 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11949 			0, burst, burst_len),
11950 			burst_len,
11951 			"Error enqueuing burst");
11952 
11953 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11954 			0, burst_dequeued, burst_len),
11955 			burst_len,
11956 			"Error dequeuing burst");
11957 
11958 
11959 	for (i = 0; i < burst_len; i++) {
11960 		TEST_ASSERT_EQUAL(
11961 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11962 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11963 					uint32_t *),
11964 			"data not as expected");
11965 
11966 		rte_pktmbuf_free(burst[i]->sym->m_src);
11967 		rte_crypto_op_free(burst[i]);
11968 	}
11969 
11970 	return TEST_SUCCESS;
11971 }
11972 
11973 static uint16_t
11974 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11975 		  uint16_t nb_ops, void *user_param)
11976 {
11977 	RTE_SET_USED(dev_id);
11978 	RTE_SET_USED(qp_id);
11979 	RTE_SET_USED(ops);
11980 	RTE_SET_USED(user_param);
11981 
11982 	printf("crypto enqueue callback called\n");
11983 	return nb_ops;
11984 }
11985 
11986 static uint16_t
11987 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11988 		  uint16_t nb_ops, void *user_param)
11989 {
11990 	RTE_SET_USED(dev_id);
11991 	RTE_SET_USED(qp_id);
11992 	RTE_SET_USED(ops);
11993 	RTE_SET_USED(user_param);
11994 
11995 	printf("crypto dequeue callback called\n");
11996 	return nb_ops;
11997 }
11998 
11999 /*
12000  * Thread using enqueue/dequeue callback with RCU.
12001  */
12002 static int
12003 test_enqdeq_callback_thread(void *arg)
12004 {
12005 	RTE_SET_USED(arg);
12006 	/* DP thread calls rte_cryptodev_enqueue_burst()/
12007 	 * rte_cryptodev_dequeue_burst() and invokes callback.
12008 	 */
12009 	test_null_burst_operation();
12010 	return 0;
12011 }
12012 
12013 static int
12014 test_enq_callback_setup(void)
12015 {
12016 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12017 	struct rte_cryptodev_info dev_info;
12018 	struct rte_cryptodev_qp_conf qp_conf = {
12019 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
12020 	};
12021 
12022 	struct rte_cryptodev_cb *cb;
12023 	uint16_t qp_id = 0;
12024 
12025 	/* Stop the device in case it's started so it can be configured */
12026 	rte_cryptodev_stop(ts_params->valid_devs[0]);
12027 
12028 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12029 
12030 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12031 			&ts_params->conf),
12032 			"Failed to configure cryptodev %u",
12033 			ts_params->valid_devs[0]);
12034 
12035 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12036 	qp_conf.mp_session = ts_params->session_mpool;
12037 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
12038 
12039 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12040 			ts_params->valid_devs[0], qp_id, &qp_conf,
12041 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12042 			"Failed test for "
12043 			"rte_cryptodev_queue_pair_setup: num_inflights "
12044 			"%u on qp %u on cryptodev %u",
12045 			qp_conf.nb_descriptors, qp_id,
12046 			ts_params->valid_devs[0]);
12047 
12048 	/* Test with invalid crypto device */
12049 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
12050 			qp_id, test_enq_callback, NULL);
12051 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12052 			"cryptodev %u did not fail",
12053 			qp_id, RTE_CRYPTO_MAX_DEVS);
12054 
12055 	/* Test with invalid queue pair */
12056 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12057 			dev_info.max_nb_queue_pairs + 1,
12058 			test_enq_callback, NULL);
12059 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12060 			"cryptodev %u did not fail",
12061 			dev_info.max_nb_queue_pairs + 1,
12062 			ts_params->valid_devs[0]);
12063 
12064 	/* Test with NULL callback */
12065 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12066 			qp_id, NULL, NULL);
12067 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12068 			"cryptodev %u did not fail",
12069 			qp_id, ts_params->valid_devs[0]);
12070 
12071 	/* Test with valid configuration */
12072 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12073 			qp_id, test_enq_callback, NULL);
12074 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12075 			"qp %u on cryptodev %u",
12076 			qp_id, ts_params->valid_devs[0]);
12077 
12078 	rte_cryptodev_start(ts_params->valid_devs[0]);
12079 
12080 	/* Launch a thread */
12081 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12082 				rte_get_next_lcore(-1, 1, 0));
12083 
12084 	/* Wait until reader exited. */
12085 	rte_eal_mp_wait_lcore();
12086 
12087 	/* Test with invalid crypto device */
12088 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12089 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12090 			"Expected call to fail as crypto device is invalid");
12091 
12092 	/* Test with invalid queue pair */
12093 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12094 			ts_params->valid_devs[0],
12095 			dev_info.max_nb_queue_pairs + 1, cb),
12096 			"Expected call to fail as queue pair is invalid");
12097 
12098 	/* Test with NULL callback */
12099 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12100 			ts_params->valid_devs[0], qp_id, NULL),
12101 			"Expected call to fail as callback is NULL");
12102 
12103 	/* Test with valid configuration */
12104 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
12105 			ts_params->valid_devs[0], qp_id, cb),
12106 			"Failed test to remove callback on "
12107 			"qp %u on cryptodev %u",
12108 			qp_id, ts_params->valid_devs[0]);
12109 
12110 	return TEST_SUCCESS;
12111 }
12112 
12113 static int
12114 test_deq_callback_setup(void)
12115 {
12116 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12117 	struct rte_cryptodev_info dev_info;
12118 	struct rte_cryptodev_qp_conf qp_conf = {
12119 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
12120 	};
12121 
12122 	struct rte_cryptodev_cb *cb;
12123 	uint16_t qp_id = 0;
12124 
12125 	/* Stop the device in case it's started so it can be configured */
12126 	rte_cryptodev_stop(ts_params->valid_devs[0]);
12127 
12128 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12129 
12130 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12131 			&ts_params->conf),
12132 			"Failed to configure cryptodev %u",
12133 			ts_params->valid_devs[0]);
12134 
12135 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12136 	qp_conf.mp_session = ts_params->session_mpool;
12137 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
12138 
12139 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12140 			ts_params->valid_devs[0], qp_id, &qp_conf,
12141 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12142 			"Failed test for "
12143 			"rte_cryptodev_queue_pair_setup: num_inflights "
12144 			"%u on qp %u on cryptodev %u",
12145 			qp_conf.nb_descriptors, qp_id,
12146 			ts_params->valid_devs[0]);
12147 
12148 	/* Test with invalid crypto device */
12149 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
12150 			qp_id, test_deq_callback, NULL);
12151 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12152 			"cryptodev %u did not fail",
12153 			qp_id, RTE_CRYPTO_MAX_DEVS);
12154 
12155 	/* Test with invalid queue pair */
12156 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12157 			dev_info.max_nb_queue_pairs + 1,
12158 			test_deq_callback, NULL);
12159 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12160 			"cryptodev %u did not fail",
12161 			dev_info.max_nb_queue_pairs + 1,
12162 			ts_params->valid_devs[0]);
12163 
12164 	/* Test with NULL callback */
12165 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12166 			qp_id, NULL, NULL);
12167 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12168 			"cryptodev %u did not fail",
12169 			qp_id, ts_params->valid_devs[0]);
12170 
12171 	/* Test with valid configuration */
12172 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12173 			qp_id, test_deq_callback, NULL);
12174 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12175 			"qp %u on cryptodev %u",
12176 			qp_id, ts_params->valid_devs[0]);
12177 
12178 	rte_cryptodev_start(ts_params->valid_devs[0]);
12179 
12180 	/* Launch a thread */
12181 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12182 				rte_get_next_lcore(-1, 1, 0));
12183 
12184 	/* Wait until reader exited. */
12185 	rte_eal_mp_wait_lcore();
12186 
12187 	/* Test with invalid crypto device */
12188 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12189 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12190 			"Expected call to fail as crypto device is invalid");
12191 
12192 	/* Test with invalid queue pair */
12193 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12194 			ts_params->valid_devs[0],
12195 			dev_info.max_nb_queue_pairs + 1, cb),
12196 			"Expected call to fail as queue pair is invalid");
12197 
12198 	/* Test with NULL callback */
12199 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12200 			ts_params->valid_devs[0], qp_id, NULL),
12201 			"Expected call to fail as callback is NULL");
12202 
12203 	/* Test with valid configuration */
12204 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
12205 			ts_params->valid_devs[0], qp_id, cb),
12206 			"Failed test to remove callback on "
12207 			"qp %u on cryptodev %u",
12208 			qp_id, ts_params->valid_devs[0]);
12209 
12210 	return TEST_SUCCESS;
12211 }
12212 
12213 static void
12214 generate_gmac_large_plaintext(uint8_t *data)
12215 {
12216 	uint16_t i;
12217 
12218 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12219 		memcpy(&data[i], &data[0], 32);
12220 }
12221 
12222 static int
12223 create_gmac_operation(enum rte_crypto_auth_operation op,
12224 		const struct gmac_test_data *tdata)
12225 {
12226 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12227 	struct crypto_unittest_params *ut_params = &unittest_params;
12228 	struct rte_crypto_sym_op *sym_op;
12229 
12230 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12231 
12232 	/* Generate Crypto op data structure */
12233 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12234 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12235 	TEST_ASSERT_NOT_NULL(ut_params->op,
12236 			"Failed to allocate symmetric crypto operation struct");
12237 
12238 	sym_op = ut_params->op->sym;
12239 
12240 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12241 			ut_params->ibuf, tdata->gmac_tag.len);
12242 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12243 			"no room to append digest");
12244 
12245 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12246 			ut_params->ibuf, plaintext_pad_len);
12247 
12248 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12249 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12250 				tdata->gmac_tag.len);
12251 		debug_hexdump(stdout, "digest:",
12252 				sym_op->auth.digest.data,
12253 				tdata->gmac_tag.len);
12254 	}
12255 
12256 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12257 			uint8_t *, IV_OFFSET);
12258 
12259 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12260 
12261 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12262 
12263 	sym_op->cipher.data.length = 0;
12264 	sym_op->cipher.data.offset = 0;
12265 
12266 	sym_op->auth.data.offset = 0;
12267 	sym_op->auth.data.length = tdata->plaintext.len;
12268 
12269 	return 0;
12270 }
12271 
12272 static int
12273 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12274 		const struct gmac_test_data *tdata,
12275 		void *digest_mem, uint64_t digest_phys)
12276 {
12277 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12278 	struct crypto_unittest_params *ut_params = &unittest_params;
12279 	struct rte_crypto_sym_op *sym_op;
12280 
12281 	/* Generate Crypto op data structure */
12282 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12283 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12284 	TEST_ASSERT_NOT_NULL(ut_params->op,
12285 			"Failed to allocate symmetric crypto operation struct");
12286 
12287 	sym_op = ut_params->op->sym;
12288 
12289 	sym_op->auth.digest.data = digest_mem;
12290 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12291 			"no room to append digest");
12292 
12293 	sym_op->auth.digest.phys_addr = digest_phys;
12294 
12295 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12296 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12297 				tdata->gmac_tag.len);
12298 		debug_hexdump(stdout, "digest:",
12299 				sym_op->auth.digest.data,
12300 				tdata->gmac_tag.len);
12301 	}
12302 
12303 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12304 			uint8_t *, IV_OFFSET);
12305 
12306 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12307 
12308 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12309 
12310 	sym_op->cipher.data.length = 0;
12311 	sym_op->cipher.data.offset = 0;
12312 
12313 	sym_op->auth.data.offset = 0;
12314 	sym_op->auth.data.length = tdata->plaintext.len;
12315 
12316 	return 0;
12317 }
12318 
12319 static int create_gmac_session(uint8_t dev_id,
12320 		const struct gmac_test_data *tdata,
12321 		enum rte_crypto_auth_operation auth_op)
12322 {
12323 	uint8_t auth_key[tdata->key.len];
12324 	int status;
12325 
12326 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12327 	struct crypto_unittest_params *ut_params = &unittest_params;
12328 
12329 	memcpy(auth_key, tdata->key.data, tdata->key.len);
12330 
12331 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12332 	ut_params->auth_xform.next = NULL;
12333 
12334 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12335 	ut_params->auth_xform.auth.op = auth_op;
12336 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12337 	ut_params->auth_xform.auth.key.length = tdata->key.len;
12338 	ut_params->auth_xform.auth.key.data = auth_key;
12339 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12340 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12341 
12342 
12343 	ut_params->sess = rte_cryptodev_sym_session_create(
12344 			ts_params->session_mpool);
12345 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12346 
12347 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12348 			&ut_params->auth_xform,
12349 			ts_params->session_priv_mpool);
12350 
12351 	return status;
12352 }
12353 
12354 static int
12355 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12356 {
12357 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12358 	struct crypto_unittest_params *ut_params = &unittest_params;
12359 	struct rte_cryptodev_info dev_info;
12360 
12361 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12362 	uint64_t feat_flags = dev_info.feature_flags;
12363 
12364 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12365 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12366 		printf("Device doesn't support RAW data-path APIs.\n");
12367 		return TEST_SKIPPED;
12368 	}
12369 
12370 	int retval;
12371 
12372 	uint8_t *auth_tag, *plaintext;
12373 	uint16_t plaintext_pad_len;
12374 
12375 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12376 			      "No GMAC length in the source data");
12377 
12378 	/* Verify the capabilities */
12379 	struct rte_cryptodev_sym_capability_idx cap_idx;
12380 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12381 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12382 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12383 			&cap_idx) == NULL)
12384 		return TEST_SKIPPED;
12385 
12386 	retval = create_gmac_session(ts_params->valid_devs[0],
12387 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12388 
12389 	if (retval == -ENOTSUP)
12390 		return TEST_SKIPPED;
12391 	if (retval < 0)
12392 		return retval;
12393 
12394 	if (tdata->plaintext.len > MBUF_SIZE)
12395 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12396 	else
12397 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12398 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12399 			"Failed to allocate input buffer in mempool");
12400 
12401 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12402 			rte_pktmbuf_tailroom(ut_params->ibuf));
12403 
12404 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12405 	/*
12406 	 * Runtime generate the large plain text instead of use hard code
12407 	 * plain text vector. It is done to avoid create huge source file
12408 	 * with the test vector.
12409 	 */
12410 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12411 		generate_gmac_large_plaintext(tdata->plaintext.data);
12412 
12413 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12414 				plaintext_pad_len);
12415 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12416 
12417 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12418 	debug_hexdump(stdout, "plaintext:", plaintext,
12419 			tdata->plaintext.len);
12420 
12421 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12422 			tdata);
12423 
12424 	if (retval < 0)
12425 		return retval;
12426 
12427 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12428 
12429 	ut_params->op->sym->m_src = ut_params->ibuf;
12430 
12431 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12432 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12433 			ut_params->op);
12434 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12435 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12436 				ut_params->op, 0, 1, 0, 0);
12437 	else
12438 		TEST_ASSERT_NOT_NULL(
12439 			process_crypto_request(ts_params->valid_devs[0],
12440 			ut_params->op), "failed to process sym crypto op");
12441 
12442 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12443 			"crypto op processing failed");
12444 
12445 	if (ut_params->op->sym->m_dst) {
12446 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12447 				uint8_t *, plaintext_pad_len);
12448 	} else {
12449 		auth_tag = plaintext + plaintext_pad_len;
12450 	}
12451 
12452 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12453 
12454 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12455 			auth_tag,
12456 			tdata->gmac_tag.data,
12457 			tdata->gmac_tag.len,
12458 			"GMAC Generated auth tag not as expected");
12459 
12460 	return 0;
12461 }
12462 
12463 static int
12464 test_AES_GMAC_authentication_test_case_1(void)
12465 {
12466 	return test_AES_GMAC_authentication(&gmac_test_case_1);
12467 }
12468 
12469 static int
12470 test_AES_GMAC_authentication_test_case_2(void)
12471 {
12472 	return test_AES_GMAC_authentication(&gmac_test_case_2);
12473 }
12474 
12475 static int
12476 test_AES_GMAC_authentication_test_case_3(void)
12477 {
12478 	return test_AES_GMAC_authentication(&gmac_test_case_3);
12479 }
12480 
12481 static int
12482 test_AES_GMAC_authentication_test_case_4(void)
12483 {
12484 	return test_AES_GMAC_authentication(&gmac_test_case_4);
12485 }
12486 
12487 static int
12488 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12489 {
12490 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12491 	struct crypto_unittest_params *ut_params = &unittest_params;
12492 	int retval;
12493 	uint32_t plaintext_pad_len;
12494 	uint8_t *plaintext;
12495 	struct rte_cryptodev_info dev_info;
12496 
12497 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12498 	uint64_t feat_flags = dev_info.feature_flags;
12499 
12500 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12501 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12502 		printf("Device doesn't support RAW data-path APIs.\n");
12503 		return TEST_SKIPPED;
12504 	}
12505 
12506 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12507 			      "No GMAC length in the source data");
12508 
12509 	/* Verify the capabilities */
12510 	struct rte_cryptodev_sym_capability_idx cap_idx;
12511 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12512 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12513 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12514 			&cap_idx) == NULL)
12515 		return TEST_SKIPPED;
12516 
12517 	retval = create_gmac_session(ts_params->valid_devs[0],
12518 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12519 
12520 	if (retval == -ENOTSUP)
12521 		return TEST_SKIPPED;
12522 	if (retval < 0)
12523 		return retval;
12524 
12525 	if (tdata->plaintext.len > MBUF_SIZE)
12526 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12527 	else
12528 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12529 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12530 			"Failed to allocate input buffer in mempool");
12531 
12532 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12533 			rte_pktmbuf_tailroom(ut_params->ibuf));
12534 
12535 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12536 
12537 	/*
12538 	 * Runtime generate the large plain text instead of use hard code
12539 	 * plain text vector. It is done to avoid create huge source file
12540 	 * with the test vector.
12541 	 */
12542 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12543 		generate_gmac_large_plaintext(tdata->plaintext.data);
12544 
12545 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12546 				plaintext_pad_len);
12547 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12548 
12549 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12550 	debug_hexdump(stdout, "plaintext:", plaintext,
12551 			tdata->plaintext.len);
12552 
12553 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12554 			tdata);
12555 
12556 	if (retval < 0)
12557 		return retval;
12558 
12559 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12560 
12561 	ut_params->op->sym->m_src = ut_params->ibuf;
12562 
12563 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12564 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12565 			ut_params->op);
12566 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12567 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12568 				ut_params->op, 0, 1, 0, 0);
12569 	else
12570 		TEST_ASSERT_NOT_NULL(
12571 			process_crypto_request(ts_params->valid_devs[0],
12572 			ut_params->op), "failed to process sym crypto op");
12573 
12574 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12575 			"crypto op processing failed");
12576 
12577 	return 0;
12578 
12579 }
12580 
12581 static int
12582 test_AES_GMAC_authentication_verify_test_case_1(void)
12583 {
12584 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12585 }
12586 
12587 static int
12588 test_AES_GMAC_authentication_verify_test_case_2(void)
12589 {
12590 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12591 }
12592 
12593 static int
12594 test_AES_GMAC_authentication_verify_test_case_3(void)
12595 {
12596 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12597 }
12598 
12599 static int
12600 test_AES_GMAC_authentication_verify_test_case_4(void)
12601 {
12602 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12603 }
12604 
12605 static int
12606 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12607 				uint32_t fragsz)
12608 {
12609 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12610 	struct crypto_unittest_params *ut_params = &unittest_params;
12611 	struct rte_cryptodev_info dev_info;
12612 	uint64_t feature_flags;
12613 	unsigned int trn_data = 0;
12614 	void *digest_mem = NULL;
12615 	uint32_t segs = 1;
12616 	unsigned int to_trn = 0;
12617 	struct rte_mbuf *buf = NULL;
12618 	uint8_t *auth_tag, *plaintext;
12619 	int retval;
12620 
12621 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12622 			      "No GMAC length in the source data");
12623 
12624 	/* Verify the capabilities */
12625 	struct rte_cryptodev_sym_capability_idx cap_idx;
12626 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12627 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12628 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12629 			&cap_idx) == NULL)
12630 		return TEST_SKIPPED;
12631 
12632 	/* Check for any input SGL support */
12633 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12634 	feature_flags = dev_info.feature_flags;
12635 
12636 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12637 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12638 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12639 		return TEST_SKIPPED;
12640 
12641 	if (fragsz > tdata->plaintext.len)
12642 		fragsz = tdata->plaintext.len;
12643 
12644 	uint16_t plaintext_len = fragsz;
12645 
12646 	retval = create_gmac_session(ts_params->valid_devs[0],
12647 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12648 
12649 	if (retval == -ENOTSUP)
12650 		return TEST_SKIPPED;
12651 	if (retval < 0)
12652 		return retval;
12653 
12654 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12655 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12656 			"Failed to allocate input buffer in mempool");
12657 
12658 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12659 			rte_pktmbuf_tailroom(ut_params->ibuf));
12660 
12661 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12662 				plaintext_len);
12663 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12664 
12665 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12666 
12667 	trn_data += plaintext_len;
12668 
12669 	buf = ut_params->ibuf;
12670 
12671 	/*
12672 	 * Loop until no more fragments
12673 	 */
12674 
12675 	while (trn_data < tdata->plaintext.len) {
12676 		++segs;
12677 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12678 				(tdata->plaintext.len - trn_data) : fragsz;
12679 
12680 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12681 		buf = buf->next;
12682 
12683 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12684 				rte_pktmbuf_tailroom(buf));
12685 
12686 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12687 				to_trn);
12688 
12689 		memcpy(plaintext, tdata->plaintext.data + trn_data,
12690 				to_trn);
12691 		trn_data += to_trn;
12692 		if (trn_data  == tdata->plaintext.len)
12693 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12694 					tdata->gmac_tag.len);
12695 	}
12696 	ut_params->ibuf->nb_segs = segs;
12697 
12698 	/*
12699 	 * Place digest at the end of the last buffer
12700 	 */
12701 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12702 
12703 	if (!digest_mem) {
12704 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12705 				+ tdata->gmac_tag.len);
12706 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12707 				tdata->plaintext.len);
12708 	}
12709 
12710 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12711 			tdata, digest_mem, digest_phys);
12712 
12713 	if (retval < 0)
12714 		return retval;
12715 
12716 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12717 
12718 	ut_params->op->sym->m_src = ut_params->ibuf;
12719 
12720 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12721 		return TEST_SKIPPED;
12722 
12723 	TEST_ASSERT_NOT_NULL(
12724 		process_crypto_request(ts_params->valid_devs[0],
12725 		ut_params->op), "failed to process sym crypto op");
12726 
12727 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12728 			"crypto op processing failed");
12729 
12730 	auth_tag = digest_mem;
12731 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12732 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12733 			auth_tag,
12734 			tdata->gmac_tag.data,
12735 			tdata->gmac_tag.len,
12736 			"GMAC Generated auth tag not as expected");
12737 
12738 	return 0;
12739 }
12740 
12741 /* Segment size not multiple of block size (16B) */
12742 static int
12743 test_AES_GMAC_authentication_SGL_40B(void)
12744 {
12745 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12746 }
12747 
12748 static int
12749 test_AES_GMAC_authentication_SGL_80B(void)
12750 {
12751 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12752 }
12753 
12754 static int
12755 test_AES_GMAC_authentication_SGL_2048B(void)
12756 {
12757 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12758 }
12759 
12760 /* Segment size not multiple of block size (16B) */
12761 static int
12762 test_AES_GMAC_authentication_SGL_2047B(void)
12763 {
12764 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12765 }
12766 
12767 struct test_crypto_vector {
12768 	enum rte_crypto_cipher_algorithm crypto_algo;
12769 	unsigned int cipher_offset;
12770 	unsigned int cipher_len;
12771 
12772 	struct {
12773 		uint8_t data[64];
12774 		unsigned int len;
12775 	} cipher_key;
12776 
12777 	struct {
12778 		uint8_t data[64];
12779 		unsigned int len;
12780 	} iv;
12781 
12782 	struct {
12783 		const uint8_t *data;
12784 		unsigned int len;
12785 	} plaintext;
12786 
12787 	struct {
12788 		const uint8_t *data;
12789 		unsigned int len;
12790 	} ciphertext;
12791 
12792 	enum rte_crypto_auth_algorithm auth_algo;
12793 	unsigned int auth_offset;
12794 
12795 	struct {
12796 		uint8_t data[128];
12797 		unsigned int len;
12798 	} auth_key;
12799 
12800 	struct {
12801 		const uint8_t *data;
12802 		unsigned int len;
12803 	} aad;
12804 
12805 	struct {
12806 		uint8_t data[128];
12807 		unsigned int len;
12808 	} digest;
12809 };
12810 
12811 static const struct test_crypto_vector
12812 hmac_sha1_test_crypto_vector = {
12813 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12814 	.plaintext = {
12815 		.data = plaintext_hash,
12816 		.len = 512
12817 	},
12818 	.auth_key = {
12819 		.data = {
12820 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12821 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12822 			0xDE, 0xF4, 0xDE, 0xAD
12823 		},
12824 		.len = 20
12825 	},
12826 	.digest = {
12827 		.data = {
12828 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12829 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12830 			0x3F, 0x91, 0x64, 0x59
12831 		},
12832 		.len = 20
12833 	}
12834 };
12835 
12836 static const struct test_crypto_vector
12837 aes128_gmac_test_vector = {
12838 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12839 	.plaintext = {
12840 		.data = plaintext_hash,
12841 		.len = 512
12842 	},
12843 	.iv = {
12844 		.data = {
12845 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12846 			0x08, 0x09, 0x0A, 0x0B
12847 		},
12848 		.len = 12
12849 	},
12850 	.auth_key = {
12851 		.data = {
12852 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12853 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12854 		},
12855 		.len = 16
12856 	},
12857 	.digest = {
12858 		.data = {
12859 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12860 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12861 		},
12862 		.len = 16
12863 	}
12864 };
12865 
12866 static const struct test_crypto_vector
12867 aes128cbc_hmac_sha1_test_vector = {
12868 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12869 	.cipher_offset = 0,
12870 	.cipher_len = 512,
12871 	.cipher_key = {
12872 		.data = {
12873 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12874 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12875 		},
12876 		.len = 16
12877 	},
12878 	.iv = {
12879 		.data = {
12880 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12881 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12882 		},
12883 		.len = 16
12884 	},
12885 	.plaintext = {
12886 		.data = plaintext_hash,
12887 		.len = 512
12888 	},
12889 	.ciphertext = {
12890 		.data = ciphertext512_aes128cbc,
12891 		.len = 512
12892 	},
12893 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12894 	.auth_offset = 0,
12895 	.auth_key = {
12896 		.data = {
12897 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12898 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12899 			0xDE, 0xF4, 0xDE, 0xAD
12900 		},
12901 		.len = 20
12902 	},
12903 	.digest = {
12904 		.data = {
12905 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12906 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12907 			0x18, 0x8C, 0x1D, 0x32
12908 		},
12909 		.len = 20
12910 	}
12911 };
12912 
12913 static const struct test_crypto_vector
12914 aes128cbc_hmac_sha1_aad_test_vector = {
12915 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12916 	.cipher_offset = 8,
12917 	.cipher_len = 496,
12918 	.cipher_key = {
12919 		.data = {
12920 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12921 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12922 		},
12923 		.len = 16
12924 	},
12925 	.iv = {
12926 		.data = {
12927 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12928 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12929 		},
12930 		.len = 16
12931 	},
12932 	.plaintext = {
12933 		.data = plaintext_hash,
12934 		.len = 512
12935 	},
12936 	.ciphertext = {
12937 		.data = ciphertext512_aes128cbc_aad,
12938 		.len = 512
12939 	},
12940 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12941 	.auth_offset = 0,
12942 	.auth_key = {
12943 		.data = {
12944 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12945 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12946 			0xDE, 0xF4, 0xDE, 0xAD
12947 		},
12948 		.len = 20
12949 	},
12950 	.digest = {
12951 		.data = {
12952 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12953 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12954 			0x62, 0x0F, 0xFB, 0x10
12955 		},
12956 		.len = 20
12957 	}
12958 };
12959 
12960 static void
12961 data_corruption(uint8_t *data)
12962 {
12963 	data[0] += 1;
12964 }
12965 
12966 static void
12967 tag_corruption(uint8_t *data, unsigned int tag_offset)
12968 {
12969 	data[tag_offset] += 1;
12970 }
12971 
12972 static int
12973 create_auth_session(struct crypto_unittest_params *ut_params,
12974 		uint8_t dev_id,
12975 		const struct test_crypto_vector *reference,
12976 		enum rte_crypto_auth_operation auth_op)
12977 {
12978 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12979 	uint8_t auth_key[reference->auth_key.len + 1];
12980 	int status;
12981 
12982 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12983 
12984 	/* Setup Authentication Parameters */
12985 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12986 	ut_params->auth_xform.auth.op = auth_op;
12987 	ut_params->auth_xform.next = NULL;
12988 	ut_params->auth_xform.auth.algo = reference->auth_algo;
12989 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12990 	ut_params->auth_xform.auth.key.data = auth_key;
12991 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
12992 
12993 	/* Create Crypto session*/
12994 	ut_params->sess = rte_cryptodev_sym_session_create(
12995 			ts_params->session_mpool);
12996 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12997 
12998 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12999 				&ut_params->auth_xform,
13000 				ts_params->session_priv_mpool);
13001 
13002 	return status;
13003 }
13004 
13005 static int
13006 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
13007 		uint8_t dev_id,
13008 		const struct test_crypto_vector *reference,
13009 		enum rte_crypto_auth_operation auth_op,
13010 		enum rte_crypto_cipher_operation cipher_op)
13011 {
13012 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13013 	uint8_t cipher_key[reference->cipher_key.len + 1];
13014 	uint8_t auth_key[reference->auth_key.len + 1];
13015 	int status;
13016 
13017 	memcpy(cipher_key, reference->cipher_key.data,
13018 			reference->cipher_key.len);
13019 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13020 
13021 	/* Setup Authentication Parameters */
13022 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13023 	ut_params->auth_xform.auth.op = auth_op;
13024 	ut_params->auth_xform.auth.algo = reference->auth_algo;
13025 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13026 	ut_params->auth_xform.auth.key.data = auth_key;
13027 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
13028 
13029 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
13030 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13031 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
13032 	} else {
13033 		ut_params->auth_xform.next = &ut_params->cipher_xform;
13034 
13035 		/* Setup Cipher Parameters */
13036 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13037 		ut_params->cipher_xform.next = NULL;
13038 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13039 		ut_params->cipher_xform.cipher.op = cipher_op;
13040 		ut_params->cipher_xform.cipher.key.data = cipher_key;
13041 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13042 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13043 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13044 	}
13045 
13046 	/* Create Crypto session*/
13047 	ut_params->sess = rte_cryptodev_sym_session_create(
13048 			ts_params->session_mpool);
13049 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13050 
13051 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13052 				&ut_params->auth_xform,
13053 				ts_params->session_priv_mpool);
13054 
13055 	return status;
13056 }
13057 
13058 static int
13059 create_auth_operation(struct crypto_testsuite_params *ts_params,
13060 		struct crypto_unittest_params *ut_params,
13061 		const struct test_crypto_vector *reference,
13062 		unsigned int auth_generate)
13063 {
13064 	/* Generate Crypto op data structure */
13065 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13066 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13067 	TEST_ASSERT_NOT_NULL(ut_params->op,
13068 			"Failed to allocate pktmbuf offload");
13069 
13070 	/* Set crypto operation data parameters */
13071 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13072 
13073 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13074 
13075 	/* set crypto operation source mbuf */
13076 	sym_op->m_src = ut_params->ibuf;
13077 
13078 	/* digest */
13079 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13080 			ut_params->ibuf, reference->digest.len);
13081 
13082 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13083 			"no room to append auth tag");
13084 
13085 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13086 			ut_params->ibuf, reference->plaintext.len);
13087 
13088 	if (auth_generate)
13089 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
13090 	else
13091 		memcpy(sym_op->auth.digest.data,
13092 				reference->digest.data,
13093 				reference->digest.len);
13094 
13095 	debug_hexdump(stdout, "digest:",
13096 			sym_op->auth.digest.data,
13097 			reference->digest.len);
13098 
13099 	sym_op->auth.data.length = reference->plaintext.len;
13100 	sym_op->auth.data.offset = 0;
13101 
13102 	return 0;
13103 }
13104 
13105 static int
13106 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
13107 		struct crypto_unittest_params *ut_params,
13108 		const struct test_crypto_vector *reference,
13109 		unsigned int auth_generate)
13110 {
13111 	/* Generate Crypto op data structure */
13112 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13113 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13114 	TEST_ASSERT_NOT_NULL(ut_params->op,
13115 			"Failed to allocate pktmbuf offload");
13116 
13117 	/* Set crypto operation data parameters */
13118 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13119 
13120 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13121 
13122 	/* set crypto operation source mbuf */
13123 	sym_op->m_src = ut_params->ibuf;
13124 
13125 	/* digest */
13126 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13127 			ut_params->ibuf, reference->digest.len);
13128 
13129 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13130 			"no room to append auth tag");
13131 
13132 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13133 			ut_params->ibuf, reference->ciphertext.len);
13134 
13135 	if (auth_generate)
13136 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
13137 	else
13138 		memcpy(sym_op->auth.digest.data,
13139 				reference->digest.data,
13140 				reference->digest.len);
13141 
13142 	debug_hexdump(stdout, "digest:",
13143 			sym_op->auth.digest.data,
13144 			reference->digest.len);
13145 
13146 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13147 			reference->iv.data, reference->iv.len);
13148 
13149 	sym_op->cipher.data.length = 0;
13150 	sym_op->cipher.data.offset = 0;
13151 
13152 	sym_op->auth.data.length = reference->plaintext.len;
13153 	sym_op->auth.data.offset = 0;
13154 
13155 	return 0;
13156 }
13157 
13158 static int
13159 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
13160 		struct crypto_unittest_params *ut_params,
13161 		const struct test_crypto_vector *reference,
13162 		unsigned int auth_generate)
13163 {
13164 	/* Generate Crypto op data structure */
13165 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13166 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13167 	TEST_ASSERT_NOT_NULL(ut_params->op,
13168 			"Failed to allocate pktmbuf offload");
13169 
13170 	/* Set crypto operation data parameters */
13171 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13172 
13173 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13174 
13175 	/* set crypto operation source mbuf */
13176 	sym_op->m_src = ut_params->ibuf;
13177 
13178 	/* digest */
13179 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13180 			ut_params->ibuf, reference->digest.len);
13181 
13182 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13183 			"no room to append auth tag");
13184 
13185 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13186 			ut_params->ibuf, reference->ciphertext.len);
13187 
13188 	if (auth_generate)
13189 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
13190 	else
13191 		memcpy(sym_op->auth.digest.data,
13192 				reference->digest.data,
13193 				reference->digest.len);
13194 
13195 	debug_hexdump(stdout, "digest:",
13196 			sym_op->auth.digest.data,
13197 			reference->digest.len);
13198 
13199 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13200 			reference->iv.data, reference->iv.len);
13201 
13202 	sym_op->cipher.data.length = reference->cipher_len;
13203 	sym_op->cipher.data.offset = reference->cipher_offset;
13204 
13205 	sym_op->auth.data.length = reference->plaintext.len;
13206 	sym_op->auth.data.offset = reference->auth_offset;
13207 
13208 	return 0;
13209 }
13210 
13211 static int
13212 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13213 		struct crypto_unittest_params *ut_params,
13214 		const struct test_crypto_vector *reference)
13215 {
13216 	return create_auth_operation(ts_params, ut_params, reference, 0);
13217 }
13218 
13219 static int
13220 create_auth_verify_GMAC_operation(
13221 		struct crypto_testsuite_params *ts_params,
13222 		struct crypto_unittest_params *ut_params,
13223 		const struct test_crypto_vector *reference)
13224 {
13225 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13226 }
13227 
13228 static int
13229 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13230 		struct crypto_unittest_params *ut_params,
13231 		const struct test_crypto_vector *reference)
13232 {
13233 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13234 }
13235 
13236 static int
13237 test_authentication_verify_fail_when_data_corruption(
13238 		struct crypto_testsuite_params *ts_params,
13239 		struct crypto_unittest_params *ut_params,
13240 		const struct test_crypto_vector *reference,
13241 		unsigned int data_corrupted)
13242 {
13243 	int retval;
13244 
13245 	uint8_t *plaintext;
13246 	struct rte_cryptodev_info dev_info;
13247 
13248 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13249 	uint64_t feat_flags = dev_info.feature_flags;
13250 
13251 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13252 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13253 		printf("Device doesn't support RAW data-path APIs.\n");
13254 		return TEST_SKIPPED;
13255 	}
13256 
13257 	/* Verify the capabilities */
13258 	struct rte_cryptodev_sym_capability_idx cap_idx;
13259 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13260 	cap_idx.algo.auth = reference->auth_algo;
13261 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13262 			&cap_idx) == NULL)
13263 		return TEST_SKIPPED;
13264 
13265 
13266 	/* Create session */
13267 	retval = create_auth_session(ut_params,
13268 			ts_params->valid_devs[0],
13269 			reference,
13270 			RTE_CRYPTO_AUTH_OP_VERIFY);
13271 
13272 	if (retval == -ENOTSUP)
13273 		return TEST_SKIPPED;
13274 	if (retval < 0)
13275 		return retval;
13276 
13277 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13278 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13279 			"Failed to allocate input buffer in mempool");
13280 
13281 	/* clear mbuf payload */
13282 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13283 			rte_pktmbuf_tailroom(ut_params->ibuf));
13284 
13285 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13286 			reference->plaintext.len);
13287 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13288 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13289 
13290 	debug_hexdump(stdout, "plaintext:", plaintext,
13291 		reference->plaintext.len);
13292 
13293 	/* Create operation */
13294 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
13295 
13296 	if (retval < 0)
13297 		return retval;
13298 
13299 	if (data_corrupted)
13300 		data_corruption(plaintext);
13301 	else
13302 		tag_corruption(plaintext, reference->plaintext.len);
13303 
13304 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13305 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13306 			ut_params->op);
13307 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13308 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13309 			"authentication not failed");
13310 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13311 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13312 				ut_params->op, 0, 1, 0, 0);
13313 	else {
13314 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13315 			ut_params->op);
13316 	}
13317 	if (ut_params->op == NULL)
13318 		return 0;
13319 	else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13320 		return 0;
13321 
13322 	return -1;
13323 }
13324 
13325 static int
13326 test_authentication_verify_GMAC_fail_when_corruption(
13327 		struct crypto_testsuite_params *ts_params,
13328 		struct crypto_unittest_params *ut_params,
13329 		const struct test_crypto_vector *reference,
13330 		unsigned int data_corrupted)
13331 {
13332 	int retval;
13333 	uint8_t *plaintext;
13334 	struct rte_cryptodev_info dev_info;
13335 
13336 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13337 	uint64_t feat_flags = dev_info.feature_flags;
13338 
13339 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13340 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13341 		printf("Device doesn't support RAW data-path APIs.\n");
13342 		return TEST_SKIPPED;
13343 	}
13344 
13345 	/* Verify the capabilities */
13346 	struct rte_cryptodev_sym_capability_idx cap_idx;
13347 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13348 	cap_idx.algo.auth = reference->auth_algo;
13349 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13350 			&cap_idx) == NULL)
13351 		return TEST_SKIPPED;
13352 
13353 	/* Create session */
13354 	retval = create_auth_cipher_session(ut_params,
13355 			ts_params->valid_devs[0],
13356 			reference,
13357 			RTE_CRYPTO_AUTH_OP_VERIFY,
13358 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
13359 	if (retval < 0)
13360 		return retval;
13361 
13362 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13363 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13364 			"Failed to allocate input buffer in mempool");
13365 
13366 	/* clear mbuf payload */
13367 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13368 			rte_pktmbuf_tailroom(ut_params->ibuf));
13369 
13370 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13371 			reference->plaintext.len);
13372 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13373 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13374 
13375 	debug_hexdump(stdout, "plaintext:", plaintext,
13376 		reference->plaintext.len);
13377 
13378 	/* Create operation */
13379 	retval = create_auth_verify_GMAC_operation(ts_params,
13380 			ut_params,
13381 			reference);
13382 
13383 	if (retval < 0)
13384 		return retval;
13385 
13386 	if (data_corrupted)
13387 		data_corruption(plaintext);
13388 	else
13389 		tag_corruption(plaintext, reference->aad.len);
13390 
13391 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13392 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13393 			ut_params->op);
13394 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13395 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13396 			"authentication not failed");
13397 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13398 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13399 				ut_params->op, 0, 1, 0, 0);
13400 	else {
13401 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13402 			ut_params->op);
13403 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13404 	}
13405 
13406 	return 0;
13407 }
13408 
13409 static int
13410 test_authenticated_decryption_fail_when_corruption(
13411 		struct crypto_testsuite_params *ts_params,
13412 		struct crypto_unittest_params *ut_params,
13413 		const struct test_crypto_vector *reference,
13414 		unsigned int data_corrupted)
13415 {
13416 	int retval;
13417 
13418 	uint8_t *ciphertext;
13419 	struct rte_cryptodev_info dev_info;
13420 
13421 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13422 	uint64_t feat_flags = dev_info.feature_flags;
13423 
13424 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13425 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13426 		printf("Device doesn't support RAW data-path APIs.\n");
13427 		return TEST_SKIPPED;
13428 	}
13429 
13430 	/* Verify the capabilities */
13431 	struct rte_cryptodev_sym_capability_idx cap_idx;
13432 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13433 	cap_idx.algo.auth = reference->auth_algo;
13434 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13435 			&cap_idx) == NULL)
13436 		return TEST_SKIPPED;
13437 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13438 	cap_idx.algo.cipher = reference->crypto_algo;
13439 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13440 			&cap_idx) == NULL)
13441 		return TEST_SKIPPED;
13442 
13443 	/* Create session */
13444 	retval = create_auth_cipher_session(ut_params,
13445 			ts_params->valid_devs[0],
13446 			reference,
13447 			RTE_CRYPTO_AUTH_OP_VERIFY,
13448 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
13449 
13450 	if (retval == -ENOTSUP)
13451 		return TEST_SKIPPED;
13452 	if (retval < 0)
13453 		return retval;
13454 
13455 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13456 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13457 			"Failed to allocate input buffer in mempool");
13458 
13459 	/* clear mbuf payload */
13460 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13461 			rte_pktmbuf_tailroom(ut_params->ibuf));
13462 
13463 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13464 			reference->ciphertext.len);
13465 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13466 	memcpy(ciphertext, reference->ciphertext.data,
13467 			reference->ciphertext.len);
13468 
13469 	/* Create operation */
13470 	retval = create_cipher_auth_verify_operation(ts_params,
13471 			ut_params,
13472 			reference);
13473 
13474 	if (retval < 0)
13475 		return retval;
13476 
13477 	if (data_corrupted)
13478 		data_corruption(ciphertext);
13479 	else
13480 		tag_corruption(ciphertext, reference->ciphertext.len);
13481 
13482 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13483 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13484 			ut_params->op);
13485 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13486 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13487 			"authentication not failed");
13488 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13489 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13490 				ut_params->op, 1, 1, 0, 0);
13491 	else {
13492 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13493 			ut_params->op);
13494 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13495 	}
13496 
13497 	return 0;
13498 }
13499 
13500 static int
13501 test_authenticated_encrypt_with_esn(
13502 		struct crypto_testsuite_params *ts_params,
13503 		struct crypto_unittest_params *ut_params,
13504 		const struct test_crypto_vector *reference)
13505 {
13506 	int retval;
13507 
13508 	uint8_t *authciphertext, *plaintext, *auth_tag;
13509 	uint16_t plaintext_pad_len;
13510 	uint8_t cipher_key[reference->cipher_key.len + 1];
13511 	uint8_t auth_key[reference->auth_key.len + 1];
13512 	struct rte_cryptodev_info dev_info;
13513 	int status;
13514 
13515 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13516 	uint64_t feat_flags = dev_info.feature_flags;
13517 
13518 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13519 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13520 		printf("Device doesn't support RAW data-path APIs.\n");
13521 		return TEST_SKIPPED;
13522 	}
13523 
13524 	/* Verify the capabilities */
13525 	struct rte_cryptodev_sym_capability_idx cap_idx;
13526 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13527 	cap_idx.algo.auth = reference->auth_algo;
13528 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13529 			&cap_idx) == NULL)
13530 		return TEST_SKIPPED;
13531 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13532 	cap_idx.algo.cipher = reference->crypto_algo;
13533 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13534 			&cap_idx) == NULL)
13535 		return TEST_SKIPPED;
13536 
13537 	/* Create session */
13538 	memcpy(cipher_key, reference->cipher_key.data,
13539 			reference->cipher_key.len);
13540 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13541 
13542 	/* Setup Cipher Parameters */
13543 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13544 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13545 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13546 	ut_params->cipher_xform.cipher.key.data = cipher_key;
13547 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13548 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13549 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13550 
13551 	ut_params->cipher_xform.next = &ut_params->auth_xform;
13552 
13553 	/* Setup Authentication Parameters */
13554 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13555 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13556 	ut_params->auth_xform.auth.algo = reference->auth_algo;
13557 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13558 	ut_params->auth_xform.auth.key.data = auth_key;
13559 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
13560 	ut_params->auth_xform.next = NULL;
13561 
13562 	/* Create Crypto session*/
13563 	ut_params->sess = rte_cryptodev_sym_session_create(
13564 			ts_params->session_mpool);
13565 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13566 
13567 	status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13568 				ut_params->sess,
13569 				&ut_params->cipher_xform,
13570 				ts_params->session_priv_mpool);
13571 
13572 	if (status == -ENOTSUP)
13573 		return TEST_SKIPPED;
13574 
13575 	TEST_ASSERT_EQUAL(status, 0, "Session init failed");
13576 
13577 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13578 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13579 			"Failed to allocate input buffer in mempool");
13580 
13581 	/* clear mbuf payload */
13582 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13583 			rte_pktmbuf_tailroom(ut_params->ibuf));
13584 
13585 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13586 			reference->plaintext.len);
13587 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13588 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13589 
13590 	/* Create operation */
13591 	retval = create_cipher_auth_operation(ts_params,
13592 			ut_params,
13593 			reference, 0);
13594 
13595 	if (retval < 0)
13596 		return retval;
13597 
13598 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13599 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13600 			ut_params->op);
13601 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13602 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13603 				ut_params->op, 1, 1, 0, 0);
13604 	else
13605 		ut_params->op = process_crypto_request(
13606 			ts_params->valid_devs[0], ut_params->op);
13607 
13608 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13609 
13610 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13611 			"crypto op processing failed");
13612 
13613 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13614 
13615 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13616 			ut_params->op->sym->auth.data.offset);
13617 	auth_tag = authciphertext + plaintext_pad_len;
13618 	debug_hexdump(stdout, "ciphertext:", authciphertext,
13619 			reference->ciphertext.len);
13620 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13621 
13622 	/* Validate obuf */
13623 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13624 			authciphertext,
13625 			reference->ciphertext.data,
13626 			reference->ciphertext.len,
13627 			"Ciphertext data not as expected");
13628 
13629 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13630 			auth_tag,
13631 			reference->digest.data,
13632 			reference->digest.len,
13633 			"Generated digest not as expected");
13634 
13635 	return TEST_SUCCESS;
13636 
13637 }
13638 
13639 static int
13640 test_authenticated_decrypt_with_esn(
13641 		struct crypto_testsuite_params *ts_params,
13642 		struct crypto_unittest_params *ut_params,
13643 		const struct test_crypto_vector *reference)
13644 {
13645 	int retval;
13646 
13647 	uint8_t *ciphertext;
13648 	uint8_t cipher_key[reference->cipher_key.len + 1];
13649 	uint8_t auth_key[reference->auth_key.len + 1];
13650 	struct rte_cryptodev_info dev_info;
13651 
13652 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13653 	uint64_t feat_flags = dev_info.feature_flags;
13654 
13655 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13656 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13657 		printf("Device doesn't support RAW data-path APIs.\n");
13658 		return TEST_SKIPPED;
13659 	}
13660 
13661 	/* Verify the capabilities */
13662 	struct rte_cryptodev_sym_capability_idx cap_idx;
13663 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13664 	cap_idx.algo.auth = reference->auth_algo;
13665 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13666 			&cap_idx) == NULL)
13667 		return TEST_SKIPPED;
13668 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13669 	cap_idx.algo.cipher = reference->crypto_algo;
13670 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13671 			&cap_idx) == NULL)
13672 		return TEST_SKIPPED;
13673 
13674 	/* Create session */
13675 	memcpy(cipher_key, reference->cipher_key.data,
13676 			reference->cipher_key.len);
13677 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13678 
13679 	/* Setup Authentication Parameters */
13680 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13681 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13682 	ut_params->auth_xform.auth.algo = reference->auth_algo;
13683 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13684 	ut_params->auth_xform.auth.key.data = auth_key;
13685 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
13686 	ut_params->auth_xform.next = &ut_params->cipher_xform;
13687 
13688 	/* Setup Cipher Parameters */
13689 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13690 	ut_params->cipher_xform.next = NULL;
13691 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13692 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13693 	ut_params->cipher_xform.cipher.key.data = cipher_key;
13694 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13695 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13696 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13697 
13698 	/* Create Crypto session*/
13699 	ut_params->sess = rte_cryptodev_sym_session_create(
13700 			ts_params->session_mpool);
13701 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13702 
13703 	retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13704 				ut_params->sess,
13705 				&ut_params->auth_xform,
13706 				ts_params->session_priv_mpool);
13707 
13708 	if (retval == -ENOTSUP)
13709 		return TEST_SKIPPED;
13710 
13711 	TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
13712 
13713 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13714 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13715 			"Failed to allocate input buffer in mempool");
13716 
13717 	/* clear mbuf payload */
13718 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13719 			rte_pktmbuf_tailroom(ut_params->ibuf));
13720 
13721 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13722 			reference->ciphertext.len);
13723 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13724 	memcpy(ciphertext, reference->ciphertext.data,
13725 			reference->ciphertext.len);
13726 
13727 	/* Create operation */
13728 	retval = create_cipher_auth_verify_operation(ts_params,
13729 			ut_params,
13730 			reference);
13731 
13732 	if (retval < 0)
13733 		return retval;
13734 
13735 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13736 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13737 			ut_params->op);
13738 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13739 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13740 				ut_params->op, 1, 1, 0, 0);
13741 	else
13742 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13743 			ut_params->op);
13744 
13745 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13746 	TEST_ASSERT_EQUAL(ut_params->op->status,
13747 			RTE_CRYPTO_OP_STATUS_SUCCESS,
13748 			"crypto op processing passed");
13749 
13750 	ut_params->obuf = ut_params->op->sym->m_src;
13751 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13752 
13753 	return 0;
13754 }
13755 
13756 static int
13757 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13758 		const struct aead_test_data *tdata,
13759 		void *digest_mem, uint64_t digest_phys)
13760 {
13761 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13762 	struct crypto_unittest_params *ut_params = &unittest_params;
13763 
13764 	const unsigned int auth_tag_len = tdata->auth_tag.len;
13765 	const unsigned int iv_len = tdata->iv.len;
13766 	unsigned int aad_len = tdata->aad.len;
13767 	unsigned int aad_len_pad = 0;
13768 
13769 	/* Generate Crypto op data structure */
13770 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13771 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13772 	TEST_ASSERT_NOT_NULL(ut_params->op,
13773 		"Failed to allocate symmetric crypto operation struct");
13774 
13775 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13776 
13777 	sym_op->aead.digest.data = digest_mem;
13778 
13779 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13780 			"no room to append digest");
13781 
13782 	sym_op->aead.digest.phys_addr = digest_phys;
13783 
13784 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13785 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13786 				auth_tag_len);
13787 		debug_hexdump(stdout, "digest:",
13788 				sym_op->aead.digest.data,
13789 				auth_tag_len);
13790 	}
13791 
13792 	/* Append aad data */
13793 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13794 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13795 				uint8_t *, IV_OFFSET);
13796 
13797 		/* Copy IV 1 byte after the IV pointer, according to the API */
13798 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13799 
13800 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13801 
13802 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13803 				ut_params->ibuf, aad_len);
13804 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13805 				"no room to prepend aad");
13806 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13807 				ut_params->ibuf);
13808 
13809 		memset(sym_op->aead.aad.data, 0, aad_len);
13810 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
13811 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13812 
13813 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13814 		debug_hexdump(stdout, "aad:",
13815 				sym_op->aead.aad.data, aad_len);
13816 	} else {
13817 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13818 				uint8_t *, IV_OFFSET);
13819 
13820 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13821 
13822 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13823 
13824 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13825 				ut_params->ibuf, aad_len_pad);
13826 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13827 				"no room to prepend aad");
13828 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13829 				ut_params->ibuf);
13830 
13831 		memset(sym_op->aead.aad.data, 0, aad_len);
13832 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13833 
13834 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13835 		debug_hexdump(stdout, "aad:",
13836 				sym_op->aead.aad.data, aad_len);
13837 	}
13838 
13839 	sym_op->aead.data.length = tdata->plaintext.len;
13840 	sym_op->aead.data.offset = aad_len_pad;
13841 
13842 	return 0;
13843 }
13844 
13845 #define SGL_MAX_NO	16
13846 
13847 static int
13848 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13849 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13850 {
13851 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13852 	struct crypto_unittest_params *ut_params = &unittest_params;
13853 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13854 	int retval;
13855 	int to_trn = 0;
13856 	int to_trn_tbl[SGL_MAX_NO];
13857 	int segs = 1;
13858 	unsigned int trn_data = 0;
13859 	uint8_t *plaintext, *ciphertext, *auth_tag;
13860 	struct rte_cryptodev_info dev_info;
13861 
13862 	/* Verify the capabilities */
13863 	struct rte_cryptodev_sym_capability_idx cap_idx;
13864 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13865 	cap_idx.algo.aead = tdata->algo;
13866 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13867 			&cap_idx) == NULL)
13868 		return TEST_SKIPPED;
13869 
13870 	/* OOP not supported with CPU crypto */
13871 	if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13872 		return TEST_SKIPPED;
13873 
13874 	/* Detailed check for the particular SGL support flag */
13875 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13876 	if (!oop) {
13877 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
13878 		if (sgl_in && (!(dev_info.feature_flags &
13879 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13880 			return TEST_SKIPPED;
13881 
13882 		uint64_t feat_flags = dev_info.feature_flags;
13883 
13884 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13885 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13886 			printf("Device doesn't support RAW data-path APIs.\n");
13887 			return TEST_SKIPPED;
13888 		}
13889 	} else {
13890 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
13891 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13892 				tdata->plaintext.len;
13893 		/* Raw data path API does not support OOP */
13894 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13895 			return TEST_SKIPPED;
13896 		if (sgl_in && !sgl_out) {
13897 			if (!(dev_info.feature_flags &
13898 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13899 				return TEST_SKIPPED;
13900 		} else if (!sgl_in && sgl_out) {
13901 			if (!(dev_info.feature_flags &
13902 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13903 				return TEST_SKIPPED;
13904 		} else if (sgl_in && sgl_out) {
13905 			if (!(dev_info.feature_flags &
13906 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13907 				return TEST_SKIPPED;
13908 		}
13909 	}
13910 
13911 	if (fragsz > tdata->plaintext.len)
13912 		fragsz = tdata->plaintext.len;
13913 
13914 	uint16_t plaintext_len = fragsz;
13915 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13916 
13917 	if (fragsz_oop > tdata->plaintext.len)
13918 		frag_size_oop = tdata->plaintext.len;
13919 
13920 	int ecx = 0;
13921 	void *digest_mem = NULL;
13922 
13923 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13924 
13925 	if (tdata->plaintext.len % fragsz != 0) {
13926 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13927 			return 1;
13928 	}	else {
13929 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13930 			return 1;
13931 	}
13932 
13933 	/*
13934 	 * For out-op-place we need to alloc another mbuf
13935 	 */
13936 	if (oop) {
13937 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13938 		rte_pktmbuf_append(ut_params->obuf,
13939 				frag_size_oop + prepend_len);
13940 		buf_oop = ut_params->obuf;
13941 	}
13942 
13943 	/* Create AEAD session */
13944 	retval = create_aead_session(ts_params->valid_devs[0],
13945 			tdata->algo,
13946 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13947 			tdata->key.data, tdata->key.len,
13948 			tdata->aad.len, tdata->auth_tag.len,
13949 			tdata->iv.len);
13950 	if (retval < 0)
13951 		return retval;
13952 
13953 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13954 
13955 	/* clear mbuf payload */
13956 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13957 			rte_pktmbuf_tailroom(ut_params->ibuf));
13958 
13959 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13960 			plaintext_len);
13961 
13962 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13963 
13964 	trn_data += plaintext_len;
13965 
13966 	buf = ut_params->ibuf;
13967 
13968 	/*
13969 	 * Loop until no more fragments
13970 	 */
13971 
13972 	while (trn_data < tdata->plaintext.len) {
13973 		++segs;
13974 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13975 				(tdata->plaintext.len - trn_data) : fragsz;
13976 
13977 		to_trn_tbl[ecx++] = to_trn;
13978 
13979 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13980 		buf = buf->next;
13981 
13982 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13983 				rte_pktmbuf_tailroom(buf));
13984 
13985 		/* OOP */
13986 		if (oop && !fragsz_oop) {
13987 			buf_last_oop = buf_oop->next =
13988 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
13989 			buf_oop = buf_oop->next;
13990 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13991 					0, rte_pktmbuf_tailroom(buf_oop));
13992 			rte_pktmbuf_append(buf_oop, to_trn);
13993 		}
13994 
13995 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13996 				to_trn);
13997 
13998 		memcpy(plaintext, tdata->plaintext.data + trn_data,
13999 				to_trn);
14000 		trn_data += to_trn;
14001 		if (trn_data  == tdata->plaintext.len) {
14002 			if (oop) {
14003 				if (!fragsz_oop)
14004 					digest_mem = rte_pktmbuf_append(buf_oop,
14005 						tdata->auth_tag.len);
14006 			} else
14007 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14008 					tdata->auth_tag.len);
14009 		}
14010 	}
14011 
14012 	uint64_t digest_phys = 0;
14013 
14014 	ut_params->ibuf->nb_segs = segs;
14015 
14016 	segs = 1;
14017 	if (fragsz_oop && oop) {
14018 		to_trn = 0;
14019 		ecx = 0;
14020 
14021 		if (frag_size_oop == tdata->plaintext.len) {
14022 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
14023 				tdata->auth_tag.len);
14024 
14025 			digest_phys = rte_pktmbuf_iova_offset(
14026 					ut_params->obuf,
14027 					tdata->plaintext.len + prepend_len);
14028 		}
14029 
14030 		trn_data = frag_size_oop;
14031 		while (trn_data < tdata->plaintext.len) {
14032 			++segs;
14033 			to_trn =
14034 				(tdata->plaintext.len - trn_data <
14035 						frag_size_oop) ?
14036 				(tdata->plaintext.len - trn_data) :
14037 						frag_size_oop;
14038 
14039 			to_trn_tbl[ecx++] = to_trn;
14040 
14041 			buf_last_oop = buf_oop->next =
14042 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
14043 			buf_oop = buf_oop->next;
14044 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14045 					0, rte_pktmbuf_tailroom(buf_oop));
14046 			rte_pktmbuf_append(buf_oop, to_trn);
14047 
14048 			trn_data += to_trn;
14049 
14050 			if (trn_data  == tdata->plaintext.len) {
14051 				digest_mem = rte_pktmbuf_append(buf_oop,
14052 					tdata->auth_tag.len);
14053 			}
14054 		}
14055 
14056 		ut_params->obuf->nb_segs = segs;
14057 	}
14058 
14059 	/*
14060 	 * Place digest at the end of the last buffer
14061 	 */
14062 	if (!digest_phys)
14063 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14064 	if (oop && buf_last_oop)
14065 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
14066 
14067 	if (!digest_mem && !oop) {
14068 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14069 				+ tdata->auth_tag.len);
14070 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14071 				tdata->plaintext.len);
14072 	}
14073 
14074 	/* Create AEAD operation */
14075 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
14076 			tdata, digest_mem, digest_phys);
14077 
14078 	if (retval < 0)
14079 		return retval;
14080 
14081 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14082 
14083 	ut_params->op->sym->m_src = ut_params->ibuf;
14084 	if (oop)
14085 		ut_params->op->sym->m_dst = ut_params->obuf;
14086 
14087 	/* Process crypto operation */
14088 	if (oop == IN_PLACE &&
14089 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14090 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
14091 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14092 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14093 				ut_params->op, 0, 0, 0, 0);
14094 	else
14095 		TEST_ASSERT_NOT_NULL(
14096 			process_crypto_request(ts_params->valid_devs[0],
14097 			ut_params->op), "failed to process sym crypto op");
14098 
14099 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14100 			"crypto op processing failed");
14101 
14102 
14103 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
14104 			uint8_t *, prepend_len);
14105 	if (oop) {
14106 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14107 				uint8_t *, prepend_len);
14108 	}
14109 
14110 	if (fragsz_oop)
14111 		fragsz = fragsz_oop;
14112 
14113 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14114 			ciphertext,
14115 			tdata->ciphertext.data,
14116 			fragsz,
14117 			"Ciphertext data not as expected");
14118 
14119 	buf = ut_params->op->sym->m_src->next;
14120 	if (oop)
14121 		buf = ut_params->op->sym->m_dst->next;
14122 
14123 	unsigned int off = fragsz;
14124 
14125 	ecx = 0;
14126 	while (buf) {
14127 		ciphertext = rte_pktmbuf_mtod(buf,
14128 				uint8_t *);
14129 
14130 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
14131 				ciphertext,
14132 				tdata->ciphertext.data + off,
14133 				to_trn_tbl[ecx],
14134 				"Ciphertext data not as expected");
14135 
14136 		off += to_trn_tbl[ecx++];
14137 		buf = buf->next;
14138 	}
14139 
14140 	auth_tag = digest_mem;
14141 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
14142 			auth_tag,
14143 			tdata->auth_tag.data,
14144 			tdata->auth_tag.len,
14145 			"Generated auth tag not as expected");
14146 
14147 	return 0;
14148 }
14149 
14150 static int
14151 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
14152 {
14153 	return test_authenticated_encryption_SGL(
14154 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
14155 }
14156 
14157 static int
14158 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
14159 {
14160 	return test_authenticated_encryption_SGL(
14161 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
14162 }
14163 
14164 static int
14165 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
14166 {
14167 	return test_authenticated_encryption_SGL(
14168 			&gcm_test_case_8, OUT_OF_PLACE, 400,
14169 			gcm_test_case_8.plaintext.len);
14170 }
14171 
14172 static int
14173 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
14174 {
14175 	/* This test is not for OPENSSL PMD */
14176 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
14177 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
14178 		return TEST_SKIPPED;
14179 
14180 	return test_authenticated_encryption_SGL(
14181 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
14182 }
14183 
14184 static int
14185 test_authentication_verify_fail_when_data_corrupted(
14186 		struct crypto_testsuite_params *ts_params,
14187 		struct crypto_unittest_params *ut_params,
14188 		const struct test_crypto_vector *reference)
14189 {
14190 	return test_authentication_verify_fail_when_data_corruption(
14191 			ts_params, ut_params, reference, 1);
14192 }
14193 
14194 static int
14195 test_authentication_verify_fail_when_tag_corrupted(
14196 		struct crypto_testsuite_params *ts_params,
14197 		struct crypto_unittest_params *ut_params,
14198 		const struct test_crypto_vector *reference)
14199 {
14200 	return test_authentication_verify_fail_when_data_corruption(
14201 			ts_params, ut_params, reference, 0);
14202 }
14203 
14204 static int
14205 test_authentication_verify_GMAC_fail_when_data_corrupted(
14206 		struct crypto_testsuite_params *ts_params,
14207 		struct crypto_unittest_params *ut_params,
14208 		const struct test_crypto_vector *reference)
14209 {
14210 	return test_authentication_verify_GMAC_fail_when_corruption(
14211 			ts_params, ut_params, reference, 1);
14212 }
14213 
14214 static int
14215 test_authentication_verify_GMAC_fail_when_tag_corrupted(
14216 		struct crypto_testsuite_params *ts_params,
14217 		struct crypto_unittest_params *ut_params,
14218 		const struct test_crypto_vector *reference)
14219 {
14220 	return test_authentication_verify_GMAC_fail_when_corruption(
14221 			ts_params, ut_params, reference, 0);
14222 }
14223 
14224 static int
14225 test_authenticated_decryption_fail_when_data_corrupted(
14226 		struct crypto_testsuite_params *ts_params,
14227 		struct crypto_unittest_params *ut_params,
14228 		const struct test_crypto_vector *reference)
14229 {
14230 	return test_authenticated_decryption_fail_when_corruption(
14231 			ts_params, ut_params, reference, 1);
14232 }
14233 
14234 static int
14235 test_authenticated_decryption_fail_when_tag_corrupted(
14236 		struct crypto_testsuite_params *ts_params,
14237 		struct crypto_unittest_params *ut_params,
14238 		const struct test_crypto_vector *reference)
14239 {
14240 	return test_authenticated_decryption_fail_when_corruption(
14241 			ts_params, ut_params, reference, 0);
14242 }
14243 
14244 static int
14245 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14246 {
14247 	return test_authentication_verify_fail_when_data_corrupted(
14248 			&testsuite_params, &unittest_params,
14249 			&hmac_sha1_test_crypto_vector);
14250 }
14251 
14252 static int
14253 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14254 {
14255 	return test_authentication_verify_fail_when_tag_corrupted(
14256 			&testsuite_params, &unittest_params,
14257 			&hmac_sha1_test_crypto_vector);
14258 }
14259 
14260 static int
14261 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14262 {
14263 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
14264 			&testsuite_params, &unittest_params,
14265 			&aes128_gmac_test_vector);
14266 }
14267 
14268 static int
14269 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14270 {
14271 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14272 			&testsuite_params, &unittest_params,
14273 			&aes128_gmac_test_vector);
14274 }
14275 
14276 static int
14277 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14278 {
14279 	return test_authenticated_decryption_fail_when_data_corrupted(
14280 			&testsuite_params,
14281 			&unittest_params,
14282 			&aes128cbc_hmac_sha1_test_vector);
14283 }
14284 
14285 static int
14286 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14287 {
14288 	return test_authenticated_decryption_fail_when_tag_corrupted(
14289 			&testsuite_params,
14290 			&unittest_params,
14291 			&aes128cbc_hmac_sha1_test_vector);
14292 }
14293 
14294 static int
14295 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14296 {
14297 	return test_authenticated_encrypt_with_esn(
14298 			&testsuite_params,
14299 			&unittest_params,
14300 			&aes128cbc_hmac_sha1_aad_test_vector);
14301 }
14302 
14303 static int
14304 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14305 {
14306 	return test_authenticated_decrypt_with_esn(
14307 			&testsuite_params,
14308 			&unittest_params,
14309 			&aes128cbc_hmac_sha1_aad_test_vector);
14310 }
14311 
14312 static int
14313 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14314 {
14315 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14316 }
14317 
14318 static int
14319 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14320 {
14321 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14322 }
14323 
14324 static int
14325 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14326 {
14327 	return test_authenticated_encryption_SGL(
14328 		&chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14329 		chacha20_poly1305_case_2.plaintext.len);
14330 }
14331 
14332 #ifdef RTE_CRYPTO_SCHEDULER
14333 
14334 /* global AESNI worker IDs for the scheduler test */
14335 uint8_t aesni_ids[2];
14336 
14337 static int
14338 scheduler_testsuite_setup(void)
14339 {
14340 	uint32_t i = 0;
14341 	int32_t nb_devs, ret;
14342 	char vdev_args[VDEV_ARGS_SIZE] = {""};
14343 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14344 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
14345 	uint16_t worker_core_count = 0;
14346 	uint16_t socket_id = 0;
14347 
14348 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
14349 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14350 
14351 		/* Identify the Worker Cores
14352 		 * Use 2 worker cores for the device args
14353 		 */
14354 		RTE_LCORE_FOREACH_WORKER(i) {
14355 			if (worker_core_count > 1)
14356 				break;
14357 			snprintf(vdev_args, sizeof(vdev_args),
14358 					"%s%d", temp_str, i);
14359 			strcpy(temp_str, vdev_args);
14360 			strlcat(temp_str, ";", sizeof(temp_str));
14361 			worker_core_count++;
14362 			socket_id = rte_lcore_to_socket_id(i);
14363 		}
14364 		if (worker_core_count != 2) {
14365 			RTE_LOG(ERR, USER1,
14366 				"Cryptodev scheduler test require at least "
14367 				"two worker cores to run. "
14368 				"Please use the correct coremask.\n");
14369 			return TEST_FAILED;
14370 		}
14371 		strcpy(temp_str, vdev_args);
14372 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14373 				temp_str, socket_id);
14374 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14375 		nb_devs = rte_cryptodev_device_count_by_driver(
14376 				rte_cryptodev_driver_id_get(
14377 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14378 		if (nb_devs < 1) {
14379 			ret = rte_vdev_init(
14380 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14381 					vdev_args);
14382 			TEST_ASSERT(ret == 0,
14383 				"Failed to create instance %u of pmd : %s",
14384 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14385 		}
14386 	}
14387 	return testsuite_setup();
14388 }
14389 
14390 static int
14391 test_scheduler_attach_worker_op(void)
14392 {
14393 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14394 	uint8_t sched_id = ts_params->valid_devs[0];
14395 	uint32_t i, nb_devs_attached = 0;
14396 	int ret;
14397 	char vdev_name[32];
14398 	unsigned int count = rte_cryptodev_count();
14399 
14400 	/* create 2 AESNI_MB vdevs on top of existing devices */
14401 	for (i = count; i < count + 2; i++) {
14402 		snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14403 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14404 				i);
14405 		ret = rte_vdev_init(vdev_name, NULL);
14406 
14407 		TEST_ASSERT(ret == 0,
14408 			"Failed to create instance %u of"
14409 			" pmd : %s",
14410 			i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14411 
14412 		if (ret < 0) {
14413 			RTE_LOG(ERR, USER1,
14414 				"Failed to create 2 AESNI MB PMDs.\n");
14415 			return TEST_SKIPPED;
14416 		}
14417 	}
14418 
14419 	/* attach 2 AESNI_MB cdevs */
14420 	for (i = count; i < count + 2; i++) {
14421 		struct rte_cryptodev_info info;
14422 		unsigned int session_size;
14423 
14424 		rte_cryptodev_info_get(i, &info);
14425 		if (info.driver_id != rte_cryptodev_driver_id_get(
14426 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14427 			continue;
14428 
14429 		session_size = rte_cryptodev_sym_get_private_session_size(i);
14430 		/*
14431 		 * Create the session mempool again, since now there are new devices
14432 		 * to use the mempool.
14433 		 */
14434 		if (ts_params->session_mpool) {
14435 			rte_mempool_free(ts_params->session_mpool);
14436 			ts_params->session_mpool = NULL;
14437 		}
14438 		if (ts_params->session_priv_mpool) {
14439 			rte_mempool_free(ts_params->session_priv_mpool);
14440 			ts_params->session_priv_mpool = NULL;
14441 		}
14442 
14443 		if (info.sym.max_nb_sessions != 0 &&
14444 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14445 			RTE_LOG(ERR, USER1,
14446 					"Device does not support "
14447 					"at least %u sessions\n",
14448 					MAX_NB_SESSIONS);
14449 			return TEST_FAILED;
14450 		}
14451 		/*
14452 		 * Create mempool with maximum number of sessions,
14453 		 * to include the session headers
14454 		 */
14455 		if (ts_params->session_mpool == NULL) {
14456 			ts_params->session_mpool =
14457 				rte_cryptodev_sym_session_pool_create(
14458 						"test_sess_mp",
14459 						MAX_NB_SESSIONS, 0, 0, 0,
14460 						SOCKET_ID_ANY);
14461 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14462 					"session mempool allocation failed");
14463 		}
14464 
14465 		/*
14466 		 * Create mempool with maximum number of sessions,
14467 		 * to include device specific session private data
14468 		 */
14469 		if (ts_params->session_priv_mpool == NULL) {
14470 			ts_params->session_priv_mpool = rte_mempool_create(
14471 					"test_sess_mp_priv",
14472 					MAX_NB_SESSIONS,
14473 					session_size,
14474 					0, 0, NULL, NULL, NULL,
14475 					NULL, SOCKET_ID_ANY,
14476 					0);
14477 
14478 			TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14479 					"session mempool allocation failed");
14480 		}
14481 
14482 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
14483 		ts_params->qp_conf.mp_session_private =
14484 				ts_params->session_priv_mpool;
14485 
14486 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14487 				(uint8_t)i);
14488 
14489 		TEST_ASSERT(ret == 0,
14490 			"Failed to attach device %u of pmd : %s", i,
14491 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14492 
14493 		aesni_ids[nb_devs_attached] = (uint8_t)i;
14494 
14495 		nb_devs_attached++;
14496 	}
14497 
14498 	return 0;
14499 }
14500 
14501 static int
14502 test_scheduler_detach_worker_op(void)
14503 {
14504 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14505 	uint8_t sched_id = ts_params->valid_devs[0];
14506 	uint32_t i;
14507 	int ret;
14508 
14509 	for (i = 0; i < 2; i++) {
14510 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14511 				aesni_ids[i]);
14512 		TEST_ASSERT(ret == 0,
14513 			"Failed to detach device %u", aesni_ids[i]);
14514 	}
14515 
14516 	return 0;
14517 }
14518 
14519 static int
14520 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14521 {
14522 	struct crypto_testsuite_params *ts_params = &testsuite_params;
14523 	uint8_t sched_id = ts_params->valid_devs[0];
14524 	/* set mode */
14525 	return rte_cryptodev_scheduler_mode_set(sched_id,
14526 		scheduler_mode);
14527 }
14528 
14529 static int
14530 test_scheduler_mode_roundrobin_op(void)
14531 {
14532 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14533 			0, "Failed to set roundrobin mode");
14534 	return 0;
14535 
14536 }
14537 
14538 static int
14539 test_scheduler_mode_multicore_op(void)
14540 {
14541 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14542 			0, "Failed to set multicore mode");
14543 
14544 	return 0;
14545 }
14546 
14547 static int
14548 test_scheduler_mode_failover_op(void)
14549 {
14550 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14551 			0, "Failed to set failover mode");
14552 
14553 	return 0;
14554 }
14555 
14556 static int
14557 test_scheduler_mode_pkt_size_distr_op(void)
14558 {
14559 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14560 			0, "Failed to set pktsize mode");
14561 
14562 	return 0;
14563 }
14564 
14565 static int
14566 scheduler_multicore_testsuite_setup(void)
14567 {
14568 	if (test_scheduler_attach_worker_op() < 0)
14569 		return TEST_SKIPPED;
14570 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14571 		return TEST_SKIPPED;
14572 	return 0;
14573 }
14574 
14575 static int
14576 scheduler_roundrobin_testsuite_setup(void)
14577 {
14578 	if (test_scheduler_attach_worker_op() < 0)
14579 		return TEST_SKIPPED;
14580 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14581 		return TEST_SKIPPED;
14582 	return 0;
14583 }
14584 
14585 static int
14586 scheduler_failover_testsuite_setup(void)
14587 {
14588 	if (test_scheduler_attach_worker_op() < 0)
14589 		return TEST_SKIPPED;
14590 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14591 		return TEST_SKIPPED;
14592 	return 0;
14593 }
14594 
14595 static int
14596 scheduler_pkt_size_distr_testsuite_setup(void)
14597 {
14598 	if (test_scheduler_attach_worker_op() < 0)
14599 		return TEST_SKIPPED;
14600 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14601 		return TEST_SKIPPED;
14602 	return 0;
14603 }
14604 
14605 static void
14606 scheduler_mode_testsuite_teardown(void)
14607 {
14608 	test_scheduler_detach_worker_op();
14609 }
14610 
14611 #endif /* RTE_CRYPTO_SCHEDULER */
14612 
14613 static struct unit_test_suite end_testsuite = {
14614 	.suite_name = NULL,
14615 	.setup = NULL,
14616 	.teardown = NULL,
14617 	.unit_test_suites = NULL
14618 };
14619 
14620 #ifdef RTE_LIB_SECURITY
14621 static struct unit_test_suite ipsec_proto_testsuite  = {
14622 	.suite_name = "IPsec Proto Unit Test Suite",
14623 	.setup = ipsec_proto_testsuite_setup,
14624 	.unit_test_cases = {
14625 		TEST_CASE_NAMED_WITH_DATA(
14626 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14627 			ut_setup_security, ut_teardown,
14628 			test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14629 		TEST_CASE_NAMED_WITH_DATA(
14630 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14631 			ut_setup_security, ut_teardown,
14632 			test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14633 		TEST_CASE_NAMED_WITH_DATA(
14634 			"Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14635 			ut_setup_security, ut_teardown,
14636 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14637 		TEST_CASE_NAMED_WITH_DATA(
14638 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14639 			ut_setup_security, ut_teardown,
14640 			test_ipsec_proto_known_vec,
14641 			&pkt_aes_128_cbc_hmac_sha256),
14642 		TEST_CASE_NAMED_WITH_DATA(
14643 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14644 			ut_setup_security, ut_teardown,
14645 			test_ipsec_proto_known_vec,
14646 			&pkt_aes_128_cbc_hmac_sha384),
14647 		TEST_CASE_NAMED_WITH_DATA(
14648 			"Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14649 			ut_setup_security, ut_teardown,
14650 			test_ipsec_proto_known_vec,
14651 			&pkt_aes_128_cbc_hmac_sha512),
14652 		TEST_CASE_NAMED_WITH_DATA(
14653 			"Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14654 			ut_setup_security, ut_teardown,
14655 			test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
14656 		TEST_CASE_NAMED_WITH_DATA(
14657 			"Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14658 			ut_setup_security, ut_teardown,
14659 			test_ipsec_proto_known_vec,
14660 			&pkt_aes_128_cbc_hmac_sha256_v6),
14661 		TEST_CASE_NAMED_WITH_DATA(
14662 			"Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14663 			ut_setup_security, ut_teardown,
14664 			test_ipsec_proto_known_vec,
14665 			&pkt_null_aes_xcbc),
14666 		TEST_CASE_NAMED_WITH_DATA(
14667 			"Outbound fragmented packet",
14668 			ut_setup_security, ut_teardown,
14669 			test_ipsec_proto_known_vec_fragmented,
14670 			&pkt_aes_128_gcm_frag),
14671 		TEST_CASE_NAMED_WITH_DATA(
14672 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14673 			ut_setup_security, ut_teardown,
14674 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14675 		TEST_CASE_NAMED_WITH_DATA(
14676 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14677 			ut_setup_security, ut_teardown,
14678 			test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14679 		TEST_CASE_NAMED_WITH_DATA(
14680 			"Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14681 			ut_setup_security, ut_teardown,
14682 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14683 		TEST_CASE_NAMED_WITH_DATA(
14684 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
14685 			ut_setup_security, ut_teardown,
14686 			test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
14687 		TEST_CASE_NAMED_WITH_DATA(
14688 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14689 			ut_setup_security, ut_teardown,
14690 			test_ipsec_proto_known_vec_inb,
14691 			&pkt_aes_128_cbc_hmac_sha256),
14692 		TEST_CASE_NAMED_WITH_DATA(
14693 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14694 			ut_setup_security, ut_teardown,
14695 			test_ipsec_proto_known_vec_inb,
14696 			&pkt_aes_128_cbc_hmac_sha384),
14697 		TEST_CASE_NAMED_WITH_DATA(
14698 			"Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14699 			ut_setup_security, ut_teardown,
14700 			test_ipsec_proto_known_vec_inb,
14701 			&pkt_aes_128_cbc_hmac_sha512),
14702 		TEST_CASE_NAMED_WITH_DATA(
14703 			"Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14704 			ut_setup_security, ut_teardown,
14705 			test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
14706 		TEST_CASE_NAMED_WITH_DATA(
14707 			"Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14708 			ut_setup_security, ut_teardown,
14709 			test_ipsec_proto_known_vec_inb,
14710 			&pkt_aes_128_cbc_hmac_sha256_v6),
14711 		TEST_CASE_NAMED_WITH_DATA(
14712 			"Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14713 			ut_setup_security, ut_teardown,
14714 			test_ipsec_proto_known_vec_inb,
14715 			&pkt_null_aes_xcbc),
14716 		TEST_CASE_NAMED_ST(
14717 			"Combined test alg list",
14718 			ut_setup_security, ut_teardown,
14719 			test_ipsec_proto_display_list),
14720 		TEST_CASE_NAMED_ST(
14721 			"IV generation",
14722 			ut_setup_security, ut_teardown,
14723 			test_ipsec_proto_iv_gen),
14724 		TEST_CASE_NAMED_ST(
14725 			"UDP encapsulation",
14726 			ut_setup_security, ut_teardown,
14727 			test_ipsec_proto_udp_encap),
14728 		TEST_CASE_NAMED_ST(
14729 			"UDP encapsulation ports verification test",
14730 			ut_setup_security, ut_teardown,
14731 			test_ipsec_proto_udp_ports_verify),
14732 		TEST_CASE_NAMED_ST(
14733 			"SA expiry packets soft",
14734 			ut_setup_security, ut_teardown,
14735 			test_ipsec_proto_sa_exp_pkts_soft),
14736 		TEST_CASE_NAMED_ST(
14737 			"SA expiry packets hard",
14738 			ut_setup_security, ut_teardown,
14739 			test_ipsec_proto_sa_exp_pkts_hard),
14740 		TEST_CASE_NAMED_ST(
14741 			"Negative test: ICV corruption",
14742 			ut_setup_security, ut_teardown,
14743 			test_ipsec_proto_err_icv_corrupt),
14744 		TEST_CASE_NAMED_ST(
14745 			"Tunnel dst addr verification",
14746 			ut_setup_security, ut_teardown,
14747 			test_ipsec_proto_tunnel_dst_addr_verify),
14748 		TEST_CASE_NAMED_ST(
14749 			"Tunnel src and dst addr verification",
14750 			ut_setup_security, ut_teardown,
14751 			test_ipsec_proto_tunnel_src_dst_addr_verify),
14752 		TEST_CASE_NAMED_ST(
14753 			"Inner IP checksum",
14754 			ut_setup_security, ut_teardown,
14755 			test_ipsec_proto_inner_ip_csum),
14756 		TEST_CASE_NAMED_ST(
14757 			"Inner L4 checksum",
14758 			ut_setup_security, ut_teardown,
14759 			test_ipsec_proto_inner_l4_csum),
14760 		TEST_CASE_NAMED_ST(
14761 			"Tunnel IPv4 in IPv4",
14762 			ut_setup_security, ut_teardown,
14763 			test_ipsec_proto_tunnel_v4_in_v4),
14764 		TEST_CASE_NAMED_ST(
14765 			"Tunnel IPv6 in IPv6",
14766 			ut_setup_security, ut_teardown,
14767 			test_ipsec_proto_tunnel_v6_in_v6),
14768 		TEST_CASE_NAMED_ST(
14769 			"Tunnel IPv4 in IPv6",
14770 			ut_setup_security, ut_teardown,
14771 			test_ipsec_proto_tunnel_v4_in_v6),
14772 		TEST_CASE_NAMED_ST(
14773 			"Tunnel IPv6 in IPv4",
14774 			ut_setup_security, ut_teardown,
14775 			test_ipsec_proto_tunnel_v6_in_v4),
14776 		TEST_CASE_NAMED_ST(
14777 			"Transport IPv4",
14778 			ut_setup_security, ut_teardown,
14779 			test_ipsec_proto_transport_v4),
14780 		TEST_CASE_NAMED_ST(
14781 			"Statistics: success",
14782 			ut_setup_security, ut_teardown,
14783 			test_ipsec_proto_stats),
14784 		TEST_CASE_NAMED_ST(
14785 			"Fragmented packet",
14786 			ut_setup_security, ut_teardown,
14787 			test_ipsec_proto_pkt_fragment),
14788 		TEST_CASE_NAMED_ST(
14789 			"Tunnel header copy DF (inner 0)",
14790 			ut_setup_security, ut_teardown,
14791 			test_ipsec_proto_copy_df_inner_0),
14792 		TEST_CASE_NAMED_ST(
14793 			"Tunnel header copy DF (inner 1)",
14794 			ut_setup_security, ut_teardown,
14795 			test_ipsec_proto_copy_df_inner_1),
14796 		TEST_CASE_NAMED_ST(
14797 			"Tunnel header set DF 0 (inner 1)",
14798 			ut_setup_security, ut_teardown,
14799 			test_ipsec_proto_set_df_0_inner_1),
14800 		TEST_CASE_NAMED_ST(
14801 			"Tunnel header set DF 1 (inner 0)",
14802 			ut_setup_security, ut_teardown,
14803 			test_ipsec_proto_set_df_1_inner_0),
14804 		TEST_CASES_END() /**< NULL terminate unit test array */
14805 	}
14806 };
14807 
14808 static struct unit_test_suite pdcp_proto_testsuite  = {
14809 	.suite_name = "PDCP Proto Unit Test Suite",
14810 	.setup = pdcp_proto_testsuite_setup,
14811 	.unit_test_cases = {
14812 		TEST_CASE_ST(ut_setup_security, ut_teardown,
14813 			test_PDCP_PROTO_all),
14814 		TEST_CASES_END() /**< NULL terminate unit test array */
14815 	}
14816 };
14817 
14818 #define ADD_UPLINK_TESTCASE(data)						\
14819 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security,	\
14820 	ut_teardown, test_docsis_proto_uplink, (const void *) &data),		\
14821 
14822 #define ADD_DOWNLINK_TESTCASE(data)						\
14823 	TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security,	\
14824 	ut_teardown, test_docsis_proto_downlink, (const void *) &data),		\
14825 
14826 static struct unit_test_suite docsis_proto_testsuite  = {
14827 	.suite_name = "DOCSIS Proto Unit Test Suite",
14828 	.setup = docsis_proto_testsuite_setup,
14829 	.unit_test_cases = {
14830 		/* Uplink */
14831 		ADD_UPLINK_TESTCASE(docsis_test_case_1)
14832 		ADD_UPLINK_TESTCASE(docsis_test_case_2)
14833 		ADD_UPLINK_TESTCASE(docsis_test_case_3)
14834 		ADD_UPLINK_TESTCASE(docsis_test_case_4)
14835 		ADD_UPLINK_TESTCASE(docsis_test_case_5)
14836 		ADD_UPLINK_TESTCASE(docsis_test_case_6)
14837 		ADD_UPLINK_TESTCASE(docsis_test_case_7)
14838 		ADD_UPLINK_TESTCASE(docsis_test_case_8)
14839 		ADD_UPLINK_TESTCASE(docsis_test_case_9)
14840 		ADD_UPLINK_TESTCASE(docsis_test_case_10)
14841 		ADD_UPLINK_TESTCASE(docsis_test_case_11)
14842 		ADD_UPLINK_TESTCASE(docsis_test_case_12)
14843 		ADD_UPLINK_TESTCASE(docsis_test_case_13)
14844 		ADD_UPLINK_TESTCASE(docsis_test_case_14)
14845 		ADD_UPLINK_TESTCASE(docsis_test_case_15)
14846 		ADD_UPLINK_TESTCASE(docsis_test_case_16)
14847 		ADD_UPLINK_TESTCASE(docsis_test_case_17)
14848 		ADD_UPLINK_TESTCASE(docsis_test_case_18)
14849 		ADD_UPLINK_TESTCASE(docsis_test_case_19)
14850 		ADD_UPLINK_TESTCASE(docsis_test_case_20)
14851 		ADD_UPLINK_TESTCASE(docsis_test_case_21)
14852 		ADD_UPLINK_TESTCASE(docsis_test_case_22)
14853 		ADD_UPLINK_TESTCASE(docsis_test_case_23)
14854 		ADD_UPLINK_TESTCASE(docsis_test_case_24)
14855 		ADD_UPLINK_TESTCASE(docsis_test_case_25)
14856 		ADD_UPLINK_TESTCASE(docsis_test_case_26)
14857 		/* Downlink */
14858 		ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
14859 		ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
14860 		ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
14861 		ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
14862 		ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
14863 		ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
14864 		ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
14865 		ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
14866 		ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
14867 		ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
14868 		ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
14869 		ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
14870 		ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
14871 		ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
14872 		ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
14873 		ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
14874 		ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
14875 		ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
14876 		ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
14877 		ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
14878 		ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
14879 		ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
14880 		ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
14881 		ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
14882 		ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
14883 		ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
14884 		TEST_CASES_END() /**< NULL terminate unit test array */
14885 	}
14886 };
14887 #endif
14888 
14889 static struct unit_test_suite cryptodev_gen_testsuite  = {
14890 	.suite_name = "Crypto General Unit Test Suite",
14891 	.setup = crypto_gen_testsuite_setup,
14892 	.unit_test_cases = {
14893 		TEST_CASE_ST(ut_setup, ut_teardown,
14894 				test_device_configure_invalid_dev_id),
14895 		TEST_CASE_ST(ut_setup, ut_teardown,
14896 				test_queue_pair_descriptor_setup),
14897 		TEST_CASE_ST(ut_setup, ut_teardown,
14898 				test_device_configure_invalid_queue_pair_ids),
14899 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14900 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14901 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14902 		TEST_CASES_END() /**< NULL terminate unit test array */
14903 	}
14904 };
14905 
14906 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14907 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
14908 	.setup = negative_hmac_sha1_testsuite_setup,
14909 	.unit_test_cases = {
14910 		/** Negative tests */
14911 		TEST_CASE_ST(ut_setup, ut_teardown,
14912 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14913 		TEST_CASE_ST(ut_setup, ut_teardown,
14914 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14915 		TEST_CASE_ST(ut_setup, ut_teardown,
14916 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14917 		TEST_CASE_ST(ut_setup, ut_teardown,
14918 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14919 
14920 		TEST_CASES_END() /**< NULL terminate unit test array */
14921 	}
14922 };
14923 
14924 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14925 	.suite_name = "Multi Session Unit Test Suite",
14926 	.setup = multi_session_testsuite_setup,
14927 	.unit_test_cases = {
14928 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14929 		TEST_CASE_ST(ut_setup, ut_teardown,
14930 				test_multi_session_random_usage),
14931 
14932 		TEST_CASES_END() /**< NULL terminate unit test array */
14933 	}
14934 };
14935 
14936 static struct unit_test_suite cryptodev_null_testsuite  = {
14937 	.suite_name = "NULL Test Suite",
14938 	.setup = null_testsuite_setup,
14939 	.unit_test_cases = {
14940 		TEST_CASE_ST(ut_setup, ut_teardown,
14941 			test_null_invalid_operation),
14942 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14943 		TEST_CASES_END()
14944 	}
14945 };
14946 
14947 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
14948 	.suite_name = "AES CCM Authenticated Test Suite",
14949 	.setup = aes_ccm_auth_testsuite_setup,
14950 	.unit_test_cases = {
14951 		/** AES CCM Authenticated Encryption 128 bits key*/
14952 		TEST_CASE_ST(ut_setup, ut_teardown,
14953 			test_AES_CCM_authenticated_encryption_test_case_128_1),
14954 		TEST_CASE_ST(ut_setup, ut_teardown,
14955 			test_AES_CCM_authenticated_encryption_test_case_128_2),
14956 		TEST_CASE_ST(ut_setup, ut_teardown,
14957 			test_AES_CCM_authenticated_encryption_test_case_128_3),
14958 
14959 		/** AES CCM Authenticated Decryption 128 bits key*/
14960 		TEST_CASE_ST(ut_setup, ut_teardown,
14961 			test_AES_CCM_authenticated_decryption_test_case_128_1),
14962 		TEST_CASE_ST(ut_setup, ut_teardown,
14963 			test_AES_CCM_authenticated_decryption_test_case_128_2),
14964 		TEST_CASE_ST(ut_setup, ut_teardown,
14965 			test_AES_CCM_authenticated_decryption_test_case_128_3),
14966 
14967 		/** AES CCM Authenticated Encryption 192 bits key */
14968 		TEST_CASE_ST(ut_setup, ut_teardown,
14969 			test_AES_CCM_authenticated_encryption_test_case_192_1),
14970 		TEST_CASE_ST(ut_setup, ut_teardown,
14971 			test_AES_CCM_authenticated_encryption_test_case_192_2),
14972 		TEST_CASE_ST(ut_setup, ut_teardown,
14973 			test_AES_CCM_authenticated_encryption_test_case_192_3),
14974 
14975 		/** AES CCM Authenticated Decryption 192 bits key*/
14976 		TEST_CASE_ST(ut_setup, ut_teardown,
14977 			test_AES_CCM_authenticated_decryption_test_case_192_1),
14978 		TEST_CASE_ST(ut_setup, ut_teardown,
14979 			test_AES_CCM_authenticated_decryption_test_case_192_2),
14980 		TEST_CASE_ST(ut_setup, ut_teardown,
14981 			test_AES_CCM_authenticated_decryption_test_case_192_3),
14982 
14983 		/** AES CCM Authenticated Encryption 256 bits key */
14984 		TEST_CASE_ST(ut_setup, ut_teardown,
14985 			test_AES_CCM_authenticated_encryption_test_case_256_1),
14986 		TEST_CASE_ST(ut_setup, ut_teardown,
14987 			test_AES_CCM_authenticated_encryption_test_case_256_2),
14988 		TEST_CASE_ST(ut_setup, ut_teardown,
14989 			test_AES_CCM_authenticated_encryption_test_case_256_3),
14990 
14991 		/** AES CCM Authenticated Decryption 256 bits key*/
14992 		TEST_CASE_ST(ut_setup, ut_teardown,
14993 			test_AES_CCM_authenticated_decryption_test_case_256_1),
14994 		TEST_CASE_ST(ut_setup, ut_teardown,
14995 			test_AES_CCM_authenticated_decryption_test_case_256_2),
14996 		TEST_CASE_ST(ut_setup, ut_teardown,
14997 			test_AES_CCM_authenticated_decryption_test_case_256_3),
14998 		TEST_CASES_END()
14999 	}
15000 };
15001 
15002 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
15003 	.suite_name = "AES GCM Authenticated Test Suite",
15004 	.setup = aes_gcm_auth_testsuite_setup,
15005 	.unit_test_cases = {
15006 		/** AES GCM Authenticated Encryption */
15007 		TEST_CASE_ST(ut_setup, ut_teardown,
15008 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
15009 		TEST_CASE_ST(ut_setup, ut_teardown,
15010 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
15011 		TEST_CASE_ST(ut_setup, ut_teardown,
15012 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
15013 		TEST_CASE_ST(ut_setup, ut_teardown,
15014 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
15015 		TEST_CASE_ST(ut_setup, ut_teardown,
15016 			test_AES_GCM_authenticated_encryption_test_case_1),
15017 		TEST_CASE_ST(ut_setup, ut_teardown,
15018 			test_AES_GCM_authenticated_encryption_test_case_2),
15019 		TEST_CASE_ST(ut_setup, ut_teardown,
15020 			test_AES_GCM_authenticated_encryption_test_case_3),
15021 		TEST_CASE_ST(ut_setup, ut_teardown,
15022 			test_AES_GCM_authenticated_encryption_test_case_4),
15023 		TEST_CASE_ST(ut_setup, ut_teardown,
15024 			test_AES_GCM_authenticated_encryption_test_case_5),
15025 		TEST_CASE_ST(ut_setup, ut_teardown,
15026 			test_AES_GCM_authenticated_encryption_test_case_6),
15027 		TEST_CASE_ST(ut_setup, ut_teardown,
15028 			test_AES_GCM_authenticated_encryption_test_case_7),
15029 		TEST_CASE_ST(ut_setup, ut_teardown,
15030 			test_AES_GCM_authenticated_encryption_test_case_8),
15031 		TEST_CASE_ST(ut_setup, ut_teardown,
15032 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
15033 
15034 		/** AES GCM Authenticated Decryption */
15035 		TEST_CASE_ST(ut_setup, ut_teardown,
15036 			test_AES_GCM_authenticated_decryption_test_case_1),
15037 		TEST_CASE_ST(ut_setup, ut_teardown,
15038 			test_AES_GCM_authenticated_decryption_test_case_2),
15039 		TEST_CASE_ST(ut_setup, ut_teardown,
15040 			test_AES_GCM_authenticated_decryption_test_case_3),
15041 		TEST_CASE_ST(ut_setup, ut_teardown,
15042 			test_AES_GCM_authenticated_decryption_test_case_4),
15043 		TEST_CASE_ST(ut_setup, ut_teardown,
15044 			test_AES_GCM_authenticated_decryption_test_case_5),
15045 		TEST_CASE_ST(ut_setup, ut_teardown,
15046 			test_AES_GCM_authenticated_decryption_test_case_6),
15047 		TEST_CASE_ST(ut_setup, ut_teardown,
15048 			test_AES_GCM_authenticated_decryption_test_case_7),
15049 		TEST_CASE_ST(ut_setup, ut_teardown,
15050 			test_AES_GCM_authenticated_decryption_test_case_8),
15051 		TEST_CASE_ST(ut_setup, ut_teardown,
15052 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
15053 
15054 		/** AES GCM Authenticated Encryption 192 bits key */
15055 		TEST_CASE_ST(ut_setup, ut_teardown,
15056 			test_AES_GCM_auth_encryption_test_case_192_1),
15057 		TEST_CASE_ST(ut_setup, ut_teardown,
15058 			test_AES_GCM_auth_encryption_test_case_192_2),
15059 		TEST_CASE_ST(ut_setup, ut_teardown,
15060 			test_AES_GCM_auth_encryption_test_case_192_3),
15061 		TEST_CASE_ST(ut_setup, ut_teardown,
15062 			test_AES_GCM_auth_encryption_test_case_192_4),
15063 		TEST_CASE_ST(ut_setup, ut_teardown,
15064 			test_AES_GCM_auth_encryption_test_case_192_5),
15065 		TEST_CASE_ST(ut_setup, ut_teardown,
15066 			test_AES_GCM_auth_encryption_test_case_192_6),
15067 		TEST_CASE_ST(ut_setup, ut_teardown,
15068 			test_AES_GCM_auth_encryption_test_case_192_7),
15069 
15070 		/** AES GCM Authenticated Decryption 192 bits key */
15071 		TEST_CASE_ST(ut_setup, ut_teardown,
15072 			test_AES_GCM_auth_decryption_test_case_192_1),
15073 		TEST_CASE_ST(ut_setup, ut_teardown,
15074 			test_AES_GCM_auth_decryption_test_case_192_2),
15075 		TEST_CASE_ST(ut_setup, ut_teardown,
15076 			test_AES_GCM_auth_decryption_test_case_192_3),
15077 		TEST_CASE_ST(ut_setup, ut_teardown,
15078 			test_AES_GCM_auth_decryption_test_case_192_4),
15079 		TEST_CASE_ST(ut_setup, ut_teardown,
15080 			test_AES_GCM_auth_decryption_test_case_192_5),
15081 		TEST_CASE_ST(ut_setup, ut_teardown,
15082 			test_AES_GCM_auth_decryption_test_case_192_6),
15083 		TEST_CASE_ST(ut_setup, ut_teardown,
15084 			test_AES_GCM_auth_decryption_test_case_192_7),
15085 
15086 		/** AES GCM Authenticated Encryption 256 bits key */
15087 		TEST_CASE_ST(ut_setup, ut_teardown,
15088 			test_AES_GCM_auth_encryption_test_case_256_1),
15089 		TEST_CASE_ST(ut_setup, ut_teardown,
15090 			test_AES_GCM_auth_encryption_test_case_256_2),
15091 		TEST_CASE_ST(ut_setup, ut_teardown,
15092 			test_AES_GCM_auth_encryption_test_case_256_3),
15093 		TEST_CASE_ST(ut_setup, ut_teardown,
15094 			test_AES_GCM_auth_encryption_test_case_256_4),
15095 		TEST_CASE_ST(ut_setup, ut_teardown,
15096 			test_AES_GCM_auth_encryption_test_case_256_5),
15097 		TEST_CASE_ST(ut_setup, ut_teardown,
15098 			test_AES_GCM_auth_encryption_test_case_256_6),
15099 		TEST_CASE_ST(ut_setup, ut_teardown,
15100 			test_AES_GCM_auth_encryption_test_case_256_7),
15101 
15102 		/** AES GCM Authenticated Decryption 256 bits key */
15103 		TEST_CASE_ST(ut_setup, ut_teardown,
15104 			test_AES_GCM_auth_decryption_test_case_256_1),
15105 		TEST_CASE_ST(ut_setup, ut_teardown,
15106 			test_AES_GCM_auth_decryption_test_case_256_2),
15107 		TEST_CASE_ST(ut_setup, ut_teardown,
15108 			test_AES_GCM_auth_decryption_test_case_256_3),
15109 		TEST_CASE_ST(ut_setup, ut_teardown,
15110 			test_AES_GCM_auth_decryption_test_case_256_4),
15111 		TEST_CASE_ST(ut_setup, ut_teardown,
15112 			test_AES_GCM_auth_decryption_test_case_256_5),
15113 		TEST_CASE_ST(ut_setup, ut_teardown,
15114 			test_AES_GCM_auth_decryption_test_case_256_6),
15115 		TEST_CASE_ST(ut_setup, ut_teardown,
15116 			test_AES_GCM_auth_decryption_test_case_256_7),
15117 
15118 		/** AES GCM Authenticated Encryption big aad size */
15119 		TEST_CASE_ST(ut_setup, ut_teardown,
15120 			test_AES_GCM_auth_encryption_test_case_aad_1),
15121 		TEST_CASE_ST(ut_setup, ut_teardown,
15122 			test_AES_GCM_auth_encryption_test_case_aad_2),
15123 
15124 		/** AES GCM Authenticated Decryption big aad size */
15125 		TEST_CASE_ST(ut_setup, ut_teardown,
15126 			test_AES_GCM_auth_decryption_test_case_aad_1),
15127 		TEST_CASE_ST(ut_setup, ut_teardown,
15128 			test_AES_GCM_auth_decryption_test_case_aad_2),
15129 
15130 		/** Out of place tests */
15131 		TEST_CASE_ST(ut_setup, ut_teardown,
15132 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
15133 		TEST_CASE_ST(ut_setup, ut_teardown,
15134 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
15135 
15136 		/** Session-less tests */
15137 		TEST_CASE_ST(ut_setup, ut_teardown,
15138 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
15139 		TEST_CASE_ST(ut_setup, ut_teardown,
15140 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
15141 
15142 		TEST_CASES_END()
15143 	}
15144 };
15145 
15146 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
15147 	.suite_name = "AES GMAC Authentication Test Suite",
15148 	.setup = aes_gmac_auth_testsuite_setup,
15149 	.unit_test_cases = {
15150 		TEST_CASE_ST(ut_setup, ut_teardown,
15151 			test_AES_GMAC_authentication_test_case_1),
15152 		TEST_CASE_ST(ut_setup, ut_teardown,
15153 			test_AES_GMAC_authentication_verify_test_case_1),
15154 		TEST_CASE_ST(ut_setup, ut_teardown,
15155 			test_AES_GMAC_authentication_test_case_2),
15156 		TEST_CASE_ST(ut_setup, ut_teardown,
15157 			test_AES_GMAC_authentication_verify_test_case_2),
15158 		TEST_CASE_ST(ut_setup, ut_teardown,
15159 			test_AES_GMAC_authentication_test_case_3),
15160 		TEST_CASE_ST(ut_setup, ut_teardown,
15161 			test_AES_GMAC_authentication_verify_test_case_3),
15162 		TEST_CASE_ST(ut_setup, ut_teardown,
15163 			test_AES_GMAC_authentication_test_case_4),
15164 		TEST_CASE_ST(ut_setup, ut_teardown,
15165 			test_AES_GMAC_authentication_verify_test_case_4),
15166 		TEST_CASE_ST(ut_setup, ut_teardown,
15167 			test_AES_GMAC_authentication_SGL_40B),
15168 		TEST_CASE_ST(ut_setup, ut_teardown,
15169 			test_AES_GMAC_authentication_SGL_80B),
15170 		TEST_CASE_ST(ut_setup, ut_teardown,
15171 			test_AES_GMAC_authentication_SGL_2048B),
15172 		TEST_CASE_ST(ut_setup, ut_teardown,
15173 			test_AES_GMAC_authentication_SGL_2047B),
15174 
15175 		TEST_CASES_END()
15176 	}
15177 };
15178 
15179 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
15180 	.suite_name = "Chacha20-Poly1305 Test Suite",
15181 	.setup = chacha20_poly1305_testsuite_setup,
15182 	.unit_test_cases = {
15183 		TEST_CASE_ST(ut_setup, ut_teardown,
15184 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
15185 		TEST_CASE_ST(ut_setup, ut_teardown,
15186 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
15187 		TEST_CASE_ST(ut_setup, ut_teardown,
15188 			test_chacha20_poly1305_encrypt_SGL_out_of_place),
15189 		TEST_CASES_END()
15190 	}
15191 };
15192 
15193 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
15194 	.suite_name = "SNOW 3G Test Suite",
15195 	.setup = snow3g_testsuite_setup,
15196 	.unit_test_cases = {
15197 		/** SNOW 3G encrypt only (UEA2) */
15198 		TEST_CASE_ST(ut_setup, ut_teardown,
15199 			test_snow3g_encryption_test_case_1),
15200 		TEST_CASE_ST(ut_setup, ut_teardown,
15201 			test_snow3g_encryption_test_case_2),
15202 		TEST_CASE_ST(ut_setup, ut_teardown,
15203 			test_snow3g_encryption_test_case_3),
15204 		TEST_CASE_ST(ut_setup, ut_teardown,
15205 			test_snow3g_encryption_test_case_4),
15206 		TEST_CASE_ST(ut_setup, ut_teardown,
15207 			test_snow3g_encryption_test_case_5),
15208 
15209 		TEST_CASE_ST(ut_setup, ut_teardown,
15210 			test_snow3g_encryption_test_case_1_oop),
15211 		TEST_CASE_ST(ut_setup, ut_teardown,
15212 			test_snow3g_encryption_test_case_1_oop_sgl),
15213 		TEST_CASE_ST(ut_setup, ut_teardown,
15214 			test_snow3g_encryption_test_case_1_offset_oop),
15215 		TEST_CASE_ST(ut_setup, ut_teardown,
15216 			test_snow3g_decryption_test_case_1_oop),
15217 
15218 		/** SNOW 3G generate auth, then encrypt (UEA2) */
15219 		TEST_CASE_ST(ut_setup, ut_teardown,
15220 			test_snow3g_auth_cipher_test_case_1),
15221 		TEST_CASE_ST(ut_setup, ut_teardown,
15222 			test_snow3g_auth_cipher_test_case_2),
15223 		TEST_CASE_ST(ut_setup, ut_teardown,
15224 			test_snow3g_auth_cipher_test_case_2_oop),
15225 		TEST_CASE_ST(ut_setup, ut_teardown,
15226 			test_snow3g_auth_cipher_part_digest_enc),
15227 		TEST_CASE_ST(ut_setup, ut_teardown,
15228 			test_snow3g_auth_cipher_part_digest_enc_oop),
15229 		TEST_CASE_ST(ut_setup, ut_teardown,
15230 			test_snow3g_auth_cipher_test_case_3_sgl),
15231 		TEST_CASE_ST(ut_setup, ut_teardown,
15232 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
15233 		TEST_CASE_ST(ut_setup, ut_teardown,
15234 			test_snow3g_auth_cipher_part_digest_enc_sgl),
15235 		TEST_CASE_ST(ut_setup, ut_teardown,
15236 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
15237 
15238 		/** SNOW 3G decrypt (UEA2), then verify auth */
15239 		TEST_CASE_ST(ut_setup, ut_teardown,
15240 			test_snow3g_auth_cipher_verify_test_case_1),
15241 		TEST_CASE_ST(ut_setup, ut_teardown,
15242 			test_snow3g_auth_cipher_verify_test_case_2),
15243 		TEST_CASE_ST(ut_setup, ut_teardown,
15244 			test_snow3g_auth_cipher_verify_test_case_2_oop),
15245 		TEST_CASE_ST(ut_setup, ut_teardown,
15246 			test_snow3g_auth_cipher_verify_part_digest_enc),
15247 		TEST_CASE_ST(ut_setup, ut_teardown,
15248 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
15249 		TEST_CASE_ST(ut_setup, ut_teardown,
15250 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
15251 		TEST_CASE_ST(ut_setup, ut_teardown,
15252 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
15253 		TEST_CASE_ST(ut_setup, ut_teardown,
15254 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
15255 		TEST_CASE_ST(ut_setup, ut_teardown,
15256 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
15257 
15258 		/** SNOW 3G decrypt only (UEA2) */
15259 		TEST_CASE_ST(ut_setup, ut_teardown,
15260 			test_snow3g_decryption_test_case_1),
15261 		TEST_CASE_ST(ut_setup, ut_teardown,
15262 			test_snow3g_decryption_test_case_2),
15263 		TEST_CASE_ST(ut_setup, ut_teardown,
15264 			test_snow3g_decryption_test_case_3),
15265 		TEST_CASE_ST(ut_setup, ut_teardown,
15266 			test_snow3g_decryption_test_case_4),
15267 		TEST_CASE_ST(ut_setup, ut_teardown,
15268 			test_snow3g_decryption_test_case_5),
15269 		TEST_CASE_ST(ut_setup, ut_teardown,
15270 			test_snow3g_decryption_with_digest_test_case_1),
15271 		TEST_CASE_ST(ut_setup, ut_teardown,
15272 			test_snow3g_hash_generate_test_case_1),
15273 		TEST_CASE_ST(ut_setup, ut_teardown,
15274 			test_snow3g_hash_generate_test_case_2),
15275 		TEST_CASE_ST(ut_setup, ut_teardown,
15276 			test_snow3g_hash_generate_test_case_3),
15277 
15278 		/* Tests with buffers which length is not byte-aligned */
15279 		TEST_CASE_ST(ut_setup, ut_teardown,
15280 			test_snow3g_hash_generate_test_case_4),
15281 		TEST_CASE_ST(ut_setup, ut_teardown,
15282 			test_snow3g_hash_generate_test_case_5),
15283 		TEST_CASE_ST(ut_setup, ut_teardown,
15284 			test_snow3g_hash_generate_test_case_6),
15285 		TEST_CASE_ST(ut_setup, ut_teardown,
15286 			test_snow3g_hash_verify_test_case_1),
15287 		TEST_CASE_ST(ut_setup, ut_teardown,
15288 			test_snow3g_hash_verify_test_case_2),
15289 		TEST_CASE_ST(ut_setup, ut_teardown,
15290 			test_snow3g_hash_verify_test_case_3),
15291 
15292 		/* Tests with buffers which length is not byte-aligned */
15293 		TEST_CASE_ST(ut_setup, ut_teardown,
15294 			test_snow3g_hash_verify_test_case_4),
15295 		TEST_CASE_ST(ut_setup, ut_teardown,
15296 			test_snow3g_hash_verify_test_case_5),
15297 		TEST_CASE_ST(ut_setup, ut_teardown,
15298 			test_snow3g_hash_verify_test_case_6),
15299 		TEST_CASE_ST(ut_setup, ut_teardown,
15300 			test_snow3g_cipher_auth_test_case_1),
15301 		TEST_CASE_ST(ut_setup, ut_teardown,
15302 			test_snow3g_auth_cipher_with_digest_test_case_1),
15303 		TEST_CASES_END()
15304 	}
15305 };
15306 
15307 static struct unit_test_suite cryptodev_zuc_testsuite  = {
15308 	.suite_name = "ZUC Test Suite",
15309 	.setup = zuc_testsuite_setup,
15310 	.unit_test_cases = {
15311 		/** ZUC encrypt only (EEA3) */
15312 		TEST_CASE_ST(ut_setup, ut_teardown,
15313 			test_zuc_encryption_test_case_1),
15314 		TEST_CASE_ST(ut_setup, ut_teardown,
15315 			test_zuc_encryption_test_case_2),
15316 		TEST_CASE_ST(ut_setup, ut_teardown,
15317 			test_zuc_encryption_test_case_3),
15318 		TEST_CASE_ST(ut_setup, ut_teardown,
15319 			test_zuc_encryption_test_case_4),
15320 		TEST_CASE_ST(ut_setup, ut_teardown,
15321 			test_zuc_encryption_test_case_5),
15322 		TEST_CASE_ST(ut_setup, ut_teardown,
15323 			test_zuc_encryption_test_case_6_sgl),
15324 
15325 		/** ZUC authenticate (EIA3) */
15326 		TEST_CASE_ST(ut_setup, ut_teardown,
15327 			test_zuc_hash_generate_test_case_1),
15328 		TEST_CASE_ST(ut_setup, ut_teardown,
15329 			test_zuc_hash_generate_test_case_2),
15330 		TEST_CASE_ST(ut_setup, ut_teardown,
15331 			test_zuc_hash_generate_test_case_3),
15332 		TEST_CASE_ST(ut_setup, ut_teardown,
15333 			test_zuc_hash_generate_test_case_4),
15334 		TEST_CASE_ST(ut_setup, ut_teardown,
15335 			test_zuc_hash_generate_test_case_5),
15336 		TEST_CASE_ST(ut_setup, ut_teardown,
15337 			test_zuc_hash_generate_test_case_6),
15338 		TEST_CASE_ST(ut_setup, ut_teardown,
15339 			test_zuc_hash_generate_test_case_7),
15340 		TEST_CASE_ST(ut_setup, ut_teardown,
15341 			test_zuc_hash_generate_test_case_8),
15342 		TEST_CASE_ST(ut_setup, ut_teardown,
15343 			test_zuc_hash_generate_test_case_9),
15344 		TEST_CASE_ST(ut_setup, ut_teardown,
15345 			test_zuc_hash_generate_test_case_10),
15346 		TEST_CASE_ST(ut_setup, ut_teardown,
15347 			test_zuc_hash_generate_test_case_11),
15348 
15349 
15350 		/** ZUC alg-chain (EEA3/EIA3) */
15351 		TEST_CASE_ST(ut_setup, ut_teardown,
15352 			test_zuc_cipher_auth_test_case_1),
15353 		TEST_CASE_ST(ut_setup, ut_teardown,
15354 			test_zuc_cipher_auth_test_case_2),
15355 
15356 		/** ZUC generate auth, then encrypt (EEA3) */
15357 		TEST_CASE_ST(ut_setup, ut_teardown,
15358 			test_zuc_auth_cipher_test_case_1),
15359 		TEST_CASE_ST(ut_setup, ut_teardown,
15360 			test_zuc_auth_cipher_test_case_1_oop),
15361 		TEST_CASE_ST(ut_setup, ut_teardown,
15362 			test_zuc_auth_cipher_test_case_1_sgl),
15363 		TEST_CASE_ST(ut_setup, ut_teardown,
15364 			test_zuc_auth_cipher_test_case_1_oop_sgl),
15365 
15366 		/** ZUC decrypt (EEA3), then verify auth */
15367 		TEST_CASE_ST(ut_setup, ut_teardown,
15368 			test_zuc_auth_cipher_verify_test_case_1),
15369 		TEST_CASE_ST(ut_setup, ut_teardown,
15370 			test_zuc_auth_cipher_verify_test_case_1_oop),
15371 		TEST_CASE_ST(ut_setup, ut_teardown,
15372 			test_zuc_auth_cipher_verify_test_case_1_sgl),
15373 		TEST_CASE_ST(ut_setup, ut_teardown,
15374 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
15375 
15376 		/** ZUC-256 encrypt only **/
15377 		TEST_CASE_ST(ut_setup, ut_teardown,
15378 			test_zuc256_encryption_test_case_1),
15379 		TEST_CASE_ST(ut_setup, ut_teardown,
15380 			test_zuc256_encryption_test_case_2),
15381 
15382 		/** ZUC-256 authentication only **/
15383 		TEST_CASE_ST(ut_setup, ut_teardown,
15384 			test_zuc256_authentication_test_case_1),
15385 		TEST_CASE_ST(ut_setup, ut_teardown,
15386 			test_zuc256_authentication_test_case_2),
15387 
15388 		TEST_CASES_END()
15389 	}
15390 };
15391 
15392 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
15393 	.suite_name = "HMAC_MD5 Authentication Test Suite",
15394 	.setup = hmac_md5_auth_testsuite_setup,
15395 	.unit_test_cases = {
15396 		TEST_CASE_ST(ut_setup, ut_teardown,
15397 			test_MD5_HMAC_generate_case_1),
15398 		TEST_CASE_ST(ut_setup, ut_teardown,
15399 			test_MD5_HMAC_verify_case_1),
15400 		TEST_CASE_ST(ut_setup, ut_teardown,
15401 			test_MD5_HMAC_generate_case_2),
15402 		TEST_CASE_ST(ut_setup, ut_teardown,
15403 			test_MD5_HMAC_verify_case_2),
15404 		TEST_CASES_END()
15405 	}
15406 };
15407 
15408 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
15409 	.suite_name = "Kasumi Test Suite",
15410 	.setup = kasumi_testsuite_setup,
15411 	.unit_test_cases = {
15412 		/** KASUMI hash only (UIA1) */
15413 		TEST_CASE_ST(ut_setup, ut_teardown,
15414 			test_kasumi_hash_generate_test_case_1),
15415 		TEST_CASE_ST(ut_setup, ut_teardown,
15416 			test_kasumi_hash_generate_test_case_2),
15417 		TEST_CASE_ST(ut_setup, ut_teardown,
15418 			test_kasumi_hash_generate_test_case_3),
15419 		TEST_CASE_ST(ut_setup, ut_teardown,
15420 			test_kasumi_hash_generate_test_case_4),
15421 		TEST_CASE_ST(ut_setup, ut_teardown,
15422 			test_kasumi_hash_generate_test_case_5),
15423 		TEST_CASE_ST(ut_setup, ut_teardown,
15424 			test_kasumi_hash_generate_test_case_6),
15425 
15426 		TEST_CASE_ST(ut_setup, ut_teardown,
15427 			test_kasumi_hash_verify_test_case_1),
15428 		TEST_CASE_ST(ut_setup, ut_teardown,
15429 			test_kasumi_hash_verify_test_case_2),
15430 		TEST_CASE_ST(ut_setup, ut_teardown,
15431 			test_kasumi_hash_verify_test_case_3),
15432 		TEST_CASE_ST(ut_setup, ut_teardown,
15433 			test_kasumi_hash_verify_test_case_4),
15434 		TEST_CASE_ST(ut_setup, ut_teardown,
15435 			test_kasumi_hash_verify_test_case_5),
15436 
15437 		/** KASUMI encrypt only (UEA1) */
15438 		TEST_CASE_ST(ut_setup, ut_teardown,
15439 			test_kasumi_encryption_test_case_1),
15440 		TEST_CASE_ST(ut_setup, ut_teardown,
15441 			test_kasumi_encryption_test_case_1_sgl),
15442 		TEST_CASE_ST(ut_setup, ut_teardown,
15443 			test_kasumi_encryption_test_case_1_oop),
15444 		TEST_CASE_ST(ut_setup, ut_teardown,
15445 			test_kasumi_encryption_test_case_1_oop_sgl),
15446 		TEST_CASE_ST(ut_setup, ut_teardown,
15447 			test_kasumi_encryption_test_case_2),
15448 		TEST_CASE_ST(ut_setup, ut_teardown,
15449 			test_kasumi_encryption_test_case_3),
15450 		TEST_CASE_ST(ut_setup, ut_teardown,
15451 			test_kasumi_encryption_test_case_4),
15452 		TEST_CASE_ST(ut_setup, ut_teardown,
15453 			test_kasumi_encryption_test_case_5),
15454 
15455 		/** KASUMI decrypt only (UEA1) */
15456 		TEST_CASE_ST(ut_setup, ut_teardown,
15457 			test_kasumi_decryption_test_case_1),
15458 		TEST_CASE_ST(ut_setup, ut_teardown,
15459 			test_kasumi_decryption_test_case_2),
15460 		TEST_CASE_ST(ut_setup, ut_teardown,
15461 			test_kasumi_decryption_test_case_3),
15462 		TEST_CASE_ST(ut_setup, ut_teardown,
15463 			test_kasumi_decryption_test_case_4),
15464 		TEST_CASE_ST(ut_setup, ut_teardown,
15465 			test_kasumi_decryption_test_case_5),
15466 		TEST_CASE_ST(ut_setup, ut_teardown,
15467 			test_kasumi_decryption_test_case_1_oop),
15468 		TEST_CASE_ST(ut_setup, ut_teardown,
15469 			test_kasumi_cipher_auth_test_case_1),
15470 
15471 		/** KASUMI generate auth, then encrypt (F8) */
15472 		TEST_CASE_ST(ut_setup, ut_teardown,
15473 			test_kasumi_auth_cipher_test_case_1),
15474 		TEST_CASE_ST(ut_setup, ut_teardown,
15475 			test_kasumi_auth_cipher_test_case_2),
15476 		TEST_CASE_ST(ut_setup, ut_teardown,
15477 			test_kasumi_auth_cipher_test_case_2_oop),
15478 		TEST_CASE_ST(ut_setup, ut_teardown,
15479 			test_kasumi_auth_cipher_test_case_2_sgl),
15480 		TEST_CASE_ST(ut_setup, ut_teardown,
15481 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
15482 
15483 		/** KASUMI decrypt (F8), then verify auth */
15484 		TEST_CASE_ST(ut_setup, ut_teardown,
15485 			test_kasumi_auth_cipher_verify_test_case_1),
15486 		TEST_CASE_ST(ut_setup, ut_teardown,
15487 			test_kasumi_auth_cipher_verify_test_case_2),
15488 		TEST_CASE_ST(ut_setup, ut_teardown,
15489 			test_kasumi_auth_cipher_verify_test_case_2_oop),
15490 		TEST_CASE_ST(ut_setup, ut_teardown,
15491 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
15492 		TEST_CASE_ST(ut_setup, ut_teardown,
15493 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
15494 
15495 		TEST_CASES_END()
15496 	}
15497 };
15498 
15499 static struct unit_test_suite cryptodev_esn_testsuite  = {
15500 	.suite_name = "ESN Test Suite",
15501 	.setup = esn_testsuite_setup,
15502 	.unit_test_cases = {
15503 		TEST_CASE_ST(ut_setup, ut_teardown,
15504 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
15505 		TEST_CASE_ST(ut_setup, ut_teardown,
15506 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
15507 		TEST_CASES_END()
15508 	}
15509 };
15510 
15511 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
15512 	.suite_name = "Negative AES GCM Test Suite",
15513 	.setup = negative_aes_gcm_testsuite_setup,
15514 	.unit_test_cases = {
15515 		TEST_CASE_ST(ut_setup, ut_teardown,
15516 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
15517 		TEST_CASE_ST(ut_setup, ut_teardown,
15518 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
15519 		TEST_CASE_ST(ut_setup, ut_teardown,
15520 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
15521 		TEST_CASE_ST(ut_setup, ut_teardown,
15522 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
15523 		TEST_CASE_ST(ut_setup, ut_teardown,
15524 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
15525 		TEST_CASE_ST(ut_setup, ut_teardown,
15526 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
15527 		TEST_CASE_ST(ut_setup, ut_teardown,
15528 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
15529 		TEST_CASE_ST(ut_setup, ut_teardown,
15530 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15531 		TEST_CASE_ST(ut_setup, ut_teardown,
15532 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15533 		TEST_CASE_ST(ut_setup, ut_teardown,
15534 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15535 		TEST_CASE_ST(ut_setup, ut_teardown,
15536 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
15537 		TEST_CASE_ST(ut_setup, ut_teardown,
15538 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
15539 
15540 		TEST_CASES_END()
15541 	}
15542 };
15543 
15544 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
15545 	.suite_name = "Negative AES GMAC Test Suite",
15546 	.setup = negative_aes_gmac_testsuite_setup,
15547 	.unit_test_cases = {
15548 		TEST_CASE_ST(ut_setup, ut_teardown,
15549 			authentication_verify_AES128_GMAC_fail_data_corrupt),
15550 		TEST_CASE_ST(ut_setup, ut_teardown,
15551 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
15552 
15553 		TEST_CASES_END()
15554 	}
15555 };
15556 
15557 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
15558 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15559 	.setup = mixed_cipher_hash_testsuite_setup,
15560 	.unit_test_cases = {
15561 		/** AUTH AES CMAC + CIPHER AES CTR */
15562 		TEST_CASE_ST(ut_setup, ut_teardown,
15563 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15564 		TEST_CASE_ST(ut_setup, ut_teardown,
15565 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15566 		TEST_CASE_ST(ut_setup, ut_teardown,
15567 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15568 		TEST_CASE_ST(ut_setup, ut_teardown,
15569 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15570 		TEST_CASE_ST(ut_setup, ut_teardown,
15571 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15572 		TEST_CASE_ST(ut_setup, ut_teardown,
15573 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15574 		TEST_CASE_ST(ut_setup, ut_teardown,
15575 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15576 		TEST_CASE_ST(ut_setup, ut_teardown,
15577 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15578 
15579 		/** AUTH ZUC + CIPHER SNOW3G */
15580 		TEST_CASE_ST(ut_setup, ut_teardown,
15581 			test_auth_zuc_cipher_snow_test_case_1),
15582 		TEST_CASE_ST(ut_setup, ut_teardown,
15583 			test_verify_auth_zuc_cipher_snow_test_case_1),
15584 		/** AUTH AES CMAC + CIPHER SNOW3G */
15585 		TEST_CASE_ST(ut_setup, ut_teardown,
15586 			test_auth_aes_cmac_cipher_snow_test_case_1),
15587 		TEST_CASE_ST(ut_setup, ut_teardown,
15588 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15589 		/** AUTH ZUC + CIPHER AES CTR */
15590 		TEST_CASE_ST(ut_setup, ut_teardown,
15591 			test_auth_zuc_cipher_aes_ctr_test_case_1),
15592 		TEST_CASE_ST(ut_setup, ut_teardown,
15593 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15594 		/** AUTH SNOW3G + CIPHER AES CTR */
15595 		TEST_CASE_ST(ut_setup, ut_teardown,
15596 			test_auth_snow_cipher_aes_ctr_test_case_1),
15597 		TEST_CASE_ST(ut_setup, ut_teardown,
15598 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15599 		/** AUTH SNOW3G + CIPHER ZUC */
15600 		TEST_CASE_ST(ut_setup, ut_teardown,
15601 			test_auth_snow_cipher_zuc_test_case_1),
15602 		TEST_CASE_ST(ut_setup, ut_teardown,
15603 			test_verify_auth_snow_cipher_zuc_test_case_1),
15604 		/** AUTH AES CMAC + CIPHER ZUC */
15605 		TEST_CASE_ST(ut_setup, ut_teardown,
15606 			test_auth_aes_cmac_cipher_zuc_test_case_1),
15607 		TEST_CASE_ST(ut_setup, ut_teardown,
15608 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15609 
15610 		/** AUTH NULL + CIPHER SNOW3G */
15611 		TEST_CASE_ST(ut_setup, ut_teardown,
15612 			test_auth_null_cipher_snow_test_case_1),
15613 		TEST_CASE_ST(ut_setup, ut_teardown,
15614 			test_verify_auth_null_cipher_snow_test_case_1),
15615 		/** AUTH NULL + CIPHER ZUC */
15616 		TEST_CASE_ST(ut_setup, ut_teardown,
15617 			test_auth_null_cipher_zuc_test_case_1),
15618 		TEST_CASE_ST(ut_setup, ut_teardown,
15619 			test_verify_auth_null_cipher_zuc_test_case_1),
15620 		/** AUTH SNOW3G + CIPHER NULL */
15621 		TEST_CASE_ST(ut_setup, ut_teardown,
15622 			test_auth_snow_cipher_null_test_case_1),
15623 		TEST_CASE_ST(ut_setup, ut_teardown,
15624 			test_verify_auth_snow_cipher_null_test_case_1),
15625 		/** AUTH ZUC + CIPHER NULL */
15626 		TEST_CASE_ST(ut_setup, ut_teardown,
15627 			test_auth_zuc_cipher_null_test_case_1),
15628 		TEST_CASE_ST(ut_setup, ut_teardown,
15629 			test_verify_auth_zuc_cipher_null_test_case_1),
15630 		/** AUTH NULL + CIPHER AES CTR */
15631 		TEST_CASE_ST(ut_setup, ut_teardown,
15632 			test_auth_null_cipher_aes_ctr_test_case_1),
15633 		TEST_CASE_ST(ut_setup, ut_teardown,
15634 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
15635 		/** AUTH AES CMAC + CIPHER NULL */
15636 		TEST_CASE_ST(ut_setup, ut_teardown,
15637 			test_auth_aes_cmac_cipher_null_test_case_1),
15638 		TEST_CASE_ST(ut_setup, ut_teardown,
15639 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
15640 		TEST_CASES_END()
15641 	}
15642 };
15643 
15644 static int
15645 run_cryptodev_testsuite(const char *pmd_name)
15646 {
15647 	uint8_t ret, j, i = 0, blk_start_idx = 0;
15648 	const enum blockcipher_test_type blk_suites[] = {
15649 		BLKCIPHER_AES_CHAIN_TYPE,
15650 		BLKCIPHER_AES_CIPHERONLY_TYPE,
15651 		BLKCIPHER_AES_DOCSIS_TYPE,
15652 		BLKCIPHER_3DES_CHAIN_TYPE,
15653 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
15654 		BLKCIPHER_DES_CIPHERONLY_TYPE,
15655 		BLKCIPHER_DES_DOCSIS_TYPE,
15656 		BLKCIPHER_AUTHONLY_TYPE};
15657 	struct unit_test_suite *static_suites[] = {
15658 		&cryptodev_multi_session_testsuite,
15659 		&cryptodev_null_testsuite,
15660 		&cryptodev_aes_ccm_auth_testsuite,
15661 		&cryptodev_aes_gcm_auth_testsuite,
15662 		&cryptodev_aes_gmac_auth_testsuite,
15663 		&cryptodev_snow3g_testsuite,
15664 		&cryptodev_chacha20_poly1305_testsuite,
15665 		&cryptodev_zuc_testsuite,
15666 		&cryptodev_hmac_md5_auth_testsuite,
15667 		&cryptodev_kasumi_testsuite,
15668 		&cryptodev_esn_testsuite,
15669 		&cryptodev_negative_aes_gcm_testsuite,
15670 		&cryptodev_negative_aes_gmac_testsuite,
15671 		&cryptodev_mixed_cipher_hash_testsuite,
15672 		&cryptodev_negative_hmac_sha1_testsuite,
15673 		&cryptodev_gen_testsuite,
15674 #ifdef RTE_LIB_SECURITY
15675 		&ipsec_proto_testsuite,
15676 		&pdcp_proto_testsuite,
15677 		&docsis_proto_testsuite,
15678 #endif
15679 		&end_testsuite
15680 	};
15681 	static struct unit_test_suite ts = {
15682 		.suite_name = "Cryptodev Unit Test Suite",
15683 		.setup = testsuite_setup,
15684 		.teardown = testsuite_teardown,
15685 		.unit_test_cases = {TEST_CASES_END()}
15686 	};
15687 
15688 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15689 
15690 	if (gbl_driver_id == -1) {
15691 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15692 		return TEST_SKIPPED;
15693 	}
15694 
15695 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15696 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15697 
15698 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15699 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15700 	ret = unit_test_suite_runner(&ts);
15701 
15702 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15703 	free(ts.unit_test_suites);
15704 	return ret;
15705 }
15706 
15707 static int
15708 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15709 {
15710 	struct rte_cryptodev_info dev_info;
15711 	uint8_t i, nb_devs;
15712 	int driver_id;
15713 
15714 	driver_id = rte_cryptodev_driver_id_get(pmd_name);
15715 	if (driver_id == -1) {
15716 		RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15717 		return TEST_SKIPPED;
15718 	}
15719 
15720 	nb_devs = rte_cryptodev_count();
15721 	if (nb_devs < 1) {
15722 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15723 		return TEST_SKIPPED;
15724 	}
15725 
15726 	for (i = 0; i < nb_devs; i++) {
15727 		rte_cryptodev_info_get(i, &dev_info);
15728 		if (dev_info.driver_id == driver_id) {
15729 			if (!(dev_info.feature_flags & flag)) {
15730 				RTE_LOG(INFO, USER1, "%s not supported\n",
15731 						flag_name);
15732 				return TEST_SKIPPED;
15733 			}
15734 			return 0; /* found */
15735 		}
15736 	}
15737 
15738 	RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15739 	return TEST_SKIPPED;
15740 }
15741 
15742 static int
15743 test_cryptodev_qat(void)
15744 {
15745 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15746 }
15747 
15748 static int
15749 test_cryptodev_virtio(void)
15750 {
15751 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15752 }
15753 
15754 static int
15755 test_cryptodev_aesni_mb(void)
15756 {
15757 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15758 }
15759 
15760 static int
15761 test_cryptodev_cpu_aesni_mb(void)
15762 {
15763 	int32_t rc;
15764 	enum rte_security_session_action_type at = gbl_action_type;
15765 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15766 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15767 	gbl_action_type = at;
15768 	return rc;
15769 }
15770 
15771 static int
15772 test_cryptodev_chacha_poly_mb(void)
15773 {
15774 	int32_t rc;
15775 	enum rte_security_session_action_type at = gbl_action_type;
15776 	rc = run_cryptodev_testsuite(
15777 			RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
15778 	gbl_action_type = at;
15779 	return rc;
15780 }
15781 
15782 static int
15783 test_cryptodev_openssl(void)
15784 {
15785 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15786 }
15787 
15788 static int
15789 test_cryptodev_aesni_gcm(void)
15790 {
15791 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15792 }
15793 
15794 static int
15795 test_cryptodev_cpu_aesni_gcm(void)
15796 {
15797 	int32_t rc;
15798 	enum rte_security_session_action_type at = gbl_action_type;
15799 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15800 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15801 	gbl_action_type = at;
15802 	return rc;
15803 }
15804 
15805 static int
15806 test_cryptodev_mlx5(void)
15807 {
15808 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15809 }
15810 
15811 static int
15812 test_cryptodev_null(void)
15813 {
15814 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15815 }
15816 
15817 static int
15818 test_cryptodev_sw_snow3g(void)
15819 {
15820 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15821 }
15822 
15823 static int
15824 test_cryptodev_sw_kasumi(void)
15825 {
15826 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15827 }
15828 
15829 static int
15830 test_cryptodev_sw_zuc(void)
15831 {
15832 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15833 }
15834 
15835 static int
15836 test_cryptodev_armv8(void)
15837 {
15838 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15839 }
15840 
15841 static int
15842 test_cryptodev_mrvl(void)
15843 {
15844 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15845 }
15846 
15847 #ifdef RTE_CRYPTO_SCHEDULER
15848 
15849 static int
15850 test_cryptodev_scheduler(void)
15851 {
15852 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15853 	const enum blockcipher_test_type blk_suites[] = {
15854 		BLKCIPHER_AES_CHAIN_TYPE,
15855 		BLKCIPHER_AES_CIPHERONLY_TYPE,
15856 		BLKCIPHER_AUTHONLY_TYPE
15857 	};
15858 	static struct unit_test_suite scheduler_multicore = {
15859 		.suite_name = "Scheduler Multicore Unit Test Suite",
15860 		.setup = scheduler_multicore_testsuite_setup,
15861 		.teardown = scheduler_mode_testsuite_teardown,
15862 		.unit_test_cases = {TEST_CASES_END()}
15863 	};
15864 	static struct unit_test_suite scheduler_round_robin = {
15865 		.suite_name = "Scheduler Round Robin Unit Test Suite",
15866 		.setup = scheduler_roundrobin_testsuite_setup,
15867 		.teardown = scheduler_mode_testsuite_teardown,
15868 		.unit_test_cases = {TEST_CASES_END()}
15869 	};
15870 	static struct unit_test_suite scheduler_failover = {
15871 		.suite_name = "Scheduler Failover Unit Test Suite",
15872 		.setup = scheduler_failover_testsuite_setup,
15873 		.teardown = scheduler_mode_testsuite_teardown,
15874 		.unit_test_cases = {TEST_CASES_END()}
15875 	};
15876 	static struct unit_test_suite scheduler_pkt_size_distr = {
15877 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15878 		.setup = scheduler_pkt_size_distr_testsuite_setup,
15879 		.teardown = scheduler_mode_testsuite_teardown,
15880 		.unit_test_cases = {TEST_CASES_END()}
15881 	};
15882 	struct unit_test_suite *sched_mode_suites[] = {
15883 		&scheduler_multicore,
15884 		&scheduler_round_robin,
15885 		&scheduler_failover,
15886 		&scheduler_pkt_size_distr
15887 	};
15888 	static struct unit_test_suite scheduler_config = {
15889 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15890 		.unit_test_cases = {
15891 			TEST_CASE(test_scheduler_attach_worker_op),
15892 			TEST_CASE(test_scheduler_mode_multicore_op),
15893 			TEST_CASE(test_scheduler_mode_roundrobin_op),
15894 			TEST_CASE(test_scheduler_mode_failover_op),
15895 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15896 			TEST_CASE(test_scheduler_detach_worker_op),
15897 
15898 			TEST_CASES_END() /**< NULL terminate array */
15899 		}
15900 	};
15901 	struct unit_test_suite *static_suites[] = {
15902 		&scheduler_config,
15903 		&end_testsuite
15904 	};
15905 	static struct unit_test_suite ts = {
15906 		.suite_name = "Scheduler Unit Test Suite",
15907 		.setup = scheduler_testsuite_setup,
15908 		.teardown = testsuite_teardown,
15909 		.unit_test_cases = {TEST_CASES_END()}
15910 	};
15911 
15912 	gbl_driver_id =	rte_cryptodev_driver_id_get(
15913 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15914 
15915 	if (gbl_driver_id == -1) {
15916 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15917 		return TEST_SKIPPED;
15918 	}
15919 
15920 	if (rte_cryptodev_driver_id_get(
15921 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15922 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15923 		return TEST_SKIPPED;
15924 	}
15925 
15926 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15927 		uint8_t blk_i = 0;
15928 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15929 				(struct unit_test_suite *) *
15930 				(RTE_DIM(blk_suites) + 1));
15931 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15932 				blk_suites, RTE_DIM(blk_suites));
15933 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15934 	}
15935 
15936 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15937 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15938 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15939 			RTE_DIM(sched_mode_suites));
15940 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15941 	ret = unit_test_suite_runner(&ts);
15942 
15943 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15944 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15945 				(*sched_mode_suites[sched_i]),
15946 				RTE_DIM(blk_suites));
15947 		free(sched_mode_suites[sched_i]->unit_test_suites);
15948 	}
15949 	free(ts.unit_test_suites);
15950 	return ret;
15951 }
15952 
15953 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15954 
15955 #endif
15956 
15957 static int
15958 test_cryptodev_dpaa2_sec(void)
15959 {
15960 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15961 }
15962 
15963 static int
15964 test_cryptodev_dpaa_sec(void)
15965 {
15966 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15967 }
15968 
15969 static int
15970 test_cryptodev_ccp(void)
15971 {
15972 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15973 }
15974 
15975 static int
15976 test_cryptodev_octeontx(void)
15977 {
15978 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15979 }
15980 
15981 static int
15982 test_cryptodev_caam_jr(void)
15983 {
15984 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15985 }
15986 
15987 static int
15988 test_cryptodev_nitrox(void)
15989 {
15990 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15991 }
15992 
15993 static int
15994 test_cryptodev_bcmfs(void)
15995 {
15996 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15997 }
15998 
15999 static int
16000 test_cryptodev_qat_raw_api(void)
16001 {
16002 	static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
16003 	int ret;
16004 
16005 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16006 			"RAW API");
16007 	if (ret)
16008 		return ret;
16009 
16010 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
16011 	ret = run_cryptodev_testsuite(pmd_name);
16012 	global_api_test_type = CRYPTODEV_API_TEST;
16013 
16014 	return ret;
16015 }
16016 
16017 static int
16018 test_cryptodev_cn9k(void)
16019 {
16020 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
16021 }
16022 
16023 static int
16024 test_cryptodev_cn10k(void)
16025 {
16026 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
16027 }
16028 
16029 static int
16030 test_cryptodev_dpaa2_sec_raw_api(void)
16031 {
16032 	static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16033 	int ret;
16034 
16035 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16036 			"RAW API");
16037 	if (ret)
16038 		return ret;
16039 
16040 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
16041 	ret = run_cryptodev_testsuite(pmd_name);
16042 	global_api_test_type = CRYPTODEV_API_TEST;
16043 
16044 	return ret;
16045 }
16046 
16047 static int
16048 test_cryptodev_dpaa_sec_raw_api(void)
16049 {
16050 	static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16051 	int ret;
16052 
16053 	ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16054 			"RAW API");
16055 	if (ret)
16056 		return ret;
16057 
16058 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
16059 	ret = run_cryptodev_testsuite(pmd_name);
16060 	global_api_test_type = CRYPTODEV_API_TEST;
16061 
16062 	return ret;
16063 }
16064 
16065 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
16066 		test_cryptodev_dpaa2_sec_raw_api);
16067 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
16068 		test_cryptodev_dpaa_sec_raw_api);
16069 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
16070 		test_cryptodev_qat_raw_api);
16071 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
16072 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
16073 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
16074 	test_cryptodev_cpu_aesni_mb);
16075 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
16076 	test_cryptodev_chacha_poly_mb);
16077 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
16078 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
16079 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
16080 	test_cryptodev_cpu_aesni_gcm);
16081 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
16082 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
16083 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
16084 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
16085 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
16086 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
16087 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
16088 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
16089 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
16090 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
16091 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
16092 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
16093 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
16094 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
16095 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
16096 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
16097 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
16098 
16099 #endif /* !RTE_EXEC_ENV_WINDOWS */
16100