All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] New crypto algorithm string parser API
@ 2017-02-23 12:33 Pablo de Lara
  2017-02-23 12:33 ` [PATCH 1/4] cryptodev: add missing algorithm strings Pablo de Lara
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-23 12:33 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

Last release, an array with strings for the supported algorithms
by the cryptodev library was added and used in the crypto-perf app.

This patchset creates a new API to parse strings from the user,
to select the desired algorithm (using the array above),
which can be used by any application, making it consistent across
all the applications (now, L2fwd-crypto and crypto-perf apps are
using different strings).

Pablo de Lara (4):
  cryptodev: add missing algorithm strings
  cryptodev: add algorithm string parsers
  app/crypto-perf: use cryptodev algorithm parser
  examples/l2fwd-crypto: use cryptodev algorithm parser

 app/test-crypto-perf/cperf_options_parsing.c   | 206 ++-----------------------
 examples/l2fwd-crypto/main.c                   |  85 ++--------
 lib/librte_cryptodev/rte_cryptodev.c           |  38 +++++
 lib/librte_cryptodev/rte_cryptodev.h           |  30 ++++
 lib/librte_cryptodev/rte_cryptodev_version.map |   8 +
 5 files changed, 100 insertions(+), 267 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/4] cryptodev: add missing algorithm strings
  2017-02-23 12:33 [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
@ 2017-02-23 12:33 ` Pablo de Lara
  2017-02-23 12:33 ` [PATCH 2/4] cryptodev: add algorithm string parsers Pablo de Lara
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-23 12:33 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

DES-CBC and AUTH NULL algorithms were missing in
the array of algorithm strings.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index a64320e..fedb9d0 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -133,6 +133,8 @@ rte_crypto_cipher_algorithm_strings[] = {
 
 	[RTE_CRYPTO_CIPHER_ARC4]	= "arc4",
 
+	[RTE_CRYPTO_CIPHER_DES_CBC]     = "des-cbc",
+
 	[RTE_CRYPTO_CIPHER_NULL]	= "null",
 
 	[RTE_CRYPTO_CIPHER_KASUMI_F8]	= "kasumi-f8",
@@ -166,6 +168,8 @@ rte_crypto_auth_algorithm_strings[] = {
 	[RTE_CRYPTO_AUTH_MD5]		= "md5",
 	[RTE_CRYPTO_AUTH_MD5_HMAC]	= "md5-hmac",
 
+	[RTE_CRYPTO_AUTH_NULL]		= "null",
+
 	[RTE_CRYPTO_AUTH_SHA1]		= "sha1",
 	[RTE_CRYPTO_AUTH_SHA1_HMAC]	= "sha1-hmac",
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/4] cryptodev: add algorithm string parsers
  2017-02-23 12:33 [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
  2017-02-23 12:33 ` [PATCH 1/4] cryptodev: add missing algorithm strings Pablo de Lara
@ 2017-02-23 12:33 ` Pablo de Lara
  2017-02-23 12:33 ` [PATCH 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-23 12:33 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

Adds functions to get the cipher/authentication
algorithm enums, given a string. This is useful for applications
which gets the algorithm required from the user, to have a common
string-enum mapping.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c           | 34 ++++++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 30 +++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  8 ++++++
 3 files changed, 72 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index fedb9d0..f15f65b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -187,6 +187,40 @@ rte_crypto_auth_algorithm_strings[] = {
 	[RTE_CRYPTO_AUTH_ZUC_EIA3]	= "zuc-eia3"
 };
 
+int
+rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
+		const char *algo_string)
+{
+	unsigned int i;
+
+	for (i = 1; i < RTE_DIM(rte_crypto_cipher_algorithm_strings); i++) {
+		if (strcmp(algo_string, rte_crypto_cipher_algorithm_strings[i]) == 0) {
+			*algo_enum = (enum rte_crypto_cipher_algorithm) i;
+			return 0;
+		}
+	}
+
+	/* Invalid string */
+	return -1;
+}
+
+int
+rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
+		const char *algo_string)
+{
+	unsigned int i;
+
+	for (i = 1; i < RTE_DIM(rte_crypto_auth_algorithm_strings); i++) {
+		if (strcmp(algo_string, rte_crypto_auth_algorithm_strings[i]) == 0) {
+			*algo_enum = (enum rte_crypto_auth_algorithm) i;
+			return 0;
+		}
+	}
+
+	/* Invalid string */
+	return -1;
+}
+
 /**
  * The crypto auth operation strings identifiers.
  * It could be used in application command line.
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 82f3bc3..d61a43e 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -234,6 +234,36 @@ rte_cryptodev_sym_capability_check_auth(
 		const struct rte_cryptodev_symmetric_capability *capability,
 		uint16_t key_size, uint16_t digest_size, uint16_t aad_size);
 
+/**
+ * Provide the cipher algorithm enum, given an algorithm string
+ *
+ * @param	algo_enum	A pointer to the cipher algorithm
+ *				enum to be filled
+ * @param	algo_string	Authentication algo string
+ *
+ * @return
+ * - Return -1 if string is not valid
+ * - Return 0 is the string is valid
+ */
+int
+rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
+		const char *algo_string);
+
+/**
+ * Provide the authentication algorithm enum, given an algorithm string
+ *
+ * @param	algo_enum	A pointer to the authentication algorithm
+ *				enum to be filled
+ * @param	algo_string	Authentication algo string
+ *
+ * @return
+ * - Return -1 if string is not valid
+ * - Return 0 is the string is valid
+ */
+int
+rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
+		const char *algo_string);
+
 /** Macro used at end of crypto PMD list */
 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
 	{ RTE_CRYPTO_OP_TYPE_UNDEFINED }
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 238bf13..831a15c 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -64,3 +64,11 @@ DPDK_17.02 {
 	rte_crypto_cipher_operation_strings;
 
 } DPDK_16.11;
