[v2,1/6] cryptodev: add security operation to crypto operation

Message ID 20200623101423.9215-2-david.coyle@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series add support for DOCSIS protocol |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Coyle, David June 23, 2020, 10:14 a.m. UTC
  Add a new security operation field to the crypto operation to allow
protocol specific parameters be defined for a crypto operation.

Signed-off-by: David Coyle <david.coyle@intel.com>
Signed-off-by: Mairtin o Loingsigh <mairtin.oloingsigh@intel.com>
---
 lib/librte_cryptodev/rte_crypto.h    | 19 +++++++++++++++++--
 lib/librte_cryptodev/rte_cryptodev.c |  5 ++++-
 2 files changed, 21 insertions(+), 3 deletions(-)
  

Patch

diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h
index fd5ef3a87..da0635e73 100644
--- a/lib/librte_cryptodev/rte_crypto.h
+++ b/lib/librte_cryptodev/rte_crypto.h
@@ -31,8 +31,10 @@  enum rte_crypto_op_type {
 	/**< Undefined operation type */
 	RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 	/**< Symmetric operation */
-	RTE_CRYPTO_OP_TYPE_ASYMMETRIC
+	RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
 	/**< Asymmetric operation */
+	RTE_CRYPTO_OP_TYPE_SECURITY
+	/**< Security operation */
 };
 
 /** Status of crypto operation */
@@ -121,9 +123,16 @@  struct rte_crypto_op {
 		struct rte_crypto_asym_op asym[0];
 		/**< Asymmetric operation parameters */
 
+		uint8_t security[0];
+		/**< Security operation parameters
+		 * - Must be accessed through a rte_security_op pointer
+		 */
 	}; /**< operation specific parameters */
 };
 
+/** Maximum size of security crypto op */
+#define RTE_CRYPTO_OP_SECURITY_MAX_SZ (88U)
+
 /**
  * Reset the fields of a crypto operation to their default values.
  *
@@ -143,7 +152,10 @@  __rte_crypto_op_reset(struct rte_crypto_op *op, enum rte_crypto_op_type type)
 		break;
 	case RTE_CRYPTO_OP_TYPE_ASYMMETRIC:
 		memset(op->asym, 0, sizeof(struct rte_crypto_asym_op));
-	break;
+		break;
+	case RTE_CRYPTO_OP_TYPE_SECURITY:
+		memset(op->security, 0, RTE_CRYPTO_OP_SECURITY_MAX_SZ);
+		break;
 	case RTE_CRYPTO_OP_TYPE_UNDEFINED:
 	default:
 		break;
@@ -317,6 +329,9 @@  __rte_crypto_op_get_priv_data(struct rte_crypto_op *op, uint32_t size)
 			if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC)
 				return (void *)((uint8_t *)(op + 1) +
 					sizeof(struct rte_crypto_asym_op));
+			if (op->type == RTE_CRYPTO_OP_TYPE_SECURITY)
+				return (void *)((uint8_t *)(op + 1) +
+					RTE_CRYPTO_OP_SECURITY_MAX_SZ);
 		}
 	}
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index e37b83afd..41128f437 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1871,9 +1871,12 @@  rte_crypto_op_pool_create(const char *name, enum rte_crypto_op_type type,
 		elt_size += sizeof(struct rte_crypto_sym_op);
 	} else if (type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
 		elt_size += sizeof(struct rte_crypto_asym_op);
+	} else if (type == RTE_CRYPTO_OP_TYPE_SECURITY) {
+		elt_size += RTE_CRYPTO_OP_SECURITY_MAX_SZ;
 	} else if (type == RTE_CRYPTO_OP_TYPE_UNDEFINED) {
 		elt_size += RTE_MAX(sizeof(struct rte_crypto_sym_op),
-		                    sizeof(struct rte_crypto_asym_op));
+				    RTE_MAX(sizeof(struct rte_crypto_asym_op),
+					    RTE_CRYPTO_OP_SECURITY_MAX_SZ));
 	} else {
 		CDEV_LOG_ERR("Invalid op_type\n");
 		return NULL;