1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* Copyright (c) 2014, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <odp_api.h>
#include <odp_cunit_common.h>
#include "odp_crypto_test_inp.h"
#include "crypto.h"
#define SHM_PKT_POOL_SIZE (512 * 2048 * 2)
#define SHM_PKT_POOL_BUF_SIZE (1024 * 32)
#define SHM_COMPL_POOL_SIZE (128 * 1024)
#define SHM_COMPL_POOL_BUF_SIZE 128
odp_suiteinfo_t crypto_suites[] = {
{ODP_CRYPTO_SYNC_INP, crypto_suite_sync_init, NULL, crypto_suite},
{ODP_CRYPTO_ASYNC_INP, crypto_suite_async_init, NULL, crypto_suite},
ODP_SUITE_INFO_NULL,
};
int crypto_init(odp_instance_t *inst)
{
odp_pool_param_t params;
odp_pool_t pool;
odp_queue_t out_queue;
odp_pool_capability_t pool_capa;
if (0 != odp_init_global(inst, NULL, NULL)) {
fprintf(stderr, "error: odp_init_global() failed.\n");
return -1;
}
if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) {
fprintf(stderr, "error: odp_init_local() failed.\n");
return -1;
}
if (odp_pool_capability(&pool_capa) < 0) {
fprintf(stderr, "error: odp_pool_capability() failed.\n");
return -1;
}
memset(¶ms, 0, sizeof(params));
params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE;
params.pkt.len = SHM_PKT_POOL_BUF_SIZE;
params.pkt.num = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUF_SIZE;
params.type = ODP_POOL_PACKET;
if (SHM_PKT_POOL_BUF_SIZE > pool_capa.pkt.max_len)
params.pkt.len = pool_capa.pkt.max_len;
pool = odp_pool_create("packet_pool", ¶ms);
if (ODP_POOL_INVALID == pool) {
fprintf(stderr, "Packet pool creation failed.\n");
return -1;
}
out_queue = odp_queue_create("crypto-out", NULL);
if (ODP_QUEUE_INVALID == out_queue) {
fprintf(stderr, "Crypto outq creation failed.\n");
return -1;
}
return 0;
}
int crypto_term(odp_instance_t inst)
{
odp_pool_t pool;
odp_queue_t out_queue;
out_queue = odp_queue_lookup("crypto-out");
if (ODP_QUEUE_INVALID != out_queue) {
if (odp_queue_destroy(out_queue))
fprintf(stderr, "Crypto outq destroy failed.\n");
} else {
fprintf(stderr, "Crypto outq not found.\n");
}
pool = odp_pool_lookup("packet_pool");
if (ODP_POOL_INVALID != pool) {
if (odp_pool_destroy(pool))
fprintf(stderr, "Packet pool destroy failed.\n");
} else {
fprintf(stderr, "Packet pool not found.\n");
}
if (0 != odp_term_local()) {
fprintf(stderr, "error: odp_term_local() failed.\n");
return -1;
}
if (0 != odp_term_global(inst)) {
fprintf(stderr, "error: odp_term_global() failed.\n");
return -1;
}
return 0;
}
int crypto_main(int argc, char *argv[])
{
int ret;
/* parse common options: */
if (odp_cunit_parse_options(argc, argv))
return -1;
odp_cunit_register_global_init(crypto_init);
odp_cunit_register_global_term(crypto_term);
ret = odp_cunit_register(crypto_suites);
if (ret == 0)
ret = odp_cunit_run();
return ret;
}
|