[RFC,1/4] cpu-crypto: Introduce basic data structures
diff mbox series

Message ID 20191105184122.15172-2-konstantin.ananyev@intel.com
State New
Delegated to: akhil goyal
Headers show
Series
  • cpu-crypto API choices
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Ananyev, Konstantin Nov. 5, 2019, 6:41 p.m. UTC
Introduce basic data strucure to be used with cpu-crypto data-path.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_cryptodev/rte_crypto_sym.h | 52 +++++++++++++++++++++++++--
 lib/librte_security/rte_security.h    |  6 +++-
 2 files changed, 54 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/rte_crypto_sym.h
index ffa038dc4..d8d9e9514 100644
--- a/lib/librte_cryptodev/rte_crypto_sym.h
+++ b/lib/librte_cryptodev/rte_crypto_sym.h
@@ -25,6 +25,30 @@  extern "C" {
 #include <rte_mempool.h>
 #include <rte_common.h>
 
+/**
+  * Crypto IO Vector (in analogy with struct iovec)
+  * Supposed be used to pass input/output data buffers for crypto data-path
+  * functions.
+  */
+struct rte_crypto_vec {
+	/** virtual address of the data buffer */
+	void *base;
+	/** IOVA of the data buffer */
+	rte_iova_t *iova;
+	/** length of the data buffer */
+	uint32_t len;
+};
+
+struct rte_crypto_sym_vec {
+	/** array of SGL vectors */
+	struct rte_crypto_vec *vec;
+	/** array of pointers to IV */
+	void **iv;
+	/** array of pointers to AAD */
+	void **aad;
+	/** array of pointers to digest */
+	void **digest;
+};
 
 /** Symmetric Cipher Algorithms */
 enum rte_crypto_cipher_algorithm {
@@ -116,7 +140,8 @@  struct rte_crypto_cipher_xform {
 	struct {
 		const uint8_t *data;	/**< pointer to key data */
 		uint16_t length;	/**< key length in bytes */
-	} key;
+	} __attribute__((__packed__)) key;
+
 	/**< Cipher key
 	 *
 	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data will
@@ -140,6 +165,16 @@  struct rte_crypto_cipher_xform {
 	 *  - Each key can be either 128 bits (16 bytes) or 256 bits (32 bytes).
 	 *  - Both keys must have the same size.
 	 **/
+
+	struct {
+		/**
+		 * offset for cipher to start within user provided data buffer.
+		 */
+		uint16_t offset;
+	} cpu_crypto;
+
+	uint8_t reserved[4];
+
 	struct {
 		uint16_t offset;
 		/**< Starting point for Initialisation Vector or Counter,
@@ -284,7 +319,7 @@  struct rte_crypto_auth_xform {
 	struct {
 		const uint8_t *data;	/**< pointer to key data */
 		uint16_t length;	/**< key length in bytes */
-	} key;
+	} __attribute__((__packed__)) key;
 	/**< Authentication key data.
 	 * The authentication key length MUST be less than or equal to the
 	 * block size of the algorithm. It is the callers responsibility to
@@ -292,6 +327,8 @@  struct rte_crypto_auth_xform {
 	 * (for example RFC 2104, FIPS 198a).
 	 */
 
+	uint8_t reserved[6];
+
 	struct {
 		uint16_t offset;
 		/**< Starting point for Initialisation Vector or Counter,
@@ -376,7 +413,16 @@  struct rte_crypto_aead_xform {
 	struct {
 		const uint8_t *data;	/**< pointer to key data */
 		uint16_t length;	/**< key length in bytes */
-	} key;
+	} __attribute__((__packed__)) key;
+
+	struct {
+		/**
+		 * offset for cipher to start within user provided data buffer.
+		 */
+		uint16_t offset;
+	} cpu_crypto;
+
+	uint8_t reserved[4];
 
 	struct {
 		uint16_t offset;
diff --git a/lib/librte_security/rte_security.h b/lib/librte_security/rte_security.h
index aaafdfcd7..fed67ab39 100644
--- a/lib/librte_security/rte_security.h
+++ b/lib/librte_security/rte_security.h
@@ -303,10 +303,14 @@  enum rte_security_session_action_type {
 	/**< All security protocol processing is performed inline during
 	 * transmission
 	 */
-	RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL
+	RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
 	/**< All security protocol processing including crypto is performed
 	 * on a lookaside accelerator
 	 */
+	RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO,
+	/**< Crypto processing for security protocol is processed by CPU
+	 * synchronously
+	 */
 };
 
 /** Security session protocol definition */