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 8/9] app/crypto-perf: add extra option checks
Date: Mon, 27 Mar 2017 12:26:05 +0100	[thread overview]
Message-ID: <1490613966-74180-9-git-send-email-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <1490613966-74180-1-git-send-email-pablo.de.lara.guarch@intel.com>

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 <pablo.de.lara.guarch@intel.com>
---
 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

  parent reply	other threads:[~2017-03-27 11:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 16:13 [dpdk-dev] [PATCH 0/3] Crypto performance app improvements Pablo de Lara
2017-03-03 16:13 ` [dpdk-dev] [PATCH 1/3] app/crypto-perf: move verify as single test type Pablo de Lara
2017-03-03 16:13 ` [dpdk-dev] [PATCH 2/3] app/crypto-perf: do not append digest if not used Pablo de Lara
2017-03-03 16:13 ` [dpdk-dev] [PATCH 3/3] app/crypto-perf: add range/list of sizes Pablo de Lara
2017-03-27 11:25 ` [dpdk-dev] [PATCH v2 0/9] Crypto performance app improvements Pablo de Lara
2017-03-27 11:25   ` [dpdk-dev] [PATCH v2 1/9] app/crypto-perf: remove cyclecount test type Pablo de Lara
2017-03-27 11:25   ` [dpdk-dev] [PATCH v2 2/9] app/crypto-perf: remove unused file Pablo de Lara
2017-03-27 11:26   ` [dpdk-dev] [PATCH v2 3/9] app/crypto-perf: fix AES CBC 128 test vectors Pablo de Lara
2017-03-27 11:26   ` [dpdk-dev] [PATCH v2 4/9] app/crypto-perf: move verify as single test type Pablo de Lara
2017-03-27 11:26   ` [dpdk-dev] [PATCH v2 5/9] app/crypto-perf: do not append digest if not used Pablo de Lara
2017-03-27 11:26   ` [dpdk-dev] [PATCH v2 6/9] app/crypto-perf: display results in test runner Pablo de Lara
2017-03-27 11:26   ` [dpdk-dev] [PATCH v2 7/9] app/crypto-perf: add range/list of sizes Pablo de Lara
2017-03-27 11:26   ` Pablo de Lara [this message]
2017-03-27 11:26   ` [dpdk-dev] [PATCH v2 9/9] app/crypto-perf: reorg options structure Pablo de Lara
2017-03-27 12:29   ` [dpdk-dev] [PATCH v2 0/9] Crypto performance app improvements De Lara Guarch, Pablo
2017-03-29 15:24     ` Sergio Gonzalez Monroy
2017-03-29 22:22       ` 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=1490613966-74180-9-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).