From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id EB959BD28 for ; Mon, 27 Feb 2017 15:36:44 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 27 Feb 2017 06:36:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,215,1484035200"; d="scan'208";a="69552018" Received: from silpixa00381631.ir.intel.com (HELO silpixa00381631.ger.corp.intel.com) ([10.237.222.122]) by orsmga005.jf.intel.com with ESMTP; 27 Feb 2017 06:36:42 -0800 From: Pablo de Lara To: declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Mon, 27 Feb 2017 14:38:45 +0000 Message-Id: <1488206326-70385-4-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488206326-70385-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1487853218-113232-1-git-send-email-pablo.de.lara.guarch@intel.com> <1488206326-70385-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 3/4] app/crypto-perf: use cryptodev algorithm parser X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2017 14:36:45 -0000 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 Acked-by: Fiona Trahe Acked-by: Hemant Agrawal --- 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 #include +#include #include #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