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