1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Intel Corporation
8 #include <rte_cryptodev.h>
9 #include <rte_malloc.h>
11 #include "cperf_options.h"
13 #define AES_BLOCK_SIZE 16
14 #define DES_BLOCK_SIZE 8
24 printf("%s [EAL options] --\n"
25 " --silent: disable options dump\n"
26 " --ptest throughput / latency / verify / pmd-cycleount :"
28 " --pool_sz N: set the number of crypto ops/mbufs allocated\n"
29 " --total-ops N: set the number of total operations performed\n"
30 " --burst-sz N: set the number of packets per burst\n"
31 " --buffer-sz N: set the size of a single packet\n"
32 " --imix N: set the distribution of packet sizes\n"
33 " --segment-sz N: set the size of the segment to use\n"
34 " --desc-nb N: set number of descriptors for each crypto device\n"
35 " --devtype TYPE: set crypto device type to use\n"
36 " --optype cipher-only / auth-only / cipher-then-auth /\n"
37 " auth-then-cipher / aead : set operation type\n"
38 " --sessionless: enable session-less crypto operations\n"
39 " --out-of-place: enable out-of-place crypto operations\n"
40 " --test-file NAME: set the test vector file path\n"
41 " --test-name NAME: set specific test name section in test file\n"
42 " --cipher-algo ALGO: set cipher algorithm\n"
43 " --cipher-op encrypt / decrypt: set the cipher operation\n"
44 " --cipher-key-sz N: set the cipher key size\n"
45 " --cipher-iv-sz N: set the cipher IV size\n"
46 " --auth-algo ALGO: set auth algorithm\n"
47 " --auth-op generate / verify: set the auth operation\n"
48 " --auth-key-sz N: set the auth key size\n"
49 " --auth-iv-sz N: set the auth IV size\n"
50 " --aead-algo ALGO: set AEAD algorithm\n"
51 " --aead-op encrypt / decrypt: set the AEAD operation\n"
52 " --aead-key-sz N: set the AEAD key size\n"
53 " --aead-iv-sz N: set the AEAD IV size\n"
54 " --aead-aad-sz N: set the AEAD AAD size\n"
55 " --digest-sz N: set the digest size\n"
56 " --pmd-cyclecount-delay-ms N: set delay between enqueue\n"
57 " and dequeue in pmd-cyclecount benchmarking mode\n"
58 " --csv-friendly: enable test result output CSV friendly\n"
59 " -h: prints this help\n",
64 get_str_key_id_mapping(struct name_id_map *map, unsigned int map_len,
69 for (i = 0; i < map_len; i++) {
71 if (strcmp(str_key, map[i].name) == 0)
79 parse_cperf_test_type(struct cperf_options *opts, const char *arg)
81 struct name_id_map cperftest_namemap[] = {
83 cperf_test_type_strs[CPERF_TEST_TYPE_THROUGHPUT],
84 CPERF_TEST_TYPE_THROUGHPUT
87 cperf_test_type_strs[CPERF_TEST_TYPE_VERIFY],
88 CPERF_TEST_TYPE_VERIFY
91 cperf_test_type_strs[CPERF_TEST_TYPE_LATENCY],
92 CPERF_TEST_TYPE_LATENCY
95 cperf_test_type_strs[CPERF_TEST_TYPE_PMDCC],
100 int id = get_str_key_id_mapping(
101 (struct name_id_map *)cperftest_namemap,
102 RTE_DIM(cperftest_namemap), arg);
104 RTE_LOG(ERR, USER1, "failed to parse test type");
108 opts->test = (enum cperf_perf_test_type)id;
114 parse_uint32_t(uint32_t *value, const char *arg)
117 unsigned long n = strtoul(arg, &end, 10);
119 if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0'))
125 *value = (uint32_t) n;
131 parse_uint16_t(uint16_t *value, const char *arg)
134 int ret = parse_uint32_t(&val, arg);
139 if (val > UINT16_MAX)
142 *value = (uint16_t) val;
148 parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
153 char *copy_arg = strdup(arg);
155 if (copy_arg == NULL)
159 token = strtok(copy_arg, ":");
161 /* Parse minimum value */
163 number = strtoul(token, NULL, 10);
165 if (errno == EINVAL || errno == ERANGE ||
173 token = strtok(NULL, ":");
175 /* Parse increment value */
177 number = strtoul(token, NULL, 10);
179 if (errno == EINVAL || errno == ERANGE ||
187 token = strtok(NULL, ":");
189 /* Parse maximum value */
191 number = strtoul(token, NULL, 10);
193 if (errno == EINVAL || errno == ERANGE ||
202 if (strtok(NULL, ":") != NULL)
214 parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max)
222 char *copy_arg = strdup(arg);
224 if (copy_arg == NULL)
228 token = strtok(copy_arg, ",");
230 /* Parse first value */
232 number = strtoul(token, NULL, 10);
234 if (errno == EINVAL || errno == ERANGE ||
238 list[count++] = number;
244 token = strtok(NULL, ",");
246 while (token != NULL) {
247 if (count == MAX_LIST) {
248 RTE_LOG(WARNING, USER1, "Using only the first %u sizes\n",
253 number = strtoul(token, NULL, 10);
255 if (errno == EINVAL || errno == ERANGE ||
259 list[count++] = number;
261 if (number < temp_min)
263 if (number > temp_max)
266 token = strtok(NULL, ",");
283 parse_total_ops(struct cperf_options *opts, const char *arg)
285 int ret = parse_uint32_t(&opts->total_ops, arg);
288 RTE_LOG(ERR, USER1, "failed to parse total operations count\n");
290 if (opts->total_ops == 0) {
292 "invalid total operations count number specified\n");
300 parse_pool_sz(struct cperf_options *opts, const char *arg)
302 int ret = parse_uint32_t(&opts->pool_sz, arg);
305 RTE_LOG(ERR, USER1, "failed to parse pool size");
310 parse_burst_sz(struct cperf_options *opts, const char *arg)
314 /* Try parsing the argument as a range, if it fails, parse it as a list */
315 if (parse_range(arg, &opts->min_burst_size, &opts->max_burst_size,
316 &opts->inc_burst_size) < 0) {
317 ret = parse_list(arg, opts->burst_size_list,
318 &opts->min_burst_size,
319 &opts->max_burst_size);
321 RTE_LOG(ERR, USER1, "failed to parse burst size/s\n");
324 opts->burst_size_count = ret;
331 parse_buffer_sz(struct cperf_options *opts, const char *arg)
335 /* Try parsing the argument as a range, if it fails, parse it as a list */
336 if (parse_range(arg, &opts->min_buffer_size, &opts->max_buffer_size,
337 &opts->inc_buffer_size) < 0) {
338 ret = parse_list(arg, opts->buffer_size_list,
339 &opts->min_buffer_size,
340 &opts->max_buffer_size);
342 RTE_LOG(ERR, USER1, "failed to parse buffer size/s\n");
345 opts->buffer_size_count = ret;
352 parse_segment_sz(struct cperf_options *opts, const char *arg)
354 int ret = parse_uint32_t(&opts->segment_sz, arg);
357 RTE_LOG(ERR, USER1, "failed to parse segment size\n");
361 if (opts->segment_sz == 0) {
362 RTE_LOG(ERR, USER1, "Segment size has to be bigger than 0\n");
370 parse_imix(struct cperf_options *opts, const char *arg)
374 ret = parse_list(arg, opts->imix_distribution_list,
377 RTE_LOG(ERR, USER1, "failed to parse imix distribution\n");
381 opts->imix_distribution_count = ret;
383 if (opts->imix_distribution_count <= 1) {
384 RTE_LOG(ERR, USER1, "imix distribution should have "
385 "at least two entries\n");
393 parse_desc_nb(struct cperf_options *opts, const char *arg)
395 int ret = parse_uint32_t(&opts->nb_descriptors, arg);
398 RTE_LOG(ERR, USER1, "failed to parse descriptors number\n");
402 if (opts->nb_descriptors == 0) {
403 RTE_LOG(ERR, USER1, "invalid descriptors number specified\n");
411 parse_device_type(struct cperf_options *opts, const char *arg)
413 if (strlen(arg) > (sizeof(opts->device_type) - 1))
416 strncpy(opts->device_type, arg, sizeof(opts->device_type) - 1);
417 *(opts->device_type + sizeof(opts->device_type) - 1) = '\0';
423 parse_op_type(struct cperf_options *opts, const char *arg)
425 struct name_id_map optype_namemap[] = {
427 cperf_op_type_strs[CPERF_CIPHER_ONLY],
431 cperf_op_type_strs[CPERF_AUTH_ONLY],
435 cperf_op_type_strs[CPERF_CIPHER_THEN_AUTH],
436 CPERF_CIPHER_THEN_AUTH
439 cperf_op_type_strs[CPERF_AUTH_THEN_CIPHER],
440 CPERF_AUTH_THEN_CIPHER
443 cperf_op_type_strs[CPERF_AEAD],
447 cperf_op_type_strs[CPERF_PDCP],
452 int id = get_str_key_id_mapping(optype_namemap,
453 RTE_DIM(optype_namemap), arg);
455 RTE_LOG(ERR, USER1, "invalid opt type specified\n");
459 opts->op_type = (enum cperf_op_type)id;
465 parse_sessionless(struct cperf_options *opts,
466 const char *arg __rte_unused)
468 opts->sessionless = 1;
473 parse_out_of_place(struct cperf_options *opts,
474 const char *arg __rte_unused)
476 opts->out_of_place = 1;
481 parse_test_file(struct cperf_options *opts,
484 opts->test_file = strdup(arg);
485 if (access(opts->test_file, F_OK) != -1)
487 RTE_LOG(ERR, USER1, "Test vector file doesn't exist\n");
493 parse_test_name(struct cperf_options *opts,
496 char *test_name = (char *) rte_zmalloc(NULL,
497 sizeof(char) * (strlen(arg) + 3), 0);
498 snprintf(test_name, strlen(arg) + 3, "[%s]", arg);
499 opts->test_name = test_name;
505 parse_silent(struct cperf_options *opts,
506 const char *arg __rte_unused)
514 parse_cipher_algo(struct cperf_options *opts, const char *arg)
517 enum rte_crypto_cipher_algorithm cipher_algo;
519 if (rte_cryptodev_get_cipher_algo_enum(&cipher_algo, arg) < 0) {
520 RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
524 opts->cipher_algo = cipher_algo;
530 parse_cipher_op(struct cperf_options *opts, const char *arg)
532 struct name_id_map cipher_op_namemap[] = {
534 rte_crypto_cipher_operation_strings
535 [RTE_CRYPTO_CIPHER_OP_ENCRYPT],
536 RTE_CRYPTO_CIPHER_OP_ENCRYPT },
538 rte_crypto_cipher_operation_strings
539 [RTE_CRYPTO_CIPHER_OP_DECRYPT],
540 RTE_CRYPTO_CIPHER_OP_DECRYPT
544 int id = get_str_key_id_mapping(cipher_op_namemap,
545 RTE_DIM(cipher_op_namemap), arg);
547 RTE_LOG(ERR, USER1, "Invalid cipher operation specified\n");
551 opts->cipher_op = (enum rte_crypto_cipher_operation)id;
557 parse_cipher_key_sz(struct cperf_options *opts, const char *arg)
559 return parse_uint16_t(&opts->cipher_key_sz, arg);
563 parse_cipher_iv_sz(struct cperf_options *opts, const char *arg)
565 return parse_uint16_t(&opts->cipher_iv_sz, arg);
569 parse_auth_algo(struct cperf_options *opts, const char *arg)
571 enum rte_crypto_auth_algorithm auth_algo;
573 if (rte_cryptodev_get_auth_algo_enum(&auth_algo, arg) < 0) {
574 RTE_LOG(ERR, USER1, "Invalid authentication algorithm specified\n");
578 opts->auth_algo = auth_algo;
584 parse_auth_op(struct cperf_options *opts, const char *arg)
586 struct name_id_map auth_op_namemap[] = {
588 rte_crypto_auth_operation_strings
589 [RTE_CRYPTO_AUTH_OP_GENERATE],
590 RTE_CRYPTO_AUTH_OP_GENERATE },
592 rte_crypto_auth_operation_strings
593 [RTE_CRYPTO_AUTH_OP_VERIFY],
594 RTE_CRYPTO_AUTH_OP_VERIFY
598 int id = get_str_key_id_mapping(auth_op_namemap,
599 RTE_DIM(auth_op_namemap), arg);
601 RTE_LOG(ERR, USER1, "invalid authentication operation specified"
606 opts->auth_op = (enum rte_crypto_auth_operation)id;
612 parse_auth_key_sz(struct cperf_options *opts, const char *arg)
614 return parse_uint16_t(&opts->auth_key_sz, arg);
618 parse_digest_sz(struct cperf_options *opts, const char *arg)
620 return parse_uint16_t(&opts->digest_sz, arg);
623 #ifdef RTE_LIBRTE_SECURITY
625 parse_pdcp_sn_sz(struct cperf_options *opts, const char *arg)
628 int ret = parse_uint32_t(&val, arg);
633 if (val != RTE_SECURITY_PDCP_SN_SIZE_5 &&
634 val != RTE_SECURITY_PDCP_SN_SIZE_7 &&
635 val != RTE_SECURITY_PDCP_SN_SIZE_12 &&
636 val != RTE_SECURITY_PDCP_SN_SIZE_15 &&
637 val != RTE_SECURITY_PDCP_SN_SIZE_18) {
638 printf("\nInvalid pdcp SN size: %u\n", val);
641 opts->pdcp_sn_sz = val;
646 const char *cperf_pdcp_domain_strs[] = {
647 [RTE_SECURITY_PDCP_MODE_CONTROL] = "control",
648 [RTE_SECURITY_PDCP_MODE_DATA] = "data"
652 parse_pdcp_domain(struct cperf_options *opts, const char *arg)
654 struct name_id_map pdcp_domain_namemap[] = {
656 cperf_pdcp_domain_strs
657 [RTE_SECURITY_PDCP_MODE_CONTROL],
658 RTE_SECURITY_PDCP_MODE_CONTROL },
660 cperf_pdcp_domain_strs
661 [RTE_SECURITY_PDCP_MODE_DATA],
662 RTE_SECURITY_PDCP_MODE_DATA
666 int id = get_str_key_id_mapping(pdcp_domain_namemap,
667 RTE_DIM(pdcp_domain_namemap), arg);
669 RTE_LOG(ERR, USER1, "invalid pdcp domain specified"
674 opts->pdcp_domain = (enum rte_security_pdcp_domain)id;
681 parse_auth_iv_sz(struct cperf_options *opts, const char *arg)
683 return parse_uint16_t(&opts->auth_iv_sz, arg);
687 parse_aead_algo(struct cperf_options *opts, const char *arg)
689 enum rte_crypto_aead_algorithm aead_algo;
691 if (rte_cryptodev_get_aead_algo_enum(&aead_algo, arg) < 0) {
692 RTE_LOG(ERR, USER1, "Invalid AEAD algorithm specified\n");
696 opts->aead_algo = aead_algo;
702 parse_aead_op(struct cperf_options *opts, const char *arg)
704 struct name_id_map aead_op_namemap[] = {
706 rte_crypto_aead_operation_strings
707 [RTE_CRYPTO_AEAD_OP_ENCRYPT],
708 RTE_CRYPTO_AEAD_OP_ENCRYPT },
710 rte_crypto_aead_operation_strings
711 [RTE_CRYPTO_AEAD_OP_DECRYPT],
712 RTE_CRYPTO_AEAD_OP_DECRYPT
716 int id = get_str_key_id_mapping(aead_op_namemap,
717 RTE_DIM(aead_op_namemap), arg);
719 RTE_LOG(ERR, USER1, "invalid AEAD operation specified"
724 opts->aead_op = (enum rte_crypto_aead_operation)id;
730 parse_aead_key_sz(struct cperf_options *opts, const char *arg)
732 return parse_uint16_t(&opts->aead_key_sz, arg);
736 parse_aead_iv_sz(struct cperf_options *opts, const char *arg)
738 return parse_uint16_t(&opts->aead_iv_sz, arg);
742 parse_aead_aad_sz(struct cperf_options *opts, const char *arg)
744 return parse_uint16_t(&opts->aead_aad_sz, arg);
748 parse_csv_friendly(struct cperf_options *opts, const char *arg __rte_unused)
756 parse_pmd_cyclecount_delay_ms(struct cperf_options *opts,
759 int ret = parse_uint32_t(&opts->pmdcc_delay, arg);
762 RTE_LOG(ERR, USER1, "failed to parse pmd-cyclecount delay\n");
769 typedef int (*option_parser_t)(struct cperf_options *opts,
772 struct long_opt_parser {
773 const char *lgopt_name;
774 option_parser_t parser_fn;
778 static struct option lgopts[] = {
780 { CPERF_PTEST_TYPE, required_argument, 0, 0 },
782 { CPERF_POOL_SIZE, required_argument, 0, 0 },
783 { CPERF_TOTAL_OPS, required_argument, 0, 0 },
784 { CPERF_BURST_SIZE, required_argument, 0, 0 },
785 { CPERF_BUFFER_SIZE, required_argument, 0, 0 },
786 { CPERF_SEGMENT_SIZE, required_argument, 0, 0 },
787 { CPERF_DESC_NB, required_argument, 0, 0 },
789 { CPERF_IMIX, required_argument, 0, 0 },
790 { CPERF_DEVTYPE, required_argument, 0, 0 },
791 { CPERF_OPTYPE, required_argument, 0, 0 },
793 { CPERF_SILENT, no_argument, 0, 0 },
794 { CPERF_SESSIONLESS, no_argument, 0, 0 },
795 { CPERF_OUT_OF_PLACE, no_argument, 0, 0 },
796 { CPERF_TEST_FILE, required_argument, 0, 0 },
797 { CPERF_TEST_NAME, required_argument, 0, 0 },
799 { CPERF_CIPHER_ALGO, required_argument, 0, 0 },
800 { CPERF_CIPHER_OP, required_argument, 0, 0 },
802 { CPERF_CIPHER_KEY_SZ, required_argument, 0, 0 },
803 { CPERF_CIPHER_IV_SZ, required_argument, 0, 0 },
805 { CPERF_AUTH_ALGO, required_argument, 0, 0 },
806 { CPERF_AUTH_OP, required_argument, 0, 0 },
808 { CPERF_AUTH_KEY_SZ, required_argument, 0, 0 },
809 { CPERF_AUTH_IV_SZ, required_argument, 0, 0 },
811 { CPERF_AEAD_ALGO, required_argument, 0, 0 },
812 { CPERF_AEAD_OP, required_argument, 0, 0 },
814 { CPERF_AEAD_KEY_SZ, required_argument, 0, 0 },
815 { CPERF_AEAD_AAD_SZ, required_argument, 0, 0 },
816 { CPERF_AEAD_IV_SZ, required_argument, 0, 0 },
818 { CPERF_DIGEST_SZ, required_argument, 0, 0 },
820 #ifdef RTE_LIBRTE_SECURITY
821 { CPERF_PDCP_SN_SZ, required_argument, 0, 0 },
822 { CPERF_PDCP_DOMAIN, required_argument, 0, 0 },
824 { CPERF_CSV, no_argument, 0, 0},
826 { CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 },
832 cperf_options_default(struct cperf_options *opts)
834 opts->test = CPERF_TEST_TYPE_THROUGHPUT;
836 opts->pool_sz = 8192;
837 opts->total_ops = 10000000;
838 opts->nb_descriptors = 2048;
840 opts->buffer_size_list[0] = 64;
841 opts->buffer_size_count = 1;
842 opts->max_buffer_size = 64;
843 opts->min_buffer_size = 64;
844 opts->inc_buffer_size = 0;
846 opts->burst_size_list[0] = 32;
847 opts->burst_size_count = 1;
848 opts->max_burst_size = 32;
849 opts->min_burst_size = 32;
850 opts->inc_burst_size = 0;
853 * Will be parsed from command line or set to
854 * maximum buffer size + digest, later
856 opts->segment_sz = 0;
858 opts->imix_distribution_count = 0;
859 strncpy(opts->device_type, "crypto_aesni_mb",
860 sizeof(opts->device_type));
863 opts->op_type = CPERF_CIPHER_THEN_AUTH;
866 opts->test_file = NULL;
867 opts->test_name = NULL;
868 opts->sessionless = 0;
869 opts->out_of_place = 0;
872 opts->cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC;
873 opts->cipher_op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
874 opts->cipher_key_sz = 16;
875 opts->cipher_iv_sz = 16;
877 opts->auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
878 opts->auth_op = RTE_CRYPTO_AUTH_OP_GENERATE;
880 opts->auth_key_sz = 64;
881 opts->auth_iv_sz = 0;
883 opts->aead_key_sz = 0;
884 opts->aead_iv_sz = 0;
885 opts->aead_aad_sz = 0;
887 opts->digest_sz = 12;
889 opts->pmdcc_delay = 0;
890 #ifdef RTE_LIBRTE_SECURITY
891 opts->pdcp_sn_sz = 12;
892 opts->pdcp_domain = RTE_SECURITY_PDCP_MODE_CONTROL;
897 cperf_opts_parse_long(int opt_idx, struct cperf_options *opts)
899 struct long_opt_parser parsermap[] = {
900 { CPERF_PTEST_TYPE, parse_cperf_test_type },
901 { CPERF_SILENT, parse_silent },
902 { CPERF_POOL_SIZE, parse_pool_sz },
903 { CPERF_TOTAL_OPS, parse_total_ops },
904 { CPERF_BURST_SIZE, parse_burst_sz },
905 { CPERF_BUFFER_SIZE, parse_buffer_sz },
906 { CPERF_SEGMENT_SIZE, parse_segment_sz },
907 { CPERF_DESC_NB, parse_desc_nb },
908 { CPERF_DEVTYPE, parse_device_type },
909 { CPERF_OPTYPE, parse_op_type },
910 { CPERF_SESSIONLESS, parse_sessionless },
911 { CPERF_OUT_OF_PLACE, parse_out_of_place },
912 { CPERF_IMIX, parse_imix },
913 { CPERF_TEST_FILE, parse_test_file },
914 { CPERF_TEST_NAME, parse_test_name },
915 { CPERF_CIPHER_ALGO, parse_cipher_algo },
916 { CPERF_CIPHER_OP, parse_cipher_op },
917 { CPERF_CIPHER_KEY_SZ, parse_cipher_key_sz },
918 { CPERF_CIPHER_IV_SZ, parse_cipher_iv_sz },
919 { CPERF_AUTH_ALGO, parse_auth_algo },
920 { CPERF_AUTH_OP, parse_auth_op },
921 { CPERF_AUTH_KEY_SZ, parse_auth_key_sz },
922 { CPERF_AUTH_IV_SZ, parse_auth_iv_sz },
923 { CPERF_AEAD_ALGO, parse_aead_algo },
924 { CPERF_AEAD_OP, parse_aead_op },
925 { CPERF_AEAD_KEY_SZ, parse_aead_key_sz },
926 { CPERF_AEAD_IV_SZ, parse_aead_iv_sz },
927 { CPERF_AEAD_AAD_SZ, parse_aead_aad_sz },
928 { CPERF_DIGEST_SZ, parse_digest_sz },
929 #ifdef RTE_LIBRTE_SECURITY
930 { CPERF_PDCP_SN_SZ, parse_pdcp_sn_sz },
931 { CPERF_PDCP_DOMAIN, parse_pdcp_domain },
933 { CPERF_CSV, parse_csv_friendly},
934 { CPERF_PMDCC_DELAY_MS, parse_pmd_cyclecount_delay_ms},
938 for (i = 0; i < RTE_DIM(parsermap); i++) {
939 if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name,
940 strlen(lgopts[opt_idx].name)) == 0)
941 return parsermap[i].parser_fn(opts, optarg);
948 cperf_options_parse(struct cperf_options *options, int argc, char **argv)
950 int opt, retval, opt_idx;
952 while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) {
956 rte_exit(EXIT_SUCCESS, "Displayed help\n");
960 retval = cperf_opts_parse_long(opt_idx, options);
976 check_cipher_buffer_length(struct cperf_options *options)
978 uint32_t buffer_size, buffer_size_idx = 0;
980 if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC ||
981 options->cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) {
982 if (options->inc_buffer_size != 0)
983 buffer_size = options->min_buffer_size;
985 buffer_size = options->buffer_size_list[0];
987 while (buffer_size <= options->max_buffer_size) {
988 if ((buffer_size % AES_BLOCK_SIZE) != 0) {
989 RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
990 "not suitable for the algorithm selected\n");
994 if (options->inc_buffer_size != 0)
995 buffer_size += options->inc_buffer_size;
997 if (++buffer_size_idx == options->buffer_size_count)
999 buffer_size = options->buffer_size_list[buffer_size_idx];
1005 if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC ||
1006 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC ||
1007 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) {
1008 if (options->inc_buffer_size != 0)
1009 buffer_size = options->min_buffer_size;
1011 buffer_size = options->buffer_size_list[0];
1013 while (buffer_size <= options->max_buffer_size) {
1014 if ((buffer_size % DES_BLOCK_SIZE) != 0) {
1015 RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
1016 "not suitable for the algorithm selected\n");
1020 if (options->inc_buffer_size != 0)
1021 buffer_size += options->inc_buffer_size;
1023 if (++buffer_size_idx == options->buffer_size_count)
1025 buffer_size = options->buffer_size_list[buffer_size_idx];
1035 cperf_options_check(struct cperf_options *options)
1037 if (options->op_type == CPERF_CIPHER_ONLY)
1038 options->digest_sz = 0;
1040 if (options->out_of_place &&
1041 options->segment_sz <= options->max_buffer_size) {
1042 RTE_LOG(ERR, USER1, "Out of place mode can only work "
1043 "with non segmented buffers\n");
1048 * If segment size is not set, assume only one segment,
1049 * big enough to contain the largest buffer and the digest
1051 if (options->segment_sz == 0)
1052 options->segment_sz = options->max_buffer_size +
1055 if (options->segment_sz < options->digest_sz) {
1057 "Segment size should be at least "
1058 "the size of the digest\n");
1062 if ((options->imix_distribution_count != 0) &&
1063 (options->imix_distribution_count !=
1064 options->buffer_size_count)) {
1065 RTE_LOG(ERR, USER1, "IMIX distribution must have the same "
1066 "number of buffer sizes\n");
1070 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1071 options->test_file == NULL) {
1072 RTE_LOG(ERR, USER1, "Define path to the file with test"
1077 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1078 options->op_type != CPERF_CIPHER_ONLY &&
1079 options->test_name == NULL) {
1080 RTE_LOG(ERR, USER1, "Define test name to get the correct digest"
1081 " from the test vectors.\n");
1085 if (options->test_name != NULL && options->test_file == NULL) {
1086 RTE_LOG(ERR, USER1, "Define path to the file with test"
1091 if (options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY &&
1092 options->test_file == NULL) {
1093 RTE_LOG(ERR, USER1, "Define path to the file with test"
1098 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1099 (options->inc_buffer_size != 0 ||
1100 options->buffer_size_count > 1)) {
1101 RTE_LOG(ERR, USER1, "Only one buffer size is allowed when "
1102 "using the verify test.\n");
1106 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1107 (options->inc_burst_size != 0 ||
1108 options->burst_size_count > 1)) {
1109 RTE_LOG(ERR, USER1, "Only one burst size is allowed when "
1110 "using the verify test.\n");
1114 if (options->test == CPERF_TEST_TYPE_PMDCC &&
1115 options->pool_sz < options->nb_descriptors) {
1116 RTE_LOG(ERR, USER1, "For pmd cyclecount benchmarks, pool size "
1117 "must be equal or greater than the number of "
1118 "cryptodev descriptors.\n");
1122 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1123 options->imix_distribution_count > 0) {
1124 RTE_LOG(ERR, USER1, "IMIX is not allowed when "
1125 "using the verify test.\n");
1129 if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
1130 if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
1132 RTE_CRYPTO_AUTH_OP_GENERATE) {
1133 RTE_LOG(ERR, USER1, "Option cipher then auth must use"
1134 " options: encrypt and generate.\n");
1137 } else if (options->op_type == CPERF_AUTH_THEN_CIPHER) {
1138 if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_DECRYPT &&
1140 RTE_CRYPTO_AUTH_OP_VERIFY) {
1141 RTE_LOG(ERR, USER1, "Option auth then cipher must use"
1142 " options: decrypt and verify.\n");
1147 if (options->op_type == CPERF_CIPHER_ONLY ||
1148 options->op_type == CPERF_CIPHER_THEN_AUTH ||
1149 options->op_type == CPERF_AUTH_THEN_CIPHER) {
1150 if (check_cipher_buffer_length(options) < 0)
1158 cperf_options_dump(struct cperf_options *opts)
1162 printf("# Crypto Performance Application Options:\n");
1164 printf("# cperf test: %s\n", cperf_test_type_strs[opts->test]);
1166 printf("# size of crypto op / mbuf pool: %u\n", opts->pool_sz);
1167 printf("# total number of ops: %u\n", opts->total_ops);
1168 if (opts->inc_buffer_size != 0) {
1169 printf("# buffer size:\n");
1170 printf("#\t min: %u\n", opts->min_buffer_size);
1171 printf("#\t max: %u\n", opts->max_buffer_size);
1172 printf("#\t inc: %u\n", opts->inc_buffer_size);
1174 printf("# buffer sizes: ");
1175 for (size_idx = 0; size_idx < opts->buffer_size_count; size_idx++)
1176 printf("%u ", opts->buffer_size_list[size_idx]);
1179 if (opts->inc_burst_size != 0) {
1180 printf("# burst size:\n");
1181 printf("#\t min: %u\n", opts->min_burst_size);
1182 printf("#\t max: %u\n", opts->max_burst_size);
1183 printf("#\t inc: %u\n", opts->inc_burst_size);
1185 printf("# burst sizes: ");
1186 for (size_idx = 0; size_idx < opts->burst_size_count; size_idx++)
1187 printf("%u ", opts->burst_size_list[size_idx]);
1190 printf("\n# segment size: %u\n", opts->segment_sz);
1192 printf("# cryptodev type: %s\n", opts->device_type);
1194 printf("# number of queue pairs per device: %u\n", opts->nb_qps);
1195 printf("# crypto operation: %s\n", cperf_op_type_strs[opts->op_type]);
1196 printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");
1197 printf("# out of place: %s\n", opts->out_of_place ? "yes" : "no");
1198 if (opts->test == CPERF_TEST_TYPE_PMDCC)
1199 printf("# inter-burst delay: %u ms\n", opts->pmdcc_delay);
1203 if (opts->op_type == CPERF_AUTH_ONLY ||
1204 opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1205 opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1206 printf("# auth algorithm: %s\n",
1207 rte_crypto_auth_algorithm_strings[opts->auth_algo]);
1208 printf("# auth operation: %s\n",
1209 rte_crypto_auth_operation_strings[opts->auth_op]);
1210 printf("# auth key size: %u\n", opts->auth_key_sz);
1211 printf("# auth iv size: %u\n", opts->auth_iv_sz);
1212 printf("# auth digest size: %u\n", opts->digest_sz);
1216 if (opts->op_type == CPERF_CIPHER_ONLY ||
1217 opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1218 opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1219 printf("# cipher algorithm: %s\n",
1220 rte_crypto_cipher_algorithm_strings[opts->cipher_algo]);
1221 printf("# cipher operation: %s\n",
1222 rte_crypto_cipher_operation_strings[opts->cipher_op]);
1223 printf("# cipher key size: %u\n", opts->cipher_key_sz);
1224 printf("# cipher iv size: %u\n", opts->cipher_iv_sz);
1228 if (opts->op_type == CPERF_AEAD) {
1229 printf("# aead algorithm: %s\n",
1230 rte_crypto_aead_algorithm_strings[opts->aead_algo]);
1231 printf("# aead operation: %s\n",
1232 rte_crypto_aead_operation_strings[opts->aead_op]);
1233 printf("# aead key size: %u\n", opts->aead_key_sz);
1234 printf("# aead iv size: %u\n", opts->aead_iv_sz);
1235 printf("# aead digest size: %u\n", opts->digest_sz);
1236 printf("# aead aad size: %u\n", opts->aead_aad_sz);