diff mbox

[dpdk-dev] crypto/dpaa_sec: add support for out of place buffers

Message ID 20171012130726.4332-6-alok.makhariya@nxp.com (mailing list archive)
State Changes Requested, archived
Delegated to: Pablo de Lara Guarch
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

alok.makhariya@nxp.com Oct. 12, 2017, 1:07 p.m. UTC
From: Alok Makhariya <alok.makhariya@nxp.com>

Enable out of place buffer test cases in dpaa_sec

Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c          | 45 +++++++++++++++++++----------
 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(+), 22 deletions(-)

Comments

Akhil Goyal Oct. 13, 2017, 2:25 p.m. UTC | #1
On 10/12/2017 6:37 PM, alok.makhariya@nxp.com wrote:
> From: Alok Makhariya <alok.makhariya@nxp.com>
> 
> Enable out of place buffer test cases in dpaa_sec
> 
> Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
> ---
>   drivers/crypto/dpaa_sec/dpaa_sec.c          | 45 +++++++++++++++++++----------
>   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(+), 22 deletions(-)
> 

Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Pablo de Lara Oct. 16, 2017, 11:33 a.m. UTC | #2
> -----Original Message-----

> From: Akhil Goyal [mailto:akhil.goyal@nxp.com]

> Sent: Friday, October 13, 2017 3:26 PM

> To: alok.makhariya@nxp.com; dev@dpdk.org

> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;

> hemant.agrawal@nxp.com

> Subject: Re: [PATCH] crypto/dpaa_sec: add support for out of place buffers

> 

> On 10/12/2017 6:37 PM, alok.makhariya@nxp.com wrote:

> > From: Alok Makhariya <alok.makhariya@nxp.com>

> >

> > Enable out of place buffer test cases in dpaa_sec

> >

> > Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>

> > ---

> >   drivers/crypto/dpaa_sec/dpaa_sec.c          | 45 +++++++++++++++++++-

> ---------

> >   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(+), 22 deletions(-)

> >

> 

> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>


One note here. This patch depends on the dpaa2_sec patch.
For next time, either state the dependency or send both as a patchset.

Applied to dpdk-next-crypto.
Thanks,

Pablo
diff mbox

Patch

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index b618b59..70db1bc 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);
 
@@ -639,9 +638,16 @@  build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	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 +667,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 +679,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 +720,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 +740,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 +765,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 +791,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 = mbuf->buf_physaddr + mbuf->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 +823,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 +836,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 +860,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 f889ecd..72584ab 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -8629,6 +8629,12 @@  static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
 		TEST_CASE_ST(ut_setup, ut_teardown,
 						test_DES_docsis_mb_all),
 
+		/** Out of place tests */
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_mb_AES_GCM_authenticated_encryption_oop),
+		TEST_CASE_ST(ut_setup, ut_teardown,
+			test_mb_AES_GCM_authenticated_decryption_oop),
+
 		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 32c5deb..54ac8d6 100644
--- a/test/test/test_cryptodev_aes_test_vectors.h
+++ b/test/test/test_cryptodev_aes_test_vectors.h
@@ -1432,7 +1432,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 "
@@ -1443,7 +1444,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",
@@ -1594,7 +1596,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",
@@ -1603,7 +1606,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 e4efd23..259a540 100644
--- a/test/test/test_cryptodev_des_test_vectors.h
+++ b/test/test/test_cryptodev_des_test_vectors.h
@@ -1182,7 +1182,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"
@@ -1192,7 +1193,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"