1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2016-2017 Intel Corporation 3 */ 4 5 #include <getopt.h> 6 #include <stdlib.h> 7 #include <unistd.h> 8 9 #include <rte_cryptodev.h> 10 #include <rte_malloc.h> 11 #include <rte_ether.h> 12 13 #include "cperf_options.h" 14 #include "cperf_test_vectors.h" 15 16 #define AES_BLOCK_SIZE 16 17 #define DES_BLOCK_SIZE 8 18 19 struct name_id_map { 20 const char *name; 21 uint32_t id; 22 }; 23 24 static void 25 usage(char *progname) 26 { 27 printf("%s [EAL options] --\n" 28 " --silent: disable options dump\n" 29 " --ptest throughput / latency / verify / pmd-cyclecount :" 30 " set test type\n" 31 " --pool_sz N: set the number of crypto ops/mbufs allocated\n" 32 " --total-ops N: set the number of total operations performed\n" 33 " --burst-sz N: set the number of packets per burst\n" 34 " --buffer-sz N: set the size of a single packet\n" 35 " --imix N: set the distribution of packet sizes\n" 36 " --segment-sz N: set the size of the segment to use\n" 37 " --desc-nb N: set number of descriptors for each crypto device\n" 38 " --devtype TYPE: set crypto device type to use\n" 39 " --optype cipher-only / auth-only / cipher-then-auth /\n" 40 " auth-then-cipher / aead : set operation type\n" 41 " --sessionless: enable session-less crypto operations\n" 42 " --out-of-place: enable out-of-place crypto operations\n" 43 " --test-file NAME: set the test vector file path\n" 44 " --test-name NAME: set specific test name section in test file\n" 45 " --cipher-algo ALGO: set cipher algorithm\n" 46 " --cipher-op encrypt / decrypt: set the cipher operation\n" 47 " --cipher-key-sz N: set the cipher key size\n" 48 " --cipher-iv-sz N: set the cipher IV size\n" 49 " --auth-algo ALGO: set auth algorithm\n" 50 " --auth-op generate / verify: set the auth operation\n" 51 " --auth-key-sz N: set the auth key size\n" 52 " --auth-iv-sz N: set the auth IV size\n" 53 " --aead-algo ALGO: set AEAD algorithm\n" 54 " --aead-op encrypt / decrypt: set the AEAD operation\n" 55 " --aead-key-sz N: set the AEAD key size\n" 56 " --aead-iv-sz N: set the AEAD IV size\n" 57 " --aead-aad-sz N: set the AEAD AAD size\n" 58 " --digest-sz N: set the digest size\n" 59 " --pmd-cyclecount-delay-ms N: set delay between enqueue\n" 60 " and dequeue in pmd-cyclecount benchmarking mode\n" 61 " --csv-friendly: enable test result output CSV friendly\n" 62 " --modex-len N: modex length, supported lengths are " 63 "60, 128, 255, 448. Default: 128\n" 64 #ifdef RTE_LIB_SECURITY 65 " --pdcp-sn-sz N: set PDCP SN size N <5/7/12/15/18>\n" 66 " --pdcp-domain DOMAIN: set PDCP domain <control/user>\n" 67 " --pdcp-ses-hfn-en: enable session based fixed HFN\n" 68 " --enable-sdap: enable sdap\n" 69 " --docsis-hdr-sz: set DOCSIS header size\n" 70 #endif 71 " -h: prints this help\n", 72 progname); 73 } 74 75 static int 76 get_str_key_id_mapping(struct name_id_map *map, unsigned int map_len, 77 const char *str_key) 78 { 79 unsigned int i; 80 81 for (i = 0; i < map_len; i++) { 82 83 if (strcmp(str_key, map[i].name) == 0) 84 return map[i].id; 85 } 86 87 return -1; 88 } 89 90 static int 91 parse_cperf_test_type(struct cperf_options *opts, const char *arg) 92 { 93 struct name_id_map cperftest_namemap[] = { 94 { 95 cperf_test_type_strs[CPERF_TEST_TYPE_THROUGHPUT], 96 CPERF_TEST_TYPE_THROUGHPUT 97 }, 98 { 99 cperf_test_type_strs[CPERF_TEST_TYPE_VERIFY], 100 CPERF_TEST_TYPE_VERIFY 101 }, 102 { 103 cperf_test_type_strs[CPERF_TEST_TYPE_LATENCY], 104 CPERF_TEST_TYPE_LATENCY 105 }, 106 { 107 cperf_test_type_strs[CPERF_TEST_TYPE_PMDCC], 108 CPERF_TEST_TYPE_PMDCC 109 } 110 }; 111 112 int id = get_str_key_id_mapping( 113 (struct name_id_map *)cperftest_namemap, 114 RTE_DIM(cperftest_namemap), arg); 115 if (id < 0) { 116 RTE_LOG(ERR, USER1, "failed to parse test type"); 117 return -1; 118 } 119 120 opts->test = (enum cperf_perf_test_type)id; 121 122 return 0; 123 } 124 125 static int 126 parse_uint32_t(uint32_t *value, const char *arg) 127 { 128 char *end = NULL; 129 unsigned long n = strtoul(arg, &end, 10); 130 131 if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0')) 132 return -1; 133 134 if (n > UINT32_MAX) 135 return -ERANGE; 136 137 *value = (uint32_t) n; 138 139 return 0; 140 } 141 142 static int 143 parse_uint16_t(uint16_t *value, const char *arg) 144 { 145 uint32_t val = 0; 146 int ret = parse_uint32_t(&val, arg); 147 148 if (ret < 0) 149 return ret; 150 151 if (val > UINT16_MAX) 152 return -ERANGE; 153 154 *value = (uint16_t) val; 155 156 return 0; 157 } 158 159 static int 160 parse_range(const char *arg, uint32_t *min, uint32_t *max, uint32_t *inc) 161 { 162 char *token; 163 uint32_t number; 164 165 char *copy_arg = strdup(arg); 166 167 if (copy_arg == NULL) 168 return -1; 169 170 errno = 0; 171 token = strtok(copy_arg, ":"); 172 173 /* Parse minimum value */ 174 if (token != NULL) { 175 number = strtoul(token, NULL, 10); 176 177 if (errno == EINVAL || errno == ERANGE || 178 number == 0) 179 goto err_range; 180 181 *min = number; 182 } else 183 goto err_range; 184 185 token = strtok(NULL, ":"); 186 187 /* Parse increment value */ 188 if (token != NULL) { 189 number = strtoul(token, NULL, 10); 190 191 if (errno == EINVAL || errno == ERANGE || 192 number == 0) 193 goto err_range; 194 195 *inc = number; 196 } else 197 goto err_range; 198 199 token = strtok(NULL, ":"); 200 201 /* Parse maximum value */ 202 if (token != NULL) { 203 number = strtoul(token, NULL, 10); 204 205 if (errno == EINVAL || errno == ERANGE || 206 number == 0 || 207 number < *min) 208 goto err_range; 209 210 *max = number; 211 } else 212 goto err_range; 213 214 if (strtok(NULL, ":") != NULL) 215 goto err_range; 216 217 free(copy_arg); 218 return 0; 219 220 err_range: 221 free(copy_arg); 222 return -1; 223 } 224 225 static int 226 parse_list(const char *arg, uint32_t *list, uint32_t *min, uint32_t *max) 227 { 228 char *token; 229 uint32_t number; 230 uint8_t count = 0; 231 uint32_t temp_min; 232 uint32_t temp_max; 233 234 char *copy_arg = strdup(arg); 235 236 if (copy_arg == NULL) 237 return -1; 238 239 errno = 0; 240 token = strtok(copy_arg, ","); 241 242 /* Parse first value */ 243 if (token != NULL) { 244 number = strtoul(token, NULL, 10); 245 246 if (errno == EINVAL || errno == ERANGE || 247 number == 0) 248 goto err_list; 249 250 list[count++] = number; 251 temp_min = number; 252 temp_max = number; 253 } else 254 goto err_list; 255 256 token = strtok(NULL, ","); 257 258 while (token != NULL) { 259 if (count == MAX_LIST) { 260 RTE_LOG(WARNING, USER1, "Using only the first %u sizes\n", 261 MAX_LIST); 262 break; 263 } 264 265 number = strtoul(token, NULL, 10); 266 267 if (errno == EINVAL || errno == ERANGE || 268 number == 0) 269 goto err_list; 270 271 list[count++] = number; 272 273 if (number < temp_min) 274 temp_min = number; 275 if (number > temp_max) 276 temp_max = number; 277 278 token = strtok(NULL, ","); 279 } 280 281 if (min) 282 *min = temp_min; 283 if (max) 284 *max = temp_max; 285 286 free(copy_arg); 287 return count; 288 289 err_list: 290 free(copy_arg); 291 return -1; 292 } 293 294 static int 295 parse_total_ops(struct cperf_options *opts, const char *arg) 296 { 297 int ret = parse_uint32_t(&opts->total_ops, arg); 298 299 if (ret) 300 RTE_LOG(ERR, USER1, "failed to parse total operations count\n"); 301 302 if (opts->total_ops == 0) { 303 RTE_LOG(ERR, USER1, 304 "invalid total operations count number specified\n"); 305 return -1; 306 } 307 308 return ret; 309 } 310 311 static int 312 parse_pool_sz(struct cperf_options *opts, const char *arg) 313 { 314 int ret = parse_uint32_t(&opts->pool_sz, arg); 315 316 if (ret) 317 RTE_LOG(ERR, USER1, "failed to parse pool size"); 318 return ret; 319 } 320 321 static int 322 parse_modex_len(struct cperf_options *opts, const char *arg) 323 { 324 int ret = parse_uint16_t(&opts->modex_len, arg); 325 326 if (ret) 327 RTE_LOG(ERR, USER1, "failed to parse modex len"); 328 return ret; 329 } 330 331 static int 332 parse_burst_sz(struct cperf_options *opts, const char *arg) 333 { 334 int ret; 335 336 /* Try parsing the argument as a range, if it fails, parse it as a list */ 337 if (parse_range(arg, &opts->min_burst_size, &opts->max_burst_size, 338 &opts->inc_burst_size) < 0) { 339 ret = parse_list(arg, opts->burst_size_list, 340 &opts->min_burst_size, 341 &opts->max_burst_size); 342 if (ret < 0) { 343 RTE_LOG(ERR, USER1, "failed to parse burst size/s\n"); 344 return -1; 345 } 346 opts->burst_size_count = ret; 347 } 348 349 return 0; 350 } 351 352 static int 353 parse_buffer_sz(struct cperf_options *opts, const char *arg) 354 { 355 int ret; 356 357 /* Try parsing the argument as a range, if it fails, parse it as a list */ 358 if (parse_range(arg, &opts->min_buffer_size, &opts->max_buffer_size, 359 &opts->inc_buffer_size) < 0) { 360 ret = parse_list(arg, opts->buffer_size_list, 361 &opts->min_buffer_size, 362 &opts->max_buffer_size); 363 if (ret < 0) { 364 RTE_LOG(ERR, USER1, "failed to parse buffer size/s\n"); 365 return -1; 366 } 367 opts->buffer_size_count = ret; 368 } 369 370 return 0; 371 } 372 373 static int 374 parse_segment_sz(struct cperf_options *opts, const char *arg) 375 { 376 int ret = parse_uint32_t(&opts->segment_sz, arg); 377 378 if (ret) { 379 RTE_LOG(ERR, USER1, "failed to parse segment size\n"); 380 return -1; 381 } 382 383 if (opts->segment_sz == 0) { 384 RTE_LOG(ERR, USER1, "Segment size has to be bigger than 0\n"); 385 return -1; 386 } 387 388 return 0; 389 } 390 391 static int 392 parse_imix(struct cperf_options *opts, const char *arg) 393 { 394 int ret; 395 396 ret = parse_list(arg, opts->imix_distribution_list, 397 NULL, NULL); 398 if (ret < 0) { 399 RTE_LOG(ERR, USER1, "failed to parse imix distribution\n"); 400 return -1; 401 } 402 403 opts->imix_distribution_count = ret; 404 405 if (opts->imix_distribution_count <= 1) { 406 RTE_LOG(ERR, USER1, "imix distribution should have " 407 "at least two entries\n"); 408 return -1; 409 } 410 411 return 0; 412 } 413 414 static int 415 parse_desc_nb(struct cperf_options *opts, const char *arg) 416 { 417 int ret = parse_uint32_t(&opts->nb_descriptors, arg); 418 419 if (ret) { 420 RTE_LOG(ERR, USER1, "failed to parse descriptors number\n"); 421 return -1; 422 } 423 424 if (opts->nb_descriptors == 0) { 425 RTE_LOG(ERR, USER1, "invalid descriptors number specified\n"); 426 return -1; 427 } 428 429 return 0; 430 } 431 432 static int 433 parse_device_type(struct cperf_options *opts, const char *arg) 434 { 435 if (strlen(arg) > (sizeof(opts->device_type) - 1)) 436 return -1; 437 438 strncpy(opts->device_type, arg, sizeof(opts->device_type) - 1); 439 *(opts->device_type + sizeof(opts->device_type) - 1) = '\0'; 440 441 return 0; 442 } 443 444 static int 445 parse_op_type(struct cperf_options *opts, const char *arg) 446 { 447 struct name_id_map optype_namemap[] = { 448 { 449 cperf_op_type_strs[CPERF_CIPHER_ONLY], 450 CPERF_CIPHER_ONLY 451 }, 452 { 453 cperf_op_type_strs[CPERF_AUTH_ONLY], 454 CPERF_AUTH_ONLY 455 }, 456 { 457 cperf_op_type_strs[CPERF_CIPHER_THEN_AUTH], 458 CPERF_CIPHER_THEN_AUTH 459 }, 460 { 461 cperf_op_type_strs[CPERF_AUTH_THEN_CIPHER], 462 CPERF_AUTH_THEN_CIPHER 463 }, 464 { 465 cperf_op_type_strs[CPERF_AEAD], 466 CPERF_AEAD 467 }, 468 { 469 cperf_op_type_strs[CPERF_PDCP], 470 CPERF_PDCP 471 }, 472 { 473 cperf_op_type_strs[CPERF_DOCSIS], 474 CPERF_DOCSIS 475 }, 476 { 477 cperf_op_type_strs[CPERF_IPSEC], 478 CPERF_IPSEC 479 }, 480 { 481 cperf_op_type_strs[CPERF_ASYM_MODEX], 482 CPERF_ASYM_MODEX 483 } 484 }; 485 486 int id = get_str_key_id_mapping(optype_namemap, 487 RTE_DIM(optype_namemap), arg); 488 if (id < 0) { 489 RTE_LOG(ERR, USER1, "invalid opt type specified\n"); 490 return -1; 491 } 492 493 opts->op_type = (enum cperf_op_type)id; 494 495 return 0; 496 } 497 498 static int 499 parse_sessionless(struct cperf_options *opts, 500 const char *arg __rte_unused) 501 { 502 opts->sessionless = 1; 503 return 0; 504 } 505 506 static int 507 parse_out_of_place(struct cperf_options *opts, 508 const char *arg __rte_unused) 509 { 510 opts->out_of_place = 1; 511 return 0; 512 } 513 514 static int 515 parse_test_file(struct cperf_options *opts, 516 const char *arg) 517 { 518 opts->test_file = strdup(arg); 519 if (opts->test_file == NULL) { 520 RTE_LOG(ERR, USER1, "Dup vector file failed!\n"); 521 return -1; 522 } 523 if (access(opts->test_file, F_OK) != -1) 524 return 0; 525 RTE_LOG(ERR, USER1, "Test vector file doesn't exist\n"); 526 free(opts->test_file); 527 528 return -1; 529 } 530 531 static int 532 parse_test_name(struct cperf_options *opts, 533 const char *arg) 534 { 535 char *test_name = (char *) rte_zmalloc(NULL, 536 sizeof(char) * (strlen(arg) + 3), 0); 537 if (test_name == NULL) { 538 RTE_LOG(ERR, USER1, "Failed to rte zmalloc with size: %zu\n", 539 strlen(arg) + 3); 540 return -1; 541 } 542 543 snprintf(test_name, strlen(arg) + 3, "[%s]", arg); 544 opts->test_name = test_name; 545 546 return 0; 547 } 548 549 static int 550 parse_silent(struct cperf_options *opts, 551 const char *arg __rte_unused) 552 { 553 opts->silent = 1; 554 555 return 0; 556 } 557 558 static int 559 parse_enable_sdap(struct cperf_options *opts, 560 const char *arg __rte_unused) 561 { 562 opts->pdcp_sdap = 1; 563 564 return 0; 565 } 566 567 static int 568 parse_cipher_algo(struct cperf_options *opts, const char *arg) 569 { 570 571 enum rte_crypto_cipher_algorithm cipher_algo; 572 573 if (rte_cryptodev_get_cipher_algo_enum(&cipher_algo, arg) < 0) { 574 RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n"); 575 return -1; 576 } 577 578 opts->cipher_algo = cipher_algo; 579 580 return 0; 581 } 582 583 static int 584 parse_cipher_op(struct cperf_options *opts, const char *arg) 585 { 586 struct name_id_map cipher_op_namemap[] = { 587 { 588 rte_crypto_cipher_operation_strings 589 [RTE_CRYPTO_CIPHER_OP_ENCRYPT], 590 RTE_CRYPTO_CIPHER_OP_ENCRYPT }, 591 { 592 rte_crypto_cipher_operation_strings 593 [RTE_CRYPTO_CIPHER_OP_DECRYPT], 594 RTE_CRYPTO_CIPHER_OP_DECRYPT 595 } 596 }; 597 598 int id = get_str_key_id_mapping(cipher_op_namemap, 599 RTE_DIM(cipher_op_namemap), arg); 600 if (id < 0) { 601 RTE_LOG(ERR, USER1, "Invalid cipher operation specified\n"); 602 return -1; 603 } 604 605 opts->cipher_op = (enum rte_crypto_cipher_operation)id; 606 607 return 0; 608 } 609 610 static int 611 parse_cipher_key_sz(struct cperf_options *opts, const char *arg) 612 { 613 return parse_uint16_t(&opts->cipher_key_sz, arg); 614 } 615 616 static int 617 parse_cipher_iv_sz(struct cperf_options *opts, const char *arg) 618 { 619 return parse_uint16_t(&opts->cipher_iv_sz, arg); 620 } 621 622 static int 623 parse_auth_algo(struct cperf_options *opts, const char *arg) 624 { 625 enum rte_crypto_auth_algorithm auth_algo; 626 627 if (rte_cryptodev_get_auth_algo_enum(&auth_algo, arg) < 0) { 628 RTE_LOG(ERR, USER1, "Invalid authentication algorithm specified\n"); 629 return -1; 630 } 631 632 opts->auth_algo = auth_algo; 633 634 return 0; 635 } 636 637 static int 638 parse_auth_op(struct cperf_options *opts, const char *arg) 639 { 640 struct name_id_map auth_op_namemap[] = { 641 { 642 rte_crypto_auth_operation_strings 643 [RTE_CRYPTO_AUTH_OP_GENERATE], 644 RTE_CRYPTO_AUTH_OP_GENERATE }, 645 { 646 rte_crypto_auth_operation_strings 647 [RTE_CRYPTO_AUTH_OP_VERIFY], 648 RTE_CRYPTO_AUTH_OP_VERIFY 649 } 650 }; 651 652 int id = get_str_key_id_mapping(auth_op_namemap, 653 RTE_DIM(auth_op_namemap), arg); 654 if (id < 0) { 655 RTE_LOG(ERR, USER1, "invalid authentication operation specified" 656 "\n"); 657 return -1; 658 } 659 660 opts->auth_op = (enum rte_crypto_auth_operation)id; 661 662 return 0; 663 } 664 665 static int 666 parse_auth_key_sz(struct cperf_options *opts, const char *arg) 667 { 668 return parse_uint16_t(&opts->auth_key_sz, arg); 669 } 670 671 static int 672 parse_digest_sz(struct cperf_options *opts, const char *arg) 673 { 674 return parse_uint16_t(&opts->digest_sz, arg); 675 } 676 677 #ifdef RTE_LIB_SECURITY 678 static int 679 parse_pdcp_sn_sz(struct cperf_options *opts, const char *arg) 680 { 681 uint32_t val = 0; 682 int ret = parse_uint32_t(&val, arg); 683 684 if (ret < 0) 685 return ret; 686 687 if (val != RTE_SECURITY_PDCP_SN_SIZE_5 && 688 val != RTE_SECURITY_PDCP_SN_SIZE_7 && 689 val != RTE_SECURITY_PDCP_SN_SIZE_12 && 690 val != RTE_SECURITY_PDCP_SN_SIZE_15 && 691 val != RTE_SECURITY_PDCP_SN_SIZE_18) { 692 printf("\nInvalid pdcp SN size: %u\n", val); 693 return -ERANGE; 694 } 695 opts->pdcp_sn_sz = val; 696 697 return 0; 698 } 699 700 const char *cperf_pdcp_domain_strs[] = { 701 [RTE_SECURITY_PDCP_MODE_CONTROL] = "control", 702 [RTE_SECURITY_PDCP_MODE_DATA] = "data", 703 [RTE_SECURITY_PDCP_MODE_SHORT_MAC] = "short_mac" 704 }; 705 706 static int 707 parse_pdcp_domain(struct cperf_options *opts, const char *arg) 708 { 709 struct name_id_map pdcp_domain_namemap[] = { 710 { 711 cperf_pdcp_domain_strs 712 [RTE_SECURITY_PDCP_MODE_CONTROL], 713 RTE_SECURITY_PDCP_MODE_CONTROL }, 714 { 715 cperf_pdcp_domain_strs 716 [RTE_SECURITY_PDCP_MODE_DATA], 717 RTE_SECURITY_PDCP_MODE_DATA 718 }, 719 { 720 cperf_pdcp_domain_strs 721 [RTE_SECURITY_PDCP_MODE_SHORT_MAC], 722 RTE_SECURITY_PDCP_MODE_SHORT_MAC 723 } 724 }; 725 726 int id = get_str_key_id_mapping(pdcp_domain_namemap, 727 RTE_DIM(pdcp_domain_namemap), arg); 728 if (id < 0) { 729 RTE_LOG(ERR, USER1, "invalid pdcp domain specified" 730 "\n"); 731 return -1; 732 } 733 734 opts->pdcp_domain = (enum rte_security_pdcp_domain)id; 735 736 return 0; 737 } 738 739 static int 740 parse_pdcp_ses_hfn_en(struct cperf_options *opts, const char *arg __rte_unused) 741 { 742 opts->pdcp_ses_hfn_en = 1; 743 return 0; 744 } 745 746 static int 747 parse_docsis_hdr_sz(struct cperf_options *opts, const char *arg) 748 { 749 return parse_uint16_t(&opts->docsis_hdr_sz, arg); 750 } 751 #endif 752 753 static int 754 parse_auth_iv_sz(struct cperf_options *opts, const char *arg) 755 { 756 return parse_uint16_t(&opts->auth_iv_sz, arg); 757 } 758 759 static int 760 parse_aead_algo(struct cperf_options *opts, const char *arg) 761 { 762 enum rte_crypto_aead_algorithm aead_algo; 763 764 if (rte_cryptodev_get_aead_algo_enum(&aead_algo, arg) < 0) { 765 RTE_LOG(ERR, USER1, "Invalid AEAD algorithm specified\n"); 766 return -1; 767 } 768 769 opts->aead_algo = aead_algo; 770 771 return 0; 772 } 773 774 static int 775 parse_aead_op(struct cperf_options *opts, const char *arg) 776 { 777 struct name_id_map aead_op_namemap[] = { 778 { 779 rte_crypto_aead_operation_strings 780 [RTE_CRYPTO_AEAD_OP_ENCRYPT], 781 RTE_CRYPTO_AEAD_OP_ENCRYPT }, 782 { 783 rte_crypto_aead_operation_strings 784 [RTE_CRYPTO_AEAD_OP_DECRYPT], 785 RTE_CRYPTO_AEAD_OP_DECRYPT 786 } 787 }; 788 789 int id = get_str_key_id_mapping(aead_op_namemap, 790 RTE_DIM(aead_op_namemap), arg); 791 if (id < 0) { 792 RTE_LOG(ERR, USER1, "invalid AEAD operation specified" 793 "\n"); 794 return -1; 795 } 796 797 opts->aead_op = (enum rte_crypto_aead_operation)id; 798 799 return 0; 800 } 801 802 static int 803 parse_aead_key_sz(struct cperf_options *opts, const char *arg) 804 { 805 return parse_uint16_t(&opts->aead_key_sz, arg); 806 } 807 808 static int 809 parse_aead_iv_sz(struct cperf_options *opts, const char *arg) 810 { 811 return parse_uint16_t(&opts->aead_iv_sz, arg); 812 } 813 814 static int 815 parse_aead_aad_sz(struct cperf_options *opts, const char *arg) 816 { 817 return parse_uint16_t(&opts->aead_aad_sz, arg); 818 } 819 820 static int 821 parse_csv_friendly(struct cperf_options *opts, const char *arg __rte_unused) 822 { 823 opts->csv = 1; 824 opts->silent = 1; 825 return 0; 826 } 827 828 static int 829 parse_pmd_cyclecount_delay_ms(struct cperf_options *opts, 830 const char *arg) 831 { 832 int ret = parse_uint32_t(&opts->pmdcc_delay, arg); 833 834 if (ret) { 835 RTE_LOG(ERR, USER1, "failed to parse pmd-cyclecount delay\n"); 836 return -1; 837 } 838 839 return 0; 840 } 841 842 typedef int (*option_parser_t)(struct cperf_options *opts, 843 const char *arg); 844 845 struct long_opt_parser { 846 const char *lgopt_name; 847 option_parser_t parser_fn; 848 849 }; 850 851 static struct option lgopts[] = { 852 853 { CPERF_PTEST_TYPE, required_argument, 0, 0 }, 854 { CPERF_MODEX_LEN, required_argument, 0, 0 }, 855 856 { CPERF_POOL_SIZE, required_argument, 0, 0 }, 857 { CPERF_TOTAL_OPS, required_argument, 0, 0 }, 858 { CPERF_BURST_SIZE, required_argument, 0, 0 }, 859 { CPERF_BUFFER_SIZE, required_argument, 0, 0 }, 860 { CPERF_SEGMENT_SIZE, required_argument, 0, 0 }, 861 { CPERF_DESC_NB, required_argument, 0, 0 }, 862 863 { CPERF_IMIX, required_argument, 0, 0 }, 864 { CPERF_DEVTYPE, required_argument, 0, 0 }, 865 { CPERF_OPTYPE, required_argument, 0, 0 }, 866 867 { CPERF_SILENT, no_argument, 0, 0 }, 868 { CPERF_SESSIONLESS, no_argument, 0, 0 }, 869 { CPERF_OUT_OF_PLACE, no_argument, 0, 0 }, 870 { CPERF_TEST_FILE, required_argument, 0, 0 }, 871 { CPERF_TEST_NAME, required_argument, 0, 0 }, 872 873 { CPERF_CIPHER_ALGO, required_argument, 0, 0 }, 874 { CPERF_CIPHER_OP, required_argument, 0, 0 }, 875 876 { CPERF_CIPHER_KEY_SZ, required_argument, 0, 0 }, 877 { CPERF_CIPHER_IV_SZ, required_argument, 0, 0 }, 878 879 { CPERF_AUTH_ALGO, required_argument, 0, 0 }, 880 { CPERF_AUTH_OP, required_argument, 0, 0 }, 881 882 { CPERF_AUTH_KEY_SZ, required_argument, 0, 0 }, 883 { CPERF_AUTH_IV_SZ, required_argument, 0, 0 }, 884 885 { CPERF_AEAD_ALGO, required_argument, 0, 0 }, 886 { CPERF_AEAD_OP, required_argument, 0, 0 }, 887 888 { CPERF_AEAD_KEY_SZ, required_argument, 0, 0 }, 889 { CPERF_AEAD_AAD_SZ, required_argument, 0, 0 }, 890 { CPERF_AEAD_IV_SZ, required_argument, 0, 0 }, 891 892 { CPERF_DIGEST_SZ, required_argument, 0, 0 }, 893 894 #ifdef RTE_LIB_SECURITY 895 { CPERF_PDCP_SN_SZ, required_argument, 0, 0 }, 896 { CPERF_PDCP_DOMAIN, required_argument, 0, 0 }, 897 { CPERF_PDCP_SES_HFN_EN, no_argument, 0, 0 }, 898 { CPERF_ENABLE_SDAP, no_argument, 0, 0 }, 899 { CPERF_DOCSIS_HDR_SZ, required_argument, 0, 0 }, 900 #endif 901 { CPERF_CSV, no_argument, 0, 0}, 902 903 { CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 }, 904 905 { NULL, 0, 0, 0 } 906 }; 907 908 void 909 cperf_options_default(struct cperf_options *opts) 910 { 911 opts->test = CPERF_TEST_TYPE_THROUGHPUT; 912 913 opts->pool_sz = 8192; 914 opts->total_ops = 10000000; 915 opts->nb_descriptors = 2048; 916 917 opts->buffer_size_list[0] = 64; 918 opts->buffer_size_count = 1; 919 opts->max_buffer_size = 64; 920 opts->min_buffer_size = 64; 921 opts->inc_buffer_size = 0; 922 923 opts->burst_size_list[0] = 32; 924 opts->burst_size_count = 1; 925 opts->max_burst_size = 32; 926 opts->min_burst_size = 32; 927 opts->inc_burst_size = 0; 928 929 /* 930 * Will be parsed from command line or set to 931 * maximum buffer size + digest, later 932 */ 933 opts->segment_sz = 0; 934 935 opts->imix_distribution_count = 0; 936 strncpy(opts->device_type, "crypto_aesni_mb", 937 sizeof(opts->device_type)); 938 opts->nb_qps = 1; 939 940 opts->op_type = CPERF_CIPHER_THEN_AUTH; 941 942 opts->silent = 0; 943 opts->test_file = NULL; 944 opts->test_name = NULL; 945 opts->sessionless = 0; 946 opts->out_of_place = 0; 947 opts->csv = 0; 948 949 opts->cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC; 950 opts->cipher_op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 951 opts->cipher_key_sz = 16; 952 opts->cipher_iv_sz = 16; 953 954 opts->auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC; 955 opts->auth_op = RTE_CRYPTO_AUTH_OP_GENERATE; 956 957 opts->auth_key_sz = 64; 958 opts->auth_iv_sz = 0; 959 960 opts->aead_key_sz = 0; 961 opts->aead_iv_sz = 0; 962 opts->aead_aad_sz = 0; 963 964 opts->digest_sz = 12; 965 966 opts->pmdcc_delay = 0; 967 #ifdef RTE_LIB_SECURITY 968 opts->pdcp_sn_sz = 12; 969 opts->pdcp_domain = RTE_SECURITY_PDCP_MODE_CONTROL; 970 opts->pdcp_ses_hfn_en = 0; 971 opts->pdcp_sdap = 0; 972 opts->docsis_hdr_sz = 17; 973 #endif 974 opts->modex_data = (struct cperf_modex_test_data *)&modex_perf_data[0]; 975 } 976 977 static int 978 cperf_opts_parse_long(int opt_idx, struct cperf_options *opts) 979 { 980 struct long_opt_parser parsermap[] = { 981 { CPERF_PTEST_TYPE, parse_cperf_test_type }, 982 { CPERF_MODEX_LEN, parse_modex_len }, 983 { CPERF_SILENT, parse_silent }, 984 { CPERF_POOL_SIZE, parse_pool_sz }, 985 { CPERF_TOTAL_OPS, parse_total_ops }, 986 { CPERF_BURST_SIZE, parse_burst_sz }, 987 { CPERF_BUFFER_SIZE, parse_buffer_sz }, 988 { CPERF_SEGMENT_SIZE, parse_segment_sz }, 989 { CPERF_DESC_NB, parse_desc_nb }, 990 { CPERF_DEVTYPE, parse_device_type }, 991 { CPERF_OPTYPE, parse_op_type }, 992 { CPERF_SESSIONLESS, parse_sessionless }, 993 { CPERF_OUT_OF_PLACE, parse_out_of_place }, 994 { CPERF_IMIX, parse_imix }, 995 { CPERF_TEST_FILE, parse_test_file }, 996 { CPERF_TEST_NAME, parse_test_name }, 997 { CPERF_CIPHER_ALGO, parse_cipher_algo }, 998 { CPERF_CIPHER_OP, parse_cipher_op }, 999 { CPERF_CIPHER_KEY_SZ, parse_cipher_key_sz }, 1000 { CPERF_CIPHER_IV_SZ, parse_cipher_iv_sz }, 1001 { CPERF_AUTH_ALGO, parse_auth_algo }, 1002 { CPERF_AUTH_OP, parse_auth_op }, 1003 { CPERF_AUTH_KEY_SZ, parse_auth_key_sz }, 1004 { CPERF_AUTH_IV_SZ, parse_auth_iv_sz }, 1005 { CPERF_AEAD_ALGO, parse_aead_algo }, 1006 { CPERF_AEAD_OP, parse_aead_op }, 1007 { CPERF_AEAD_KEY_SZ, parse_aead_key_sz }, 1008 { CPERF_AEAD_IV_SZ, parse_aead_iv_sz }, 1009 { CPERF_AEAD_AAD_SZ, parse_aead_aad_sz }, 1010 { CPERF_DIGEST_SZ, parse_digest_sz }, 1011 #ifdef RTE_LIB_SECURITY 1012 { CPERF_PDCP_SN_SZ, parse_pdcp_sn_sz }, 1013 { CPERF_PDCP_DOMAIN, parse_pdcp_domain }, 1014 { CPERF_PDCP_SES_HFN_EN, parse_pdcp_ses_hfn_en }, 1015 { CPERF_ENABLE_SDAP, parse_enable_sdap }, 1016 { CPERF_DOCSIS_HDR_SZ, parse_docsis_hdr_sz }, 1017 #endif 1018 { CPERF_CSV, parse_csv_friendly}, 1019 { CPERF_PMDCC_DELAY_MS, parse_pmd_cyclecount_delay_ms}, 1020 }; 1021 unsigned int i; 1022 1023 for (i = 0; i < RTE_DIM(parsermap); i++) { 1024 if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name, 1025 strlen(lgopts[opt_idx].name)) == 0) 1026 return parsermap[i].parser_fn(opts, optarg); 1027 } 1028 1029 return -EINVAL; 1030 } 1031 1032 int 1033 cperf_options_parse(struct cperf_options *options, int argc, char **argv) 1034 { 1035 int opt, retval, opt_idx; 1036 1037 while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) { 1038 switch (opt) { 1039 case 'h': 1040 usage(argv[0]); 1041 exit(EXIT_SUCCESS); 1042 break; 1043 /* long options */ 1044 case 0: 1045 retval = cperf_opts_parse_long(opt_idx, options); 1046 if (retval != 0) 1047 return retval; 1048 1049 break; 1050 1051 default: 1052 usage(argv[0]); 1053 return -EINVAL; 1054 } 1055 } 1056 1057 return 0; 1058 } 1059 1060 static int 1061 check_cipher_buffer_length(struct cperf_options *options) 1062 { 1063 uint32_t buffer_size, buffer_size_idx = 0; 1064 1065 if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC || 1066 options->cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) { 1067 if (options->inc_buffer_size != 0) 1068 buffer_size = options->min_buffer_size; 1069 else 1070 buffer_size = options->buffer_size_list[0]; 1071 1072 if ((options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) && 1073 (options->op_type == CPERF_AUTH_THEN_CIPHER)) 1074 buffer_size += options->digest_sz; 1075 1076 while (buffer_size <= options->max_buffer_size) { 1077 if ((buffer_size % AES_BLOCK_SIZE) != 0) { 1078 RTE_LOG(ERR, USER1, "Some of the buffer sizes are " 1079 "not suitable for the algorithm selected\n"); 1080 return -EINVAL; 1081 } 1082 1083 if (options->inc_buffer_size != 0) 1084 buffer_size += options->inc_buffer_size; 1085 else { 1086 if (++buffer_size_idx == options->buffer_size_count) 1087 break; 1088 buffer_size = options->buffer_size_list[buffer_size_idx]; 1089 } 1090 1091 } 1092 } 1093 1094 if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC || 1095 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC || 1096 options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) { 1097 if (options->inc_buffer_size != 0) 1098 buffer_size = options->min_buffer_size; 1099 else 1100 buffer_size = options->buffer_size_list[0]; 1101 1102 if ((options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) && 1103 (options->op_type == CPERF_AUTH_THEN_CIPHER)) 1104 buffer_size += options->digest_sz; 1105 1106 while (buffer_size <= options->max_buffer_size) { 1107 if ((buffer_size % DES_BLOCK_SIZE) != 0) { 1108 RTE_LOG(ERR, USER1, "Some of the buffer sizes are " 1109 "not suitable for the algorithm selected\n"); 1110 return -EINVAL; 1111 } 1112 1113 if (options->inc_buffer_size != 0) 1114 buffer_size += options->inc_buffer_size; 1115 else { 1116 if (++buffer_size_idx == options->buffer_size_count) 1117 break; 1118 buffer_size = options->buffer_size_list[buffer_size_idx]; 1119 } 1120 1121 } 1122 } 1123 1124 return 0; 1125 } 1126 1127 #ifdef RTE_LIB_SECURITY 1128 static int 1129 check_docsis_buffer_length(struct cperf_options *options) 1130 { 1131 uint32_t buffer_size, buffer_size_idx = 0; 1132 1133 if (options->inc_buffer_size != 0) 1134 buffer_size = options->min_buffer_size; 1135 else 1136 buffer_size = options->buffer_size_list[0]; 1137 1138 while (buffer_size <= options->max_buffer_size) { 1139 if (buffer_size < (uint32_t)(options->docsis_hdr_sz + 1140 RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)) { 1141 RTE_LOG(ERR, USER1, "Some of the buffer sizes are not " 1142 "valid for DOCSIS\n"); 1143 return -EINVAL; 1144 } 1145 1146 if (options->inc_buffer_size != 0) 1147 buffer_size += options->inc_buffer_size; 1148 else { 1149 if (++buffer_size_idx == options->buffer_size_count) 1150 break; 1151 buffer_size = 1152 options->buffer_size_list[buffer_size_idx]; 1153 } 1154 } 1155 1156 return 0; 1157 } 1158 #endif 1159 1160 static bool 1161 is_valid_chained_op(struct cperf_options *options) 1162 { 1163 if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT && 1164 options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) 1165 return true; 1166 1167 if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT && 1168 options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) 1169 return true; 1170 1171 return false; 1172 } 1173 1174 int 1175 cperf_options_check(struct cperf_options *options) 1176 { 1177 int i; 1178 1179 if (options->op_type == CPERF_CIPHER_ONLY || 1180 options->op_type == CPERF_DOCSIS) 1181 options->digest_sz = 0; 1182 1183 if (options->out_of_place && 1184 options->segment_sz <= options->max_buffer_size) { 1185 RTE_LOG(ERR, USER1, "Out of place mode can only work " 1186 "with non segmented buffers\n"); 1187 return -EINVAL; 1188 } 1189 1190 /* 1191 * If segment size is not set, assume only one segment, 1192 * big enough to contain the largest buffer and the digest 1193 */ 1194 if (options->segment_sz == 0) { 1195 options->segment_sz = options->max_buffer_size + 1196 options->digest_sz; 1197 /* In IPsec operation, packet length will be increased 1198 * by some bytes depend upon the algorithm, so increasing 1199 * the segment size by headroom to cover most of 1200 * the scenarios. 1201 */ 1202 if (options->op_type == CPERF_IPSEC) 1203 options->segment_sz += RTE_PKTMBUF_HEADROOM; 1204 } 1205 1206 if (options->segment_sz < options->digest_sz) { 1207 RTE_LOG(ERR, USER1, 1208 "Segment size should be at least " 1209 "the size of the digest\n"); 1210 return -EINVAL; 1211 } 1212 1213 if ((options->imix_distribution_count != 0) && 1214 (options->imix_distribution_count != 1215 options->buffer_size_count)) { 1216 RTE_LOG(ERR, USER1, "IMIX distribution must have the same " 1217 "number of buffer sizes\n"); 1218 return -EINVAL; 1219 } 1220 1221 if (options->test == CPERF_TEST_TYPE_VERIFY && 1222 options->test_file == NULL) { 1223 RTE_LOG(ERR, USER1, "Define path to the file with test" 1224 " vectors.\n"); 1225 return -EINVAL; 1226 } 1227 1228 if (options->test == CPERF_TEST_TYPE_VERIFY && 1229 options->op_type != CPERF_CIPHER_ONLY && 1230 options->test_name == NULL) { 1231 RTE_LOG(ERR, USER1, "Define test name to get the correct digest" 1232 " from the test vectors.\n"); 1233 return -EINVAL; 1234 } 1235 1236 if (options->test_name != NULL && options->test_file == NULL) { 1237 RTE_LOG(ERR, USER1, "Define path to the file with test" 1238 " vectors.\n"); 1239 return -EINVAL; 1240 } 1241 1242 if (options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY && 1243 options->test_file == NULL) { 1244 RTE_LOG(ERR, USER1, "Define path to the file with test" 1245 " vectors.\n"); 1246 return -EINVAL; 1247 } 1248 1249 if (options->test == CPERF_TEST_TYPE_VERIFY && 1250 (options->inc_buffer_size != 0 || 1251 options->buffer_size_count > 1)) { 1252 RTE_LOG(ERR, USER1, "Only one buffer size is allowed when " 1253 "using the verify test.\n"); 1254 return -EINVAL; 1255 } 1256 1257 if (options->test == CPERF_TEST_TYPE_VERIFY && 1258 (options->inc_burst_size != 0 || 1259 options->burst_size_count > 1)) { 1260 RTE_LOG(ERR, USER1, "Only one burst size is allowed when " 1261 "using the verify test.\n"); 1262 return -EINVAL; 1263 } 1264 1265 if (options->test == CPERF_TEST_TYPE_PMDCC && 1266 options->pool_sz < options->nb_descriptors) { 1267 RTE_LOG(ERR, USER1, "For pmd cyclecount benchmarks, pool size " 1268 "must be equal or greater than the number of " 1269 "cryptodev descriptors.\n"); 1270 return -EINVAL; 1271 } 1272 1273 if (options->test == CPERF_TEST_TYPE_VERIFY && 1274 options->imix_distribution_count > 0) { 1275 RTE_LOG(ERR, USER1, "IMIX is not allowed when " 1276 "using the verify test.\n"); 1277 return -EINVAL; 1278 } 1279 1280 if (options->op_type == CPERF_CIPHER_THEN_AUTH || 1281 options->op_type == CPERF_AUTH_THEN_CIPHER) { 1282 if (!is_valid_chained_op(options)) { 1283 RTE_LOG(ERR, USER1, "Invalid chained operation.\n"); 1284 return -EINVAL; 1285 } 1286 } 1287 1288 if (options->op_type == CPERF_CIPHER_THEN_AUTH) { 1289 if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_ENCRYPT && 1290 options->auth_op != 1291 RTE_CRYPTO_AUTH_OP_GENERATE) { 1292 RTE_LOG(ERR, USER1, "Option cipher then auth must use" 1293 " options: encrypt and generate.\n"); 1294 return -EINVAL; 1295 } 1296 } 1297 1298 if (options->op_type == CPERF_CIPHER_ONLY || 1299 options->op_type == CPERF_CIPHER_THEN_AUTH || 1300 options->op_type == CPERF_AUTH_THEN_CIPHER) { 1301 if (check_cipher_buffer_length(options) < 0) 1302 return -EINVAL; 1303 } 1304 1305 if (options->modex_len) { 1306 if (options->op_type != CPERF_ASYM_MODEX) { 1307 RTE_LOG(ERR, USER1, "Option modex len should be used only with " 1308 " optype: modex.\n"); 1309 return -EINVAL; 1310 } 1311 1312 for (i = 0; i < (int)RTE_DIM(modex_perf_data); i++) { 1313 if (modex_perf_data[i].modulus.len == 1314 options->modex_len) { 1315 options->modex_data = 1316 (struct cperf_modex_test_data 1317 *)&modex_perf_data[i]; 1318 break; 1319 } 1320 } 1321 if (i == (int)RTE_DIM(modex_perf_data)) { 1322 RTE_LOG(ERR, USER1, 1323 "Option modex len: %d is not supported\n", 1324 options->modex_len); 1325 return -EINVAL; 1326 } 1327 } 1328 1329 #ifdef RTE_LIB_SECURITY 1330 if (options->op_type == CPERF_DOCSIS) { 1331 if (check_docsis_buffer_length(options) < 0) 1332 return -EINVAL; 1333 } 1334 1335 if (options->op_type == CPERF_IPSEC) { 1336 if (options->aead_algo) { 1337 if (options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT) 1338 options->is_outbound = 1; 1339 else 1340 options->is_outbound = 0; 1341 } else { 1342 if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT && 1343 options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) 1344 options->is_outbound = 1; 1345 else 1346 options->is_outbound = 0; 1347 } 1348 } 1349 #endif 1350 1351 return 0; 1352 } 1353 1354 void 1355 cperf_options_dump(struct cperf_options *opts) 1356 { 1357 uint8_t size_idx; 1358 1359 printf("# Crypto Performance Application Options:\n"); 1360 printf("#\n"); 1361 printf("# cperf test: %s\n", cperf_test_type_strs[opts->test]); 1362 printf("#\n"); 1363 printf("# size of crypto op / mbuf pool: %u\n", opts->pool_sz); 1364 printf("# total number of ops: %u\n", opts->total_ops); 1365 if (opts->inc_buffer_size != 0) { 1366 printf("# buffer size:\n"); 1367 printf("#\t min: %u\n", opts->min_buffer_size); 1368 printf("#\t max: %u\n", opts->max_buffer_size); 1369 printf("#\t inc: %u\n", opts->inc_buffer_size); 1370 } else { 1371 printf("# buffer sizes: "); 1372 for (size_idx = 0; size_idx < opts->buffer_size_count; size_idx++) 1373 printf("%u ", opts->buffer_size_list[size_idx]); 1374 printf("\n"); 1375 } 1376 if (opts->inc_burst_size != 0) { 1377 printf("# burst size:\n"); 1378 printf("#\t min: %u\n", opts->min_burst_size); 1379 printf("#\t max: %u\n", opts->max_burst_size); 1380 printf("#\t inc: %u\n", opts->inc_burst_size); 1381 } else { 1382 printf("# burst sizes: "); 1383 for (size_idx = 0; size_idx < opts->burst_size_count; size_idx++) 1384 printf("%u ", opts->burst_size_list[size_idx]); 1385 printf("\n"); 1386 } 1387 printf("\n# segment size: %u\n", opts->segment_sz); 1388 printf("#\n"); 1389 printf("# cryptodev type: %s\n", opts->device_type); 1390 printf("#\n"); 1391 printf("# number of queue pairs per device: %u\n", opts->nb_qps); 1392 printf("# crypto operation: %s\n", cperf_op_type_strs[opts->op_type]); 1393 printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no"); 1394 printf("# out of place: %s\n", opts->out_of_place ? "yes" : "no"); 1395 if (opts->test == CPERF_TEST_TYPE_PMDCC) 1396 printf("# inter-burst delay: %u ms\n", opts->pmdcc_delay); 1397 1398 printf("#\n"); 1399 1400 if (opts->op_type == CPERF_AUTH_ONLY || 1401 opts->op_type == CPERF_CIPHER_THEN_AUTH || 1402 opts->op_type == CPERF_AUTH_THEN_CIPHER) { 1403 printf("# auth algorithm: %s\n", 1404 rte_cryptodev_get_auth_algo_string(opts->auth_algo)); 1405 printf("# auth operation: %s\n", 1406 rte_crypto_auth_operation_strings[opts->auth_op]); 1407 printf("# auth key size: %u\n", opts->auth_key_sz); 1408 printf("# auth iv size: %u\n", opts->auth_iv_sz); 1409 printf("# auth digest size: %u\n", opts->digest_sz); 1410 printf("#\n"); 1411 } 1412 1413 if (opts->op_type == CPERF_CIPHER_ONLY || 1414 opts->op_type == CPERF_CIPHER_THEN_AUTH || 1415 opts->op_type == CPERF_AUTH_THEN_CIPHER) { 1416 printf("# cipher algorithm: %s\n", 1417 rte_cryptodev_get_cipher_algo_string(opts->cipher_algo)); 1418 printf("# cipher operation: %s\n", 1419 rte_crypto_cipher_operation_strings[opts->cipher_op]); 1420 printf("# cipher key size: %u\n", opts->cipher_key_sz); 1421 printf("# cipher iv size: %u\n", opts->cipher_iv_sz); 1422 printf("#\n"); 1423 } 1424 1425 if (opts->op_type == CPERF_AEAD) { 1426 printf("# aead algorithm: %s\n", 1427 rte_cryptodev_get_aead_algo_string(opts->aead_algo)); 1428 printf("# aead operation: %s\n", 1429 rte_crypto_aead_operation_strings[opts->aead_op]); 1430 printf("# aead key size: %u\n", opts->aead_key_sz); 1431 printf("# aead iv size: %u\n", opts->aead_iv_sz); 1432 printf("# aead digest size: %u\n", opts->digest_sz); 1433 printf("# aead aad size: %u\n", opts->aead_aad_sz); 1434 printf("#\n"); 1435 } 1436 1437 #ifdef RTE_LIB_SECURITY 1438 if (opts->op_type == CPERF_DOCSIS) { 1439 printf("# docsis header size: %u\n", opts->docsis_hdr_sz); 1440 printf("#\n"); 1441 } 1442 #endif 1443 } 1444