+
+DPDK_17.05 {
+	global:
+
+	rte_cryptodev_get_auth_algo_enum;
+	rte_cryptodev_get_cipher_algo_enum;
+
+} DPDK_17.02;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/4] app/crypto-perf: use cryptodev algorithm parser
  2017-02-23 12:33 [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
  2017-02-23 12:33 ` [PATCH 1/4] cryptodev: add missing algorithm strings Pablo de Lara
  2017-02-23 12:33 ` [PATCH 2/4] cryptodev: add algorithm string parsers Pablo de Lara
@ 2017-02-23 12:33 ` Pablo de Lara
  2017-02-23 12:33 ` [PATCH 4/4] examples/l2fwd-crypto: " Pablo de Lara
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-23 12:33 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

Instead of going through the array of supported algorithms
in the app, to get the algorithm enum, use the new API in
cryptodev to parse this string, so it is not necessary to add
a new supported algorithm in the cryptodev library and this app.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/cperf_options_parsing.c | 206 ++-------------------------
 1 file changed, 10 insertions(+), 196 deletions(-)

diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index c1d5ffc..da82ce9 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -33,6 +33,7 @@
 #include <getopt.h>
 #include <unistd.h>
 
+#include <rte_cryptodev.h>
 #include <rte_malloc.h>
 
 #include "cperf_options.h"
@@ -309,93 +310,15 @@ parse_silent(struct cperf_options *opts,
 static int
 parse_cipher_algo(struct cperf_options *opts, const char *arg)
 {
-	struct name_id_map cipher_algo_namemap[] = {
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_3DES_CBC],
-			RTE_CRYPTO_CIPHER_3DES_CBC
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_3DES_ECB],
-			RTE_CRYPTO_CIPHER_3DES_ECB
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_3DES_CTR],
-			RTE_CRYPTO_CIPHER_3DES_CTR
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_CBC],
-			RTE_CRYPTO_CIPHER_AES_CBC
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_CCM],
-			RTE_CRYPTO_CIPHER_AES_CCM
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_CTR],
-			RTE_CRYPTO_CIPHER_AES_CTR
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_ECB],
-			RTE_CRYPTO_CIPHER_AES_ECB
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_GCM],
-			RTE_CRYPTO_CIPHER_AES_GCM
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_F8],
-			RTE_CRYPTO_CIPHER_AES_F8
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_XTS],
-			RTE_CRYPTO_CIPHER_AES_XTS
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_ARC4],
-			RTE_CRYPTO_CIPHER_ARC4
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_NULL],
-			RTE_CRYPTO_CIPHER_NULL
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_KASUMI_F8],
-			RTE_CRYPTO_CIPHER_KASUMI_F8
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_SNOW3G_UEA2],
-			RTE_CRYPTO_CIPHER_SNOW3G_UEA2
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_ZUC_EEA3],
-			RTE_CRYPTO_CIPHER_ZUC_EEA3
-		},
-	};
 
+	enum rte_crypto_cipher_algorithm cipher_algo;
 
-	int id = get_str_key_id_mapping(cipher_algo_namemap,
-			RTE_DIM(cipher_algo_namemap), arg);
-	if (id < 0) {
+	if (rte_cryptodev_get_cipher_algo_enum(&cipher_algo, arg) < 0) {
 		RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
 		return -1;
 	}
 
-	opts->cipher_algo = (enum rte_crypto_cipher_algorithm)id;
+	opts->cipher_algo = cipher_algo;
 
 	return 0;
 }
@@ -440,125 +363,16 @@ parse_cipher_iv_sz(struct cperf_options *opts, const char *arg)
 }
 
 static int
