DPDK patches and discussions
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org, techboard@dpdk.org
Cc: roy.fan.zhang@intel.com, declan.doherty@intel.com,
	akhil.goyal@nxp.com,
	Konstantin Ananyev <konstantin.ananyev@intel.com>
Subject: [dpdk-dev] [RFC 2/4] security: introduce cpu-crypto API
Date: Tue,  5 Nov 2019 18:41:20 +0000	[thread overview]
Message-ID: <20191105184122.15172-3-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <20191105184122.15172-1-konstantin.ananyev@intel.com>

This patch extends rte_security API with CPU-CRYPTO mode.

Crypto PMD that wants to support that functionality would need to:
1. claim RTE_CRYPTODEV_FF_SECURITY capability supported.
2. at device .probe() allocate and initialize security context (dev->
security_ctx).
3. implement at least the following functions inside rte_security_ops:
	.session_create,
	.session_get_size,
	.session_destroy, 
	.process_cpu_crypto_sym

For data-path processing consumer of that API would have to maintain:
	struct rte_security_ctx *ctx,
	struct rte_security_session *sess

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_security/rte_security.c        | 11 +++++++++++
 lib/librte_security/rte_security.h        | 22 ++++++++++++++++++++++
 lib/librte_security/rte_security_driver.h | 20 ++++++++++++++++++++
 3 files changed, 53 insertions(+)

diff --git a/lib/librte_security/rte_security.c b/lib/librte_security/rte_security.c
index bc81ce15d..243f59105 100644
--- a/lib/librte_security/rte_security.c
+++ b/lib/librte_security/rte_security.c
@@ -141,3 +141,14 @@ rte_security_capability_get(struct rte_security_ctx *instance,
 
 	return NULL;
 }
+
+__rte_experimental
+int
+rte_security__cpu_crypto_sym_process(struct rte_security_ctx *instance,
+	struct rte_security_session *sess, struct rte_crypto_sym_vec *vec,
+	int32_t status[], uint32_t num)
+{
+	RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->process_cpu_crypto_sym,
+		-ENOENT);
+	return instance->ops->process_cpu_crypto_sym(sess, vec, status, num);
+}
diff --git a/lib/librte_security/rte_security.h b/lib/librte_security/rte_security.h
index fed67ab39..0dc8fec09 100644
--- a/lib/librte_security/rte_security.h
+++ b/lib/librte_security/rte_security.h
@@ -669,6 +669,28 @@ const struct rte_security_capability *
 rte_security_capability_get(struct rte_security_ctx *instance,
 			    struct rte_security_capability_idx *idx);
 
+ /**
+ * Perform actual crypto processing (encrypt/digest or auth/decrypt)
+ * on user provided data.
+ *
+ * @param	instance	security instance.
+ * @param	sess		Security session structure
+ * @param	vec		Array of vectors for input data
+ * @param	status		Array of status values (one per vec)
+ *				(RTE_CRYPTO_OP_STATUS_* values)
+ * @param	num		Number of elems in vec and status arrays.
+ *
+ * @return
+ *  - Returns negative errno value on error, or non-negative number
+ *    of successfully processed input vectors.
+ *
+*/
+__rte_experimental
+int
+rte_security__cpu_crypto_sym_process(struct rte_security_ctx *instance,
+	struct rte_security_session *sess, struct rte_crypto_sym_vec *vec,
+	int32_t status[], uint32_t num);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_security/rte_security_driver.h b/lib/librte_security/rte_security_driver.h
index 1b561f852..b348c5817 100644
--- a/lib/librte_security/rte_security_driver.h
+++ b/lib/librte_security/rte_security_driver.h
@@ -132,6 +132,25 @@ typedef int (*security_get_userdata_t)(void *device,
 typedef const struct rte_security_capability *(*security_capabilities_get_t)(
 		void *device);
 
+/**
+ * Perform actual crypto processing (encrypt/digest or auth/decrypt)
+ * on user provided data.
+ *
+ * @param	sess	Security session structure
+ * @param	vec	Array of vectors for input data
+ * @param	status	Array of status values (one per vec)
+ *			(RTE_CRYPTO_OP_STATUS_* values)
+ * @param	num	Number of elems in vec and status arrays.
+ *
+ * @return
+ *  - Returns negative errno value on error, or non-negative number
+ *    of successfully processed input vectors.
+ *
+*/
+typedef int (*security_process_cpu_crypto_sym_t)(
+	struct rte_security_session *sess, struct rte_crypto_sym_vec *vec,
+	int32_t status[], uint32_t num);
+
 /** Security operations function pointer table */
 struct rte_security_ops {
 	security_session_create_t session_create;
@@ -150,6 +169,7 @@ struct rte_security_ops {
 	/**< Get userdata associated with session which processed the packet. */
 	security_capabilities_get_t capabilities_get;
 	/**< Get security capabilities. */
+	security_process_cpu_crypto_sym_t process_cpu_crypto_sym;
 };
 
 #ifdef __cplusplus
-- 
2.17.1


  parent reply	other threads:[~2019-11-05 18:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 18:41 [dpdk-dev] [RFC 0/4] cpu-crypto API choices Konstantin Ananyev
2019-11-05 18:41 ` [dpdk-dev] [RFC 1/4] cpu-crypto: Introduce basic data structures Konstantin Ananyev
2019-11-05 18:41 ` Konstantin Ananyev [this message]
2019-11-05 18:41 ` [dpdk-dev] [RFC 3/4] cryptodev: introduce cpu-crypto API Konstantin Ananyev
2019-11-05 21:41   ` Akhil Goyal
2019-11-06 14:49     ` Ananyev, Konstantin
2019-11-05 18:41 ` [dpdk-dev] [RFC 4/4] cryptodev: introduce rte_crypto_cpu_sym_session API Konstantin Ananyev
2019-11-06  4:54 ` [dpdk-dev] [dpdk-techboard] [RFC 0/4] cpu-crypto API choices Honnappa Nagarahalli
2019-11-06  9:35   ` Thomas Monjalon
2019-11-06  9:48     ` Thomas Monjalon
2019-11-06 10:14       ` Ananyev, Konstantin
2019-11-06 11:33         ` Ananyev, Konstantin
2019-11-06 12:18           ` Thomas Monjalon
2019-11-06 12:22             ` Hemant Agrawal
2019-11-06 15:19             ` Ananyev, Konstantin
2019-11-14  5:46 ` [dpdk-dev] " Jerin Jacob
2019-11-18 11:57   ` Ananyev, Konstantin
2019-11-20 14:27     ` Jerin Jacob

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=20191105184122.15172-3-konstantin.ananyev@intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=akhil.goyal@nxp.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=roy.fan.zhang@intel.com \
    --cc=techboard@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).