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