xref: /dpdk/app/test-crypto-perf/cperf_options_parsing.c (revision 3a80d7fb2ecdd6e8e48e56e3726b26980fa2a089)
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 (access(opts->test_file, F_OK) != -1)
520 		return 0;
521 	RTE_LOG(ERR, USER1, "Test vector file doesn't exist\n");
522 
523 	return -1;
524 }
525 
526 static int
527 parse_test_name(struct cperf_options *opts,
528 		const char *arg)
529 {
530 	char *test_name = (char *) rte_zmalloc(NULL,
531 		sizeof(char) * (strlen(arg) + 3), 0);
532 	if (test_name == NULL) {
533 		RTE_LOG(ERR, USER1, "Failed to rte zmalloc with size: %zu\n",
534 			strlen(arg) + 3);
535 		return -1;
536 	}
537 
538 	snprintf(test_name, strlen(arg) + 3, "[%s]", arg);
539 	opts->test_name = test_name;
540 
541 	return 0;
542 }
543 
544 static int
545 parse_silent(struct cperf_options *opts,
546 		const char *arg __rte_unused)
547 {
548 	opts->silent = 1;
549 
550 	return 0;
551 }
552 
553 static int
554 parse_enable_sdap(struct cperf_options *opts,
555 		const char *arg __rte_unused)
556 {
557 	opts->pdcp_sdap = 1;
558 
559 	return 0;
560 }
561 
562 static int
563 parse_cipher_algo(struct cperf_options *opts, const char *arg)
564 {
565 
566 	enum rte_crypto_cipher_algorithm cipher_algo;
567 
568 	if (rte_cryptodev_get_cipher_algo_enum(&cipher_algo, arg) < 0) {
569 		RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
570 		return -1;
571 	}
572 
573 	opts->cipher_algo = cipher_algo;
574 
575 	return 0;
576 }
577 
578 static int
579 parse_cipher_op(struct cperf_options *opts, const char *arg)
580 {
581 	struct name_id_map cipher_op_namemap[] = {
582 		{
583 			rte_crypto_cipher_operation_strings
584 			[RTE_CRYPTO_CIPHER_OP_ENCRYPT],
585 			RTE_CRYPTO_CIPHER_OP_ENCRYPT },
586 		{
587 			rte_crypto_cipher_operation_strings
588 			[RTE_CRYPTO_CIPHER_OP_DECRYPT],
589 			RTE_CRYPTO_CIPHER_OP_DECRYPT
590 		}
591 	};
592 
593 	int id = get_str_key_id_mapping(cipher_op_namemap,
594 			RTE_DIM(cipher_op_namemap), arg);
595 	if (id < 0) {
596 		RTE_LOG(ERR, USER1, "Invalid cipher operation specified\n");
597 		return -1;
598 	}
599 
600 	opts->cipher_op = (enum rte_crypto_cipher_operation)id;
601 
602 	return 0;
603 }
604 
605 static int
606 parse_cipher_key_sz(struct cperf_options *opts, const char *arg)
607 {
608 	return parse_uint16_t(&opts->cipher_key_sz, arg);
609 }
610 
611 static int
612 parse_cipher_iv_sz(struct cperf_options *opts, const char *arg)
613 {
614 	return parse_uint16_t(&opts->cipher_iv_sz, arg);
615 }
616 
617 static int
618 parse_auth_algo(struct cperf_options *opts, const char *arg)
619 {
620 	enum rte_crypto_auth_algorithm auth_algo;
621 
622 	if (rte_cryptodev_get_auth_algo_enum(&auth_algo, arg) < 0) {
623 		RTE_LOG(ERR, USER1, "Invalid authentication algorithm specified\n");
624 		return -1;
625 	}
626 
627 	opts->auth_algo = auth_algo;
628 
629 	return 0;
630 }
631 
632 static int
633 parse_auth_op(struct cperf_options *opts, const char *arg)
634 {
635 	struct name_id_map auth_op_namemap[] = {
636 		{
637 			rte_crypto_auth_operation_strings
638 			[RTE_CRYPTO_AUTH_OP_GENERATE],
639 			RTE_CRYPTO_AUTH_OP_GENERATE },
640 		{
641 			rte_crypto_auth_operation_strings
642 			[RTE_CRYPTO_AUTH_OP_VERIFY],
643 			RTE_CRYPTO_AUTH_OP_VERIFY
644 		}
645 	};
646 
647 	int id = get_str_key_id_mapping(auth_op_namemap,
648 			RTE_DIM(auth_op_namemap), arg);
649 	if (id < 0) {
650 		RTE_LOG(ERR, USER1, "invalid authentication operation specified"
651 				"\n");
652 		return -1;
653 	}
654 
655 	opts->auth_op = (enum rte_crypto_auth_operation)id;
656 
657 	return 0;
658 }
659 
660 static int
661 parse_auth_key_sz(struct cperf_options *opts, const char *arg)
662 {
663 	return parse_uint16_t(&opts->auth_key_sz, arg);
664 }
665 
666 static int
667 parse_digest_sz(struct cperf_options *opts, const char *arg)
668 {
669 	return parse_uint16_t(&opts->digest_sz, arg);
670 }
671 
672 #ifdef RTE_LIB_SECURITY
673 static int
674 parse_pdcp_sn_sz(struct cperf_options *opts, const char *arg)
675 {
676 	uint32_t val = 0;
677 	int ret = parse_uint32_t(&val, arg);
678 
679 	if (ret < 0)
680 		return ret;
681 
682 	if (val != RTE_SECURITY_PDCP_SN_SIZE_5 &&
683 			val != RTE_SECURITY_PDCP_SN_SIZE_7 &&
684 			val != RTE_SECURITY_PDCP_SN_SIZE_12 &&
685 			val != RTE_SECURITY_PDCP_SN_SIZE_15 &&
686 			val != RTE_SECURITY_PDCP_SN_SIZE_18) {
687 		printf("\nInvalid pdcp SN size: %u\n", val);
688 		return -ERANGE;
689 	}
690 	opts->pdcp_sn_sz = val;
691 
692 	return 0;
693 }
694 
695 const char *cperf_pdcp_domain_strs[] = {
696 	[RTE_SECURITY_PDCP_MODE_CONTROL] = "control",
697 	[RTE_SECURITY_PDCP_MODE_DATA] = "data",
698 	[RTE_SECURITY_PDCP_MODE_SHORT_MAC] = "short_mac"
699 };
700 
701 static int
702 parse_pdcp_domain(struct cperf_options *opts, const char *arg)
703 {
704 	struct name_id_map pdcp_domain_namemap[] = {
705 		{
706 			cperf_pdcp_domain_strs
707 			[RTE_SECURITY_PDCP_MODE_CONTROL],
708 			RTE_SECURITY_PDCP_MODE_CONTROL },
709 		{
710 			cperf_pdcp_domain_strs
711 			[RTE_SECURITY_PDCP_MODE_DATA],
712 			RTE_SECURITY_PDCP_MODE_DATA
713 		},
714 		{
715 			cperf_pdcp_domain_strs
716 			[RTE_SECURITY_PDCP_MODE_SHORT_MAC],
717 			RTE_SECURITY_PDCP_MODE_SHORT_MAC
718 		}
719 	};
720 
721 	int id = get_str_key_id_mapping(pdcp_domain_namemap,
722 			RTE_DIM(pdcp_domain_namemap), arg);
723 	if (id < 0) {
724 		RTE_LOG(ERR, USER1, "invalid pdcp domain specified"
725 				"\n");
726 		return -1;
727 	}
728 
729 	opts->pdcp_domain = (enum rte_security_pdcp_domain)id;
730 
731 	return 0;
732 }
733 
734 static int
735 parse_pdcp_ses_hfn_en(struct cperf_options *opts, const char *arg __rte_unused)
736 {
737 	opts->pdcp_ses_hfn_en = 1;
738 	return 0;
739 }
740 
741 static int
742 parse_docsis_hdr_sz(struct cperf_options *opts, const char *arg)
743 {
744 	return parse_uint16_t(&opts->docsis_hdr_sz, arg);
745 }
746 #endif
747 
748 static int
749 parse_auth_iv_sz(struct cperf_options *opts, const char *arg)
750 {
751 	return parse_uint16_t(&opts->auth_iv_sz, arg);
752 }
753 
754 static int
755 parse_aead_algo(struct cperf_options *opts, const char *arg)
756 {
757 	enum rte_crypto_aead_algorithm aead_algo;
758 
759 	if (rte_cryptodev_get_aead_algo_enum(&aead_algo, arg) < 0) {
760 		RTE_LOG(ERR, USER1, "Invalid AEAD algorithm specified\n");
761 		return -1;
762 	}
763 
764 	opts->aead_algo = aead_algo;
765 
766 	return 0;
767 }
768 
769 static int
770 parse_aead_op(struct cperf_options *opts, const char *arg)
771 {
772 	struct name_id_map aead_op_namemap[] = {
773 		{
774 			rte_crypto_aead_operation_strings
775 			[RTE_CRYPTO_AEAD_OP_ENCRYPT],
776 			RTE_CRYPTO_AEAD_OP_ENCRYPT },
777 		{
778 			rte_crypto_aead_operation_strings
779 			[RTE_CRYPTO_AEAD_OP_DECRYPT],
780 			RTE_CRYPTO_AEAD_OP_DECRYPT
781 		}
782 	};
783 
784 	int id = get_str_key_id_mapping(aead_op_namemap,
785 			RTE_DIM(aead_op_namemap), arg);
786 	if (id < 0) {
787 		RTE_LOG(ERR, USER1, "invalid AEAD operation specified"
788 				"\n");
789 		return -1;
790 	}
791 
792 	opts->aead_op = (enum rte_crypto_aead_operation)id;
793 
794 	return 0;
795 }
796 
797 static int
798 parse_aead_key_sz(struct cperf_options *opts, const char *arg)
799 {
800 	return parse_uint16_t(&opts->aead_key_sz, arg);
801 }
802 
803 static int
804 parse_aead_iv_sz(struct cperf_options *opts, const char *arg)
805 {
806 	return parse_uint16_t(&opts->aead_iv_sz, arg);
807 }
808 
809 static int
810 parse_aead_aad_sz(struct cperf_options *opts, const char *arg)
811 {
812 	return parse_uint16_t(&opts->aead_aad_sz, arg);
813 }
814 
815 static int
816 parse_csv_friendly(struct cperf_options *opts, const char *arg __rte_unused)
817 {
818 	opts->csv = 1;
819 	opts->silent = 1;
820 	return 0;
821 }
822 
823 static int
824 parse_pmd_cyclecount_delay_ms(struct cperf_options *opts,
825 			const char *arg)
826 {
827 	int ret = parse_uint32_t(&opts->pmdcc_delay, arg);
828 
829 	if (ret) {
830 		RTE_LOG(ERR, USER1, "failed to parse pmd-cyclecount delay\n");
831 		return -1;
832 	}
833 
834 	return 0;
835 }
836 
837 typedef int (*option_parser_t)(struct cperf_options *opts,
838 		const char *arg);
839 
840 struct long_opt_parser {
841 	const char *lgopt_name;
842 	option_parser_t parser_fn;
843 
844 };
845 
846 static struct option lgopts[] = {
847 
848 	{ CPERF_PTEST_TYPE, required_argument, 0, 0 },
849 	{ CPERF_MODEX_LEN, required_argument, 0, 0 },
850 
851 	{ CPERF_POOL_SIZE, required_argument, 0, 0 },
852 	{ CPERF_TOTAL_OPS, required_argument, 0, 0 },
853 	{ CPERF_BURST_SIZE, required_argument, 0, 0 },
854 	{ CPERF_BUFFER_SIZE, required_argument, 0, 0 },
855 	{ CPERF_SEGMENT_SIZE, required_argument, 0, 0 },
856 	{ CPERF_DESC_NB, required_argument, 0, 0 },
857 
858 	{ CPERF_IMIX, required_argument, 0, 0 },
859 	{ CPERF_DEVTYPE, required_argument, 0, 0 },
860 	{ CPERF_OPTYPE, required_argument, 0, 0 },
861 
862 	{ CPERF_SILENT, no_argument, 0, 0 },
863 	{ CPERF_SESSIONLESS, no_argument, 0, 0 },
864 	{ CPERF_OUT_OF_PLACE, no_argument, 0, 0 },
865 	{ CPERF_TEST_FILE, required_argument, 0, 0 },
866 	{ CPERF_TEST_NAME, required_argument, 0, 0 },
867 
868 	{ CPERF_CIPHER_ALGO, required_argument, 0, 0 },
869 	{ CPERF_CIPHER_OP, required_argument, 0, 0 },
870 
871 	{ CPERF_CIPHER_KEY_SZ, required_argument, 0, 0 },
872 	{ CPERF_CIPHER_IV_SZ, required_argument, 0, 0 },
873 
874 	{ CPERF_AUTH_ALGO, required_argument, 0, 0 },
875 	{ CPERF_AUTH_OP, required_argument, 0, 0 },
876 
877 	{ CPERF_AUTH_KEY_SZ, required_argument, 0, 0 },
878 	{ CPERF_AUTH_IV_SZ, required_argument, 0, 0 },
879 
880 	{ CPERF_AEAD_ALGO, required_argument, 0, 0 },
881 	{ CPERF_AEAD_OP, required_argument, 0, 0 },
882 
883 	{ CPERF_AEAD_KEY_SZ, required_argument, 0, 0 },
884 	{ CPERF_AEAD_AAD_SZ, required_argument, 0, 0 },
885 	{ CPERF_AEAD_IV_SZ, required_argument, 0, 0 },
886 
887 	{ CPERF_DIGEST_SZ, required_argument, 0, 0 },
888 
889 #ifdef RTE_LIB_SECURITY
890 	{ CPERF_PDCP_SN_SZ, required_argument, 0, 0 },
891 	{ CPERF_PDCP_DOMAIN, required_argument, 0, 0 },
892 	{ CPERF_PDCP_SES_HFN_EN, no_argument, 0, 0 },
893 	{ CPERF_ENABLE_SDAP, no_argument, 0, 0 },
894 	{ CPERF_DOCSIS_HDR_SZ, required_argument, 0, 0 },
895 #endif
896 	{ CPERF_CSV, no_argument, 0, 0},
897 
898 	{ CPERF_PMDCC_DELAY_MS, required_argument, 0, 0 },
899 
900 	{ NULL, 0, 0, 0 }
901 };
902 
903 void
904 cperf_options_default(struct cperf_options *opts)
905 {
906 	opts->test = CPERF_TEST_TYPE_THROUGHPUT;
907 
908 	opts->pool_sz = 8192;
909 	opts->total_ops = 10000000;
910 	opts->nb_descriptors = 2048;
911 
912 	opts->buffer_size_list[0] = 64;
913 	opts->buffer_size_count = 1;
914 	opts->max_buffer_size = 64;
915 	opts->min_buffer_size = 64;
916 	opts->inc_buffer_size = 0;
917 
918 	opts->burst_size_list[0] = 32;
919 	opts->burst_size_count = 1;
920 	opts->max_burst_size = 32;
921 	opts->min_burst_size = 32;
922 	opts->inc_burst_size = 0;
923 
924 	/*
925 	 * Will be parsed from command line or set to
926 	 * maximum buffer size + digest, later
927 	 */
928 	opts->segment_sz = 0;
929 
930 	opts->imix_distribution_count = 0;
931 	strncpy(opts->device_type, "crypto_aesni_mb",
932 			sizeof(opts->device_type));
933 	opts->nb_qps = 1;
934 
935 	opts->op_type = CPERF_CIPHER_THEN_AUTH;
936 
937 	opts->silent = 0;
938 	opts->test_file = NULL;
939 	opts->test_name = NULL;
940 	opts->sessionless = 0;
941 	opts->out_of_place = 0;
942 	opts->csv = 0;
943 
944 	opts->cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC;
945 	opts->cipher_op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
946 	opts->cipher_key_sz = 16;
947 	opts->cipher_iv_sz = 16;
948 
949 	opts->auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
950 	opts->auth_op = RTE_CRYPTO_AUTH_OP_GENERATE;
951 
952 	opts->auth_key_sz = 64;
953 	opts->auth_iv_sz = 0;
954 
955 	opts->aead_key_sz = 0;
956 	opts->aead_iv_sz = 0;
957 	opts->aead_aad_sz = 0;
958 
959 	opts->digest_sz = 12;
960 
961 	opts->pmdcc_delay = 0;
962 #ifdef RTE_LIB_SECURITY
963 	opts->pdcp_sn_sz = 12;
964 	opts->pdcp_domain = RTE_SECURITY_PDCP_MODE_CONTROL;
965 	opts->pdcp_ses_hfn_en = 0;
966 	opts->pdcp_sdap = 0;
967 	opts->docsis_hdr_sz = 17;
968 #endif
969 	opts->modex_data = (struct cperf_modex_test_data *)&modex_perf_data[0];
970 }
971 
972 static int
973 cperf_opts_parse_long(int opt_idx, struct cperf_options *opts)
974 {
975 	struct long_opt_parser parsermap[] = {
976 		{ CPERF_PTEST_TYPE,	parse_cperf_test_type },
977 		{ CPERF_MODEX_LEN,	parse_modex_len },
978 		{ CPERF_SILENT,		parse_silent },
979 		{ CPERF_POOL_SIZE,	parse_pool_sz },
980 		{ CPERF_TOTAL_OPS,	parse_total_ops },
981 		{ CPERF_BURST_SIZE,	parse_burst_sz },
982 		{ CPERF_BUFFER_SIZE,	parse_buffer_sz },
983 		{ CPERF_SEGMENT_SIZE,	parse_segment_sz },
984 		{ CPERF_DESC_NB,	parse_desc_nb },
985 		{ CPERF_DEVTYPE,	parse_device_type },
986 		{ CPERF_OPTYPE,		parse_op_type },
987 		{ CPERF_SESSIONLESS,	parse_sessionless },
988 		{ CPERF_OUT_OF_PLACE,	parse_out_of_place },
989 		{ CPERF_IMIX,		parse_imix },
990 		{ CPERF_TEST_FILE,	parse_test_file },
991 		{ CPERF_TEST_NAME,	parse_test_name },
992 		{ CPERF_CIPHER_ALGO,	parse_cipher_algo },
993 		{ CPERF_CIPHER_OP,	parse_cipher_op },
994 		{ CPERF_CIPHER_KEY_SZ,	parse_cipher_key_sz },
995 		{ CPERF_CIPHER_IV_SZ,	parse_cipher_iv_sz },
996 		{ CPERF_AUTH_ALGO,	parse_auth_algo },
997 		{ CPERF_AUTH_OP,	parse_auth_op },
998 		{ CPERF_AUTH_KEY_SZ,	parse_auth_key_sz },
999 		{ CPERF_AUTH_IV_SZ,	parse_auth_iv_sz },
1000 		{ CPERF_AEAD_ALGO,	parse_aead_algo },
1001 		{ CPERF_AEAD_OP,	parse_aead_op },
1002 		{ CPERF_AEAD_KEY_SZ,	parse_aead_key_sz },
1003 		{ CPERF_AEAD_IV_SZ,	parse_aead_iv_sz },
1004 		{ CPERF_AEAD_AAD_SZ,	parse_aead_aad_sz },
1005 		{ CPERF_DIGEST_SZ,	parse_digest_sz },
1006 #ifdef RTE_LIB_SECURITY
1007 		{ CPERF_PDCP_SN_SZ,	parse_pdcp_sn_sz },
1008 		{ CPERF_PDCP_DOMAIN,	parse_pdcp_domain },
1009 		{ CPERF_PDCP_SES_HFN_EN,	parse_pdcp_ses_hfn_en },
1010 		{ CPERF_ENABLE_SDAP,	parse_enable_sdap },
1011 		{ CPERF_DOCSIS_HDR_SZ,	parse_docsis_hdr_sz },
1012 #endif
1013 		{ CPERF_CSV,		parse_csv_friendly},
1014 		{ CPERF_PMDCC_DELAY_MS,	parse_pmd_cyclecount_delay_ms},
1015 	};
1016 	unsigned int i;
1017 
1018 	for (i = 0; i < RTE_DIM(parsermap); i++) {
1019 		if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name,
1020 				strlen(lgopts[opt_idx].name)) == 0)
1021 			return parsermap[i].parser_fn(opts, optarg);
1022 	}
1023 
1024 	return -EINVAL;
1025 }
1026 
1027 int
1028 cperf_options_parse(struct cperf_options *options, int argc, char **argv)
1029 {
1030 	int opt, retval, opt_idx;
1031 
1032 	while ((opt = getopt_long(argc, argv, "h", lgopts, &opt_idx)) != EOF) {
1033 		switch (opt) {
1034 		case 'h':
1035 			usage(argv[0]);
1036 			exit(EXIT_SUCCESS);
1037 			break;
1038 		/* long options */
1039 		case 0:
1040 			retval = cperf_opts_parse_long(opt_idx, options);
1041 			if (retval != 0)
1042 				return retval;
1043 
1044 			break;
1045 
1046 		default:
1047 			usage(argv[0]);
1048 			return -EINVAL;
1049 		}
1050 	}
1051 
1052 	return 0;
1053 }
1054 
1055 static int
1056 check_cipher_buffer_length(struct cperf_options *options)
1057 {
1058 	uint32_t buffer_size, buffer_size_idx = 0;
1059 
1060 	if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC ||
1061 			options->cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) {
1062 		if (options->inc_buffer_size != 0)
1063 			buffer_size = options->min_buffer_size;
1064 		else
1065 			buffer_size = options->buffer_size_list[0];
1066 
1067 		while (buffer_size <= options->max_buffer_size) {
1068 			if ((buffer_size % AES_BLOCK_SIZE) != 0) {
1069 				RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
1070 					"not suitable for the algorithm selected\n");
1071 				return -EINVAL;
1072 			}
1073 
1074 			if (options->inc_buffer_size != 0)
1075 				buffer_size += options->inc_buffer_size;
1076 			else {
1077 				if (++buffer_size_idx == options->buffer_size_count)
1078 					break;
1079 				buffer_size = options->buffer_size_list[buffer_size_idx];
1080 			}
1081 
1082 		}
1083 	}
1084 
1085 	if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC ||
1086 			options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC ||
1087 			options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) {
1088 		if (options->inc_buffer_size != 0)
1089 			buffer_size = options->min_buffer_size;
1090 		else
1091 			buffer_size = options->buffer_size_list[0];
1092 
1093 		while (buffer_size <= options->max_buffer_size) {
1094 			if ((buffer_size % DES_BLOCK_SIZE) != 0) {
1095 				RTE_LOG(ERR, USER1, "Some of the buffer sizes are "
1096 					"not suitable for the algorithm selected\n");
1097 				return -EINVAL;
1098 			}
1099 
1100 			if (options->inc_buffer_size != 0)
1101 				buffer_size += options->inc_buffer_size;
1102 			else {
1103 				if (++buffer_size_idx == options->buffer_size_count)
1104 					break;
1105 				buffer_size = options->buffer_size_list[buffer_size_idx];
1106 			}
1107 
1108 		}
1109 	}
1110 
1111 	return 0;
1112 }
1113 
1114 #ifdef RTE_LIB_SECURITY
1115 static int
1116 check_docsis_buffer_length(struct cperf_options *options)
1117 {
1118 	uint32_t buffer_size, buffer_size_idx = 0;
1119 
1120 	if (options->inc_buffer_size != 0)
1121 		buffer_size = options->min_buffer_size;
1122 	else
1123 		buffer_size = options->buffer_size_list[0];
1124 
1125 	while (buffer_size <= options->max_buffer_size) {
1126 		if (buffer_size < (uint32_t)(options->docsis_hdr_sz +
1127 				RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN)) {
1128 			RTE_LOG(ERR, USER1, "Some of the buffer sizes are not "
1129 				"valid for DOCSIS\n");
1130 			return -EINVAL;
1131 		}
1132 
1133 		if (options->inc_buffer_size != 0)
1134 			buffer_size += options->inc_buffer_size;
1135 		else {
1136 			if (++buffer_size_idx == options->buffer_size_count)
1137 				break;
1138 			buffer_size =
1139 				options->buffer_size_list[buffer_size_idx];
1140 		}
1141 	}
1142 
1143 	return 0;
1144 }
1145 #endif
1146 
1147 static bool
1148 is_valid_chained_op(struct cperf_options *options)
1149 {
1150 	if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
1151 			options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
1152 		return true;
1153 
1154 	if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT &&
1155 			options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY)
1156 		return true;
1157 
1158 	return false;
1159 }
1160 
1161 int
1162 cperf_options_check(struct cperf_options *options)
1163 {
1164 	int i;
1165 
1166 	if (options->op_type == CPERF_CIPHER_ONLY ||
1167 			options->op_type == CPERF_DOCSIS)
1168 		options->digest_sz = 0;
1169 
1170 	if (options->out_of_place &&
1171 			options->segment_sz <= options->max_buffer_size) {
1172 		RTE_LOG(ERR, USER1, "Out of place mode can only work "
1173 					"with non segmented buffers\n");
1174 		return -EINVAL;
1175 	}
1176 
1177 	/*
1178 	 * If segment size is not set, assume only one segment,
1179 	 * big enough to contain the largest buffer and the digest
1180 	 */
1181 	if (options->segment_sz == 0) {
1182 		options->segment_sz = options->max_buffer_size +
1183 				options->digest_sz;
1184 		/* In IPsec operation, packet length will be increased
1185 		 * by some bytes depend upon the algorithm, so increasing
1186 		 * the segment size by headroom to cover most of
1187 		 * the scenarios.
1188 		 */
1189 		if (options->op_type == CPERF_IPSEC)
1190 			options->segment_sz += RTE_PKTMBUF_HEADROOM;
1191 	}
1192 
1193 	if (options->segment_sz < options->digest_sz) {
1194 		RTE_LOG(ERR, USER1,
1195 				"Segment size should be at least "
1196 				"the size of the digest\n");
1197 		return -EINVAL;
1198 	}
1199 
1200 	if ((options->imix_distribution_count != 0) &&
1201 			(options->imix_distribution_count !=
1202 				options->buffer_size_count)) {
1203 		RTE_LOG(ERR, USER1, "IMIX distribution must have the same "
1204 				"number of buffer sizes\n");
1205 		return -EINVAL;
1206 	}
1207 
1208 	if (options->test == CPERF_TEST_TYPE_VERIFY &&
1209 			options->test_file == NULL) {
1210 		RTE_LOG(ERR, USER1, "Define path to the file with test"
1211 				" vectors.\n");
1212 		return -EINVAL;
1213 	}
1214 
1215 	if (options->test == CPERF_TEST_TYPE_VERIFY &&
1216 			options->op_type != CPERF_CIPHER_ONLY &&
1217 			options->test_name == NULL) {
1218 		RTE_LOG(ERR, USER1, "Define test name to get the correct digest"
1219 				" from the test vectors.\n");
1220 		return -EINVAL;
1221 	}
1222 
1223 	if (options->test_name != NULL && options->test_file == NULL) {
1224 		RTE_LOG(ERR, USER1, "Define path to the file with test"
1225 				" vectors.\n");
1226 		return -EINVAL;
1227 	}
1228 
1229 	if (options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY &&
1230 			options->test_file == NULL) {
1231 		RTE_LOG(ERR, USER1, "Define path to the file with test"
1232 				" vectors.\n");
1233 		return -EINVAL;
1234 	}
1235 
1236 	if (options->test == CPERF_TEST_TYPE_VERIFY &&
1237 			(options->inc_buffer_size != 0 ||
1238 			options->buffer_size_count > 1)) {
1239 		RTE_LOG(ERR, USER1, "Only one buffer size is allowed when "
1240 				"using the verify test.\n");
1241 		return -EINVAL;
1242 	}
1243 
1244 	if (options->test == CPERF_TEST_TYPE_VERIFY &&
1245 			(options->inc_burst_size != 0 ||
1246 			options->burst_size_count > 1)) {
1247 		RTE_LOG(ERR, USER1, "Only one burst size is allowed when "
1248 				"using the verify test.\n");
1249 		return -EINVAL;
1250 	}
1251 
1252 	if (options->test == CPERF_TEST_TYPE_PMDCC &&
1253 			options->pool_sz < options->nb_descriptors) {
1254 		RTE_LOG(ERR, USER1, "For pmd cyclecount benchmarks, pool size "
1255 				"must be equal or greater than the number of "
1256 				"cryptodev descriptors.\n");
1257 		return -EINVAL;
1258 	}
1259 
1260 	if (options->test == CPERF_TEST_TYPE_VERIFY &&
1261 			options->imix_distribution_count > 0) {
1262 		RTE_LOG(ERR, USER1, "IMIX is not allowed when "
1263 				"using the verify test.\n");
1264 		return -EINVAL;
1265 	}
1266 
1267 	if (options->op_type == CPERF_CIPHER_THEN_AUTH ||
1268 			options->op_type == CPERF_AUTH_THEN_CIPHER) {
1269 		if (!is_valid_chained_op(options)) {
1270 			RTE_LOG(ERR, USER1, "Invalid chained operation.\n");
1271 			return -EINVAL;
1272 		}
1273 	}
1274 
1275 	if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
1276 		if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
1277 				options->auth_op !=
1278 				RTE_CRYPTO_AUTH_OP_GENERATE) {
1279 			RTE_LOG(ERR, USER1, "Option cipher then auth must use"
1280 					" options: encrypt and generate.\n");
1281 			return -EINVAL;
1282 		}
1283 	}
1284 
1285 	if (options->op_type == CPERF_CIPHER_ONLY ||
1286 			options->op_type == CPERF_CIPHER_THEN_AUTH ||
1287 			options->op_type == CPERF_AUTH_THEN_CIPHER) {
1288 		if (check_cipher_buffer_length(options) < 0)
1289 			return -EINVAL;
1290 	}
1291 
1292 	if (options->modex_len) {
1293 		if (options->op_type != CPERF_ASYM_MODEX) {
1294 			RTE_LOG(ERR, USER1, "Option modex len should be used only with "
1295 					" optype: modex.\n");
1296 			return -EINVAL;
1297 		}
1298 
1299 		for (i = 0; i < (int)RTE_DIM(modex_perf_data); i++) {
1300 			if (modex_perf_data[i].modulus.len ==
1301 			    options->modex_len) {
1302 				options->modex_data =
1303 					(struct cperf_modex_test_data
1304 						 *)&modex_perf_data[i];
1305 				break;
1306 			}
1307 		}
1308 		if (i == (int)RTE_DIM(modex_perf_data)) {
1309 			RTE_LOG(ERR, USER1,
1310 				"Option modex len: %d is not supported\n",
1311 				options->modex_len);
1312 			return -EINVAL;
1313 		}
1314 	}
1315 
1316 #ifdef RTE_LIB_SECURITY
1317 	if (options->op_type == CPERF_DOCSIS) {
1318 		if (check_docsis_buffer_length(options) < 0)
1319 			return -EINVAL;
1320 	}
1321 
1322 	if (options->op_type == CPERF_IPSEC) {
1323 		if (options->aead_algo) {
1324 			if (options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT)
1325 				options->is_outbound = 1;
1326 			else
1327 				options->is_outbound = 0;
1328 		} else {
1329 			if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
1330 			    options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
1331 				options->is_outbound = 1;
1332 			else
1333 				options->is_outbound = 0;
1334 		}
1335 	}
1336 #endif
1337 
1338 	return 0;
1339 }
1340 
1341 void
1342 cperf_options_dump(struct cperf_options *opts)
1343 {
1344 	uint8_t size_idx;
1345 
1346 	printf("# Crypto Performance Application Options:\n");
1347 	printf("#\n");
1348 	printf("# cperf test: %s\n", cperf_test_type_strs[opts->test]);
1349 	printf("#\n");
1350 	printf("# size of crypto op / mbuf pool: %u\n", opts->pool_sz);
1351 	printf("# total number of ops: %u\n", opts->total_ops);
1352 	if (opts->inc_buffer_size != 0) {
1353 		printf("# buffer size:\n");
1354 		printf("#\t min: %u\n", opts->min_buffer_size);
1355 		printf("#\t max: %u\n", opts->max_buffer_size);
1356 		printf("#\t inc: %u\n", opts->inc_buffer_size);
1357 	} else {
1358 		printf("# buffer sizes: ");
1359 		for (size_idx = 0; size_idx < opts->buffer_size_count; size_idx++)
1360 			printf("%u ", opts->buffer_size_list[size_idx]);
1361 		printf("\n");
1362 	}
1363 	if (opts->inc_burst_size != 0) {
1364 		printf("# burst size:\n");
1365 		printf("#\t min: %u\n", opts->min_burst_size);
1366 		printf("#\t max: %u\n", opts->max_burst_size);
1367 		printf("#\t inc: %u\n", opts->inc_burst_size);
1368 	} else {
1369 		printf("# burst sizes: ");
1370 		for (size_idx = 0; size_idx < opts->burst_size_count; size_idx++)
1371 			printf("%u ", opts->burst_size_list[size_idx]);
1372 		printf("\n");
1373 	}
1374 	printf("\n# segment size: %u\n", opts->segment_sz);
1375 	printf("#\n");
1376 	printf("# cryptodev type: %s\n", opts->device_type);
1377 	printf("#\n");
1378 	printf("# number of queue pairs per device: %u\n", opts->nb_qps);
1379 	printf("# crypto operation: %s\n", cperf_op_type_strs[opts->op_type]);
1380 	printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");
1381 	printf("# out of place: %s\n", opts->out_of_place ? "yes" : "no");
1382 	if (opts->test == CPERF_TEST_TYPE_PMDCC)
1383 		printf("# inter-burst delay: %u ms\n", opts->pmdcc_delay);
1384 
1385 	printf("#\n");
1386 
1387 	if (opts->op_type == CPERF_AUTH_ONLY ||
1388 			opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1389 			opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1390 		printf("# auth algorithm: %s\n",
1391 			rte_cryptodev_get_auth_algo_string(opts->auth_algo));
1392 		printf("# auth operation: %s\n",
1393 			rte_crypto_auth_operation_strings[opts->auth_op]);
1394 		printf("# auth key size: %u\n", opts->auth_key_sz);
1395 		printf("# auth iv size: %u\n", opts->auth_iv_sz);
1396 		printf("# auth digest size: %u\n", opts->digest_sz);
1397 		printf("#\n");
1398 	}
1399 
1400 	if (opts->op_type == CPERF_CIPHER_ONLY ||
1401 			opts->op_type == CPERF_CIPHER_THEN_AUTH ||
1402 			opts->op_type == CPERF_AUTH_THEN_CIPHER) {
1403 		printf("# cipher algorithm: %s\n",
1404 			rte_cryptodev_get_cipher_algo_string(opts->cipher_algo));
1405 		printf("# cipher operation: %s\n",
1406 			rte_crypto_cipher_operation_strings[opts->cipher_op]);
1407 		printf("# cipher key size: %u\n", opts->cipher_key_sz);
1408 		printf("# cipher iv size: %u\n", opts->cipher_iv_sz);
1409 		printf("#\n");
1410 	}
1411 
1412 	if (opts->op_type == CPERF_AEAD) {
1413 		printf("# aead algorithm: %s\n",
1414 			rte_cryptodev_get_aead_algo_string(opts->aead_algo));
1415 		printf("# aead operation: %s\n",
1416 			rte_crypto_aead_operation_strings[opts->aead_op]);
1417 		printf("# aead key size: %u\n", opts->aead_key_sz);
1418 		printf("# aead iv size: %u\n", opts->aead_iv_sz);
1419 		printf("# aead digest size: %u\n", opts->digest_sz);
1420 		printf("# aead aad size: %u\n", opts->aead_aad_sz);
1421 		printf("#\n");
1422 	}
1423 
1424 #ifdef RTE_LIB_SECURITY
1425 	if (opts->op_type == CPERF_DOCSIS) {
1426 		printf("# docsis header size: %u\n", opts->docsis_hdr_sz);
1427 		printf("#\n");
1428 	}
1429 #endif
1430 }
1431