DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: pablo.de.lara.guarch@intel.com, akhil.goyal@nxp.com
Subject: [dpdk-dev] [PATCH v2 7/8] crypto/dpaa_sec: move mempool allocation to config
Date: Mon,  2 Apr 2018 13:06:33 +0530	[thread overview]
Message-ID: <1522654594-2757-7-git-send-email-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <1522654594-2757-1-git-send-email-hemant.agrawal@nxp.com>

From: Akhil Goyal <akhil.goyal@nxp.com>

Currently, the context mempools are allocated during device probe. Thus,
even if the DPAA SEC devices are not used, any application would still
allocate the memory required for working with the contexts.

This patch moves the allocation to configuration time so that when the
CAAM devices are configured, this allocation would be done.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
Signed-off-by: Ashish Jain <ashish.jain@nxp.com>
Tested-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 49 ++++++++++++++++++++++++++------------
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 2df5e5c..c7f7cdf 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2169,11 +2169,32 @@ dpaa_sec_security_session_destroy(void *dev __rte_unused,
 
 
 static int
-dpaa_sec_dev_configure(struct rte_cryptodev *dev __rte_unused,
+dpaa_sec_dev_configure(struct rte_cryptodev *dev,
 		       struct rte_cryptodev_config *config __rte_unused)
 {
+
+	char str[20];
+	struct dpaa_sec_dev_private *internals;
+
 	PMD_INIT_FUNC_TRACE();
 
+	internals = dev->data->dev_private;
+	sprintf(str, "ctx_pool_%d", dev->data->dev_id);
+	if (!internals->ctx_pool) {
+		internals->ctx_pool = rte_mempool_create((const char *)str,
+							CTX_POOL_NUM_BUFS,
+							CTX_POOL_BUF_SIZE,
+							CTX_POOL_CACHE_SIZE, 0,
+							NULL, NULL, NULL, NULL,
+							SOCKET_ID_ANY, 0);
+		if (!internals->ctx_pool) {
+			RTE_LOG(ERR, PMD, "%s create failed\n", str);
+			return -ENOMEM;
+		}
+	} else
+		RTE_LOG(INFO, PMD, "mempool already created for dev_id : %d\n",
+			dev->data->dev_id);
+
 	return 0;
 }
 
@@ -2191,9 +2212,19 @@ dpaa_sec_dev_stop(struct rte_cryptodev *dev __rte_unused)
 }
 
 static int
-dpaa_sec_dev_close(struct rte_cryptodev *dev __rte_unused)
+dpaa_sec_dev_close(struct rte_cryptodev *dev)
 {
+	struct dpaa_sec_dev_private *internals;
+
 	PMD_INIT_FUNC_TRACE();
+
+	if (dev == NULL)
+		return -ENOMEM;
+
+	internals = dev->data->dev_private;
+	rte_mempool_free(internals->ctx_pool);
+	internals->ctx_pool = NULL;
+
 	return 0;
 }
 
@@ -2260,6 +2291,7 @@ dpaa_sec_uninit(struct rte_cryptodev *dev)
 	internals = dev->data->dev_private;
 	rte_free(dev->security_ctx);
 
+	/* In case close has been called, internals->ctx_pool would be NULL */
 	rte_mempool_free(internals->ctx_pool);
 	rte_free(internals);
 
@@ -2277,7 +2309,6 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev)
 	struct dpaa_sec_qp *qp;
 	uint32_t i, flags;
 	int ret;
-	char str[20];
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -2337,18 +2368,6 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev)
 		}
 	}
 
-	sprintf(str, "ctx_pool_%d", cryptodev->data->dev_id);
-	internals->ctx_pool = rte_mempool_create((const char *)str,
-			CTX_POOL_NUM_BUFS,
-			CTX_POOL_BUF_SIZE,
-			CTX_POOL_CACHE_SIZE, 0,
-			NULL, NULL, NULL, NULL,
-			SOCKET_ID_ANY, 0);
-	if (!internals->ctx_pool) {
-		RTE_LOG(ERR, PMD, "%s create failed\n", str);
-		goto init_error;
-	}
-
 	PMD_INIT_LOG(DEBUG, "driver %s: created\n", cryptodev->data->name);
 	return 0;
 
