X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-crypto-perf%2Fcperf_options_parsing.c;h=af81162bd922e9d364d947c9b4da96457d318b37;hb=0c2173c166da8abba93ed4a2f602ad523ee7a59a;hp=63ba37cf4b9c470f55d672cf67147eeed93f7f65;hpb=0dfef60553e055b4aee36f7d9e9f3b662668a01b;p=dpdk.git diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 63ba37cf4b..af81162bd9 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -76,6 +76,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 +141,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 +208,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 */ @@ -339,6 +345,24 @@ parse_segments_nb(struct cperf_options *opts, const char *arg) 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; + } + + return 0; +} + static int parse_device_type(struct cperf_options *opts, const char *arg) { @@ -543,15 +567,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->digest_sz, arg); +} + +static int +parse_auth_iv_sz(struct cperf_options *opts, const char *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->auth_digest_sz, arg); + return parse_uint16_t(&opts->aead_key_sz, arg); } static int -parse_auth_aad_sz(struct cperf_options *opts, const char *arg) +parse_aead_iv_sz(struct cperf_options *opts, const char *arg) { - return parse_uint16_t(&opts->auth_aad_sz, 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 @@ -562,6 +647,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); @@ -580,6 +679,7 @@ static struct option lgopts[] = { { CPERF_BURST_SIZE, required_argument, 0, 0 }, { CPERF_BUFFER_SIZE, required_argument, 0, 0 }, { CPERF_SEGMENTS_NB, required_argument, 0, 0 }, + { CPERF_DESC_NB, required_argument, 0, 0 }, { CPERF_DEVTYPE, required_argument, 0, 0 }, { CPERF_OPTYPE, required_argument, 0, 0 }, @@ -600,10 +700,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 } }; @@ -614,6 +725,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; @@ -650,8 +762,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 @@ -665,6 +784,7 @@ cperf_opts_parse_long(int opt_idx, struct cperf_options *opts) { CPERF_BURST_SIZE, parse_burst_sz }, { CPERF_BUFFER_SIZE, parse_buffer_sz }, { CPERF_SEGMENTS_NB, parse_segments_nb }, + { CPERF_DESC_NB, parse_desc_nb }, { CPERF_DEVTYPE, parse_device_type }, { CPERF_OPTYPE, parse_op_type }, { CPERF_SESSIONLESS, parse_sessionless }, @@ -678,9 +798,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; @@ -717,11 +843,68 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) return 0; } -int -cperf_options_check(struct cperf_options *options) +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->min_buffer_size) { RTE_LOG(ERR, USER1, "Segments number greater than buffer size.\n"); @@ -779,6 +962,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 != @@ -795,68 +986,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; - } - } - - 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; @@ -902,27 +1038,27 @@ cperf_options_dump(struct cperf_options *opts) 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"); 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", @@ -931,4 +1067,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"); + } }