DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: declan.doherty@intel.com
Cc: dev@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [dpdk-dev] [PATCH v2 3/4] app/crypto-perf: use cryptodev algorithm parser
Date: Mon, 27 Feb 2017 14:38:45 +0000	[thread overview]
Message-ID: <1488206326-70385-4-git-send-email-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <1488206326-70385-1-git-send-email-pablo.de.lara.guarch@intel.com>

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

  parent reply	other threads:[~2017-02-27 14:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23 12:33 [dpdk-dev] [PATCH 0/4] New crypto algorithm string parser API Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 1/4] cryptodev: add missing algorithm strings Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 2/4] cryptodev: add algorithm string parsers Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 3/4] app/crypto-perf: use cryptodev algorithm parser Pablo de Lara
2017-02-23 12:33 ` [dpdk-dev] [PATCH 4/4] examples/l2fwd-crypto: " Pablo de Lara
2017-02-24 15:41 ` [dpdk-dev] [PATCH 0/4] New crypto algorithm string parser API Trahe, Fiona
2017-02-25 11:18   ` Hemant Agrawal
2017-02-27 14:38 ` [dpdk-dev] [PATCH v2 " Pablo de Lara
2017-02-27 14:38   ` [dpdk-dev] [PATCH v2 1/4] cryptodev: add missing algorithm strings Pablo de Lara
2017-02-27 14:38   ` [dpdk-dev] [PATCH v2 2/4] cryptodev: add algorithm string parsers Pablo de Lara
2017-02-27 14:38   ` Pablo de Lara [this message]
2017-02-27 14:38   ` [dpdk-dev] [PATCH v2 4/4] examples/l2fwd-crypto: use cryptodev algorithm parser Pablo de Lara
2017-02-28 14:18   ` [dpdk-dev] [PATCH v2 0/4] New crypto algorithm string parser API De Lara Guarch, Pablo

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=1488206326-70385-4-git-send-email-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@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).