-parse_auth_algo(struct cperf_options *opts, const char *arg) {
-	struct name_id_map cipher_auth_namemap[] = {
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_CBC_MAC],
-			RTE_CRYPTO_AUTH_AES_CBC_MAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_CCM],
-			RTE_CRYPTO_AUTH_AES_CCM
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_CMAC],
-			RTE_CRYPTO_AUTH_AES_CMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_GCM],
-			RTE_CRYPTO_AUTH_AES_GCM
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_GMAC],
-			RTE_CRYPTO_AUTH_AES_GMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_XCBC_MAC],
-			RTE_CRYPTO_AUTH_AES_XCBC_MAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_MD5],
-			RTE_CRYPTO_AUTH_MD5
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_MD5_HMAC],
-			RTE_CRYPTO_AUTH_MD5_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA1],
-			RTE_CRYPTO_AUTH_SHA1
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA1_HMAC],
-			RTE_CRYPTO_AUTH_SHA1_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA224],
-			RTE_CRYPTO_AUTH_SHA224
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA224_HMAC],
-			RTE_CRYPTO_AUTH_SHA224_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA256],
-			RTE_CRYPTO_AUTH_SHA256
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA256_HMAC],
-			RTE_CRYPTO_AUTH_SHA256_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA384],
-			RTE_CRYPTO_AUTH_SHA384
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA384_HMAC],
-			RTE_CRYPTO_AUTH_SHA384_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA512],
-			RTE_CRYPTO_AUTH_SHA512
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA512_HMAC],
-			RTE_CRYPTO_AUTH_SHA512_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_KASUMI_F9],
-			RTE_CRYPTO_AUTH_KASUMI_F9
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SNOW3G_UIA2],
-			RTE_CRYPTO_AUTH_SNOW3G_UIA2
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_ZUC_EIA3],
-			RTE_CRYPTO_AUTH_ZUC_EIA3
-		},
-	};
-
+parse_auth_algo(struct cperf_options *opts, const char *arg)
+{
+	enum rte_crypto_auth_algorithm auth_algo;
 
-	int id = get_str_key_id_mapping(cipher_auth_namemap,
-			RTE_DIM(cipher_auth_namemap), arg);
-	if (id < 0) {
-		RTE_LOG(ERR, USER1, "invalid authentication algorithm specified"
-				"\n");
+	if (rte_cryptodev_get_auth_algo_enum(&auth_algo, arg) < 0) {
+		RTE_LOG(ERR, USER1, "Invalid authentication algorithm specified\n");
 		return -1;
 	}
 
-	opts->auth_algo = (enum rte_crypto_auth_algorithm)id;
+	opts->auth_algo = auth_algo;
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/4] examples/l2fwd-crypto: use cryptodev algorithm parser
  2017-02-23 12:33 [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
                   ` (2 preceding siblings ...)
  2017-02-23 12:33 ` [PATCH 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
@ 2017-02-23 12:33 ` Pablo de Lara
  2017-02-24 15:41 ` [PATCH 0/4] New crypto algorithm string parser API Trahe, Fiona
  2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
  5 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-23 12:33 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

L2fwd-crypto app was creating an array of strings for the
supported algorithms, which was different from the strings
that are now in cryptodev.

Use the new API in cryptodev to parse the string from the user,
to get the algorithm enum, instead, so it is not necessary to add
a new supported algorithm in the cryptodev library and this app.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 85 ++++++++------------------------------------
 1 file changed, 14 insertions(+), 71 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 62ee933..af58946 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -135,9 +135,6 @@ struct l2fwd_key {
 	phys_addr_t phys_addr;
 };
 
-char supported_auth_algo[RTE_CRYPTO_AUTH_LIST_END][MAX_STR_LEN];
-char supported_cipher_algo[RTE_CRYPTO_CIPHER_LIST_END][MAX_STR_LEN];
-
 /** l2fwd crypto application command line options */
 struct l2fwd_crypto_options {
 	unsigned portmask;
@@ -331,50 +328,6 @@ print_stats(void)
 	printf("\n====================================================\n");
 }
 
-static void
-fill_supported_algorithm_tables(void)
-{
-	unsigned i;
-
-	for (i = 0; i < RTE_CRYPTO_AUTH_LIST_END; i++)
-		strcpy(supported_auth_algo[i], "NOT_SUPPORTED");
-
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_GCM], "AES_GCM");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_GMAC], "AES_GMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_MD5_HMAC], "MD5_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_MD5], "MD5");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_NULL], "NULL");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_XCBC_MAC],
-		"AES_XCBC_MAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA1_HMAC], "SHA1_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA1], "SHA1");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA224_HMAC], "SHA224_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA224], "SHA224");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA256_HMAC], "SHA256_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA256], "SHA256");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA384_HMAC], "SHA384_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA384], "SHA384");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA512_HMAC], "SHA512_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA512], "SHA512");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SNOW3G_UIA2], "SNOW3G_UIA2");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_ZUC_EIA3], "ZUC_EIA3");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_KASUMI_F9], "KASUMI_F9");
-
-	for (i = 0; i < RTE_CRYPTO_CIPHER_LIST_END; i++)
-		strcpy(supported_cipher_algo[i], "NOT_SUPPORTED");
-
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_CBC], "AES_CBC");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_CTR], "AES_CTR");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_GCM], "AES_GCM");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_NULL], "NULL");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_SNOW3G_UEA2], "SNOW3G_UEA2");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_ZUC_EEA3], "ZUC_EEA3");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_KASUMI_F8], "KASUMI_F8");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_3DES_CTR], "3DES_CTR");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_3DES_CBC], "3DES_CBC");
-}
-
-
 static int
 l2fwd_crypto_send_burst(struct lcore_queue_conf *qconf, unsigned n,
 		struct l2fwd_crypto_params *cparams)
