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));
82 int nitrox_pmd = rte_cryptodev_driver_id_get(
83 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
86 uint32_t nb_iterates = 0;
88 rte_cryptodev_info_get(dev_id, &dev_info);
90 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
91 uint64_t feat_flags = dev_info.feature_flags;
92 uint64_t oop_flag = RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT;
94 if (t->feature_mask && BLOCKCIPHER_TEST_FEATURE_OOP) {
95 if (!(feat_flags & oop_flag)) {
96 printf("Device doesn't support out-of-place "
97 "scatter-gather in input mbuf. "
102 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
103 printf("Device doesn't support in-place "
104 "scatter-gather mbufs. "
113 if (tdata->cipher_key.len)
114 memcpy(cipher_key, tdata->cipher_key.data,
115 tdata->cipher_key.len);
116 if (tdata->auth_key.len)
117 memcpy(auth_key, tdata->auth_key.data,
118 tdata->auth_key.len);
120 if (driver_id == dpaa2_sec_pmd ||
121 driver_id == dpaa_sec_pmd ||
122 driver_id == caam_jr_pmd ||
123 driver_id == qat_pmd ||
124 driver_id == openssl_pmd ||
125 driver_id == armv8_pmd ||
126 driver_id == mrvl_pmd ||
127 driver_id == ccp_pmd ||
128 driver_id == virtio_pmd ||
129 driver_id == octeontx_pmd ||
130 driver_id == null_pmd ||
131 driver_id == nitrox_pmd) { /* Fall through */
132 digest_len = tdata->digest.len;
133 } else if (driver_id == aesni_mb_pmd ||
134 driver_id == scheduler_pmd) {
135 digest_len = tdata->digest.truncated_len;
137 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
138 "line %u FAILED: %s",
139 __LINE__, "Unsupported PMD type");
140 status = TEST_FAILED;
145 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
146 buf_len += digest_len;
148 /* for contiguous mbuf, nb_segs is 1 */
149 ibuf = create_segmented_mbuf(mbuf_pool,
150 tdata->ciphertext.len, nb_segs, src_pattern);
152 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
153 "line %u FAILED: %s",
154 __LINE__, "Cannot create source mbuf");
155 status = TEST_FAILED;
159 /* only encryption requires plaintext.data input,
160 * decryption/(digest gen)/(digest verify) use ciphertext.data
163 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
164 pktmbuf_write(ibuf, 0, tdata->plaintext.len,
165 tdata->plaintext.data);
167 pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
168 tdata->ciphertext.data);
170 buf_p = rte_pktmbuf_append(ibuf, digest_len);
171 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
172 rte_memcpy(buf_p, tdata->digest.data, digest_len);
174 memset(buf_p, 0, digest_len);
176 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
177 obuf = rte_pktmbuf_alloc(mbuf_pool);
179 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
180 "FAILED: %s", __LINE__,
181 "Allocation of rte_mbuf failed");
182 status = TEST_FAILED;
185 memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
187 buf_p = rte_pktmbuf_append(obuf, buf_len);
189 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
190 "FAILED: %s", __LINE__,
191 "No room to append mbuf");
192 status = TEST_FAILED;
195 memset(buf_p, 0, buf_len);
198 /* Generate Crypto op data structure */
199 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
201 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
202 "line %u FAILED: %s",
203 __LINE__, "Failed to allocate symmetric crypto "
205 status = TEST_FAILED;
213 struct rte_mbuf *tmp_buf = ibuf;
218 rte_pktmbuf_reset(ibuf);
219 rte_pktmbuf_reset(obuf);
221 rte_pktmbuf_append(ibuf, tdata->ciphertext.len);
223 /* only encryption requires plaintext.data input,
224 * decryption/(digest gen)/(digest verify) use ciphertext.data
227 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
228 pktmbuf_write(ibuf, 0, tdata->plaintext.len,
229 tdata->plaintext.data);
231 pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
232 tdata->ciphertext.data);
234 buf_p = rte_pktmbuf_append(ibuf, digest_len);
235 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
236 rte_memcpy(buf_p, tdata->digest.data, digest_len);
238 memset(buf_p, 0, digest_len);
240 memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
242 buf_p = rte_pktmbuf_append(obuf, buf_len);
244 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
245 "FAILED: %s", __LINE__,
246 "No room to append mbuf");
247 status = TEST_FAILED;
250 memset(buf_p, 0, buf_len);
253 sym_op->m_src = ibuf;
255 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
256 sym_op->m_dst = obuf;
259 sym_op->m_dst = NULL;
263 /* sessionless op requires allocate xform using
264 * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
267 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
268 uint32_t n_xforms = 0;
270 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
272 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
275 if (rte_crypto_op_sym_xforms_alloc(op, n_xforms)
277 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
278 "FAILED: %s", __LINE__, "Failed to "
279 "allocate space for crypto transforms");
280 status = TEST_FAILED;
284 cipher_xform = rte_zmalloc(NULL,
285 sizeof(struct rte_crypto_sym_xform), 0);
287 auth_xform = rte_zmalloc(NULL,
288 sizeof(struct rte_crypto_sym_xform), 0);
290 if (!cipher_xform || !auth_xform) {
291 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
292 "FAILED: %s", __LINE__, "Failed to "
293 "allocate memory for crypto transforms");
294 status = TEST_FAILED;
299 /* preparing xform, for sessioned op, init_xform is initialized
300 * here and later as param in rte_cryptodev_sym_session_create() call
302 if (t->op_mask == BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN) {
303 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
304 cipher_xform = op->sym->xform;
305 auth_xform = cipher_xform->next;
306 auth_xform->next = NULL;
308 cipher_xform->next = auth_xform;
309 auth_xform->next = NULL;
310 init_xform = cipher_xform;
312 } else if (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC) {
313 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
314 auth_xform = op->sym->xform;
315 cipher_xform = auth_xform->next;
316 cipher_xform->next = NULL;
318 auth_xform->next = cipher_xform;
319 cipher_xform->next = NULL;
320 init_xform = auth_xform;
322 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_ENCRYPT) ||
323 (t->op_mask == BLOCKCIPHER_TEST_OP_DECRYPT)) {
324 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
325 cipher_xform = op->sym->xform;
327 init_xform = cipher_xform;
328 cipher_xform->next = NULL;
329 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_GEN) ||
330 (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY)) {
331 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
332 auth_xform = op->sym->xform;
334 init_xform = auth_xform;
335 auth_xform->next = NULL;
337 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
338 "line %u FAILED: %s",
339 __LINE__, "Unrecognized operation");
340 status = TEST_FAILED;
344 /*configure xforms & sym_op cipher and auth data*/
345 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
346 cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
347 cipher_xform->cipher.algo = tdata->crypto_algo;
348 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
349 cipher_xform->cipher.op =
350 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
352 cipher_xform->cipher.op =
353 RTE_CRYPTO_CIPHER_OP_DECRYPT;
354 cipher_xform->cipher.key.data = cipher_key;
355 cipher_xform->cipher.key.length = tdata->cipher_key.len;
356 cipher_xform->cipher.iv.offset = IV_OFFSET;
357 cipher_xform->cipher.iv.length = tdata->iv.len;
359 sym_op->cipher.data.offset = tdata->cipher_offset;
360 sym_op->cipher.data.length = tdata->ciphertext.len -
361 tdata->cipher_offset;
362 rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
367 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
368 uint32_t digest_offset = tdata->ciphertext.len;
370 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
371 auth_xform->auth.algo = tdata->auth_algo;
372 auth_xform->auth.key.length = tdata->auth_key.len;
373 auth_xform->auth.key.data = auth_key;
374 auth_xform->auth.digest_length = digest_len;
376 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
377 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
378 sym_op->auth.digest.data = pktmbuf_mtod_offset
379 (iobuf, digest_offset);
380 sym_op->auth.digest.phys_addr =
381 pktmbuf_iova_offset(iobuf,
384 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
385 sym_op->auth.digest.data = pktmbuf_mtod_offset
386 (sym_op->m_src, digest_offset);
387 sym_op->auth.digest.phys_addr =
388 pktmbuf_iova_offset(sym_op->m_src,
392 sym_op->auth.data.offset = tdata->auth_offset;
393 sym_op->auth.data.length = tdata->ciphertext.len -
398 * Create session for sessioned op. For mbuf iteration test,
399 * skip the session creation for the second iteration.
401 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) &&
403 sess = rte_cryptodev_sym_session_create(sess_mpool);
405 rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
408 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
409 "FAILED: %s", __LINE__,
410 "Session creation failed");
411 status = TEST_FAILED;
415 /* attach symmetric crypto session to crypto operations */
416 rte_crypto_op_attach_sym_session(op, sess);
419 debug_hexdump(stdout, "m_src(before):",
420 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
421 rte_memcpy(tmp_src_buf, sym_op->m_src->buf_addr,
422 sym_op->m_src->buf_len);
423 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
424 debug_hexdump(stdout, "m_dst(before):",
425 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
426 rte_memcpy(tmp_dst_buf, sym_op->m_dst->buf_addr,
427 sym_op->m_dst->buf_len);
430 /* Process crypto operation */
431 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
432 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
433 "line %u FAILED: %s",
434 __LINE__, "Error sending packet for encryption");
435 status = TEST_FAILED;
441 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
445 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
446 "line %u FAILED: %s",
447 __LINE__, "Failed to process sym crypto op");
448 status = TEST_FAILED;
452 debug_hexdump(stdout, "m_src(after):",
453 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
454 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP)
455 debug_hexdump(stdout, "m_dst(after):",
456 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
459 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
460 if ((t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) &&
461 (op->status == RTE_CRYPTO_OP_STATUS_AUTH_FAILED))
462 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
463 "FAILED: Digest verification failed "
464 "(0x%X)", __LINE__, op->status);
466 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
467 "FAILED: Operation failed "
468 "(0x%X)", __LINE__, op->status);
469 status = TEST_FAILED;
473 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
474 uint8_t buffer[2048];
475 const uint8_t *compare_ref;
476 uint32_t compare_len;
478 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) {
479 compare_ref = tdata->ciphertext.data +
480 tdata->cipher_offset;
481 compare_len = tdata->ciphertext.len -
482 tdata->cipher_offset;
484 compare_ref = tdata->plaintext.data +
485 tdata->cipher_offset;
486 compare_len = tdata->plaintext.len -
487 tdata->cipher_offset;
490 if (memcmp(rte_pktmbuf_read(iobuf, tdata->cipher_offset,
491 compare_len, buffer), compare_ref,
493 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
494 "FAILED: %s", __LINE__,
495 "Crypto data not as expected");
496 status = TEST_FAILED;
501 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
502 uint8_t *auth_res = pktmbuf_mtod_offset(iobuf,
503 tdata->ciphertext.len);
505 if (memcmp(auth_res, tdata->digest.data, digest_len)) {
506 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
507 "FAILED: %s", __LINE__, "Generated "
508 "digest data not as expected");
509 status = TEST_FAILED;
514 /* The only parts that should have changed in the buffer are
515 * plaintext/ciphertext and digest.
516 * In OOP only the dest buffer should change.
518 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
519 struct rte_mbuf *mbuf;
521 uint32_t head_unchanged_len, changed_len = 0;
523 uint32_t hdroom_used = 0, tlroom_used = 0;
526 mbuf = sym_op->m_src;
528 * Crypto PMDs specify the headroom & tailroom it would use
529 * when processing the crypto operation. PMD is free to modify
530 * this space, and so the verification check should skip that
533 hdroom_used = dev_info.min_mbuf_headroom_req;
534 tlroom_used = dev_info.min_mbuf_tailroom_req;
537 hdroom = rte_pktmbuf_headroom(mbuf);
539 head_unchanged_len = mbuf->buf_len;
541 for (i = 0; i < mbuf->buf_len; i++) {
543 /* Skip headroom used by PMD */
544 if (i == hdroom - hdroom_used)
547 /* Skip tailroom used by PMD */
548 if (i == (hdroom + mbuf->data_len))
551 value = *((uint8_t *)(mbuf->buf_addr)+i);
552 if (value != tmp_src_buf[i]) {
553 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
554 "line %u FAILED: OOP src outer mbuf data (0x%x) not as expected (0x%x)",
555 __LINE__, value, tmp_src_buf[i]);
556 status = TEST_FAILED;
561 mbuf = sym_op->m_dst;
562 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
563 head_unchanged_len = hdroom + sym_op->auth.data.offset;
564 changed_len = sym_op->auth.data.length;
565 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
566 changed_len += digest_len;
569 head_unchanged_len = hdroom +
570 sym_op->cipher.data.offset;
571 changed_len = sym_op->cipher.data.length;
574 for (i = 0; i < mbuf->buf_len; i++) {
575 if (i == head_unchanged_len)
577 value = *((uint8_t *)(mbuf->buf_addr)+i);
578 if (value != tmp_dst_buf[i]) {
579 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
580 "line %u FAILED: OOP dst outer mbuf data "
581 "(0x%x) not as expected (0x%x)",
582 __LINE__, value, tmp_dst_buf[i]);
583 status = TEST_FAILED;
593 /* In-place operation */
594 struct rte_mbuf *mbuf;
596 uint32_t head_unchanged_len = 0, changed_len = 0;
598 uint32_t hdroom_used = 0, tlroom_used = 0;
602 * Crypto PMDs specify the headroom & tailroom it would use
603 * when processing the crypto operation. PMD is free to modify
604 * this space, and so the verification check should skip that
607 hdroom_used = dev_info.min_mbuf_headroom_req;
608 tlroom_used = dev_info.min_mbuf_tailroom_req;
610 mbuf = sym_op->m_src;
613 hdroom = rte_pktmbuf_headroom(mbuf);
615 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
616 head_unchanged_len = hdroom +
617 sym_op->cipher.data.offset;
618 changed_len = sym_op->cipher.data.length;
621 head_unchanged_len = hdroom +
622 sym_op->auth.data.offset +
623 sym_op->auth.data.length;
627 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
628 changed_len += digest_len;
630 for (i = 0; i < mbuf->buf_len; i++) {
632 /* Skip headroom used by PMD */
633 if (i == hdroom - hdroom_used)
636 if (i == head_unchanged_len)
639 /* Skip tailroom used by PMD */
640 if (i == (hdroom + mbuf->data_len))
643 value = *((uint8_t *)(mbuf->buf_addr)+i);
644 if (value != tmp_src_buf[i]) {
645 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
646 "line %u FAILED: outer mbuf data (0x%x) "
647 "not as expected (0x%x)",
648 __LINE__, value, tmp_src_buf[i]);
649 status = TEST_FAILED;
655 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "PASS");
658 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
660 rte_cryptodev_sym_session_clear(dev_id, sess);
661 rte_cryptodev_sym_session_free(sess);
664 rte_free(cipher_xform);
666 rte_free(auth_xform);
670 rte_crypto_op_free(op);
673 rte_pktmbuf_free(obuf);
676 rte_pktmbuf_free(ibuf);
682 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
683 struct rte_mempool *op_mpool,
684 struct rte_mempool *sess_mpool,
685 struct rte_mempool *sess_priv_mpool,
688 enum blockcipher_test_type test_type)
690 int status, overall_status = TEST_SUCCESS;
691 uint32_t i, test_index = 0;
692 char test_msg[BLOCKCIPHER_TEST_MSG_LEN + 1];
693 uint32_t n_test_cases = 0;
694 uint32_t target_pmd_mask = 0;
695 const struct blockcipher_test_case *tcs = NULL;
697 int openssl_pmd = rte_cryptodev_driver_id_get(
698 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
699 int ccp_pmd = rte_cryptodev_driver_id_get(
700 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
701 int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
702 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
703 int dpaa_sec_pmd = rte_cryptodev_driver_id_get(
704 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
705 int caam_jr_pmd = rte_cryptodev_driver_id_get(
706 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
707 int scheduler_pmd = rte_cryptodev_driver_id_get(
708 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
709 int armv8_pmd = rte_cryptodev_driver_id_get(
710 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
711 int aesni_mb_pmd = rte_cryptodev_driver_id_get(
712 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
713 int qat_pmd = rte_cryptodev_driver_id_get(
714 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
715 int mrvl_pmd = rte_cryptodev_driver_id_get(
716 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
717 int virtio_pmd = rte_cryptodev_driver_id_get(
718 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
719 int octeontx_pmd = rte_cryptodev_driver_id_get(
720 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
721 int null_pmd = rte_cryptodev_driver_id_get(
722 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
723 int nitrox_pmd = rte_cryptodev_driver_id_get(
724 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
727 case BLKCIPHER_AES_CHAIN_TYPE:
728 n_test_cases = sizeof(aes_chain_test_cases) /
729 sizeof(aes_chain_test_cases[0]);
730 tcs = aes_chain_test_cases;
732 case BLKCIPHER_AES_CIPHERONLY_TYPE:
733 n_test_cases = sizeof(aes_cipheronly_test_cases) /
734 sizeof(aes_cipheronly_test_cases[0]);
735 tcs = aes_cipheronly_test_cases;
737 case BLKCIPHER_AES_DOCSIS_TYPE:
738 n_test_cases = sizeof(aes_docsis_test_cases) /
739 sizeof(aes_docsis_test_cases[0]);
740 tcs = aes_docsis_test_cases;
742 case BLKCIPHER_3DES_CHAIN_TYPE:
743 n_test_cases = sizeof(triple_des_chain_test_cases) /
744 sizeof(triple_des_chain_test_cases[0]);
745 tcs = triple_des_chain_test_cases;
747 case BLKCIPHER_3DES_CIPHERONLY_TYPE:
748 n_test_cases = sizeof(triple_des_cipheronly_test_cases) /
749 sizeof(triple_des_cipheronly_test_cases[0]);
750 tcs = triple_des_cipheronly_test_cases;
752 case BLKCIPHER_DES_CIPHERONLY_TYPE:
753 n_test_cases = sizeof(des_cipheronly_test_cases) /
754 sizeof(des_cipheronly_test_cases[0]);
755 tcs = des_cipheronly_test_cases;
757 case BLKCIPHER_DES_DOCSIS_TYPE:
758 n_test_cases = sizeof(des_docsis_test_cases) /
759 sizeof(des_docsis_test_cases[0]);
760 tcs = des_docsis_test_cases;
762 case BLKCIPHER_AUTHONLY_TYPE:
763 n_test_cases = sizeof(hash_test_cases) /
764 sizeof(hash_test_cases[0]);
765 tcs = hash_test_cases;
771 if (driver_id == aesni_mb_pmd)
772 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB;
773 else if (driver_id == qat_pmd)
774 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT;
775 else if (driver_id == openssl_pmd)
776 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL;
777 else if (driver_id == armv8_pmd)
778 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8;
779 else if (driver_id == scheduler_pmd)
780 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER;
781 else if (driver_id == dpaa2_sec_pmd)
782 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC;
783 else if (driver_id == ccp_pmd)
784 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CCP;
785 else if (driver_id == dpaa_sec_pmd)
786 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC;
787 else if (driver_id == caam_jr_pmd)
788 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CAAM_JR;
789 else if (driver_id == mrvl_pmd)
790 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MVSAM;
791 else if (driver_id == virtio_pmd)
792 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO;
793 else if (driver_id == octeontx_pmd)
794 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OCTEONTX;
795 else if (driver_id == null_pmd)
796 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_NULL;
797 else if (driver_id == nitrox_pmd)
798 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_NITROX;
800 TEST_ASSERT(0, "Unrecognized cryptodev type");
802 for (i = 0; i < n_test_cases; i++) {
803 const struct blockcipher_test_case *tc = &tcs[i];
805 if (!(tc->pmd_mask & target_pmd_mask))
808 status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
809 sess_mpool, sess_priv_mpool, dev_id, driver_id,
812 printf(" %u) TestCase %s %s\n", test_index ++,
813 tc->test_descr, test_msg);
815 if (status != TEST_SUCCESS) {
816 if (overall_status == TEST_SUCCESS)
817 overall_status = status;
819 if (tc->feature_mask & BLOCKCIPHER_TEST_FEATURE_STOPPER)
824 return overall_status;