[dpdk-dev] [PATCH v9 3/5] cryptodev: remove unused phys_addr field from key

Fiona Trahe fiona.trahe at intel.com
Thu Mar 10 16:41:11 CET 2016


Remove unused phys_addr field from key in crypto_xform, simplifiy struct
and fix knock-on impacts in l2fwd-crypto app

Signed-off-by: Fiona Trahe <fiona.trahe at intel.com>
---
 examples/l2fwd-crypto/main.c          | 42 ++++++++++++++++++++++++++---------
 lib/librte_cryptodev/rte_crypto_sym.h | 16 ++++++-------
 2 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index ee519e7..9b6b7ef 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -112,6 +112,12 @@ enum l2fwd_crypto_xform_chain {
 	L2FWD_CRYPTO_HASH_CIPHER
 };
 
+struct l2fwd_key {
+	uint8_t *data;
+	uint32_t length;
+	phys_addr_t phys_addr;
+};
+
 /** l2fwd crypto application command line options */
 struct l2fwd_crypto_options {
 	unsigned portmask;
@@ -127,7 +133,7 @@ struct l2fwd_crypto_options {
 	struct rte_crypto_sym_xform cipher_xform;
 	uint8_t ckey_data[32];
 
-	struct rte_crypto_key iv_key;
+	struct l2fwd_key iv_key;
 	uint8_t ivkey_data[16];
 
 	struct rte_crypto_sym_xform auth_xform;
@@ -141,7 +147,7 @@ struct l2fwd_crypto_params {
 
 	unsigned digest_length;
 	unsigned block_size;
-	struct rte_crypto_key iv_key;
+	struct l2fwd_key iv_key;
 	struct rte_cryptodev_sym_session *session;
 };
 
@@ -744,7 +750,7 @@ parse_cipher_op(enum rte_crypto_cipher_operation *op, char *optarg)
 
 /** Parse crypto key command line argument */
 static int
-parse_key(struct rte_crypto_key *key __rte_unused,
+parse_key(struct l2fwd_key *key __rte_unused,
 		unsigned length __rte_unused, char *arg __rte_unused)
 {
 	printf("Currently an unsupported argument!\n");
@@ -820,11 +826,18 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
 		return parse_cipher_op(&options->cipher_xform.cipher.op,
 				optarg);
 
-	else if (strcmp(lgopts[option_index].name, "cipher_key") == 0)
-		return parse_key(&options->cipher_xform.cipher.key,
-				sizeof(options->ckey_data), optarg);
+	else if (strcmp(lgopts[option_index].name, "cipher_key") == 0) {
+		struct l2fwd_key key = { 0 };
+		int retval = 0;
+
+		retval = parse_key(&key, sizeof(options->ckey_data), optarg);
+
+		options->cipher_xform.cipher.key.data = key.data;
+		options->cipher_xform.cipher.key.length = key.length;
 
-	else if (strcmp(lgopts[option_index].name, "iv") == 0)
+		return retval;
+
+	} else if (strcmp(lgopts[option_index].name, "iv") == 0)
 		return parse_key(&options->iv_key, sizeof(options->ivkey_data),
 				optarg);
 
@@ -837,11 +850,18 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
 		return parse_auth_op(&options->auth_xform.auth.op,
 				optarg);
 
-	else if (strcmp(lgopts[option_index].name, "auth_key") == 0)
-		return parse_key(&options->auth_xform.auth.key,
-				sizeof(options->akey_data), optarg);
+	else if (strcmp(lgopts[option_index].name, "auth_key") == 0) {
+		struct l2fwd_key key = { 0 };
+		int retval = 0;
+
+		retval = parse_key(&key, sizeof(options->akey_data), optarg);
+
+		options->auth_xform.auth.key.data = key.data;
+		options->auth_xform.auth.key.length = key.length;
+
+		return retval;
 
-	else if (strcmp(lgopts[option_index].name, "sessionless") == 0) {
+	} else if (strcmp(lgopts[option_index].name, "sessionless") == 0) {
 		options->sessionless = 1;
 		return 0;
 	}
diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/rte_crypto_sym.h
index de6c701..270510e 100644
--- a/lib/librte_cryptodev/rte_crypto_sym.h
+++ b/lib/librte_cryptodev/rte_crypto_sym.h
@@ -111,12 +111,6 @@ enum rte_crypto_cipher_operation {
 	/**< Decrypt cipher operation */
 };
 
-/** Crypto key structure */
-struct rte_crypto_key {
-	uint8_t *data;  /**< pointer to key data */
-	phys_addr_t phys_addr;
-	size_t length;  /**< key length in bytes */
-};
 
 /**
  * Symmetric Cipher Setup Data.
@@ -133,7 +127,10 @@ struct rte_crypto_cipher_xform {
 	enum rte_crypto_cipher_algorithm algo;
 	/**< Cipher algorithm */
 
-	struct rte_crypto_key key;
+	struct {
+		uint8_t *data;  /**< pointer to key data */
+		size_t length;  /**< key length in bytes */
+	} key;
 	/**< Cipher key
 	 *
 	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data will
@@ -257,7 +254,10 @@ struct rte_crypto_auth_xform {
 	enum rte_crypto_auth_algorithm algo;
 	/**< Authentication algorithm selection */
 
-	struct rte_crypto_key key;
+	struct {
+		uint8_t *data;  /**< pointer to key data */
+		size_t length;  /**< key length in bytes */
+	} 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
-- 
2.5.0



More information about the dev mailing list