DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Boyer <andrew.boyer@amd.com>
To: <dev@dpdk.org>
Cc: Andrew Boyer <andrew.boyer@amd.com>
Subject: [PATCH v2 5/9] crypto/ionic: add capabilities and basic ops
Date: Tue, 30 Apr 2024 13:21:40 -0700	[thread overview]
Message-ID: <20240430202144.49899-6-andrew.boyer@amd.com> (raw)
In-Reply-To: <20240430202144.49899-1-andrew.boyer@amd.com>

This exposes the supported capabilities to the stack.

Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
---
 drivers/crypto/ionic/ionic_crypto.h      |  3 ++
 drivers/crypto/ionic/ionic_crypto_caps.c | 25 +++++++++
 drivers/crypto/ionic/ionic_crypto_main.c |  8 +++
 drivers/crypto/ionic/ionic_crypto_ops.c  | 66 ++++++++++++++++++++++++
 drivers/crypto/ionic/meson.build         |  2 +
 5 files changed, 104 insertions(+)
 create mode 100644 drivers/crypto/ionic/ionic_crypto_caps.c
 create mode 100644 drivers/crypto/ionic/ionic_crypto_ops.c

diff --git a/drivers/crypto/ionic/ionic_crypto.h b/drivers/crypto/ionic/ionic_crypto.h
index 065e1bd826..f487768c10 100644
--- a/drivers/crypto/ionic/ionic_crypto.h
+++ b/drivers/crypto/ionic/ionic_crypto.h
@@ -34,6 +34,8 @@ extern int iocpt_logtype;
 
 #define IOCPT_PRINT_CALL() IOCPT_PRINT(DEBUG, " >>")
 
