From a389434efc1b6846dd345def27178d9be24cb914 Mon Sep 17 00:00:00 2001 From: Alok Makhariya Date: Mon, 23 Oct 2017 01:05:51 +0530 Subject: [PATCH] crypto/dpaa_sec: support out of place buffers Enable out of place buffer test cases in dpaa_sec Signed-off-by: Alok Makhariya Acked-by: Akhil Goyal --- drivers/crypto/dpaa_sec/dpaa_sec.c | 46 +++++++++++++-------- test/test/test_cryptodev.c | 6 +++ test/test/test_cryptodev_aes_test_vectors.h | 12 ++++-- test/test/test_cryptodev_des_test_vectors.h | 6 ++- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 53f004eae6..26a29a4957 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -623,11 +623,10 @@ static inline struct dpaa_sec_job * build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses) { struct rte_crypto_sym_op *sym = op->sym; - struct rte_mbuf *mbuf = sym->m_src; struct dpaa_sec_job *cf; struct dpaa_sec_op_ctx *ctx; struct qm_sg_entry *sg; - phys_addr_t start_addr; + phys_addr_t src_start_addr, dst_start_addr; uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, ses->iv.offset); @@ -637,11 +636,17 @@ build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses) cf = &ctx->job; ctx->op = op; - start_addr = rte_pktmbuf_mtophys(mbuf); + + src_start_addr = rte_pktmbuf_mtophys(sym->m_src); + + if (sym->m_dst) + dst_start_addr = rte_pktmbuf_mtophys(sym->m_dst); + else + dst_start_addr = src_start_addr; /* output */ sg = &cf->sg[0]; - qm_sg_entry_set64(sg, start_addr + sym->cipher.data.offset); + qm_sg_entry_set64(sg, dst_start_addr + sym->cipher.data.offset); sg->length = sym->cipher.data.length + ses->iv.length; cpu_to_hw_sg(sg); @@ -661,7 +666,7 @@ build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses) cpu_to_hw_sg(sg); sg++; - qm_sg_entry_set64(sg, start_addr + sym->cipher.data.offset); + qm_sg_entry_set64(sg, src_start_addr + sym->cipher.data.offset); sg->length = sym->cipher.data.length; sg->final = 1; cpu_to_hw_sg(sg); @@ -673,16 +678,20 @@ static inline struct dpaa_sec_job * build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) { struct rte_crypto_sym_op *sym = op->sym; - struct rte_mbuf *mbuf = sym->m_src; struct dpaa_sec_job *cf; struct dpaa_sec_op_ctx *ctx; struct qm_sg_entry *sg; - phys_addr_t start_addr; uint32_t length = 0; + phys_addr_t src_start_addr, dst_start_addr; uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, ses->iv.offset); - start_addr = mbuf->buf_physaddr + mbuf->data_off; + src_start_addr = sym->m_src->buf_physaddr + sym->m_src->data_off; + + if (sym->m_dst) + dst_start_addr = sym->m_dst->buf_physaddr + sym->m_dst->data_off; + else + dst_start_addr = src_start_addr; ctx = dpaa_sec_alloc_ctx(ses); if (!ctx) @@ -710,7 +719,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) cpu_to_hw_sg(sg); sg++; } - qm_sg_entry_set64(sg, start_addr + sym->aead.data.offset); + qm_sg_entry_set64(sg, src_start_addr + sym->aead.data.offset); sg->length = sym->aead.data.length; length += sg->length; sg->final = 1; @@ -730,7 +739,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) cpu_to_hw_sg(sg); sg++; } - qm_sg_entry_set64(sg, start_addr + sym->aead.data.offset); + qm_sg_entry_set64(sg, src_start_addr + sym->aead.data.offset); sg->length = sym->aead.data.length; length += sg->length; cpu_to_hw_sg(sg); @@ -755,7 +764,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses) sg++; qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop(sg)); qm_sg_entry_set64(sg, - start_addr + sym->aead.data.offset - ses->auth_only_len); + dst_start_addr + sym->aead.data.offset - ses->auth_only_len); sg->length = sym->aead.data.length + ses->auth_only_len; length = sg->length; if (is_encode(ses)) { @@ -781,16 +790,19 @@ static inline struct dpaa_sec_job * build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) { struct rte_crypto_sym_op *sym = op->sym; - struct rte_mbuf *mbuf = sym->m_src; struct dpaa_sec_job *cf; struct dpaa_sec_op_ctx *ctx; struct qm_sg_entry *sg; - phys_addr_t start_addr; + phys_addr_t src_start_addr, dst_start_addr; uint32_t length = 0; uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *, ses->iv.offset); - start_addr = mbuf->buf_physaddr + mbuf->data_off; + src_start_addr = sym->m_src->buf_physaddr + sym->m_src->data_off; + if (sym->m_dst) + dst_start_addr = sym->m_dst->buf_physaddr + sym->m_dst->data_off; + else + dst_start_addr = src_start_addr; ctx = dpaa_sec_alloc_ctx(ses); if (!ctx) @@ -810,7 +822,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) cpu_to_hw_sg(sg); sg++; - qm_sg_entry_set64(sg, start_addr + sym->auth.data.offset); + qm_sg_entry_set64(sg, src_start_addr + sym->auth.data.offset); sg->length = sym->auth.data.length; length += sg->length; sg->final = 1; @@ -823,7 +835,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) sg++; - qm_sg_entry_set64(sg, start_addr + sym->auth.data.offset); + qm_sg_entry_set64(sg, src_start_addr + sym->auth.data.offset); sg->length = sym->auth.data.length; length += sg->length; cpu_to_hw_sg(sg); @@ -847,7 +859,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses) /* output */ sg++; qm_sg_entry_set64(&cf->sg[0], dpaa_mem_vtop(sg)); - qm_sg_entry_set64(sg, start_addr + sym->cipher.data.offset); + qm_sg_entry_set64(sg, dst_start_addr + sym->cipher.data.offset); sg->length = sym->cipher.data.length; length = sg->length; if (is_encode(ses)) { diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index cb9b486128..72988c5610 100644 --- a/test/test/test_cryptodev.c +++ b/test/test/test_cryptodev.c @@ -9370,6 +9370,12 @@ static struct unit_test_suite cryptodev_dpaa_sec_testsuite = { TEST_CASE_ST(ut_setup, ut_teardown, test_AES_GCM_auth_decryption_test_case_256_7), + /** Out of place tests */ + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_authenticated_encryption_oop_test_case_1), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_GCM_authenticated_decryption_oop_test_case_1), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; diff --git a/test/test/test_cryptodev_aes_test_vectors.h b/test/test/test_cryptodev_aes_test_vectors.h index 050d868aa6..9c13041d32 100644 --- a/test/test/test_cryptodev_aes_test_vectors.h +++ b/test/test/test_cryptodev_aes_test_vectors.h @@ -1446,7 +1446,8 @@ static const struct blockcipher_test_case aes_chain_test_cases[] = { .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | BLOCKCIPHER_TEST_TARGET_PMD_QAT | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | - BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC + BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC | + BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC }, { .test_descr = "AES-128-CBC HMAC-SHA1 Decryption Digest " @@ -1457,7 +1458,8 @@ static const struct blockcipher_test_case aes_chain_test_cases[] = { .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | BLOCKCIPHER_TEST_TARGET_PMD_QAT | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | - BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC + BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC | + BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC }, { .test_descr = "AES-128-CBC HMAC-SHA224 Encryption Digest", @@ -1614,7 +1616,8 @@ static const struct blockcipher_test_case aes_cipheronly_test_cases[] = { .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT | - BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC + BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC | + BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC }, { .test_descr = "AES-256-CBC OOP Decryption", @@ -1623,7 +1626,8 @@ static const struct blockcipher_test_case aes_cipheronly_test_cases[] = { .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT | - BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC + BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC | + BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC }, { .test_descr = "AES-128-CTR Encryption", diff --git a/test/test/test_cryptodev_des_test_vectors.h b/test/test/test_cryptodev_des_test_vectors.h index 0602df767e..d09e23de2d 100644 --- a/test/test/test_cryptodev_des_test_vectors.h +++ b/test/test/test_cryptodev_des_test_vectors.h @@ -1188,7 +1188,8 @@ static const struct blockcipher_test_case triple_des_chain_test_cases[] = { .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT | - BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC + BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC | + BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC }, { .test_descr = "3DES-128-CBC HMAC-SHA1 Decryption Digest" @@ -1198,7 +1199,8 @@ static const struct blockcipher_test_case triple_des_chain_test_cases[] = { .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT | - BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC + BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC | + BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC }, { .test_descr = "3DES-128-CBC HMAC-SHA1 Encryption Digest" -- 2.20.1