-- 
2.7.4

  parent reply	other threads:[~2018-04-02  7:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 12:00 [dpdk-dev] [PATCH 1/7] test/crypto: add macro for dpaa sec device name Hemant Agrawal
2018-03-27 12:00 ` [dpdk-dev] [PATCH 2/7] app/crypto-perf: fix excess crypto device error Hemant Agrawal
2018-03-30 16:01   ` De Lara Guarch, Pablo
2018-03-27 12:00 ` [dpdk-dev] [PATCH 3/7] app/crypto-perf: enable it for non default mempool Hemant Agrawal
2018-03-30 16:02   ` De Lara Guarch, Pablo
2018-03-30 16:11   ` De Lara Guarch, Pablo
2018-03-27 12:00 ` [dpdk-dev] [PATCH 4/7] crypto/dpaa_sec: add macro for device name Hemant Agrawal
2018-03-27 12:00 ` [dpdk-dev] [PATCH 5/7] crypto/dpaa_sec: fix to check the portal presence Hemant Agrawal
2018-03-27 12:00 ` [dpdk-dev] [PATCH 6/7] crypto/dpaa_sec: fix incorrect NULL check Hemant Agrawal
2018-03-27 12:00 ` [dpdk-dev] [PATCH 7/7] crypto/dpaa_sec: move mempool allocation to config Hemant Agrawal
2018-03-30 16:01 ` [dpdk-dev] [PATCH 1/7] test/crypto: add macro for dpaa sec device name De Lara Guarch, Pablo
2018-04-02  7:36 ` [dpdk-dev] [PATCH v2 1/8] " Hemant Agrawal
2018-04-02  7:36   ` [dpdk-dev] [PATCH v2 2/8] app/crypto-perf: fix excess crypto device error Hemant Agrawal
2018-04-02  7:36   ` [dpdk-dev] [PATCH v2 3/8] app/crypto-perf: enable it for non default mempool Hemant Agrawal
2018-04-02  7:36   ` [dpdk-dev] [PATCH v2 4/8] crypto/dpaa_sec: add macro for device name Hemant Agrawal
2018-04-02  7:36   ` [dpdk-dev] [PATCH v2 5/8] crypto/dpaa_sec: fix to check the portal presence Hemant Agrawal
2018-04-02  7:36   ` [dpdk-dev] [PATCH v2 6/8] crypto/dpaa_sec: fix incorrect NULL check Hemant Agrawal
2018-04-02  7:36   ` Hemant Agrawal [this message]
2018-04-02  7:36   ` [dpdk-dev] [PATCH v2 8/8] crypto/dpaa2_sec: fix OP storage for physical IOVA mode Hemant Agrawal
2018-04-02 13:35     ` De Lara Guarch, Pablo
2018-04-02 15:33   ` [dpdk-dev] [PATCH] sec Hemant Agrawal
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 1/8] test/crypto: add macro for dpaa sec device name Hemant Agrawal
2018-04-03  9:34       ` De Lara Guarch, Pablo
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 2/8] app/crypto-perf: fix excess crypto device error Hemant Agrawal
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 3/8] app/crypto-perf: enable it for non default mempool Hemant Agrawal
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 4/8] crypto/dpaa_sec: add macro for device name Hemant Agrawal
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 5/8] crypto/dpaa_sec: fix to check the portal presence Hemant Agrawal
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 6/8] crypto/dpaa_sec: fix incorrect NULL check Hemant Agrawal
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 7/8] crypto/dpaa_sec: move mempool allocation to config Hemant Agrawal
2018-04-02 15:33     ` [dpdk-dev] [PATCH v3 8/8] crypto/dpaa2_sec: fix OP storage for physical IOVA mode Hemant Agrawal
2018-04-02 15:46     ` [dpdk-dev] [PATCH] sec Hemant Agrawal

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=1522654594-2757-7-git-send-email-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.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).