DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tejasree Kondoj <ktejasree@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>
Cc: Anoob Joseph <anoobj@marvell.com>,
	Vidya Sagar Velumuri <vvelumuri@marvell.com>, <dev@dpdk.org>
Subject: [PATCH 10/11] crypto/cnxk: add CPTR read and write
Date: Thu, 5 Sep 2024 13:16:30 +0530	[thread overview]
Message-ID: <20240905074631.1462357-11-ktejasree@marvell.com> (raw)
In-Reply-To: <20240905074631.1462357-1-ktejasree@marvell.com>

From: Anoob Joseph <anoobj@marvell.com>

Add PMD API for CPTR read and write.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 71 +++++++++++++++++++++++
 drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 52 +++++++++++++++++
 drivers/crypto/cnxk/version.map           |  2 +
 3 files changed, 125 insertions(+)

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
index ccb800730c..a7d58a5445 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <rte_atomic.h>
 #include <rte_cryptodev.h>
 #include <cryptodev_pmd.h>
 #include <rte_errno.h>
@@ -1090,3 +1091,73 @@ rte_pmd_cnxk_crypto_cptr_get(struct rte_pmd_cnxk_crypto_sess *rte_sess)
 	plt_err("Invalid session type");
 	return NULL;
 }
+
+int
+rte_pmd_cnxk_crypto_cptr_read(struct rte_pmd_cnxk_crypto_qptr *qptr,
+			      struct rte_pmd_cnxk_crypto_cptr *cptr, void *data, uint32_t len)
+{
+	struct cnxk_cpt_qp *qp = PLT_PTR_CAST(qptr);
+	int ret;
+
+	if (unlikely(qptr == NULL)) {
+		plt_err("Invalid queue pair pointer");
+		return -EINVAL;
+	}
+
+	if (unlikely(cptr == NULL)) {
+		plt_err("Invalid CPTR pointer");
+		return -EINVAL;
+	}
+
+	if (unlikely(data == NULL)) {
+		plt_err("Invalid data pointer");
+		return -EINVAL;
+	}
+
+	ret = roc_cpt_lf_ctx_flush(&qp->lf, cptr, false);
+	if (ret)
+		return ret;
+
+	/* Wait for the flush to complete. */
+	rte_delay_ms(1);
+
+	memcpy(data, cptr, len);
+	return 0;
+}
+
+int
+rte_pmd_cnxk_crypto_cptr_write(struct rte_pmd_cnxk_crypto_qptr *qptr,
+			       struct rte_pmd_cnxk_crypto_cptr *cptr, void *data, uint32_t len)
+{
+	struct cnxk_cpt_qp *qp = PLT_PTR_CAST(qptr);
+	int ret;
+
+	if (unlikely(qptr == NULL)) {
+		plt_err("Invalid queue pair pointer");
+		return -EINVAL;
+	}
+
+	if (unlikely(cptr == NULL)) {
+		plt_err("Invalid CPTR pointer");
+		return -EINVAL;
+	}
+
+	if (unlikely(data == NULL)) {
+		plt_err("Invalid data pointer");
+		return -EINVAL;
+	}
+
+	ret = roc_cpt_ctx_write(&qp->lf, data, cptr, len);
+	if (ret) {
+		plt_err("Could not write to CPTR");
+		return ret;
+	}
+
+	ret = roc_cpt_lf_ctx_flush(&qp->lf, cptr, false);
+	if (ret)
+		return ret;
+
+	rte_atomic_thread_fence(rte_memory_order_seq_cst);
+
+	return 0;
+}
diff --git a/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h b/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h
index 7a7d20c290..454261022b 100644
--- a/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h
+++ b/drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h
@@ -124,4 +124,56 @@ __rte_experimental
 struct rte_pmd_cnxk_crypto_cptr *rte_pmd_cnxk_crypto_cptr_get(
 	struct rte_pmd_cnxk_crypto_sess *rte_sess);
 
