X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-crypto-perf%2Fcperf_options_parsing.c;h=7a5aa06a67d80dd30ced248f46f74a076edf400f;hb=7687735442922e937fc8871825be696d3021746b;hp=d6afc8548f375c301f22a86c3298f3cbb56766c3;hpb=5e669376316651d6b6ed2d67cc0cb9a7d4c63b3a;p=dpdk.git diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index d6afc8548f..7a5aa06a67 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -1,33 +1,5 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2016-2017 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2016-2017 Intel Corporation */ #include @@ -38,11 +10,56 @@ #include "cperf_options.h" +#define AES_BLOCK_SIZE 16 +#define DES_BLOCK_SIZE 8 + struct name_id_map { const char *name; 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" + " --imix N: set the distribution of packet sizes\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) @@ -67,12 +84,16 @@ parse_cperf_test_type(struct cperf_options *opts, const char *arg) CPERF_TEST_TYPE_THROUGHPUT }, { - cperf_test_type_strs[CPERF_TEST_TYPE_CYCLECOUNT], - CPERF_TEST_TYPE_CYCLECOUNT + cperf_test_type_strs[CPERF_TEST_TYPE_VERIFY], + CPERF_TEST_TYPE_VERIFY }, { cperf_test_type_strs[CPERF_TEST_TYPE_LATENCY], CPERF_TEST_TYPE_LATENCY + }, + { + cperf_test_type_strs[CPERF_TEST_TYPE_PMDCC], + CPERF_TEST_TYPE_PMDCC } }; @@ -123,6 +144,141 @@ parse_uint16_t(uint16_t *value, const char *arg) return 0; } +static int +parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc) +{ + char *token; + uint32_t number; + + char *copy_arg = strdup(arg); + + if (copy_arg == NULL) + return -1; + + errno = 0; + token = strtok(copy_arg, ":"); + + /* Parse minimum value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE || + number == 0) + goto err_range; + + *min = number; + } else + goto err_range; + + token = strtok(NULL, ":"); + + /* Parse increment value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE || + number == 0) + goto err_range; + + *inc = number; + } else + goto err_range; + + token = strtok(NULL, ":"); + + /* Parse maximum value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE || + number == 0 || + number < *min) + goto err_range; + + *max = number; + } else + goto err_range; + + if (strtok(NULL, ":") != NULL) + goto err_range; + + free(copy_arg); + return 0; + +err_range: + free(copy_arg); + return -1; +} + +static int +parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max) +{ + char *token; + uint32_t number; + uint8_t count = 0; + uint32_t temp_min; + uint32_t temp_max; + + char *copy_arg = strdup(arg); + + if (copy_arg == NULL) + return -1; + + errno = 0; + token = strtok(copy_arg, ","); + + /* Parse first value */ + if (token != NULL) { + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE || + number == 0) + goto err_list; + + list[count++] = number; + temp_min = number; + temp_max = number; + } else + goto err_list; + + token = strtok(NULL, ","); + + while (token != NULL) { + if (count == MAX_LIST) { + RTE_LOG(WARNING, USER1, "Using only the first %u sizes\n", + MAX_LIST); + break; + } + + number = strtoul(token, NULL, 10); + + if (errno == EINVAL || errno == ERANGE || + number == 0) + goto err_list; + + list[count++] = number; + + if (number < temp_min) + temp_min = number; + if (number > temp_max) + temp_max = number; + + token = strtok(NULL, ","); + } + + if (min) + *min = temp_min; + if (max) + *max = temp_max; + + free(copy_arg); + return count; + +err_list: + free(copy_arg); + return -1; +} + static int parse_total_ops(struct cperf_options *opts, const char *arg) { @@ -153,46 +309,98 @@ parse_pool_sz(struct cperf_options *opts, const char *arg) static int parse_burst_sz(struct cperf_options *opts, const char *arg) { - int ret = parse_uint32_t(&opts->burst_sz, arg); + int ret; + + /* Try parsing the argument as a range, if it fails, parse it as a list */ + if (parse_range(arg, &opts->min_burst_size, &opts->max_burst_size, + &opts->inc_burst_size) < 0) { + ret = parse_list(arg, opts->burst_size_list, + &opts->min_burst_size, + &opts->max_burst_size); + if (ret < 0) { + RTE_LOG(ERR, USER1, "failed to parse burst size/s\n"); + return -1; + } + opts->burst_size_count = ret; + } - if (ret) - RTE_LOG(ERR, USER1, "failed to parse burst size"); - return ret; + return 0; } static int parse_buffer_sz(struct cperf_options *opts, const char *arg) { - uint32_t i, valid_buf_sz[] = { - 32, 64, 128, 256, 384, 512, 768, 1024, 1280, 1536, 1792, - 2048 - }; + int ret; + + /* Try parsing the argument as a range, if it fails, parse it as a list */ + if (parse_range(arg, &opts->min_buffer_size, &opts->max_buffer_size, + &opts->inc_buffer_size) < 0) { + ret = parse_list(arg, opts->buffer_size_list, + &opts->min_buffer_size, + &opts->max_buffer_size); + if (ret < 0) { + RTE_LOG(ERR, USER1, "failed to parse buffer size/s\n"); + return -1; + } + opts->buffer_size_count = ret; + } + + return 0; +} + +static int +parse_segment_sz(struct cperf_options *opts, const char *arg) +{ + int ret = parse_uint32_t(&opts->segment_sz, arg); + + if (ret) { + RTE_LOG(ERR, USER1, "failed to parse segment size\n"); + return -1; + } - if (parse_uint32_t(&opts->buffer_sz, arg)) { - RTE_LOG(ERR, USER1, "failed to parse buffer size"); + if (opts->segment_sz == 0) { + RTE_LOG(ERR, USER1, "Segment size has to be bigger than 0\n"); return -1; } - for (i = 0; i < RTE_DIM(valid_buf_sz); i++) - if (valid_buf_sz[i] == opts->buffer_sz) - return 0; + return 0; +} - RTE_LOG(ERR, USER1, "invalid buffer size specified"); - return -1; +static int +parse_imix(struct cperf_options *opts, const char *arg) +{ + int ret; + + ret = parse_list(arg, opts->imix_distribution_list, + NULL, NULL); + if (ret < 0) { + RTE_LOG(ERR, USER1, "failed to parse imix distribution\n"); + return -1; + } + + opts->imix_distribution_count = ret; + + if (opts->imix_distribution_count <= 1) { + RTE_LOG(ERR, USER1, "imix distribution should have " + "at least two entries\n"); + return -1; + } + + return 0; } static int -parse_segments_nb(struct cperf_options *opts, const char *arg) +parse_desc_nb(struct cperf_options *opts, const char *arg) { - int ret = parse_uint32_t(&opts->segments_nb, arg); + int ret = parse_uint32_t(&opts->nb_descriptors, arg); if (ret) { - RTE_LOG(ERR, USER1, "failed to parse segments number\n"); + RTE_LOG(ERR, USER1, "failed to parse descriptors number\n"); return -1; } - if ((opts->segments_nb == 0) || (opts->segments_nb > 255)) { - RTE_LOG(ERR, USER1, "invalid segments number specified\n"); + if (opts->nb_descriptors == 0) { + RTE_LOG(ERR, USER1, "invalid descriptors number specified\n"); return -1; } @@ -265,15 +473,6 @@ parse_out_of_place(struct cperf_options *opts, return 0; } -static int -parse_verify(struct cperf_options *opts, - const char *arg __rte_unused) -{ - opts->verify = 1; - - return 0; -} - static int parse_test_file(struct cperf_options *opts, const char *arg) @@ -412,15 +611,76 @@ parse_auth_key_sz(struct cperf_options *opts, const char *arg) } static int -parse_auth_digest_sz(struct cperf_options *opts, const char *arg) +parse_digest_sz(struct cperf_options *opts, const char *arg) { - return parse_uint16_t(&opts->auth_digest_sz, arg); + return parse_uint16_t(&opts->digest_sz, arg); } static int -parse_auth_aad_sz(struct cperf_options *opts, const char *arg) +parse_auth_iv_sz(struct cperf_options *opts, const char *arg) { - return parse_uint16_t(&opts->auth_aad_sz, arg); + return parse_uint16_t(&opts->auth_iv_sz, arg); +} + +static int +parse_aead_algo(struct cperf_options *opts, const char *arg) +{ + enum rte_crypto_aead_algorithm aead_algo; + + if (rte_cryptodev_get_aead_algo_enum(&aead_algo, arg) < 0) { + RTE_LOG(ERR, USER1, "Invalid AEAD algorithm specified\n"); + return -1; + } + + opts->aead_algo = aead_algo; + + return 0; +} + +static int +parse_aead_op(struct cperf_options *opts, const char *arg) +{ + struct name_id_map aead_op_namemap[] = { + { + rte_crypto_aead_operation_strings + [RTE_CRYPTO_AEAD_OP_ENCRYPT], + RTE_CRYPTO_AEAD_OP_ENCRYPT }, + { + rte_crypto_aead_operation_strings + [RTE_CRYPTO_AEAD_OP_DECRYPT], + RTE_CRYPTO_AEAD_OP_DECRYPT + } + }; + + int id = get_str_key_id_mapping(aead_op_namemap, + RTE_DIM(aead_op_namemap), arg); + if (id < 0) { + RTE_LOG(ERR, USER1, "invalid AEAD operation specified" + "\n"); + return -1; + } + + opts->aead_op = (enum rte_crypto_aead_operation)id; + + return 0; +} + +static int +parse_aead_key_sz(struct cperf_options *opts, const char *arg) +{ + return parse_uint16_t(&opts->aead_key_sz, arg); +} + +static int +parse_aead_iv_sz(struct cperf_options *opts, const char *arg) +{ + return parse_uint16_t(&opts->aead_iv_sz, arg); +} + +static int +parse_aead_aad_sz(struct cperf_options *opts, const char *arg) +{ + return parse_uint16_t(&opts->aead_aad_sz, arg); } static int @@ -431,6 +691,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); @@ -448,15 +722,16 @@ 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_IMIX, required_argument, 0, 0 }, { CPERF_DEVTYPE, required_argument, 0, 0 }, { CPERF_OPTYPE, required_argument, 0, 0 }, { CPERF_SILENT, no_argument, 0, 0 }, { CPERF_SESSIONLESS, no_argument, 0, 0 }, { CPERF_OUT_OF_PLACE, no_argument, 0, 0 }, - { CPERF_VERIFY, no_argument, 0, 0 }, { CPERF_TEST_FILE, required_argument, 0, 0 }, { CPERF_TEST_NAME, required_argument, 0, 0 }, @@ -470,10 +745,21 @@ static struct option lgopts[] = { { CPERF_AUTH_OP, required_argument, 0, 0 }, { CPERF_AUTH_KEY_SZ, required_argument, 0, 0 }, - { CPERF_AUTH_DIGEST_SZ, required_argument, 0, 0 }, - { CPERF_AUTH_AAD_SZ, required_argument, 0, 0 }, + { CPERF_AUTH_IV_SZ, required_argument, 0, 0 }, + + { CPERF_AEAD_ALGO, required_argument, 0, 0 }, + { CPERF_AEAD_OP, required_argument, 0, 0 }, + + { CPERF_AEAD_KEY_SZ, required_argument, 0, 0 }, + { CPERF_AEAD_AAD_SZ, required_argument, 0, 0 }, + { CPERF_AEAD_IV_SZ, required_argument, 0, 0 }, + + { CPERF_DIGEST_SZ, required_argument, 0, 0 }, + { CPERF_CSV, no_argument, 0, 0}, + { CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 }, + { NULL, 0, 0, 0 } }; @@ -484,17 +770,34 @@ cperf_options_default(struct cperf_options *opts) opts->pool_sz = 8192; opts->total_ops = 10000000; - opts->burst_sz = 32; - opts->buffer_sz = 64; - opts->segments_nb = 1; - + opts->nb_descriptors = 2048; + + opts->buffer_size_list[0] = 64; + opts->buffer_size_count = 1; + opts->max_buffer_size = 64; + opts->min_buffer_size = 64; + opts->inc_buffer_size = 0; + + opts->burst_size_list[0] = 32; + opts->burst_size_count = 1; + opts->max_burst_size = 32; + opts->min_burst_size = 32; + opts->inc_burst_size = 0; + + /* + * Will be parsed from command line or set to + * maximum buffer size + digest, later + */ + opts->segment_sz = 0; + + opts->imix_distribution_count = 0; strncpy(opts->device_type, "crypto_aesni_mb", sizeof(opts->device_type)); + opts->nb_qps = 1; opts->op_type = CPERF_CIPHER_THEN_AUTH; opts->silent = 0; - opts->verify = 0; opts->test_file = NULL; opts->test_name = NULL; opts->sessionless = 0; @@ -510,8 +813,15 @@ cperf_options_default(struct cperf_options *opts) opts->auth_op = RTE_CRYPTO_AUTH_OP_GENERATE; opts->auth_key_sz = 64; - opts->auth_digest_sz = 12; - opts->auth_aad_sz = 0; + opts->auth_iv_sz = 0; + + opts->aead_key_sz = 0; + opts->aead_iv_sz = 0; + opts->aead_aad_sz = 0; + + opts->digest_sz = 12; + + opts->pmdcc_delay = 0; } static int @@ -524,12 +834,13 @@ 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 }, { CPERF_OUT_OF_PLACE, parse_out_of_place }, - { CPERF_VERIFY, parse_verify }, + { CPERF_IMIX, parse_imix }, { CPERF_TEST_FILE, parse_test_file }, { CPERF_TEST_NAME, parse_test_name }, { CPERF_CIPHER_ALGO, parse_cipher_algo }, @@ -539,9 +850,15 @@ cperf_opts_parse_long(int opt_idx, struct cperf_options *opts) { CPERF_AUTH_ALGO, parse_auth_algo }, { CPERF_AUTH_OP, parse_auth_op }, { CPERF_AUTH_KEY_SZ, parse_auth_key_sz }, - { CPERF_AUTH_DIGEST_SZ, parse_auth_digest_sz }, - { CPERF_AUTH_AAD_SZ, parse_auth_aad_sz }, - { CPERF_CSV, parse_csv_friendly}, + { CPERF_AUTH_IV_SZ, parse_auth_iv_sz }, + { CPERF_AEAD_ALGO, parse_aead_algo }, + { CPERF_AEAD_OP, parse_aead_op }, + { CPERF_AEAD_KEY_SZ, parse_aead_key_sz }, + { CPERF_AEAD_IV_SZ, parse_aead_iv_sz }, + { 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; @@ -559,11 +876,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; @@ -571,6 +891,7 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) break; default: + usage(argv[0]); return -EINVAL; } } @@ -578,21 +899,109 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) return 0; } +static int +check_cipher_buffer_length(struct cperf_options *options) +{ + uint32_t buffer_size, buffer_size_idx = 0; + + 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) { + 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]; + } + + } + } + + return 0; +} + int cperf_options_check(struct cperf_options *options) { - if (options->segments_nb > options->buffer_sz) { + 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; } - if (options->verify && options->test_file == NULL) { + if ((options->imix_distribution_count != 0) && + (options->imix_distribution_count != + options->buffer_size_count)) { + RTE_LOG(ERR, USER1, "IMIX distribution must have the same " + "number of buffer sizes\n"); + return -EINVAL; + } + + if (options->test == CPERF_TEST_TYPE_VERIFY && + options->test_file == NULL) { RTE_LOG(ERR, USER1, "Define path to the file with test" " vectors.\n"); 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"); @@ -606,10 +1015,34 @@ cperf_options_check(struct cperf_options *options) return -EINVAL; } - if (options->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"); + 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 " + "using the verify test.\n"); + return -EINVAL; + } + + if (options->test == CPERF_TEST_TYPE_VERIFY && + (options->inc_burst_size != 0 || + options->burst_size_count > 1)) { + RTE_LOG(ERR, USER1, "Only one burst size is allowed when " + "using the verify test.\n"); + 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->test == CPERF_TEST_TYPE_VERIFY && + options->imix_distribution_count > 0) { + RTE_LOG(ERR, USER1, "IMIX is not allowed when " + "using the verify test.\n"); return -EINVAL; } @@ -629,29 +1062,13 @@ cperf_options_check(struct cperf_options *options) " options: decrypt and verify.\n"); return -EINVAL; } - } else if (options->op_type == CPERF_AEAD) { - if (!(options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT && - options->auth_op == - RTE_CRYPTO_AUTH_OP_GENERATE) && - !(options->cipher_op == - RTE_CRYPTO_CIPHER_OP_DECRYPT && - options->auth_op == - RTE_CRYPTO_AUTH_OP_VERIFY)) { - RTE_LOG(ERR, USER1, "Use together options: encrypt and" - " generate or decrypt and verify.\n"); - return -EINVAL; - } } - if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_GCM || - options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CCM || - options->auth_algo == RTE_CRYPTO_AUTH_AES_GCM || - options->auth_algo == RTE_CRYPTO_AUTH_AES_CCM || - options->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) { - if (options->op_type != CPERF_AEAD) { - RTE_LOG(ERR, USER1, "Use --optype aead\n"); + if (options->op_type == CPERF_CIPHER_ONLY || + options->op_type == CPERF_CIPHER_THEN_AUTH || + options->op_type == CPERF_AUTH_THEN_CIPHER) { + if (check_cipher_buffer_length(options) < 0) return -EINVAL; - } } return 0; @@ -660,43 +1077,65 @@ cperf_options_check(struct cperf_options *options) void cperf_options_dump(struct cperf_options *opts) { + uint8_t size_idx; + printf("# Crypto Performance Application Options:\n"); printf("#\n"); printf("# cperf test: %s\n", cperf_test_type_strs[opts->test]); printf("#\n"); printf("# size of crypto op / mbuf pool: %u\n", opts->pool_sz); printf("# total number of ops: %u\n", opts->total_ops); - printf("# burst size: %u\n", opts->burst_sz); - printf("# buffer size: %u\n", opts->buffer_sz); - printf("# segments per buffer: %u\n", opts->segments_nb); + if (opts->inc_buffer_size != 0) { + printf("# buffer size:\n"); + printf("#\t min: %u\n", opts->min_buffer_size); + printf("#\t max: %u\n", opts->max_buffer_size); + printf("#\t inc: %u\n", opts->inc_buffer_size); + } else { + printf("# buffer sizes: "); + for (size_idx = 0; size_idx < opts->buffer_size_count; size_idx++) + printf("%u ", opts->buffer_size_list[size_idx]); + printf("\n"); + } + if (opts->inc_burst_size != 0) { + printf("# burst size:\n"); + printf("#\t min: %u\n", opts->min_burst_size); + printf("#\t max: %u\n", opts->max_burst_size); + printf("#\t inc: %u\n", opts->inc_burst_size); + } else { + printf("# burst sizes: "); + for (size_idx = 0; size_idx < opts->burst_size_count; size_idx++) + printf("%u ", opts->burst_size_list[size_idx]); + printf("\n"); + } + 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("# verify operation: %s\n", opts->verify ? "yes" : "no"); 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"); if (opts->op_type == CPERF_AUTH_ONLY || opts->op_type == CPERF_CIPHER_THEN_AUTH || - opts->op_type == CPERF_AUTH_THEN_CIPHER || - opts->op_type == CPERF_AEAD) { + opts->op_type == CPERF_AUTH_THEN_CIPHER) { printf("# auth algorithm: %s\n", rte_crypto_auth_algorithm_strings[opts->auth_algo]); printf("# auth operation: %s\n", rte_crypto_auth_operation_strings[opts->auth_op]); printf("# auth key size: %u\n", opts->auth_key_sz); - printf("# auth digest size: %u\n", opts->auth_digest_sz); - printf("# auth aad size: %u\n", opts->auth_aad_sz); + printf("# auth iv size: %u\n", opts->auth_iv_sz); + printf("# auth digest size: %u\n", opts->digest_sz); printf("#\n"); } if (opts->op_type == CPERF_CIPHER_ONLY || opts->op_type == CPERF_CIPHER_THEN_AUTH || - opts->op_type == CPERF_AUTH_THEN_CIPHER || - opts->op_type == CPERF_AEAD) { + opts->op_type == CPERF_AUTH_THEN_CIPHER) { printf("# cipher algorithm: %s\n", rte_crypto_cipher_algorithm_strings[opts->cipher_algo]); printf("# cipher operation: %s\n", @@ -705,4 +1144,16 @@ cperf_options_dump(struct cperf_options *opts) printf("# cipher iv size: %u\n", opts->cipher_iv_sz); printf("#\n"); } + + if (opts->op_type == CPERF_AEAD) { + printf("# aead algorithm: %s\n", + rte_crypto_aead_algorithm_strings[opts->aead_algo]); + printf("# aead operation: %s\n", + rte_crypto_aead_operation_strings[opts->aead_op]); + printf("# aead key size: %u\n", opts->aead_key_sz); + printf("# aead iv size: %u\n", opts->aead_iv_sz); + printf("# aead digest size: %u\n", opts->digest_sz); + printf("# aead aad size: %u\n", opts->aead_aad_sz); + printf("#\n"); + } }