4 * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
39 #include <rte_crypto.h>
40 #include <rte_cryptodev.h>
41 #include <rte_cryptodev_pmd.h>
44 #include "test_cryptodev_aes.h"
46 #ifndef AES_TEST_MSG_LEN
47 #define AES_TEST_MSG_LEN 256
50 #define AES_TEST_OP_ENCRYPT 0x01
51 #define AES_TEST_OP_DECRYPT 0x02
52 #define AES_TEST_OP_AUTH_GEN 0x04
53 #define AES_TEST_OP_AUTH_VERIFY 0x08
55 #define AES_TEST_FEATURE_OOP 0x01
56 #define AES_TEST_FEATURE_SESSIONLESS 0x02
57 #define AES_TEST_FEATURE_STOPPER 0x04 /* stop upon failing */
59 #define AES_TEST_TARGET_PMD_MB 0x0001 /* Multi-buffer flag */
60 #define AES_TEST_TARGET_PMD_QAT 0x0002 /* QAT flag */
62 #define AES_TEST_OP_CIPHER (AES_TEST_OP_ENCRYPT | \
65 #define AES_TEST_OP_AUTH (AES_TEST_OP_AUTH_GEN | \
66 AES_TEST_OP_AUTH_VERIFY)
68 #define AES_TEST_OP_ENC_AUTH_GEN (AES_TEST_OP_ENCRYPT | \
71 #define AES_TEST_OP_AUTH_VERIFY_DEC (AES_TEST_OP_DECRYPT | \
72 AES_TEST_OP_AUTH_VERIFY)
74 struct aes_test_case {
75 const char *test_descr; /* test description */
76 const struct aes_test_data *test_data;
77 uint8_t op_mask; /* operation mask */
82 static const struct aes_test_case aes_test_cases[] = {
84 .test_descr = "AES-128-CTR HMAC-SHA1 Encryption Digest",
85 .test_data = &aes_test_data_1,
86 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
87 .pmd_mask = AES_TEST_TARGET_PMD_MB |
88 AES_TEST_TARGET_PMD_QAT
91 .test_descr = "AES-128-CTR HMAC-SHA1 Decryption Digest "
93 .test_data = &aes_test_data_1,
94 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
95 .pmd_mask = AES_TEST_TARGET_PMD_MB |
96 AES_TEST_TARGET_PMD_QAT
99 .test_descr = "AES-192-CTR XCBC Encryption Digest",
100 .test_data = &aes_test_data_2,
101 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
102 .pmd_mask = AES_TEST_TARGET_PMD_MB |
103 AES_TEST_TARGET_PMD_QAT
106 .test_descr = "AES-192-CTR XCBC Decryption Digest Verify",
107 .test_data = &aes_test_data_2,
108 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
109 .pmd_mask = AES_TEST_TARGET_PMD_MB |
110 AES_TEST_TARGET_PMD_QAT
113 .test_descr = "AES-256-CTR HMAC-SHA1 Encryption Digest",
114 .test_data = &aes_test_data_3,
115 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
116 .pmd_mask = AES_TEST_TARGET_PMD_MB |
117 AES_TEST_TARGET_PMD_QAT
120 .test_descr = "AES-256-CTR HMAC-SHA1 Decryption Digest "
122 .test_data = &aes_test_data_3,
123 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
124 .pmd_mask = AES_TEST_TARGET_PMD_MB |
125 AES_TEST_TARGET_PMD_QAT
128 .test_descr = "AES-128-CBC HMAC-SHA1 Encryption Digest",
129 .test_data = &aes_test_data_4,
130 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
131 .pmd_mask = AES_TEST_TARGET_PMD_MB |
132 AES_TEST_TARGET_PMD_QAT
135 .test_descr = "AES-128-CBC HMAC-SHA1 Decryption Digest "
137 .test_data = &aes_test_data_4,
138 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
139 .pmd_mask = AES_TEST_TARGET_PMD_MB |
140 AES_TEST_TARGET_PMD_QAT
143 .test_descr = "AES-128-CBC HMAC-SHA256 Encryption Digest",
144 .test_data = &aes_test_data_5,
145 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
146 .pmd_mask = AES_TEST_TARGET_PMD_MB |
147 AES_TEST_TARGET_PMD_QAT
150 .test_descr = "AES-128-CBC HMAC-SHA256 Decryption Digest "
152 .test_data = &aes_test_data_5,
153 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
154 .pmd_mask = AES_TEST_TARGET_PMD_MB |
155 AES_TEST_TARGET_PMD_QAT
158 .test_descr = "AES-128-CBC HMAC-SHA512 Encryption Digest",
159 .test_data = &aes_test_data_6,
160 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
161 .pmd_mask = AES_TEST_TARGET_PMD_MB |
162 AES_TEST_TARGET_PMD_QAT
165 .test_descr = "AES-128-CBC HMAC-SHA512 Encryption Digest "
167 .test_data = &aes_test_data_6,
168 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
169 .feature_mask = AES_TEST_FEATURE_SESSIONLESS,
170 .pmd_mask = AES_TEST_TARGET_PMD_MB
173 .test_descr = "AES-128-CBC HMAC-SHA512 Decryption Digest "
175 .test_data = &aes_test_data_6,
176 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
177 .pmd_mask = AES_TEST_TARGET_PMD_MB |
178 AES_TEST_TARGET_PMD_QAT
181 .test_descr = "AES-128-CBC XCBC Encryption Digest",
182 .test_data = &aes_test_data_7,
183 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
184 .pmd_mask = AES_TEST_TARGET_PMD_MB |
185 AES_TEST_TARGET_PMD_QAT
188 .test_descr = "AES-128-CBC XCBC Decryption Digest Verify",
189 .test_data = &aes_test_data_7,
190 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
191 .pmd_mask = AES_TEST_TARGET_PMD_MB |
192 AES_TEST_TARGET_PMD_QAT
195 .test_descr = "AES-128-CBC HMAC-SHA1 Encryption Digest "
197 .test_data = &aes_test_data_4,
198 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
199 .feature_mask = AES_TEST_FEATURE_OOP,
200 .pmd_mask = AES_TEST_TARGET_PMD_QAT
203 .test_descr = "AES-128-CBC HMAC-SHA1 Decryption Digest "
205 .test_data = &aes_test_data_4,
206 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
207 .feature_mask = AES_TEST_FEATURE_OOP,
208 .pmd_mask = AES_TEST_TARGET_PMD_QAT
211 .test_descr = "AES-128-CBC HMAC-SHA224 Encryption Digest",
212 .test_data = &aes_test_data_8,
213 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
214 .pmd_mask = AES_TEST_TARGET_PMD_MB |
215 AES_TEST_TARGET_PMD_QAT
218 .test_descr = "AES-128-CBC HMAC-SHA224 Decryption Digest "
220 .test_data = &aes_test_data_8,
221 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
222 .pmd_mask = AES_TEST_TARGET_PMD_MB |
223 AES_TEST_TARGET_PMD_QAT
226 .test_descr = "AES-128-CBC HMAC-SHA384 Encryption Digest",
227 .test_data = &aes_test_data_9,
228 .op_mask = AES_TEST_OP_ENC_AUTH_GEN,
229 .pmd_mask = AES_TEST_TARGET_PMD_MB |
230 AES_TEST_TARGET_PMD_QAT
233 .test_descr = "AES-128-CBC HMAC-SHA384 Decryption Digest "
235 .test_data = &aes_test_data_9,
236 .op_mask = AES_TEST_OP_AUTH_VERIFY_DEC,
237 .pmd_mask = AES_TEST_TARGET_PMD_MB |
238 AES_TEST_TARGET_PMD_QAT
243 test_AES_one_case(const struct aes_test_case *t,
244 struct rte_mempool *mbuf_pool,
245 struct rte_mempool *op_mpool,
247 enum rte_cryptodev_type cryptodev_type,
250 struct rte_mbuf *ibuf = NULL;
251 struct rte_mbuf *obuf = NULL;
252 struct rte_mbuf *iobuf;
253 struct rte_crypto_sym_xform *cipher_xform = NULL;
254 struct rte_crypto_sym_xform *auth_xform = NULL;
255 struct rte_crypto_sym_xform *init_xform = NULL;
256 struct rte_crypto_sym_op *sym_op = NULL;
257 struct rte_crypto_op *op = NULL;
258 struct rte_cryptodev_sym_session *sess = NULL;
260 int status = TEST_SUCCESS;
261 const struct aes_test_data *tdata = t->test_data;
262 uint8_t cipher_key[tdata->cipher_key.len];
263 uint8_t auth_key[tdata->auth_key.len];
264 uint32_t buf_len = tdata->ciphertext.len;
265 uint32_t digest_len = 0;
268 if (tdata->cipher_key.len)
269 memcpy(cipher_key, tdata->cipher_key.data,
270 tdata->cipher_key.len);
271 if (tdata->auth_key.len)
272 memcpy(auth_key, tdata->auth_key.data,
273 tdata->auth_key.len);
275 switch (cryptodev_type) {
276 case RTE_CRYPTODEV_QAT_SYM_PMD:
277 digest_len = tdata->digest.len;
279 case RTE_CRYPTODEV_AESNI_MB_PMD:
280 digest_len = tdata->digest.truncated_len;
283 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u FAILED: %s",
284 __LINE__, "Unsupported PMD type");
285 status = TEST_FAILED;
290 ibuf = rte_pktmbuf_alloc(mbuf_pool);
292 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u FAILED: %s",
293 __LINE__, "Allocation of rte_mbuf failed");
294 status = TEST_FAILED;
298 if (t->op_mask & AES_TEST_OP_CIPHER)
299 buf_len += tdata->iv.len;
300 if (t->op_mask & AES_TEST_OP_AUTH)
301 buf_len += digest_len;
303 buf_p = rte_pktmbuf_append(ibuf, buf_len);
305 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u FAILED: %s",
306 __LINE__, "No room to append mbuf");
307 status = TEST_FAILED;
311 if (t->op_mask & AES_TEST_OP_CIPHER) {
312 rte_memcpy(buf_p, tdata->iv.data, tdata->iv.len);
313 buf_p += tdata->iv.len;
316 /* only encryption requires plaintext.data input,
317 * decryption/(digest gen)/(digest verify) use ciphertext.data
319 if (t->op_mask & AES_TEST_OP_ENCRYPT) {
320 rte_memcpy(buf_p, tdata->plaintext.data,
321 tdata->plaintext.len);
322 buf_p += tdata->plaintext.len;
324 rte_memcpy(buf_p, tdata->ciphertext.data,
325 tdata->ciphertext.len);
326 buf_p += tdata->ciphertext.len;
329 if (t->op_mask & AES_TEST_OP_AUTH_VERIFY)
330 rte_memcpy(buf_p, tdata->digest.data, digest_len);
332 memset(buf_p, 0, digest_len);
334 if (t->feature_mask & AES_TEST_FEATURE_OOP) {
335 obuf = rte_pktmbuf_alloc(mbuf_pool);
337 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
338 "FAILED: %s", __LINE__,
339 "Allocation of rte_mbuf failed");
340 status = TEST_FAILED;
344 buf_p = rte_pktmbuf_append(obuf, buf_len);
346 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
347 "FAILED: %s", __LINE__,
348 "No room to append mbuf");
349 status = TEST_FAILED;
352 memset(buf_p, 0, buf_len);
355 /* Generate Crypto op data structure */
356 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
358 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u FAILED: %s",
359 __LINE__, "Failed to allocate symmetric crypto "
361 status = TEST_FAILED;
367 sym_op->m_src = ibuf;
369 if (t->feature_mask & AES_TEST_FEATURE_OOP) {
370 sym_op->m_dst = obuf;
373 sym_op->m_dst = NULL;
377 /* sessionless op requires allocate xform using
378 * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
380 if (t->feature_mask & AES_TEST_FEATURE_SESSIONLESS) {
381 uint32_t n_xforms = 0;
383 if (t->op_mask & AES_TEST_OP_CIPHER)
385 if (t->op_mask & AES_TEST_OP_AUTH)
388 if (rte_crypto_op_sym_xforms_alloc(op, n_xforms)
390 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
391 "FAILED: %s", __LINE__, "Failed to "
392 "allocate space for crypto transforms");
393 status = TEST_FAILED;
397 cipher_xform = rte_zmalloc(NULL,
398 sizeof(struct rte_crypto_sym_xform), 0);
400 auth_xform = rte_zmalloc(NULL,
401 sizeof(struct rte_crypto_sym_xform), 0);
403 if (!cipher_xform || !auth_xform) {
404 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
405 "FAILED: %s", __LINE__, "Failed to "
406 "allocate memory for crypto transforms");
407 status = TEST_FAILED;
412 /* preparing xform, for sessioned op, init_xform is initialized
413 * here and later as param in rte_cryptodev_sym_session_create()
415 if (t->op_mask == AES_TEST_OP_ENC_AUTH_GEN) {
416 if (t->feature_mask & AES_TEST_FEATURE_SESSIONLESS) {
417 cipher_xform = op->sym->xform;
418 auth_xform = cipher_xform->next;
419 auth_xform->next = NULL;
421 cipher_xform->next = auth_xform;
422 auth_xform->next = NULL;
423 init_xform = cipher_xform;
425 } else if (t->op_mask == AES_TEST_OP_AUTH_VERIFY_DEC) {
426 if (t->feature_mask & AES_TEST_FEATURE_SESSIONLESS) {
427 auth_xform = op->sym->xform;
428 cipher_xform = auth_xform->next;
429 cipher_xform->next = NULL;
431 auth_xform->next = cipher_xform;
432 cipher_xform->next = NULL;
433 init_xform = auth_xform;
435 } else if ((t->op_mask == AES_TEST_OP_ENCRYPT) ||
436 (t->op_mask == AES_TEST_OP_DECRYPT)) {
437 if (t->feature_mask & AES_TEST_FEATURE_SESSIONLESS)
438 cipher_xform = op->sym->xform;
440 init_xform = cipher_xform;
441 cipher_xform->next = NULL;
442 } else if ((t->op_mask == AES_TEST_OP_AUTH_GEN) ||
443 (t->op_mask == AES_TEST_OP_AUTH_VERIFY)) {
444 if (t->feature_mask & AES_TEST_FEATURE_SESSIONLESS)
445 auth_xform = op->sym->xform;
447 init_xform = auth_xform;
448 auth_xform->next = NULL;
450 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u FAILED: %s",
451 __LINE__, "Unrecognized operation");
452 status = TEST_FAILED;
456 /*configure xforms & sym_op cipher and auth data*/
457 if (t->op_mask & AES_TEST_OP_CIPHER) {
458 cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
459 cipher_xform->cipher.algo = tdata->crypto_algo;
460 if (t->op_mask & AES_TEST_OP_ENCRYPT)
461 cipher_xform->cipher.op =
462 RTE_CRYPTO_CIPHER_OP_ENCRYPT;
464 cipher_xform->cipher.op =
465 RTE_CRYPTO_CIPHER_OP_DECRYPT;
466 cipher_xform->cipher.key.data = cipher_key;
467 cipher_xform->cipher.key.length = tdata->cipher_key.len;
469 sym_op->cipher.data.offset = tdata->iv.len;
470 sym_op->cipher.data.length = tdata->ciphertext.len;
471 sym_op->cipher.iv.data = rte_pktmbuf_mtod(sym_op->m_src,
473 sym_op->cipher.iv.length = tdata->iv.len;
474 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(
478 if (t->op_mask & AES_TEST_OP_AUTH) {
479 uint32_t auth_data_offset = 0;
480 uint32_t digest_offset = tdata->ciphertext.len;
482 if (t->op_mask & AES_TEST_OP_CIPHER) {
483 digest_offset += tdata->iv.len;
484 auth_data_offset += tdata->iv.len;
487 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
488 auth_xform->auth.algo = tdata->auth_algo;
489 auth_xform->auth.key.length = tdata->auth_key.len;
490 auth_xform->auth.key.data = auth_key;
491 auth_xform->auth.digest_length = digest_len;
493 if (t->op_mask & AES_TEST_OP_AUTH_GEN) {
494 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
495 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset
496 (iobuf, uint8_t *, digest_offset);
497 sym_op->auth.digest.phys_addr =
498 rte_pktmbuf_mtophys_offset(iobuf,
501 auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
502 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset
503 (sym_op->m_src, uint8_t *, digest_offset);
504 sym_op->auth.digest.phys_addr =
505 rte_pktmbuf_mtophys_offset(sym_op->m_src,
509 sym_op->auth.data.offset = auth_data_offset;
510 sym_op->auth.data.length = tdata->ciphertext.len;
511 sym_op->auth.digest.length = digest_len;
514 /* create session for sessioned op */
515 if (!(t->feature_mask & AES_TEST_FEATURE_SESSIONLESS)) {
516 sess = rte_cryptodev_sym_session_create(dev_id,
519 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
520 "FAILED: %s", __LINE__,
521 "Session creation failed");
522 status = TEST_FAILED;
526 /* attach symmetric crypto session to crypto operations */
527 rte_crypto_op_attach_sym_session(op, sess);
530 /* Process crypto operation */
531 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
532 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u FAILED: %s",
533 __LINE__, "Error sending packet for encryption");
534 status = TEST_FAILED;
540 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
544 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u FAILED: %s",
545 __LINE__, "Failed to process sym crypto op");
546 status = TEST_FAILED;
550 TEST_HEXDUMP(stdout, "m_src:",
551 rte_pktmbuf_mtod(sym_op->m_src, uint8_t *), buf_len);
552 if (t->feature_mask & AES_TEST_FEATURE_OOP)
553 TEST_HEXDUMP(stdout, "m_dst:",
554 rte_pktmbuf_mtod(sym_op->m_dst, uint8_t *),
558 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
559 if (t->op_mask & AES_TEST_OP_AUTH_VERIFY)
560 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
561 "FAILED: Digest verification failed "
562 "(0x%X)", __LINE__, op->status);
564 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
565 "FAILED: Digest verification failed "
566 "(0x%X)", __LINE__, op->status);
567 status = TEST_FAILED;
571 if (t->op_mask & AES_TEST_OP_CIPHER) {
573 const uint8_t *compare_ref;
574 uint32_t compare_len;
576 crypto_res = rte_pktmbuf_mtod_offset(iobuf, uint8_t *,
579 if (t->op_mask & AES_TEST_OP_ENCRYPT) {
580 compare_ref = tdata->ciphertext.data;
581 compare_len = tdata->ciphertext.len;
583 compare_ref = tdata->plaintext.data;
584 compare_len = tdata->plaintext.len;
587 if (memcmp(crypto_res, compare_ref, compare_len)) {
588 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
589 "FAILED: %s", __LINE__,
590 "Crypto data not as expected");
591 status = TEST_FAILED;
596 if (t->op_mask & AES_TEST_OP_AUTH_GEN) {
599 if (t->op_mask & AES_TEST_OP_CIPHER)
600 auth_res = rte_pktmbuf_mtod_offset(iobuf,
602 tdata->iv.len + tdata->ciphertext.len);
604 auth_res = rte_pktmbuf_mtod_offset(iobuf,
605 uint8_t *, tdata->ciphertext.len);
607 if (memcmp(auth_res, tdata->digest.data, digest_len)) {
608 snprintf(test_msg, AES_TEST_MSG_LEN, "line %u "
609 "FAILED: %s", __LINE__, "Generated "
610 "digest data not as expected");
611 status = TEST_FAILED;
616 snprintf(test_msg, AES_TEST_MSG_LEN, "PASS");
619 if (!(t->feature_mask & AES_TEST_FEATURE_SESSIONLESS)) {
621 rte_cryptodev_sym_session_free(dev_id, sess);
623 rte_free(cipher_xform);
625 rte_free(auth_xform);
629 rte_crypto_op_free(op);
632 rte_pktmbuf_free(obuf);
635 rte_pktmbuf_free(ibuf);
641 test_AES_all_tests(struct rte_mempool *mbuf_pool,
642 struct rte_mempool *op_mpool,
644 enum rte_cryptodev_type cryptodev_type)
646 int status, overall_status = TEST_SUCCESS;
647 uint32_t i, test_index = 0;
648 char test_msg[AES_TEST_MSG_LEN + 1];
649 uint32_t n_test_cases = sizeof(aes_test_cases) /
650 sizeof(aes_test_cases[0]);
651 uint32_t target_pmd_mask = 0;
653 switch (cryptodev_type) {
654 case RTE_CRYPTODEV_AESNI_MB_PMD:
655 target_pmd_mask = AES_TEST_TARGET_PMD_MB;
657 case RTE_CRYPTODEV_QAT_SYM_PMD:
658 target_pmd_mask = AES_TEST_TARGET_PMD_QAT;
661 TEST_ASSERT(-1, "Unrecognized cryptodev type");
665 for (i = 0; i < n_test_cases; i++) {
666 const struct aes_test_case *tc = &aes_test_cases[i];
668 if (!(tc->pmd_mask & target_pmd_mask))
671 status = test_AES_one_case(tc, mbuf_pool, op_mpool,
672 dev_id, cryptodev_type, test_msg);
674 printf(" %u) TestCase %s %s\n", test_index ++,
675 tc->test_descr, test_msg);
677 if (status != TEST_SUCCESS) {
678 if (overall_status == TEST_SUCCESS)
679 overall_status = status;
681 if (tc->feature_mask & AES_TEST_FEATURE_STOPPER)
686 return overall_status;