@@ -946,17 +899,14 @@ parse_crypto_opt_chain(struct l2fwd_crypto_options *options, char *optarg)
 static int
 parse_cipher_algo(enum rte_crypto_cipher_algorithm *algo, char *optarg)
 {
-	unsigned i;
 
-	for (i = 0; i < RTE_CRYPTO_CIPHER_LIST_END; i++) {
-		if (!strcmp(supported_cipher_algo[i], optarg)) {
-			*algo = (enum rte_crypto_cipher_algorithm)i;
-			return 0;
-		}
+	if (rte_cryptodev_get_cipher_algo_enum(algo, optarg) < 0) {
+		RTE_LOG(ERR, USER1, "Cipher algorithm specified "
+				"not supported!\n");
+		return -1;
 	}
 
-	printf("Cipher algorithm  not supported!\n");
-	return -1;
+	return 0;
 }
 
 /** Parse crypto cipher operation command line argument */
@@ -1022,17 +972,13 @@ parse_size(int *size, const char *q_arg)
 static int
 parse_auth_algo(enum rte_crypto_auth_algorithm *algo, char *optarg)
 {
-	unsigned i;
-
-	for (i = 0; i < RTE_CRYPTO_AUTH_LIST_END; i++) {
-		if (!strcmp(supported_auth_algo[i], optarg)) {
-			*algo = (enum rte_crypto_auth_algorithm)i;
-			return 0;
-		}
+	if (rte_cryptodev_get_auth_algo_enum(algo, optarg) < 0) {
+		RTE_LOG(ERR, USER1, "Authentication algorithm specified "
+				"not supported!\n");
+		return -1;
 	}
 
-	printf("Authentication algorithm specified not supported!\n");
-	return -1;
+	return 0;
 }
 
 static int
@@ -1271,7 +1217,7 @@ display_cipher_info(struct l2fwd_crypto_options *options)
 {
 	printf("\n---- Cipher information ---\n");
 	printf("Algorithm: %s\n",
-		supported_cipher_algo[options->cipher_xform.cipher.algo]);
+		rte_crypto_cipher_algorithm_strings[options->cipher_xform.cipher.algo]);
 	rte_hexdump(stdout, "Cipher key:",
 			options->cipher_xform.cipher.key.data,
 			options->cipher_xform.cipher.key.length);
@@ -1283,7 +1229,7 @@ display_auth_info(struct l2fwd_crypto_options *options)
 {
 	printf("\n---- Authentication information ---\n");
 	printf("Algorithm: %s\n",
-		supported_auth_algo[options->auth_xform.auth.algo]);
+		rte_crypto_auth_algorithm_strings[options->auth_xform.cipher.algo]);
 	rte_hexdump(stdout, "Auth key:",
 			options->auth_xform.auth.key.data,
 			options->auth_xform.auth.key.length);
@@ -1605,7 +1551,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 			if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) {
 				printf("Algorithm %s not supported by cryptodev %u"
 					" or device not of preferred type (%s)\n",
-					supported_cipher_algo[opt_cipher_algo],
+					rte_crypto_cipher_algorithm_strings[opt_cipher_algo],
 					cdev_id,
 					options->string_type);
 				continue;
@@ -1705,7 +1651,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 			if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) {
 				printf("Algorithm %s not supported by cryptodev %u"
 					" or device not of preferred type (%s)\n",
-					supported_auth_algo[opt_auth_algo],
+					rte_crypto_auth_algorithm_strings[opt_auth_algo],
 					cdev_id,
 					options->string_type);
 				continue;
@@ -1985,9 +1931,6 @@ main(int argc, char **argv)
 	/* reserve memory for Cipher/Auth key and IV */
 	reserve_key_memory(&options);
 
-	/* fill out the supported algorithm tables */
-	fill_supported_algorithm_tables();
-
 	/* parse application arguments (after the EAL ones) */
 	ret = l2fwd_crypto_parse_args(&options, argc, argv);
 	if (ret < 0)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/4] New crypto algorithm string parser API
  2017-02-23 12:33 [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
                   ` (3 preceding siblings ...)
  2017-02-23 12:33 ` [PATCH 4/4] examples/l2fwd-crypto: " Pablo de Lara
@ 2017-02-24 15:41 ` Trahe, Fiona
  2017-02-25 11:18   ` Hemant Agrawal
  2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
  5 siblings, 1 reply; 13+ messages in thread
From: Trahe, Fiona @ 2017-02-24 15:41 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, Doherty, Declan; +Cc: dev, De Lara Guarch, Pablo



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Thursday, February 23, 2017 12:34 PM
> To: Doherty, Declan <declan.doherty@intel.com>
> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev] [PATCH 0/4] New crypto algorithm string parser API
> 
> Last release, an array with strings for the supported algorithms
> by the cryptodev library was added and used in the crypto-perf app.
> 
> This patchset creates a new API to parse strings from the user,
> to select the desired algorithm (using the array above),
> which can be used by any application, making it consistent across
> all the applications (now, L2fwd-crypto and crypto-perf apps are
> using different strings).
> 
> Pablo de Lara (4):
>   cryptodev: add missing algorithm strings
>   cryptodev: add algorithm string parsers
>   app/crypto-perf: use cryptodev algorithm parser
>   examples/l2fwd-crypto: use cryptodev algorithm parser
> 
>  app/test-crypto-perf/cperf_options_parsing.c   | 206 ++-----------------------
>  examples/l2fwd-crypto/main.c                   |  85 ++--------
>  lib/librte_cryptodev/rte_cryptodev.c           |  38 +++++
>  lib/librte_cryptodev/rte_cryptodev.h           |  30 ++++
>  lib/librte_cryptodev/rte_cryptodev_version.map |   8 +
>  5 files changed, 100 insertions(+), 267 deletions(-)
> 
> --
> 2.7.4
Acked-by: Fiona Trahe <fiona.trahe@intel.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/4] New crypto algorithm string parser API
  2017-02-24 15:41 ` [PATCH 0/4] New crypto algorithm string parser API Trahe, Fiona
@ 2017-02-25 11:18   ` Hemant Agrawal
  0 siblings, 0 replies; 13+ messages in thread
From: Hemant Agrawal @ 2017-02-25 11:18 UTC (permalink / raw)
  To: Trahe, Fiona, De Lara Guarch, Pablo, Doherty, Declan; +Cc: dev

