From patchwork Fri May 16 07:27:44 2025
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Hanxiao Li
X-Patchwork-Id: 153477
X-Patchwork-Delegate: gakhil@marvell.com
Return-Path:
X-Original-To: patchwork@inbox.dpdk.org
Delivered-To: patchwork@inbox.dpdk.org
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
by inbox.dpdk.org (Postfix) with ESMTP id 0E39546760;
Fri, 16 May 2025 09:32:17 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
by mails.dpdk.org (Postfix) with ESMTP id 843D04065D;
Fri, 16 May 2025 09:31:40 +0200 (CEST)
Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35])
by mails.dpdk.org (Postfix) with ESMTP id CC2DB4060C
for ; Fri, 16 May 2025 09:31:36 +0200 (CEST)
Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mxhk.zte.com.cn (FangMail) with ESMTPS id 4ZzJfv6Jdjz5B1Jd
for ; Fri, 16 May 2025 15:31:35 +0800 (CST)
Received: from szxlzmapp01.zte.com.cn ([10.5.231.85])
by mse-fl1.zte.com.cn with SMTP id 54G7VCjD006330
for ; Fri, 16 May 2025 15:31:12 +0800 (+08)
(envelope-from li.hanxiao@zte.com.cn)
Received: from localhost.localdomain (unknown [192.168.6.15])
by smtp (Zmail) with SMTP; Fri, 16 May 2025 15:31:14 +0800
X-Zmail-TransId: 3e816826e9c2004-de5a6
From: Hanxiao Li
To: dev@dpdk.org
Cc: Hanxiao Li
Subject: [PATCH v4 2/9] crypto/zsda: add device operations
Date: Fri, 16 May 2025 15:27:44 +0800
Message-ID: <20250516072752.1971299-3-li.hanxiao@zte.com.cn>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20250516072752.1971299-1-li.hanxiao@zte.com.cn>
References: <20250515101927.1926502-2-li.hanxiao@zte.com.cn>
<20250516072752.1971299-1-li.hanxiao@zte.com.cn>
MIME-Version: 1.0
X-MAIL: mse-fl1.zte.com.cn 54G7VCjD006330
X-Fangmail-Anti-Spam-Filtered: true
X-Fangmail-MID-QID: 6826E9D7.003/4ZzJfv6Jdjz5B1Jd
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: dev-bounces@dpdk.org
Add crypto device operations for zsda devices.
Signed-off-by: Hanxiao Li
---
drivers/crypto/zsda/zsda_crypto_pmd.c | 82 +++++++++++++++++++++++++--
1 file changed, 77 insertions(+), 5 deletions(-)
--
2.27.0
diff --git a/drivers/crypto/zsda/zsda_crypto_pmd.c b/drivers/crypto/zsda/zsda_crypto_pmd.c
index 99acfa3418..04c4e45843 100644
--- a/drivers/crypto/zsda/zsda_crypto_pmd.c
+++ b/drivers/crypto/zsda/zsda_crypto_pmd.c
@@ -8,12 +8,82 @@
uint8_t zsda_crypto_driver_id;
+static int
+zsda_dev_config(__rte_unused struct rte_cryptodev *dev,
+ __rte_unused struct rte_cryptodev_config *config)
+{
+ return ZSDA_SUCCESS;
+}
+
+static int
+zsda_dev_start(struct rte_cryptodev *dev)
+{
+ struct zsda_crypto_dev_private *crypto_dev = dev->data->dev_private;
+ int ret;
+
+ ret = zsda_queue_start(crypto_dev->zsda_pci_dev->pci_dev);
+
+ return ret;
+}
+
+static void
+zsda_dev_stop(struct rte_cryptodev *dev)
+{
+ struct zsda_crypto_dev_private *crypto_dev = dev->data->dev_private;
+
+ zsda_queue_stop(crypto_dev->zsda_pci_dev->pci_dev);
+}
+
+static int
+zsda_dev_close(struct rte_cryptodev *dev __rte_unused)
+{
+ int ret = ZSDA_SUCCESS;
+ return ret;
+}
+
+static uint16_t
+zsda_crypto_max_nb_qps(void)
+{
+ uint16_t encrypt = zsda_nb_qps.encrypt;
+ uint16_t decrypt = zsda_nb_qps.decrypt;
+ uint16_t hash = zsda_nb_qps.hash;
+ uint16_t min = 0;
+
+ if ((encrypt == MAX_QPS_ON_FUNCTION) ||
+ (decrypt == MAX_QPS_ON_FUNCTION) ||
+ (hash == MAX_QPS_ON_FUNCTION))
+ min = MAX_QPS_ON_FUNCTION;
+ else {
+ min = (encrypt < decrypt) ? encrypt : decrypt;
+ min = (min < hash) ? min : hash;
+ }
+
+ if (min == 0)
+ return MAX_QPS_ON_FUNCTION;
+ return min;
+}
+
+static void
+zsda_dev_info_get(struct rte_cryptodev *dev,
+ struct rte_cryptodev_info *info)
+{
+ struct zsda_crypto_dev_private *crypto_dev_priv = dev->data->dev_private;
+
+ if (info != NULL) {
+ info->max_nb_queue_pairs = zsda_crypto_max_nb_qps();
+ info->feature_flags = dev->feature_flags;
+ info->capabilities = crypto_dev_priv->zsda_crypto_capabilities;
+ info->driver_id = zsda_crypto_driver_id;
+ info->sym.max_nb_sessions = 0;
+ }
+}
+
static struct rte_cryptodev_ops crypto_zsda_ops = {
- .dev_configure = NULL,
- .dev_start = NULL,
- .dev_stop = NULL,
- .dev_close = NULL,
- .dev_infos_get = NULL,
+ .dev_configure = zsda_dev_config,
+ .dev_start = zsda_dev_start,
+ .dev_stop = zsda_dev_stop,
+ .dev_close = zsda_dev_close,
+ .dev_infos_get = zsda_dev_info_get,
.stats_get = NULL,
.stats_reset = NULL,
@@ -105,6 +175,8 @@ zsda_crypto_dev_destroy(struct zsda_pci_device *zsda_pci_dev)
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_memzone_free(crypto_dev_priv->capa_mz);
+ zsda_dev_close(crypto_dev_priv->cryptodev);
+
rte_cryptodev_pmd_destroy(crypto_dev_priv->cryptodev);
zsda_devs[zsda_pci_dev->zsda_dev_id].crypto_rte_dev.name = NULL;
zsda_pci_dev->crypto_dev_priv = NULL;