+const struct rte_cryptodev_capabilities *iocpt_get_caps(uint64_t flags);
+
 static inline void iocpt_struct_size_checks(void)
 {
 	RTE_BUILD_BUG_ON(sizeof(struct ionic_doorbell) != 8);
@@ -227,6 +229,7 @@ int iocpt_probe(void *bus_dev, struct rte_device *rte_dev,
 int iocpt_remove(struct rte_device *rte_dev);
 
 void iocpt_configure(struct iocpt_dev *dev);
+int iocpt_assign_ops(struct rte_cryptodev *cdev);
 void iocpt_deinit(struct iocpt_dev *dev);
 
 int iocpt_dev_identify(struct iocpt_dev *dev);
diff --git a/drivers/crypto/ionic/ionic_crypto_caps.c b/drivers/crypto/ionic/ionic_crypto_caps.c
new file mode 100644
index 0000000000..c22681fabc
--- /dev/null
+++ b/drivers/crypto/ionic/ionic_crypto_caps.c
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2021-2024 Advanced Micro Devices, Inc.
+ */
+
+#include <rte_cryptodev.h>
+
+#include "ionic_crypto.h"
+
+static const struct rte_cryptodev_capabilities iocpt_sym_caps[] = {
+	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
+};
+
+static const struct rte_cryptodev_capabilities iocpt_asym_caps[] = {
+	/* None */
+	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
+};
+
+const struct rte_cryptodev_capabilities *
+iocpt_get_caps(uint64_t flags)
+{
+	if (flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)
+		return iocpt_asym_caps;
+	else
+		return iocpt_sym_caps;
+}
diff --git a/drivers/crypto/ionic/ionic_crypto_main.c b/drivers/crypto/ionic/ionic_crypto_main.c
index 8d4ee7f29f..3ff2d51950 100644
--- a/drivers/crypto/ionic/ionic_crypto_main.c
+++ b/drivers/crypto/ionic/ionic_crypto_main.c
@@ -505,8 +505,16 @@ iocpt_probe(void *bus_dev, struct rte_device *rte_dev,
 		goto err_free_objs;
 	}
 
+	err = iocpt_assign_ops(cdev);
+	if (err != 0) {
+		IOCPT_PRINT(ERR, "Failed to configure opts");
+		goto err_deinit_dev;
+	}
+
 	return 0;
 
+err_deinit_dev:
+	iocpt_deinit(dev);
 err_free_objs:
 	iocpt_free_objs(dev);
 err_destroy_crypto_dev:
diff --git a/drivers/crypto/ionic/ionic_crypto_ops.c b/drivers/crypto/ionic/ionic_crypto_ops.c
new file mode 100644
index 0000000000..74a6ce56ea
--- /dev/null
+++ b/drivers/crypto/ionic/ionic_crypto_ops.c
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2021-2024 Advanced Micro Devices, Inc.
+ */
+
+#include <rte_cryptodev.h>
+#include <cryptodev_pmd.h>
+#include <rte_errno.h>
+#include <rte_malloc.h>
+#include <rte_mempool.h>
+
+#include "ionic_crypto.h"
+
+static int
+iocpt_op_config(struct rte_cryptodev *cdev,
+		struct rte_cryptodev_config *config __rte_unused)
+{
+	struct iocpt_dev *dev = cdev->data->dev_private;
+
+	iocpt_configure(dev);
+
+	return 0;
+}
+
+static int
+iocpt_op_close(struct rte_cryptodev *cdev)
+{
+	struct iocpt_dev *dev = cdev->data->dev_private;
+
+	iocpt_deinit(dev);
+
+	return 0;
+}
+
+static void
+iocpt_op_info_get(struct rte_cryptodev *cdev, struct rte_cryptodev_info *info)
+{
+	struct iocpt_dev *dev = cdev->data->dev_private;
+
+	if (info == NULL)
+		return;
+
+	info->max_nb_queue_pairs = dev->max_qps;
+	info->feature_flags = dev->features;
+	info->capabilities = iocpt_get_caps(info->feature_flags);
+	info->sym.max_nb_sessions = dev->max_sessions;
+	info->driver_id = dev->driver_id;
+	info->min_mbuf_headroom_req = 0;
+	info->min_mbuf_tailroom_req = 0;
+}
+
+static struct rte_cryptodev_ops iocpt_ops = {
+	.dev_configure = iocpt_op_config,
+	.dev_close = iocpt_op_close,
+	.dev_infos_get = iocpt_op_info_get,
+};
+
+int
+iocpt_assign_ops(struct rte_cryptodev *cdev)
+{
+	struct iocpt_dev *dev = cdev->data->dev_private;
+
+	cdev->dev_ops = &iocpt_ops;
+	cdev->feature_flags = dev->features;
+
+	return 0;
+}
diff --git a/drivers/crypto/ionic/meson.build b/drivers/crypto/ionic/meson.build
index a6e0a1d415..b63428fa9b 100644
--- a/drivers/crypto/ionic/meson.build
+++ b/drivers/crypto/ionic/meson.build
@@ -5,8 +5,10 @@ deps += ['bus_vdev']
 deps += ['common_ionic']
 
 sources = files(
+        'ionic_crypto_caps.c',
         'ionic_crypto_cmds.c',
         'ionic_crypto_main.c',
+        'ionic_crypto_ops.c',
         'ionic_crypto_vdev.c',
 )
 name = 'ionic_crypto'
-- 
2.17.1


  parent reply	other threads:[~2024-04-30 20:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 19:53 [PATCH 0/6] crypto/ionic: introduce AMD Pensando ionic crypto driver Andrew Boyer
2024-04-19 19:53 ` [PATCH 1/6] " Andrew Boyer
2024-04-19 19:53 ` [PATCH 2/6] crypto/ionic: add device and admin command handlers Andrew Boyer
2024-04-22 12:29   ` Boyer, Andrew
2024-04-19 19:53 ` [PATCH 3/6] common/ionic: add crypto vdev support Andrew Boyer
2024-04-19 19:53 ` [PATCH 4/6] crypto/ionic: add device object and " Andrew Boyer
2024-04-19 19:53 ` [PATCH 5/6] crypto/ionic: add datapath and capabilities support Andrew Boyer
2024-04-19 19:53 ` [PATCH 6/6] crypto/ionic: add documentation and connect to build Andrew Boyer
2024-04-24 18:21 ` [EXTERNAL] [PATCH 0/6] crypto/ionic: introduce AMD Pensando ionic crypto driver Akhil Goyal
2024-04-30 20:21 ` [PATCH v2 0/9] " Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 1/9] " Andrew Boyer
2024-05-30 12:02     ` [EXTERNAL] " Akhil Goyal
2024-04-30 20:21   ` [PATCH v2 2/9] crypto/ionic: add the firmware interface definition file Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 3/9] crypto/ionic: add device commands Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 4/9] crypto/ionic: add adminq command support Andrew Boyer
2024-04-30 20:21   ` Andrew Boyer [this message]
2024-04-30 20:21   ` [PATCH v2 6/9] crypto/ionic: add session support Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 7/9] crypto/ionic: add datapath Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 8/9] crypto/ionic: add a watchdog operation Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 9/9] crypto/ionic: add stats support Andrew Boyer

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=20240430202144.49899-6-andrew.boyer@amd.com \
    --to=andrew.boyer@amd.com \
    --cc=dev@dpdk.org \
    /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).