DPDK patches and discussions
 help / color / mirror / Atom feed
From: Akhil Goyal <akhil.goyal@nxp.com>
To: dev@dpdk.org
Cc: aconole@redhat.com, anoobj@marvell.com,
	Hemant Agrawal <hemant.agrawal@nxp.com>
Subject: [dpdk-dev] [PATCH v3 22/24] crypto/dpaa_sec: dynamic contxt buffer for SG cases
Date: Mon, 30 Sep 2019 20:11:02 +0530	[thread overview]
Message-ID: <20190930144104.12742-23-akhil.goyal@nxp.com> (raw)
In-Reply-To: <20190930144104.12742-1-akhil.goyal@nxp.com>

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This patch allocate/clean the SEC context dynamically
based on the number of SG entries in the buffer.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 43 ++++++++++++++----------------
 drivers/crypto/dpaa_sec/dpaa_sec.h |  8 +++---
 2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 291cba28d..fa9d03adc 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -65,10 +65,10 @@ dpaa_sec_op_ending(struct dpaa_sec_op_ctx *ctx)
 }
 
 static inline struct dpaa_sec_op_ctx *
-dpaa_sec_alloc_ctx(dpaa_sec_session *ses)
+dpaa_sec_alloc_ctx(dpaa_sec_session *ses, int sg_count)
 {
 	struct dpaa_sec_op_ctx *ctx;
-	int retval;
+	int i, retval;
 
 	retval = rte_mempool_get(ses->ctx_pool, (void **)(&ctx));
 	if (!ctx || retval) {
@@ -81,14 +81,11 @@ dpaa_sec_alloc_ctx(dpaa_sec_session *ses)
 	 * to clear all the SG entries. dpaa_sec_alloc_ctx() is called for
 	 * each packet, memset is costlier than dcbz_64().
 	 */
-	dcbz_64(&ctx->job.sg[SG_CACHELINE_0]);
-	dcbz_64(&ctx->job.sg[SG_CACHELINE_1]);
-	dcbz_64(&ctx->job.sg[SG_CACHELINE_2]);
-	dcbz_64(&ctx->job.sg[SG_CACHELINE_3]);
+	for (i = 0; i < sg_count && i < MAX_JOB_SG_ENTRIES; i += 4)
+		dcbz_64(&ctx->job.sg[i]);
 
 	ctx->ctx_pool = ses->ctx_pool;
-	ctx->vtop_offset = (size_t) ctx
-				- rte_mempool_virt2iova(ctx);
+	ctx->vtop_offset = (size_t) ctx - rte_mempool_virt2iova(ctx);
 
 	return ctx;
 }
@@ -855,12 +852,12 @@ build_auth_only_sg(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	else
 		extra_segs = 2;
 
-	if ((mbuf->nb_segs + extra_segs) > MAX_SG_ENTRIES) {
+	if (mbuf->nb_segs > MAX_SG_ENTRIES) {
 		DPAA_SEC_DP_ERR("Auth: Max sec segs supported is %d",
 				MAX_SG_ENTRIES);
 		return NULL;
 	}
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, mbuf->nb_segs + extra_segs);
 	if (!ctx)
 		return NULL;
 
@@ -938,7 +935,7 @@ build_auth_only(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	rte_iova_t start_addr;
 	uint8_t *old_digest;
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, 4);
 	if (!ctx)
 		return NULL;
 
@@ -1008,13 +1005,13 @@ build_cipher_only_sg(struct rte_crypto_op *op, dpaa_sec_session *ses)
 		req_segs = mbuf->nb_segs * 2 + 3;
 	}
 
-	if (req_segs > MAX_SG_ENTRIES) {
+	if (mbuf->nb_segs > MAX_SG_ENTRIES) {
 		DPAA_SEC_DP_ERR("Cipher: Max sec segs supported is %d",
 				MAX_SG_ENTRIES);
 		return NULL;
 	}
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, req_segs);
 	if (!ctx)
 		return NULL;
 
@@ -1094,7 +1091,7 @@ build_cipher_only(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	uint8_t *IV_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
 			ses->iv.offset);
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, 4);
 	if (!ctx)
 		return NULL;
 
@@ -1161,13 +1158,13 @@ build_cipher_auth_gcm_sg(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	if (ses->auth_only_len)
 		req_segs++;
 
-	if (req_segs > MAX_SG_ENTRIES) {
+	if (mbuf->nb_segs > MAX_SG_ENTRIES) {
 		DPAA_SEC_DP_ERR("AEAD: Max sec segs supported is %d",
 				MAX_SG_ENTRIES);
 		return NULL;
 	}
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, req_segs);
 	if (!ctx)
 		return NULL;
 
@@ -1296,7 +1293,7 @@ build_cipher_auth_gcm(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	else
 		dst_start_addr = src_start_addr;
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, 7);
 	if (!ctx)
 		return NULL;
 
@@ -1409,13 +1406,13 @@ build_cipher_auth_sg(struct rte_crypto_op *op, dpaa_sec_session *ses)
 		req_segs = mbuf->nb_segs * 2 + 4;
 	}
 
