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 660855598 for ; Thu, 23 Feb 2017 13:31:45 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP; 23 Feb 2017 04:31:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,197,1484035200"; d="scan'208";a="827607384" Received: from silpixa00381631.ir.intel.com (HELO silpixa00381631.ger.corp.intel.com) ([10.237.222.122]) by FMSMGA003.fm.intel.com with ESMTP; 23 Feb 2017 04:31:43 -0800 From: Pablo de Lara To: declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Thu, 23 Feb 2017 12:33:37 +0000 Message-Id: <1487853218-113232-4-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487853218-113232-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1487853218-113232-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH 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: Thu, 23 Feb 2017 12:31: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 --- 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