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,
32 struct rte_mbuf *ibuf = NULL;
33 struct rte_mbuf *obuf = NULL;
34 struct rte_mbuf *iobuf;
35 struct rte_crypto_sym_xform *cipher_xform = NULL;
36 struct rte_crypto_sym_xform *auth_xform = NULL;
37 struct rte_crypto_sym_xform *init_xform = NULL;
38 struct rte_crypto_sym_op *sym_op = NULL;
39 struct rte_crypto_op *op = NULL;
40 struct rte_cryptodev_info dev_info;
41 struct rte_cryptodev_sym_session *sess = NULL;
43 int status = TEST_SUCCESS;
44 const struct blockcipher_test_data *tdata = t->test_data;
45 uint8_t cipher_key[tdata->cipher_key.len];
46 uint8_t auth_key[tdata->auth_key.len];
47 uint32_t buf_len = tdata->ciphertext.len;
48 uint32_t digest_len = 0;
50 uint8_t src_pattern = 0xa5;
51 uint8_t dst_pattern = 0xb6;
52 uint8_t tmp_src_buf[MBUF_SIZE];
53 uint8_t tmp_dst_buf[MBUF_SIZE];
55 int openssl_pmd = rte_cryptodev_driver_id_get(
56 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
57 int ccp_pmd = rte_cryptodev_driver_id_get(
58 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
59 int scheduler_pmd = rte_cryptodev_driver_id_get(
60 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
61 int armv8_pmd = rte_cryptodev_driver_id_get(
62 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
63 int aesni_mb_pmd = rte_cryptodev_driver_id_get(
64 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
65 int qat_pmd = rte_cryptodev_driver_id_get(
66 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
67 int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
68 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
69 int dpaa_sec_pmd = rte_cryptodev_driver_id_get(
70 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
71 int caam_jr_pmd = rte_cryptodev_driver_id_get(
72 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
73 int mrvl_pmd = rte_cryptodev_driver_id_get(
74 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
75 int virtio_pmd = rte_cryptodev_driver_id_get(
76 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
77 int octeontx_pmd = rte_cryptodev_driver_id_get(
78 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
82 rte_cryptodev_info_get(dev_id, &dev_info);
84 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
85 uint64_t feat_flags = dev_info.feature_flags;
86 uint64_t oop_flag = RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT;
88 if (t->feature_mask && BLOCKCIPHER_TEST_FEATURE_OOP) {
89 if (!(feat_flags & oop_flag)) {
90 printf("Device doesn't support out-of-place "
91 "scatter-gather in input mbuf. "
96 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
97 printf("Device doesn't support in-place "
98 "scatter-gather mbufs. "
107 if (tdata->cipher_key.len)
108 memcpy(cipher_key, tdata->cipher_key.data,
109 tdata->cipher_key.len);
110 if (tdata->auth_key.len)
111 memcpy(auth_key, tdata->auth_key.data,
112 tdata->auth_key.len);
114 if (driver_id == dpaa2_sec_pmd ||
115 driver_id == dpaa_sec_pmd ||
116 driver_id == caam_jr_pmd ||
117 driver_id == qat_pmd ||
118 driver_id == openssl_pmd ||
119 driver_id == armv8_pmd ||
120 driver_id == mrvl_pmd ||
121 driver_id == ccp_pmd ||
122 driver_id == virtio_pmd ||
123 driver_id == octeontx_pmd) { /* Fall through */
124 digest_len = tdata->digest.len;
125 } else if (driver_id == aesni_mb_pmd ||
126 driver_id == scheduler_pmd) {
127 digest_len = tdata->digest.truncated_len;
129 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
130 "line %u FAILED: %s",
131 __LINE__, "Unsupported PMD type");
132 status = TEST_FAILED;
137 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
138 buf_len += digest_len;
140 /* for contiguous mbuf, nb_segs is 1 */
141 ibuf = create_segmented_mbuf(mbuf_pool,
142 tdata->ciphertext.len, nb_segs, src_pattern);
144 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
145 "line %u FAILED: %s",
146 __LINE__, "Cannot create source mbuf");
147 status = TEST_FAILED;
151 /* only encryption requires plaintext.data input,
152 * decryption/(digest gen)/(digest verify) use ciphertext.data
155 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
156 pktmbuf_write(ibuf, 0, tdata->plaintext.len,
157 tdata->plaintext.data);
159 pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
160 tdata->ciphertext.data);
162 buf_p = rte_pktmbuf_append(ibuf, digest_len);
163 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
164 rte_memcpy(buf_p, tdata->digest.data, digest_len);
166 memset(buf_p, 0, digest_len);
168 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
169 obuf = rte_pktmbuf_alloc(mbuf_pool);
171 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
172 "FAILED: %s", __LINE__,
173 "Allocation of rte_mbuf failed");
174 status = TEST_FAILED;
177 memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
179 buf_p = rte_pktmbuf_append(obuf, buf_len);
181 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
182 "FAILED: %s", __LINE__,
183 "No room to append mbuf");
184 status = TEST_FAILED;
187 memset(buf_p, 0, buf_len);
190 /* Generate Crypto op data structure */
191 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
193 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
194 "line %u FAILED: %s",
195 __LINE__, "Failed to allocate symmetric crypto "
197 status = TEST_FAILED;
203 sym_op->m_src = ibuf;
205 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
206 sym_op->m_dst = obuf;
209 sym_op->m_dst = NULL;
213 /* sessionless op requires allocate xform using
214 * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
217 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
218 uint32_t n_xforms = 0;
220 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
222 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
225 if (rte_crypto_op_sym_xforms_alloc(op, n_xforms)
227 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
228 "FAILED: %s", __LINE__, "Failed to "
229 "allocate space for crypto transforms");
230 status = TEST_FAILED;
234 cipher_xform = rte_zmalloc(NULL,
235 sizeof(struct rte_crypto_sym_xform), 0);
237 auth_xform = rte_zmalloc(NULL,
238 sizeof(struct rte_crypto_sym_xform), 0);
240 if (!cipher_xform || !auth_xform) {
241 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
242 "FAILED: %s", __LINE__, "Failed to "
243 "allocate memory for crypto transforms");
244 status = TEST_FAILED;
249 /* preparing xform, for sessioned op, init_xform is initialized
250 * here and later as param in rte_cryptodev_sym_session_create() call
252 if (t->op_mask == BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN) {
253 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
254 cipher_xform = op->sym->xform;
255 auth_xform = cipher_xform->next;
256 auth_xform->next = NULL;
258 cipher_xform->next = auth_xform;
259 auth_xform->next = NULL;
260 init_xform = cipher_xform;
262 } else if (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC) {
263 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
264 auth_xform = op->sym->xform;
265 cipher_xform = auth_xform->next;
266 cipher_xform->next = NULL;
268 auth_xform->next = cipher_xform;
269 cipher_xform->next = NULL;
270 init_xform = auth_xform;
272 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_ENCRYPT) ||
273 (t->op_mask == BLOCKCIPHER_TEST_OP_DECRYPT)) {
274 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
275 cipher_xform = op->sym->xform;
277 init_xform = cipher_xform;
278 cipher_xform->next = NULL;
279 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_GEN) ||
280 (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY)) {
281 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
282 auth_xform = op->sym->xform;
284 init_xform = auth_xform;
285 auth_xform->next = NULL;
287 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
288 "line %u FAILED: %s",
289 __LINE__, "Unrecognized operation");
290 status = TEST_FAILED;
294 /*configure xforms & sym_op cipher and auth data*/
295 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
296 cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
297 cipher_xform->cipher.algo = tdata->crypto_algo;
298 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
299 cipher_xform->cipher.op =
300 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
302 cipher_xform->cipher.op =
303 RTE_CRYPTO_CIPHER_OP_DECRYPT;
304 cipher_xform->cipher.key.data = cipher_key;
305 cipher_xform->cipher.key.length = tdata->cipher_key.len;
306 cipher_xform->cipher.iv.offset = IV_OFFSET;
307 cipher_xform->cipher.iv.length = tdata->iv.len;
309 sym_op->cipher.data.offset = 0;
310 sym_op->cipher.data.length = tdata->ciphertext.len;
311 rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
316 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
317 uint32_t digest_offset = tdata->ciphertext.len;
319 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
320 auth_xform->auth.algo = tdata->auth_algo;
321 auth_xform->auth.key.length = tdata->auth_key.len;
322 auth_xform->auth.key.data = auth_key;
323 auth_xform->auth.digest_length = digest_len;
325 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
326 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
327 sym_op->auth.digest.data = pktmbuf_mtod_offset
328 (iobuf, digest_offset);
329 sym_op->auth.digest.phys_addr =
330 pktmbuf_iova_offset(iobuf,
333 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
334 sym_op->auth.digest.data = pktmbuf_mtod_offset
335 (sym_op->m_src, digest_offset);
336 sym_op->auth.digest.phys_addr =
337 pktmbuf_iova_offset(sym_op->m_src,
341 sym_op->auth.data.offset = 0;
342 sym_op->auth.data.length = tdata->ciphertext.len;
345 /* create session for sessioned op */
346 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
347 sess = rte_cryptodev_sym_session_create(sess_mpool);
349 rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
352 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
353 "FAILED: %s", __LINE__,
354 "Session creation failed");
355 status = TEST_FAILED;
359 /* attach symmetric crypto session to crypto operations */
360 rte_crypto_op_attach_sym_session(op, sess);
363 debug_hexdump(stdout, "m_src(before):",
364 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
365 rte_memcpy(tmp_src_buf, sym_op->m_src->buf_addr,
366 sym_op->m_src->buf_len);
367 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
368 debug_hexdump(stdout, "m_dst(before):",
369 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
370 rte_memcpy(tmp_dst_buf, sym_op->m_dst->buf_addr,
371 sym_op->m_dst->buf_len);
374 /* Process crypto operation */
375 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
376 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
377 "line %u FAILED: %s",
378 __LINE__, "Error sending packet for encryption");
379 status = TEST_FAILED;
385 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
389 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
390 "line %u FAILED: %s",
391 __LINE__, "Failed to process sym crypto op");
392 status = TEST_FAILED;
396 debug_hexdump(stdout, "m_src(after):",
397 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
398 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP)
399 debug_hexdump(stdout, "m_dst(after):",
400 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
403 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
404 if ((t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) &&
405 (op->status == RTE_CRYPTO_OP_STATUS_AUTH_FAILED))
406 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
407 "FAILED: Digest verification failed "
408 "(0x%X)", __LINE__, op->status);
410 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
411 "FAILED: Operation failed "
412 "(0x%X)", __LINE__, op->status);
413 status = TEST_FAILED;
417 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
418 uint8_t buffer[2048];
419 const uint8_t *compare_ref;
420 uint32_t compare_len;
422 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) {
423 compare_ref = tdata->ciphertext.data;
424 compare_len = tdata->ciphertext.len;
426 compare_ref = tdata->plaintext.data;
427 compare_len = tdata->plaintext.len;
430 if (memcmp(rte_pktmbuf_read(iobuf, 0, compare_len,
431 buffer), compare_ref, compare_len)) {
432 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
433 "FAILED: %s", __LINE__,
434 "Crypto data not as expected");
435 status = TEST_FAILED;
440 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
441 uint8_t *auth_res = pktmbuf_mtod_offset(iobuf,
442 tdata->ciphertext.len);
444 if (memcmp(auth_res, tdata->digest.data, digest_len)) {
445 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
446 "FAILED: %s", __LINE__, "Generated "
447 "digest data not as expected");
448 status = TEST_FAILED;
453 /* The only parts that should have changed in the buffer are
454 * plaintext/ciphertext and digest.
455 * In OOP only the dest buffer should change.
457 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
458 struct rte_mbuf *mbuf;
460 uint32_t head_unchanged_len, changed_len = 0;
462 uint32_t hdroom_used = 0, tlroom_used = 0;
465 mbuf = sym_op->m_src;
467 * Crypto PMDs specify the headroom & tailroom it would use
468 * when processing the crypto operation. PMD is free to modify
469 * this space, and so the verification check should skip that
472 hdroom_used = dev_info.min_mbuf_headroom_req;
473 tlroom_used = dev_info.min_mbuf_tailroom_req;
476 hdroom = rte_pktmbuf_headroom(mbuf);
478 head_unchanged_len = mbuf->buf_len;
480 for (i = 0; i < mbuf->buf_len; i++) {
482 /* Skip headroom used by PMD */
483 if (i == hdroom - hdroom_used)
486 /* Skip tailroom used by PMD */
487 if (i == (hdroom + mbuf->data_len))
490 value = *((uint8_t *)(mbuf->buf_addr)+i);
491 if (value != tmp_src_buf[i]) {
492 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
493 "line %u FAILED: OOP src outer mbuf data (0x%x) not as expected (0x%x)",
494 __LINE__, value, tmp_src_buf[i]);
495 status = TEST_FAILED;
500 mbuf = sym_op->m_dst;
501 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
502 head_unchanged_len = hdroom + sym_op->auth.data.offset;
503 changed_len = sym_op->auth.data.length;
504 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
505 changed_len += digest_len;
508 head_unchanged_len = hdroom +
509 sym_op->cipher.data.offset;
510 changed_len = sym_op->cipher.data.length;
513 for (i = 0; i < mbuf->buf_len; i++) {
514 if (i == head_unchanged_len)
516 value = *((uint8_t *)(mbuf->buf_addr)+i);
517 if (value != tmp_dst_buf[i]) {
518 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
519 "line %u FAILED: OOP dst outer mbuf data "
520 "(0x%x) not as expected (0x%x)",
521 __LINE__, value, tmp_dst_buf[i]);
522 status = TEST_FAILED;
527 /* In-place operation */
528 struct rte_mbuf *mbuf;
530 uint32_t head_unchanged_len = 0, changed_len = 0;
532 uint32_t hdroom_used = 0, tlroom_used = 0;
536 * Crypto PMDs specify the headroom & tailroom it would use
537 * when processing the crypto operation. PMD is free to modify
538 * this space, and so the verification check should skip that
541 hdroom_used = dev_info.min_mbuf_headroom_req;
542 tlroom_used = dev_info.min_mbuf_tailroom_req;
544 mbuf = sym_op->m_src;
547 hdroom = rte_pktmbuf_headroom(mbuf);
549 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
550 head_unchanged_len = hdroom +
551 sym_op->cipher.data.offset;
552 changed_len = sym_op->cipher.data.length;
555 head_unchanged_len = hdroom +
556 sym_op->auth.data.offset +
557 sym_op->auth.data.length;
561 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
562 changed_len += digest_len;
564 for (i = 0; i < mbuf->buf_len; i++) {
566 /* Skip headroom used by PMD */
567 if (i == hdroom - hdroom_used)
570 if (i == head_unchanged_len)
573 /* Skip tailroom used by PMD */
574 if (i == (hdroom + mbuf->data_len))
577 value = *((uint8_t *)(mbuf->buf_addr)+i);
578 if (value != tmp_src_buf[i]) {
579 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
580 "line %u FAILED: outer mbuf data (0x%x) "
581 "not as expected (0x%x)",
582 __LINE__, value, tmp_src_buf[i]);
583 status = TEST_FAILED;
589 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "PASS");
592 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
594 rte_cryptodev_sym_session_clear(dev_id, sess);
595 rte_cryptodev_sym_session_free(sess);
598 rte_free(cipher_xform);
600 rte_free(auth_xform);
604 rte_crypto_op_free(op);
607 rte_pktmbuf_free(obuf);
610 rte_pktmbuf_free(ibuf);
616 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
617 struct rte_mempool *op_mpool,
618 struct rte_mempool *sess_mpool,
621 enum blockcipher_test_type test_type)
623 int status, overall_status = TEST_SUCCESS;
624 uint32_t i, test_index = 0;
625 char test_msg[BLOCKCIPHER_TEST_MSG_LEN + 1];
626 uint32_t n_test_cases = 0;
627 uint32_t target_pmd_mask = 0;
628 const struct blockcipher_test_case *tcs = NULL;
630 int openssl_pmd = rte_cryptodev_driver_id_get(
631 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
632 int ccp_pmd = rte_cryptodev_driver_id_get(
633 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
634 int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
635 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
636 int dpaa_sec_pmd = rte_cryptodev_driver_id_get(
637 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
638 int caam_jr_pmd = rte_cryptodev_driver_id_get(
639 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
640 int scheduler_pmd = rte_cryptodev_driver_id_get(
641 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
642 int armv8_pmd = rte_cryptodev_driver_id_get(
643 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
644 int aesni_mb_pmd = rte_cryptodev_driver_id_get(
645 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
646 int qat_pmd = rte_cryptodev_driver_id_get(
647 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
648 int mrvl_pmd = rte_cryptodev_driver_id_get(
649 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
650 int virtio_pmd = rte_cryptodev_driver_id_get(
651 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
652 int octeontx_pmd = rte_cryptodev_driver_id_get(
653 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
656 case BLKCIPHER_AES_CHAIN_TYPE:
657 n_test_cases = sizeof(aes_chain_test_cases) /
658 sizeof(aes_chain_test_cases[0]);
659 tcs = aes_chain_test_cases;
661 case BLKCIPHER_AES_CIPHERONLY_TYPE:
662 n_test_cases = sizeof(aes_cipheronly_test_cases) /
663 sizeof(aes_cipheronly_test_cases[0]);
664 tcs = aes_cipheronly_test_cases;
666 case BLKCIPHER_AES_DOCSIS_TYPE:
667 n_test_cases = sizeof(aes_docsis_test_cases) /
668 sizeof(aes_docsis_test_cases[0]);
669 tcs = aes_docsis_test_cases;
671 case BLKCIPHER_3DES_CHAIN_TYPE:
672 n_test_cases = sizeof(triple_des_chain_test_cases) /
673 sizeof(triple_des_chain_test_cases[0]);
674 tcs = triple_des_chain_test_cases;
676 case BLKCIPHER_3DES_CIPHERONLY_TYPE:
677 n_test_cases = sizeof(triple_des_cipheronly_test_cases) /
678 sizeof(triple_des_cipheronly_test_cases[0]);
679 tcs = triple_des_cipheronly_test_cases;
681 case BLKCIPHER_DES_CIPHERONLY_TYPE:
682 n_test_cases = sizeof(des_cipheronly_test_cases) /
683 sizeof(des_cipheronly_test_cases[0]);
684 tcs = des_cipheronly_test_cases;
686 case BLKCIPHER_DES_DOCSIS_TYPE:
687 n_test_cases = sizeof(des_docsis_test_cases) /
688 sizeof(des_docsis_test_cases[0]);
689 tcs = des_docsis_test_cases;
691 case BLKCIPHER_AUTHONLY_TYPE:
692 n_test_cases = sizeof(hash_test_cases) /
693 sizeof(hash_test_cases[0]);
694 tcs = hash_test_cases;
700 if (driver_id == aesni_mb_pmd)
701 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB;
702 else if (driver_id == qat_pmd)
703 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT;
704 else if (driver_id == openssl_pmd)
705 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL;
706 else if (driver_id == armv8_pmd)
707 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8;
708 else if (driver_id == scheduler_pmd)
709 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER;
710 else if (driver_id == dpaa2_sec_pmd)
711 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC;
712 else if (driver_id == ccp_pmd)
713 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CCP;
714 else if (driver_id == dpaa_sec_pmd)
715 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC;
716 else if (driver_id == caam_jr_pmd)
717 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CAAM_JR;
718 else if (driver_id == mrvl_pmd)
719 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MVSAM;
720 else if (driver_id == virtio_pmd)
721 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO;
722 else if (driver_id == octeontx_pmd)
723 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OCTEONTX;
725 TEST_ASSERT(0, "Unrecognized cryptodev type");
727 for (i = 0; i < n_test_cases; i++) {
728 const struct blockcipher_test_case *tc = &tcs[i];
730 if (!(tc->pmd_mask & target_pmd_mask))
733 status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
734 sess_mpool, dev_id, driver_id, test_msg);
736 printf(" %u) TestCase %s %s\n", test_index ++,
737 tc->test_descr, test_msg);
739 if (status != TEST_SUCCESS) {
740 if (overall_status == TEST_SUCCESS)
741 overall_status = status;
743 if (tc->feature_mask & BLOCKCIPHER_TEST_FEATURE_STOPPER)
748 return overall_status;