-	if (req_segs > MAX_SG_ENTRIES) {
+	if (mbuf->nb_segs > MAX_SG_ENTRIES) {
 		DPAA_SEC_DP_ERR("Cipher-Auth: Max sec segs supported is %d",
 				MAX_SG_ENTRIES);
 		return NULL;
 	}
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, req_segs);
 	if (!ctx)
 		return NULL;
 
@@ -1533,7 +1530,7 @@ build_cipher_auth(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	else
 		dst_start_addr = src_start_addr;
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, 7);
 	if (!ctx)
 		return NULL;
 
@@ -1619,7 +1616,7 @@ build_proto(struct rte_crypto_op *op, dpaa_sec_session *ses)
 	struct qm_sg_entry *sg;
 	phys_addr_t src_start_addr, dst_start_addr;
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, 2);
 	if (!ctx)
 		return NULL;
 	cf = &ctx->job;
@@ -1666,13 +1663,13 @@ build_proto_sg(struct rte_crypto_op *op, dpaa_sec_session *ses)
 		mbuf = sym->m_src;
 
 	req_segs = mbuf->nb_segs + sym->m_src->nb_segs + 2;
-	if (req_segs > MAX_SG_ENTRIES) {
+	if (mbuf->nb_segs > MAX_SG_ENTRIES) {
 		DPAA_SEC_DP_ERR("Proto: Max sec segs supported is %d",
 				MAX_SG_ENTRIES);
 		return NULL;
 	}
 
-	ctx = dpaa_sec_alloc_ctx(ses);
+	ctx = dpaa_sec_alloc_ctx(ses, req_segs);
 	if (!ctx)
 		return NULL;
 	cf = &ctx->job;
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.h b/drivers/crypto/dpaa_sec/dpaa_sec.h
index 68461cecc..2a6a3fad7 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.h
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.h
@@ -183,13 +183,11 @@ struct dpaa_sec_dev_private {
 };
 
 #define MAX_SG_ENTRIES		16
-#define SG_CACHELINE_0		0
-#define SG_CACHELINE_1		4
-#define SG_CACHELINE_2		8
-#define SG_CACHELINE_3		12
+#define MAX_JOB_SG_ENTRIES	36
+
 struct dpaa_sec_job {
 	/* sg[0] output, sg[1] input, others are possible sub frames */
-	struct qm_sg_entry sg[MAX_SG_ENTRIES];
+	struct qm_sg_entry sg[MAX_JOB_SG_ENTRIES];
 };
 
 #define DPAA_MAX_NB_MAX_DIGEST	32
-- 
2.17.1


  parent reply	other threads:[~2019-09-30 15:00 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-02 12:17 [dpdk-dev] [PATCH 00/20] crypto/dpaaX_sec: Support Wireless algos Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 01/20] drivers/crypto: Support PDCP 12-bit c-plane processing Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 02/20] drivers/crypto: Support PDCP u-plane with integrity Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 03/20] security: add hfn override option in PDCP Akhil Goyal
