1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 Intel Corporation
5 #include <rte_common.h>
6 #include <rte_hexdump.h>
8 #include <rte_malloc.h>
9 #include <rte_memcpy.h>
10 #include <rte_pause.h>
12 #include <rte_crypto.h>
13 #include <rte_cryptodev.h>
14 #include <rte_cryptodev_pmd.h>
17 #include "test_cryptodev.h"
18 #include "test_cryptodev_blockcipher.h"
19 #include "test_cryptodev_aes_test_vectors.h"
20 #include "test_cryptodev_des_test_vectors.h"
21 #include "test_cryptodev_hash_test_vectors.h"
24 test_blockcipher_one_case(const struct blockcipher_test_case *t,
25 struct rte_mempool *mbuf_pool,
26 struct rte_mempool *op_mpool,
27 struct rte_mempool *sess_mpool,
28 struct rte_mempool *sess_priv_mpool,
33 struct rte_mbuf *ibuf = NULL;
34 struct rte_mbuf *obuf = NULL;
35 struct rte_mbuf *iobuf;
36 struct rte_crypto_sym_xform *cipher_xform = NULL;
37 struct rte_crypto_sym_xform *auth_xform = NULL;
38 struct rte_crypto_sym_xform *init_xform = NULL;
39 struct rte_crypto_sym_op *sym_op = NULL;
40 struct rte_crypto_op *op = NULL;
41 struct rte_cryptodev_info dev_info;
42 struct rte_cryptodev_sym_session *sess = NULL;
44 int status = TEST_SUCCESS;
45 const struct blockcipher_test_data *tdata = t->test_data;
46 uint8_t cipher_key[tdata->cipher_key.len];
47 uint8_t auth_key[tdata->auth_key.len];
48 uint32_t buf_len = tdata->ciphertext.len;
49 uint32_t digest_len = 0;
51 uint8_t src_pattern = 0xa5;
52 uint8_t dst_pattern = 0xb6;
53 uint8_t tmp_src_buf[MBUF_SIZE];
54 uint8_t tmp_dst_buf[MBUF_SIZE];
56 int openssl_pmd = rte_cryptodev_driver_id_get(
57 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
58 int ccp_pmd = rte_cryptodev_driver_id_get(
59 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
60 int scheduler_pmd = rte_cryptodev_driver_id_get(
61 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
62 int armv8_pmd = rte_cryptodev_driver_id_get(
63 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
64 int aesni_mb_pmd = rte_cryptodev_driver_id_get(
65 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
66 int qat_pmd = rte_cryptodev_driver_id_get(
67 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
68 int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
69 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
70 int dpaa_sec_pmd = rte_cryptodev_driver_id_get(
71 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
72 int caam_jr_pmd = rte_cryptodev_driver_id_get(
73 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
74 int mrvl_pmd = rte_cryptodev_driver_id_get(
75 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
76 int virtio_pmd = rte_cryptodev_driver_id_get(
77 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
78 int octeontx_pmd = rte_cryptodev_driver_id_get(
79 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
80 int null_pmd = rte_cryptodev_driver_id_get(
81 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
84 uint32_t nb_iterates = 0;
86 rte_cryptodev_info_get(dev_id, &dev_info);
88 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
89 uint64_t feat_flags = dev_info.feature_flags;
90 uint64_t oop_flag = RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT;
92 if (t->feature_mask && BLOCKCIPHER_TEST_FEATURE_OOP) {
93 if (!(feat_flags & oop_flag)) {
94 printf("Device doesn't support out-of-place "
95 "scatter-gather in input mbuf. "
100 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
101 printf("Device doesn't support in-place "
102 "scatter-gather mbufs. "
111 if (tdata->cipher_key.len)
112 memcpy(cipher_key, tdata->cipher_key.data,
113 tdata->cipher_key.len);
114 if (tdata->auth_key.len)
115 memcpy(auth_key, tdata->auth_key.data,
116 tdata->auth_key.len);
118 if (driver_id == dpaa2_sec_pmd ||
119 driver_id == dpaa_sec_pmd ||
120 driver_id == caam_jr_pmd ||
121 driver_id == qat_pmd ||
122 driver_id == openssl_pmd ||
123 driver_id == armv8_pmd ||
124 driver_id == mrvl_pmd ||
125 driver_id == ccp_pmd ||
126 driver_id == virtio_pmd ||
127 driver_id == octeontx_pmd ||
128 driver_id == null_pmd) { /* Fall through */
129 digest_len = tdata->digest.len;
130 } else if (driver_id == aesni_mb_pmd ||
131 driver_id == scheduler_pmd) {
132 digest_len = tdata->digest.truncated_len;
134 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
135 "line %u FAILED: %s",
136 __LINE__, "Unsupported PMD type");
137 status = TEST_FAILED;
142 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
143 buf_len += digest_len;
145 /* for contiguous mbuf, nb_segs is 1 */
146 ibuf = create_segmented_mbuf(mbuf_pool,
147 tdata->ciphertext.len, nb_segs, src_pattern);
149 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
150 "line %u FAILED: %s",
151 __LINE__, "Cannot create source mbuf");
152 status = TEST_FAILED;
156 /* only encryption requires plaintext.data input,
157 * decryption/(digest gen)/(digest verify) use ciphertext.data
160 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
161 pktmbuf_write(ibuf, 0, tdata->plaintext.len,
162 tdata->plaintext.data);
164 pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
165 tdata->ciphertext.data);
167 buf_p = rte_pktmbuf_append(ibuf, digest_len);
168 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
169 rte_memcpy(buf_p, tdata->digest.data, digest_len);
171 memset(buf_p, 0, digest_len);
173 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
174 obuf = rte_pktmbuf_alloc(mbuf_pool);
176 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
177 "FAILED: %s", __LINE__,
178 "Allocation of rte_mbuf failed");
179 status = TEST_FAILED;
182 memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
184 buf_p = rte_pktmbuf_append(obuf, buf_len);
186 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
187 "FAILED: %s", __LINE__,
188 "No room to append mbuf");
189 status = TEST_FAILED;
192 memset(buf_p, 0, buf_len);
195 /* Generate Crypto op data structure */
196 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
198 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
199 "line %u FAILED: %s",
200 __LINE__, "Failed to allocate symmetric crypto "
202 status = TEST_FAILED;
210 struct rte_mbuf *tmp_buf = ibuf;
215 rte_pktmbuf_reset(ibuf);
216 rte_pktmbuf_reset(obuf);
218 rte_pktmbuf_append(ibuf, tdata->ciphertext.len);
220 /* only encryption requires plaintext.data input,
221 * decryption/(digest gen)/(digest verify) use ciphertext.data
224 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
225 pktmbuf_write(ibuf, 0, tdata->plaintext.len,
226 tdata->plaintext.data);
228 pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
229 tdata->ciphertext.data);
231 buf_p = rte_pktmbuf_append(ibuf, digest_len);
232 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
233 rte_memcpy(buf_p, tdata->digest.data, digest_len);
235 memset(buf_p, 0, digest_len);
237 memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
239 buf_p = rte_pktmbuf_append(obuf, buf_len);
241 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
242 "FAILED: %s", __LINE__,
243 "No room to append mbuf");
244 status = TEST_FAILED;
247 memset(buf_p, 0, buf_len);
250 sym_op->m_src = ibuf;
252 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
253 sym_op->m_dst = obuf;
256 sym_op->m_dst = NULL;
260 /* sessionless op requires allocate xform using
261 * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
264 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
265 uint32_t n_xforms = 0;
267 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
269 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
272 if (rte_crypto_op_sym_xforms_alloc(op, n_xforms)
274 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
275 "FAILED: %s", __LINE__, "Failed to "
276 "allocate space for crypto transforms");
277 status = TEST_FAILED;
281 cipher_xform = rte_zmalloc(NULL,
282 sizeof(struct rte_crypto_sym_xform), 0);
284 auth_xform = rte_zmalloc(NULL,
285 sizeof(struct rte_crypto_sym_xform), 0);
287 if (!cipher_xform || !auth_xform) {
288 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
289 "FAILED: %s", __LINE__, "Failed to "
290 "allocate memory for crypto transforms");
291 status = TEST_FAILED;
296 /* preparing xform, for sessioned op, init_xform is initialized
297 * here and later as param in rte_cryptodev_sym_session_create() call
299 if (t->op_mask == BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN) {
300 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
301 cipher_xform = op->sym->xform;
302 auth_xform = cipher_xform->next;
303 auth_xform->next = NULL;
305 cipher_xform->next = auth_xform;
306 auth_xform->next = NULL;
307 init_xform = cipher_xform;
309 } else if (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC) {
310 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
311 auth_xform = op->sym->xform;
312 cipher_xform = auth_xform->next;
313 cipher_xform->next = NULL;
315 auth_xform->next = cipher_xform;
316 cipher_xform->next = NULL;
317 init_xform = auth_xform;
319 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_ENCRYPT) ||
320 (t->op_mask == BLOCKCIPHER_TEST_OP_DECRYPT)) {
321 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
322 cipher_xform = op->sym->xform;
324 init_xform = cipher_xform;
325 cipher_xform->next = NULL;
326 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_GEN) ||
327 (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY)) {
328 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
329 auth_xform = op->sym->xform;
331 init_xform = auth_xform;
332 auth_xform->next = NULL;
334 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
335 "line %u FAILED: %s",
336 __LINE__, "Unrecognized operation");
337 status = TEST_FAILED;
341 /*configure xforms & sym_op cipher and auth data*/
342 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
343 cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
344 cipher_xform->cipher.algo = tdata->crypto_algo;
345 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
346 cipher_xform->cipher.op =
347 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
349 cipher_xform->cipher.op =
350 RTE_CRYPTO_CIPHER_OP_DECRYPT;
351 cipher_xform->cipher.key.data = cipher_key;
352 cipher_xform->cipher.key.length = tdata->cipher_key.len;
353 cipher_xform->cipher.iv.offset = IV_OFFSET;
354 cipher_xform->cipher.iv.length = tdata->iv.len;
356 sym_op->cipher.data.offset = tdata->cipher_offset;
357 sym_op->cipher.data.length = tdata->ciphertext.len -
358 tdata->cipher_offset;
359 rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
364 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
365 uint32_t digest_offset = tdata->ciphertext.len;
367 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
368 auth_xform->auth.algo = tdata->auth_algo;
369 auth_xform->auth.key.length = tdata->auth_key.len;
370 auth_xform->auth.key.data = auth_key;
371 auth_xform->auth.digest_length = digest_len;
373 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
374 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
375 sym_op->auth.digest.data = pktmbuf_mtod_offset
376 (iobuf, digest_offset);
377 sym_op->auth.digest.phys_addr =
378 pktmbuf_iova_offset(iobuf,
381 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
382 sym_op->auth.digest.data = pktmbuf_mtod_offset
383 (sym_op->m_src, digest_offset);
384 sym_op->auth.digest.phys_addr =
385 pktmbuf_iova_offset(sym_op->m_src,
389 sym_op->auth.data.offset = tdata->auth_offset;
390 sym_op->auth.data.length = tdata->ciphertext.len -
395 * Create session for sessioned op. For mbuf iteration test,
396 * skip the session creation for the second iteration.
398 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) &&
400 sess = rte_cryptodev_sym_session_create(sess_mpool);
402 rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
405 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
406 "FAILED: %s", __LINE__,
407 "Session creation failed");
408 status = TEST_FAILED;
412 /* attach symmetric crypto session to crypto operations */
413 rte_crypto_op_attach_sym_session(op, sess);
416 debug_hexdump(stdout, "m_src(before):",
417 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
418 rte_memcpy(tmp_src_buf, sym_op->m_src->buf_addr,
419 sym_op->m_src->buf_len);
420 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
421 debug_hexdump(stdout, "m_dst(before):",
422 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
423 rte_memcpy(tmp_dst_buf, sym_op->m_dst->buf_addr,
424 sym_op->m_dst->buf_len);
427 /* Process crypto operation */
428 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
429 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
430 "line %u FAILED: %s",
431 __LINE__, "Error sending packet for encryption");
432 status = TEST_FAILED;
438 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
442 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
443 "line %u FAILED: %s",
444 __LINE__, "Failed to process sym crypto op");
445 status = TEST_FAILED;
449 debug_hexdump(stdout, "m_src(after):",
450 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
451 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP)
452 debug_hexdump(stdout, "m_dst(after):",
453 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
456 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
457 if ((t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) &&
458 (op->status == RTE_CRYPTO_OP_STATUS_AUTH_FAILED))
459 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
460 "FAILED: Digest verification failed "
461 "(0x%X)", __LINE__, op->status);
463 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
464 "FAILED: Operation failed "
465 "(0x%X)", __LINE__, op->status);
466 status = TEST_FAILED;
470 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
471 uint8_t buffer[2048];
472 const uint8_t *compare_ref;
473 uint32_t compare_len;
475 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) {
476 compare_ref = tdata->ciphertext.data +
477 tdata->cipher_offset;
478 compare_len = tdata->ciphertext.len -
479 tdata->cipher_offset;
481 compare_ref = tdata->plaintext.data +
482 tdata->cipher_offset;
483 compare_len = tdata->plaintext.len -
484 tdata->cipher_offset;
487 if (memcmp(rte_pktmbuf_read(iobuf, tdata->cipher_offset,
488 compare_len, buffer), compare_ref,
490 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
491 "FAILED: %s", __LINE__,
492 "Crypto data not as expected");
493 status = TEST_FAILED;
498 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
499 uint8_t *auth_res = pktmbuf_mtod_offset(iobuf,
500 tdata->ciphertext.len);
502 if (memcmp(auth_res, tdata->digest.data, digest_len)) {
503 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
504 "FAILED: %s", __LINE__, "Generated "
505 "digest data not as expected");
506 status = TEST_FAILED;
511 /* The only parts that should have changed in the buffer are
512 * plaintext/ciphertext and digest.
513 * In OOP only the dest buffer should change.
515 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
516 struct rte_mbuf *mbuf;
518 uint32_t head_unchanged_len, changed_len = 0;
520 uint32_t hdroom_used = 0, tlroom_used = 0;
523 mbuf = sym_op->m_src;
525 * Crypto PMDs specify the headroom & tailroom it would use
526 * when processing the crypto operation. PMD is free to modify
527 * this space, and so the verification check should skip that
530 hdroom_used = dev_info.min_mbuf_headroom_req;
531 tlroom_used = dev_info.min_mbuf_tailroom_req;
534 hdroom = rte_pktmbuf_headroom(mbuf);
536 head_unchanged_len = mbuf->buf_len;
538 for (i = 0; i < mbuf->buf_len; i++) {
540 /* Skip headroom used by PMD */
541 if (i == hdroom - hdroom_used)
544 /* Skip tailroom used by PMD */
545 if (i == (hdroom + mbuf->data_len))
548 value = *((uint8_t *)(mbuf->buf_addr)+i);
549 if (value != tmp_src_buf[i]) {
550 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
551 "line %u FAILED: OOP src outer mbuf data (0x%x) not as expected (0x%x)",
552 __LINE__, value, tmp_src_buf[i]);
553 status = TEST_FAILED;
558 mbuf = sym_op->m_dst;
559 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
560 head_unchanged_len = hdroom + sym_op->auth.data.offset;
561 changed_len = sym_op->auth.data.length;
562 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
563 changed_len += digest_len;
566 head_unchanged_len = hdroom +
567 sym_op->cipher.data.offset;
568 changed_len = sym_op->cipher.data.length;
571 for (i = 0; i < mbuf->buf_len; i++) {
572 if (i == head_unchanged_len)
574 value = *((uint8_t *)(mbuf->buf_addr)+i);
575 if (value != tmp_dst_buf[i]) {
576 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
577 "line %u FAILED: OOP dst outer mbuf data "
578 "(0x%x) not as expected (0x%x)",
579 __LINE__, value, tmp_dst_buf[i]);
580 status = TEST_FAILED;
590 /* In-place operation */
591 struct rte_mbuf *mbuf;
593 uint32_t head_unchanged_len = 0, changed_len = 0;
595 uint32_t hdroom_used = 0, tlroom_used = 0;
599 * Crypto PMDs specify the headroom & tailroom it would use
600 * when processing the crypto operation. PMD is free to modify
601 * this space, and so the verification check should skip that
604 hdroom_used = dev_info.min_mbuf_headroom_req;
605 tlroom_used = dev_info.min_mbuf_tailroom_req;
607 mbuf = sym_op->m_src;
610 hdroom = rte_pktmbuf_headroom(mbuf);
612 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
613 head_unchanged_len = hdroom +
614 sym_op->cipher.data.offset;
615 changed_len = sym_op->cipher.data.length;
618 head_unchanged_len = hdroom +
619 sym_op->auth.data.offset +
620 sym_op->auth.data.length;
624 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
625 changed_len += digest_len;
627 for (i = 0; i < mbuf->buf_len; i++) {
629 /* Skip headroom used by PMD */
630 if (i == hdroom - hdroom_used)
633 if (i == head_unchanged_len)
636 /* Skip tailroom used by PMD */
637 if (i == (hdroom + mbuf->data_len))
640 value = *((uint8_t *)(mbuf->buf_addr)+i);
641 if (value != tmp_src_buf[i]) {
642 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
643 "line %u FAILED: outer mbuf data (0x%x) "
644 "not as expected (0x%x)",
645 __LINE__, value, tmp_src_buf[i]);
646 status = TEST_FAILED;
652 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "PASS");
655 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
657 rte_cryptodev_sym_session_clear(dev_id, sess);
658 rte_cryptodev_sym_session_free(sess);
661 rte_free(cipher_xform);
663 rte_free(auth_xform);
667 rte_crypto_op_free(op);
670 rte_pktmbuf_free(obuf);
673 rte_pktmbuf_free(ibuf);
679 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
680 struct rte_mempool *op_mpool,
681 struct rte_mempool *sess_mpool,
682 struct rte_mempool *sess_priv_mpool,
685 enum blockcipher_test_type test_type)
687 int status, overall_status = TEST_SUCCESS;
688 uint32_t i, test_index = 0;
689 char test_msg[BLOCKCIPHER_TEST_MSG_LEN + 1];
690 uint32_t n_test_cases = 0;
691 uint32_t target_pmd_mask = 0;
692 const struct blockcipher_test_case *tcs = NULL;
694 int openssl_pmd = rte_cryptodev_driver_id_get(
695 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
696 int ccp_pmd = rte_cryptodev_driver_id_get(
697 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
698 int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
699 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
700 int dpaa_sec_pmd = rte_cryptodev_driver_id_get(
701 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
702 int caam_jr_pmd = rte_cryptodev_driver_id_get(
703 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
704 int scheduler_pmd = rte_cryptodev_driver_id_get(
705 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
706 int armv8_pmd = rte_cryptodev_driver_id_get(
707 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
708 int aesni_mb_pmd = rte_cryptodev_driver_id_get(
709 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
710 int qat_pmd = rte_cryptodev_driver_id_get(
711 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
712 int mrvl_pmd = rte_cryptodev_driver_id_get(
713 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
714 int virtio_pmd = rte_cryptodev_driver_id_get(
715 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
716 int octeontx_pmd = rte_cryptodev_driver_id_get(
717 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
718 int null_pmd = rte_cryptodev_driver_id_get(
719 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
722 case BLKCIPHER_AES_CHAIN_TYPE:
723 n_test_cases = sizeof(aes_chain_test_cases) /
724 sizeof(aes_chain_test_cases[0]);
725 tcs = aes_chain_test_cases;
727 case BLKCIPHER_AES_CIPHERONLY_TYPE:
728 n_test_cases = sizeof(aes_cipheronly_test_cases) /
729 sizeof(aes_cipheronly_test_cases[0]);
730 tcs = aes_cipheronly_test_cases;
732 case BLKCIPHER_AES_DOCSIS_TYPE:
733 n_test_cases = sizeof(aes_docsis_test_cases) /
734 sizeof(aes_docsis_test_cases[0]);
735 tcs = aes_docsis_test_cases;
737 case BLKCIPHER_3DES_CHAIN_TYPE:
738 n_test_cases = sizeof(triple_des_chain_test_cases) /
739 sizeof(triple_des_chain_test_cases[0]);
740 tcs = triple_des_chain_test_cases;
742 case BLKCIPHER_3DES_CIPHERONLY_TYPE:
743 n_test_cases = sizeof(triple_des_cipheronly_test_cases) /
744 sizeof(triple_des_cipheronly_test_cases[0]);
745 tcs = triple_des_cipheronly_test_cases;
747 case BLKCIPHER_DES_CIPHERONLY_TYPE:
748 n_test_cases = sizeof(des_cipheronly_test_cases) /
749 sizeof(des_cipheronly_test_cases[0]);
750 tcs = des_cipheronly_test_cases;
752 case BLKCIPHER_DES_DOCSIS_TYPE:
753 n_test_cases = sizeof(des_docsis_test_cases) /
754 sizeof(des_docsis_test_cases[0]);
755 tcs = des_docsis_test_cases;
757 case BLKCIPHER_AUTHONLY_TYPE:
758 n_test_cases = sizeof(hash_test_cases) /
759 sizeof(hash_test_cases[0]);
760 tcs = hash_test_cases;
766 if (driver_id == aesni_mb_pmd)
767 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB;
768 else if (driver_id == qat_pmd)
769 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT;
770 else if (driver_id == openssl_pmd)
771 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL;
772 else if (driver_id == armv8_pmd)
773 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8;
774 else if (driver_id == scheduler_pmd)
775 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER;
776 else if (driver_id == dpaa2_sec_pmd)
777 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC;
778 else if (driver_id == ccp_pmd)
779 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CCP;
780 else if (driver_id == dpaa_sec_pmd)
781 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC;
782 else if (driver_id == caam_jr_pmd)
783 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CAAM_JR;
784 else if (driver_id == mrvl_pmd)
785 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MVSAM;
786 else if (driver_id == virtio_pmd)
787 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO;
788 else if (driver_id == octeontx_pmd)
789 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OCTEONTX;
790 else if (driver_id == null_pmd)
791 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_NULL;
793 TEST_ASSERT(0, "Unrecognized cryptodev type");
795 for (i = 0; i < n_test_cases; i++) {
796 const struct blockcipher_test_case *tc = &tcs[i];
798 if (!(tc->pmd_mask & target_pmd_mask))
801 status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
802 sess_mpool, sess_priv_mpool, dev_id, driver_id,
805 printf(" %u) TestCase %s %s\n", test_index ++,
806 tc->test_descr, test_msg);
808 if (status != TEST_SUCCESS) {
809 if (overall_status == TEST_SUCCESS)
810 overall_status = status;
812 if (tc->feature_mask & BLOCKCIPHER_TEST_FEATURE_STOPPER)
817 return overall_status;