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 mrvl_pmd = rte_cryptodev_driver_id_get(
72 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
73 int virtio_pmd = rte_cryptodev_driver_id_get(
74 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
75 int octeontx_pmd = rte_cryptodev_driver_id_get(
76 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
80 rte_cryptodev_info_get(dev_id, &dev_info);
82 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
83 uint64_t feat_flags = dev_info.feature_flags;
84 uint64_t oop_flag = RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT;
86 if (t->feature_mask && BLOCKCIPHER_TEST_FEATURE_OOP) {
87 if (!(feat_flags & oop_flag)) {
88 printf("Device doesn't support out-of-place "
89 "scatter-gather in input mbuf. "
94 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
95 printf("Device doesn't support in-place "
96 "scatter-gather mbufs. "
105 if (tdata->cipher_key.len)
106 memcpy(cipher_key, tdata->cipher_key.data,
107 tdata->cipher_key.len);
108 if (tdata->auth_key.len)
109 memcpy(auth_key, tdata->auth_key.data,
110 tdata->auth_key.len);
112 if (driver_id == dpaa2_sec_pmd ||
113 driver_id == dpaa_sec_pmd ||
114 driver_id == qat_pmd ||
115 driver_id == openssl_pmd ||
116 driver_id == armv8_pmd ||
117 driver_id == mrvl_pmd ||
118 driver_id == ccp_pmd ||
119 driver_id == virtio_pmd ||
120 driver_id == octeontx_pmd) { /* Fall through */
121 digest_len = tdata->digest.len;
122 } else if (driver_id == aesni_mb_pmd ||
123 driver_id == scheduler_pmd) {
124 digest_len = tdata->digest.truncated_len;
126 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
127 "line %u FAILED: %s",
128 __LINE__, "Unsupported PMD type");
129 status = TEST_FAILED;
134 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
135 buf_len += digest_len;
137 /* for contiguous mbuf, nb_segs is 1 */
138 ibuf = create_segmented_mbuf(mbuf_pool,
139 tdata->ciphertext.len, nb_segs, src_pattern);
141 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
142 "line %u FAILED: %s",
143 __LINE__, "Cannot create source mbuf");
144 status = TEST_FAILED;
148 /* only encryption requires plaintext.data input,
149 * decryption/(digest gen)/(digest verify) use ciphertext.data
152 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
153 pktmbuf_write(ibuf, 0, tdata->plaintext.len,
154 tdata->plaintext.data);
156 pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
157 tdata->ciphertext.data);
159 buf_p = rte_pktmbuf_append(ibuf, digest_len);
160 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
161 rte_memcpy(buf_p, tdata->digest.data, digest_len);
163 memset(buf_p, 0, digest_len);
165 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
166 obuf = rte_pktmbuf_alloc(mbuf_pool);
168 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
169 "FAILED: %s", __LINE__,
170 "Allocation of rte_mbuf failed");
171 status = TEST_FAILED;
174 memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
176 buf_p = rte_pktmbuf_append(obuf, buf_len);
178 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
179 "FAILED: %s", __LINE__,
180 "No room to append mbuf");
181 status = TEST_FAILED;
184 memset(buf_p, 0, buf_len);
187 /* Generate Crypto op data structure */
188 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
190 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
191 "line %u FAILED: %s",
192 __LINE__, "Failed to allocate symmetric crypto "
194 status = TEST_FAILED;
200 sym_op->m_src = ibuf;
202 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
203 sym_op->m_dst = obuf;
206 sym_op->m_dst = NULL;
210 /* sessionless op requires allocate xform using
211 * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
214 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
215 uint32_t n_xforms = 0;
217 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
219 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
222 if (rte_crypto_op_sym_xforms_alloc(op, n_xforms)
224 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
225 "FAILED: %s", __LINE__, "Failed to "
226 "allocate space for crypto transforms");
227 status = TEST_FAILED;
231 cipher_xform = rte_zmalloc(NULL,
232 sizeof(struct rte_crypto_sym_xform), 0);
234 auth_xform = rte_zmalloc(NULL,
235 sizeof(struct rte_crypto_sym_xform), 0);
237 if (!cipher_xform || !auth_xform) {
238 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
239 "FAILED: %s", __LINE__, "Failed to "
240 "allocate memory for crypto transforms");
241 status = TEST_FAILED;
246 /* preparing xform, for sessioned op, init_xform is initialized
247 * here and later as param in rte_cryptodev_sym_session_create() call
249 if (t->op_mask == BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN) {
250 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
251 cipher_xform = op->sym->xform;
252 auth_xform = cipher_xform->next;
253 auth_xform->next = NULL;
255 cipher_xform->next = auth_xform;
256 auth_xform->next = NULL;
257 init_xform = cipher_xform;
259 } else if (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC) {
260 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
261 auth_xform = op->sym->xform;
262 cipher_xform = auth_xform->next;
263 cipher_xform->next = NULL;
265 auth_xform->next = cipher_xform;
266 cipher_xform->next = NULL;
267 init_xform = auth_xform;
269 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_ENCRYPT) ||
270 (t->op_mask == BLOCKCIPHER_TEST_OP_DECRYPT)) {
271 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
272 cipher_xform = op->sym->xform;
274 init_xform = cipher_xform;
275 cipher_xform->next = NULL;
276 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_GEN) ||
277 (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY)) {
278 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
279 auth_xform = op->sym->xform;
281 init_xform = auth_xform;
282 auth_xform->next = NULL;
284 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
285 "line %u FAILED: %s",
286 __LINE__, "Unrecognized operation");
287 status = TEST_FAILED;
291 /*configure xforms & sym_op cipher and auth data*/
292 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
293 cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
294 cipher_xform->cipher.algo = tdata->crypto_algo;
295 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
296 cipher_xform->cipher.op =
297 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
299 cipher_xform->cipher.op =
300 RTE_CRYPTO_CIPHER_OP_DECRYPT;
301 cipher_xform->cipher.key.data = cipher_key;
302 cipher_xform->cipher.key.length = tdata->cipher_key.len;
303 cipher_xform->cipher.iv.offset = IV_OFFSET;
304 cipher_xform->cipher.iv.length = tdata->iv.len;
306 sym_op->cipher.data.offset = 0;
307 sym_op->cipher.data.length = tdata->ciphertext.len;
308 rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
313 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
314 uint32_t digest_offset = tdata->ciphertext.len;
316 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
317 auth_xform->auth.algo = tdata->auth_algo;
318 auth_xform->auth.key.length = tdata->auth_key.len;
319 auth_xform->auth.key.data = auth_key;
320 auth_xform->auth.digest_length = digest_len;
322 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
323 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
324 sym_op->auth.digest.data = pktmbuf_mtod_offset
325 (iobuf, digest_offset);
326 sym_op->auth.digest.phys_addr =
327 pktmbuf_iova_offset(iobuf,
330 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
331 sym_op->auth.digest.data = pktmbuf_mtod_offset
332 (sym_op->m_src, digest_offset);
333 sym_op->auth.digest.phys_addr =
334 pktmbuf_iova_offset(sym_op->m_src,
338 sym_op->auth.data.offset = 0;
339 sym_op->auth.data.length = tdata->ciphertext.len;
342 /* create session for sessioned op */
343 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
344 sess = rte_cryptodev_sym_session_create(sess_mpool);
346 rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
349 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
350 "FAILED: %s", __LINE__,
351 "Session creation failed");
352 status = TEST_FAILED;
356 /* attach symmetric crypto session to crypto operations */
357 rte_crypto_op_attach_sym_session(op, sess);
360 debug_hexdump(stdout, "m_src(before):",
361 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
362 rte_memcpy(tmp_src_buf, sym_op->m_src->buf_addr,
363 sym_op->m_src->buf_len);
364 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
365 debug_hexdump(stdout, "m_dst(before):",
366 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
367 rte_memcpy(tmp_dst_buf, sym_op->m_dst->buf_addr,
368 sym_op->m_dst->buf_len);
371 /* Process crypto operation */
372 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
373 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
374 "line %u FAILED: %s",
375 __LINE__, "Error sending packet for encryption");
376 status = TEST_FAILED;
382 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
386 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
387 "line %u FAILED: %s",
388 __LINE__, "Failed to process sym crypto op");
389 status = TEST_FAILED;
393 debug_hexdump(stdout, "m_src(after):",
394 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
395 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP)
396 debug_hexdump(stdout, "m_dst(after):",
397 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
400 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
401 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
402 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
403 "FAILED: Digest verification failed "
404 "(0x%X)", __LINE__, op->status);
406 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
407 "FAILED: Digest verification failed "
408 "(0x%X)", __LINE__, op->status);
409 status = TEST_FAILED;
413 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
414 uint8_t buffer[2048];
415 const uint8_t *compare_ref;
416 uint32_t compare_len;
418 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) {
419 compare_ref = tdata->ciphertext.data;
420 compare_len = tdata->ciphertext.len;
422 compare_ref = tdata->plaintext.data;
423 compare_len = tdata->plaintext.len;
426 if (memcmp(rte_pktmbuf_read(iobuf, 0, compare_len,
427 buffer), compare_ref, compare_len)) {
428 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
429 "FAILED: %s", __LINE__,
430 "Crypto data not as expected");
431 status = TEST_FAILED;
436 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
437 uint8_t *auth_res = pktmbuf_mtod_offset(iobuf,
438 tdata->ciphertext.len);
440 if (memcmp(auth_res, tdata->digest.data, digest_len)) {
441 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
442 "FAILED: %s", __LINE__, "Generated "
443 "digest data not as expected");
444 status = TEST_FAILED;
449 /* The only parts that should have changed in the buffer are
450 * plaintext/ciphertext and digest.
451 * In OOP only the dest buffer should change.
453 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
454 struct rte_mbuf *mbuf;
456 uint32_t head_unchanged_len, changed_len = 0;
458 uint32_t hdroom_used = 0, tlroom_used = 0;
461 mbuf = sym_op->m_src;
463 * Crypto PMDs specify the headroom & tailroom it would use
464 * when processing the crypto operation. PMD is free to modify
465 * this space, and so the verification check should skip that
468 hdroom_used = dev_info.min_mbuf_headroom_req;
469 tlroom_used = dev_info.min_mbuf_tailroom_req;
472 hdroom = rte_pktmbuf_headroom(mbuf);
474 head_unchanged_len = mbuf->buf_len;
476 for (i = 0; i < mbuf->buf_len; i++) {
478 /* Skip headroom used by PMD */
479 if (i == hdroom - hdroom_used)
482 /* Skip tailroom used by PMD */
483 if (i == (hdroom + mbuf->data_len))
486 value = *((uint8_t *)(mbuf->buf_addr)+i);
487 if (value != tmp_src_buf[i]) {
488 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
489 "line %u FAILED: OOP src outer mbuf data (0x%x) not as expected (0x%x)",
490 __LINE__, value, tmp_src_buf[i]);
491 status = TEST_FAILED;
496 mbuf = sym_op->m_dst;
497 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
498 head_unchanged_len = hdroom + sym_op->auth.data.offset;
499 changed_len = sym_op->auth.data.length;
500 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
501 changed_len += digest_len;
504 head_unchanged_len = hdroom +
505 sym_op->cipher.data.offset;
506 changed_len = sym_op->cipher.data.length;
509 for (i = 0; i < mbuf->buf_len; i++) {
510 if (i == head_unchanged_len)
512 value = *((uint8_t *)(mbuf->buf_addr)+i);
513 if (value != tmp_dst_buf[i]) {
514 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
515 "line %u FAILED: OOP dst outer mbuf data "
516 "(0x%x) not as expected (0x%x)",
517 __LINE__, value, tmp_dst_buf[i]);
518 status = TEST_FAILED;
523 /* In-place operation */
524 struct rte_mbuf *mbuf;
526 uint32_t head_unchanged_len = 0, changed_len = 0;
528 uint32_t hdroom_used = 0, tlroom_used = 0;
532 * Crypto PMDs specify the headroom & tailroom it would use
533 * when processing the crypto operation. PMD is free to modify
534 * this space, and so the verification check should skip that
537 hdroom_used = dev_info.min_mbuf_headroom_req;
538 tlroom_used = dev_info.min_mbuf_tailroom_req;
540 mbuf = sym_op->m_src;
543 hdroom = rte_pktmbuf_headroom(mbuf);
545 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
546 head_unchanged_len = hdroom +
547 sym_op->cipher.data.offset;
548 changed_len = sym_op->cipher.data.length;
551 head_unchanged_len = hdroom +
552 sym_op->auth.data.offset +
553 sym_op->auth.data.length;
557 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
558 changed_len += digest_len;
560 for (i = 0; i < mbuf->buf_len; i++) {
562 /* Skip headroom used by PMD */
563 if (i == hdroom - hdroom_used)
566 if (i == head_unchanged_len)
569 /* Skip tailroom used by PMD */
570 if (i == (hdroom + mbuf->data_len))
573 value = *((uint8_t *)(mbuf->buf_addr)+i);
574 if (value != tmp_src_buf[i]) {
575 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
576 "line %u FAILED: outer mbuf data (0x%x) "
577 "not as expected (0x%x)",
578 __LINE__, value, tmp_src_buf[i]);
579 status = TEST_FAILED;
585 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "PASS");
588 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
590 rte_cryptodev_sym_session_clear(dev_id, sess);
591 rte_cryptodev_sym_session_free(sess);
594 rte_free(cipher_xform);
596 rte_free(auth_xform);
600 rte_crypto_op_free(op);
603 rte_pktmbuf_free(obuf);
606 rte_pktmbuf_free(ibuf);
612 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
613 struct rte_mempool *op_mpool,
614 struct rte_mempool *sess_mpool,
617 enum blockcipher_test_type test_type)
619 int status, overall_status = TEST_SUCCESS;
620 uint32_t i, test_index = 0;
621 char test_msg[BLOCKCIPHER_TEST_MSG_LEN + 1];
622 uint32_t n_test_cases = 0;
623 uint32_t target_pmd_mask = 0;
624 const struct blockcipher_test_case *tcs = NULL;
626 int openssl_pmd = rte_cryptodev_driver_id_get(
627 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
628 int ccp_pmd = rte_cryptodev_driver_id_get(
629 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
630 int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
631 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
632 int dpaa_sec_pmd = rte_cryptodev_driver_id_get(
633 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
634 int scheduler_pmd = rte_cryptodev_driver_id_get(
635 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
636 int armv8_pmd = rte_cryptodev_driver_id_get(
637 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
638 int aesni_mb_pmd = rte_cryptodev_driver_id_get(
639 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
640 int qat_pmd = rte_cryptodev_driver_id_get(
641 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
642 int mrvl_pmd = rte_cryptodev_driver_id_get(
643 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
644 int virtio_pmd = rte_cryptodev_driver_id_get(
645 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
646 int octeontx_pmd = rte_cryptodev_driver_id_get(
647 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
650 case BLKCIPHER_AES_CHAIN_TYPE:
651 n_test_cases = sizeof(aes_chain_test_cases) /
652 sizeof(aes_chain_test_cases[0]);
653 tcs = aes_chain_test_cases;
655 case BLKCIPHER_AES_CIPHERONLY_TYPE:
656 n_test_cases = sizeof(aes_cipheronly_test_cases) /
657 sizeof(aes_cipheronly_test_cases[0]);
658 tcs = aes_cipheronly_test_cases;
660 case BLKCIPHER_AES_DOCSIS_TYPE:
661 n_test_cases = sizeof(aes_docsis_test_cases) /
662 sizeof(aes_docsis_test_cases[0]);
663 tcs = aes_docsis_test_cases;
665 case BLKCIPHER_3DES_CHAIN_TYPE:
666 n_test_cases = sizeof(triple_des_chain_test_cases) /
667 sizeof(triple_des_chain_test_cases[0]);
668 tcs = triple_des_chain_test_cases;
670 case BLKCIPHER_3DES_CIPHERONLY_TYPE:
671 n_test_cases = sizeof(triple_des_cipheronly_test_cases) /
672 sizeof(triple_des_cipheronly_test_cases[0]);
673 tcs = triple_des_cipheronly_test_cases;
675 case BLKCIPHER_DES_CIPHERONLY_TYPE:
676 n_test_cases = sizeof(des_cipheronly_test_cases) /
677 sizeof(des_cipheronly_test_cases[0]);
678 tcs = des_cipheronly_test_cases;
680 case BLKCIPHER_DES_DOCSIS_TYPE:
681 n_test_cases = sizeof(des_docsis_test_cases) /
682 sizeof(des_docsis_test_cases[0]);
683 tcs = des_docsis_test_cases;
685 case BLKCIPHER_AUTHONLY_TYPE:
686 n_test_cases = sizeof(hash_test_cases) /
687 sizeof(hash_test_cases[0]);
688 tcs = hash_test_cases;
694 if (driver_id == aesni_mb_pmd)
695 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB;
696 else if (driver_id == qat_pmd)
697 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT;
698 else if (driver_id == openssl_pmd)
699 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL;
700 else if (driver_id == armv8_pmd)
701 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8;
702 else if (driver_id == scheduler_pmd)
703 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER;
704 else if (driver_id == dpaa2_sec_pmd)
705 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC;
706 else if (driver_id == ccp_pmd)
707 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CCP;
708 else if (driver_id == dpaa_sec_pmd)
709 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC;
710 else if (driver_id == mrvl_pmd)
711 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MVSAM;
712 else if (driver_id == virtio_pmd)
713 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO;
714 else if (driver_id == octeontx_pmd)
715 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OCTEONTX;
717 TEST_ASSERT(0, "Unrecognized cryptodev type");
719 for (i = 0; i < n_test_cases; i++) {
720 const struct blockcipher_test_case *tc = &tcs[i];
722 if (!(tc->pmd_mask & target_pmd_mask))
725 status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
726 sess_mpool, dev_id, driver_id, test_msg);
728 printf(" %u) TestCase %s %s\n", test_index ++,
729 tc->test_descr, test_msg);
731 if (status != TEST_SUCCESS) {
732 if (overall_status == TEST_SUCCESS)
733 overall_status = status;
735 if (tc->feature_mask & BLOCKCIPHER_TEST_FEATURE_STOPPER)
740 return overall_status;