2019-09-19 15:31   ` Akhil Goyal
2019-09-24 11:36     ` Ananyev, Konstantin
2019-09-25  7:18     ` Anoob Joseph
2019-09-27 15:06       ` Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 04/20] crypto/dpaaX_sec: update dpovrd for hfn override " Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 05/20] crypto/dpaa2_sec: update desc for pdcp 18bit enc-auth Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 06/20] crypto/dpaa2_sec: support CAAM HW era 10 Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 07/20] crypto/dpaa2_sec/hw: update 12bit SN desc for null auth for ERA8 Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 08/20] crypto/dpaa_sec: support scatter gather for pdcp Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 09/20] crypto/dpaa2_sec: support scatter gather for proto offloads Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 10/20] crypto/dpaa2_sec: disable 'write-safe' for PDCP Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 11/20] crypto/dpaa2_sec/hw: Support 18-bit PDCP enc-auth cases Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 12/20] crypto/dpaa2_sec/hw: Support aes-aes 18-bit PDCP Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 13/20] crypto/dpaa2_sec/hw: Support zuc-zuc " Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 14/20] crypto/dpaa2_sec/hw: Support snow-snow " Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 15/20] crypto/dpaa2_sec/hw: Support snow-f8 Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 16/20] crypto/dpaa2_sec/hw: Support snow-f9 Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 17/20] crypto/dpaa2_sec: Support snow3g cipher/integrity Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 18/20] crypto/dpaa2_sec/hw: Support kasumi Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 19/20] crypto/dpaa2_sec/hw: Support zuc cipher/integrity Akhil Goyal
2019-09-02 12:17 ` [dpdk-dev] [PATCH 20/20] crypto/dpaa2_sec: Support zuc ciphering Akhil Goyal
2019-09-03 14:39 ` [dpdk-dev] [PATCH 00/20] crypto/dpaaX_sec: Support Wireless algos Aaron Conole
2019-09-03 14:42   ` Akhil Goyal
2019-09-30 11:52 ` [dpdk-dev] [PATCH v2 " Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 01/20] drivers/crypto: support PDCP 12-bit c-plane processing Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 02/20] drivers/crypto: support PDCP u-plane with integrity Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 03/20] security: add hfn override option in PDCP Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 04/20] drivers/crypto: support hfn override for NXP PMDs Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 05/20] crypto/dpaa2_sec: update desc for pdcp 18bit enc-auth Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 06/20] crypto/dpaa2_sec: support CAAM HW era 10 Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 07/20] crypto/dpaa2_sec/hw: update 12bit SN desc for NULL auth Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 08/20] crypto/dpaa_sec: support scatter gather for PDCP Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 09/20] crypto/dpaa2_sec: support scatter gather for proto offloads Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 10/20] crypto/dpaa2_sec: disable 'write-safe' for PDCP Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 11/20] crypto/dpaa2_sec/hw: support 18-bit PDCP enc-auth cases Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 12/20] crypto/dpaa2_sec/hw: support aes-aes 18-bit PDCP Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 13/20] crypto/dpaa2_sec/hw: support zuc-zuc " Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 14/20] crypto/dpaa2_sec/hw: support snow-snow " Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 15/20] crypto/dpaa2_sec/hw: support snow-f8 Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 16/20] crypto/dpaa2_sec/hw: support snow-f9 Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 17/20] crypto/dpaa2_sec: support snow3g cipher/integrity Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 18/20] crypto/dpaa2_sec/hw: support kasumi Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 19/20] crypto/dpaa2_sec/hw: support ZUCE and ZUCA Akhil Goyal
2019-09-30 11:52   ` [dpdk-dev] [PATCH v2 20/20] crypto/dpaa2_sec: support zuc ciphering/integrity Akhil Goyal
2019-09-30 13:48   ` [dpdk-dev] [PATCH v2 00/20] crypto/dpaaX_sec: Support Wireless algos Akhil Goyal
2019-09-30 14:40   ` [dpdk-dev] [PATCH v3 00/24] " Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 01/24] drivers/crypto: support PDCP 12-bit c-plane processing Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 02/24] drivers/crypto: support PDCP u-plane with integrity Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 03/24] security: add hfn override option in PDCP Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 04/24] drivers/crypto: support hfn override for NXP PMDs Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 05/24] crypto/dpaa2_sec: update desc for pdcp 18bit enc-auth Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 06/24] crypto/dpaa2_sec: support CAAM HW era 10 Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 07/24] crypto/dpaa2_sec/hw: update 12bit SN desc for NULL auth Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 08/24] crypto/dpaa_sec: support scatter gather for PDCP Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 09/24] crypto/dpaa2_sec: support scatter gather for proto offloads Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 10/24] crypto/dpaa2_sec: disable 'write-safe' for PDCP Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 11/24] crypto/dpaa2_sec/hw: support 18-bit PDCP enc-auth cases Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 12/24] crypto/dpaa2_sec/hw: support aes-aes 18-bit PDCP Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 13/24] crypto/dpaa2_sec/hw: support zuc-zuc " Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 14/24] crypto/dpaa2_sec/hw: support snow-snow " Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 15/24] crypto/dpaa2_sec/hw: support snow-f8 Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 16/24] crypto/dpaa2_sec/hw: support snow-f9 Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 17/24] crypto/dpaa2_sec: support snow3g cipher/integrity Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 18/24] crypto/dpaa2_sec/hw: support kasumi Akhil Goyal
2019-09-30 14:40     ` [dpdk-dev] [PATCH v3 19/24] crypto/dpaa2_sec/hw: support ZUCE and ZUCA Akhil Goyal
2019-09-30 14:41     ` [dpdk-dev] [PATCH v3 20/24] crypto/dpaa2_sec: support zuc ciphering/integrity Akhil Goyal
2019-09-30 14:41     ` [dpdk-dev] [PATCH v3 21/24] crypto/dpaa2_sec: allocate context as per num segs Akhil Goyal
2019-09-30 14:41     ` Akhil Goyal [this message]
2019-09-30 14:41     ` [dpdk-dev] [PATCH v3 23/24] crypto/dpaa_sec: change per cryptodev pool to per qp Akhil Goyal
2019-09-30 14:41     ` [dpdk-dev] [PATCH v3 24/24] crypto/dpaa2_sec: improve debug logging Akhil Goyal
2019-09-30 20:08     ` [dpdk-dev] [PATCH v3 00/24] crypto/dpaaX_sec: Support Wireless algos Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190930144104.12742-23-akhil.goyal@nxp.com \
    --to=akhil.goyal@nxp.com \
    --cc=aconole@redhat.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).