On 2/24/2017 9:11 PM, Trahe, Fiona wrote:
>
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
>> Sent: Thursday, February 23, 2017 12:34 PM
>> To: Doherty, Declan <declan.doherty@intel.com>
>> Cc: dev@dpdk.org; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Subject: [dpdk-dev] [PATCH 0/4] New crypto algorithm string parser API
>>
>> Last release, an array with strings for the supported algorithms
>> by the cryptodev library was added and used in the crypto-perf app.
>>
>> This patchset creates a new API to parse strings from the user,
>> to select the desired algorithm (using the array above),
>> which can be used by any application, making it consistent across
>> all the applications (now, L2fwd-crypto and crypto-perf apps are
>> using different strings).
>>
>> Pablo de Lara (4):
>>   cryptodev: add missing algorithm strings
>>   cryptodev: add algorithm string parsers
>>   app/crypto-perf: use cryptodev algorithm parser
>>   examples/l2fwd-crypto: use cryptodev algorithm parser
>>
>>  app/test-crypto-perf/cperf_options_parsing.c   | 206 ++-----------------------
>>  examples/l2fwd-crypto/main.c                   |  85 ++--------
>>  lib/librte_cryptodev/rte_cryptodev.c           |  38 +++++
>>  lib/librte_cryptodev/rte_cryptodev.h           |  30 ++++
>>  lib/librte_cryptodev/rte_cryptodev_version.map |   8 +
>>  5 files changed, 100 insertions(+), 267 deletions(-)
>>
>> --
>> 2.7.4
> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 0/4] New crypto algorithm string parser API
  2017-02-23 12:33 [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
                   ` (4 preceding siblings ...)
  2017-02-24 15:41 ` [PATCH 0/4] New crypto algorithm string parser API Trahe, Fiona
@ 2017-02-27 14:38 ` Pablo de Lara
  2017-02-27 14:38   ` [PATCH v2 1/4] cryptodev: add missing algorithm strings Pablo de Lara
                     ` (4 more replies)
  5 siblings, 5 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-27 14:38 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

Last release, an array with strings for the supported algorithms
by the cryptodev library was added and used in the crypto-perf app.

This patchset creates a new API to parse strings from the user,
to select the desired algorithm (using the array above),
which can be used by any application, making it consistent across
all the applications (now, L2fwd-crypto and crypto-perf apps are
using different strings).

Changes in v2:

- Modified L2fwd-crypto document to reflect the changes

Pablo de Lara (4):
  cryptodev: add missing algorithm strings
  cryptodev: add algorithm string parsers
  app/crypto-perf: use cryptodev algorithm parser
  examples/l2fwd-crypto: use cryptodev algorithm parser

 app/test-crypto-perf/cperf_options_parsing.c   | 206 ++-----------------------
 doc/guides/sample_app_ug/l2_forward_crypto.rst |  10 +-
 examples/l2fwd-crypto/main.c                   |  85 ++--------
 lib/librte_cryptodev/rte_cryptodev.c           |  38 +++++
 lib/librte_cryptodev/rte_cryptodev.h           |  30 ++++
 lib/librte_cryptodev/rte_cryptodev_version.map |   8 +
 6 files changed, 105 insertions(+), 272 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/4] cryptodev: add missing algorithm strings
  2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
@ 2017-02-27 14:38   ` Pablo de Lara
  2017-02-27 14:38   ` [PATCH v2 2/4] cryptodev: add algorithm string parsers Pablo de Lara
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-27 14:38 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

DES-CBC and AUTH NULL algorithms were missing in
the array of algorithm strings.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index a64320e..fedb9d0 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -133,6 +133,8 @@ rte_crypto_cipher_algorithm_strings[] = {
 
 	[RTE_CRYPTO_CIPHER_ARC4]	= "arc4",
 
+	[RTE_CRYPTO_CIPHER_DES_CBC]     = "des-cbc",
+
 	[RTE_CRYPTO_CIPHER_NULL]	= "null",
 
 	[RTE_CRYPTO_CIPHER_KASUMI_F8]	= "kasumi-f8",
@@ -166,6 +168,8 @@ rte_crypto_auth_algorithm_strings[] = {
 	[RTE_CRYPTO_AUTH_MD5]		= "md5",
 	[RTE_CRYPTO_AUTH_MD5_HMAC]	= "md5-hmac",
 
+	[RTE_CRYPTO_AUTH_NULL]		= "null",
+
 	[RTE_CRYPTO_AUTH_SHA1]		= "sha1",
 	[RTE_CRYPTO_AUTH_SHA1_HMAC]	= "sha1-hmac",
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/4] cryptodev: add algorithm string parsers
  2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
  2017-02-27 14:38   ` [PATCH v2 1/4] cryptodev: add missing algorithm strings Pablo de Lara
@ 2017-02-27 14:38   ` Pablo de Lara
  2017-02-27 14:38   ` [PATCH v2 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-27 14:38 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

Adds functions to get the cipher/authentication
algorithm enums, given a string. This is useful for applications
which gets the algorithm required from the user, to have a common
string-enum mapping.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 lib/librte_cryptodev/rte_cryptodev.c           | 34 ++++++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 30 +++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  8 ++++++
 3 files changed, 72 insertions(+)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index fedb9d0..f15f65b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -187,6 +187,40 @@ rte_crypto_auth_algorithm_strings[] = {
 	[RTE_CRYPTO_AUTH_ZUC_EIA3]	= "zuc-eia3"
 };
 
+int
+rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
+		const char *algo_string)
+{
+	unsigned int i;
+
+	for (i = 1; i < RTE_DIM(rte_crypto_cipher_algorithm_strings); i++) {
+		if (strcmp(algo_string, rte_crypto_cipher_algorithm_strings[i]) == 0) {
+			*algo_enum = (enum rte_crypto_cipher_algorithm) i;
+			return 0;
+		}
+	}
+
+	/* Invalid string */
+	return -1;
+}
+
+int
+rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
+		const char *algo_string)
+{
+	unsigned int i;
+
+	for (i = 1; i < RTE_DIM(rte_crypto_auth_algorithm_strings); i++) {
+		if (strcmp(algo_string, rte_crypto_auth_algorithm_strings[i]) == 0) {
+			*algo_enum = (enum rte_crypto_auth_algorithm) i;
+			return 0;
+		}
+	}
+
+	/* Invalid string */
+	return -1;
+}
+
 /**
  * The crypto auth operation strings identifiers.
  * It could be used in application command line.
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 82f3bc3..d61a43e 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -234,6 +234,36 @@ rte_cryptodev_sym_capability_check_auth(
 		const struct rte_cryptodev_symmetric_capability *capability,
 		uint16_t key_size, uint16_t digest_size, uint16_t aad_size);
 
+/**
+ * Provide the cipher algorithm enum, given an algorithm string
+ *
+ * @param	algo_enum	A pointer to the cipher algorithm
+ *				enum to be filled
+ * @param	algo_string	Authentication algo string
+ *
+ * @return
+ * - Return -1 if string is not valid
+ * - Return 0 is the string is valid
+ */
+int
+rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
+		const char *algo_string);
+
+/**
+ * Provide the authentication algorithm enum, given an algorithm string
+ *
+ * @param	algo_enum	A pointer to the authentication algorithm
+ *				enum to be filled
+ * @param	algo_string	Authentication algo string
+ *
+ * @return
+ * - Return -1 if string is not valid
+ * - Return 0 is the string is valid
+ */
+int
+rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
+		const char *algo_string);
+
 /** Macro used at end of crypto PMD list */
 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
 	{ RTE_CRYPTO_OP_TYPE_UNDEFINED }
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 238bf13..831a15c 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -64,3 +64,11 @@ DPDK_17.02 {
 	rte_crypto_cipher_operation_strings;
 
 } DPDK_16.11;
+
+DPDK_17.05 {
+	global:
+
+	rte_cryptodev_get_auth_algo_enum;
+	rte_cryptodev_get_cipher_algo_enum;
+
+} DPDK_17.02;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/4] app/crypto-perf: use cryptodev algorithm parser
  2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
  2017-02-27 14:38   ` [PATCH v2 1/4] cryptodev: add missing algorithm strings Pablo de Lara
  2017-02-27 14:38   ` [PATCH v2 2/4] cryptodev: add algorithm string parsers Pablo de Lara
