4 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <rte_cryptodev.h>
37 #include <rte_malloc.h>
39 #include "cperf_options.h"
41 #define AES_BLOCK_SIZE 16
42 #define DES_BLOCK_SIZE 8
52 printf("%s [EAL options] --\n"
53 " --silent: disable options dump\n"
54 " --ptest throughput / latency / verify / pmd-cycleount :"
56 " --pool_sz N: set the number of crypto ops/mbufs allocated\n"
57 " --total-ops N: set the number of total operations performed\n"
58 " --burst-sz N: set the number of packets per burst\n"
59 " --buffer-sz N: set the size of a single packet\n"
60 " --segment-sz N: set the size of the segment to use\n"
61 " --desc-nb N: set number of descriptors for each crypto device\n"
62 " --devtype TYPE: set crypto device type to use\n"
63 " --optype cipher-only / auth-only / cipher-then-auth /\n"
64 " auth-then-cipher / aead : set operation type\n"
65 " --sessionless: enable session-less crypto operations\n"
66 " --out-of-place: enable out-of-place crypto operations\n"
67 " --test-file NAME: set the test vector file path\n"
68 " --test-name NAME: set specific test name section in test file\n"
69 " --cipher-algo ALGO: set cipher algorithm\n"
70 " --cipher-op encrypt / decrypt: set the cipher operation\n"
71 " --cipher-key-sz N: set the cipher key size\n"
72 " --cipher-iv-sz N: set the cipher IV size\n"
73 " --auth-algo ALGO: set auth algorithm\n"
74 " --auth-op generate / verify: set the auth operation\n"
75 " --auth-key-sz N: set the auth key size\n"
76 " --auth-iv-sz N: set the auth IV size\n"
77 " --aead-algo ALGO: set AEAD algorithm\n"
78 " --aead-op encrypt / decrypt: set the AEAD operation\n"
79 " --aead-key-sz N: set the AEAD key size\n"
80 " --aead-iv-sz N: set the AEAD IV size\n"
81 " --aead-aad-sz N: set the AEAD AAD size\n"
82 " --digest-sz N: set the digest size\n"
83 " --pmd-cyclecount-delay-ms N: set delay between enqueue\n"
84 " and dequeue in pmd-cyclecount benchmarking mode\n"
85 " --csv-friendly: enable test result output CSV friendly\n"
86 " -h: prints this help\n",
91 get_str_key_id_mapping(struct name_id_map *map, unsigned int map_len,
96 for (i = 0; i < map_len; i++) {
98 if (strcmp(str_key, map[i].name) == 0)
106 parse_cperf_test_type(struct cperf_options *opts, const char *arg)
108 struct name_id_map cperftest_namemap[] = {
110 cperf_test_type_strs[CPERF_TEST_TYPE_THROUGHPUT],
111 CPERF_TEST_TYPE_THROUGHPUT
114 cperf_test_type_strs[CPERF_TEST_TYPE_VERIFY],
115 CPERF_TEST_TYPE_VERIFY
118 cperf_test_type_strs[CPERF_TEST_TYPE_LATENCY],
119 CPERF_TEST_TYPE_LATENCY
122 cperf_test_type_strs[CPERF_TEST_TYPE_PMDCC],
123 CPERF_TEST_TYPE_PMDCC
127 int id = get_str_key_id_mapping(
128 (struct name_id_map *)cperftest_namemap,
129 RTE_DIM(cperftest_namemap), arg);
131 RTE_LOG(ERR, USER1, "failed to parse test type");
135 opts->test = (enum cperf_perf_test_type)id;
141 parse_uint32_t(uint32_t *value, const char *arg)
144 unsigned long n = strtoul(arg, &end, 10);
146 if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0'))
152 *value = (uint32_t) n;
158 parse_uint16_t(uint16_t *value, const char *arg)
161 int ret = parse_uint32_t(&val, arg);
166 if (val > UINT16_MAX)
169 *value = (uint16_t) val;
175 parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc)
180 char *copy_arg = strdup(arg);
182 if (copy_arg == NULL)
186 token = strtok(copy_arg, ":");
188 /* Parse minimum value */
190 number = strtoul(token, NULL, 10);
192 if (errno == EINVAL || errno == ERANGE ||
200 token = strtok(NULL, ":");
202 /* Parse increment value */
204 number = strtoul(token, NULL, 10);
206 if (errno == EINVAL || errno == ERANGE ||
214 token = strtok(NULL, ":");
216 /* Parse maximum value */
218 number = strtoul(token, NULL, 10);
220 if (errno == EINVAL || errno == ERANGE ||
229 if (strtok(NULL, ":") != NULL)
241 parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max)
247 char *copy_arg = strdup(arg);
249 if (copy_arg == NULL)
253 token = strtok(copy_arg, ",");
255 /* Parse first value */
257 number = strtoul(token, NULL, 10);
259 if (errno == EINVAL || errno == ERANGE ||
263 list[count++] = number;
269 token = strtok(NULL, ",");
271 while (token != NULL) {
272 if (count == MAX_LIST) {
273 RTE_LOG(WARNING, USER1, "Using only the first %u sizes\n",
278 number = strtoul(token, NULL, 10);
280 if (errno == EINVAL || errno == ERANGE ||
284 list[count++] = number;
291 token = strtok(NULL, ",");
303 parse_total_ops(struct cperf_options *opts, const char *arg)
305 int ret = parse_uint32_t(&opts->total_ops, arg);
308 RTE_LOG(ERR, USER1, "failed to parse total operations count\n");
310 if (opts->total_ops == 0) {
312 "invalid total operations count number specified\n");
320 parse_pool_sz(struct cperf_options *opts, const char *arg)
322 int ret = parse_uint32_t(&opts->pool_sz, arg);
325 RTE_LOG(ERR, USER1, "failed to parse pool size");
330 parse_burst_sz(struct cperf_options *opts, const char *arg)
334 /* Try parsing the argument as a range, if it fails, parse it as a list */
335 if (parse_range(arg, &opts->min_burst_size, &opts->max_burst_size,
336 &opts->inc_burst_size) < 0) {
337 ret = parse_list(arg, opts->burst_size_list,
338 &opts->min_burst_size,
339 &opts->max_burst_size);
341 RTE_LOG(ERR, USER1, "failed to parse burst size/s\n");
344 opts->burst_size_count = ret;
351 parse_buffer_sz(struct cperf_options *opts, const char *arg)
355 /* Try parsing the argument as a range, if it fails, parse it as a list */
356 if (parse_range(arg, &opts->min_buffer_size, &opts->max_buffer_size,
357 &opts->inc_buffer_size) < 0) {
358 ret = parse_list(arg, opts->buffer_size_list,
359 &opts->min_buffer_size,
360 &opts->max_buffer_size);
362 RTE_LOG(ERR, USER1, "failed to parse buffer size/s\n");
365 opts->buffer_size_count = ret;
372 parse_segment_sz(struct cperf_options *opts, const char *arg)
374 int ret = parse_uint32_t(&opts->segment_sz, arg);
377 RTE_LOG(ERR, USER1, "failed to parse segment size\n");
381 if (opts->segment_sz == 0) {
382 RTE_LOG(ERR, USER1, "Segment size has to be bigger than 0\n");
390 parse_desc_nb(struct cperf_options *opts, const char *arg)
392 int ret = parse_uint32_t(&opts->nb_descriptors, arg);
395 RTE_LOG(ERR, USER1, "failed to parse descriptors number\n");
399 if (opts->nb_descriptors == 0) {
400 RTE_LOG(ERR, USER1, "invalid descriptors number specified\n");
408 parse_device_type(struct cperf_options *opts, const char *arg)
410 if (strlen(arg) > (sizeof(opts->device_type) - 1))
413 strncpy(opts->device_type, arg, sizeof(opts->device_type) - 1);
414 *(opts->device_type + sizeof(opts->device_type) - 1) = '\0';
420 parse_op_type(struct cperf_options *opts, const char *arg)
422 struct name_id_map optype_namemap[] = {
424 cperf_op_type_strs[CPERF_CIPHER_ONLY],
428 cperf_op_type_strs[CPERF_AUTH_ONLY],
432 cperf_op_type_strs[CPERF_CIPHER_THEN_AUTH],
433 CPERF_CIPHER_THEN_AUTH
436 cperf_op_type_strs[CPERF_AUTH_THEN_CIPHER],
437 CPERF_AUTH_THEN_CIPHER
440 cperf_op_type_strs[CPERF_AEAD],
445 int id = get_str_key_id_mapping(optype_namemap,
446 RTE_DIM(optype_namemap), arg);
448 RTE_LOG(ERR, USER1, "invalid opt type specified\n");
452 opts->op_type = (enum cperf_op_type)id;
458 parse_sessionless(struct cperf_options *opts,
459 const char *arg __rte_unused)
461 opts->sessionless = 1;
466 parse_out_of_place(struct cperf_options *opts,
467 const char *arg __rte_unused)
469 opts->out_of_place = 1;
474 parse_test_file(struct cperf_options *opts,
477 opts->test_file = strdup(arg);
478 if (access(opts->test_file, F_OK) != -1)
480 RTE_LOG(ERR, USER1, "Test vector file doesn't exist\n");
486 parse_test_name(struct cperf_options *opts,
489 char *test_name = (char *) rte_zmalloc(NULL,
490 sizeof(char) * (strlen(arg) + 3), 0);
491 snprintf(test_name, strlen(arg) + 3, "[%s]", arg);
492 opts->test_name = test_name;
498 parse_silent(struct cperf_options *opts,
499 const char *arg __rte_unused)
507 parse_cipher_algo(struct cperf_options *opts, const char *arg)
510 enum rte_crypto_cipher_algorithm cipher_algo;
512 if (rte_cryptodev_get_cipher_algo_enum(&cipher_algo, arg) < 0) {
513 RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
517 opts->cipher_algo = cipher_algo;
523 parse_cipher_op(struct cperf_options *opts, const char *arg)
525 struct name_id_map cipher_op_namemap[] = {
527 rte_crypto_cipher_operation_strings
528 [RTE_CRYPTO_CIPHER_OP_ENCRYPT],
529 RTE_CRYPTO_CIPHER_OP_ENCRYPT },
531 rte_crypto_cipher_operation_strings
532 [RTE_CRYPTO_CIPHER_OP_DECRYPT],
533 RTE_CRYPTO_CIPHER_OP_DECRYPT
537 int id = get_str_key_id_mapping(cipher_op_namemap,
538 RTE_DIM(cipher_op_namemap), arg);
540 RTE_LOG(ERR, USER1, "Invalid cipher operation specified\n");
544 opts->cipher_op = (enum rte_crypto_cipher_operation)id;
550 parse_cipher_key_sz(struct cperf_options *opts, const char *arg)
552 return parse_uint16_t(&opts->cipher_key_sz, arg);
556 parse_cipher_iv_sz(struct cperf_options *opts, const char *arg)
558 return parse_uint16_t(&opts->cipher_iv_sz, arg);
562 parse_auth_algo(struct cperf_options *opts, const char *arg)
564 enum rte_crypto_auth_algorithm auth_algo;
566 if (rte_cryptodev_get_auth_algo_enum(&auth_algo, arg) < 0) {
567 RTE_LOG(ERR, USER1, "Invalid authentication algorithm specified\n");
571 opts->auth_algo = auth_algo;
577 parse_auth_op(struct cperf_options *opts, const char *arg)
579 struct name_id_map auth_op_namemap[] = {
581 rte_crypto_auth_operation_strings
582 [RTE_CRYPTO_AUTH_OP_GENERATE],
583 RTE_CRYPTO_AUTH_OP_GENERATE },
585 rte_crypto_auth_operation_strings
586 [RTE_CRYPTO_AUTH_OP_VERIFY],
587 RTE_CRYPTO_AUTH_OP_VERIFY
591 int id = get_str_key_id_mapping(auth_op_namemap,
592 RTE_DIM(auth_op_namemap), arg);
594 RTE_LOG(ERR, USER1, "invalid authentication operation specified"
599 opts->auth_op = (enum rte_crypto_auth_operation)id;
605 parse_auth_key_sz(struct cperf_options *opts, const char *arg)
607 return parse_uint16_t(&opts->auth_key_sz, arg);
611 parse_digest_sz(struct cperf_options *opts, const char *arg)
613 return parse_uint16_t(&opts->digest_sz, arg);
617 parse_auth_iv_sz(struct cperf_options *opts, const char *arg)
619 return parse_uint16_t(&opts->auth_iv_sz, arg);
623 parse_aead_algo(struct cperf_options *opts, const char *arg)
625 enum rte_crypto_aead_algorithm aead_algo;
627 if (rte_cryptodev_get_aead_algo_enum(&aead_algo, arg) < 0) {
628 RTE_LOG(ERR, USER1, "Invalid AEAD algorithm specified\n");
632 opts->aead_algo = aead_algo;
638 parse_aead_op(struct cperf_options *opts, const char *arg)
640 struct name_id_map aead_op_namemap[] = {
642 rte_crypto_aead_operation_strings
643 [RTE_CRYPTO_AEAD_OP_ENCRYPT],
644 RTE_CRYPTO_AEAD_OP_ENCRYPT },
646 rte_crypto_aead_operation_strings
647 [RTE_CRYPTO_AEAD_OP_DECRYPT],
648 RTE_CRYPTO_AEAD_OP_DECRYPT
652 int id = get_str_key_id_mapping(aead_op_namemap,
653 RTE_DIM(aead_op_namemap), arg);
655 RTE_LOG(ERR, USER1, "invalid AEAD operation specified"
660 opts->aead_op = (enum rte_crypto_aead_operation)id;
666 parse_aead_key_sz(struct cperf_options *opts, const char *arg)
668 return parse_uint16_t(&opts->aead_key_sz, arg);
672 parse_aead_iv_sz(struct cperf_options *opts, const char *arg)
674 return parse_uint16_t(&opts->aead_iv_sz, arg);
678 parse_aead_aad_sz(struct cperf_options *opts, const char *arg)
680 return parse_uint16_t(&opts->aead_aad_sz, arg);
684 parse_csv_friendly(struct cperf_options *opts, const char *arg __rte_unused)
692 parse_pmd_cyclecount_delay_ms(struct cperf_options *opts,
695 int ret = parse_uint32_t(&opts->pmdcc_delay, arg);
698 RTE_LOG(ERR, USER1, "failed to parse pmd-cyclecount delay\n");
705 typedef int (*option_parser_t)(struct cperf_options *opts,
708 struct long_opt_parser {
709 const char *lgopt_name;
710 option_parser_t parser_fn;
714 static struct option lgopts[] = {
716 { CPERF_PTEST_TYPE, required_argument, 0, 0 },
718 { CPERF_POOL_SIZE, required_argument, 0, 0 },
719 { CPERF_TOTAL_OPS, required_argument, 0, 0 },
720 { CPERF_BURST_SIZE, required_argument, 0, 0 },
721 { CPERF_BUFFER_SIZE, required_argument, 0, 0 },
722 { CPERF_SEGMENT_SIZE, required_argument, 0, 0 },
723 { CPERF_DESC_NB, required_argument, 0, 0 },
725 { CPERF_DEVTYPE, required_argument, 0, 0 },
726 { CPERF_OPTYPE, required_argument, 0, 0 },
728 { CPERF_SILENT, no_argument, 0, 0 },
729 { CPERF_SESSIONLESS, no_argument, 0, 0 },
730 { CPERF_OUT_OF_PLACE, no_argument, 0, 0 },
731 { CPERF_TEST_FILE, required_argument, 0, 0 },
732 { CPERF_TEST_NAME, required_argument, 0, 0 },
734 { CPERF_CIPHER_ALGO, required_argument, 0, 0 },
735 { CPERF_CIPHER_OP, required_argument, 0, 0 },
737 { CPERF_CIPHER_KEY_SZ, required_argument, 0, 0 },
738 { CPERF_CIPHER_IV_SZ, required_argument, 0, 0 },
740 { CPERF_AUTH_ALGO, required_argument, 0, 0 },
741 { CPERF_AUTH_OP, required_argument, 0, 0 },
743 { CPERF_AUTH_KEY_SZ, required_argument, 0, 0 },
744 { CPERF_AUTH_IV_SZ, required_argument, 0, 0 },
746 { CPERF_AEAD_ALGO, required_argument, 0, 0 },
747 { CPERF_AEAD_OP, required_argument, 0, 0 },
749 { CPERF_AEAD_KEY_SZ, required_argument, 0, 0 },
750 { CPERF_AEAD_AAD_SZ, required_argument, 0, 0 },
751 { CPERF_AEAD_IV_SZ, required_argument, 0, 0 },
753 { CPERF_DIGEST_SZ, required_argument, 0, 0 },
755 { CPERF_CSV, no_argument, 0, 0},
757 { CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 },
763 cperf_options_default(struct cperf_options *opts)
765 opts->test = CPERF_TEST_TYPE_THROUGHPUT;
767 opts->pool_sz = 8192;
768 opts->total_ops = 10000000;
769 opts->nb_descriptors = 2048;
771 opts->buffer_size_list[0] = 64;
772 opts->buffer_size_count = 1;
773 opts->max_buffer_size = 64;
774 opts->min_buffer_size = 64;
775 opts->inc_buffer_size = 0;
777 opts->burst_size_list[0] = 32;
778 opts->burst_size_count = 1;
779 opts->max_burst_size = 32;
780 opts->min_burst_size = 32;
781 opts->inc_burst_size = 0;
784 * Will be parsed from command line or set to
785 * maximum buffer size + digest, later
787 opts->segment_sz = 0;
789 strncpy(opts->device_type, "crypto_aesni_mb",
790 sizeof(opts->device_type));
793 opts->op_type = CPERF_CIPHER_THEN_AUTH;
796 opts->test_file = NULL;
797 opts->test_name = NULL;
798 opts->sessionless = 0;
799 opts->out_of_place = 0;
802 opts->cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC;
803 opts->cipher_op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
804 opts->cipher_key_sz = 16;
805 opts->cipher_iv_sz = 16;
807 opts->auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
808 opts->auth_op = RTE_CRYPTO_AUTH_OP_GENERATE;
810 opts->auth_key_sz = 64;
811 opts->auth_iv_sz = 0;
813 opts->aead_key_sz = 0;
814 opts->aead_iv_sz = 0;
815 opts->aead_aad_sz = 0;
817 opts->digest_sz = 12;
819 opts->pmdcc_delay = 0;
823 cperf_opts_parse_long(int opt_idx, struct cperf_options *opts)
825 struct long_opt_parser parsermap[] = {
826 { CPERF_PTEST_TYPE, parse_cperf_test_type },
827 { CPERF_SILENT, parse_silent },
828 { CPERF_POOL_SIZE, parse_pool_sz },
829 { CPERF_TOTAL_OPS, parse_total_ops },
830 { CPERF_BURST_SIZE, parse_burst_sz },
831 { CPERF_BUFFER_SIZE, parse_buffer_sz },
832 { CPERF_SEGMENT_SIZE, parse_segment_sz },
833 { CPERF_DESC_NB, parse_desc_nb },
834 { CPERF_DEVTYPE, parse_device_type },
835 { CPERF_OPTYPE, parse_op_type },
836 { CPERF_SESSIONLESS, parse_sessionless },
837 { CPERF_OUT_OF_PLACE, parse_out_of_place },
838 { CPERF_TEST_FILE, parse_test_file },
839 { CPERF_TEST_NAME, parse_test_name },
840 { CPERF_CIPHER_ALGO, parse_cipher_algo },
841 { CPERF_CIPHER_OP, parse_cipher_op },
842 { CPERF_CIPHER_KEY_SZ, parse_cipher_key_sz },
843 { CPERF_CIPHER_IV_SZ, parse_cipher_iv_sz },
844 { CPERF_AUTH_ALGO, parse_auth_algo },
845 { CPERF_AUTH_OP, parse_auth_op },
846 { CPERF_AUTH_KEY_SZ, parse_auth_key_sz },
847 { CPERF_AUTH_IV_SZ, parse_auth_iv_sz },
848 { CPERF_AEAD_ALGO, parse_aead_algo },
849 { CPERF_AEAD_OP, parse_aead_op },
850 { CPERF_AEAD_KEY_SZ, parse_aead_key_sz },
851 { CPERF_AEAD_IV_SZ, parse_aead_iv_sz },
852 { CPERF_AEAD_AAD_SZ, parse_aead_aad_sz },
853 { CPERF_DIGEST_SZ, parse_digest_sz },
854 { CPERF_CSV, parse_csv_friendly},
855 { CPERF_PMDCC_DELAY_MS, parse_pmd_cyclecount_delay_ms},
859 for (i = 0; i < RTE_DIM(parsermap); i++) {
860 if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name,
861 strlen(lgopts[opt_idx].name)) == 0)
862 return parsermap[i].parser_fn(opts, optarg);
869 cperf_options_parse(struct cperf_options *options, int argc, char **argv)
871 int opt, retval, opt_idx;
873 while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) {
877 rte_exit(EXIT_SUCCESS, "Displayed help\n");
881 retval = cperf_opts_parse_long(opt_idx, options);
897 check_cipher_buffer_length(struct cperf_options *options)
899 uint32_t buffer_size, buffer_size_idx = 0;
901 if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC ||
902 options->cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) {
903 if (options->inc_buffer_size != 0)
904 buffer_size = options->min_buffer_size;
906 buffer_size = options->buffer_size_list[0];
908 while (buffer_size <= options->max_buffer_size) {
909 if ((buffer_size % AES_BLOCK_SIZE) != 0) {
910 RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
911 "not suitable for the algorithm selected\n");
915 if (options->inc_buffer_size != 0)
916 buffer_size += options->inc_buffer_size;
918 if (++buffer_size_idx == options->buffer_size_count)
920 buffer_size = options->buffer_size_list[buffer_size_idx];
926 if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC ||
927 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC ||
928 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) {
929 if (options->inc_buffer_size != 0)
930 buffer_size = options->min_buffer_size;
932 buffer_size = options->buffer_size_list[0];
934 while (buffer_size <= options->max_buffer_size) {
935 if ((buffer_size % DES_BLOCK_SIZE) != 0) {
936 RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
937 "not suitable for the algorithm selected\n");
941 if (options->inc_buffer_size != 0)
942 buffer_size += options->inc_buffer_size;
944 if (++buffer_size_idx == options->buffer_size_count)
946 buffer_size = options->buffer_size_list[buffer_size_idx];
956 cperf_options_check(struct cperf_options *options)
958 if (options->op_type == CPERF_CIPHER_ONLY)
959 options->digest_sz = 0;
962 * If segment size is not set, assume only one segment,
963 * big enough to contain the largest buffer and the digest
965 if (options->segment_sz == 0)
966 options->segment_sz = options->max_buffer_size +
969 if (options->segment_sz < options->digest_sz) {
971 "Segment size should be at least "
972 "the size of the digest\n");
976 if (options->test == CPERF_TEST_TYPE_VERIFY &&
977 options->test_file == NULL) {
978 RTE_LOG(ERR, USER1, "Define path to the file with test"
983 if (options->test == CPERF_TEST_TYPE_VERIFY &&
984 options->op_type != CPERF_CIPHER_ONLY &&
985 options->test_name == NULL) {
986 RTE_LOG(ERR, USER1, "Define test name to get the correct digest"
987 " from the test vectors.\n");
991 if (options->test_name != NULL && options->test_file == NULL) {
992 RTE_LOG(ERR, USER1, "Define path to the file with test"
997 if (options->auth_op == RTE_CRYPTO_AUTH_OP_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->inc_buffer_size != 0 ||
1006 options->buffer_size_count > 1)) {
1007 RTE_LOG(ERR, USER1, "Only one buffer size is allowed when "
1008 "using the verify test.\n");
1012 if (options->test == CPERF_TEST_TYPE_VERIFY &&
1013 (options->inc_burst_size != 0 ||
1014 options->burst_size_count > 1)) {
1015 RTE_LOG(ERR, USER1, "Only one burst size is allowed when "
1016 "using the verify test.\n");
1020 if (options->test == CPERF_TEST_TYPE_PMDCC &&
1021 options->pool_sz < options->nb_descriptors) {
1022 RTE_LOG(ERR, USER1, "For pmd cyclecount benchmarks, pool size "
1023 "must be equal or greater than the number of "
1024 "cryptodev descriptors.\n");
1028 if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
1029 if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
1031 RTE_CRYPTO_AUTH_OP_GENERATE) {
1032 RTE_LOG(ERR, USER1, "Option cipher then auth must use"
1033 " options: encrypt and generate.\n");
1036 } else if (options->op_type == CPERF_AUTH_THEN_CIPHER) {
1037 if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_DECRYPT &&
1039 RTE_CRYPTO_AUTH_OP_VERIFY) {
1040 RTE_LOG(ERR, USER1, "Option auth then cipher must use"
1041 " options: decrypt and verify.\n");
1046 if (options->op_type == CPERF_CIPHER_ONLY ||
1047 options->op_type == CPERF_CIPHER_THEN_AUTH ||
1048 options->op_type == CPERF_AUTH_THEN_CIPHER) {
1049 if (check_cipher_buffer_length(options) < 0)
1057 cperf_options_dump(struct cperf_options *opts)
1061 printf("# Crypto Performance Application Options:\n");
1063 printf("# cperf test: %s\n", cperf_test_type_strs[opts->test]);
1065 printf("# size of crypto op / mbuf pool: %u\n", opts->pool_sz);
1066 printf("# total number of ops: %u\n", opts->total_ops);
1067 if (opts->inc_buffer_size != 0) {
1068 printf("# buffer size:\n");
1069 printf("#\t min: %u\n", opts->min_buffer_size);
1070 printf("#\t max: %u\n", opts->max_buffer_size);
1071 printf("#\t inc: %u\n", opts->inc_buffer_size);
1073 printf("# buffer sizes: ");
1074 for (size_idx = 0; size_idx < opts->buffer_size_count; size_idx++)
1075 printf("%u ", opts->buffer_size_list[size_idx]);
1078 if (opts->inc_burst_size != 0) {
1079 printf("# burst size:\n");
1080 printf("#\t min: %u\n", opts->min_burst_size);
1081 printf("#\t max: %u\n", opts->max_burst_size);
1082 printf("#\t inc: %u\n", opts->inc_burst_size);
1084 printf("# burst sizes: ");
1085 for (size_idx = 0; size_idx < opts->burst_size_count; size_idx++)
1086 printf("%u ", opts->burst_size_list[size_idx]);
1089 printf("\n# segment size: %u\n", opts->segment_sz);
1091 printf("# cryptodev type: %s\n", opts->device_type);
1093 printf("# number of queue pairs per device: %u\n", opts->nb_qps);
1094 printf("# crypto operation: %s\n", cperf_op_type_strs[opts->op_type]);
1095 printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");
1096 printf("# out of place: %s\n", opts->out_of_place ? "yes" : "no");
1097 if (opts->test == CPERF_TEST_TYPE_PMDCC)
1098 printf("# inter-burst delay: %u ms\n", opts->pmdcc_delay);
1102 if (opts->op_type == CPERF_AUTH_ONLY ||
1103 opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1104 opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1105 printf("# auth algorithm: %s\n",
1106 rte_crypto_auth_algorithm_strings[opts->auth_algo]);
1107 printf("# auth operation: %s\n",
1108 rte_crypto_auth_operation_strings[opts->auth_op]);
1109 printf("# auth key size: %u\n", opts->auth_key_sz);
1110 printf("# auth iv size: %u\n", opts->auth_iv_sz);
1111 printf("# auth digest size: %u\n", opts->digest_sz);
1115 if (opts->op_type == CPERF_CIPHER_ONLY ||
1116 opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1117 opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1118 printf("# cipher algorithm: %s\n",
1119 rte_crypto_cipher_algorithm_strings[opts->cipher_algo]);
1120 printf("# cipher operation: %s\n",
1121 rte_crypto_cipher_operation_strings[opts->cipher_op]);
1122 printf("# cipher key size: %u\n", opts->cipher_key_sz);
1123 printf("# cipher iv size: %u\n", opts->cipher_iv_sz);
1127 if (opts->op_type == CPERF_AEAD) {
1128 printf("# aead algorithm: %s\n",
1129 rte_crypto_aead_algorithm_strings[opts->aead_algo]);
1130 printf("# aead operation: %s\n",
1131 rte_crypto_aead_operation_strings[opts->aead_op]);
1132 printf("# aead key size: %u\n", opts->aead_key_sz);
1133 printf("# aead iv size: %u\n", opts->aead_iv_sz);
1134 printf("# aead digest size: %u\n", opts->digest_sz);
1135 printf("# aead aad size: %u\n", opts->aead_aad_sz);