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],
448 int id = get_str_key_id_mapping(optype_namemap,
449 RTE_DIM(optype_namemap), arg);
451 RTE_LOG(ERR, USER1, "invalid opt type specified\n");
455 opts->op_type = (enum cperf_op_type)id;
461 parse_sessionless(struct cperf_options *opts,
462 const char *arg __rte_unused)
464 opts->sessionless = 1;
469 parse_out_of_place(struct cperf_options *opts,
470 const char *arg __rte_unused)
472 opts->out_of_place = 1;
477 parse_test_file(struct cperf_options *opts,
480 opts->test_file = strdup(arg);
481 if (access(opts->test_file, F_OK) != -1)
483 RTE_LOG(ERR, USER1, "Test vector file doesn't exist\n");
489 parse_test_name(struct cperf_options *opts,
492 char *test_name = (char *) rte_zmalloc(NULL,
493 sizeof(char) * (strlen(arg) + 3), 0);
494 snprintf(test_name, strlen(arg) + 3, "[%s]", arg);
495 opts->test_name = test_name;
501 parse_silent(struct cperf_options *opts,
502 const char *arg __rte_unused)
510 parse_cipher_algo(struct cperf_options *opts, const char *arg)
513 enum rte_crypto_cipher_algorithm cipher_algo;
515 if (rte_cryptodev_get_cipher_algo_enum(&cipher_algo, arg) < 0) {
516 RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
520 opts->cipher_algo = cipher_algo;
526 parse_cipher_op(struct cperf_options *opts, const char *arg)
528 struct name_id_map cipher_op_namemap[] = {
530 rte_crypto_cipher_operation_strings
531 [RTE_CRYPTO_CIPHER_OP_ENCRYPT],
532 RTE_CRYPTO_CIPHER_OP_ENCRYPT },
534 rte_crypto_cipher_operation_strings
535 [RTE_CRYPTO_CIPHER_OP_DECRYPT],
536 RTE_CRYPTO_CIPHER_OP_DECRYPT
540 int id = get_str_key_id_mapping(cipher_op_namemap,
541 RTE_DIM(cipher_op_namemap), arg);
543 RTE_LOG(ERR, USER1, "Invalid cipher operation specified\n");
547 opts->cipher_op = (enum rte_crypto_cipher_operation)id;
553 parse_cipher_key_sz(struct cperf_options *opts, const char *arg)
555 return parse_uint16_t(&opts->cipher_key_sz, arg);
559 parse_cipher_iv_sz(struct cperf_options *opts, const char *arg)
561 return parse_uint16_t(&opts->cipher_iv_sz, arg);
565 parse_auth_algo(struct cperf_options *opts, const char *arg)
567 enum rte_crypto_auth_algorithm auth_algo;
569 if (rte_cryptodev_get_auth_algo_enum(&auth_algo, arg) < 0) {
570 RTE_LOG(ERR, USER1, "Invalid authentication algorithm specified\n");
574 opts->auth_algo = auth_algo;
580 parse_auth_op(struct cperf_options *opts, const char *arg)
582 struct name_id_map auth_op_namemap[] = {
584 rte_crypto_auth_operation_strings
585 [RTE_CRYPTO_AUTH_OP_GENERATE],
586 RTE_CRYPTO_AUTH_OP_GENERATE },
588 rte_crypto_auth_operation_strings
589 [RTE_CRYPTO_AUTH_OP_VERIFY],
590 RTE_CRYPTO_AUTH_OP_VERIFY
594 int id = get_str_key_id_mapping(auth_op_namemap,
595 RTE_DIM(auth_op_namemap), arg);
597 RTE_LOG(ERR, USER1, "invalid authentication operation specified"
602 opts->auth_op = (enum rte_crypto_auth_operation)id;
608 parse_auth_key_sz(struct cperf_options *opts, const char *arg)
610 return parse_uint16_t(&opts->auth_key_sz, arg);
614 parse_digest_sz(struct cperf_options *opts, const char *arg)
616 return parse_uint16_t(&opts->digest_sz, arg);
620 parse_auth_iv_sz(struct cperf_options *opts, const char *arg)
622 return parse_uint16_t(&opts->auth_iv_sz, arg);
626 parse_aead_algo(struct cperf_options *opts, const char *arg)
628 enum rte_crypto_aead_algorithm aead_algo;
630 if (rte_cryptodev_get_aead_algo_enum(&aead_algo, arg) < 0) {
631 RTE_LOG(ERR, USER1, "Invalid AEAD algorithm specified\n");
635 opts->aead_algo = aead_algo;
641 parse_aead_op(struct cperf_options *opts, const char *arg)
643 struct name_id_map aead_op_namemap[] = {
645 rte_crypto_aead_operation_strings
646 [RTE_CRYPTO_AEAD_OP_ENCRYPT],
647 RTE_CRYPTO_AEAD_OP_ENCRYPT },
649 rte_crypto_aead_operation_strings
650 [RTE_CRYPTO_AEAD_OP_DECRYPT],
651 RTE_CRYPTO_AEAD_OP_DECRYPT
655 int id = get_str_key_id_mapping(aead_op_namemap,
656 RTE_DIM(aead_op_namemap), arg);
658 RTE_LOG(ERR, USER1, "invalid AEAD operation specified"
663 opts->aead_op = (enum rte_crypto_aead_operation)id;
669 parse_aead_key_sz(struct cperf_options *opts, const char *arg)
671 return parse_uint16_t(&opts->aead_key_sz, arg);
675 parse_aead_iv_sz(struct cperf_options *opts, const char *arg)
677 return parse_uint16_t(&opts->aead_iv_sz, arg);
681 parse_aead_aad_sz(struct cperf_options *opts, const char *arg)
683 return parse_uint16_t(&opts->aead_aad_sz, arg);
687 parse_csv_friendly(struct cperf_options *opts, const char *arg __rte_unused)
695 parse_pmd_cyclecount_delay_ms(struct cperf_options *opts,
698 int ret = parse_uint32_t(&opts->pmdcc_delay, arg);
701 RTE_LOG(ERR, USER1, "failed to parse pmd-cyclecount delay\n");
708 typedef int (*option_parser_t)(struct cperf_options *opts,
711 struct long_opt_parser {
712 const char *lgopt_name;
713 option_parser_t parser_fn;
717 static struct option lgopts[] = {
719 { CPERF_PTEST_TYPE, required_argument, 0, 0 },
721 { CPERF_POOL_SIZE, required_argument, 0, 0 },
722 { CPERF_TOTAL_OPS, required_argument, 0, 0 },
723 { CPERF_BURST_SIZE, required_argument, 0, 0 },
724 { CPERF_BUFFER_SIZE, required_argument, 0, 0 },
725 { CPERF_SEGMENT_SIZE, required_argument, 0, 0 },
726 { CPERF_DESC_NB, required_argument, 0, 0 },
728 { CPERF_IMIX, required_argument, 0, 0 },
729 { CPERF_DEVTYPE, required_argument, 0, 0 },
730 { CPERF_OPTYPE, required_argument, 0, 0 },
732 { CPERF_SILENT, no_argument, 0, 0 },
733 { CPERF_SESSIONLESS, no_argument, 0, 0 },
734 { CPERF_OUT_OF_PLACE, no_argument, 0, 0 },
735 { CPERF_TEST_FILE, required_argument, 0, 0 },
736 { CPERF_TEST_NAME, required_argument, 0, 0 },
738 { CPERF_CIPHER_ALGO, required_argument, 0, 0 },
739 { CPERF_CIPHER_OP, required_argument, 0, 0 },
741 { CPERF_CIPHER_KEY_SZ, required_argument, 0, 0 },
742 { CPERF_CIPHER_IV_SZ, required_argument, 0, 0 },
744 { CPERF_AUTH_ALGO, required_argument, 0, 0 },
745 { CPERF_AUTH_OP, required_argument, 0, 0 },
747 { CPERF_AUTH_KEY_SZ, required_argument, 0, 0 },
748 { CPERF_AUTH_IV_SZ, required_argument, 0, 0 },
750 { CPERF_AEAD_ALGO, required_argument, 0, 0 },
751 { CPERF_AEAD_OP, required_argument, 0, 0 },
753 { CPERF_AEAD_KEY_SZ, required_argument, 0, 0 },
754 { CPERF_AEAD_AAD_SZ, required_argument, 0, 0 },
755 { CPERF_AEAD_IV_SZ, required_argument, 0, 0 },
757 { CPERF_DIGEST_SZ, required_argument, 0, 0 },
759 { CPERF_CSV, no_argument, 0, 0},
761 { CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 },
767 cperf_options_default(struct cperf_options *opts)
769 opts->test = CPERF_TEST_TYPE_THROUGHPUT;
771 opts->pool_sz = 8192;
772 opts->total_ops = 10000000;
773 opts->nb_descriptors = 2048;
775 opts->buffer_size_list[0] = 64;
776 opts->buffer_size_count = 1;
777 opts->max_buffer_size = 64;
778 opts->min_buffer_size = 64;
779 opts->inc_buffer_size = 0;
781 opts->burst_size_list[0] = 32;
782 opts->burst_size_count = 1;
783 opts->max_burst_size = 32;
784 opts->min_burst_size = 32;
785 opts->inc_burst_size = 0;
788 * Will be parsed from command line or set to
789 * maximum buffer size + digest, later
791 opts->segment_sz = 0;
793 opts->imix_distribution_count = 0;
794 strncpy(opts->device_type, "crypto_aesni_mb",
795 sizeof(opts->device_type));
798 opts->op_type = CPERF_CIPHER_THEN_AUTH;
801 opts->test_file = NULL;
802 opts->test_name = NULL;
803 opts->sessionless = 0;
804 opts->out_of_place = 0;
807 opts->cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC;
808 opts->cipher_op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
809 opts->cipher_key_sz = 16;
810 opts->cipher_iv_sz = 16;
812 opts->auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
813 opts->auth_op = RTE_CRYPTO_AUTH_OP_GENERATE;
815 opts->auth_key_sz = 64;
816 opts->auth_iv_sz = 0;
818 opts->aead_key_sz = 0;
819 opts->aead_iv_sz = 0;
820 opts->aead_aad_sz = 0;
822 opts->digest_sz = 12;
824 opts->pmdcc_delay = 0;
828 cperf_opts_parse_long(int opt_idx, struct cperf_options *opts)
830 struct long_opt_parser parsermap[] = {
831 { CPERF_PTEST_TYPE, parse_cperf_test_type },
832 { CPERF_SILENT, parse_silent },
833 { CPERF_POOL_SIZE, parse_pool_sz },
834 { CPERF_TOTAL_OPS, parse_total_ops },
835 { CPERF_BURST_SIZE, parse_burst_sz },
836 { CPERF_BUFFER_SIZE, parse_buffer_sz },
837 { CPERF_SEGMENT_SIZE, parse_segment_sz },
838 { CPERF_DESC_NB, parse_desc_nb },
839 { CPERF_DEVTYPE, parse_device_type },
840 { CPERF_OPTYPE, parse_op_type },
841 { CPERF_SESSIONLESS, parse_sessionless },
842 { CPERF_OUT_OF_PLACE, parse_out_of_place },
843 { CPERF_IMIX, parse_imix },
844 { CPERF_TEST_FILE, parse_test_file },
845 { CPERF_TEST_NAME, parse_test_name },
846 { CPERF_CIPHER_ALGO, parse_cipher_algo },
847 { CPERF_CIPHER_OP, parse_cipher_op },
848 { CPERF_CIPHER_KEY_SZ, parse_cipher_key_sz },
849 { CPERF_CIPHER_IV_SZ, parse_cipher_iv_sz },
850 { CPERF_AUTH_ALGO, parse_auth_algo },
851 { CPERF_AUTH_OP, parse_auth_op },
852 { CPERF_AUTH_KEY_SZ, parse_auth_key_sz },
853 { CPERF_AUTH_IV_SZ, parse_auth_iv_sz },
854 { CPERF_AEAD_ALGO, parse_aead_algo },
855 { CPERF_AEAD_OP, parse_aead_op },
856 { CPERF_AEAD_KEY_SZ, parse_aead_key_sz },
857 { CPERF_AEAD_IV_SZ, parse_aead_iv_sz },
858 { CPERF_AEAD_AAD_SZ, parse_aead_aad_sz },
859 { CPERF_DIGEST_SZ, parse_digest_sz },
860 { CPERF_CSV, parse_csv_friendly},
861 { CPERF_PMDCC_DELAY_MS, parse_pmd_cyclecount_delay_ms},
865 for (i = 0; i < RTE_DIM(parsermap); i++) {
866 if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name,
867 strlen(lgopts[opt_idx].name)) == 0)
868 return parsermap[i].parser_fn(opts, optarg);
875 cperf_options_parse(struct cperf_options *options, int argc, char **argv)
877 int opt, retval, opt_idx;
879 while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) {
883 rte_exit(EXIT_SUCCESS, "Displayed help\n");
887 retval = cperf_opts_parse_long(opt_idx, options);
903 check_cipher_buffer_length(struct cperf_options *options)
905 uint32_t buffer_size, buffer_size_idx = 0;
907 if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC ||
908 options->cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) {
909 if (options->inc_buffer_size != 0)
910 buffer_size = options->min_buffer_size;
912 buffer_size = options->buffer_size_list[0];
914 while (buffer_size <= options->max_buffer_size) {
915 if ((buffer_size % AES_BLOCK_SIZE) != 0) {
916 RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
917 "not suitable for the algorithm selected\n");
921 if (options->inc_buffer_size != 0)
922 buffer_size += options->inc_buffer_size;
924 if (++buffer_size_idx == options->buffer_size_count)
926 buffer_size = options->buffer_size_list[buffer_size_idx];
932 if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC ||
933 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC ||
934 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) {
935 if (options->inc_buffer_size != 0)
936 buffer_size = options->min_buffer_size;
938 buffer_size = options->buffer_size_list[0];
940 while (buffer_size <= options->max_buffer_size) {
941 if ((buffer_size % DES_BLOCK_SIZE) != 0) {
942 RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
943 "not suitable for the algorithm selected\n");
947 if (options->inc_buffer_size != 0)
948 buffer_size += options->inc_buffer_size;
950 if (++buffer_size_idx == options->buffer_size_count)
952 buffer_size = options->buffer_size_list[buffer_size_idx];
962 cperf_options_check(struct cperf_options *options)
964 if (options->op_type == CPERF_CIPHER_ONLY)
965 options->digest_sz = 0;
967 if (options->out_of_place &&
968 options->segment_sz <= options->max_buffer_size) {
969 RTE_LOG(ERR, USER1, "Out of place mode can only work "
970 "with non segmented buffers\n");
975 * If segment size is not set, assume only one segment,
976 * big enough to contain the largest buffer and the digest
978 if (options->segment_sz == 0)
979 options->segment_sz = options->max_buffer_size +
982 if (options->segment_sz < options->digest_sz) {
984 "Segment size should be at least "
985 "the size of the digest\n");
989 if ((options->imix_distribution_count != 0) &&
990 (options->imix_distribution_count !=
991 options->buffer_size_count)) {
992 RTE_LOG(ERR, USER1, "IMIX distribution must have the same "
993 "number of buffer sizes\n");
997 if (options->test == CPERF_TEST_TYPE_VERIFY &&
998 options->test_file == NULL) {
999 RTE_LOG(ERR, USER1, "Define path to the file with test"
1004 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1005 options->op_type != CPERF_CIPHER_ONLY &&
1006 options->test_name == NULL) {
1007 RTE_LOG(ERR, USER1, "Define test name to get the correct digest"
1008 " from the test vectors.\n");
1012 if (options->test_name != NULL && options->test_file == NULL) {
1013 RTE_LOG(ERR, USER1, "Define path to the file with test"
1018 if (options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY &&
1019 options->test_file == NULL) {
1020 RTE_LOG(ERR, USER1, "Define path to the file with test"
1025 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1026 (options->inc_buffer_size != 0 ||
1027 options->buffer_size_count > 1)) {
1028 RTE_LOG(ERR, USER1, "Only one buffer size is allowed when "
1029 "using the verify test.\n");
1033 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1034 (options->inc_burst_size != 0 ||
1035 options->burst_size_count > 1)) {
1036 RTE_LOG(ERR, USER1, "Only one burst size is allowed when "
1037 "using the verify test.\n");
1041 if (options->test == CPERF_TEST_TYPE_PMDCC &&
1042 options->pool_sz < options->nb_descriptors) {
1043 RTE_LOG(ERR, USER1, "For pmd cyclecount benchmarks, pool size "
1044 "must be equal or greater than the number of "
1045 "cryptodev descriptors.\n");
1049 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1050 options->imix_distribution_count > 0) {
1051 RTE_LOG(ERR, USER1, "IMIX is not allowed when "
1052 "using the verify test.\n");
1056 if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
1057 if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
1059 RTE_CRYPTO_AUTH_OP_GENERATE) {
1060 RTE_LOG(ERR, USER1, "Option cipher then auth must use"
1061 " options: encrypt and generate.\n");
1064 } else if (options->op_type == CPERF_AUTH_THEN_CIPHER) {
1065 if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_DECRYPT &&
1067 RTE_CRYPTO_AUTH_OP_VERIFY) {
1068 RTE_LOG(ERR, USER1, "Option auth then cipher must use"
1069 " options: decrypt and verify.\n");
1074 if (options->op_type == CPERF_CIPHER_ONLY ||
1075 options->op_type == CPERF_CIPHER_THEN_AUTH ||
1076 options->op_type == CPERF_AUTH_THEN_CIPHER) {
1077 if (check_cipher_buffer_length(options) < 0)
1085 cperf_options_dump(struct cperf_options *opts)
1089 printf("# Crypto Performance Application Options:\n");
1091 printf("# cperf test: %s\n", cperf_test_type_strs[opts->test]);
1093 printf("# size of crypto op / mbuf pool: %u\n", opts->pool_sz);
1094 printf("# total number of ops: %u\n", opts->total_ops);
1095 if (opts->inc_buffer_size != 0) {
1096 printf("# buffer size:\n");
1097 printf("#\t min: %u\n", opts->min_buffer_size);
1098 printf("#\t max: %u\n", opts->max_buffer_size);
1099 printf("#\t inc: %u\n", opts->inc_buffer_size);
1101 printf("# buffer sizes: ");
1102 for (size_idx = 0; size_idx < opts->buffer_size_count; size_idx++)
1103 printf("%u ", opts->buffer_size_list[size_idx]);
1106 if (opts->inc_burst_size != 0) {
1107 printf("# burst size:\n");
1108 printf("#\t min: %u\n", opts->min_burst_size);
1109 printf("#\t max: %u\n", opts->max_burst_size);
1110 printf("#\t inc: %u\n", opts->inc_burst_size);
1112 printf("# burst sizes: ");
1113 for (size_idx = 0; size_idx < opts->burst_size_count; size_idx++)
1114 printf("%u ", opts->burst_size_list[size_idx]);
1117 printf("\n# segment size: %u\n", opts->segment_sz);
1119 printf("# cryptodev type: %s\n", opts->device_type);
1121 printf("# number of queue pairs per device: %u\n", opts->nb_qps);
1122 printf("# crypto operation: %s\n", cperf_op_type_strs[opts->op_type]);
1123 printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");
1124 printf("# out of place: %s\n", opts->out_of_place ? "yes" : "no");
1125 if (opts->test == CPERF_TEST_TYPE_PMDCC)
1126 printf("# inter-burst delay: %u ms\n", opts->pmdcc_delay);
1130 if (opts->op_type == CPERF_AUTH_ONLY ||
1131 opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1132 opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1133 printf("# auth algorithm: %s\n",
1134 rte_crypto_auth_algorithm_strings[opts->auth_algo]);
1135 printf("# auth operation: %s\n",
1136 rte_crypto_auth_operation_strings[opts->auth_op]);
1137 printf("# auth key size: %u\n", opts->auth_key_sz);
1138 printf("# auth iv size: %u\n", opts->auth_iv_sz);
1139 printf("# auth digest size: %u\n", opts->digest_sz);
1143 if (opts->op_type == CPERF_CIPHER_ONLY ||
1144 opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1145 opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1146 printf("# cipher algorithm: %s\n",
1147 rte_crypto_cipher_algorithm_strings[opts->cipher_algo]);
1148 printf("# cipher operation: %s\n",
1149 rte_crypto_cipher_operation_strings[opts->cipher_op]);
1150 printf("# cipher key size: %u\n", opts->cipher_key_sz);
1151 printf("# cipher iv size: %u\n", opts->cipher_iv_sz);
1155 if (opts->op_type == CPERF_AEAD) {
1156 printf("# aead algorithm: %s\n",
1157 rte_crypto_aead_algorithm_strings[opts->aead_algo]);
1158 printf("# aead operation: %s\n",
1159 rte_crypto_aead_operation_strings[opts->aead_op]);
1160 printf("# aead key size: %u\n", opts->aead_key_sz);
1161 printf("# aead iv size: %u\n", opts->aead_iv_sz);
1162 printf("# aead digest size: %u\n", opts->digest_sz);
1163 printf("# aead aad size: %u\n", opts->aead_aad_sz);