@ 2017-02-27 14:38   ` Pablo de Lara
  2017-02-27 14:38   ` [PATCH v2 4/4] examples/l2fwd-crypto: " Pablo de Lara
  2017-02-28 14:18   ` [PATCH v2 0/4] New crypto algorithm string parser API De Lara Guarch, Pablo
  4 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-27 14:38 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

Instead of going through the array of supported algorithms
in the app, to get the algorithm enum, use the new API in
cryptodev to parse this string, so it is not necessary to add
a new supported algorithm in the cryptodev library and this app.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 app/test-crypto-perf/cperf_options_parsing.c | 206 ++-------------------------
 1 file changed, 10 insertions(+), 196 deletions(-)

diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index c1d5ffc..da82ce9 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -33,6 +33,7 @@
 #include <getopt.h>
 #include <unistd.h>
 
+#include <rte_cryptodev.h>
 #include <rte_malloc.h>
 
 #include "cperf_options.h"
@@ -309,93 +310,15 @@ parse_silent(struct cperf_options *opts,
 static int
 parse_cipher_algo(struct cperf_options *opts, const char *arg)
 {
-	struct name_id_map cipher_algo_namemap[] = {
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_3DES_CBC],
-			RTE_CRYPTO_CIPHER_3DES_CBC
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_3DES_ECB],
-			RTE_CRYPTO_CIPHER_3DES_ECB
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_3DES_CTR],
-			RTE_CRYPTO_CIPHER_3DES_CTR
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_CBC],
-			RTE_CRYPTO_CIPHER_AES_CBC
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_CCM],
-			RTE_CRYPTO_CIPHER_AES_CCM
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_CTR],
-			RTE_CRYPTO_CIPHER_AES_CTR
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_ECB],
-			RTE_CRYPTO_CIPHER_AES_ECB
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_GCM],
-			RTE_CRYPTO_CIPHER_AES_GCM
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_F8],
-			RTE_CRYPTO_CIPHER_AES_F8
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_AES_XTS],
-			RTE_CRYPTO_CIPHER_AES_XTS
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_ARC4],
-			RTE_CRYPTO_CIPHER_ARC4
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_NULL],
-			RTE_CRYPTO_CIPHER_NULL
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_KASUMI_F8],
-			RTE_CRYPTO_CIPHER_KASUMI_F8
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_SNOW3G_UEA2],
-			RTE_CRYPTO_CIPHER_SNOW3G_UEA2
-		},
-		{
-			rte_crypto_cipher_algorithm_strings
-			[RTE_CRYPTO_CIPHER_ZUC_EEA3],
-			RTE_CRYPTO_CIPHER_ZUC_EEA3
-		},
-	};
 
+	enum rte_crypto_cipher_algorithm cipher_algo;
 
-	int id = get_str_key_id_mapping(cipher_algo_namemap,
-			RTE_DIM(cipher_algo_namemap), arg);
-	if (id < 0) {
+	if (rte_cryptodev_get_cipher_algo_enum(&cipher_algo, arg) < 0) {
 		RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
 		return -1;
 	}
 
-	opts->cipher_algo = (enum rte_crypto_cipher_algorithm)id;
+	opts->cipher_algo = cipher_algo;
 
 	return 0;
 }
@@ -440,125 +363,16 @@ parse_cipher_iv_sz(struct cperf_options *opts, const char *arg)
 }
 
 static int
-parse_auth_algo(struct cperf_options *opts, const char *arg) {
-	struct name_id_map cipher_auth_namemap[] = {
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_CBC_MAC],
-			RTE_CRYPTO_AUTH_AES_CBC_MAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_CCM],
-			RTE_CRYPTO_AUTH_AES_CCM
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_CMAC],
-			RTE_CRYPTO_AUTH_AES_CMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_GCM],
-			RTE_CRYPTO_AUTH_AES_GCM
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_GMAC],
-			RTE_CRYPTO_AUTH_AES_GMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_AES_XCBC_MAC],
-			RTE_CRYPTO_AUTH_AES_XCBC_MAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_MD5],
-			RTE_CRYPTO_AUTH_MD5
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_MD5_HMAC],
-			RTE_CRYPTO_AUTH_MD5_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA1],
-			RTE_CRYPTO_AUTH_SHA1
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA1_HMAC],
-			RTE_CRYPTO_AUTH_SHA1_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA224],
-			RTE_CRYPTO_AUTH_SHA224
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA224_HMAC],
-			RTE_CRYPTO_AUTH_SHA224_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA256],
-			RTE_CRYPTO_AUTH_SHA256
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA256_HMAC],
-			RTE_CRYPTO_AUTH_SHA256_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA384],
-			RTE_CRYPTO_AUTH_SHA384
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA384_HMAC],
-			RTE_CRYPTO_AUTH_SHA384_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA512],
-			RTE_CRYPTO_AUTH_SHA512
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SHA512_HMAC],
-			RTE_CRYPTO_AUTH_SHA512_HMAC
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_KASUMI_F9],
-			RTE_CRYPTO_AUTH_KASUMI_F9
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_SNOW3G_UIA2],
-			RTE_CRYPTO_AUTH_SNOW3G_UIA2
-		},
-		{
-			rte_crypto_auth_algorithm_strings
-			[RTE_CRYPTO_AUTH_ZUC_EIA3],
-			RTE_CRYPTO_AUTH_ZUC_EIA3
-		},
-	};
-
+parse_auth_algo(struct cperf_options *opts, const char *arg)
+{
+	enum rte_crypto_auth_algorithm auth_algo;
 
-	int id = get_str_key_id_mapping(cipher_auth_namemap,
-			RTE_DIM(cipher_auth_namemap), arg);
-	if (id < 0) {
-		RTE_LOG(ERR, USER1, "invalid authentication algorithm specified"
-				"\n");
+	if (rte_cryptodev_get_auth_algo_enum(&auth_algo, arg) < 0) {
+		RTE_LOG(ERR, USER1, "Invalid authentication algorithm specified\n");
 		return -1;
 	}
 
-	opts->auth_algo = (enum rte_crypto_auth_algorithm)id;
+	opts->auth_algo = auth_algo;
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/4] examples/l2fwd-crypto: use cryptodev algorithm parser
  2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
                     ` (2 preceding siblings ...)
  2017-02-27 14:38   ` [PATCH v2 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
@ 2017-02-27 14:38   ` Pablo de Lara
  2017-02-28 14:18   ` [PATCH v2 0/4] New crypto algorithm string parser API De Lara Guarch, Pablo
  4 siblings, 0 replies; 13+ messages in thread
From: Pablo de Lara @ 2017-02-27 14:38 UTC (permalink / raw)
  To: declan.doherty; +Cc: dev, Pablo de Lara

L2fwd-crypto app was creating an array of strings for the
supported algorithms, which was different from the strings
that are now in cryptodev.

Use the new API in cryptodev to parse the string from the user,
to get the algorithm enum, instead, so it is not necessary to add
a new supported algorithm in the cryptodev library and this app.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 doc/guides/sample_app_ug/l2_forward_crypto.rst | 10 +--
 examples/l2fwd-crypto/main.c                   | 85 +++++---------------------
 2 files changed, 19 insertions(+), 76 deletions(-)

diff --git a/doc/guides/sample_app_ug/l2_forward_crypto.rst b/doc/guides/sample_app_ug/l2_forward_crypto.rst
index 723376c..adcbf16 100644
--- a/doc/guides/sample_app_ug/l2_forward_crypto.rst
+++ b/doc/guides/sample_app_ug/l2_forward_crypto.rst
@@ -1,5 +1,5 @@
 ..  BSD LICENSE
-    Copyright(c) 2016 Intel Corporation. All rights reserved.
+    Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -113,7 +113,7 @@ where,
 
     (default is Cipher->Hash)
 
-*   cipher_algo: select the ciphering algorithm (default is AES CBC)
+*   cipher_algo: select the ciphering algorithm (default is aes-cbc)
 
 *   cipher_op: select the ciphering operation to perform: ENCRYPT or DECRYPT
 
@@ -133,7 +133,7 @@ where,
 
     Note that if --iv is used, this will be ignored.
 
-*   auth_algo: select the authentication algorithm (default is SHA1-HMAC)
+*   auth_algo: select the authentication algorithm (default is sha1-hmac)
 
 *   cipher_op: select the authentication operation to perform: GENERATE or VERIFY
 
@@ -169,9 +169,9 @@ To run the application in linuxapp environment with 2 lcores, 2 ports and 2 cryp
 
     $ ./build/l2fwd-crypto -c 0x3 -n 4 --vdev "cryptodev_aesni_mb_pmd" \
     --vdev "cryptodev_aesni_mb_pmd" -- -p 0x3 --chain CIPHER_HASH \
-    --cipher_op ENCRYPT --cipher_algo AES_CBC \
+    --cipher_op ENCRYPT --cipher_algo aes-cbc \
     --cipher_key 00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f \
-    --auth_op GENERATE --auth_algo AES_XCBC_MAC \
+    --auth_op GENERATE --auth_algo aes-xcbc-mac \
     --auth_key 10:11:12:13:14:15:16:17:18:19:1a:1b:1c:1d:1e:1f
 
 Refer to the *DPDK Getting Started Guide* for general information on running applications
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 62ee933..af58946 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -135,9 +135,6 @@ struct l2fwd_key {
 	phys_addr_t phys_addr;
 };
 
-char supported_auth_algo[RTE_CRYPTO_AUTH_LIST_END][MAX_STR_LEN];
-char supported_cipher_algo[RTE_CRYPTO_CIPHER_LIST_END][MAX_STR_LEN];
-
 /** l2fwd crypto application command line options */
 struct l2fwd_crypto_options {
 	unsigned portmask;
@@ -331,50 +328,6 @@ print_stats(void)
 	printf("\n====================================================\n");
 }
 
-static void
-fill_supported_algorithm_tables(void)
-{
-	unsigned i;
-
-	for (i = 0; i < RTE_CRYPTO_AUTH_LIST_END; i++)
-		strcpy(supported_auth_algo[i], "NOT_SUPPORTED");
-
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_GCM], "AES_GCM");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_GMAC], "AES_GMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_MD5_HMAC], "MD5_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_MD5], "MD5");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_NULL], "NULL");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_XCBC_MAC],
-		"AES_XCBC_MAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA1_HMAC], "SHA1_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA1], "SHA1");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA224_HMAC], "SHA224_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA224], "SHA224");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA256_HMAC], "SHA256_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA256], "SHA256");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA384_HMAC], "SHA384_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA384], "SHA384");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA512_HMAC], "SHA512_HMAC");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA512], "SHA512");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SNOW3G_UIA2], "SNOW3G_UIA2");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_ZUC_EIA3], "ZUC_EIA3");
-	strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_KASUMI_F9], "KASUMI_F9");
-
-	for (i = 0; i < RTE_CRYPTO_CIPHER_LIST_END; i++)
-		strcpy(supported_cipher_algo[i], "NOT_SUPPORTED");
-
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_CBC], "AES_CBC");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_CTR], "AES_CTR");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_GCM], "AES_GCM");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_NULL], "NULL");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_SNOW3G_UEA2], "SNOW3G_UEA2");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_ZUC_EEA3], "ZUC_EEA3");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_KASUMI_F8], "KASUMI_F8");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_3DES_CTR], "3DES_CTR");
-	strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_3DES_CBC], "3DES_CBC");
-}
-
-
 static int
 l2fwd_crypto_send_burst(struct lcore_queue_conf *qconf, unsigned n,
 		struct l2fwd_crypto_params *cparams)
@@ -946,17 +899,14 @@ parse_crypto_opt_chain(struct l2fwd_crypto_options *options, char *optarg)
 static int
 parse_cipher_algo(enum rte_crypto_cipher_algorithm *algo, char *optarg)
 {
-	unsigned i;
 
-	for (i = 0; i < RTE_CRYPTO_CIPHER_LIST_END; i++) {
-		if (!strcmp(supported_cipher_algo[i], optarg)) {
-			*algo = (enum rte_crypto_cipher_algorithm)i;
-			return 0;
-		}
+	if (rte_cryptodev_get_cipher_algo_enum(algo, optarg) < 0) {
+		RTE_LOG(ERR, USER1, "Cipher algorithm specified "
+				"not supported!\n");
+		return -1;
 	}
 
-	printf("Cipher algorithm  not supported!\n");
-	return -1;
+	return 0;
 }
 
 /** Parse crypto cipher operation command line argument */
@@ -1022,17 +972,13 @@ parse_size(int *size, const char *q_arg)
 static int
 parse_auth_algo(enum rte_crypto_auth_algorithm *algo, char *optarg)
 {
-	unsigned i;
-
-	for (i = 0; i < RTE_CRYPTO_AUTH_LIST_END; i++) {
-		if (!strcmp(supported_auth_algo[i], optarg)) {
-			*algo = (enum rte_crypto_auth_algorithm)i;
-			return 0;
-		}
+	if (rte_cryptodev_get_auth_algo_enum(algo, optarg) < 0) {
+		RTE_LOG(ERR, USER1, "Authentication algorithm specified "
+				"not supported!\n");
+		return -1;
 	}
 
-	printf("Authentication algorithm specified not supported!\n");
-	return -1;
+	return 0;
 }
 
 static int
@@ -1271,7 +1217,7 @@ display_cipher_info(struct l2fwd_crypto_options *options)
 {
 	printf("\n---- Cipher information ---\n");
 	printf("Algorithm: %s\n",
-		supported_cipher_algo[options->cipher_xform.cipher.algo]);
+		rte_crypto_cipher_algorithm_strings[options->cipher_xform.cipher.algo]);
 	rte_hexdump(stdout, "Cipher key:",
 			options->cipher_xform.cipher.key.data,
 			options->cipher_xform.cipher.key.length);
@@ -1283,7 +1229,7 @@ display_auth_info(struct l2fwd_crypto_options *options)
 {
 	printf("\n---- Authentication information ---\n");
 	printf("Algorithm: %s\n",
-		supported_auth_algo[options->auth_xform.auth.algo]);
+		rte_crypto_auth_algorithm_strings[options->auth_xform.cipher.algo]);
 	rte_hexdump(stdout, "Auth key:",
 			options->auth_xform.auth.key.data,
 			options->auth_xform.auth.key.length);
@@ -1605,7 +1551,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 			if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) {
 				printf("Algorithm %s not supported by cryptodev %u"
 					" or device not of preferred type (%s)\n",
-					supported_cipher_algo[opt_cipher_algo],
+					rte_crypto_cipher_algorithm_strings[opt_cipher_algo],
 					cdev_id,
 					options->string_type);
 				continue;
@@ -1705,7 +1651,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 			if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) {
 				printf("Algorithm %s not supported by cryptodev %u"
 					" or device not of preferred type (%s)\n",
-					supported_auth_algo[opt_auth_algo],
+					rte_crypto_auth_algorithm_strings[opt_auth_algo],
 					cdev_id,
 					options->string_type);
 				continue;
@@ -1985,9 +1931,6 @@ main(int argc, char **argv)
 	/* reserve memory for Cipher/Auth key and IV */
 	reserve_key_memory(&options);
 
-	/* fill out the supported algorithm tables */
-	fill_supported_algorithm_tables();
-
 	/* parse application arguments (after the EAL ones) */
 	ret = l2fwd_crypto_parse_args(&options, argc, argv);
 	if (ret < 0)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/4] New crypto algorithm string parser API
  2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
                     ` (3 preceding siblings ...)
  2017-02-27 14:38   ` [PATCH v2 4/4] examples/l2fwd-crypto: " Pablo de Lara
@ 2017-02-28 14:18   ` De Lara Guarch, Pablo
  4 siblings, 0 replies; 13+ messages in thread
