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));
83 rte_cryptodev_info_get(dev_id, &dev_info);
85 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
86 uint64_t feat_flags = dev_info.feature_flags;
87 uint64_t oop_flag = RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT;
89 if (t->feature_mask && BLOCKCIPHER_TEST_FEATURE_OOP) {
90 if (!(feat_flags & oop_flag)) {
91 printf("Device doesn't support out-of-place "
92 "scatter-gather in input mbuf. "
97 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
98 printf("Device doesn't support in-place "
99 "scatter-gather mbufs. "
108 if (tdata->cipher_key.len)
109 memcpy(cipher_key, tdata->cipher_key.data,
110 tdata->cipher_key.len);
111 if (tdata->auth_key.len)
112 memcpy(auth_key, tdata->auth_key.data,
113 tdata->auth_key.len);
115 if (driver_id == dpaa2_sec_pmd ||
116 driver_id == dpaa_sec_pmd ||
117 driver_id == caam_jr_pmd ||
118 driver_id == qat_pmd ||
119 driver_id == openssl_pmd ||
120 driver_id == armv8_pmd ||
121 driver_id == mrvl_pmd ||
122 driver_id == ccp_pmd ||
123 driver_id == virtio_pmd ||
124 driver_id == octeontx_pmd) { /* Fall through */
125 digest_len = tdata->digest.len;
126 } else if (driver_id == aesni_mb_pmd ||
127 driver_id == scheduler_pmd) {
128 digest_len = tdata->digest.truncated_len;
130 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
131 "line %u FAILED: %s",
132 __LINE__, "Unsupported PMD type");
133 status = TEST_FAILED;
138 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
139 buf_len += digest_len;
141 /* for contiguous mbuf, nb_segs is 1 */
142 ibuf = create_segmented_mbuf(mbuf_pool,
143 tdata->ciphertext.len, nb_segs, src_pattern);
145 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
146 "line %u FAILED: %s",
147 __LINE__, "Cannot create source mbuf");
148 status = TEST_FAILED;
152 /* only encryption requires plaintext.data input,
153 * decryption/(digest gen)/(digest verify) use ciphertext.data
156 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
157 pktmbuf_write(ibuf, 0, tdata->plaintext.len,
158 tdata->plaintext.data);
160 pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
161 tdata->ciphertext.data);
163 buf_p = rte_pktmbuf_append(ibuf, digest_len);
164 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
165 rte_memcpy(buf_p, tdata->digest.data, digest_len);
167 memset(buf_p, 0, digest_len);
169 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
170 obuf = rte_pktmbuf_alloc(mbuf_pool);
172 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
173 "FAILED: %s", __LINE__,
174 "Allocation of rte_mbuf failed");
175 status = TEST_FAILED;
178 memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
180 buf_p = rte_pktmbuf_append(obuf, buf_len);
182 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
183 "FAILED: %s", __LINE__,
184 "No room to append mbuf");
185 status = TEST_FAILED;
188 memset(buf_p, 0, buf_len);
191 /* Generate Crypto op data structure */
192 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
194 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
195 "line %u FAILED: %s",
196 __LINE__, "Failed to allocate symmetric crypto "
198 status = TEST_FAILED;
204 sym_op->m_src = ibuf;
206 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
207 sym_op->m_dst = obuf;
210 sym_op->m_dst = NULL;
214 /* sessionless op requires allocate xform using
215 * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
218 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
219 uint32_t n_xforms = 0;
221 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
223 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
226 if (rte_crypto_op_sym_xforms_alloc(op, n_xforms)
228 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
229 "FAILED: %s", __LINE__, "Failed to "
230 "allocate space for crypto transforms");
231 status = TEST_FAILED;
235 cipher_xform = rte_zmalloc(NULL,
236 sizeof(struct rte_crypto_sym_xform), 0);
238 auth_xform = rte_zmalloc(NULL,
239 sizeof(struct rte_crypto_sym_xform), 0);
241 if (!cipher_xform || !auth_xform) {
242 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
243 "FAILED: %s", __LINE__, "Failed to "
244 "allocate memory for crypto transforms");
245 status = TEST_FAILED;
250 /* preparing xform, for sessioned op, init_xform is initialized
251 * here and later as param in rte_cryptodev_sym_session_create() call
253 if (t->op_mask == BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN) {
254 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
255 cipher_xform = op->sym->xform;
256 auth_xform = cipher_xform->next;
257 auth_xform->next = NULL;
259 cipher_xform->next = auth_xform;
260 auth_xform->next = NULL;
261 init_xform = cipher_xform;
263 } else if (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC) {
264 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
265 auth_xform = op->sym->xform;
266 cipher_xform = auth_xform->next;
267 cipher_xform->next = NULL;
269 auth_xform->next = cipher_xform;
270 cipher_xform->next = NULL;
271 init_xform = auth_xform;
273 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_ENCRYPT) ||
274 (t->op_mask == BLOCKCIPHER_TEST_OP_DECRYPT)) {
275 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
276 cipher_xform = op->sym->xform;
278 init_xform = cipher_xform;
279 cipher_xform->next = NULL;
280 } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_GEN) ||
281 (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY)) {
282 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
283 auth_xform = op->sym->xform;
285 init_xform = auth_xform;
286 auth_xform->next = NULL;
288 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
289 "line %u FAILED: %s",
290 __LINE__, "Unrecognized operation");
291 status = TEST_FAILED;
295 /*configure xforms & sym_op cipher and auth data*/
296 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
297 cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
298 cipher_xform->cipher.algo = tdata->crypto_algo;
299 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
300 cipher_xform->cipher.op =
301 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
303 cipher_xform->cipher.op =
304 RTE_CRYPTO_CIPHER_OP_DECRYPT;
305 cipher_xform->cipher.key.data = cipher_key;
306 cipher_xform->cipher.key.length = tdata->cipher_key.len;
307 cipher_xform->cipher.iv.offset = IV_OFFSET;
308 cipher_xform->cipher.iv.length = tdata->iv.len;
310 sym_op->cipher.data.offset = 0;
311 sym_op->cipher.data.length = tdata->ciphertext.len;
312 rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
317 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
318 uint32_t digest_offset = tdata->ciphertext.len;
320 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
321 auth_xform->auth.algo = tdata->auth_algo;
322 auth_xform->auth.key.length = tdata->auth_key.len;
323 auth_xform->auth.key.data = auth_key;
324 auth_xform->auth.digest_length = digest_len;
326 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
327 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
328 sym_op->auth.digest.data = pktmbuf_mtod_offset
329 (iobuf, digest_offset);
330 sym_op->auth.digest.phys_addr =
331 pktmbuf_iova_offset(iobuf,
334 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
335 sym_op->auth.digest.data = pktmbuf_mtod_offset
336 (sym_op->m_src, digest_offset);
337 sym_op->auth.digest.phys_addr =
338 pktmbuf_iova_offset(sym_op->m_src,
342 sym_op->auth.data.offset = 0;
343 sym_op->auth.data.length = tdata->ciphertext.len;
346 /* create session for sessioned op */
347 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
348 sess = rte_cryptodev_sym_session_create(sess_mpool);
350 rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
353 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
354 "FAILED: %s", __LINE__,
355 "Session creation failed");
356 status = TEST_FAILED;
360 /* attach symmetric crypto session to crypto operations */
361 rte_crypto_op_attach_sym_session(op, sess);
364 debug_hexdump(stdout, "m_src(before):",
365 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
366 rte_memcpy(tmp_src_buf, sym_op->m_src->buf_addr,
367 sym_op->m_src->buf_len);
368 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
369 debug_hexdump(stdout, "m_dst(before):",
370 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
371 rte_memcpy(tmp_dst_buf, sym_op->m_dst->buf_addr,
372 sym_op->m_dst->buf_len);
375 /* Process crypto operation */
376 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
377 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
378 "line %u FAILED: %s",
379 __LINE__, "Error sending packet for encryption");
380 status = TEST_FAILED;
386 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
390 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
391 "line %u FAILED: %s",
392 __LINE__, "Failed to process sym crypto op");
393 status = TEST_FAILED;
397 debug_hexdump(stdout, "m_src(after):",
398 sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
399 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP)
400 debug_hexdump(stdout, "m_dst(after):",
401 sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
404 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
405 if ((t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) &&
406 (op->status == RTE_CRYPTO_OP_STATUS_AUTH_FAILED))
407 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
408 "FAILED: Digest verification failed "
409 "(0x%X)", __LINE__, op->status);
411 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
412 "FAILED: Operation failed "
413 "(0x%X)", __LINE__, op->status);
414 status = TEST_FAILED;
418 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
419 uint8_t buffer[2048];
420 const uint8_t *compare_ref;
421 uint32_t compare_len;
423 if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) {
424 compare_ref = tdata->ciphertext.data;
425 compare_len = tdata->ciphertext.len;
427 compare_ref = tdata->plaintext.data;
428 compare_len = tdata->plaintext.len;
431 if (memcmp(rte_pktmbuf_read(iobuf, 0, compare_len,
432 buffer), compare_ref, compare_len)) {
433 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
434 "FAILED: %s", __LINE__,
435 "Crypto data not as expected");
436 status = TEST_FAILED;
441 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
442 uint8_t *auth_res = pktmbuf_mtod_offset(iobuf,
443 tdata->ciphertext.len);
445 if (memcmp(auth_res, tdata->digest.data, digest_len)) {
446 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
447 "FAILED: %s", __LINE__, "Generated "
448 "digest data not as expected");
449 status = TEST_FAILED;
454 /* The only parts that should have changed in the buffer are
455 * plaintext/ciphertext and digest.
456 * In OOP only the dest buffer should change.
458 if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
459 struct rte_mbuf *mbuf;
461 uint32_t head_unchanged_len, changed_len = 0;
463 uint32_t hdroom_used = 0, tlroom_used = 0;
466 mbuf = sym_op->m_src;
468 * Crypto PMDs specify the headroom & tailroom it would use
469 * when processing the crypto operation. PMD is free to modify
470 * this space, and so the verification check should skip that
473 hdroom_used = dev_info.min_mbuf_headroom_req;
474 tlroom_used = dev_info.min_mbuf_tailroom_req;
477 hdroom = rte_pktmbuf_headroom(mbuf);
479 head_unchanged_len = mbuf->buf_len;
481 for (i = 0; i < mbuf->buf_len; i++) {
483 /* Skip headroom used by PMD */
484 if (i == hdroom - hdroom_used)
487 /* Skip tailroom used by PMD */
488 if (i == (hdroom + mbuf->data_len))
491 value = *((uint8_t *)(mbuf->buf_addr)+i);
492 if (value != tmp_src_buf[i]) {
493 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
494 "line %u FAILED: OOP src outer mbuf data (0x%x) not as expected (0x%x)",
495 __LINE__, value, tmp_src_buf[i]);
496 status = TEST_FAILED;
501 mbuf = sym_op->m_dst;
502 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
503 head_unchanged_len = hdroom + sym_op->auth.data.offset;
504 changed_len = sym_op->auth.data.length;
505 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
506 changed_len += digest_len;
509 head_unchanged_len = hdroom +
510 sym_op->cipher.data.offset;
511 changed_len = sym_op->cipher.data.length;
514 for (i = 0; i < mbuf->buf_len; i++) {
515 if (i == head_unchanged_len)
517 value = *((uint8_t *)(mbuf->buf_addr)+i);
518 if (value != tmp_dst_buf[i]) {
519 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
520 "line %u FAILED: OOP dst outer mbuf data "
521 "(0x%x) not as expected (0x%x)",
522 __LINE__, value, tmp_dst_buf[i]);
523 status = TEST_FAILED;
528 /* In-place operation */
529 struct rte_mbuf *mbuf;
531 uint32_t head_unchanged_len = 0, changed_len = 0;
533 uint32_t hdroom_used = 0, tlroom_used = 0;
537 * Crypto PMDs specify the headroom & tailroom it would use
538 * when processing the crypto operation. PMD is free to modify
539 * this space, and so the verification check should skip that
542 hdroom_used = dev_info.min_mbuf_headroom_req;
543 tlroom_used = dev_info.min_mbuf_tailroom_req;
545 mbuf = sym_op->m_src;
548 hdroom = rte_pktmbuf_headroom(mbuf);
550 if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
551 head_unchanged_len = hdroom +
552 sym_op->cipher.data.offset;
553 changed_len = sym_op->cipher.data.length;
556 head_unchanged_len = hdroom +
557 sym_op->auth.data.offset +
558 sym_op->auth.data.length;
562 if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
563 changed_len += digest_len;
565 for (i = 0; i < mbuf->buf_len; i++) {
567 /* Skip headroom used by PMD */
568 if (i == hdroom - hdroom_used)
571 if (i == head_unchanged_len)
574 /* Skip tailroom used by PMD */
575 if (i == (hdroom + mbuf->data_len))
578 value = *((uint8_t *)(mbuf->buf_addr)+i);
579 if (value != tmp_src_buf[i]) {
580 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
581 "line %u FAILED: outer mbuf data (0x%x) "
582 "not as expected (0x%x)",
583 __LINE__, value, tmp_src_buf[i]);
584 status = TEST_FAILED;
590 snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "PASS");
593 if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
595 rte_cryptodev_sym_session_clear(dev_id, sess);
596 rte_cryptodev_sym_session_free(sess);
599 rte_free(cipher_xform);
601 rte_free(auth_xform);
605 rte_crypto_op_free(op);
608 rte_pktmbuf_free(obuf);
611 rte_pktmbuf_free(ibuf);
617 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
618 struct rte_mempool *op_mpool,
619 struct rte_mempool *sess_mpool,
620 struct rte_mempool *sess_priv_mpool,
623 enum blockcipher_test_type test_type)
625 int status, overall_status = TEST_SUCCESS;
626 uint32_t i, test_index = 0;
627 char test_msg[BLOCKCIPHER_TEST_MSG_LEN + 1];
628 uint32_t n_test_cases = 0;
629 uint32_t target_pmd_mask = 0;
630 const struct blockcipher_test_case *tcs = NULL;
632 int openssl_pmd = rte_cryptodev_driver_id_get(
633 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
634 int ccp_pmd = rte_cryptodev_driver_id_get(
635 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
636 int dpaa2_sec_pmd = rte_cryptodev_driver_id_get(
637 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
638 int dpaa_sec_pmd = rte_cryptodev_driver_id_get(
639 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
640 int caam_jr_pmd = rte_cryptodev_driver_id_get(
641 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
642 int scheduler_pmd = rte_cryptodev_driver_id_get(
643 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
644 int armv8_pmd = rte_cryptodev_driver_id_get(
645 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
646 int aesni_mb_pmd = rte_cryptodev_driver_id_get(
647 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
648 int qat_pmd = rte_cryptodev_driver_id_get(
649 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
650 int mrvl_pmd = rte_cryptodev_driver_id_get(
651 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
652 int virtio_pmd = rte_cryptodev_driver_id_get(
653 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
654 int octeontx_pmd = rte_cryptodev_driver_id_get(
655 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
658 case BLKCIPHER_AES_CHAIN_TYPE:
659 n_test_cases = sizeof(aes_chain_test_cases) /
660 sizeof(aes_chain_test_cases[0]);
661 tcs = aes_chain_test_cases;
663 case BLKCIPHER_AES_CIPHERONLY_TYPE:
664 n_test_cases = sizeof(aes_cipheronly_test_cases) /
665 sizeof(aes_cipheronly_test_cases[0]);
666 tcs = aes_cipheronly_test_cases;
668 case BLKCIPHER_AES_DOCSIS_TYPE:
669 n_test_cases = sizeof(aes_docsis_test_cases) /
670 sizeof(aes_docsis_test_cases[0]);
671 tcs = aes_docsis_test_cases;
673 case BLKCIPHER_3DES_CHAIN_TYPE:
674 n_test_cases = sizeof(triple_des_chain_test_cases) /
675 sizeof(triple_des_chain_test_cases[0]);
676 tcs = triple_des_chain_test_cases;
678 case BLKCIPHER_3DES_CIPHERONLY_TYPE:
679 n_test_cases = sizeof(triple_des_cipheronly_test_cases) /
680 sizeof(triple_des_cipheronly_test_cases[0]);
681 tcs = triple_des_cipheronly_test_cases;
683 case BLKCIPHER_DES_CIPHERONLY_TYPE:
684 n_test_cases = sizeof(des_cipheronly_test_cases) /
685 sizeof(des_cipheronly_test_cases[0]);
686 tcs = des_cipheronly_test_cases;
688 case BLKCIPHER_DES_DOCSIS_TYPE:
689 n_test_cases = sizeof(des_docsis_test_cases) /
690 sizeof(des_docsis_test_cases[0]);
691 tcs = des_docsis_test_cases;
693 case BLKCIPHER_AUTHONLY_TYPE:
694 n_test_cases = sizeof(hash_test_cases) /
695 sizeof(hash_test_cases[0]);
696 tcs = hash_test_cases;
702 if (driver_id == aesni_mb_pmd)
703 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB;
704 else if (driver_id == qat_pmd)
705 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT;
706 else if (driver_id == openssl_pmd)
707 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL;
708 else if (driver_id == armv8_pmd)
709 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8;
710 else if (driver_id == scheduler_pmd)
711 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER;
712 else if (driver_id == dpaa2_sec_pmd)
713 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC;
714 else if (driver_id == ccp_pmd)
715 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CCP;
716 else if (driver_id == dpaa_sec_pmd)
717 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC;
718 else if (driver_id == caam_jr_pmd)
719 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_CAAM_JR;
720 else if (driver_id == mrvl_pmd)
721 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MVSAM;
722 else if (driver_id == virtio_pmd)
723 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO;
724 else if (driver_id == octeontx_pmd)
725 target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OCTEONTX;
727 TEST_ASSERT(0, "Unrecognized cryptodev type");
729 for (i = 0; i < n_test_cases; i++) {
730 const struct blockcipher_test_case *tc = &tcs[i];
732 if (!(tc->pmd_mask & target_pmd_mask))
735 status = test_blockcipher_one_case(tc, mbuf_pool, op_mpool,
736 sess_mpool, sess_priv_mpool, dev_id, driver_id,
739 printf(" %u) TestCase %s %s\n", test_index ++,
740 tc->test_descr, test_msg);
742 if (status != TEST_SUCCESS) {
743 if (overall_status == TEST_SUCCESS)
744 overall_status = status;
746 if (tc->feature_mask & BLOCKCIPHER_TEST_FEATURE_STOPPER)
751 return overall_status;