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
));
78 rte_cryptodev_info_get(dev_id
, &dev_info
);
80 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SG
) {
81 uint64_t feat_flags
= dev_info
.feature_flags
;
82 uint64_t oop_flag
= RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT
;
84 if (t
->feature_mask
&& BLOCKCIPHER_TEST_FEATURE_OOP
) {
85 if (!(feat_flags
& oop_flag
)) {
86 printf("Device doesn't support out-of-place "
87 "scatter-gather in input mbuf. "
92 if (!(feat_flags
& RTE_CRYPTODEV_FF_IN_PLACE_SGL
)) {
93 printf("Device doesn't support in-place "
94 "scatter-gather mbufs. "
103 if (tdata
->cipher_key
.len
)
104 memcpy(cipher_key
, tdata
->cipher_key
.data
,
105 tdata
->cipher_key
.len
);
106 if (tdata
->auth_key
.len
)
107 memcpy(auth_key
, tdata
->auth_key
.data
,
108 tdata
->auth_key
.len
);
110 if (driver_id
== dpaa2_sec_pmd
||
111 driver_id
== dpaa_sec_pmd
||
112 driver_id
== qat_pmd
||
113 driver_id
== openssl_pmd
||
114 driver_id
== armv8_pmd
||
115 driver_id
== mrvl_pmd
||
116 driver_id
== ccp_pmd
||
117 driver_id
== virtio_pmd
) { /* Fall through */
118 digest_len
= tdata
->digest
.len
;
119 } else if (driver_id
== aesni_mb_pmd
||
120 driver_id
== scheduler_pmd
) {
121 digest_len
= tdata
->digest
.truncated_len
;
123 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
124 "line %u FAILED: %s",
125 __LINE__
, "Unsupported PMD type");
126 status
= TEST_FAILED
;
131 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH
)
132 buf_len
+= digest_len
;
134 /* for contiguous mbuf, nb_segs is 1 */
135 ibuf
= create_segmented_mbuf(mbuf_pool
,
136 tdata
->ciphertext
.len
, nb_segs
, src_pattern
);
138 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
139 "line %u FAILED: %s",
140 __LINE__
, "Cannot create source mbuf");
141 status
= TEST_FAILED
;
145 /* only encryption requires plaintext.data input,
146 * decryption/(digest gen)/(digest verify) use ciphertext.data
149 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_ENCRYPT
)
150 pktmbuf_write(ibuf
, 0, tdata
->plaintext
.len
,
151 tdata
->plaintext
.data
);
153 pktmbuf_write(ibuf
, 0, tdata
->ciphertext
.len
,
154 tdata
->ciphertext
.data
);
156 buf_p
= rte_pktmbuf_append(ibuf
, digest_len
);
157 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH_VERIFY
)
158 rte_memcpy(buf_p
, tdata
->digest
.data
, digest_len
);
160 memset(buf_p
, 0, digest_len
);
162 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_OOP
) {
163 obuf
= rte_pktmbuf_alloc(mbuf_pool
);
165 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
166 "FAILED: %s", __LINE__
,
167 "Allocation of rte_mbuf failed");
168 status
= TEST_FAILED
;
171 memset(obuf
->buf_addr
, dst_pattern
, obuf
->buf_len
);
173 buf_p
= rte_pktmbuf_append(obuf
, buf_len
);
175 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
176 "FAILED: %s", __LINE__
,
177 "No room to append mbuf");
178 status
= TEST_FAILED
;
181 memset(buf_p
, 0, buf_len
);
184 /* Generate Crypto op data structure */
185 op
= rte_crypto_op_alloc(op_mpool
, RTE_CRYPTO_OP_TYPE_SYMMETRIC
);
187 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
188 "line %u FAILED: %s",
189 __LINE__
, "Failed to allocate symmetric crypto "
191 status
= TEST_FAILED
;
197 sym_op
->m_src
= ibuf
;
199 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_OOP
) {
200 sym_op
->m_dst
= obuf
;
203 sym_op
->m_dst
= NULL
;
207 /* sessionless op requires allocate xform using
208 * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
211 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SESSIONLESS
) {
212 uint32_t n_xforms
= 0;
214 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_CIPHER
)
216 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH
)
219 if (rte_crypto_op_sym_xforms_alloc(op
, n_xforms
)
221 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
222 "FAILED: %s", __LINE__
, "Failed to "
223 "allocate space for crypto transforms");
224 status
= TEST_FAILED
;
228 cipher_xform
= rte_zmalloc(NULL
,
229 sizeof(struct rte_crypto_sym_xform
), 0);
231 auth_xform
= rte_zmalloc(NULL
,
232 sizeof(struct rte_crypto_sym_xform
), 0);
234 if (!cipher_xform
|| !auth_xform
) {
235 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
236 "FAILED: %s", __LINE__
, "Failed to "
237 "allocate memory for crypto transforms");
238 status
= TEST_FAILED
;
243 /* preparing xform, for sessioned op, init_xform is initialized
244 * here and later as param in rte_cryptodev_sym_session_create() call
246 if (t
->op_mask
== BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN
) {
247 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SESSIONLESS
) {
248 cipher_xform
= op
->sym
->xform
;
249 auth_xform
= cipher_xform
->next
;
250 auth_xform
->next
= NULL
;
252 cipher_xform
->next
= auth_xform
;
253 auth_xform
->next
= NULL
;
254 init_xform
= cipher_xform
;
256 } else if (t
->op_mask
== BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC
) {
257 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SESSIONLESS
) {
258 auth_xform
= op
->sym
->xform
;
259 cipher_xform
= auth_xform
->next
;
260 cipher_xform
->next
= NULL
;
262 auth_xform
->next
= cipher_xform
;
263 cipher_xform
->next
= NULL
;
264 init_xform
= auth_xform
;
266 } else if ((t
->op_mask
== BLOCKCIPHER_TEST_OP_ENCRYPT
) ||
267 (t
->op_mask
== BLOCKCIPHER_TEST_OP_DECRYPT
)) {
268 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SESSIONLESS
)
269 cipher_xform
= op
->sym
->xform
;
271 init_xform
= cipher_xform
;
272 cipher_xform
->next
= NULL
;
273 } else if ((t
->op_mask
== BLOCKCIPHER_TEST_OP_AUTH_GEN
) ||
274 (t
->op_mask
== BLOCKCIPHER_TEST_OP_AUTH_VERIFY
)) {
275 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SESSIONLESS
)
276 auth_xform
= op
->sym
->xform
;
278 init_xform
= auth_xform
;
279 auth_xform
->next
= NULL
;
281 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
282 "line %u FAILED: %s",
283 __LINE__
, "Unrecognized operation");
284 status
= TEST_FAILED
;
288 /*configure xforms & sym_op cipher and auth data*/
289 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_CIPHER
) {
290 cipher_xform
->type
= RTE_CRYPTO_SYM_XFORM_CIPHER
;
291 cipher_xform
->cipher
.algo
= tdata
->crypto_algo
;
292 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_ENCRYPT
)
293 cipher_xform
->cipher
.op
=
294 RTE_CRYPTO_CIPHER_OP_ENCRYPT
;
296 cipher_xform
->cipher
.op
=
297 RTE_CRYPTO_CIPHER_OP_DECRYPT
;
298 cipher_xform
->cipher
.key
.data
= cipher_key
;
299 cipher_xform
->cipher
.key
.length
= tdata
->cipher_key
.len
;
300 cipher_xform
->cipher
.iv
.offset
= IV_OFFSET
;
301 cipher_xform
->cipher
.iv
.length
= tdata
->iv
.len
;
303 sym_op
->cipher
.data
.offset
= 0;
304 sym_op
->cipher
.data
.length
= tdata
->ciphertext
.len
;
305 rte_memcpy(rte_crypto_op_ctod_offset(op
, uint8_t *, IV_OFFSET
),
310 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH
) {
311 uint32_t digest_offset
= tdata
->ciphertext
.len
;
313 auth_xform
->type
= RTE_CRYPTO_SYM_XFORM_AUTH
;
314 auth_xform
->auth
.algo
= tdata
->auth_algo
;
315 auth_xform
->auth
.key
.length
= tdata
->auth_key
.len
;
316 auth_xform
->auth
.key
.data
= auth_key
;
317 auth_xform
->auth
.digest_length
= digest_len
;
319 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH_GEN
) {
320 auth_xform
->auth
.op
= RTE_CRYPTO_AUTH_OP_GENERATE
;
321 sym_op
->auth
.digest
.data
= pktmbuf_mtod_offset
322 (iobuf
, digest_offset
);
323 sym_op
->auth
.digest
.phys_addr
=
324 pktmbuf_iova_offset(iobuf
,
327 auth_xform
->auth
.op
= RTE_CRYPTO_AUTH_OP_VERIFY
;
328 sym_op
->auth
.digest
.data
= pktmbuf_mtod_offset
329 (sym_op
->m_src
, digest_offset
);
330 sym_op
->auth
.digest
.phys_addr
=
331 pktmbuf_iova_offset(sym_op
->m_src
,
335 sym_op
->auth
.data
.offset
= 0;
336 sym_op
->auth
.data
.length
= tdata
->ciphertext
.len
;
339 /* create session for sessioned op */
340 if (!(t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SESSIONLESS
)) {
341 sess
= rte_cryptodev_sym_session_create(sess_mpool
);
343 rte_cryptodev_sym_session_init(dev_id
, sess
, init_xform
,
346 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
347 "FAILED: %s", __LINE__
,
348 "Session creation failed");
349 status
= TEST_FAILED
;
353 /* attach symmetric crypto session to crypto operations */
354 rte_crypto_op_attach_sym_session(op
, sess
);
357 debug_hexdump(stdout
, "m_src(before):",
358 sym_op
->m_src
->buf_addr
, sym_op
->m_src
->buf_len
);
359 rte_memcpy(tmp_src_buf
, sym_op
->m_src
->buf_addr
,
360 sym_op
->m_src
->buf_len
);
361 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_OOP
) {
362 debug_hexdump(stdout
, "m_dst(before):",
363 sym_op
->m_dst
->buf_addr
, sym_op
->m_dst
->buf_len
);
364 rte_memcpy(tmp_dst_buf
, sym_op
->m_dst
->buf_addr
,
365 sym_op
->m_dst
->buf_len
);
368 /* Process crypto operation */
369 if (rte_cryptodev_enqueue_burst(dev_id
, 0, &op
, 1) != 1) {
370 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
371 "line %u FAILED: %s",
372 __LINE__
, "Error sending packet for encryption");
373 status
= TEST_FAILED
;
379 while (rte_cryptodev_dequeue_burst(dev_id
, 0, &op
, 1) == 0)
383 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
384 "line %u FAILED: %s",
385 __LINE__
, "Failed to process sym crypto op");
386 status
= TEST_FAILED
;
390 debug_hexdump(stdout
, "m_src(after):",
391 sym_op
->m_src
->buf_addr
, sym_op
->m_src
->buf_len
);
392 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_OOP
)
393 debug_hexdump(stdout
, "m_dst(after):",
394 sym_op
->m_dst
->buf_addr
, sym_op
->m_dst
->buf_len
);
397 if (op
->status
!= RTE_CRYPTO_OP_STATUS_SUCCESS
) {
398 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH_VERIFY
)
399 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
400 "FAILED: Digest verification failed "
401 "(0x%X)", __LINE__
, op
->status
);
403 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
404 "FAILED: Digest verification failed "
405 "(0x%X)", __LINE__
, op
->status
);
406 status
= TEST_FAILED
;
410 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_CIPHER
) {
411 uint8_t buffer
[2048];
412 const uint8_t *compare_ref
;
413 uint32_t compare_len
;
415 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_ENCRYPT
) {
416 compare_ref
= tdata
->ciphertext
.data
;
417 compare_len
= tdata
->ciphertext
.len
;
419 compare_ref
= tdata
->plaintext
.data
;
420 compare_len
= tdata
->plaintext
.len
;
423 if (memcmp(rte_pktmbuf_read(iobuf
, 0, compare_len
,
424 buffer
), compare_ref
, compare_len
)) {
425 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
426 "FAILED: %s", __LINE__
,
427 "Crypto data not as expected");
428 status
= TEST_FAILED
;
433 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH_GEN
) {
434 uint8_t *auth_res
= pktmbuf_mtod_offset(iobuf
,
435 tdata
->ciphertext
.len
);
437 if (memcmp(auth_res
, tdata
->digest
.data
, digest_len
)) {
438 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "line %u "
439 "FAILED: %s", __LINE__
, "Generated "
440 "digest data not as expected");
441 status
= TEST_FAILED
;
446 /* The only parts that should have changed in the buffer are
447 * plaintext/ciphertext and digest.
448 * In OOP only the dest buffer should change.
450 if (t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_OOP
) {
451 struct rte_mbuf
*mbuf
;
453 uint32_t head_unchanged_len
, changed_len
= 0;
455 uint32_t hdroom_used
= 0, tlroom_used
= 0;
458 mbuf
= sym_op
->m_src
;
460 * Crypto PMDs specify the headroom & tailroom it would use
461 * when processing the crypto operation. PMD is free to modify
462 * this space, and so the verification check should skip that
465 hdroom_used
= dev_info
.min_mbuf_headroom_req
;
466 tlroom_used
= dev_info
.min_mbuf_tailroom_req
;
469 hdroom
= rte_pktmbuf_headroom(mbuf
);
471 head_unchanged_len
= mbuf
->buf_len
;
473 for (i
= 0; i
< mbuf
->buf_len
; i
++) {
475 /* Skip headroom used by PMD */
476 if (i
== hdroom
- hdroom_used
)
479 /* Skip tailroom used by PMD */
480 if (i
== (hdroom
+ mbuf
->data_len
))
483 value
= *((uint8_t *)(mbuf
->buf_addr
)+i
);
484 if (value
!= tmp_src_buf
[i
]) {
485 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
486 "line %u FAILED: OOP src outer mbuf data (0x%x) not as expected (0x%x)",
487 __LINE__
, value
, tmp_src_buf
[i
]);
488 status
= TEST_FAILED
;
493 mbuf
= sym_op
->m_dst
;
494 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH
) {
495 head_unchanged_len
= hdroom
+ sym_op
->auth
.data
.offset
;
496 changed_len
= sym_op
->auth
.data
.length
;
497 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH_GEN
)
498 changed_len
+= digest_len
;
501 head_unchanged_len
= hdroom
+
502 sym_op
->cipher
.data
.offset
;
503 changed_len
= sym_op
->cipher
.data
.length
;
506 for (i
= 0; i
< mbuf
->buf_len
; i
++) {
507 if (i
== head_unchanged_len
)
509 value
= *((uint8_t *)(mbuf
->buf_addr
)+i
);
510 if (value
!= tmp_dst_buf
[i
]) {
511 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
512 "line %u FAILED: OOP dst outer mbuf data "
513 "(0x%x) not as expected (0x%x)",
514 __LINE__
, value
, tmp_dst_buf
[i
]);
515 status
= TEST_FAILED
;
520 /* In-place operation */
521 struct rte_mbuf
*mbuf
;
523 uint32_t head_unchanged_len
= 0, changed_len
= 0;
525 uint32_t hdroom_used
= 0, tlroom_used
= 0;
529 * Crypto PMDs specify the headroom & tailroom it would use
530 * when processing the crypto operation. PMD is free to modify
531 * this space, and so the verification check should skip that
534 hdroom_used
= dev_info
.min_mbuf_headroom_req
;
535 tlroom_used
= dev_info
.min_mbuf_tailroom_req
;
537 mbuf
= sym_op
->m_src
;
540 hdroom
= rte_pktmbuf_headroom(mbuf
);
542 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_CIPHER
) {
543 head_unchanged_len
= hdroom
+
544 sym_op
->cipher
.data
.offset
;
545 changed_len
= sym_op
->cipher
.data
.length
;
548 head_unchanged_len
= hdroom
+
549 sym_op
->auth
.data
.offset
+
550 sym_op
->auth
.data
.length
;
554 if (t
->op_mask
& BLOCKCIPHER_TEST_OP_AUTH_GEN
)
555 changed_len
+= digest_len
;
557 for (i
= 0; i
< mbuf
->buf_len
; i
++) {
559 /* Skip headroom used by PMD */
560 if (i
== hdroom
- hdroom_used
)
563 if (i
== head_unchanged_len
)
566 /* Skip tailroom used by PMD */
567 if (i
== (hdroom
+ mbuf
->data_len
))
570 value
= *((uint8_t *)(mbuf
->buf_addr
)+i
);
571 if (value
!= tmp_src_buf
[i
]) {
572 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
,
573 "line %u FAILED: outer mbuf data (0x%x) "
574 "not as expected (0x%x)",
575 __LINE__
, value
, tmp_src_buf
[i
]);
576 status
= TEST_FAILED
;
582 snprintf(test_msg
, BLOCKCIPHER_TEST_MSG_LEN
, "PASS");
585 if (!(t
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_SESSIONLESS
)) {
587 rte_cryptodev_sym_session_clear(dev_id
, sess
);
588 rte_cryptodev_sym_session_free(sess
);
591 rte_free(cipher_xform
);
593 rte_free(auth_xform
);
597 rte_crypto_op_free(op
);
600 rte_pktmbuf_free(obuf
);
603 rte_pktmbuf_free(ibuf
);
609 test_blockcipher_all_tests(struct rte_mempool
*mbuf_pool
,
610 struct rte_mempool
*op_mpool
,
611 struct rte_mempool
*sess_mpool
,
614 enum blockcipher_test_type test_type
)
616 int status
, overall_status
= TEST_SUCCESS
;
617 uint32_t i
, test_index
= 0;
618 char test_msg
[BLOCKCIPHER_TEST_MSG_LEN
+ 1];
619 uint32_t n_test_cases
= 0;
620 uint32_t target_pmd_mask
= 0;
621 const struct blockcipher_test_case
*tcs
= NULL
;
623 int openssl_pmd
= rte_cryptodev_driver_id_get(
624 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD
));
625 int ccp_pmd
= rte_cryptodev_driver_id_get(
626 RTE_STR(CRYPTODEV_NAME_CCP_PMD
));
627 int dpaa2_sec_pmd
= rte_cryptodev_driver_id_get(
628 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD
));
629 int dpaa_sec_pmd
= rte_cryptodev_driver_id_get(
630 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD
));
631 int scheduler_pmd
= rte_cryptodev_driver_id_get(
632 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD
));
633 int armv8_pmd
= rte_cryptodev_driver_id_get(
634 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD
));
635 int aesni_mb_pmd
= rte_cryptodev_driver_id_get(
636 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD
));
637 int qat_pmd
= rte_cryptodev_driver_id_get(
638 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD
));
639 int mrvl_pmd
= rte_cryptodev_driver_id_get(
640 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD
));
641 int virtio_pmd
= rte_cryptodev_driver_id_get(
642 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD
));
645 case BLKCIPHER_AES_CHAIN_TYPE
:
646 n_test_cases
= sizeof(aes_chain_test_cases
) /
647 sizeof(aes_chain_test_cases
[0]);
648 tcs
= aes_chain_test_cases
;
650 case BLKCIPHER_AES_CIPHERONLY_TYPE
:
651 n_test_cases
= sizeof(aes_cipheronly_test_cases
) /
652 sizeof(aes_cipheronly_test_cases
[0]);
653 tcs
= aes_cipheronly_test_cases
;
655 case BLKCIPHER_AES_DOCSIS_TYPE
:
656 n_test_cases
= sizeof(aes_docsis_test_cases
) /
657 sizeof(aes_docsis_test_cases
[0]);
658 tcs
= aes_docsis_test_cases
;
660 case BLKCIPHER_3DES_CHAIN_TYPE
:
661 n_test_cases
= sizeof(triple_des_chain_test_cases
) /
662 sizeof(triple_des_chain_test_cases
[0]);
663 tcs
= triple_des_chain_test_cases
;
665 case BLKCIPHER_3DES_CIPHERONLY_TYPE
:
666 n_test_cases
= sizeof(triple_des_cipheronly_test_cases
) /
667 sizeof(triple_des_cipheronly_test_cases
[0]);
668 tcs
= triple_des_cipheronly_test_cases
;
670 case BLKCIPHER_DES_CIPHERONLY_TYPE
:
671 n_test_cases
= sizeof(des_cipheronly_test_cases
) /
672 sizeof(des_cipheronly_test_cases
[0]);
673 tcs
= des_cipheronly_test_cases
;
675 case BLKCIPHER_DES_DOCSIS_TYPE
:
676 n_test_cases
= sizeof(des_docsis_test_cases
) /
677 sizeof(des_docsis_test_cases
[0]);
678 tcs
= des_docsis_test_cases
;
680 case BLKCIPHER_AUTHONLY_TYPE
:
681 n_test_cases
= sizeof(hash_test_cases
) /
682 sizeof(hash_test_cases
[0]);
683 tcs
= hash_test_cases
;
689 if (driver_id
== aesni_mb_pmd
)
690 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_MB
;
691 else if (driver_id
== qat_pmd
)
692 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_QAT
;
693 else if (driver_id
== openssl_pmd
)
694 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL
;
695 else if (driver_id
== armv8_pmd
)
696 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_ARMV8
;
697 else if (driver_id
== scheduler_pmd
)
698 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER
;
699 else if (driver_id
== dpaa2_sec_pmd
)
700 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC
;
701 else if (driver_id
== ccp_pmd
)
702 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_CCP
;
703 else if (driver_id
== dpaa_sec_pmd
)
704 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC
;
705 else if (driver_id
== mrvl_pmd
)
706 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_MVSAM
;
707 else if (driver_id
== virtio_pmd
)
708 target_pmd_mask
= BLOCKCIPHER_TEST_TARGET_PMD_VIRTIO
;
710 TEST_ASSERT(0, "Unrecognized cryptodev type");
712 for (i
= 0; i
< n_test_cases
; i
++) {
713 const struct blockcipher_test_case
*tc
= &tcs
[i
];
715 if (!(tc
->pmd_mask
& target_pmd_mask
))
718 status
= test_blockcipher_one_case(tc
, mbuf_pool
, op_mpool
,
719 sess_mpool
, dev_id
, driver_id
, test_msg
);
721 printf(" %u) TestCase %s %s\n", test_index
++,
722 tc
->test_descr
, test_msg
);
724 if (status
!= TEST_SUCCESS
) {
725 if (overall_status
== TEST_SUCCESS
)
726 overall_status
= status
;
728 if (tc
->feature_mask
& BLOCKCIPHER_TEST_FEATURE_STOPPER
)
733 return overall_status
;