From: De Lara Guarch, Pablo @ 2017-02-28 14:18 UTC (permalink / raw)
  To: Doherty, Declan; +Cc: dev



> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Monday, February 27, 2017 2:39 PM
> To: Doherty, Declan
> Cc: dev@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v2 0/4] New crypto algorithm string parser API
> 
> Last release, an array with strings for the supported algorithms
> by the cryptodev library was added and used in the crypto-perf app.
> 
> This patchset creates a new API to parse strings from the user,
> to select the desired algorithm (using the array above),
> which can be used by any application, making it consistent across
> all the applications (now, L2fwd-crypto and crypto-perf apps are
> using different strings).
> 
> Changes in v2:
> 
> - Modified L2fwd-crypto document to reflect the changes
> 
> Pablo de Lara (4):
>   cryptodev: add missing algorithm strings
>   cryptodev: add algorithm string parsers
>   app/crypto-perf: use cryptodev algorithm parser
>   examples/l2fwd-crypto: use cryptodev algorithm parser
> 
>  app/test-crypto-perf/cperf_options_parsing.c   | 206 ++-----------------------
>  doc/guides/sample_app_ug/l2_forward_crypto.rst |  10 +-
>  examples/l2fwd-crypto/main.c                   |  85 ++--------
>  lib/librte_cryptodev/rte_cryptodev.c           |  38 +++++
>  lib/librte_cryptodev/rte_cryptodev.h           |  30 ++++
>  lib/librte_cryptodev/rte_cryptodev_version.map |   8 +
>  6 files changed, 105 insertions(+), 272 deletions(-)
> 
> --
> 2.7.4

