API Reference Manual 1.51.0
Loading...
Searching...
No Matches
odp_crypto.c
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2015-2018 Linaro Limited
3 * Copyright (c) 2021-2026 Nokia
4 */
5
14#ifndef _GNU_SOURCE
15#define _GNU_SOURCE
16#endif /* _GNU_SOURCE */
17
18#include <stdlib.h>
19#include <string.h>
20#include <getopt.h>
21#include <unistd.h>
22#include <stdio.h>
23#include <sys/time.h>
24#include <sys/resource.h>
25
26#include <odp_api.h>
27#include <odp/helper/odph_api.h>
28
32#define POOL_NUM_PKT 64
33
34#define AAD_LEN 8 /* typical AAD length used in IPsec when ESN is not in use */
35#define MAX_AUTH_DIGEST_LEN 32 /* maximum MAC length in bytes */
36
37static uint8_t test_aad[AAD_LEN] = {1, 2, 3, 4, 5, 6, 7, 8};
38static uint8_t test_iv[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
39
40static uint8_t test_key16[16] = { 0x01, 0x02, 0x03, 0x04, 0x05,
41 0x06, 0x07, 0x08, 0x09, 0x0a,
42 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
43 0x10,
44};
45
46static uint8_t test_key20[20] = { 0x01, 0x02, 0x03, 0x04, 0x05,
47 0x06, 0x07, 0x08, 0x09, 0x0a,
48 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
49 0x10, 0x11, 0x12, 0x13, 0x14,
50};
51
52static uint8_t test_key24[24] = { 0x01, 0x02, 0x03, 0x04, 0x05,
53 0x06, 0x07, 0x08, 0x09, 0x0a,
54 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
55 0x10, 0x11, 0x12, 0x13, 0x14,
56 0x15, 0x16, 0x17, 0x18
57};
58
59static uint8_t test_key32[32] = { 0x01, 0x02, 0x03, 0x04, 0x05,
60 0x06, 0x07, 0x08, 0x09, 0x0a,
61 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
62 0x10, 0x11, 0x12, 0x13, 0x14,
63 0x15, 0x16, 0x17, 0x18, 0x19,
64 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
65 0x1f, 0x20,
66};
67
68static uint8_t test_key64[64] = { 0x01, 0x02, 0x03, 0x04, 0x05,
69 0x06, 0x07, 0x08, 0x09, 0x0a,
70 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
71 0x10, 0x11, 0x12, 0x13, 0x14,
72 0x15, 0x16, 0x17, 0x18, 0x19,
73 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
74 0x1f, 0x20, 0x21, 0x22, 0x23,
75 0x24, 0x25, 0x26, 0x27, 0x28,
76 0x29, 0x2a, 0x4b, 0x2c, 0x2d,
77 0x2e, 0x2f, 0x30, 0x31, 0x32,
78 0x33, 0x34, 0x55, 0x36, 0x37,
79 0x38, 0x39, 0x5a, 0x3b, 0x3c,
80 0x3d, 0x3e, 0x5f, 0x40,
81};
82
87typedef struct {
88 const char *name;
90 int cipher_in_bit_mode;
91 int auth_in_bit_mode;
92} crypto_alg_config_t;
93
97typedef struct {
102 int debug_packets;
103
108 int reuse_packet;
109
116 int in_flight;
117
123 int iteration_count;
124
128 int max_sessions;
129
134 int payload_length;
135
141 crypto_alg_config_t *alg_config;
142
147 int schedule;
148
149 /*
150 * Poll completion queue for crypto completion events.
151 * Specified through -p argument.
152 */
153 int poll;
154} crypto_args_t;
155
156/*
157 * Helper structure that holds averages for test of one algorithm
158 * for given payload size.
159 */
160typedef struct {
164 double elapsed;
165
171 double rusage_self;
172
178 double rusage_thread;
179} crypto_run_result_t;
180
184typedef struct {
185 struct timeval tv;
186 struct rusage ru_self;
187 struct rusage ru_thread;
188} time_record_t;
189
190/* Arguments for one test run */
191typedef struct test_run_arg_t {
192 crypto_args_t crypto_args;
193 crypto_alg_config_t *crypto_alg_config;
194 odp_crypto_capability_t crypto_capa;
195
196} test_run_arg_t;
197
198static void parse_args(int argc, char *argv[], crypto_args_t *cargs);
199static void usage(char *progname);
200
204static unsigned int payloads[] = {
205 16,
206 64,
207 256,
208 1024,
209 8192,
210 16384
211};
212
214static unsigned num_payloads;
215
219static crypto_alg_config_t algs_config[] = {
220 {
221 .name = "3des-cbc-null",
222 .session = {
223 .cipher_alg = ODP_CIPHER_ALG_3DES_CBC,
224 .cipher_key = {
225 .data = test_key24,
226 .length = sizeof(test_key24)
227 },
228 .cipher_iv_len = 8,
229 .auth_alg = ODP_AUTH_ALG_NULL
230 },
231 },
232 {
233 .name = "3des-cbc-hmac-md5-96",
234 .session = {
235 .cipher_alg = ODP_CIPHER_ALG_3DES_CBC,
236 .cipher_key = {
237 .data = test_key24,
238 .length = sizeof(test_key24)
239 },
240 .cipher_iv_len = 8,
241 .auth_alg = ODP_AUTH_ALG_MD5_HMAC,
242 .auth_key = {
243 .data = test_key16,
244 .length = sizeof(test_key16)
245 },
246 .auth_digest_len = 12,
247 },
248 },
249 {
250 .name = "null-hmac-md5-96",
251 .session = {
252 .cipher_alg = ODP_CIPHER_ALG_NULL,
253 .auth_alg = ODP_AUTH_ALG_MD5_HMAC,
254 .auth_key = {
255 .data = test_key16,
256 .length = sizeof(test_key16)
257 },
258 .auth_digest_len = 12,
259 },
260 },
261 {
262 .name = "aes-cbc-null",
263 .session = {
264 .cipher_alg = ODP_CIPHER_ALG_AES_CBC,
265 .cipher_key = {
266 .data = test_key16,
267 .length = sizeof(test_key16)
268 },
269 .cipher_iv_len = 16,
270 .auth_alg = ODP_AUTH_ALG_NULL
271 },
272 },
273 {
274 .name = "aes-cbc-hmac-sha1-96",
275 .session = {
276 .cipher_alg = ODP_CIPHER_ALG_AES_CBC,
277 .cipher_key = {
278 .data = test_key16,
279 .length = sizeof(test_key16)
280 },
281 .cipher_iv_len = 16,
282 .auth_alg = ODP_AUTH_ALG_SHA1_HMAC,
283 .auth_key = {
284 .data = test_key20,
285 .length = sizeof(test_key20)
286 },
287 .auth_digest_len = 12,
288 },
289 },
290 {
291 .name = "null-hmac-sha1-96",
292 .session = {
293 .cipher_alg = ODP_CIPHER_ALG_NULL,
294 .auth_alg = ODP_AUTH_ALG_SHA1_HMAC,
295 .auth_key = {
296 .data = test_key20,
297 .length = sizeof(test_key20)
298 },
299 .auth_digest_len = 12,
300 },
301 },
302 {
303 .name = "aes-ctr-null",
304 .session = {
305 .cipher_alg = ODP_CIPHER_ALG_AES_CTR,
306 .cipher_key = {
307 .data = test_key16,
308 .length = sizeof(test_key16)
309 },
310 .cipher_iv_len = 16,
311 .auth_alg = ODP_AUTH_ALG_NULL
312 },
313 },
314 {
315 .name = "aes-ctr-hmac-sha1-96",
316 .session = {
317 .cipher_alg = ODP_CIPHER_ALG_AES_CTR,
318 .cipher_key = {
319 .data = test_key16,
320 .length = sizeof(test_key16)
321 },
322 .cipher_iv_len = 16,
323 .auth_alg = ODP_AUTH_ALG_SHA1_HMAC,
324 .auth_key = {
325 .data = test_key20,
326 .length = sizeof(test_key20)
327 },
328 .auth_digest_len = 12,
329 },
330 },
331 {
332 .name = "null-hmac-sha256-128",
333 .session = {
334 .cipher_alg = ODP_CIPHER_ALG_NULL,
335 .auth_alg = ODP_AUTH_ALG_SHA256_HMAC,
336 .auth_key = {
337 .data = test_key32,
338 .length = sizeof(test_key32)
339 },
340 .auth_digest_len = 16,
341 },
342 },
343 {
344 .name = "null-hmac-sha512-256",
345 .session = {
346 .cipher_alg = ODP_CIPHER_ALG_NULL,
347 .auth_alg = ODP_AUTH_ALG_SHA512_HMAC,
348 .auth_key = {
349 .data = test_key64,
350 .length = sizeof(test_key64)
351 },
352 .auth_digest_len = 32,
353 },
354 },
355 {
356 .name = "null-aes-gmac",
357 .session = {
358 .cipher_alg = ODP_CIPHER_ALG_NULL,
359 .auth_alg = ODP_AUTH_ALG_AES_GMAC,
360 .auth_key = {
361 .data = test_key16,
362 .length = sizeof(test_key16)
363 },
364 .auth_iv_len = 12,
365 .auth_digest_len = 16,
366 },
367 },
368 {
369 .name = "aes-gcm",
370 .session = {
371 .cipher_alg = ODP_CIPHER_ALG_AES_GCM,
372 .cipher_key = {
373 .data = test_key16,
374 .length = sizeof(test_key16)
375 },
376 .cipher_iv_len = 12,
377 .auth_alg = ODP_AUTH_ALG_AES_GCM,
378 .auth_digest_len = 16,
379 .auth_aad_len = AAD_LEN,
380 },
381 },
382 {
383 .name = "aes-ccm",
384 .session = {
385 .cipher_alg = ODP_CIPHER_ALG_AES_CCM,
386 .cipher_key = {
387 .data = test_key16,
388 .length = sizeof(test_key16)
389 },
390 .cipher_iv_len = 11,
391 .auth_alg = ODP_AUTH_ALG_AES_CCM,
392 .auth_digest_len = 16,
393 .auth_aad_len = AAD_LEN,
394 },
395 },
396 {
397 .name = "chacha20-poly1305",
398 .session = {
400 .cipher_key = {
401 .data = test_key32,
402 .length = sizeof(test_key32)
403 },
404 .cipher_iv_len = 12,
406 .auth_digest_len = 16,
407 .auth_aad_len = AAD_LEN,
408 },
409 },
410 {
411 .name = "zuc-eea3",
412 .session = {
413 .cipher_alg = ODP_CIPHER_ALG_ZUC_EEA3,
414 .cipher_key = {
415 .data = test_key16,
416 .length = sizeof(test_key16)
417 },
418 .cipher_iv_len = 16,
419 .auth_alg = ODP_AUTH_ALG_NULL,
420 },
421 },
422 {
423 .name = "zuc-eia3",
424 .session = {
425 .cipher_alg = ODP_CIPHER_ALG_NULL,
426 .auth_alg = ODP_AUTH_ALG_ZUC_EIA3,
427 .auth_key = {
428 .data = test_key16,
429 .length = sizeof(test_key16)
430 },
431 .auth_iv_len = 16,
432 .auth_digest_len = 4,
433 },
434 },
435 {
436 .name = "zuc-eea3-zuc-eia3",
437 .session = {
438 .cipher_alg = ODP_CIPHER_ALG_ZUC_EEA3,
439 .cipher_key = {
440 .data = test_key16,
441 .length = sizeof(test_key16)
442 },
443 .cipher_iv_len = 16,
444 .auth_alg = ODP_AUTH_ALG_ZUC_EIA3,
445 .auth_key = {
446 .data = test_key16,
447 .length = sizeof(test_key16)
448 },
449 .auth_iv_len = 16,
450 .auth_digest_len = 4,
451 },
452 },
453 {
454 .name = "snow3g-uea2",
455 .session = {
456 .cipher_alg = ODP_CIPHER_ALG_SNOW3G_UEA2,
457 .cipher_key = {
458 .data = test_key16,
459 .length = sizeof(test_key16)
460 },
461 .cipher_iv_len = 16,
462 .auth_alg = ODP_AUTH_ALG_NULL,
463 },
464 },
465 {
466 .name = "snow3g-uia2",
467 .session = {
468 .cipher_alg = ODP_CIPHER_ALG_NULL,
469 .auth_alg = ODP_AUTH_ALG_SNOW3G_UIA2,
470 .auth_key = {
471 .data = test_key16,
472 .length = sizeof(test_key16)
473 },
474 .auth_iv_len = 16,
475 .auth_digest_len = 4,
476 },
477 },
478 {
479 .name = "snow3g-uea2-snow3g-uia2",
480 .session = {
481 .cipher_alg = ODP_CIPHER_ALG_SNOW3G_UEA2,
482 .cipher_key = {
483 .data = test_key16,
484 .length = sizeof(test_key16)
485 },
486 .cipher_iv_len = 16,
487 .auth_alg = ODP_AUTH_ALG_SNOW3G_UIA2,
488 .auth_key = {
489 .data = test_key16,
490 .length = sizeof(test_key16)
491 },
492 .auth_iv_len = 16,
493 .auth_digest_len = 4,
494 },
495 },
496};
497
502static crypto_alg_config_t *
503find_config_by_name(const char *name) {
504 unsigned int i;
505 crypto_alg_config_t *ret = NULL;
506
507 for (i = 0; i < ODPH_ARRAY_SIZE(algs_config); i++) {
508 if (strcmp(algs_config[i].name, name) == 0) {
509 ret = algs_config + i;
510 break;
511 }
512 }
513 return ret;
514}
515
520static void
521print_config_names(const char *prefix) {
522 unsigned int i;
523
524 for (i = 0; i < ODPH_ARRAY_SIZE(algs_config); i++)
525 printf("%s %s\n", prefix, algs_config[i].name);
526}
527
531static void
532fill_time_record(time_record_t *rec)
533{
534 gettimeofday(&rec->tv, NULL);
535 getrusage(RUSAGE_SELF, &rec->ru_self);
536 getrusage(RUSAGE_THREAD, &rec->ru_thread);
537}
538
543static unsigned long long
544get_rusage_diff(struct rusage *start, struct rusage *end)
545{
546 unsigned long long rusage_diff;
547 unsigned long long rusage_start;
548 unsigned long long rusage_end;
549
550 rusage_start = (start->ru_utime.tv_sec * 1000000) +
551 (start->ru_utime.tv_usec);
552 rusage_start += (start->ru_stime.tv_sec * 1000000) +
553 (start->ru_stime.tv_usec);
554
555 rusage_end = (end->ru_utime.tv_sec * 1000000) +
556 (end->ru_utime.tv_usec);
557 rusage_end += (end->ru_stime.tv_sec * 1000000) +
558 (end->ru_stime.tv_usec);
559
560 rusage_diff = rusage_end - rusage_start;
561
562 return rusage_diff;
563}
564
569static unsigned long long
570get_rusage_self_diff(time_record_t *start, time_record_t *end)
571{
572 return get_rusage_diff(&start->ru_self, &end->ru_self);
573}
574
579static unsigned long long
580get_rusage_thread_diff(time_record_t *start, time_record_t *end)
581{
582 return get_rusage_diff(&start->ru_thread, &end->ru_thread);
583}
584
588static unsigned long long
589get_elapsed_usec(time_record_t *start, time_record_t *end)
590{
591 unsigned long long s;
592 unsigned long long e;
593
594 s = (start->tv.tv_sec * 1000000) +
595 (start->tv.tv_usec);
596 e = (end->tv.tv_sec * 1000000) +
597 (end->tv.tv_usec);
598
599 return e - s;
600}
601
602#define REPORT_HEADER "%30.30s %15s %15s %15s %15s %15s %15s\n"
603#define REPORT_LINE "%30.30s %15d %15d %15.3f %15.3f %15.3f %15d\n"
604
608static void
609print_result_header(void)
610{
611 printf(REPORT_HEADER,
612 "algorithm", "avg over #", "payload (bytes)", "elapsed (us)",
613 "rusg self (us)", "rusg thrd (us)", "throughput (Kb)");
614}
615
619static void
620print_result(crypto_args_t *cargs,
621 unsigned int payload_length,
622 crypto_alg_config_t *config,
623 crypto_run_result_t *result)
624{
625 unsigned int throughput;
626
627 throughput = (1000000.0 / result->elapsed) * payload_length / 1024;
628 printf(REPORT_LINE,
629 config->name, cargs->iteration_count, payload_length,
630 result->elapsed, result->rusage_self, result->rusage_thread,
631 throughput);
632}
633
637static void
638print_mem(const char *msg,
639 const unsigned char *ptr,
640 unsigned int len)
641{
642 unsigned i, j;
643 char c;
644 char line[81];
645 char *p;
646
647 if (msg)
648 printf("\n%s (bytes size = %d)", msg, len);
649
650 for (i = 0; i < len; i += 16) {
651 p = line;
652 sprintf(p, "\n%04x ", i); p += 8;
653
654 for (j = 0; j < 16; j++) {
655 if (i + j == len)
656 break;
657
658 sprintf(p, " %02x", (ptr)[i + j]); p += 3;
659 }
660
661 for (; j < 16; j++) {
662 sprintf(p, " "); p += 3;
663 }
664
665 sprintf(p, " "); p += 3;
666
667 for (j = 0; j < 16; j++) {
668 if (i + j == len)
669 break;
670 c = (ptr)[i + j];
671 *p++ = (' ' <= c && c <= '~') ? c : '.';
672 }
673
674 *p = '\0';
675 printf("%s", line);
676 }
677 printf("\n");
678}
679
683static int
684create_session_from_config(odp_crypto_session_t *session,
685 crypto_alg_config_t *config,
686 crypto_args_t *cargs)
687{
689 odp_crypto_ses_create_err_t ses_create_rc;
690 odp_queue_t out_queue;
691
693
694 params.cipher_alg = config->session.cipher_alg;
695 params.cipher_key = config->session.cipher_key;
696 params.cipher_iv_len = config->session.cipher_iv_len;
697 params.auth_alg = config->session.auth_alg;
698 params.auth_key = config->session.auth_key;
699 params.auth_digest_len = config->session.auth_digest_len;
700 params.auth_aad_len = config->session.auth_aad_len;
701
702 params.op = ODP_CRYPTO_OP_ENCODE;
704 params.auth_cipher_text = true;
705
706 if (cargs->schedule || cargs->poll) {
707 out_queue = odp_queue_lookup("crypto-out");
708 if (out_queue == ODP_QUEUE_INVALID) {
709 ODPH_ERR("crypto-out queue not found\n");
710 return -1;
711 }
712 params.compl_queue = out_queue;
713 params.op_mode = ODP_CRYPTO_ASYNC;
714 } else {
716 params.op_mode = ODP_CRYPTO_SYNC;
717 }
718 if (odp_crypto_session_create(&params, session,
719 &ses_create_rc)) {
720 switch (ses_create_rc) {
722 printf(" requested algorithm combination not supported\n");
723 return 1;
725 printf(" requested algorithm order not supported\n");
726 return 1;
728 printf(" requested session parameters not supported\n");
729 return 1;
730 default:
731 break;
732 }
733 ODPH_ERR("crypto session create failed.\n");
734 return -1;
735 }
736
737 return 0;
738}
739
740static odp_packet_t
741make_packet(odp_pool_t pkt_pool, unsigned int payload_length)
742{
743 odp_packet_t pkt;
744
745 pkt = odp_packet_alloc(pkt_pool, payload_length);
746 if (pkt == ODP_PACKET_INVALID) {
747 ODPH_ERR("failed to allocate buffer\n");
748 return pkt;
749 }
750
751 void *mem = odp_packet_data(pkt);
752
753 memset(mem, 1, payload_length);
754
755 return pkt;
756}
757
762static int
763run_measure_one(crypto_args_t *cargs,
764 crypto_alg_config_t *config,
765 odp_crypto_session_t *session,
766 unsigned int payload_length,
767 crypto_run_result_t *result)
768{
770
771 odp_pool_t pkt_pool;
772 odp_queue_t out_queue;
774 int rc = 0;
775 uint32_t packet_len = payload_length + MAX_AUTH_DIGEST_LEN;
776
777 pkt_pool = odp_pool_lookup("packet_pool");
778 if (pkt_pool == ODP_POOL_INVALID) {
779 ODPH_ERR("pkt_pool not found\n");
780 return -1;
781 }
782
783 out_queue = odp_queue_lookup("crypto-out");
784 if (cargs->schedule || cargs->poll) {
785 if (out_queue == ODP_QUEUE_INVALID) {
786 ODPH_ERR("crypto-out queue not found\n");
787 return -1;
788 }
789 }
790
791 if (cargs->reuse_packet) {
792 pkt = make_packet(pkt_pool, packet_len);
793 if (ODP_PACKET_INVALID == pkt)
794 return -1;
795 }
796
797 time_record_t start, end;
798 int packets_sent = 0;
799 int packets_received = 0;
800
801 /* Initialize parameters block */
802 memset(&params, 0, sizeof(params));
803 params.session = *session;
804 params.cipher_iv_ptr = test_iv;
805 params.auth_iv_ptr = test_iv;
806 params.aad_ptr = test_aad;
807
808 params.cipher_range.offset = 0;
809 params.cipher_range.length = config->cipher_in_bit_mode ? payload_length * 8
810 : payload_length;
811 params.auth_range.offset = 0;
812 params.auth_range.length = config->auth_in_bit_mode ? payload_length * 8
813 : payload_length;
814 params.hash_result_offset = payload_length;
815
816 fill_time_record(&start);
817
818 while ((packets_sent < cargs->iteration_count) ||
819 (packets_received < cargs->iteration_count)) {
820 void *mem;
821
822 if ((packets_sent < cargs->iteration_count) &&
823 (packets_sent - packets_received <
824 cargs->in_flight)) {
825 odp_packet_t out_pkt;
826
827 if (!cargs->reuse_packet) {
828 pkt = make_packet(pkt_pool, packet_len);
829 if (ODP_PACKET_INVALID == pkt)
830 return -1;
831 }
832
833 if (cargs->debug_packets) {
834 mem = odp_packet_data(pkt);
835 print_mem("Packet before encryption:",
836 mem, payload_length);
837 }
838
839 if (cargs->schedule || cargs->poll) {
840 rc = odp_crypto_op_enq(&pkt, NULL, &params, 1);
841 if (rc <= 0) {
842 ODPH_ERR("failed odp_crypto_packet_op_enq: rc = %d\n", rc);
843 if (!cargs->reuse_packet)
844 odp_packet_free(pkt);
845 break;
846 }
847 packets_sent += rc;
848 } else {
849 rc = odp_crypto_op(&pkt, &out_pkt,
850 &params, 1);
851 if (rc <= 0) {
852 ODPH_ERR("failed odp_crypto_packet_op: rc = %d\n", rc);
853 if (!cargs->reuse_packet)
854 odp_packet_free(pkt);
855 break;
856 }
857 packets_sent += rc;
858 packets_received++;
859 if (odp_unlikely(odp_crypto_result(NULL, out_pkt) != 0)) {
860 ODPH_ERR("Crypto operation failed\n");
861 odp_packet_free(out_pkt);
862 return -1;
863 }
864 if (cargs->debug_packets) {
865 mem = odp_packet_data(out_pkt);
866 print_mem("Immediately encrypted "
867 "packet",
868 mem,
869 payload_length +
870 config->session.
871 auth_digest_len);
872 }
873 if (cargs->reuse_packet)
874 pkt = out_pkt;
875 else
876 odp_packet_free(out_pkt);
877 }
878 }
879
880 if (cargs->schedule || cargs->poll) {
881 odp_event_t ev;
882 odp_packet_t out_pkt;
883
884 if (cargs->schedule)
885 ev = odp_schedule(NULL,
887 else
888 ev = odp_queue_deq(out_queue);
889
890 while (ev != ODP_EVENT_INVALID) {
891 out_pkt = odp_crypto_packet_from_event(ev);
892 if (odp_unlikely(odp_crypto_result(NULL, out_pkt) != 0)) {
893 ODPH_ERR("Crypto operation failed\n");
894 odp_packet_free(out_pkt);
895 return -1;
896 }
897 if (cargs->debug_packets) {
898 mem = odp_packet_data(out_pkt);
899 print_mem("Received encrypted packet",
900 mem,
901 payload_length +
902 config->
903 session.auth_digest_len);
904 }
905 if (cargs->reuse_packet)
906 pkt = out_pkt;
907 else
908 odp_packet_free(out_pkt);
909 packets_received++;
910 if (cargs->schedule)
911 ev = odp_schedule(NULL,
913 else
914 ev = odp_queue_deq(out_queue);
915 };
916 }
917 }
918
919 fill_time_record(&end);
920
921 {
922 double count;
923
924 count = get_elapsed_usec(&start, &end);
925 result->elapsed = count /
926 cargs->iteration_count;
927
928 count = get_rusage_self_diff(&start, &end);
929 result->rusage_self = count /
930 cargs->iteration_count;
931
932 count = get_rusage_thread_diff(&start, &end);
933 result->rusage_thread = count /
934 cargs->iteration_count;
935 }
936
937 if (cargs->reuse_packet)
938 odp_packet_free(pkt);
939
940 return rc < 0 ? rc : 0;
941}
942
943static int check_cipher_alg(const odp_crypto_capability_t *capa,
945{
946 switch (alg) {
948 if (capa->ciphers.bit.null)
949 return 0;
950 break;
952 if (capa->ciphers.bit.des)
953 return 0;
954 break;
956 if (capa->ciphers.bit.trides_cbc)
957 return 0;
958 break;
960 if (capa->ciphers.bit.aes_cbc)
961 return 0;
962 break;
964 if (capa->ciphers.bit.aes_ctr)
965 return 0;
966 break;
968 if (capa->ciphers.bit.aes_gcm)
969 return 0;
970 break;
972 if (capa->ciphers.bit.aes_ccm)
973 return 0;
974 break;
976 if (capa->ciphers.bit.chacha20_poly1305)
977 return 0;
978 break;
980 if (capa->ciphers.bit.zuc_eea3)
981 return 0;
982 break;
984 if (capa->ciphers.bit.snow3g_uea2)
985 return 0;
986 break;
987 default:
988 break;
989 }
990
991 return -1;
992}
993
994static int check_auth_alg(const odp_crypto_capability_t *capa,
995 odp_auth_alg_t alg)
996{
997 switch (alg) {
999 if (capa->auths.bit.null)
1000 return 0;
1001 break;
1003 if (capa->auths.bit.md5_hmac)
1004 return 0;
1005 break;
1007 if (capa->auths.bit.sha1_hmac)
1008 return 0;
1009 break;
1011 if (capa->auths.bit.sha256_hmac)
1012 return 0;
1013 break;
1015 if (capa->auths.bit.sha384_hmac)
1016 return 0;
1017 break;
1019 if (capa->auths.bit.sha512_hmac)
1020 return 0;
1021 break;
1023 if (capa->auths.bit.aes_gcm)
1024 return 0;
1025 break;
1027 if (capa->auths.bit.aes_gmac)
1028 return 0;
1029 break;
1031 if (capa->auths.bit.aes_ccm)
1032 return 0;
1033 break;
1035 if (capa->auths.bit.chacha20_poly1305)
1036 return 0;
1037 break;
1039 if (capa->auths.bit.zuc_eia3)
1040 return 0;
1041 break;
1043 if (capa->auths.bit.snow3g_uia2)
1044 return 0;
1045 break;
1046 default:
1047 break;
1048 }
1049
1050 return -1;
1051}
1052
1053static int check_cipher_params(const odp_crypto_capability_t *crypto_capa,
1054 const odp_crypto_session_param_t *param,
1055 int *bit_mode)
1056{
1057 int num, rc;
1058
1059 if (check_cipher_alg(crypto_capa, param->cipher_alg))
1060 return 1;
1061
1062 num = odp_crypto_cipher_capability(param->cipher_alg, NULL, 0);
1063 if (num <= 0)
1064 return 1;
1065
1066 odp_crypto_cipher_capability_t cipher_capa[num];
1067
1068 rc = odp_crypto_cipher_capability(param->cipher_alg, cipher_capa, num);
1069 if (rc < num)
1070 num = rc;
1071
1072 for (int n = 0; n < num; n++) {
1073 odp_crypto_cipher_capability_t *capa = &cipher_capa[n];
1074
1075 if (capa->key_len != param->cipher_key.length ||
1076 capa->iv_len != param->cipher_iv_len)
1077 continue;
1078
1079 *bit_mode = capa->bit_mode;
1080 return 0;
1081 }
1082 return 1;
1083}
1084
1085static int aad_len_ok(const odp_crypto_auth_capability_t *capa, uint32_t len)
1086{
1087 if (len < capa->aad_len.min || len > capa->aad_len.max)
1088 return 0;
1089
1090 if (len == capa->aad_len.min)
1091 return 1;
1092 if (capa->aad_len.inc == 0)
1093 return 0;
1094
1095 return ((len - capa->aad_len.min) % capa->aad_len.inc) == 0;
1096}
1097
1098static int check_auth_params(const odp_crypto_capability_t *crypto_capa,
1099 const odp_crypto_session_param_t *param,
1100 int *bit_mode)
1101{
1102 int num, rc;
1103
1104 if (param->auth_digest_len > MAX_AUTH_DIGEST_LEN) {
1105 ODPH_ERR("MAX_AUTH_DIGEST_LEN too low\n");
1106 return 1;
1107 }
1108
1109 if (check_auth_alg(crypto_capa, param->auth_alg))
1110 return 1;
1111
1112 num = odp_crypto_auth_capability(param->auth_alg, NULL, 0);
1113 if (num <= 0)
1114 return 1;
1115
1116 odp_crypto_auth_capability_t auth_capa[num];
1117
1118 rc = odp_crypto_auth_capability(param->auth_alg, auth_capa, num);
1119 if (rc < num)
1120 num = rc;
1121
1122 for (int n = 0; n < num; n++) {
1123 odp_crypto_auth_capability_t *capa = &auth_capa[n];
1124
1125 if (capa->digest_len != param->auth_digest_len ||
1126 capa->key_len != param->auth_key.length ||
1127 capa->iv_len != param->auth_iv_len)
1128 continue;
1129
1130 if (!aad_len_ok(capa, param->auth_aad_len))
1131 continue;
1132
1133 *bit_mode = capa->bit_mode;
1134 return 0;
1135 }
1136 return 1;
1137}
1138
1143static int run_measure_one_config(test_run_arg_t *arg)
1144{
1145 crypto_run_result_t result;
1146 odp_crypto_session_t session;
1147 crypto_args_t *cargs = &arg->crypto_args;
1148 crypto_alg_config_t *config = arg->crypto_alg_config;
1149 odp_crypto_capability_t crypto_capa = arg->crypto_capa;
1150 int rc = 0;
1151
1152 printf("\n");
1153
1154 if (check_cipher_params(&crypto_capa, &config->session,
1155 &config->cipher_in_bit_mode)) {
1156 printf(" Cipher algorithm not supported\n");
1157 rc = 1;
1158 }
1159
1160 if (check_auth_params(&crypto_capa, &config->session,
1161 &config->auth_in_bit_mode)) {
1162 printf(" Auth algorithm not supported\n");
1163 rc = 1;
1164 }
1165
1166#if ODP_VERSION_API >= ODP_VERSION_API_NUM(1, 42, 0)
1167 /* Bit mode ciphers can now be used in byte mode. */
1168 config->cipher_in_bit_mode = 0;
1169 config->auth_in_bit_mode = 0;
1170#endif
1171
1172 if (rc == 0)
1173 rc = create_session_from_config(&session, config, cargs);
1174 if (rc) {
1175 printf(" => %s skipped\n", config->name);
1176 return rc > 0 ? 0 : -1;
1177 }
1178
1179 if (cargs->payload_length) {
1180 rc = run_measure_one(cargs, config, &session,
1181 cargs->payload_length, &result);
1182 if (!rc) {
1183 print_result_header();
1184 print_result(cargs, cargs->payload_length,
1185 config, &result);
1186 }
1187 } else {
1188 unsigned i;
1189
1190 print_result_header();
1191 for (i = 0; i < num_payloads; i++) {
1192 rc = run_measure_one(cargs, config, &session,
1193 payloads[i], &result);
1194 if (rc)
1195 break;
1196 print_result(cargs, payloads[i],
1197 config, &result);
1198 }
1199 }
1200
1202
1203 return rc;
1204}
1205
1206static int run_thr_func(void *arg)
1207{
1208 run_measure_one_config((test_run_arg_t *)arg);
1209 return 0;
1210}
1211
1212int main(int argc, char *argv[])
1213{
1214 crypto_args_t cargs;
1215 odp_pool_t pool;
1216 odp_queue_param_t qparam;
1217 odp_pool_param_t params;
1218 odp_queue_t out_queue = ODP_QUEUE_INVALID;
1219 test_run_arg_t test_run_arg;
1220 odp_cpumask_t cpumask;
1221 char cpumaskstr[ODP_CPUMASK_STR_SIZE];
1222 int num_workers = 1;
1223 odph_helper_options_t helper_options;
1224 odph_thread_t thread_tbl[num_workers];
1225 odph_thread_common_param_t thr_common;
1226 odph_thread_param_t thr_param;
1227 odp_instance_t instance;
1228 odp_init_t init_param;
1229 odp_pool_capability_t pool_capa;
1230 odp_crypto_capability_t crypto_capa;
1231 uint32_t max_seg_len;
1232 uint32_t i;
1233
1234 /* Let helper collect its own arguments (e.g. --odph_proc) */
1235 argc = odph_parse_options(argc, argv);
1236 if (odph_options(&helper_options)) {
1237 ODPH_ERR("Reading ODP helper options failed.\n");
1238 exit(EXIT_FAILURE);
1239 }
1240
1241 odp_init_param_init(&init_param);
1242 init_param.mem_model = helper_options.mem_model;
1243
1244 memset(&cargs, 0, sizeof(cargs));
1245
1246 /* Parse and store the application arguments */
1247 parse_args(argc, argv, &cargs);
1248
1249 /* Init ODP before calling anything else */
1250 if (odp_init_global(&instance, &init_param, NULL)) {
1251 ODPH_ERR("ODP global init failed.\n");
1252 exit(EXIT_FAILURE);
1253 }
1254
1255 /* Init this thread */
1257
1259 memset(&crypto_capa, 0, sizeof(crypto_capa));
1260
1261 if (odp_crypto_capability(&crypto_capa)) {
1262 ODPH_ERR("Crypto capability request failed.\n");
1263 exit(EXIT_FAILURE);
1264 }
1265
1266 if (cargs.schedule && crypto_capa.queue_type_sched == 0) {
1267 ODPH_ERR("scheduled type completion queue not supported.\n");
1268 exit(EXIT_FAILURE);
1269 }
1270
1271 if (cargs.poll && crypto_capa.queue_type_plain == 0) {
1272 ODPH_ERR("plain type completion queue not supported.\n");
1273 exit(EXIT_FAILURE);
1274 }
1275
1276 if (odp_pool_capability(&pool_capa)) {
1277 ODPH_ERR("Pool capability request failed.\n");
1278 exit(EXIT_FAILURE);
1279 }
1280
1281 max_seg_len = pool_capa.pkt.max_seg_len;
1282
1283 for (i = 0; i < ODPH_ARRAY_SIZE(payloads); i++) {
1284 if (payloads[i] + MAX_AUTH_DIGEST_LEN > max_seg_len)
1285 break;
1286 }
1287
1288 num_payloads = i;
1289
1290 /* Create packet pool */
1291 odp_pool_param_init(&params);
1292 params.pkt.seg_len = max_seg_len;
1293 params.pkt.len = max_seg_len;
1294 params.pkt.num = POOL_NUM_PKT;
1295 params.type = ODP_POOL_PACKET;
1296 pool = odp_pool_create("packet_pool", &params);
1297
1298 if (pool == ODP_POOL_INVALID) {
1299 ODPH_ERR("packet pool create failed.\n");
1300 exit(EXIT_FAILURE);
1301 }
1302 odp_pool_print(pool);
1303
1304 odp_queue_param_init(&qparam);
1305 if (cargs.schedule) {
1306 odp_schedule_config(NULL);
1307 qparam.type = ODP_QUEUE_TYPE_SCHED;
1311 out_queue = odp_queue_create("crypto-out", &qparam);
1312 } else if (cargs.poll) {
1313 qparam.type = ODP_QUEUE_TYPE_PLAIN;
1314 out_queue = odp_queue_create("crypto-out", &qparam);
1315 }
1316 if (cargs.schedule || cargs.poll) {
1317 if (out_queue == ODP_QUEUE_INVALID) {
1318 ODPH_ERR("crypto-out queue create failed.\n");
1319 exit(EXIT_FAILURE);
1320 }
1321 }
1322
1323 if (cargs.schedule) {
1324 printf("Run in async scheduled mode\n");
1325 num_workers = odp_cpumask_default_worker(&cpumask,
1326 num_workers);
1327 (void)odp_cpumask_to_str(&cpumask, cpumaskstr,
1328 sizeof(cpumaskstr));
1329 printf("num worker threads: %i\n",
1330 num_workers);
1331 printf("first CPU: %i\n",
1332 odp_cpumask_first(&cpumask));
1333 printf("cpu mask: %s\n",
1334 cpumaskstr);
1335 } else if (cargs.poll) {
1336 printf("Run in async poll mode\n");
1337 } else {
1338 printf("Run in sync mode\n");
1339 }
1340
1341 test_run_arg.crypto_args = cargs;
1342 test_run_arg.crypto_alg_config = cargs.alg_config;
1343 test_run_arg.crypto_capa = crypto_capa;
1344
1345 if (cargs.alg_config) {
1346 odph_thread_common_param_init(&thr_common);
1347 thr_common.instance = instance;
1348 thr_common.cpumask = &cpumask;
1349 thr_common.share_param = 1;
1350
1351 if (cargs.schedule) {
1352 odph_thread_param_init(&thr_param);
1353 thr_param.start = run_thr_func;
1354 thr_param.arg = &test_run_arg;
1355 thr_param.thr_type = ODP_THREAD_WORKER;
1356
1357 memset(thread_tbl, 0, sizeof(thread_tbl));
1358 odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers);
1359
1360 odph_thread_join(thread_tbl, num_workers);
1361 } else {
1362 run_measure_one_config(&test_run_arg);
1363 }
1364 } else {
1365 for (i = 0; i < ODPH_ARRAY_SIZE(algs_config); i++) {
1366 test_run_arg.crypto_alg_config = algs_config + i;
1367 run_measure_one_config(&test_run_arg);
1368 }
1369 }
1370
1371 if (cargs.schedule || cargs.poll)
1372 odp_queue_destroy(out_queue);
1373 if (odp_pool_destroy(pool)) {
1374 ODPH_ERR("Error: pool destroy\n");
1375 exit(EXIT_FAILURE);
1376 }
1377
1378 if (odp_term_local()) {
1379 ODPH_ERR("Error: term local\n");
1380 exit(EXIT_FAILURE);
1381 }
1382
1383 if (odp_term_global(instance)) {
1384 ODPH_ERR("Error: term global\n");
1385 exit(EXIT_FAILURE);
1386 }
1387
1388 return 0;
1389}
1390
1391static void parse_args(int argc, char *argv[], crypto_args_t *cargs)
1392{
1393 int opt;
1394 static const struct option longopts[] = {
1395 {"algorithm", optional_argument, NULL, 'a'},
1396 {"debug", no_argument, NULL, 'd'},
1397 {"flight", optional_argument, NULL, 'f'},
1398 {"help", no_argument, NULL, 'h'},
1399 {"iterations", optional_argument, NULL, 'i'},
1400 {"payload", optional_argument, NULL, 'l'},
1401 {"sessions", optional_argument, NULL, 'm'},
1402 {"reuse", no_argument, NULL, 'r'},
1403 {"poll", no_argument, NULL, 'p'},
1404 {"schedule", no_argument, NULL, 's'},
1405 {NULL, 0, NULL, 0}
1406 };
1407
1408 static const char *shortopts = "+a:c:df:hi:m:l:spr";
1409
1410 cargs->in_flight = 1;
1411 cargs->debug_packets = 0;
1412 cargs->iteration_count = 10000;
1413 cargs->payload_length = 0;
1414 cargs->alg_config = NULL;
1415 cargs->reuse_packet = 0;
1416 cargs->schedule = 0;
1417
1418 while (1) {
1419 opt = getopt_long(argc, argv, shortopts, longopts, NULL);
1420
1421 if (opt == -1)
1422 break; /* No more options */
1423
1424 switch (opt) {
1425 case 'a':
1426 cargs->alg_config = find_config_by_name(optarg);
1427 if (!cargs->alg_config) {
1428 printf("cannot test crypto '%s' configuration\n",
1429 optarg);
1430 usage(argv[0]);
1431 exit(-1);
1432 }
1433 break;
1434 case 'd':
1435 cargs->debug_packets = 1;
1436 break;
1437 case 'i':
1438 cargs->iteration_count = atoi(optarg);
1439 break;
1440 case 'f':
1441 cargs->in_flight = atoi(optarg);
1442 break;
1443 case 'h':
1444 usage(argv[0]);
1445 exit(EXIT_SUCCESS);
1446 break;
1447 case 'm':
1448 cargs->max_sessions = atoi(optarg);
1449 break;
1450 case 'l':
1451 cargs->payload_length = atoi(optarg);
1452 break;
1453 case 'r':
1454 cargs->reuse_packet = 1;
1455 break;
1456 case 's':
1457 cargs->schedule = 1;
1458 break;
1459 case 'p':
1460 cargs->poll = 1;
1461 break;
1462 default:
1463 break;
1464 }
1465 }
1466
1467 optind = 1; /* reset 'extern optind' from the getopt lib */
1468
1469 if ((cargs->in_flight > 1) && cargs->reuse_packet) {
1470 printf("-f (in flight > 1) and -r (reuse packet) options are not compatible\n");
1471 usage(argv[0]);
1472 exit(-1);
1473 }
1474 if (cargs->schedule && cargs->poll) {
1475 printf("-s (schedule) and -p (poll) options are not compatible\n");
1476 usage(argv[0]);
1477 exit(-1);
1478 }
1479}
1480
1484static void usage(char *progname)
1485{
1486 printf("\n"
1487 "Usage: %s OPTIONS\n"
1488 " E.g. %s -i 100000\n"
1489 "\n"
1490 "OpenDataPlane crypto speed measure.\n"
1491 "Optional OPTIONS\n"
1492 " -a, --algorithm <name> Specify algorithm name (default all)\n"
1493 " Supported values are:\n",
1494 progname, progname);
1495
1496 print_config_names(" ");
1497 printf(" -d, --debug Enable dump of processed packets.\n"
1498 " -f, --flight <number> Max number of packet processed in parallel (default 1)\n"
1499 " -i, --iterations <number> Number of iterations.\n"
1500 " -l, --payload Payload length.\n"
1501 " -r, --reuse Output encrypted packet is passed as input\n"
1502 " to next encrypt iteration.\n"
1503 " -s, --schedule Use scheduler for completion events.\n"
1504 " -p, --poll Poll completion queue for completion events.\n"
1505 " -h, --help Display help and exit.\n"
1506 "\n");
1507}
#define odp_unlikely(x)
Branch unlikely taken.
Definition spec/hints.h:64
int odp_cpumask_default_worker(odp_cpumask_t *mask, int num)
Default CPU mask for worker threads.
int odp_cpumask_first(const odp_cpumask_t *mask)
Find first set CPU in mask.
int32_t odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int32_t size)
Format a string from CPU mask.
#define ODP_CPUMASK_STR_SIZE
The maximum number of characters needed to record any CPU mask as a string (output of odp_cpumask_to_...
int odp_crypto_cipher_capability(odp_cipher_alg_t cipher, odp_crypto_cipher_capability_t capa[], int num)
Query supported cipher algorithm capabilities.
odp_cipher_alg_t
Crypto API cipher algorithm.
int odp_crypto_capability(odp_crypto_capability_t *capa)
Query crypto capabilities.
void odp_crypto_session_param_init(odp_crypto_session_param_t *param)
Initialize crypto session parameters.
uint64_t odp_crypto_session_t
Crypto API opaque session handle.
int odp_crypto_session_create(const odp_crypto_session_param_t *param, odp_crypto_session_t *session, odp_crypto_ses_create_err_t *status)
Crypto session creation.
int odp_crypto_result(odp_crypto_packet_result_t *result, odp_packet_t packet)
Get crypto operation results from a crypto processed packet.
int odp_crypto_session_destroy(odp_crypto_session_t session)
Crypto session destroy.
int odp_crypto_op(const odp_packet_t pkt_in[], odp_packet_t pkt_out[], const odp_crypto_packet_op_param_t param[], int num_pkt)
Crypto packet operation.
odp_auth_alg_t
Crypto API authentication algorithm.
odp_crypto_ses_create_err_t
Crypto API session creation return code.
odp_packet_t odp_crypto_packet_from_event(odp_event_t ev)
Return crypto processed packet that is associated with event.
int odp_crypto_op_enq(const odp_packet_t pkt_in[], const odp_packet_t pkt_out[], const odp_crypto_packet_op_param_t param[], int num_pkt)
Crypto packet operation.
int odp_crypto_auth_capability(odp_auth_alg_t auth, odp_crypto_auth_capability_t capa[], int num)
Query supported authentication algorithm capabilities.
@ ODP_CIPHER_ALG_SNOW3G_UEA2
Confidentiality UEA2 algorithm (128-EEA1)
@ ODP_CIPHER_ALG_AES_CCM
AES-CCM.
@ ODP_CIPHER_ALG_AES_CTR
AES with counter mode.
@ ODP_CIPHER_ALG_CHACHA20_POLY1305
ChaCha20-Poly1305.
@ ODP_CIPHER_ALG_AES_CBC
AES with cipher block chaining.
@ ODP_CIPHER_ALG_AES_GCM
AES-GCM.
@ ODP_CIPHER_ALG_3DES_CBC
Triple DES with cipher block chaining.
@ ODP_CIPHER_ALG_DES
DES.
@ ODP_CIPHER_ALG_NULL
No cipher algorithm specified.
@ ODP_CIPHER_ALG_ZUC_EEA3
ZUC based confidentiality algorithm.
@ ODP_CRYPTO_OP_TYPE_BASIC
Input packet data and metadata are copied to the output packet and then processed.
@ ODP_AUTH_ALG_SHA384_HMAC
HMAC-SHA-384.
@ ODP_AUTH_ALG_CHACHA20_POLY1305
ChaCha20-Poly1305 AEAD.
@ ODP_AUTH_ALG_NULL
No authentication algorithm specified.
@ ODP_AUTH_ALG_MD5_HMAC
HMAC-MD5.
@ ODP_AUTH_ALG_SHA512_HMAC
HMAC-SHA-512.
@ ODP_AUTH_ALG_SHA1_HMAC
HMAC-SHA-1.
@ ODP_AUTH_ALG_SHA256_HMAC
HMAC-SHA-256.
@ ODP_AUTH_ALG_SNOW3G_UIA2
Integrity UIA2 algorithm (128-EIA1)
@ ODP_AUTH_ALG_AES_GMAC
AES-GMAC.
@ ODP_AUTH_ALG_AES_GCM
AES-GCM.
@ ODP_AUTH_ALG_AES_CCM
AES-CCM.
@ ODP_AUTH_ALG_ZUC_EIA3
ZUC-based integrity algorithm.
@ ODP_CRYPTO_SES_ERR_ALG_COMBO
Unsupported combination of algorithms.
@ ODP_CRYPTO_SES_ERR_ALG_ORDER
Unsupported order of cipher and auth.
@ ODP_CRYPTO_SES_ERR_PARAMS
Unsupported combination of session creation parameters.
@ ODP_CRYPTO_OP_ENCODE
Encrypt and/or compute authentication ICV.
@ ODP_CRYPTO_SYNC
Synchronous, return results immediately.
@ ODP_CRYPTO_ASYNC
Asynchronous, return results via posted event.
#define ODP_EVENT_INVALID
Invalid event.
void odp_init_param_init(odp_init_t *param)
Initialize the odp_init_t to default values for all fields.
int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
Thread local ODP initialization.
int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params)
Global ODP initialization.
int odp_term_local(void)
Thread local ODP termination.
int odp_term_global(odp_instance_t instance)
Global ODP termination.
uint64_t odp_instance_t
ODP instance ID.
void * odp_packet_data(odp_packet_t pkt)
Packet data pointer.
odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len)
Allocate a packet from a packet pool.
void odp_packet_free(odp_packet_t pkt)
Free packet.
#define ODP_PACKET_INVALID
Invalid packet.
odp_pool_t odp_pool_create(const char *name, const odp_pool_param_t *param)
Create a pool.
int odp_pool_capability(odp_pool_capability_t *capa)
Query pool capabilities.
void odp_pool_param_init(odp_pool_param_t *param)
Initialize pool params.
int odp_pool_destroy(odp_pool_t pool)
Destroy a pool previously created by odp_pool_create()
void odp_pool_print(odp_pool_t pool)
Print pool info.
odp_pool_t odp_pool_lookup(const char *name)
Find a pool by name.
#define ODP_POOL_INVALID
Invalid pool.
@ ODP_POOL_PACKET
Packet pool.
odp_queue_t odp_queue_lookup(const char *name)
Find a queue by name.
void odp_queue_param_init(odp_queue_param_t *param)
Initialize queue params.
#define ODP_QUEUE_INVALID
Invalid queue.
odp_event_t odp_queue_deq(odp_queue_t queue)
Dequeue an event from a queue.
odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param)
Queue create.
int odp_queue_destroy(odp_queue_t queue)
Destroy ODP queue.
@ ODP_QUEUE_TYPE_SCHED
Scheduled queue.
@ ODP_QUEUE_TYPE_PLAIN
Plain queue.
#define ODP_SCHED_SYNC_PARALLEL
Parallel scheduled queues.
#define ODP_SCHED_NO_WAIT
Do not wait.
int odp_schedule_default_prio(void)
Default scheduling priority level.
int odp_schedule_config(const odp_schedule_config_t *config)
Global schedule configuration.
odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait)
Schedule an event.
#define ODP_SCHED_GROUP_ALL
Group of all threads.
void odp_sys_info_print(void)
Print system info.
@ ODP_THREAD_WORKER
Worker thread.
The OpenDataPlane API.
Authentication algorithm capabilities.
struct odp_crypto_auth_capability_t::@26 aad_len
Additional Authenticated Data (AAD) lengths.
uint32_t min
Minimum AAD length in bytes.
uint32_t max
Maximum AAD length in bytes.
odp_bool_t bit_mode
Auth algorithm supports bit mode.
uint32_t inc
Increment of supported lengths between min and max (in bytes)
uint32_t digest_len
Digest length in bytes.
uint32_t key_len
Key length in bytes.
uint32_t iv_len
IV length in bytes.
odp_bool_t queue_type_sched
Scheduled crypto completion queue support.
odp_crypto_cipher_algos_t ciphers
Supported cipher algorithms.
odp_bool_t queue_type_plain
Plain crypto completion queue support.
odp_crypto_auth_algos_t auths
Supported authentication algorithms.
Cipher algorithm capabilities.
odp_bool_t bit_mode
Cipher supports bit mode.
uint32_t key_len
Key length in bytes.
uint32_t iv_len
IV length in bytes.
uint32_t length
Key length in bytes.
Crypto packet API per packet operation parameters.
uint32_t hash_result_offset
Offset from start of packet for hash result.
const uint8_t * aad_ptr
Pointer to AAD.
const uint8_t * cipher_iv_ptr
IV pointer for cipher.
const uint8_t * auth_iv_ptr
IV pointer for authentication.
odp_packet_data_range_t cipher_range
Data range to be ciphered.
odp_crypto_session_t session
Session handle from creation.
odp_packet_data_range_t auth_range
Data range to be authenticated.
Crypto API session creation parameters.
odp_bool_t auth_cipher_text
Authenticate cipher vs.
odp_crypto_key_t auth_key
Authentication key.
uint32_t auth_aad_len
Additional Authenticated Data (AAD) length in bytes.
odp_crypto_op_type_t op_type
Crypto operation type.
odp_crypto_key_t cipher_key
Cipher key.
odp_queue_t compl_queue
Async mode completion event queue.
uint32_t cipher_iv_len
Cipher IV length.
uint32_t auth_digest_len
Authentication digest length in bytes.
odp_auth_alg_t auth_alg
Authentication algorithm.
odp_crypto_op_mode_t op_mode
Operation mode when using packet interface: sync or async.
odp_cipher_alg_t cipher_alg
Cipher algorithm.
uint32_t auth_iv_len
Authentication IV length.
odp_crypto_op_t op
Encode vs.
Global initialization parameters.
odp_mem_model_t mem_model
Application memory model.
uint32_t offset
Offset from beginning of packet.
uint32_t length
Length of data to operate on.
struct odp_pool_capability_t::@134 pkt
Packet pool capabilities
uint32_t max_seg_len
Maximum packet segment data length in bytes.
uint32_t num
Number of buffers in the pool.
struct odp_pool_param_t::@139 pkt
Parameters for packet pools.
odp_pool_type_t type
Pool type.
uint32_t len
Minimum length of 'num' packets.
uint32_t seg_len
Minimum number of packet data bytes that can be stored in the first segment of a newly allocated pack...
ODP Queue parameters.
odp_schedule_param_t sched
Scheduler parameters.
odp_queue_type_t type
Queue type.
odp_schedule_group_t group
Thread group.
odp_schedule_prio_t prio
Priority level.
odp_schedule_sync_t sync
Synchronization method.
uint32_t null
ODP_AUTH_ALG_NULL.
uint32_t sha1_hmac
ODP_AUTH_ALG_SHA1_HMAC.
uint32_t sha512_hmac
ODP_AUTH_ALG_SHA512_HMAC.
uint32_t zuc_eia3
ODP_AUTH_ALG_ZUC_EIA3.
uint32_t snow3g_uia2
ODP_AUTH_ALG_SNOW3G_UIA2.
uint32_t aes_gmac
ODP_AUTH_ALG_AES_GMAC.
uint32_t aes_gcm
ODP_AUTH_ALG_AES_GCM.
uint32_t md5_hmac
ODP_AUTH_ALG_MD5_HMAC.
uint32_t sha384_hmac
ODP_AUTH_ALG_SHA384_HMAC.
uint32_t sha256_hmac
ODP_AUTH_ALG_SHA256_HMAC.
uint32_t chacha20_poly1305
ODP_AUTH_ALG_CHACHA20_POLY1305.
struct odp_crypto_auth_algos_t::@25 bit
Authentication algorithms.
uint32_t aes_ccm
ODP_AUTH_ALG_AES_CCM.
struct odp_crypto_cipher_algos_t::@24 bit
Cipher algorithms.
uint32_t aes_gcm
ODP_CIPHER_ALG_AES_GCM.
uint32_t trides_cbc
ODP_CIPHER_ALG_3DES_CBC.
uint32_t aes_ctr
ODP_CIPHER_ALG_AES_CTR.
uint32_t aes_cbc
ODP_CIPHER_ALG_AES_CBC.
uint32_t des
ODP_CIPHER_ALG_DES.
uint32_t zuc_eea3
ODP_CIPHER_ALG_ZUC_EEA3.
uint32_t null
ODP_CIPHER_ALG_NULL.
uint32_t chacha20_poly1305
ODP_CIPHER_ALG_CHACHA20_POLY1305.
uint32_t snow3g_uea2
ODP_CIPHER_ALG_SNOW3G_UEA2.
uint32_t aes_ccm
ODP_CIPHER_ALG_AES_CCM.