aboutsummaryrefslogtreecommitdiffstats
path: root/app/test-crypto-perf/cperf_options_parsing.c
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@gmail.com>2017-11-08 14:15:11 +0000
committerLuca Boccassi <luca.boccassi@gmail.com>2017-11-08 14:45:54 +0000
commit055c52583a2794da8ba1e85a48cce3832372b12f (patch)
tree8ceb1cb78fbb46a0f341f8ee24feb3c6b5540013 /app/test-crypto-perf/cperf_options_parsing.c
parentf239aed5e674965691846e8ce3f187dd47523689 (diff)
New upstream version 17.11-rc3
Change-Id: I6a5baa40612fe0c20f30b5fa773a6cbbac63a685 Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'app/test-crypto-perf/cperf_options_parsing.c')
-rw-r--r--app/test-crypto-perf/cperf_options_parsing.c170
1 files changed, 147 insertions, 23 deletions
diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index 085aa8fe..ad43e84c 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -46,6 +46,47 @@ struct name_id_map {
uint32_t id;
};
+static void
+usage(char *progname)
+{
+ printf("%s [EAL options] --\n"
+ " --silent: disable options dump\n"
+ " --ptest throughput / latency / verify / pmd-cycleount :"
+ " set test type\n"
+ " --pool_sz N: set the number of crypto ops/mbufs allocated\n"
+ " --total-ops N: set the number of total operations performed\n"
+ " --burst-sz N: set the number of packets per burst\n"
+ " --buffer-sz N: set the size of a single packet\n"
+ " --segment-sz N: set the size of the segment to use\n"
+ " --desc-nb N: set number of descriptors for each crypto device\n"
+ " --devtype TYPE: set crypto device type to use\n"
+ " --optype cipher-only / auth-only / cipher-then-auth /\n"
+ " auth-then-cipher / aead : set operation type\n"
+ " --sessionless: enable session-less crypto operations\n"
+ " --out-of-place: enable out-of-place crypto operations\n"
+ " --test-file NAME: set the test vector file path\n"
+ " --test-name NAME: set specific test name section in test file\n"
+ " --cipher-algo ALGO: set cipher algorithm\n"
+ " --cipher-op encrypt / decrypt: set the cipher operation\n"
+ " --cipher-key-sz N: set the cipher key size\n"
+ " --cipher-iv-sz N: set the cipher IV size\n"
+ " --auth-algo ALGO: set auth algorithm\n"
+ " --auth-op generate / verify: set the auth operation\n"
+ " --auth-key-sz N: set the auth key size\n"
+ " --auth-iv-sz N: set the auth IV size\n"
+ " --aead-algo ALGO: set AEAD algorithm\n"
+ " --aead-op encrypt / decrypt: set the AEAD operation\n"
+ " --aead-key-sz N: set the AEAD key size\n"
+ " --aead-iv-sz N: set the AEAD IV size\n"
+ " --aead-aad-sz N: set the AEAD AAD size\n"
+ " --digest-sz N: set the digest size\n"
+ " --pmd-cyclecount-delay-ms N: set delay between enqueue\n"
+ " and dequeue in pmd-cyclecount benchmarking mode\n"
+ " --csv-friendly: enable test result output CSV friendly\n"
+ " -h: prints this help\n",
+ progname);
+}
+
static int
get_str_key_id_mapping(struct name_id_map *map, unsigned int map_len,
const char *str_key)
@@ -76,6 +117,10 @@ parse_cperf_test_type(struct cperf_options *opts, const char *arg)
{
cperf_test_type_strs[CPERF_TEST_TYPE_LATENCY],
CPERF_TEST_TYPE_LATENCY
+ },
+ {
+ cperf_test_type_strs[CPERF_TEST_TYPE_PMDCC],
+ CPERF_TEST_TYPE_PMDCC
}
};
@@ -137,6 +182,7 @@ parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
if (copy_arg == NULL)
return -1;
+ errno = 0;
token = strtok(copy_arg, ":");
/* Parse minimum value */
@@ -203,6 +249,7 @@ parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max)
if (copy_arg == NULL)
return -1;
+ errno = 0;
token = strtok(copy_arg, ",");
/* Parse first value */
@@ -322,17 +369,35 @@ parse_buffer_sz(struct cperf_options *opts, const char *arg)
}
static int
-parse_segments_nb(struct cperf_options *opts, const char *arg)
+parse_segment_sz(struct cperf_options *opts, const char *arg)
{
- int ret = parse_uint32_t(&opts->segments_nb, arg);
+ int ret = parse_uint32_t(&opts->segment_sz, arg);
if (ret) {
- RTE_LOG(ERR, USER1, "failed to parse segments number\n");
+ RTE_LOG(ERR, USER1, "failed to parse segment size\n");
return -1;
}
- if ((opts->segments_nb == 0) || (opts->segments_nb > 255)) {
- RTE_LOG(ERR, USER1, "invalid segments number specified\n");
+ if (opts->segment_sz == 0) {
+ RTE_LOG(ERR, USER1, "Segment size has to be bigger than 0\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+parse_desc_nb(struct cperf_options *opts, const char *arg)
+{
+ int ret = parse_uint32_t(&opts->nb_descriptors, arg);
+
+ if (ret) {
+ RTE_LOG(ERR, USER1, "failed to parse descriptors number\n");
+ return -1;
+ }
+
+ if (opts->nb_descriptors == 0) {
+ RTE_LOG(ERR, USER1, "invalid descriptors number specified\n");
return -1;
}
@@ -623,6 +688,20 @@ parse_csv_friendly(struct cperf_options *opts, const char *arg __rte_unused)
return 0;
}
+static int
+parse_pmd_cyclecount_delay_ms(struct cperf_options *opts,
+ const char *arg)
+{
+ int ret = parse_uint32_t(&opts->pmdcc_delay, arg);
+
+ if (ret) {
+ RTE_LOG(ERR, USER1, "failed to parse pmd-cyclecount delay\n");
+ return -1;
+ }
+
+ return 0;
+}
+
typedef int (*option_parser_t)(struct cperf_options *opts,
const char *arg);
@@ -640,7 +719,8 @@ static struct option lgopts[] = {
{ CPERF_TOTAL_OPS, required_argument, 0, 0 },
{ CPERF_BURST_SIZE, required_argument, 0, 0 },
{ CPERF_BUFFER_SIZE, required_argument, 0, 0 },
- { CPERF_SEGMENTS_NB, required_argument, 0, 0 },
+ { CPERF_SEGMENT_SIZE, required_argument, 0, 0 },
+ { CPERF_DESC_NB, required_argument, 0, 0 },
{ CPERF_DEVTYPE, required_argument, 0, 0 },
{ CPERF_OPTYPE, required_argument, 0, 0 },
@@ -674,6 +754,8 @@ static struct option lgopts[] = {
{ CPERF_CSV, no_argument, 0, 0},
+ { CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 },
+
{ NULL, 0, 0, 0 }
};
@@ -684,6 +766,7 @@ cperf_options_default(struct cperf_options *opts)
opts->pool_sz = 8192;
opts->total_ops = 10000000;
+ opts->nb_descriptors = 2048;
opts->buffer_size_list[0] = 64;
opts->buffer_size_count = 1;
@@ -697,10 +780,15 @@ cperf_options_default(struct cperf_options *opts)
opts->min_burst_size = 32;
opts->inc_burst_size = 0;
- opts->segments_nb = 1;
+ /*
+ * Will be parsed from command line or set to
+ * maximum buffer size + digest, later
+ */
+ opts->segment_sz = 0;
strncpy(opts->device_type, "crypto_aesni_mb",
sizeof(opts->device_type));
+ opts->nb_qps = 1;
opts->op_type = CPERF_CIPHER_THEN_AUTH;
@@ -727,6 +815,8 @@ cperf_options_default(struct cperf_options *opts)
opts->aead_aad_sz = 0;
opts->digest_sz = 12;
+
+ opts->pmdcc_delay = 0;
}
static int
@@ -739,7 +829,8 @@ cperf_opts_parse_long(int opt_idx, struct cperf_options *opts)
{ CPERF_TOTAL_OPS, parse_total_ops },
{ CPERF_BURST_SIZE, parse_burst_sz },
{ CPERF_BUFFER_SIZE, parse_buffer_sz },
- { CPERF_SEGMENTS_NB, parse_segments_nb },
+ { CPERF_SEGMENT_SIZE, parse_segment_sz },
+ { CPERF_DESC_NB, parse_desc_nb },
{ CPERF_DEVTYPE, parse_device_type },
{ CPERF_OPTYPE, parse_op_type },
{ CPERF_SESSIONLESS, parse_sessionless },
@@ -761,6 +852,7 @@ cperf_opts_parse_long(int opt_idx, struct cperf_options *opts)
{ CPERF_AEAD_AAD_SZ, parse_aead_aad_sz },
{ CPERF_DIGEST_SZ, parse_digest_sz },
{ CPERF_CSV, parse_csv_friendly},
+ { CPERF_PMDCC_DELAY_MS, parse_pmd_cyclecount_delay_ms},
};
unsigned int i;
@@ -778,11 +870,14 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv)
{
int opt, retval, opt_idx;
- while ((opt = getopt_long(argc, argv, "", lgopts, &opt_idx)) != EOF) {
+ while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) {
switch (opt) {
+ case 'h':
+ usage(argv[0]);
+ rte_exit(EXIT_SUCCESS, "Displayed help\n");
+ break;
/* long options */
case 0:
-
retval = cperf_opts_parse_long(opt_idx, options);
if (retval != 0)
return retval;
@@ -790,6 +885,7 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv)
break;
default:
+ usage(argv[0]);
return -EINVAL;
}
}
@@ -830,14 +926,26 @@ check_cipher_buffer_length(struct cperf_options *options)
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 (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 % DES_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];
+ }
+
}
}
@@ -847,9 +955,21 @@ check_cipher_buffer_length(struct cperf_options *options)
int
cperf_options_check(struct cperf_options *options)
{
- if (options->segments_nb > options->min_buffer_size) {
+ if (options->op_type == CPERF_CIPHER_ONLY)
+ options->digest_sz = 0;
+
+ /*
+ * If segment size is not set, assume only one segment,
+ * big enough to contain the largest buffer and the digest
+ */
+ if (options->segment_sz == 0)
+ options->segment_sz = options->max_buffer_size +
+ options->digest_sz;
+
+ if (options->segment_sz < options->digest_sz) {
RTE_LOG(ERR, USER1,
- "Segments number greater than buffer size.\n");
+ "Segment size should be at least "
+ "the size of the digest\n");
return -EINVAL;
}
@@ -882,13 +1002,6 @@ cperf_options_check(struct cperf_options *options)
}
if (options->test == CPERF_TEST_TYPE_VERIFY &&
- options->total_ops > options->pool_sz) {
- RTE_LOG(ERR, USER1, "Total number of ops must be less than or"
- " equal to the pool size.\n");
- return -EINVAL;
- }
-
- if (options->test == CPERF_TEST_TYPE_VERIFY &&
(options->inc_buffer_size != 0 ||
options->buffer_size_count > 1)) {
RTE_LOG(ERR, USER1, "Only one buffer size is allowed when "
@@ -904,6 +1017,14 @@ cperf_options_check(struct cperf_options *options)
return -EINVAL;
}
+ if (options->test == CPERF_TEST_TYPE_PMDCC &&
+ options->pool_sz < options->nb_descriptors) {
+ RTE_LOG(ERR, USER1, "For pmd cyclecount benchmarks, pool size "
+ "must be equal or greater than the number of "
+ "cryptodev descriptors.\n");
+ return -EINVAL;
+ }
+
if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
options->auth_op !=
@@ -965,13 +1086,16 @@ cperf_options_dump(struct cperf_options *opts)
printf("%u ", opts->burst_size_list[size_idx]);
printf("\n");
}
- printf("\n# segments per buffer: %u\n", opts->segments_nb);
+ printf("\n# segment size: %u\n", opts->segment_sz);
printf("#\n");
printf("# cryptodev type: %s\n", opts->device_type);
printf("#\n");
+ printf("# number of queue pairs per device: %u\n", opts->nb_qps);
printf("# crypto operation: %s\n", cperf_op_type_strs[opts->op_type]);
printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");
printf("# out of place: %s\n", opts->out_of_place ? "yes" : "no");
+ if (opts->test == CPERF_TEST_TYPE_PMDCC)
+ printf("# inter-burst delay: %u ms\n", opts->pmdcc_delay);
printf("#\n");