Applied to dpdk-next-crypto.

Pablo

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-02-28 14:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-23 12:33 [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
2017-02-23 12:33 ` [PATCH 1/4] cryptodev: add missing algorithm strings Pablo de Lara
2017-02-23 12:33 ` [PATCH 2/4] cryptodev: add algorithm string parsers Pablo de Lara
2017-02-23 12:33 ` [PATCH 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
2017-02-23 12:33 ` [PATCH 4/4] examples/l2fwd-crypto: " Pablo de Lara
2017-02-24 15:41 ` [PATCH 0/4] New crypto algorithm string parser API Trahe, Fiona
2017-02-25 11:18   ` Hemant Agrawal
2017-02-27 14:38 ` [PATCH v2 " Pablo de Lara
2017-02-27 14:38   ` [PATCH v2 1/4] cryptodev: add missing algorithm strings Pablo de Lara
2017-02-27 14:38   ` [PATCH v2 2/4] cryptodev: add algorithm string parsers Pablo de Lara
2017-02-27 14:38   ` [PATCH v2 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
2017-02-27 14:38   ` [PATCH v2 4/4] examples/l2fwd-crypto: " Pablo de Lara
2017-02-28 14:18   ` [PATCH v2 0/4] New crypto algorithm string parser API De Lara Guarch, Pablo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.