crypto/dpaa_sec: support out of place buffers
authorAlok Makhariya <alok.makhariya@nxp.com>
Sun, 22 Oct 2017 19:35:51 +0000 (01:05 +0530)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 25 Oct 2017 16:11:00 +0000 (18:11 +0200)
Enable out of place buffer test cases in dpaa_sec

Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/crypto/dpaa_sec/dpaa_sec.c
test/test/test_cryptodev.c
test/test/test_cryptodev_aes_test_vectors.h
test/test/test_cryptodev_des_test_vectors.h

index 53f004e..26a29a4 100644 (file)
@@ -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)) {
index cb9b486..72988c5 100644 (file)
@@ -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 */
        }
 };
index 050d868..9c13041 100644 (file)
@@ -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",
index 0602df7..d09e23d 100644 (file)
@@ -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"