From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A6DD5FAFA for ; Mon, 27 Mar 2017 13:26:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490613999; x=1522149999; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=3n2MkVfNc7Re6RNw+5lyjczwGwG6Zn4jqYwHUP7kDBY=; b=Y6Ky3GFeL2rWbKXJ8HGHWEzyWV2Wg+qEUl0CpUMOsfLETfjKMiim6EzF C44pJTFKSUFfWrybmzKCxlW7xv+gPg==; Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 04:26:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,231,1486454400"; d="scan'208";a="79709458" Received: from silpixa00381631.ir.intel.com (HELO silpixa00381631.ger.corp.intel.com) ([10.237.222.122]) by orsmga005.jf.intel.com with ESMTP; 27 Mar 2017 04:26:38 -0700 From: Pablo de Lara To: declan.doherty@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Mon, 27 Mar 2017 12:26:05 +0100 Message-Id: <1490613966-74180-9-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490613966-74180-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1488557592-46193-1-git-send-email-pablo.de.lara.guarch@intel.com> <1490613966-74180-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 8/9] app/crypto-perf: add extra option checks 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 Mar 2017 11:26:40 -0000 When using the verify test, test name is necessary to be passed when digest is needed. Also, when using an block cipher algorithm (CBC, ECB), the buffer size has to be aligned to the block size. Signed-off-by: Pablo de Lara --- app/test-crypto-perf/cperf_options_parsing.c | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index e458f6d..d172671 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -38,6 +38,9 @@ #include "cperf_options.h" +#define AES_BLOCK_SIZE 16 +#define DES_BLOCK_SIZE 8 + struct name_id_map { const char *name; uint32_t id; @@ -717,6 +720,8 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) int cperf_options_check(struct cperf_options *options) { + uint32_t buffer_size, buffer_size_idx = 0; + if (options->segments_nb > options->min_buffer_size) { RTE_LOG(ERR, USER1, "Segments number greater than buffer size.\n"); @@ -730,6 +735,14 @@ cperf_options_check(struct cperf_options *options) return -EINVAL; } + if (options->test == CPERF_TEST_TYPE_VERIFY && + options->op_type != CPERF_CIPHER_ONLY && + options->test_name == NULL) { + RTE_LOG(ERR, USER1, "Define test name to get the correct digest" + " from the test vectors.\n"); + return -EINVAL; + } + if (options->test_name != NULL && options->test_file == NULL) { RTE_LOG(ERR, USER1, "Define path to the file with test" " vectors.\n"); @@ -807,6 +820,45 @@ cperf_options_check(struct cperf_options *options) } } + if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC || + options->cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) { + if (options->inc_buffer_size != 0) + buffer_size = options->min_buffer_size; + else + buffer_size = options->buffer_size_list[0]; + + while (buffer_size <= options->max_buffer_size) { + if ((buffer_size % AES_BLOCK_SIZE) != 0) { + RTE_LOG(ERR, USER1, "Some of the buffer sizes are " + "not suitable for the algorithm selected\n"); + return -EINVAL; + } + + if (options->inc_buffer_size != 0) + buffer_size += options->inc_buffer_size; + else { + if (++buffer_size_idx == options->buffer_size_count) + break; + buffer_size = options->buffer_size_list[buffer_size_idx]; + } + + } + } + + if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC || + options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC || + options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) { + for (buffer_size = options->min_buffer_size; + buffer_size < options->max_buffer_size; + buffer_size += options->inc_buffer_size) { + if ((buffer_size % DES_BLOCK_SIZE) != 0) { + RTE_LOG(ERR, USER1, "Some of the buffer sizes are " + "not suitable for the algorithm selected\n"); + return -EINVAL; + } + } + } + return 0; } -- 2.7.4