From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 52B96D59A for ; Mon, 27 Feb 2017 15:36:50 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2017 06:36:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,215,1484035200"; d="scan'208";a="69552055" 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:48 -0800 From: Pablo de Lara To: declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Mon, 27 Feb 2017 14:38:46 +0000 Message-Id: <1488206326-70385-5-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 4/4] examples/l2fwd-crypto: 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:51 -0000 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 Acked-by: Fiona Trahe Acked-by: Hemant Agrawal --- 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