X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-crypto-perf%2Fcperf_options_parsing.c;h=c244f81bbf10f2ac6f20b038d9b73f0430b06802;hb=c7ebd65c137215d714b445b7b4c584007cc89ffb;hp=7a5aa06a67d80dd30ced248f46f74a076edf400f;hpb=27c2e74719614df32e5358b9adfbed013ac7991c;p=dpdk.git diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index 7a5aa06a67..c244f81bbf 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -7,6 +7,7 @@ #include #include +#include #include "cperf_options.h" @@ -23,7 +24,7 @@ usage(char *progname) { printf("%s [EAL options] --\n" " --silent: disable options dump\n" - " --ptest throughput / latency / verify / pmd-cycleount :" + " --ptest throughput / latency / verify / pmd-cyclecount :" " 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" @@ -56,6 +57,12 @@ usage(char *progname) " --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" +#ifdef RTE_LIB_SECURITY + " --pdcp-sn-sz N: set PDCP SN size N <5/7/12/15/18>\n" + " --pdcp-domain DOMAIN: set PDCP domain \n" + " --pdcp-ses-hfn-en: enable session based fixed HFN\n" + " --docsis-hdr-sz: set DOCSIS header size\n" +#endif " -h: prints this help\n", progname); } @@ -442,6 +449,22 @@ parse_op_type(struct cperf_options *opts, const char *arg) { cperf_op_type_strs[CPERF_AEAD], CPERF_AEAD + }, + { + cperf_op_type_strs[CPERF_PDCP], + CPERF_PDCP + }, + { + cperf_op_type_strs[CPERF_DOCSIS], + CPERF_DOCSIS + }, + { + cperf_op_type_strs[CPERF_IPSEC], + CPERF_IPSEC + }, + { + cperf_op_type_strs[CPERF_ASYM_MODEX], + CPERF_ASYM_MODEX } }; @@ -491,6 +514,12 @@ parse_test_name(struct cperf_options *opts, { char *test_name = (char *) rte_zmalloc(NULL, sizeof(char) * (strlen(arg) + 3), 0); + if (test_name == NULL) { + RTE_LOG(ERR, USER1, "Failed to rte zmalloc with size: %zu\n", + strlen(arg) + 3); + return -1; + } + snprintf(test_name, strlen(arg) + 3, "[%s]", arg); opts->test_name = test_name; @@ -616,6 +645,82 @@ parse_digest_sz(struct cperf_options *opts, const char *arg) return parse_uint16_t(&opts->digest_sz, arg); } +#ifdef RTE_LIB_SECURITY +static int +parse_pdcp_sn_sz(struct cperf_options *opts, const char *arg) +{ + uint32_t val = 0; + int ret = parse_uint32_t(&val, arg); + + if (ret < 0) + return ret; + + if (val != RTE_SECURITY_PDCP_SN_SIZE_5 && + val != RTE_SECURITY_PDCP_SN_SIZE_7 && + val != RTE_SECURITY_PDCP_SN_SIZE_12 && + val != RTE_SECURITY_PDCP_SN_SIZE_15 && + val != RTE_SECURITY_PDCP_SN_SIZE_18) { + printf("\nInvalid pdcp SN size: %u\n", val); + return -ERANGE; + } + opts->pdcp_sn_sz = val; + + return 0; +} + +const char *cperf_pdcp_domain_strs[] = { + [RTE_SECURITY_PDCP_MODE_CONTROL] = "control", + [RTE_SECURITY_PDCP_MODE_DATA] = "data", + [RTE_SECURITY_PDCP_MODE_SHORT_MAC] = "short_mac" +}; + +static int +parse_pdcp_domain(struct cperf_options *opts, const char *arg) +{ + struct name_id_map pdcp_domain_namemap[] = { + { + cperf_pdcp_domain_strs + [RTE_SECURITY_PDCP_MODE_CONTROL], + RTE_SECURITY_PDCP_MODE_CONTROL }, + { + cperf_pdcp_domain_strs + [RTE_SECURITY_PDCP_MODE_DATA], + RTE_SECURITY_PDCP_MODE_DATA + }, + { + cperf_pdcp_domain_strs + [RTE_SECURITY_PDCP_MODE_SHORT_MAC], + RTE_SECURITY_PDCP_MODE_SHORT_MAC + } + }; + + int id = get_str_key_id_mapping(pdcp_domain_namemap, + RTE_DIM(pdcp_domain_namemap), arg); + if (id < 0) { + RTE_LOG(ERR, USER1, "invalid pdcp domain specified" + "\n"); + return -1; + } + + opts->pdcp_domain = (enum rte_security_pdcp_domain)id; + + return 0; +} + +static int +parse_pdcp_ses_hfn_en(struct cperf_options *opts, const char *arg __rte_unused) +{ + opts->pdcp_ses_hfn_en = 1; + return 0; +} + +static int +parse_docsis_hdr_sz(struct cperf_options *opts, const char *arg) +{ + return parse_uint16_t(&opts->docsis_hdr_sz, arg); +} +#endif + static int parse_auth_iv_sz(struct cperf_options *opts, const char *arg) { @@ -756,6 +861,12 @@ static struct option lgopts[] = { { CPERF_DIGEST_SZ, required_argument, 0, 0 }, +#ifdef RTE_LIB_SECURITY + { CPERF_PDCP_SN_SZ, required_argument, 0, 0 }, + { CPERF_PDCP_DOMAIN, required_argument, 0, 0 }, + { CPERF_PDCP_SES_HFN_EN, no_argument, 0, 0 }, + { CPERF_DOCSIS_HDR_SZ, required_argument, 0, 0 }, +#endif { CPERF_CSV, no_argument, 0, 0}, { CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 }, @@ -822,6 +933,12 @@ cperf_options_default(struct cperf_options *opts) opts->digest_sz = 12; opts->pmdcc_delay = 0; +#ifdef RTE_LIB_SECURITY + opts->pdcp_sn_sz = 12; + opts->pdcp_domain = RTE_SECURITY_PDCP_MODE_CONTROL; + opts->pdcp_ses_hfn_en = 0; + opts->docsis_hdr_sz = 17; +#endif } static int @@ -857,6 +974,12 @@ cperf_opts_parse_long(int opt_idx, struct cperf_options *opts) { CPERF_AEAD_IV_SZ, parse_aead_iv_sz }, { CPERF_AEAD_AAD_SZ, parse_aead_aad_sz }, { CPERF_DIGEST_SZ, parse_digest_sz }, +#ifdef RTE_LIB_SECURITY + { CPERF_PDCP_SN_SZ, parse_pdcp_sn_sz }, + { CPERF_PDCP_DOMAIN, parse_pdcp_domain }, + { CPERF_PDCP_SES_HFN_EN, parse_pdcp_ses_hfn_en }, + { CPERF_DOCSIS_HDR_SZ, parse_docsis_hdr_sz }, +#endif { CPERF_CSV, parse_csv_friendly}, { CPERF_PMDCC_DELAY_MS, parse_pmd_cyclecount_delay_ms}, }; @@ -880,7 +1003,7 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) switch (opt) { case 'h': usage(argv[0]); - rte_exit(EXIT_SUCCESS, "Displayed help\n"); + exit(EXIT_SUCCESS); break; /* long options */ case 0: @@ -958,12 +1081,53 @@ check_cipher_buffer_length(struct cperf_options *options) return 0; } +#ifdef RTE_LIB_SECURITY +static int +check_docsis_buffer_length(struct cperf_options *options) +{ + uint32_t buffer_size, buffer_size_idx = 0; + + 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 < (uint32_t)(options->docsis_hdr_sz + + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)) { + RTE_LOG(ERR, USER1, "Some of the buffer sizes are not " + "valid for DOCSIS\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; +} +#endif + int cperf_options_check(struct cperf_options *options) { - if (options->op_type == CPERF_CIPHER_ONLY) + if (options->op_type == CPERF_CIPHER_ONLY || + options->op_type == CPERF_DOCSIS) options->digest_sz = 0; + if (options->out_of_place && + options->segment_sz <= options->max_buffer_size) { + RTE_LOG(ERR, USER1, "Out of place mode can only work " + "with non segmented buffers\n"); + return -EINVAL; + } + /* * If segment size is not set, assume only one segment, * big enough to contain the largest buffer and the digest @@ -1071,6 +1235,13 @@ cperf_options_check(struct cperf_options *options) return -EINVAL; } +#ifdef RTE_LIB_SECURITY + if (options->op_type == CPERF_DOCSIS) { + if (check_docsis_buffer_length(options) < 0) + return -EINVAL; + } +#endif + return 0; } @@ -1156,4 +1327,11 @@ cperf_options_dump(struct cperf_options *opts) printf("# aead aad size: %u\n", opts->aead_aad_sz); printf("#\n"); } + +#ifdef RTE_LIB_SECURITY + if (opts->op_type == CPERF_DOCSIS) { + printf("# docsis header size: %u\n", opts->docsis_hdr_sz); + printf("#\n"); + } +#endif }