+/**
+ * Read HW context (CPTR).
+ *
+ * @param qptr
+ *   Pointer obtained with ``rte_pmd_cnxk_crypto_qptr_get``.
+ * @param cptr
+ *   Pointer obtained with ``rte_pmd_cnxk_crypto_cptr_get`` or any valid CPTR address that can be
+ *   used with CPT CTX cache.
+ * @param[out] data
+ *   Destination pointer to copy CPTR context for application.
+ * @param len
+ *   Length of CPTR context to copy into data parameter.
+ *
+ * @return
+ *   - 0 On success.
+ *   - Negative value on error.
+ *     - -EINVAL if the input parameters are invalid.
+ *     - -ENOTSUP if the operation is not supported.
+ *     - -EAGAIN if the operation is not successful.
+ *     - -EFAULT if the operation failed.
+ */
+__rte_experimental
+int rte_pmd_cnxk_crypto_cptr_read(struct rte_pmd_cnxk_crypto_qptr *qptr,
+				  struct rte_pmd_cnxk_crypto_cptr *cptr, void *data,
+				  uint32_t len);
+
+/**
+ * Write HW context (CPTR).
+ *
+ * @param qptr
+ *  Pointer obtained with ``rte_pmd_cnxk_crypto_qptr_get``.
+ * @param cptr
+ *  Pointer obtained with ``rte_pmd_cnxk_crypto_cptr_get`` or any valid CPTR address that can be
+ *  used with CPT CTX cache.
+ * @param data
+ *  Source pointer to copy CPTR context from application.
+ * @param len
+ *  Length of CPTR context to copy from data parameter.
+ *
+ * @return
+ *   - 0 On success.
+ *   - Negative value on error.
+ *     - -EINVAL if the input parameters are invalid.
+ *     - -ENOTSUP if the operation is not supported.
+ *     - -EAGAIN if the operation is not successful.
+ *     - -EFAULT if the operation failed.
+ */
+__rte_experimental
+int rte_pmd_cnxk_crypto_cptr_write(struct rte_pmd_cnxk_crypto_qptr *qptr,
+				   struct rte_pmd_cnxk_crypto_cptr *cptr, void *data,
+				   uint32_t len);
+
 #endif /* _PMD_CNXK_CRYPTO_H_ */
diff --git a/drivers/crypto/cnxk/version.map b/drivers/crypto/cnxk/version.map
index 7a8122dc1d..6e51f7be1a 100644
--- a/drivers/crypto/cnxk/version.map
+++ b/drivers/crypto/cnxk/version.map
@@ -8,6 +8,8 @@ EXPERIMENTAL {
 	# added in 24.07
 	rte_pmd_cnxk_crypto_cptr_flush;
 	rte_pmd_cnxk_crypto_cptr_get;
+	rte_pmd_cnxk_crypto_cptr_read;
+	rte_pmd_cnxk_crypto_cptr_write;
 };
 
 INTERNAL {
-- 
2.25.1


  parent reply	other threads:[~2024-09-05  7:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05  7:46 [PATCH 00/11] fixes and improvements to cnxk crypto PMD Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 01/11] crypto/cnxk: align passthrough data for SM ciphers Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 02/11] crypto/cnxk: add multi segment support for Rx inject Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 03/11] common/cnxk: ensure CPTR is 128B aligned Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 04/11] common/cnxk: rearrange to remove hole Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 05/11] common/cnxk: remove abort from flush API Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 06/11] common/cnxk: move algo enums to common Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 07/11] crypto/cnxk: use opaque pointer for PMD APIs Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 08/11] crypto/cnxk: add PMD API for getting CPTR Tejasree Kondoj
2024-09-05  7:46 ` [PATCH 09/11] crypto/cnxk: add PMD API to flush CTX Tejasree Kondoj
2024-09-05  7:46 ` Tejasree Kondoj [this message]
2024-09-05  7:46 ` [PATCH 11/11] crypto/cnxk: add PMD API to get qp stats Tejasree Kondoj
2024-09-18  5:37 ` [PATCH 00/11] fixes and improvements to cnxk crypto PMD 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=20240905074631.1462357-11-ktejasree@marvell.com \
    --to=ktejasree@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=vvelumuri@marvell.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).