From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org, gakhil@marvell.com,
Hemant Agrawal <hemant.agrawal@nxp.com>,
Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [PATCH v2 4/9] crypto/dpaa2_sec: change custom device API to standard
Date: Wed, 21 May 2025 12:26:53 +0530 [thread overview]
Message-ID: <20250521065658.857707-5-g.singh@nxp.com> (raw)
In-Reply-To: <20250521065658.857707-1-g.singh@nxp.com>
Replacing existing device creation and deletion code in probe and
remove functions with rte_cryptodev_pmd_create() and
rte_cryptodev_pmd_destroy() APIs provided by the DPDK library,
simplifying drivers initialization and teardown.
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 38 +++++++------------
drivers/crypto/dpaa_sec/dpaa_sec.c | 42 +++++++--------------
2 files changed, 27 insertions(+), 53 deletions(-)
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 0ccadecff4..925d2709d2 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2016-2023 NXP
+ * Copyright 2016-2025 NXP
*
*/
@@ -4413,33 +4413,27 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
{
struct rte_cryptodev *cryptodev;
char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-
int retval;
+ struct rte_cryptodev_pmd_init_params init_params = {
+ .name = "",
+ .private_data_size = sizeof(struct dpaa2_sec_dev_private),
+ .socket_id = rte_socket_id(),
+ .max_nb_queue_pairs =
+ RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS,
+ /* setting default, will be updated in init. */
+ };
snprintf(cryptodev_name, sizeof(cryptodev_name), "dpsec-%d",
dpaa2_dev->object_id);
- cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
- if (cryptodev == NULL)
+ cryptodev = rte_cryptodev_pmd_create(cryptodev_name, &dpaa2_dev->device,
+ &init_params);
+ if (cryptodev == NULL) {
+ DPAA2_SEC_ERR("failed to create cryptodev vdev");
return -ENOMEM;
-
- if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- cryptodev->data->dev_private = rte_zmalloc_socket(
- "cryptodev private structure",
- sizeof(struct dpaa2_sec_dev_private),
- RTE_CACHE_LINE_SIZE,
- rte_socket_id());
-
- if (cryptodev->data->dev_private == NULL)
- rte_panic("Cannot allocate memzone for private "
- "device data");
}
dpaa2_dev->cryptodev = cryptodev;
- cryptodev->device = &dpaa2_dev->device;
-
- /* init user callbacks */
- TAILQ_INIT(&(cryptodev->link_intr_cbs));
if (dpaa2_svr_family == SVR_LX2160A)
rta_set_sec_era(RTA_SEC_ERA_10);
@@ -4454,11 +4448,7 @@ cryptodev_dpaa2_sec_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
rte_cryptodev_pmd_probing_finish(cryptodev);
return 0;
}
-
- if (rte_eal_process_type() == RTE_PROC_PRIMARY)
- rte_free(cryptodev->data->dev_private);
-
- cryptodev->attached = RTE_CRYPTODEV_DETACHED;
+ rte_cryptodev_pmd_destroy(cryptodev);
return -ENXIO;
}
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index bcea4ff3ab..58d691d8a6 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2017-2024 NXP
+ * Copyright 2017-2025 NXP
*
*/
@@ -3614,16 +3614,10 @@ static const struct rte_security_ops dpaa_sec_security_ops = {
static int
dpaa_sec_uninit(struct rte_cryptodev *dev)
{
- struct dpaa_sec_dev_private *internals;
-
if (dev == NULL)
return -ENODEV;
- internals = dev->data->dev_private;
rte_free(dev->security_ctx);
-
- rte_free(internals);
-
DPAA_SEC_INFO("Closing DPAA_SEC device %s on numa socket %u",
dev->data->name, rte_socket_id());
@@ -3780,33 +3774,26 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused,
{
struct rte_cryptodev *cryptodev;
char cryptodev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-
int retval;
+ struct rte_cryptodev_pmd_init_params init_params = {
+ .name = "",
+ .private_data_size = sizeof(struct dpaa_sec_dev_private),
+ .socket_id = rte_socket_id(),
+ .max_nb_queue_pairs =
+ RTE_DPAA_MAX_NB_SEC_QPS,
+ };
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
snprintf(cryptodev_name, sizeof(cryptodev_name), "%s", dpaa_dev->name);
- cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
- if (cryptodev == NULL)
+ cryptodev = rte_cryptodev_pmd_create(cryptodev_name, &dpaa_dev->device, &init_params);
+ if (cryptodev == NULL) {
+ DPAA_SEC_ERR("failed to create cryptodev vdev");
return -ENOMEM;
-
- cryptodev->data->dev_private = rte_zmalloc_socket(
- "cryptodev private structure",
- sizeof(struct dpaa_sec_dev_private),
- RTE_CACHE_LINE_SIZE,
- rte_socket_id());
-
- if (cryptodev->data->dev_private == NULL)
- rte_panic("Cannot allocate memzone for private "
- "device data");
-
+ }
dpaa_dev->crypto_dev = cryptodev;
- cryptodev->device = &dpaa_dev->device;
-
- /* init user callbacks */
- TAILQ_INIT(&(cryptodev->link_intr_cbs));
/* if sec device version is not configured */
if (!rta_get_sec_era()) {
@@ -3841,10 +3828,7 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused,
retval = -ENXIO;
out:
- /* In case of error, cleanup is done */
- rte_free(cryptodev->data->dev_private);
-
- rte_cryptodev_pmd_release_device(cryptodev);
+ rte_cryptodev_pmd_destroy(cryptodev);
return retval;
}
--
2.25.1
next prev parent reply other threads:[~2025-05-21 6:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 5:51 [PATCH 1/9] common/dpaax: fix invalid key command error Gagandeep Singh
2025-05-20 5:51 ` [PATCH 2/9] common/dpaax: fix for PDCP AES only 12bit SN case Gagandeep Singh
2025-05-20 5:51 ` [PATCH 3/9] common/dpaax: support 12bit SN in pdcp uplane Gagandeep Singh
2025-05-20 6:18 ` Hemant Agrawal
2025-05-21 4:50 ` Gagandeep Singh
2025-05-20 5:51 ` [PATCH 4/9] crypto/dpaa2_sec: change custom device API to standard Gagandeep Singh
2025-05-20 5:51 ` [PATCH 5/9] crypto/dpaa2_sec: fix coverity Issues Gagandeep Singh
2025-05-20 5:51 ` [PATCH 6/9] crypto/dpaa2_sec: add null algo capability Gagandeep Singh
2025-05-20 6:20 ` Hemant Agrawal
2025-05-21 4:51 ` Gagandeep Singh
2025-05-20 5:51 ` [PATCH 7/9] net/dpaa2: configure buffer layout Gagandeep Singh
2025-05-20 5:51 ` [PATCH 8/9] mempool/dpaa2: mempool operation index Gagandeep Singh
2025-05-20 5:51 ` [PATCH 9/9] crypto/dpaa2_sec: add support for simple IPsec FD Gagandeep Singh
2025-05-20 6:16 ` [PATCH 1/9] common/dpaax: fix invalid key command error Hemant Agrawal
2025-05-21 4:43 ` Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 0/9] DPAA2 crypto driver changes Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 1/9] common/dpaax: fix invalid key command error Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 2/9] common/dpaax: fix for PDCP AES only 12bit SN case Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 3/9] common/dpaax: support 12bit SN in pdcp uplane Gagandeep Singh
2025-05-21 6:56 ` Gagandeep Singh [this message]
2025-05-21 6:56 ` [PATCH v2 5/9] crypto/dpaa2_sec: fix coverity Issues Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 6/9] crypto/dpaa2_sec: add null algo capability Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 7/9] net/dpaa2: configure buffer layout Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 8/9] mempool/dpaa2: mempool operation index Gagandeep Singh
2025-05-21 6:56 ` [PATCH v2 9/9] crypto/dpaa2_sec: add support for simple IPsec FD Gagandeep Singh
2025-05-21 11:59 ` [EXTERNAL] [PATCH v2 0/9] DPAA2 crypto driver changes 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=20250521065658.857707-5-g.singh@nxp.com \
--to=g.singh@nxp.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--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).